@sreetej510/pi-shipd-checks 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -4
- package/dist/index.js +21 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,6 +47,8 @@ The two finder flags are additive/combinable; `--config` must be used alone.
|
|
|
47
47
|
| `/checks --gap-finder` | Find gaps sentence-by-sentence, then review them for fairness |
|
|
48
48
|
| `/checks --solver-gap-finder` | Run several solver agents TDD-style against `agent_prompt.md` + `test.patch`, then compare their solutions to the real solution to find gaps |
|
|
49
49
|
| `/checks --config` | Configure behavioral and solver gap-finder models |
|
|
50
|
+
| `/analyze:on` | Enable the agent-callable Gap Finder tool for the current project |
|
|
51
|
+
| `/analyze:off` | Disable the agent-callable Gap Finder tool for the current project |
|
|
50
52
|
|
|
51
53
|
**Shortcut:** `Ctrl+Shift+X` cancels an in-progress `/checks` run.
|
|
52
54
|
|
|
@@ -58,12 +60,20 @@ The two finder flags are additive/combinable; `--config` must be used alone.
|
|
|
58
60
|
solver-solution comparison agent.
|
|
59
61
|
- **Solver**: model and thinking level for TDD solver agents, plus their timeout, parallel solver
|
|
60
62
|
count, and artifact-saving setting.
|
|
61
|
-
- **Analyze Tool**:
|
|
62
|
-
|
|
63
|
+
- **Analyze Tool**: pick the model + thinking level for the agent-callable Gap Finder tool.
|
|
64
|
+
|
|
65
|
+
Use `/analyze:on` and `/analyze:off` to control the tool per project, like HPC. The enabled project
|
|
66
|
+
list is stored alongside the other settings in `~/.pi/agent/checks-config.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"enabledProjects": ["/path/to/project"]
|
|
71
|
+
}
|
|
72
|
+
```
|
|
63
73
|
|
|
64
74
|
Use ↑/↓ to select a row and Enter/Space to change it. The currently selected model is shown first
|
|
65
|
-
in its picker.
|
|
66
|
-
under `solverGap` and analyze-tool settings under `analyzeGap`.
|
|
75
|
+
in its picker. Model settings are saved to `~/.pi/agent/checks-config.json`; solver settings are nested
|
|
76
|
+
under `solverGap` and analyze-tool model settings under `analyzeGap`.
|
|
67
77
|
|
|
68
78
|
## Install
|
|
69
79
|
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Zf=Object.defineProperty;var St=(e,t)=>{for(var n in t)Zf(e,n,{get:t[n],enumerable:!0})};import{Container as Qv,Key as e$,Spacer as t$,Text as xi}from"@earendil-works/pi-tui";import{randomUUID as Gf}from"node:crypto";import{copyFileSync as zv,existsSync as Nf,mkdirSync as _f,rmSync as Bv,writeFileSync as Vv}from"node:fs";import{tmpdir as Uf}from"node:os";import{join as et}from"node:path";import{getSettingsListTheme as Wv}from"@earendil-works/pi-coding-agent";import{Container as Hv,Key as zt,matchesKey as Bt,Spacer as Yv,Text as Kf}from"@earendil-works/pi-tui";import{createAgentSession as Sa,SessionManager as Oa}from"@earendil-works/pi-coding-agent";import{copyFileSync as eh,existsSync as Qa,lstatSync as th,mkdirSync as eo,readFileSync as Ir,rmSync as Gi,symlinkSync as nh,unlinkSync as rh,writeFileSync as ot}from"node:fs";import{join as fe}from"node:path";import{existsSync as Wt,mkdirSync as wi,readFileSync as cr,writeFileSync as Ei}from"node:fs";import{dirname as Ri,join as Si}from"node:path";import{getAgentDir as Oi}from"@earendil-works/pi-coding-agent";var ft=Si(Oi(),"checks-config.json"),ur=Si(Oi(),"settings.json"),Pi=10,Ai=60,Wa=20,Ha=1,Ci=5,Ya=3,Ja=!0,Mi=!1,Xf=["off","minimal","low","medium","high","xhigh","max"];function Li(e){return e?.reasoning?Xf.filter(t=>{let n=e.thinkingLevelMap?.[t];return n===null?!1:t==="xhigh"||t==="max"?n!==void 0:!0}):["off"]}function ve(){try{if(!Wt(ft))return null;let e=JSON.parse(cr(ft,"utf-8"));if(e.provider&&e.modelId&&e.thinkingLevel)return e}catch{}return null}function Fe(e){let t=Ri(ft);Wt(t)||wi(t,{recursive:!0}),Ei(ft,JSON.stringify(e,null,2),"utf-8")}function qi(){let e=ve()?.solverGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e,timeoutMinutes:e.timeoutMinutes>0?e.timeoutMinutes:Wa,solverCount:e.solverCount>0?e.solverCount:Ya,saveArtifacts:typeof e.saveArtifacts=="boolean"?e.saveArtifacts:Ja}}function Za(){try{if(!Wt(ft))return{};let e=JSON.parse(cr(ft,"utf-8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Xa(){let e=Za().enabledProjects;return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function lr(e){let t=Za();return Array.isArray(t.enabledProjects)?t.enabledProjects.some(n=>n===e):ve()?.enableAnalyzeTool??Mi}function dr(e,t){let n=new Set(Xa());t?n.add(e):n.delete(e);let r=[...n],a=ve();if(a){Fe({...a,enabledProjects:r});return}let i=Ri(ft);Wt(i)||wi(i,{recursive:!0}),Ei(ft,JSON.stringify({...Za(),enabledProjects:r},null,2),"utf-8")}function fr(e){return e!==void 0?lr(e):ve()?.enableAnalyzeTool??Mi}function ji(){let e=ve()?.analyzeGap;return!e?.provider||!e.modelId||!e.thinkingLevel?null:{...e}}function Fi(){try{return Wt(ur)?JSON.parse(cr(ur,"utf-8")).enabledModels??[]:[]}catch{return[]}}function Di(e){let t=e.indexOf("/");return t<=0||t===e.length-1?null:{provider:e.slice(0,t),modelId:e.slice(t+1)}}function Qf(){try{if(Wt(ur))return JSON.parse(cr(ur,"utf-8"))}catch{}return{}}function hr(){let e=Qf().shellPath;return e||(process.platform==="win32"?"C:\\Program Files\\Git\\bin\\bash.exe":"bash")}function gr(e){return e.replace(/\\/g,"/")}function yr(e){return`'${e.replace(/'/g,"'\\''")}'`}async function xr(e,t,n){if((await e.exec("git",["rev-parse","HEAD"],{cwd:t,timeout:15e3})).code!==0)return{status:"error",error:"Not a git repository, or it has no commits yet."};let a=`git archive HEAD | tar -x -C ${yr(gr(n))}`,i=await e.exec(hr(),["-c",a],{cwd:t,timeout:6e4});return i.code!==0?{status:"error",error:i.stderr?.trim()||`git archive failed (exit ${i.code})`}:{status:"ok"}}var to=3e4,ah=4e3,oh=".pi/shipd-checks",vn="solver_gap_solutions";function ih(e){let t=new Set,n=/^diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/gm;for(let r of e.matchAll(n))r[1]&&t.add(r[1]),r[2]&&t.add(r[2]);return[...t]}function sh(e,t){return e.length>t?e.slice(e.length-t):e}async function Ni(e){let{pi:t,repoDir:n,solverDir:r,testPatchPath:a,agentPromptPath:i}=e,m=await xr(t,n,r);if(m.status==="error")return{status:"error",solverDir:r,error:m.error};let u={cwd:r,timeout:to},l=await t.exec("git",["init"],u);if(l.code!==0)return{status:"error",solverDir:r,error:l.stderr?.trim()||"git init failed"};await t.exec("git",["config","user.email","solvergap@shipd-checks.local"],u),await t.exec("git",["config","user.name","shipd-checks solver-gap-finder"],u);let f=await t.exec("git",["add","-A"],u);if(f.code!==0)return{status:"error",solverDir:r,error:f.stderr?.trim()||"git add (baseline) failed"};let h=await t.exec("git",["commit","-m","baseline","--allow-empty"],u);if(h.code!==0)return{status:"error",solverDir:r,error:h.stderr?.trim()||"git commit (baseline) failed"};let $=fe(r,".gitignore"),E=Qa($)?Ir($,"utf-8"):"";if(!E.split(/\r?\n/).some(ct=>ct.trim()==="node_modules")){let ct=E.length>0&&!E.endsWith(`
|
|
2
2
|
`)?`
|
|
3
3
|
`:"";ot($,`${E}${ct}node_modules
|
|
4
|
-
`,"utf-8")}let A=fe(n,"node_modules"),H=fe(r,"node_modules");if(
|
|
5
|
-
${ne.stderr}`.trim(),Qf),{totalTests:N,failedTests:nt}=rh(A);return{index:n,status:a,passed:ue,diff:E,testOutputTail:tt,durationMs:i,totalTests:N,failedTests:nt,testOutputXmlPath:A}}function Mi(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=fe(t,eh,n,`solver_${r}`);Ya(l,{recursive:!0}),ot(fe(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),ot(fe(l,"solution.patch"),i,"utf-8");try{let f=gr(m,"utf-8");ot(fe(l,"test_output.xml"),f,"utf-8")}catch{ot(fe(l,"test_output.txt"),u,"utf-8")}return l}function Li(e,t){let n=fe(e,In);Ya(n,{recursive:!0});let r=t.map(a=>{let i=fe(n,`solver_${a.index}`);return Ya(i,{recursive:!0}),ot(fe(i,"solution.diff"),a.diff,"utf-8"),ot(fe(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return ot(fe(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function qi(e){let t=fe(e,"node_modules");try{Jf(t).isSymbolicLink()&&Pi(t,{force:!0})}catch{}try{Pi(e,{recursive:!0,force:!0})}catch{}}var p={};Rt(p,{Assign:()=>ah,Clone:()=>Tn,Create:()=>ug,Discard:()=>cg,Metrics:()=>De,Update:()=>lg});var De={assign:0,create:0,clone:0,discard:0,update:0};function ah(e,t){return De.assign+=1,{...e,...t}}var s={};Rt(s,{Entries:()=>wh,EntriesRegExp:()=>kh,Every:()=>vh,EveryAll:()=>$h,GraphemeCount:()=>xh,HasPropertyKey:()=>Th,IsArray:()=>vn,IsBigInt:()=>bn,IsBoolean:()=>zi,IsClassInstance:()=>gh,IsConstructor:()=>uh,IsDeepEqual:()=>eo,IsEqual:()=>M,IsFunction:()=>Bi,IsGreaterEqualThan:()=>Wi,IsGreaterThan:()=>dh,IsInteger:()=>Xa,IsLessEqualThan:()=>Vi,IsLessThan:()=>fh,IsMaxLength:()=>Ih,IsMinLength:()=>bh,IsMultipleOf:()=>hh,IsNull:()=>Ir,IsNumber:()=>br,IsObject:()=>$n,IsObjectNotArray:()=>ch,IsString:()=>vr,IsSymbol:()=>lh,IsUndefined:()=>Qa,IsUnsafePropertyKey:()=>Hi,IsValueLike:()=>yh,Keys:()=>xr,ShiftLeft:()=>$r,Symbols:()=>Eh,Values:()=>Rh});function St(e,t,n){return e>=t&&e<=n}function oh(e){return e===8205}function ih(e){return St(e,55296,56319)}function ji(e){return St(e,127462,127487)}function Di(e){return St(e,65024,65039)}function Gi(e){return St(e,768,879)||St(e,6832,6911)||St(e,7616,7679)||St(e,65056,65071)}function yr(e){return e>65535?2:1}function Fi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Gi(n)||Di(n))t+=yr(n);else break}return t}function Za(e,t){let n=e.codePointAt(t),r=t+yr(n);for(r=Fi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+yr(a),r=Fi(e,r)}return ji(n)&&r<e.length&&ji(e.codePointAt(r))&&(r+=yr(e.codePointAt(r))),r}function Ni(e){return ih(e)||Gi(e)||Di(e)||oh(e)}function Ui(e){let t=0,n=0;for(;n<e.length;)n=Za(e,n),t++;return t}function sh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=Za(e,r),n++,n>=t)return!0;return!1}function mh(e,t){let n=0,r=0;for(;r<e.length;)if(r=Za(e,r),n++,n>t)return!1;return!0}function _i(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Ni(e.charCodeAt(n)))return sh(e,t);if(n++,n>=t)return!0}return!1}function Ki(e,t){let n=0;for(;n<e.length;){if(Ni(e.charCodeAt(n)))return mh(e,t);if(n++,n>t)return!1}return!0}function vn(e){return Array.isArray(e)}function bn(e){return M(typeof e,"bigint")}function zi(e){return M(typeof e,"boolean")}function uh(e){if(Qa(e)||!Bi(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function Bi(e){return M(typeof e,"function")}function Xa(e){return Number.isInteger(e)}function Ir(e){return M(e,null)}function br(e){return Number.isFinite(e)}function ch(e){return $n(e)&&!vn(e)}function $n(e){return M(typeof e,"object")&&!Ir(e)}function vr(e){return M(typeof e,"string")}function lh(e){return M(typeof e,"symbol")}function Qa(e){return M(e,void 0)}function M(e,t){return e===t}function dh(e,t){return e>t}function fh(e,t){return e<t}function Vi(e,t){return e<=t}function Wi(e,t){return e>=t}function hh(e,t){if(bn(e)||bn(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!br(e)||Xa(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function gh(e){if(!$n(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Ir(t)?!1:M(typeof t.constructor,"function")&&!(M(t.constructor,globalThis.Object)||M(t.constructor.name,"Object"))}function yh(e){return bn(e)||zi(e)||Ir(e)||br(e)||vr(e)||Qa(e)}function xh(e){return Ui(e)}function Ih(e,t){return Ki(e,t)}function bh(e,t){return _i(e,t)}function vh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function $h(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function $r(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function Hi(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Th(e,t){return Hi(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function kh(e){return xr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function wh(e){return Object.entries(e)}function xr(e){return Object.getOwnPropertyNames(e)}function Eh(e){return Object.getOwnPropertySymbols(e)}function Rh(e){return Object.values(e)}function Sh(e,t){if(!$n(t))return!1;let n=xr(e);return M(n.length,xr(t).length)&&n.every(r=>eo(e[r],t[r]))}function Oh(e,t){return vn(t)&&M(e.length,t.length)&&e.every((n,r)=>eo(e[r],t[r]))}function eo(e,t){return vn(e)?Oh(e,t):$n(e)?Sh(e,t):M(e,t)}var ft={};Rt(ft,{IsBigInt64Array:()=>zh,IsBigUint64Array:()=>Bh,IsBoolean:()=>Ah,IsDate:()=>Wh,IsFloat32Array:()=>_h,IsFloat64Array:()=>Kh,IsInt16Array:()=>Dh,IsInt32Array:()=>Nh,IsInt8Array:()=>qh,IsMap:()=>Yh,IsNumber:()=>Ch,IsRegExp:()=>Vh,IsSet:()=>Hh,IsString:()=>Mh,IsTypeArray:()=>Lh,IsUint16Array:()=>Gh,IsUint32Array:()=>Uh,IsUint8Array:()=>jh,IsUint8ClampedArray:()=>Fh});function Ah(e){return e instanceof Boolean}function Ch(e){return e instanceof Number}function Mh(e){return e instanceof String}function Lh(e){return globalThis.ArrayBuffer.isView(e)}function qh(e){return e instanceof globalThis.Int8Array}function jh(e){return e instanceof globalThis.Uint8Array}function Fh(e){return e instanceof globalThis.Uint8ClampedArray}function Dh(e){return e instanceof globalThis.Int16Array}function Gh(e){return e instanceof globalThis.Uint16Array}function Nh(e){return e instanceof globalThis.Int32Array}function Uh(e){return e instanceof globalThis.Uint32Array}function _h(e){return e instanceof globalThis.Float32Array}function Kh(e){return e instanceof globalThis.Float64Array}function zh(e){return e instanceof globalThis.BigInt64Array}function Bh(e){return e instanceof globalThis.BigUint64Array}function Vh(e){return e instanceof globalThis.RegExp}function Wh(e){return e instanceof globalThis.Date}function Hh(e){return e instanceof globalThis.Set}function Yh(e){return e instanceof globalThis.Map}function Zh(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function Xh(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let r of Object.keys(n)){if(s.IsUnsafePropertyKey(r))continue;let a=n[r];s.HasPropertyKey(a,"value")&&Object.defineProperty(t,r,{...a,value:Ot(a.value)})}return t}function Qh(e){let t={};for(let n of s.Keys(e))s.IsUnsafePropertyKey(n)||(t[n]=Ot(e[n]));for(let n of s.Symbols(e))t[n]=Ot(e[n]);return t}function eg(e){return s.IsClassInstance(e)?e:Zh(e)?Xh(e):Qh(e)}function tg(e){return e.map(t=>Ot(t))}function ng(e){return e.slice()}function rg(e){return new RegExp(e.source,e.flags)}function ag(e){return new Map(Ot([...e.entries()]))}function og(e){return new Set(Ot([...e.values()]))}function Ot(e){return ft.IsTypeArray(e)?ng(e):ft.IsRegExp(e)?rg(e):ft.IsMap(e)?ag(e):ft.IsSet(e)?og(e):s.IsArray(e)?tg(e):s.IsObject(e)?eg(e):e}function Tn(e){return De.clone+=1,Ot(e)}var Pt={};Rt(Pt,{Get:()=>mg,Reset:()=>ig,Set:()=>sg});var it={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function ig(){it.immutableTypes=!1,it.maxErrors=8,it.useAcceleration=!0,it.exactOptionalPropertyTypes=!1,it.enumerableKind=!1,it.correctiveParse=!1,it.unionPrioritySort=!0}function sg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(it,t,{value:n})}}function mg(){return it}function pg(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function Yi(e,t){return{...e,...t}}function ug(e,t,n={}){De.create+=1;let r=Pt.Get(),a=Yi(t,n),i=r.enumerableKind?Yi(a,e):pg(a,e);return r.immutableTypes?Object.freeze(i):i}function cg(e,t){De.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(Tn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function lg(e,t,n){De.update+=1;let r=Pt.Get(),a=Tn(e);for(let i of Object.keys(t))Object.defineProperty(a,i,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[i]});for(let i of Object.keys(n))Object.defineProperty(a,i,{configurable:!0,enumerable:!0,writable:!0,value:n[i]});return a}function y(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function re(e){return s.IsObject(e)}function I(e,t,n){return p.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function ht(e){return y(e,"Deferred")}function dg(e){return p.Update(e,{"~readonly":!0},{})}function kn(e,t){return p.Update(dg(e),{},t)}function Ji(e,t,n,r){let a=d(e,t,n);return kn(a,r)}function fg(e){return p.Update(e,{"~optional":!0},{})}function wn(e,t){return p.Update(fg(e),{},t)}function Zi(e,t,n,r){let a=d(e,t,n);return wn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function K(e){return y(e,"Array")}function Tr(e){return p.Discard(e,["~kind","type","items"])}function _e(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function Xi(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ke(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function Qi(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function st(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function se(e){return y(e,"Ref")}function gt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Bt(e){return y(e,"Generic")}function Vt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var es="(?!)";function F(e){return p.Create({"~kind":"Never"},{not:{}},e)}function yt(e){return y(e,"Never")}function ze(e,t={}){return I("AddOptional",[e],t)}function At(e,t={}){return wn(e,t)}function ts(e){return At(e)}function he(e){return re(e)&&s.HasPropertyKey(e,"~optional")}function ns(e){return s.Keys(e).filter(t=>!he(e[t]))}function kr(e){return s.Keys(e)}function wr(e){return s.Values(e)}function v(e,t={}){let n=ns(e),r=n.length>0?{required:n}:{};return p.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function L(e){return y(e,"Object")}function rs(e){return p.Discard(e,["~kind","type","properties","required"])}function me(e){return p.Create({"~kind":"Unknown"},{},e)}function ae(e){return y(e,"Unknown")}function Be(e,t,n){let r=s.Keys(e).reduce((a,i)=>({...a,[i]:p.Update(e[i],{},{$id:i})}),{});return p.Create({"~kind":"Cyclic"},{$defs:r,$ref:t},n)}function ce(e){return y(e,"Cyclic")}function as(e){return p.Update(e,{"~unsafe":null},{})}function Er(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ve={};Rt(Ve,{Match:()=>hg});function hg(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function En(...e){let[t,n]=Ve.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,me(),me()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function Y(e){return y(e,"Infer")}function Ct(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function V(e){return y(e,"Dependent")}function os(e){return p.Discard(e,["~kind","if","then","else"])}function is(e){return s.IsObjectNotArray(e)}function ss(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function ms(e){return s.IsString(e)||s.IsNumber(e)}function ps(e,t){let n=is(e)?ss(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function ye(e){return y(e,"Enum")}function ge(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function us(e){return p.Discard(e,["~kind","allOf"])}function J(){throw new Error("Unreachable")}var cs;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(cs||(cs={}));var fk=BigInt("14695981039346656037"),[hk,gk]=[BigInt("1099511628211"),BigInt("18446744073709551616")],yk=Array.from({length:256}).map((e,t)=>BigInt(t)),ls=new Float64Array(1),xk=new DataView(ls.buffer),Ik=new Uint8Array(ls.buffer);var bk=new TextEncoder;var Rn=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Rr(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Rr(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Sn=class{constructor(t){this.type=t}Decode(t){return new Rn(this.type,t)}};function Sr(e){return new Sn(e)}function fs(e,t){return Sr(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function hs(e,t){return Sr(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Rr(e){return re(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function gs(e){return Wt(e)}function Mt(e){return re(e)&&s.HasPropertyKey(e,"~immutable")}function We(e,t={}){return I("AddReadonly",[e],t)}function Lt(e,t={}){return kn(e,t)}function ys(e){return Lt(e)}function qt(e){return re(e)&&s.HasPropertyKey(e,"~readonly")}function Ig(e,t){let n=to(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function xs(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return Ig(t,{check:n,error:r})}function bg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function to(e){return re(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>bg(t))}var Is="-?(?:0|[1-9][0-9]*)n";function On(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function He(e){return y(e,"BigInt")}function Or(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ae(e){return y(e,"Boolean")}function Pn(e){return p.Create({"~kind":"Identifier"},{name:e})}function bs(e){return y(e,"Identifier")}var Pr="-?(?:0|[1-9][0-9]*)";function jt(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function xe(e){return y(e,"Integer")}var no=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function vg(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new no(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:vg(e),const:e},t)}function Ar(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function vs(e){return q(e)&&s.IsNumber(e.const)}function $s(e){return q(e)&&s.IsString(e.const)}function q(e){return y(e,"Literal")}function Ht(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Yt(e){return y(e,"Null")}var Cr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Te(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function X(e){return y(e,"Number")}function Jt(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function xt(e){return y(e,"Symbol")}function Ft(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,me(),me()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function Ts(e){return y(e,"Parameter")}var Mr=".*";function Ce(e){return p.Create({"~kind":"String"},{type:"string"},e)}function Ie(e){return y(e,"String")}function w(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function x(e){return y(e,"Union")}function ks(e){return p.Discard(e,["~kind","anyOf"])}function An(e){let t=ws(e);return s.IsEqual(t.length,2)?t[0]:[]}function $g(e){return!0}function Es(e){return s.ShiftLeft(e,(t,n)=>Tg(t)?Es(n):!1,()=>!0)}function Rs(e){return s.IsEqual(e.length,0)?!1:Es(e)}function Tg(e){return x(e)?Rs(e.anyOf):q(e)?$g(e.const):!1}function Lr(e){return Rs(e)}function qr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Ss(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Ss(a,t,[...n,`${r}${t}`]),()=>n)}function kg(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Ss(e,t)}function Os(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Os(e,a,[...n,...Ps(e,r)]),()=>n)}function Ps(e,t){return x(t)?Os(e,t.anyOf):q(t)?kg(e,t.const):J()}function As(e,t){return s.ShiftLeft(t,(n,r)=>As(Ps(e,n),r),()=>e)}function wg(e){return e.map(t=>P(t))}function Eg(e){let t=As([],e),n=wg(t);return w(n)}function Rg(e){return s.IsEqual(e.length,0)?J():s.IsEqual(e.length,1)&&q(e[0])?e[0]:Eg(e)}function ro(e){let t=An(e);return s.IsEqual(t.length,0)?Ce():Lr(t)?Rg(t):qr(e)}function Cs(e){let t=ro(e);return Q(t)?Ce():t}function ve(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function Ms(e){return ve(Ge,e)}function Ls(e){return v({true:e,false:e})}function ee(e,t={}){let[n,r,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:n,minItems:r},t)}function G(e){return y(e,"Tuple")}function qs(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Sg(e){return p.Discard(e,["~readonly"])}function ao(e,t){return p.Update(Sg(e),{},t)}function js(e,t,n,r){let a=d(e,t,n);return ao(a,r)}function Fs(e,t={}){return I("RemoveReadonly",[e],t)}function Ds(e,t={}){return ao(e,t)}function Og(e){return p.Discard(e,["~optional"])}function oo(e,t){return p.Update(Og(e),{},t)}function Gs(e,t,n,r){let a=d(e,t,n);return oo(a,r)}function Ns(e,t={}){return I("RemoveOptional",[e],t)}function jr(e,t={}){return oo(e,t)}function io(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Us(e){let t=io(e.items);return v(t)}function Pg(e,t){return qt(e)?!!qt(t):!1}function Ag(e,t){return he(e)?!!he(t):!1}function Cg(e,t){let n=Pg(e,t),r=Ag(e,t),a=z([e,t]),i=Ds(jr(a));return n&&r?Lt(At(i)):n&&!r?Lt(i):!n&&r?At(i):i}function Mg(e,t,n){return n in e?n in t?Cg(e[n],t[n]):e[n]:n in t?t[n]:F()}function Lg(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:Mg(e,t,a)}),{})}function _s(e){return L(e)?e.properties:G(e)?io(e.items):J()}function Ks(e,t){let n=_s(e),r=_s(t),a=Lg(n,r);return v(a)}function zs(e,t){let n=Zt(e,t);return s.IsEqual(n,Mn)?e:s.IsEqual(n,Ln)||s.IsEqual(n,Cn)?t:F()}function Bs(e){return L(e)||G(e)}function qg(e,t){let n=x(e),r=x(t);return n||r}function jg(e,t){let n=Me(e),r=Me(t),a=qg(n,r),i=Bs(n),m=Bs(r);return a?z([n,r]):i&&m?Ks(n,r):i&&!m?n:!i&&m?r:zs(n,r)}function Vs(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Vs(e,a,[...n,jg(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function Ws(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Ws(a,t,[...n,...qn([r],t)]),()=>n)}function qn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?qn(r,Ws(n.anyOf,t)):qn(r,Vs(n,t)),()=>t)}function Fg(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[]:[e]}function Dg(e,t){return e.reduce((n,r)=>[...n,...Fg(r,t)],[])}function Fr(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Dg(r,t);return ke(a)}function Ne(e,t,n){let r=ge([e,t]),a=Fr(n,e);return ke([r,a])}function Se(e){let t=e.map(n=>P(n));return ke(t)}function z(e){let t=qn(e),n=so(t);return mt(n)}function $e(e){let t=Cs(e);return Me(t)}function ke(e){let t=so(e);return mt(t)}function Me(e){return V(e)?Ne(e.if,e.then,e.else):ye(e)?Se(e.enum):O(e)?z(e.allOf):Q(e)?$e(e.pattern):x(e)?ke(e.anyOf):e}function mt(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?F():w(e)}function Hs(e,t){let n=Se(e);return It(n,t)}function Ys(e,t){return ve(bt,t)}function Js(e,t){let n=z(e);return It(n,t)}function Zs(e,t){return s.IsString(e)||s.IsNumber(e)?v({[e]:t}):s.IsEqual(e,!1)?v({false:t}):s.IsEqual(e,!0)?v({true:t}):v({})}function Xs(e,t){return ve(Xt,t)}function Qs(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?ve(e.pattern.toString(),t):ve(Ge,t)}function em(e,t){let n=An(e);return Lr(n)?It($e(e),t):ve(e,t)}function Gg(e){return x(e)?jn(e.anyOf):[e]}function jn(e){return e.reduce((t,n)=>[...t,...Gg(n)],[])}function Ng(e){return e.some(t=>Ie(t)||X(t)||xe(t))}function Ug(e,t){return s.IsEqual(Ng(e),!0)?ve(Ge,t):void 0}function _g(e,t){return e.reduce((n,r)=>q(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Kg(e,t){let n=_g(e,t);return v(n)}function tm(e,t){let n=jn(e),r=Ug(n,t);return re(r)?r:Kg(n,t)}function It(e,t){return Z(e)?Ms(t):Ae(e)?Ls(t):ye(e)?Hs(e.enum,t):xe(e)?Ys(e,t):O(e)?Js(e.allOf,t):q(e)?Zs(e.const,t):X(e)?Xs(e,t):x(e)?tm(e.anyOf,t):Ie(e)?Qs(e,t):Q(e)?em(e.pattern,t):v({})}function mo(e,t,n){return k([e])?p.Update(It(e,t),{},n):Dr(e,t,n)}function nm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return mo(i,m,a)}var bt=`^${Pr}$`,Xt=`^${Cr}$`,Ge=`^${Mr}$`;function Dr(e,t,n={}){return I("Record",[e,t],n)}function Gr(e,t,n={}){return mo(e,t,n)}function rm(e,t){return ve(e,t)}function Nr(e){return s.IsEqual(e,Ge)?Ce():s.IsEqual(e,bt)?jt():s.IsEqual(e,Xt)?Te():ro(e)}function Le(e){return s.Keys(e.patternProperties)[0]}function Qt(e){let t=Le(e);return Nr(t)}function be(e){return e.patternProperties[Le(e)]}function de(e){return y(e,"Record")}function Dt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function vt(e){return y(e,"Rest")}function Ur(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function _r(e){return y(e,"This")}function en(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function tn(e){return y(e,"Undefined")}function Kr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ye(e){return y(e,"Void")}function Bg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Br(t[0]):s.IsEqual(e,"ConstructorParameters")?Jr(t[0]):s.IsEqual(e,"Evaluate")?ou(t[0]):s.IsEqual(e,"Exclude")?Zr(t[0],t[1]):s.IsEqual(e,"Extract")?Xr(t[0],t[1]):s.IsEqual(e,"Index")?Nn(t[0],t[1]):s.IsEqual(e,"InstanceType")?Qr(t[0]):s.IsEqual(e,"Lowercase")?Vr(t[0]):s.IsEqual(e,"NonNullable")?ea(t[0]):s.IsEqual(e,"Omit")?ta(t[0],t[1]):s.IsEqual(e,"Parameters")?na(t[0]):s.IsEqual(e,"Partial")?ra(t[0]):s.IsEqual(e,"Pick")?aa(t[0],t[1]):s.IsEqual(e,"Readonly")?oa(t[0]):s.IsEqual(e,"KeyOf")?Un(t[0]):s.IsEqual(e,"Record")?Dr(t[0],t[1]):s.IsEqual(e,"Required")?ia(t[0]):s.IsEqual(e,"ReturnType")?sa(t[0]):s.IsEqual(e,"Uncapitalize")?Wr(t[0]):s.IsEqual(e,"Uppercase")?Hr(t[0]):Gn(st(e),t)}function Gt(){throw Error("Unreachable")}var Vg=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),pt=e=>{let[t,n]=e;return Vg([...t,...n])};function mm(e){return Ft(e[0],e[2],e[4])}function pm(e){return Ft(e[0],e[2],e[2])}function um(e){return Ft(e[0],me(),e[2])}function cm(e){return Ft(e,me(),me())}function lm(e){return pt(e)}function dm(e){return e[1]}function fm(e){return pt(e)}function hm(e){return e[1]}function gm(e){return Bg(e[0],e[1])}function ym(e){return null}function xm(e){return Ce()}function Im(e){return Te()}function bm(e){return Or()}function vm(e){return en()}function $m(e){return Ht()}function Tm(e){return jt()}function km(e){return On()}function wm(e){return me()}function Em(e){return Vt()}function Rm(e){return v({})}function Sm(e){return F()}function Om(e){return Jt()}function Pm(e){return Kr()}function Am(e){return Ur()}function Cm(e){return P(BigInt(e))}function Mm(e){return P(s.IsEqual(e,"true"))}function Lm(e){return P(parseFloat(e))}function qm(e){return P(e)}function jm(e){return e[1]}function Fm(e){return P(e)}function Dm(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Gm(e){return e[1]}function Nm(e){return zr(e)}function Um(e){return s.IsEqual(e.length,6)?Ct(e[1],e[3],e[5]):Ct(e[1],e[3],me())}function _m(e){return e.length>0}function Km(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function zm(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function Bm(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function Vm(e){return s.IsEqual(e.length,2)?e[1]:[]}function am(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Nn(n,a[0]):s.IsEqual(a.length,0)?Re(n):Gt()},e)}function om(e,t){return s.IsEqual(t.length,3)?Yr(e,t[0],t[1],t[2]):e}function Wg(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:ma(e,t)}function Wm(e){let[t,n,r,a,i]=e;return Wg(om(t?Un(am(n,r)):am(n,r),a),i)}function po(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=po(r,a);if(s.IsEqual(n,"&"))return O(i)?ge([e,...i.allOf]):ge([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Gt()})():e}function Hm(e){let[t,n]=e;return po(t,n)}function Ym(e){let[t,n]=e;return po(t,n)}function Jm(e){return au(e[1])}function Zm(e){return e[1]}function Xm(e){return gt(e[0],e[2])}function Qm(e){return s.IsEqual(e.length,4)?En(e[1],e[3]):s.IsEqual(e.length,2)?En(e[1],me()):Gt()}function ep(e){return`${e}`}function tp(e){return xe(e[3])?bt:X(e[3])?Xt:xt(e[3])?Ge:Ie(e[3])?Ge:Gt()}function np(e){return e.length>0}function rp(e){return e.length>0}function ap(e){let[t,n,r,a,i]=e;return{[n]:t&&r?We(ze(i)):t&&!r?We(i):!t&&r?ze(i):i}}function op(e){return pt(e)}function ip(e){return e.reduce((t,n)=>s.HasPropertyKey(n,bt)||s.HasPropertyKey(n,Xt)||s.HasPropertyKey(n,Ge)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function sp(e){return ip(e[1])}function mp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return v(t,r)}function pp(e){return s.IsEqual(e.length,5)?We(ze(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?We(e[3]):ze(e[3]):Gt()}function up(e){return We(ze(e[1]))}function cp(e){return We(e[1])}function lp(e){return ze(e[0])}function dp(e){return s.IsEqual(e.length,2)?Dt(e[1]):s.IsEqual(e.length,1)?e[0]:Gt()}function fp(e){return pt(e)}function hp(e){return ee(e[1])}function gp(e){return We(ze(e[4]))}function yp(e){return We(e[3])}function xp(e){return ze(e[3])}function Ip(e){return e[2]}function bp(e){return s.IsEqual(e.length,2)?Dt(e[1]):s.IsEqual(e.length,1)?e[0]:Gt()}function vp(e){return pt(e)}function $p(e){return Ke(e[1],e[4])}function Tp(e){return _e(e[2],e[5])}function im(e,t){return s.IsEqual(e,"remove")?Fs(t):s.IsEqual(e,"add")?We(t):t}function kp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function sm(e,t){return s.IsEqual(e,"remove")?Ns(t):s.IsEqual(e,"add")?ze(t):t}function wp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function Ep(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function Rp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Fn(Pn(e[3]),e[5],e[6][0],im(e[1],sm(e[8],e[10]))):Fn(Pn(e[3]),e[5],st(e[3]),im(e[1],sm(e[8],e[10])))}function Sp(e){return st(e)}function Op(e){return BigInt(e)}function Pp(e){return parseFloat(e)}function Ap(e){return s.IsEqual(e,"true")}function Cp(e){return null}function Mp(e){return{[e[0]]:e[2]}}function Lp(e){return pt(e)}function Hg(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function qp(e){return Hg(e[1])}function jp(e){return pt(e)}function Fp(e){return e[1]}function Dp(e){return On()}function Gp(e){return Ce()}function Np(e){return Te()}function Up(e){return jt()}function _p(e){return F()}function Kp(e){return P(e)}function zp(e){return w(e[1])}function Bp(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function Vp(e){return[e[0],...e[1]]}function Wp(e){return e[1]}function Hp(e){return pt(e)}function Yp(e){return s.IsEqual(e.length,2)?e[1]:[]}function Jp(e){let t=e[2],n=e[3],[r,a]=e[4],i=s.IsEqual(s.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:gt(t,Dn(n,r,i))}}function Zp(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Dn(t,n,a)}}function Xp(e){return{[e[1]]:gt(e[2],e[4])}}function Qp(e){return{[e[1]]:e[3]}}function eu(e){return null}function tu(e){return ip(pt(e))}function nu(e){return e[1]}function ru(e){let t=e[0],n=e[1];return iu(p.Assign(t,n[0]))}function _n(e){return M(e.length,2)}function R(e,t,n){return _n(e)?t(e[0],e[1]):n()}function Zg(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function B(e,t){for(let n=0;n<e.length;n++){let r=Zg(e[n],t);if(_n(r))return r}return[]}function uo(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var su=[...uo(97,122),...uo(65,90)],co="0",lo=uo(49,57),nn=[co,...lo],mu=" ",rn=`
|
|
6
|
-
`;var
|
|
4
|
+
`,"utf-8")}let A=fe(n,"node_modules"),H=fe(r,"node_modules");if(Qa(A)&&!Qa(H))try{nh(A,H,process.platform==="win32"?"junction":"dir")}catch{}try{eh(i,fe(r,"agent_prompt.md"))}catch{}let te=Ir(a,"utf-8"),ne=ih(te),ue=fe(r,"test.patch");ot(ue,te,"utf-8");let tt=await t.exec("git",["apply","test.patch"],u);try{rh(ue)}catch{}if(tt.code!==0)return{status:"patchFailed",solverDir:r,error:tt.stderr?.trim()||"git apply test.patch failed"};let N=await t.exec("git",["add","-A"],u);if(N.code!==0)return{status:"error",solverDir:r,error:N.stderr?.trim()||"git add (tests applied) failed"};let nt=await t.exec("git",["commit","-m","tests applied","--allow-empty"],u);if(nt.code!==0)return{status:"error",solverDir:r,error:nt.stderr?.trim()||"git commit (tests applied) failed"};let _e=await t.exec("git",["rev-parse","HEAD"],u);return _e.code!==0||!_e.stdout.trim()?{status:"error",solverDir:r,error:"Could not resolve tests-applied commit hash."}:{status:"ok",solverDir:r,testsAppliedCommit:_e.stdout.trim(),testPatchPaths:ne}}function mh(e){try{let t=Ir(e,"utf-8").match(/<testsuites\b[^>]*>/i)?.[0];if(!t)return{totalTests:null,failedTests:null};let n=m=>Number.parseInt(t.match(new RegExp(`\\b${m}="(\\d+)"`,"i"))?.[1]??"",10),r=n("tests"),a=n("failures"),i=n("errors");return{totalTests:Number.isFinite(r)?r:null,failedTests:Number.isFinite(a)?a+(Number.isFinite(i)?i:0):null}}catch{return{totalTests:null,failedTests:null}}}async function _i(e){let{pi:t,index:n,workspace:r,status:a,durationMs:i}=e,{solverDir:m,testsAppliedCommit:u,testPatchPaths:l}=r,f={cwd:m,timeout:to};await t.exec("git",["add","-A"],f);let h=[...l,"agent_prompt.md"].map(_e=>`:(exclude)${_e}`),$=await t.exec("git",["diff","--cached",u,"--",".",...h],f),E=$.code===0?$.stdout:"",A=fe(m,"test_output.xml"),H=`bash test.sh --output_path ${yr(gr(A))} new`,te=hr(),ne=await t.exec(te,["-c",`cd ${yr(gr(m))} && ${H}`],{timeout:to*10}),ue=ne.code===0,tt=sh(`${ne.stdout}
|
|
5
|
+
${ne.stderr}`.trim(),ah),{totalTests:N,failedTests:nt}=mh(A);return{index:n,status:a,passed:ue,diff:E,testOutputTail:tt,durationMs:i,totalTests:N,failedTests:nt,testOutputXmlPath:A}}function Ui(e){let{repoDir:t,runId:n,index:r,trajectory:a,solutionPatch:i,testOutputXmlPath:m,testOutputTail:u}=e,l=fe(t,oh,n,`solver_${r}`);eo(l,{recursive:!0}),ot(fe(l,"trajectory.json"),JSON.stringify(a,null,2),"utf-8"),ot(fe(l,"solution.patch"),i,"utf-8");try{let f=Ir(m,"utf-8");ot(fe(l,"test_output.xml"),f,"utf-8")}catch{ot(fe(l,"test_output.txt"),u,"utf-8")}return l}function Ki(e,t){let n=fe(e,vn);eo(n,{recursive:!0});let r=t.map(a=>{let i=fe(n,`solver_${a.index}`);return eo(i,{recursive:!0}),ot(fe(i,"solution.diff"),a.diff,"utf-8"),ot(fe(i,"test_output.txt"),a.testOutputTail,"utf-8"),{index:a.index,status:a.status,passed:a.passed}});return ot(fe(n,"manifest.json"),JSON.stringify(r,null,2),"utf-8"),n}function zi(e){let t=fe(e,"node_modules");try{th(t).isSymbolicLink()&&Gi(t,{force:!0})}catch{}try{Gi(e,{recursive:!0,force:!0})}catch{}}var p={};St(p,{Assign:()=>ph,Clone:()=>wn,Create:()=>hg,Discard:()=>gg,Metrics:()=>De,Update:()=>yg});var De={assign:0,create:0,clone:0,discard:0,update:0};function ph(e,t){return De.assign+=1,{...e,...t}}var s={};St(s,{Entries:()=>Ph,EntriesRegExp:()=>Oh,Every:()=>Eh,EveryAll:()=>Rh,GraphemeCount:()=>Th,HasPropertyKey:()=>Sh,IsArray:()=>Tn,IsBigInt:()=>$n,IsBoolean:()=>Qi,IsClassInstance:()=>vh,IsConstructor:()=>hh,IsDeepEqual:()=>oo,IsEqual:()=>M,IsFunction:()=>es,IsGreaterEqualThan:()=>ns,IsGreaterThan:()=>xh,IsInteger:()=>ro,IsLessEqualThan:()=>ts,IsLessThan:()=>Ih,IsMaxLength:()=>kh,IsMinLength:()=>wh,IsMultipleOf:()=>bh,IsNull:()=>$r,IsNumber:()=>Tr,IsObject:()=>kn,IsObjectNotArray:()=>gh,IsString:()=>kr,IsSymbol:()=>yh,IsUndefined:()=>ao,IsUnsafePropertyKey:()=>rs,IsValueLike:()=>$h,Keys:()=>vr,ShiftLeft:()=>wr,Symbols:()=>Ah,Values:()=>Ch});function Ot(e,t,n){return e>=t&&e<=n}function uh(e){return e===8205}function ch(e){return Ot(e,55296,56319)}function Bi(e){return Ot(e,127462,127487)}function Wi(e){return Ot(e,65024,65039)}function Hi(e){return Ot(e,768,879)||Ot(e,6832,6911)||Ot(e,7616,7679)||Ot(e,65056,65071)}function br(e){return e>65535?2:1}function Vi(e,t){for(;t<e.length;){let n=e.codePointAt(t);if(Hi(n)||Wi(n))t+=br(n);else break}return t}function no(e,t){let n=e.codePointAt(t),r=t+br(n);for(r=Vi(e,r);r<e.length-1&&e[r]==="\u200D";){let a=e.codePointAt(r+1);r+=1+br(a),r=Vi(e,r)}return Bi(n)&&r<e.length&&Bi(e.codePointAt(r))&&(r+=br(e.codePointAt(r))),r}function Yi(e){return ch(e)||Hi(e)||Wi(e)||uh(e)}function Ji(e){let t=0,n=0;for(;n<e.length;)n=no(e,n),t++;return t}function lh(e,t){if(t===0)return!0;let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>=t)return!0;return!1}function dh(e,t){let n=0,r=0;for(;r<e.length;)if(r=no(e,r),n++,n>t)return!1;return!0}function Zi(e,t){if(t===0)return!0;let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return lh(e,t);if(n++,n>=t)return!0}return!1}function Xi(e,t){let n=0;for(;n<e.length;){if(Yi(e.charCodeAt(n)))return dh(e,t);if(n++,n>t)return!1}return!0}function Tn(e){return Array.isArray(e)}function $n(e){return M(typeof e,"bigint")}function Qi(e){return M(typeof e,"boolean")}function hh(e){if(ao(e)||!es(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function es(e){return M(typeof e,"function")}function ro(e){return Number.isInteger(e)}function $r(e){return M(e,null)}function Tr(e){return Number.isFinite(e)}function gh(e){return kn(e)&&!Tn(e)}function kn(e){return M(typeof e,"object")&&!$r(e)}function kr(e){return M(typeof e,"string")}function yh(e){return M(typeof e,"symbol")}function ao(e){return M(e,void 0)}function M(e,t){return e===t}function xh(e,t){return e>t}function Ih(e,t){return e<t}function ts(e,t){return e<=t}function ns(e,t){return e>=t}function bh(e,t){if($n(e)||$n(t))return BigInt(e)%BigInt(t)===0n;let n=1e-10;if(!Tr(e)||ro(e)&&1/t%1===0)return!0;let r=e%t;return Math.min(Math.abs(r),Math.abs(r-t),Math.abs(r+t))<n}function vh(e){if(!kn(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return $r(t)?!1:M(typeof t.constructor,"function")&&!(M(t.constructor,globalThis.Object)||M(t.constructor.name,"Object"))}function $h(e){return $n(e)||Qi(e)||$r(e)||Tr(e)||kr(e)||ao(e)}function Th(e){return Ji(e)}function kh(e,t){return Xi(e,t)}function wh(e,t){return Zi(e,t)}function Eh(e,t,n){for(let r=t;r<e.length;r++)if(!n(e[r],r))return!1;return!0}function Rh(e,t,n){let r=!0;for(let a=t;a<e.length;a++)n(e[a],a)||(r=!1);return r}function wr(e,t,n){return M(e.length,0)?n():t(e[0],e.slice(1))}function rs(e){return M(e,"__proto__")||M(e,"constructor")||M(e,"prototype")}function Sh(e,t){return rs(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function Oh(e){return vr(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function Ph(e){return Object.entries(e)}function vr(e){return Object.getOwnPropertyNames(e)}function Ah(e){return Object.getOwnPropertySymbols(e)}function Ch(e){return Object.values(e)}function Mh(e,t){if(!kn(t))return!1;let n=vr(e);return M(n.length,vr(t).length)&&n.every(r=>oo(e[r],t[r]))}function Lh(e,t){return Tn(t)&&M(e.length,t.length)&&e.every((n,r)=>oo(e[r],t[r]))}function oo(e,t){return Tn(e)?Lh(e,t):kn(e)?Mh(e,t):M(e,t)}var ht={};St(ht,{IsBigInt64Array:()=>Yh,IsBigUint64Array:()=>Jh,IsBoolean:()=>jh,IsDate:()=>Xh,IsFloat32Array:()=>Wh,IsFloat64Array:()=>Hh,IsInt16Array:()=>Kh,IsInt32Array:()=>Bh,IsInt8Array:()=>Nh,IsMap:()=>eg,IsNumber:()=>Fh,IsRegExp:()=>Zh,IsSet:()=>Qh,IsString:()=>Dh,IsTypeArray:()=>Gh,IsUint16Array:()=>zh,IsUint32Array:()=>Vh,IsUint8Array:()=>_h,IsUint8ClampedArray:()=>Uh});function jh(e){return e instanceof Boolean}function Fh(e){return e instanceof Number}function Dh(e){return e instanceof String}function Gh(e){return globalThis.ArrayBuffer.isView(e)}function Nh(e){return e instanceof globalThis.Int8Array}function _h(e){return e instanceof globalThis.Uint8Array}function Uh(e){return e instanceof globalThis.Uint8ClampedArray}function Kh(e){return e instanceof globalThis.Int16Array}function zh(e){return e instanceof globalThis.Uint16Array}function Bh(e){return e instanceof globalThis.Int32Array}function Vh(e){return e instanceof globalThis.Uint32Array}function Wh(e){return e instanceof globalThis.Float32Array}function Hh(e){return e instanceof globalThis.Float64Array}function Yh(e){return e instanceof globalThis.BigInt64Array}function Jh(e){return e instanceof globalThis.BigUint64Array}function Zh(e){return e instanceof globalThis.RegExp}function Xh(e){return e instanceof globalThis.Date}function Qh(e){return e instanceof globalThis.Set}function eg(e){return e instanceof globalThis.Map}function ng(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function rg(e){let t={},n=Object.getOwnPropertyDescriptors(e);for(let r of Object.keys(n)){if(s.IsUnsafePropertyKey(r))continue;let a=n[r];s.HasPropertyKey(a,"value")&&Object.defineProperty(t,r,{...a,value:Pt(a.value)})}return t}function ag(e){let t={};for(let n of s.Keys(e))s.IsUnsafePropertyKey(n)||(t[n]=Pt(e[n]));for(let n of s.Symbols(e))t[n]=Pt(e[n]);return t}function og(e){return s.IsClassInstance(e)?e:ng(e)?rg(e):ag(e)}function ig(e){return e.map(t=>Pt(t))}function sg(e){return e.slice()}function mg(e){return new RegExp(e.source,e.flags)}function pg(e){return new Map(Pt([...e.entries()]))}function ug(e){return new Set(Pt([...e.values()]))}function Pt(e){return ht.IsTypeArray(e)?sg(e):ht.IsRegExp(e)?mg(e):ht.IsMap(e)?pg(e):ht.IsSet(e)?ug(e):s.IsArray(e)?ig(e):s.IsObject(e)?og(e):e}function wn(e){return De.clone+=1,Pt(e)}var At={};St(At,{Get:()=>dg,Reset:()=>cg,Set:()=>lg});var it={immutableTypes:!1,maxErrors:8,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function cg(){it.immutableTypes=!1,it.maxErrors=8,it.useAcceleration=!0,it.exactOptionalPropertyTypes=!1,it.enumerableKind=!1,it.correctiveParse=!1,it.unionPrioritySort=!0}function lg(e){for(let t of s.Keys(e)){let n=e[t];n!==void 0&&Object.defineProperty(it,t,{value:n})}}function dg(){return it}function fg(e,t){for(let n of Object.keys(t))Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:!1,value:t[n]});return e}function as(e,t){return{...e,...t}}function hg(e,t,n={}){De.create+=1;let r=At.Get(),a=as(t,n),i=r.enumerableKind?as(a,e):fg(a,e);return r.immutableTypes?Object.freeze(i):i}function gg(e,t){De.discard+=1;let n={},r=Object.getOwnPropertyDescriptors(wn(e)),a=new Set(t);for(let i of Object.keys(r))a.has(i)||Object.defineProperty(n,i,r[i]);return n}function yg(e,t,n){De.update+=1;let r=At.Get(),a=wn(e);for(let i of Object.keys(t))Object.defineProperty(a,i,{configurable:!0,writable:!0,enumerable:r.enumerableKind,value:t[i]});for(let i of Object.keys(n))Object.defineProperty(a,i,{configurable:!0,enumerable:!0,writable:!0,value:n[i]});return a}function y(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function re(e){return s.IsObject(e)}function I(e,t,n){return p.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:n},{})}function gt(e){return y(e,"Deferred")}function xg(e){return p.Update(e,{"~readonly":!0},{})}function En(e,t){return p.Update(xg(e),{},t)}function os(e,t,n,r){let a=d(e,t,n);return En(a,r)}function Ig(e){return p.Update(e,{"~optional":!0},{})}function Rn(e,t){return p.Update(Ig(e),{},t)}function is(e,t,n,r){let a=d(e,t,n);return Rn(a,r)}function Re(e,t){return p.Create({"~kind":"Array"},{type:"array",items:e},t)}function K(e){return y(e,"Array")}function Er(e){return p.Discard(e,["~kind","type","items"])}function Ue(e,t,n={}){return p.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},n)}function oe(e){return y(e,"Constructor")}function ss(e){return p.Discard(e,["~kind","type","parameters","instanceType"])}function Ke(e,t,n={}){return p.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},n)}function ie(e){return y(e,"Function")}function ms(e){return p.Discard(e,["~kind","type","parameters","returnType"])}function st(e,t){return p.Create({"~kind":"Ref"},{$ref:e},t)}function se(e){return y(e,"Ref")}function yt(e,t){return p.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Ht(e){return y(e,"Generic")}function Yt(e){return p.Create({"~kind":"Any"},{},e)}function Z(e){return y(e,"Any")}var ps="(?!)";function F(e){return p.Create({"~kind":"Never"},{not:{}},e)}function xt(e){return y(e,"Never")}function ze(e,t={}){return I("AddOptional",[e],t)}function Ct(e,t={}){return Rn(e,t)}function us(e){return Ct(e)}function he(e){return re(e)&&s.HasPropertyKey(e,"~optional")}function cs(e){return s.Keys(e).filter(t=>!he(e[t]))}function Rr(e){return s.Keys(e)}function Sr(e){return s.Values(e)}function v(e,t={}){let n=cs(e),r=n.length>0?{required:n}:{};return p.Create({"~kind":"Object"},{type:"object",...r,properties:e},t)}function L(e){return y(e,"Object")}function ls(e){return p.Discard(e,["~kind","type","properties","required"])}function me(e){return p.Create({"~kind":"Unknown"},{},e)}function ae(e){return y(e,"Unknown")}function Be(e,t,n){let r=s.Keys(e).reduce((a,i)=>({...a,[i]:p.Update(e[i],{},{$id:i})}),{});return p.Create({"~kind":"Cyclic"},{$defs:r,$ref:t},n)}function ce(e){return y(e,"Cyclic")}function ds(e){return p.Update(e,{"~unsafe":null},{})}function Or(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}var Ve={};St(Ve,{Match:()=>bg});function bg(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}function Sn(...e){let[t,n]=Ve.Match(e,{2:(r,a)=>[r,a,a],1:r=>[r,me(),me()]});return p.Create({"~kind":"Infer"},{type:"infer",name:t,extends:n},{})}function Y(e){return y(e,"Infer")}function Mt(e,t,n,r={}){return p.Create({"~kind":"Dependent"},{if:e,then:t,else:n},r)}function V(e){return y(e,"Dependent")}function fs(e){return p.Discard(e,["~kind","if","then","else"])}function hs(e){return s.IsObjectNotArray(e)}function gs(e){return s.Keys(e).filter(n=>isNaN(n)).reduce((n,r)=>[...n,e[r]],[])}function ys(e){return s.IsString(e)||s.IsNumber(e)}function xs(e,t){let n=hs(e)?gs(e):e;return p.Create({"~kind":"Enum"},{enum:n},t)}function ye(e){return y(e,"Enum")}function ge(e,t={}){return p.Create({"~kind":"Intersect"},{allOf:e},t)}function O(e){return y(e,"Intersect")}function Is(e){return p.Discard(e,["~kind","allOf"])}function J(){throw new Error("Unreachable")}var bs;(function(e){e[e.Array=0]="Array",e[e.BigInt=1]="BigInt",e[e.Boolean=2]="Boolean",e[e.Date=3]="Date",e[e.Constructor=4]="Constructor",e[e.Function=5]="Function",e[e.Null=6]="Null",e[e.Number=7]="Number",e[e.Object=8]="Object",e[e.RegExp=9]="RegExp",e[e.String=10]="String",e[e.Symbol=11]="Symbol",e[e.TypeArray=12]="TypeArray",e[e.Undefined=13]="Undefined"})(bs||(bs={}));var bk=BigInt("14695981039346656037"),[vk,$k]=[BigInt("1099511628211"),BigInt("18446744073709551616")],Tk=Array.from({length:256}).map((e,t)=>BigInt(t)),vs=new Float64Array(1),kk=new DataView(vs.buffer),wk=new Uint8Array(vs.buffer);var Ek=new TextEncoder;var On=class{constructor(t,n){this.type=t,this.decode=n}Encode(t){let n=this.type,r=Pr(n)?m=>this.decode(n["~codec"].decode(m)):this.decode,a=Pr(n)?m=>n["~codec"].encode(t(m)):t,i={decode:r,encode:a};return p.Update(this.type,{"~codec":i},{})}},Pn=class{constructor(t){this.type=t}Decode(t){return new On(this.type,t)}};function Ar(e){return new Pn(e)}function Ts(e,t){return Ar(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function ks(e,t){return Ar(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function Pr(e){return re(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function ws(e){return Jt(e)}function Lt(e){return re(e)&&s.HasPropertyKey(e,"~immutable")}function We(e,t={}){return I("AddReadonly",[e],t)}function qt(e,t={}){return En(e,t)}function Es(e){return qt(e)}function jt(e){return re(e)&&s.HasPropertyKey(e,"~readonly")}function kg(e,t){let n=io(e)?[...e["~refine"],t]:[t];return p.Update(e,{"~refine":n},{})}function Rs(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,()=>"Refine Error"]});return kg(t,{check:n,error:r})}function wg(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function io(e){return re(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>wg(t))}var Ss="-?(?:0|[1-9][0-9]*)n";function An(e){return p.Create({"~kind":"BigInt"},{type:"bigint"},e)}function He(e){return y(e,"BigInt")}function Cr(e){return p.Create({"~kind":"Boolean"},{type:"boolean"},e)}function Ae(e){return y(e,"Boolean")}function Cn(e){return p.Create({"~kind":"Identifier"},{name:e})}function Os(e){return y(e,"Identifier")}var Mr="-?(?:0|[1-9][0-9]*)";function Ft(e){return p.Create({"~kind":"Integer"},{type:"integer"},e)}function xe(e){return y(e,"Integer")}var so=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function Eg(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new so(e)})()}function P(e,t){return p.Create({"~kind":"Literal"},{type:Eg(e),const:e},t)}function Lr(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Ps(e){return q(e)&&s.IsNumber(e.const)}function As(e){return q(e)&&s.IsString(e.const)}function q(e){return y(e,"Literal")}function Zt(e){return p.Create({"~kind":"Null"},{type:"null"},e)}function Xt(e){return y(e,"Null")}var qr="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function ke(e){return p.Create({"~kind":"Number"},{type:"number"},e)}function X(e){return y(e,"Number")}function Qt(e){return p.Create({"~kind":"Symbol"},{type:"symbol"},e)}function It(e){return y(e,"Symbol")}function Dt(...e){let[t,n,r]=Ve.Match(e,{3:(a,i,m)=>[a,i,m],2:(a,i)=>[a,i,i],1:a=>[a,me(),me()]});return p.Create({"~kind":"Parameter"},{name:t,extends:n,equals:r},{})}function Cs(e){return y(e,"Parameter")}var jr=".*";function Ce(e){return p.Create({"~kind":"String"},{type:"string"},e)}function Ie(e){return y(e,"String")}function w(e,t={}){return p.Create({"~kind":"Union"},{anyOf:e},t)}function x(e){return y(e,"Union")}function Ms(e){return p.Discard(e,["~kind","anyOf"])}function Mn(e){let t=Ls(e);return s.IsEqual(t.length,2)?t[0]:[]}function Rg(e){return!0}function qs(e){return s.ShiftLeft(e,(t,n)=>Sg(t)?qs(n):!1,()=>!0)}function js(e){return s.IsEqual(e.length,0)?!1:qs(e)}function Sg(e){return x(e)?js(e.anyOf):q(e)?Rg(e.const):!1}function Fr(e){return js(e)}function Dr(e){return p.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function Fs(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>Fs(a,t,[...n,`${r}${t}`]),()=>n)}function Og(e,t){return s.IsEqual(e.length,0)?[`${t}`]:Fs(e,t)}function Ds(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>Ds(e,a,[...n,...Gs(e,r)]),()=>n)}function Gs(e,t){return x(t)?Ds(e,t.anyOf):q(t)?Og(e,t.const):J()}function Ns(e,t){return s.ShiftLeft(t,(n,r)=>Ns(Gs(e,n),r),()=>e)}function Pg(e){return e.map(t=>P(t))}function Ag(e){let t=Ns([],e),n=Pg(t);return w(n)}function Cg(e){return s.IsEqual(e.length,0)?J():s.IsEqual(e.length,1)&&q(e[0])?e[0]:Ag(e)}function mo(e){let t=Mn(e);return s.IsEqual(t.length,0)?Ce():Fr(t)?Cg(t):Dr(e)}function _s(e){let t=mo(e);return Q(t)?Ce():t}function $e(e,t){let n="object",r={[e]:t};return p.Create({"~kind":"Record"},{type:n,patternProperties:r})}function Us(e){return $e(Ge,e)}function Ks(e){return v({true:e,false:e})}function ee(e,t={}){let[n,r,a]=[e,e.length,!1];return p.Create({"~kind":"Tuple"},{type:"array",additionalItems:a,items:n,minItems:r},t)}function G(e){return y(e,"Tuple")}function zs(e){return p.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Mg(e){return p.Discard(e,["~readonly"])}function po(e,t){return p.Update(Mg(e),{},t)}function Bs(e,t,n,r){let a=d(e,t,n);return po(a,r)}function Vs(e,t={}){return I("RemoveReadonly",[e],t)}function Ws(e,t={}){return po(e,t)}function Lg(e){return p.Discard(e,["~optional"])}function uo(e,t){return p.Update(Lg(e),{},t)}function Hs(e,t,n,r){let a=d(e,t,n);return uo(a,r)}function Ys(e,t={}){return I("RemoveOptional",[e],t)}function Gr(e,t={}){return uo(e,t)}function co(e){return e.reduceRight((n,r,a)=>({[a]:r,...n}),{})}function Js(e){let t=co(e.items);return v(t)}function qg(e,t){return jt(e)?!!jt(t):!1}function jg(e,t){return he(e)?!!he(t):!1}function Fg(e,t){let n=qg(e,t),r=jg(e,t),a=z([e,t]),i=Ws(Gr(a));return n&&r?qt(Ct(i)):n&&!r?qt(i):!n&&r?Ct(i):i}function Dg(e,t,n){return n in e?n in t?Fg(e[n],t[n]):e[n]:n in t?t[n]:F()}function Gg(e,t){return[...new Set([...s.Keys(t),...s.Keys(e)])].reduce((r,a)=>({...r,[a]:Dg(e,t,a)}),{})}function Zs(e){return L(e)?e.properties:G(e)?co(e.items):J()}function Xs(e,t){let n=Zs(e),r=Zs(t),a=Gg(n,r);return v(a)}function Qs(e,t){let n=en(e,t);return s.IsEqual(n,qn)?e:s.IsEqual(n,jn)||s.IsEqual(n,Ln)?t:F()}function em(e){return L(e)||G(e)}function Ng(e,t){let n=x(e),r=x(t);return n||r}function _g(e,t){let n=Me(e),r=Me(t),a=Ng(n,r),i=em(n),m=em(r);return a?z([n,r]):i&&m?Xs(n,r):i&&!m?n:!i&&m?r:Qs(n,r)}function tm(e,t,n=[]){return s.ShiftLeft(t,(r,a)=>tm(e,a,[...n,_g(e,r)]),()=>s.IsEqual(n.length,0)?[e]:n)}function nm(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>nm(a,t,[...n,...Fn([r],t)]),()=>n)}function Fn(e,t=[]){return s.ShiftLeft(e,(n,r)=>x(n)?Fn(r,nm(n.anyOf,t)):Fn(r,tm(n,t)),()=>t)}function Ug(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[]:[e]}function Kg(e,t){return e.reduce((n,r)=>[...n,...Ug(r,t)],[])}function Nr(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Kg(r,t);return we(a)}function Ne(e,t,n){let r=ge([e,t]),a=Nr(n,e);return we([r,a])}function Se(e){let t=e.map(n=>P(n));return we(t)}function z(e){let t=Fn(e),n=lo(t);return mt(n)}function Te(e){let t=_s(e);return Me(t)}function we(e){let t=lo(e);return mt(t)}function Me(e){return V(e)?Ne(e.if,e.then,e.else):ye(e)?Se(e.enum):O(e)?z(e.allOf):Q(e)?Te(e.pattern):x(e)?we(e.anyOf):e}function mt(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?F():w(e)}function rm(e,t){let n=Se(e);return bt(n,t)}function am(e,t){return $e(vt,t)}function om(e,t){let n=z(e);return bt(n,t)}function im(e,t){return s.IsString(e)||s.IsNumber(e)?v({[e]:t}):s.IsEqual(e,!1)?v({false:t}):s.IsEqual(e,!0)?v({true:t}):v({})}function sm(e,t){return $e(tn,t)}function mm(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?$e(e.pattern.toString(),t):$e(Ge,t)}function pm(e,t){let n=Mn(e);return Fr(n)?bt(Te(e),t):$e(e,t)}function zg(e){return x(e)?Dn(e.anyOf):[e]}function Dn(e){return e.reduce((t,n)=>[...t,...zg(n)],[])}function Bg(e){return e.some(t=>Ie(t)||X(t)||xe(t))}function Vg(e,t){return s.IsEqual(Bg(e),!0)?$e(Ge,t):void 0}function Wg(e,t){return e.reduce((n,r)=>q(r)&&(s.IsString(r.const)||s.IsNumber(r.const))?{...n,[r.const]:t}:n,{})}function Hg(e,t){let n=Wg(e,t);return v(n)}function um(e,t){let n=Dn(e),r=Vg(n,t);return re(r)?r:Hg(n,t)}function bt(e,t){return Z(e)?Us(t):Ae(e)?Ks(t):ye(e)?rm(e.enum,t):xe(e)?am(e,t):O(e)?om(e.allOf,t):q(e)?im(e.const,t):X(e)?sm(e,t):x(e)?um(e.anyOf,t):Ie(e)?mm(e,t):Q(e)?pm(e.pattern,t):v({})}function fo(e,t,n){return k([e])?p.Update(bt(e,t),{},n):_r(e,t,n)}function cm(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return fo(i,m,a)}var vt=`^${Mr}$`,tn=`^${qr}$`,Ge=`^${jr}$`;function _r(e,t,n={}){return I("Record",[e,t],n)}function Ur(e,t,n={}){return fo(e,t,n)}function lm(e,t){return $e(e,t)}function Kr(e){return s.IsEqual(e,Ge)?Ce():s.IsEqual(e,vt)?Ft():s.IsEqual(e,tn)?ke():mo(e)}function Le(e){return s.Keys(e.patternProperties)[0]}function nn(e){let t=Le(e);return Kr(t)}function be(e){return e.patternProperties[Le(e)]}function de(e){return y(e,"Record")}function Gt(e){return p.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function $t(e){return y(e,"Rest")}function zr(e){return p.Create({"~kind":"This"},{$ref:"#"},e)}function Br(e){return y(e,"This")}function rn(e){return p.Create({"~kind":"Undefined"},{type:"undefined"},e)}function an(e){return y(e,"Undefined")}function Vr(e){return p.Create({"~kind":"Void"},{type:"void"},e)}function Ye(e){return y(e,"Void")}function Jg(e,t){return s.IsEqual(e,"Array")?Re(t[0]):s.IsEqual(e,"Capitalize")?Hr(t[0]):s.IsEqual(e,"ConstructorParameters")?Qr(t[0]):s.IsEqual(e,"Evaluate")?fu(t[0]):s.IsEqual(e,"Exclude")?ea(t[0],t[1]):s.IsEqual(e,"Extract")?ta(t[0],t[1]):s.IsEqual(e,"Index")?Un(t[0],t[1]):s.IsEqual(e,"InstanceType")?na(t[0]):s.IsEqual(e,"Lowercase")?Yr(t[0]):s.IsEqual(e,"NonNullable")?ra(t[0]):s.IsEqual(e,"Omit")?aa(t[0],t[1]):s.IsEqual(e,"Parameters")?oa(t[0]):s.IsEqual(e,"Partial")?ia(t[0]):s.IsEqual(e,"Pick")?sa(t[0],t[1]):s.IsEqual(e,"Readonly")?ma(t[0]):s.IsEqual(e,"KeyOf")?Kn(t[0]):s.IsEqual(e,"Record")?_r(t[0],t[1]):s.IsEqual(e,"Required")?pa(t[0]):s.IsEqual(e,"ReturnType")?ua(t[0]):s.IsEqual(e,"Uncapitalize")?Jr(t[0]):s.IsEqual(e,"Uppercase")?Zr(t[0]):_n(st(e),t)}function Nt(){throw Error("Unreachable")}var Zg=(e,t=[])=>e.reduce((n,r)=>s.IsArray(r)&&s.IsEqual(r.length,2)?[...n,r[0]]:[...n,r],[]),pt=e=>{let[t,n]=e;return Zg([...t,...n])};function ym(e){return Dt(e[0],e[2],e[4])}function xm(e){return Dt(e[0],e[2],e[2])}function Im(e){return Dt(e[0],me(),e[2])}function bm(e){return Dt(e,me(),me())}function vm(e){return pt(e)}function $m(e){return e[1]}function Tm(e){return pt(e)}function km(e){return e[1]}function wm(e){return Jg(e[0],e[1])}function Em(e){return null}function Rm(e){return Ce()}function Sm(e){return ke()}function Om(e){return Cr()}function Pm(e){return rn()}function Am(e){return Zt()}function Cm(e){return Ft()}function Mm(e){return An()}function Lm(e){return me()}function qm(e){return Yt()}function jm(e){return v({})}function Fm(e){return F()}function Dm(e){return Qt()}function Gm(e){return Vr()}function Nm(e){return zr()}function _m(e){return P(BigInt(e))}function Um(e){return P(s.IsEqual(e,"true"))}function Km(e){return P(parseFloat(e))}function zm(e){return P(e)}function Bm(e){return e[1]}function Vm(e){return P(e)}function Wm(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function Hm(e){return e[1]}function Ym(e){return Wr(e)}function Jm(e){return s.IsEqual(e.length,6)?Mt(e[1],e[3],e[5]):Mt(e[1],e[3],me())}function Zm(e){return e.length>0}function Xm(e){return e.reduce((t,n)=>s.IsEqual(n.length,3)?[...t,[n[1]]]:[...t,[]],[])}function Qm(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function ep(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function tp(e){return s.IsEqual(e.length,2)?e[1]:[]}function dm(e,t){return t.reduce((n,r)=>{let a=r;return s.IsEqual(a.length,1)?Un(n,a[0]):s.IsEqual(a.length,0)?Re(n):Nt()},e)}function fm(e,t){return s.IsEqual(t.length,3)?Xr(e,t[0],t[1],t[2]):e}function Xg(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:ca(e,t)}function np(e){let[t,n,r,a,i]=e;return Xg(fm(t?Kn(dm(n,r)):dm(n,r),a),i)}function ho(e,t){return s.IsEqual(t.length,3)?(()=>{let[n,r,a]=t,i=ho(r,a);if(s.IsEqual(n,"&"))return O(i)?ge([e,...i.allOf]):ge([e,i]);if(s.IsEqual(n,"|"))return x(i)?w([e,...i.anyOf]):w([e,i]);Nt()})():e}function rp(e){let[t,n]=e;return ho(t,n)}function ap(e){let[t,n]=e;return ho(t,n)}function op(e){return du(e[1])}function ip(e){return e[1]}function sp(e){return yt(e[0],e[2])}function mp(e){return s.IsEqual(e.length,4)?Sn(e[1],e[3]):s.IsEqual(e.length,2)?Sn(e[1],me()):Nt()}function pp(e){return`${e}`}function up(e){return xe(e[3])?vt:X(e[3])?tn:It(e[3])?Ge:Ie(e[3])?Ge:Nt()}function cp(e){return e.length>0}function lp(e){return e.length>0}function dp(e){let[t,n,r,a,i]=e;return{[n]:t&&r?We(ze(i)):t&&!r?We(i):!t&&r?ze(i):i}}function fp(e){return pt(e)}function hp(e){return e.reduce((t,n)=>s.HasPropertyKey(n,vt)||s.HasPropertyKey(n,tn)||s.HasPropertyKey(n,Ge)?[t[0],p.Assign(t[1],n)]:[p.Assign(t[0],n),t[1]],[{},{}])}function gp(e){return hp(e[1])}function yp(e){let[t,n]=e,r=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return v(t,r)}function xp(e){return s.IsEqual(e.length,5)?We(ze(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?We(e[3]):ze(e[3]):Nt()}function Ip(e){return We(ze(e[1]))}function bp(e){return We(e[1])}function vp(e){return ze(e[0])}function $p(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Tp(e){return pt(e)}function kp(e){return ee(e[1])}function wp(e){return We(ze(e[4]))}function Ep(e){return We(e[3])}function Rp(e){return ze(e[3])}function Sp(e){return e[2]}function Op(e){return s.IsEqual(e.length,2)?Gt(e[1]):s.IsEqual(e.length,1)?e[0]:Nt()}function Pp(e){return pt(e)}function Ap(e){return Ke(e[1],e[4])}function Cp(e){return Ue(e[2],e[5])}function hm(e,t){return s.IsEqual(e,"remove")?Vs(t):s.IsEqual(e,"add")?We(t):t}function Mp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function gm(e,t){return s.IsEqual(e,"remove")?Ys(t):s.IsEqual(e,"add")?ze(t):t}function Lp(e){return s.IsEqual(e.length,2)&&s.IsEqual(e[0],"-")?"remove":s.IsEqual(e.length,2)&&s.IsEqual(e[0],"+")||s.IsEqual(e.length,1)?"add":"none"}function qp(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function jp(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?Gn(Cn(e[3]),e[5],e[6][0],hm(e[1],gm(e[8],e[10]))):Gn(Cn(e[3]),e[5],st(e[3]),hm(e[1],gm(e[8],e[10])))}function Fp(e){return st(e)}function Dp(e){return BigInt(e)}function Gp(e){return parseFloat(e)}function Np(e){return s.IsEqual(e,"true")}function _p(e){return null}function Up(e){return{[e[0]]:e[2]}}function Kp(e){return pt(e)}function Qg(e){return e.reduce((t,n)=>p.Assign(t,n),{})}function zp(e){return Qg(e[1])}function Bp(e){return pt(e)}function Vp(e){return e[1]}function Wp(e){return An()}function Hp(e){return Ce()}function Yp(e){return ke()}function Jp(e){return Ft()}function Zp(e){return F()}function Xp(e){return P(e)}function Qp(e){return w(e[1])}function eu(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function tu(e){return[e[0],...e[1]]}function nu(e){return e[1]}function ru(e){return pt(e)}function au(e){return s.IsEqual(e.length,2)?e[1]:[]}function ou(e){let t=e[2],n=e[3],[r,a]=e[4],i=s.IsEqual(s.Keys(a).length,0)?{}:{patternProperties:a};return{[e[1]]:yt(t,Nn(n,r,i))}}function iu(e){let t=e[2],[n,r]=e[3],a=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return{[e[1]]:Nn(t,n,a)}}function su(e){return{[e[1]]:yt(e[2],e[4])}}function mu(e){return{[e[1]]:e[3]}}function pu(e){return null}function uu(e){return hp(pt(e))}function cu(e){return e[1]}function lu(e){let t=e[0],n=e[1];return hu(p.Assign(t,n[0]))}function zn(e){return M(e.length,2)}function R(e,t,n){return zn(e)?t(e[0],e[1]):n()}function ny(e,t){return M(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function B(e,t){for(let n=0;n<e.length;n++){let r=ny(e[n],t);if(zn(r))return r}return[]}function go(e,t){return Array.from({length:t-e+1},(n,r)=>String.fromCharCode(e+r))}var gu=[...go(97,122),...go(65,90)],yo="0",xo=go(49,57),on=[yo,...xo],yu=" ",sn=`
|
|
6
|
+
`;var Tt="_",la=".",xu="$",da="-";var Iu="//",bu="/*",ay="*/";function vu(e){let t=e.indexOf(ay);return M(t,-1)?"":e.slice(t+2)}function $u(e){let t=e.indexOf(sn);return M(t,-1)?"":e.slice(t)}function oy(e){return e.replace(/^[ \t\r\f\v]+/,"")}function fa(e){let t=oy(e);return t.startsWith(bu)?fa(vu(t.slice(2))):t.startsWith(Iu)?fa($u(t.slice(2))):t}function pe(e){let t=e.trimStart();return t.startsWith(bu)?pe(vu(t.slice(2))):t.startsWith(Iu)?pe($u(t.slice(2))):t}function ha(e,t){return R(B([e],t),(n,r)=>[n,r],()=>["",t])}function iy(e,t){return e.includes(t)}function mn(e,t,n,r=""){return R(B(e,n),(a,i)=>iy(t,a)?mn(e,t,i,r):mn(e,t,i,`${r}${a}`),()=>[r,n])}function sy(e){return B(xo,e)}var my=[...on,Tt];function py(e){return mn(my,[Tt],e)}function uy(e){return R(B([yo],e),(t,n)=>[t,n],()=>R(sy(e),(t,n)=>R(py(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[]))}function ga(e){return uy(pe(e))}function cy(e){return ha(da,e)}function ly(e){return R(cy(e),(t,n)=>R(ga(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function Tu(e){return ly(pe(e))}function dy(e){return R(Tu(e),(t,n)=>R(B(["n"],n),(r,a)=>[`${t}`,a],()=>[]),()=>[])}function Io(e){return dy(e)}function bo(e,t){return B([e],t)}function c(e,t){return M(e,"")?["",t]:e.startsWith(sn)?bo(e,fa(t)):e.startsWith(yu)?bo(e,t):bo(e,pe(t))}var ku=[...gu,Tt,xu];function fy(e){return B(ku,e)}var hy=[...ku,...on];function wu(e,t=""){return R(B(hy,e),(n,r)=>wu(r,`${t}${n}`),()=>[t,e])}function gy(e){return R(fy(e),(t,n)=>R(wu(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function W(e){return gy(pe(e))}var yy=[...on,Tt];function xy(e){return zn(B([la],e))}function Eu(e){return R(mn(yy,[Tt],e),(t,n)=>M(t,"")?[]:[t,n],()=>[])}function Iy(e){return R(B([la],e),(t,n)=>R(Eu(n),(r,a)=>[`0${t}${r}`,a],()=>[]),()=>[])}function by(e){return R(ga(e),(t,n)=>R(B([la],n),(r,a)=>R(Eu(a),(i,m)=>[`${t}${r}${i}`,m],()=>[`${t}`,a]),()=>[`${t}`,n]),()=>[])}function vy(e){return xy(e)?Iy(e):by(e)}function Ru(e){return vy(pe(e))}function $y(e){return ha(da,e)}function Ty(e){return R($y(e),(t,n)=>R(Ru(n),(r,a)=>[`${t}${r}`,a],()=>[]),()=>[])}function ya(e){return Ty(pe(e))}function ky(e){return M(e,"")?[]:[e.slice(0,1),e.slice(1)]}function Su(e,t){return wr(e,(n,r)=>t.startsWith(n)?!0:Su(r,t),()=>!1)}function kt(e,t,n=""){return R(ky(t),(r,a)=>Su(e,t)?[n,t]:kt(e,a,`${n}${r}`),()=>[])}function wy(e,t,n){return R(B([e],n),(r,a)=>R(kt([t],a),(i,m)=>R(B([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Ey(e,t,n){return R(B([e],n),(r,a)=>R(kt([sn,t],a),(i,m)=>R(B([t],m),(u,l)=>[`${i}`,l],()=>[]),()=>[]),()=>[])}function Ou(e,t,n,r){return n?wy(e,t,pe(r)):Ey(e,t,pe(r))}function Ry(e,t){return B(e,t)}function Sy(e,t){return Ou(e,e,!1,t)}function Oy(e,t){return R(Ry(e,t),(n,r)=>Sy(n,`${n}${r}`),()=>[])}function xa(e,t){return Oy(e,pe(t))}function Pu(e,t){return R(kt(e,t),(n,r)=>M(n,"")?[]:[n,r],()=>[])}var o=(e,t,n=()=>[])=>e.length===2?t(e):n(),Ay=e=>o(o(W(e),([t,n])=>o(c("extends",n),([r,a])=>o(S(a),([i,m])=>o(c("=",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[ym(t),n]),Cy=e=>o(o(W(e),([t,n])=>o(c("extends",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[xm(t),n]),My=e=>o(o(W(e),([t,n])=>o(c("=",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Im(t),n]),Ly=e=>o(W(e),([t,n])=>[bm(t),n]),Mu=e=>o(o(Ay(e),([t,n])=>[t,n],()=>o(Cy(e),([t,n])=>[t,n],()=>o(My(e),([t,n])=>[t,n],()=>o(Ly(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Lu=(e,t=[])=>o(o(Mu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Lu(r,[...t,n]),()=>[t,e]),qy=e=>o(o(Lu(e),([t,n])=>o(o(o(Mu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[vm(t),n]),To=e=>o(o(c("<",e),([t,n])=>o(qy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[$m(t),n]),qu=(e,t=[])=>o(o(S(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>qu(r,[...t,n]),()=>[t,e]),jy=e=>o(o(qu(e),([t,n])=>o(o(o(S(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Tm(t),n]),Fy=e=>o(o(c("<",e),([t,n])=>o(jy(n),([r,a])=>o(c(">",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[km(t),n]),Dy=e=>o(o(W(e),([t,n])=>o(Fy(n),([r,a])=>[[t,r],a])),([t,n])=>[wm(t),n]),ju=e=>o(o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Em(t),n]),Fu=e=>o(c("string",e),([t,n])=>[Rm(t),n]),Du=e=>o(c("number",e),([t,n])=>[Sm(t),n]),Gy=e=>o(c("boolean",e),([t,n])=>[Om(t),n]),Ny=e=>o(c("undefined",e),([t,n])=>[Pm(t),n]),_y=e=>o(c("null",e),([t,n])=>[Am(t),n]),Gu=e=>o(c("integer",e),([t,n])=>[Cm(t),n]),Uy=e=>o(c("bigint",e),([t,n])=>[Mm(t),n]),Ky=e=>o(c("unknown",e),([t,n])=>[Lm(t),n]),zy=e=>o(c("any",e),([t,n])=>[qm(t),n]),By=e=>o(c("object",e),([t,n])=>[jm(t),n]),Vy=e=>o(c("never",e),([t,n])=>[Fm(t),n]),Nu=e=>o(c("symbol",e),([t,n])=>[Dm(t),n]),Wy=e=>o(c("void",e),([t,n])=>[Gm(t),n]),Hy=e=>o(c("this",e),([t,n])=>[Nm(t),n]),Yy=e=>o(o(c("${",e),([t,n])=>o(S(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Bm(t),n]),vo=e=>o(kt(["${","`"],e),([t,n])=>[Vm(t),n]),_u=e=>o(o(o(vo(e),([t,n])=>o(Yy(n),([r,a])=>o(_u(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o(vo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(vo(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[Wm(t),n]),ko=e=>o(o(c("`",e),([t,n])=>o(_u(n),([r,a])=>o(c("`",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Hm(t),n]),Jy=e=>o(ko(e),([t,n])=>[Ym(t),n]),Zy=e=>o(o(o(c("if",e),([t,n])=>o(S(n),([r,a])=>o(c("then",a),([i,m])=>o(S(m),([u,l])=>o(c("else",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[t,n],()=>o(o(c("if",e),([t,n])=>o(S(n),([r,a])=>o(c("then",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>[])),([t,n])=>[Jm(t),n]),Xy=e=>o(Io(e),([t,n])=>[_m(t),n]),Qy=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Um(t),n]),ex=e=>o(ya(e),([t,n])=>[Km(t),n]),tx=e=>o(xa(["'",'"'],e),([t,n])=>[zm(t),n]),nx=e=>o(o(o(c("keyof",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Zm(t),n]),Uu=(e,t=[])=>o(o(o(c("[",e),([n,r])=>o(S(r),([a,i])=>o(c("]",i),([m,u])=>[[n,a,m],u]))),([n,r])=>[n,r],()=>o(o(c("[",e),([n,r])=>o(c("]",r),([a,i])=>[[n,a],i])),([n,r])=>[n,r],()=>[])),([n,r])=>Uu(r,[...t,n]),()=>[t,e]),rx=e=>o(Uu(e),([t,n])=>[Xm(t),n]),ax=e=>o(o(o(c("extends",e),([t,n])=>o(S(n),([r,a])=>o(c("?",a),([i,m])=>o(S(m),([u,l])=>o(c(":",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[Qm(t),n]),ox=e=>o(o(o(c("(",e),([t,n])=>o(S(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(Fu(e),([t,n])=>[t,n],()=>o(Du(e),([t,n])=>[t,n],()=>o(Gy(e),([t,n])=>[t,n],()=>o(Ny(e),([t,n])=>[t,n],()=>o(_y(e),([t,n])=>[t,n],()=>o(Gu(e),([t,n])=>[t,n],()=>o(Uy(e),([t,n])=>[t,n],()=>o(Ky(e),([t,n])=>[t,n],()=>o(zy(e),([t,n])=>[t,n],()=>o(By(e),([t,n])=>[t,n],()=>o(Vy(e),([t,n])=>[t,n],()=>o(Nu(e),([t,n])=>[t,n],()=>o(Wy(e),([t,n])=>[t,n],()=>o(Hy(e),([t,n])=>[t,n],()=>o(Xy(e),([t,n])=>[t,n],()=>o(Qy(e),([t,n])=>[t,n],()=>o(ex(e),([t,n])=>[t,n],()=>o(tx(e),([t,n])=>[t,n],()=>o(Jy(e),([t,n])=>[t,n],()=>o(Zy(e),([t,n])=>[t,n],()=>o(xx(e),([t,n])=>[t,n],()=>o(kx(e),([t,n])=>[t,n],()=>o(Px(e),([t,n])=>[t,n],()=>o(Ox(e),([t,n])=>[t,n],()=>o(Lx(e),([t,n])=>[t,n],()=>o(Dy(e),([t,n])=>[t,n],()=>o(qx(e),([t,n])=>[t,n],()=>[])))))))))))))))))))))))))))),([t,n])=>[ep(t),n]),ix=e=>o(o(o(c("with",e),([t,n])=>o(ac(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[tp(t),n]),Ku=e=>o(o(nx(e),([t,n])=>o(ox(n),([r,a])=>o(rx(a),([i,m])=>o(ax(m),([u,l])=>o(ix(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[np(t),n]),zu=e=>o(o(o(c("&",e),([t,n])=>o(Ku(n),([r,a])=>o(zu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Bu=e=>o(o(Ku(e),([t,n])=>o(zu(n),([r,a])=>[[t,r],a])),([t,n])=>[rp(t),n]),Vu=e=>o(o(o(c("|",e),([t,n])=>o(Bu(n),([r,a])=>o(Vu(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Ia=e=>o(o(Bu(e),([t,n])=>o(Vu(n),([r,a])=>[[t,r],a])),([t,n])=>[ap(t),n]),sx=e=>o(o(c("readonly",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[op(t),n]),mx=e=>o(o(c("|",e),([t,n])=>o(Ia(n),([r,a])=>[[t,r],a])),([t,n])=>[ip(t),n]),px=e=>o(o(To(e),([t,n])=>o(c("=",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[sp(t),n]),ux=e=>o(o(o(c("infer",e),([t,n])=>o(W(n),([r,a])=>o(c("extends",a),([i,m])=>o(Ia(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(c("infer",e),([t,n])=>o(W(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>[])),([t,n])=>[mp(t),n]),S=e=>o(o(ux(e),([t,n])=>[t,n],()=>o(mx(e),([t,n])=>[t,n],()=>o(sx(e),([t,n])=>[t,n],()=>o(Ia(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),cx=e=>o(ya(e),([t,n])=>[pp(t),n]),lx=e=>o(W(e),([t,n])=>[t,n]),dx=e=>o(xa(["'",'"'],e),([t,n])=>[t,n]),fx=e=>o(o(c("[",e),([t,n])=>o(W(n),([r,a])=>o(c(":",a),([i,m])=>o(o(Gu(m),([u,l])=>[u,l],()=>o(Du(m),([u,l])=>[u,l],()=>o(Fu(m),([u,l])=>[u,l],()=>o(Nu(m),([u,l])=>[u,l],()=>[])))),([u,l])=>o(c("]",l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[up(t),n]),Wu=e=>o(o(cx(e),([t,n])=>[t,n],()=>o(lx(e),([t,n])=>[t,n],()=>o(dx(e),([t,n])=>[t,n],()=>o(fx(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),hx=e=>o(o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[cp(t),n]),gx=e=>o(o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[lp(t),n]),Hu=e=>o(o(hx(e),([t,n])=>o(Wu(n),([r,a])=>o(gx(a),([i,m])=>o(c(":",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[dp(t),n]),Yu=e=>o(o(o(c(",",e),([t,n])=>o(c(`
|
|
7
7
|
`,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>o(c(`
|
|
8
8
|
`,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(",",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(`
|
|
9
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),
|
|
9
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Ju=(e,t=[])=>o(o(Hu(e),([n,r])=>o(Yu(r),([a,i])=>[[n,a],i])),([n,r])=>Ju(r,[...t,n]),()=>[t,e]),yx=e=>o(o(Ju(e),([t,n])=>o(o(o(Hu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[fp(t),n]),wo=e=>o(o(c("{",e),([t,n])=>o(yx(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[gp(t),n]),xx=e=>o(wo(e),([t,n])=>[yp(t),n]),Ix=e=>o(o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[t,n],()=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>[])))),([t,n])=>[xp(t),n]),bx=e=>o(o(c("readonly",e),([t,n])=>o(S(n),([r,a])=>o(c("?",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Ip(t),n]),vx=e=>o(o(c("readonly",e),([t,n])=>o(S(n),([r,a])=>[[t,r],a])),([t,n])=>[bp(t),n]),$x=e=>o(o(S(e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[vp(t),n]),Au=e=>o(o(Ix(e),([t,n])=>[t,n],()=>o(bx(e),([t,n])=>[t,n],()=>o(vx(e),([t,n])=>[t,n],()=>o($x(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))))),([t,n])=>[t,n]),Zu=e=>o(o(o(c("...",e),([t,n])=>o(Au(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Au(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[$p(t),n]),Xu=(e,t=[])=>o(o(Zu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>Xu(r,[...t,n]),()=>[t,e]),Tx=e=>o(o(Xu(e),([t,n])=>o(o(o(Zu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Tp(t),n]),kx=e=>o(o(c("[",e),([t,n])=>o(Tx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[kp(t),n]),wx=e=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(c("readonly",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[wp(t),n]),Ex=e=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(c("readonly",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Ep(t),n]),Rx=e=>o(o(W(e),([t,n])=>o(c("?",n),([r,a])=>o(c(":",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[Rp(t),n]),Sx=e=>o(o(W(e),([t,n])=>o(c(":",n),([r,a])=>o(S(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Sp(t),n]),Cu=e=>o(o(wx(e),([t,n])=>[t,n],()=>o(Ex(e),([t,n])=>[t,n],()=>o(Rx(e),([t,n])=>[t,n],()=>o(Sx(e),([t,n])=>[t,n],()=>[])))),([t,n])=>[t,n]),Qu=e=>o(o(o(c("...",e),([t,n])=>o(Cu(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(Cu(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[])),([t,n])=>[Op(t),n]),ec=(e,t=[])=>o(o(Qu(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>ec(r,[...t,n]),()=>[t,e]),tc=e=>o(o(ec(e),([t,n])=>o(o(o(Qu(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Pp(t),n]),Ox=e=>o(o(c("(",e),([t,n])=>o(tc(n),([r,a])=>o(c(")",a),([i,m])=>o(c("=>",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[Ap(t),n]),Px=e=>o(o(c("new",e),([t,n])=>o(c("(",n),([r,a])=>o(tc(a),([i,m])=>o(c(")",m),([u,l])=>o(c("=>",l),([f,h])=>o(S(h),([$,E])=>[[t,r,i,u,f,$],E])))))),([t,n])=>[Cp(t),n]),Ax=e=>o(o(o(c("+",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("readonly",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("readonly",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Mp(t),n]),Cx=e=>o(o(o(c("+",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("-",e),([t,n])=>o(c("?",n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c("?",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])))),([t,n])=>[Lp(t),n]),Mx=e=>o(o(o(c("as",e),([t,n])=>o(S(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[qp(t),n]),Lx=e=>o(o(c("{",e),([t,n])=>o(Ax(n),([r,a])=>o(c("[",a),([i,m])=>o(W(m),([u,l])=>o(c("in",l),([f,h])=>o(S(h),([$,E])=>o(Mx(E),([A,H])=>o(c("]",H),([te,ne])=>o(Cx(ne),([ue,tt])=>o(c(":",tt),([N,nt])=>o(S(nt),([_e,ct])=>o(ju(ct),([rt,lt])=>o(c("}",lt),([Vt,dt])=>[[t,r,i,u,f,$,A,te,ue,N,_e,rt,Vt],dt]))))))))))))),([t,n])=>[jp(t),n]),qx=e=>o(W(e),([t,n])=>[Fp(t),n]),jx=e=>o(Io(e),([t,n])=>[Dp(t),n]),Fx=e=>o(ya(e),([t,n])=>[Gp(t),n]),Dx=e=>o(o(c("true",e),([t,n])=>[t,n],()=>o(c("false",e),([t,n])=>[t,n],()=>[])),([t,n])=>[Np(t),n]),Gx=e=>o(xa(['"',"'"],e),([t,n])=>[t,n]),Nx=e=>o(c("null",e),([t,n])=>[_p(t),n]),_x=e=>o(c("undefined",e),([t,n])=>[void 0,n]),nc=e=>o(o(Wu(e),([t,n])=>o(c(":",n),([r,a])=>o(Eo(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Up(t),n]),rc=(e,t=[])=>o(o(nc(e),([n,r])=>o(Yu(r),([a,i])=>[[n,a],i])),([n,r])=>rc(r,[...t,n]),()=>[t,e]),Ux=e=>o(o(rc(e),([t,n])=>o(o(o(nc(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Kp(t),n]),ac=e=>o(o(c("{",e),([t,n])=>o(Ux(n),([r,a])=>o(c("}",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[zp(t),n]),oc=(e,t=[])=>o(o(Eo(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>oc(r,[...t,n]),()=>[t,e]),Kx=e=>o(o(oc(e),([t,n])=>o(o(o(Eo(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[Bp(t),n]),zx=e=>o(o(c("[",e),([t,n])=>o(Kx(n),([r,a])=>o(c("]",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Vp(t),n]),Eo=e=>o(o(jx(e),([t,n])=>[t,n],()=>o(Fx(e),([t,n])=>[t,n],()=>o(Dx(e),([t,n])=>[t,n],()=>o(Gx(e),([t,n])=>[t,n],()=>o(Nx(e),([t,n])=>[t,n],()=>o(_x(e),([t,n])=>[t,n],()=>o(ac(e),([t,n])=>[t,n],()=>o(zx(e),([t,n])=>[t,n],()=>[])))))))),([t,n])=>[t,n]),Bx=e=>o(c("-?(?:0|[1-9][0-9]*)n",e),([t,n])=>[Wp(t),n]),Vx=e=>o(c(".*",e),([t,n])=>[Hp(t),n]),Wx=e=>o(c("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,n])=>[Yp(t),n]),Hx=e=>o(c("-?(?:0|[1-9][0-9]*)",e),([t,n])=>[Jp(t),n]),Yx=e=>o(c("(?!)",e),([t,n])=>[Zp(t),n]),Jx=e=>o(Pu(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,n])=>[Xp(t),n]),Zx=e=>o(o(Bx(e),([t,n])=>[t,n],()=>o(Vx(e),([t,n])=>[t,n],()=>o(Wx(e),([t,n])=>[t,n],()=>o(Hx(e),([t,n])=>[t,n],()=>o(Yx(e),([t,n])=>[t,n],()=>o(Xx(e),([t,n])=>[t,n],()=>o(Jx(e),([t,n])=>[t,n],()=>[]))))))),([t,n])=>[t,n]),Xx=e=>o(o(c("(",e),([t,n])=>o(Ro(n),([r,a])=>o(c(")",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[Qp(t),n]),ic=e=>o(o(o($o(e),([t,n])=>o(c("|",n),([r,a])=>o(ic(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[t,n],()=>o(o($o(e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[]))),([t,n])=>[eu(t),n]),$o=e=>o(o(Zx(e),([t,n])=>o(Ro(n),([r,a])=>[[t,r],a])),([t,n])=>[tu(t),n]),Ro=e=>o(o(ic(e),([t,n])=>[t,n],()=>o($o(e),([t,n])=>[t,n],()=>[])),([t,n])=>[t,n]),Ls=e=>o(o(c("^",e),([t,n])=>o(Ro(n),([r,a])=>o(c("$",a),([i,m])=>[[t,r,i],m]))),([t,n])=>[nu(t),n]),sc=(e,t=[])=>o(o(S(e),([n,r])=>o(c(",",r),([a,i])=>[[n,a],i])),([n,r])=>sc(r,[...t,n]),()=>[t,e]),Qx=e=>o(o(sc(e),([t,n])=>o(o(o(S(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[ru(t),n]),mc=e=>o(o(o(c("extends",e),([t,n])=>o(Qx(n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[au(t),n]),eI=e=>o(o(c("interface",e),([t,n])=>o(W(n),([r,a])=>o(To(a),([i,m])=>o(mc(m),([u,l])=>o(wo(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[ou(t),n]),tI=e=>o(o(c("interface",e),([t,n])=>o(W(n),([r,a])=>o(mc(a),([i,m])=>o(wo(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[iu(t),n]),nI=e=>o(o(c("type",e),([t,n])=>o(W(n),([r,a])=>o(To(a),([i,m])=>o(c("=",m),([u,l])=>o(S(l),([f,h])=>[[t,r,i,u,f],h]))))),([t,n])=>[su(t),n]),rI=e=>o(o(c("type",e),([t,n])=>o(W(n),([r,a])=>o(c("=",a),([i,m])=>o(S(m),([u,l])=>[[t,r,i,u],l])))),([t,n])=>[mu(t),n]),aI=e=>o(o(o(c("export",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o([[],e],([t,n])=>[t,n],()=>[])),([t,n])=>[pu(t),n]),oI=e=>o(o(o(c(";",e),([t,n])=>o(c(`
|
|
10
10
|
`,n),([r,a])=>[[t,r],a])),([t,n])=>[t,n],()=>o(o(c(";",e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>o(o(c(`
|
|
11
|
-
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),ec=(e,t=[])=>o(o(To(e),([n,r])=>o(eI(r),([a,i])=>[[n,a],i])),([n,r])=>ec(r,[...t,n]),()=>[t,e]),tI=e=>o(o(ec(e),([t,n])=>o(o(o(To(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[tu(t),n]),To=e=>o(o(Qx(e),([t,n])=>o(o(Yx(n),([r,a])=>[r,a],()=>o(Jx(n),([r,a])=>[r,a],()=>o(Zx(n),([r,a])=>[r,a],()=>o(Xx(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(Ru(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[nu(t),n]),nI=e=>o(o(To(e),([t,n])=>o(tI(n),([r,a])=>[[t,r],a])),([t,n])=>[ru(t),n]),tc=e=>o(o(nI(e),([t,n])=>[t,n],()=>o(ax(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function nc(e){let t=Io(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:J()}function aI(e){return e.join("|")}function oI(e){return e.slice(1,e.length-1)}function iI(e,t,n){return kt(t,`${n}${e}`)}function sI(e,t){return kt(e,`${t}${Is}`)}function mI(e,t){return kt(e,`${t}${Pr}`)}function pI(e,t){return kt(e,`${t}${Cr}`)}function uI(e,t){return Kn(w([P("false"),P("true")]),e,t)}function cI(e,t){return kt(e,`${t}${Mr}`)}function lI(e,t,n){return kt(t,`${n}${oI(e)}`)}function dI(e,t,n){let r=zn(e,{});return Kn(r,t,n)}function fI(e,t,n){let r=Se(e);return Kn(r,t,n)}function rc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>rc(i,t,n,[...r,Kn(a,[],"")]),()=>kt(t,`${n}(${aI(r)})`))}function Kn(e,t,n){return ye(e)?fI(e.enum,t,n):xe(e)?mI(t,n):q(e)?iI(e.const,t,n):He(e)?sI(t,n):Ae(e)?uI(t,n):X(e)?pI(t,n):Ie(e)?cI(t,n):Q(e)?lI(e.pattern,t,n):oc(e)?dI(e.parameters[0],t,n):x(e)?rc(e.anyOf,t,n):es}function kt(e,t){return s.ShiftLeft(e,(n,r)=>Kn(n,r,t),()=>t)}function hI(e){return`^${kt(e,"")}$`}function ac(e){let t=hI(e);return qr(t)}function zn(e,t){return k(e)?p.Update(ac(e),{},t):zr(e,t)}function ic(e,t,n,r){let a=Oe(e,t,n);return zn(a,r)}function zr(e,t={}){return I("TemplateLiteral",[e],t)}function oc(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function sc(e){return zn(e,{})}function gI(e){let t=nc(e);return sc(t)}function mc(e,t={}){let n=s.IsString(e)?gI(e):sc(e);return p.Update(n,{},t)}function Q(e){return y(e,"TemplateLiteral")}var b={};Rt(b,{ExtendsFalse:()=>T,ExtendsTrue:()=>g,ExtendsUnion:()=>ko,IsExtendsFalse:()=>yI,IsExtendsTrue:()=>uc,IsExtendsTrueLike:()=>on,IsExtendsUnion:()=>pc,Match:()=>_});function ko(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function pc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function g(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function uc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function T(){return p.Create({"~kind":"ExtendsFalse"},{})}function yI(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function on(e){return pc(e)||uc(e)}function _(e,t,n){return on(e)?t(e.inferred):n()}function xI(e,t,n,r){return _(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>T())}function II(e,t){return g(e)}function bI(e,t,n,r,a){return _(C(e,t,n),i=>_(C(i,t,r),m=>g(m),()=>T()),()=>_(C(e,t,a),i=>g(i),()=>T()))}function vI(e,t,n){let r=Se(n);return C(e,t,r)}function cc(e,t,n){return s.ShiftLeft(n,(r,a)=>_(C(e,t,r),i=>cc(i,t,a),()=>T()),()=>g(e))}function $I(e,t,n){let r=$e(n);return C(e,t,r)}function lc(e,t,n){return s.ShiftLeft(n,(r,a)=>_(C(e,t,r),i=>g(i),()=>lc(e,t,a)),()=>T())}function j(e,t,n){return Z(n)?II(e,t):V(n)?bI(e,t,n.if,n.then,n.else):ye(n)?vI(e,t,n.enum):Y(n)?xI(e,n.name,t,n.extends):O(n)?cc(e,t,n.allOf):Q(n)?$I(e,t,n.pattern):x(n)?lc(e,t,n.anyOf):ae(n)?g(e):T()}function dc(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):ko(e)}function TI(e,t){let n=Mt(e),r=Mt(t);return n&&r||!n&&r?!0:!(n&&!r)}function fc(e,t,n,r){return K(r)?TI(t,r)?C(e,n,r.items):T():j(e,t,r)}function hc(e,t,n){return He(n)?g(e):j(e,t,n)}function gc(e,t,n){return Ae(n)?g(e):j(e,t,n)}function kI(e,t,n,r,a){let i=Y(r)?t:r,m=Y(r)?r:t,u=he(t),l=he(r);return!u&&l?T():_(C(e,i,m),f=>Bn(f,n,a),()=>T())}function wI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>kI(e,t,n,a,i),()=>he(t)?g(e):T())}function EI(e,t,n){return s.ShiftLeft(t,(r,a)=>wI(e,r,a,n),()=>g(e))}function Bn(e,t,n){return EI(e,t,n)}function ya(e,t,n){return Ye(n)?g(e):C(e,t,n)}function yc(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):oe(r)?_(Bn(e,t,r.parameters),a=>ya(a,n,r.instanceType),()=>T()):T()}function xc(e,t,n,r,a){return _(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Ic(e,t,n){let r=Se(t);return C(e,r,n)}function bc(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):ie(r)?_(Bn(e,t,r.parameters),a=>ya(a,n,r.returnType),()=>T()):T()}function vc(e,t,n){return xe(n)?g(e):X(n)?g(e):j(e,t,n)}function $c(e,t,n){let r=z(t);return C(e,r,n)}function xa(e,t,n){return t===n?g(e):T()}function RI(e,t,n){return q(n)?xa(e,t,n.const):He(n)?g(e):j(e,P(t),n)}function SI(e,t,n){return q(n)?xa(e,t,n.const):Ae(n)?g(e):j(e,P(t),n)}function OI(e,t,n){return q(n)?xa(e,t,n.const):X(n)?g(e):j(e,P(t),n)}function PI(e,t,n){return q(n)?xa(e,t,n.const):Ie(n)?g(e):j(e,P(t),n)}function Tc(e,t,n){return s.IsBigInt(t.const)?RI(e,t.const,n):s.IsBoolean(t.const)?SI(e,t.const,n):s.IsNumber(t.const)?OI(e,t.const,n):s.IsString(t.const)?PI(e,t.const,n):J()}function kc(e,t,n){return Y(n)?j(e,t,n):g(e)}function wc(e,t,n){return Yt(n)?g(e):j(e,t,n)}function Ec(e,t,n){return X(n)?g(e):j(e,t,n)}function AI(e,t,n){return he(t)?he(n)?g(e):T():g(e)}function CI(e,t,n){return Y(n)&&yt(n.extends)?T():_(C(e,t,n),r=>AI(r,t,n),()=>T())}function MI(e,t){return e.reduce((n,r)=>r in t?on(t[r])?{...n,...t[r].inferred}:J():J(),{})}function LI(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?CI({},t[m],n[m]):he(n[m])?Y(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):T();let a=s.Values(r).every(m=>on(m)),i=a?MI(s.Keys(r),r):{};return a?g(i):T()}function qI(e,t,n){let r=LI(e,t,n);return on(r)?g(p.Assign(e,r.inferred)):T()}function jI(e,t,n){return qI(e,t,n)}function FI(e,t){return s.Keys(t).reduce((n,r)=>({...n,[r]:s.HasPropertyKey(e,r)?x(n[r])?w([...n[r].anyOf,t[r]]):w([e[r],t[r]]):t[r]}),e)}function Rc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>_(C({},e[a],n),m=>Rc(e,i,n,FI(r,m)),()=>T()),()=>g(r))}function DI(e,t,n,r){let a=s.Keys(t);return Rc(t,a,r,e)}function Sc(e,t,n){return de(n)?DI(e,t,Le(n),be(n)):L(n)?jI(e,t,n.properties):j(e,v(t),n)}function GI(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):T()}function NI(e,t,n,r,a){return C(e,n,a)}function Oc(e,t,n,r){return de(r)?NI(e,Nr(t),n,Nr(Le(r)),be(r)):L(r)?GI(e,r.properties):Z(r)?g(e):ae(r)?g(e):T()}function Pc(e,t,n){return Ie(n)?g(e):j(e,t,n)}function Ac(e,t,n){return xt(n)?g(e):j(e,t,n)}function Cc(e,t,n){let r=$e(t);return C(e,r,n)}function wo(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Vn(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function Eo(e){return vt(e)?Y(e.items)?K(e.items.extends)?wo(e.items.name,e.items.extends.items):ae(e.items.extends)?wo(e.items.name,e.items.extends):void 0:J():void 0}function Ia(e){return Y(e)?wo(e.name,e.extends):void 0}function Ro(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>_(C({},r,t),()=>Ro(a,t,[...n,r]),()=>{}),()=>n)}function Mc(e,t,n,r){let a=Ro(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:ee(a)})):T()}function ba(e,t,n,r){let a=Ro(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):T()}function UI(e){return[...e].reverse()}function So(e,t){return t?UI(e):e}function _I(e){let t=e.length>0?e[0]:void 0,n=re(t)?Eo(t):void 0;return re(n)}function KI(e,t,n,r,a,i){return _(C(e,n,a),m=>Lc(m,t,r,i),()=>T())}function zI(e,t,n,r,a){let i=Eo(r);return Vn(i)?Mc(e,i.name,So(n,t),i.type):s.ShiftLeft(n,(m,u)=>KI(e,t,m,u,r,a),()=>T())}function BI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>zI(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):T())}function Lc(e,t,n,r){return BI(e,t,n,r)}function VI(e,t,n){let r=wt(e,U([],[]),n),a=_I(r);return Lc(e,a,So(t,a),So(r,a))}function qc(e,t,n){let r=Ia(n);return Vn(r)?ba(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>_(C(e,a,n),m=>qc(m,i,n),()=>T()),()=>g(e))}function jc(e,t,n){let r=wt(e,U([],[]),t);return G(n)?VI(e,r,n.items):K(n)?qc(e,r,n.items):j(e,ee(r),n)}function Fc(e,t,n){return Ye(n)?g(e):tn(n)?g(e):j(e,t,n)}function Dc(e,t,n){return s.ShiftLeft(n,(r,a)=>_(C(e,t,r),i=>g(i),()=>Dc(e,t,a)),()=>T())}function Oo(e,t,n){return s.ShiftLeft(t,(r,a)=>_(Dc(e,r,n),i=>Oo(i,a,n),()=>T()),()=>g(e))}function Gc(e,t,n){let r=Ia(n);return Vn(r)?ba(e,r.name,t,r.type):x(n)?Oo(e,t,n.anyOf):Oo(e,t,[n])}function Nc(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):T()}function Uc(e,t,n){return Ye(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?dc(e,t,n):K(t)?fc(e,t,t.items,n):He(t)?hc(e,t,n):Ae(t)?gc(e,t,n):oe(t)?yc(e,t.parameters,t.instanceType,n):V(t)?xc(e,t.if,t.then,t.else,n):ye(t)?Ic(e,t.enum,n):ie(t)?bc(e,t.parameters,t.returnType,n):xe(t)?vc(e,t,n):O(t)?$c(e,t.allOf,n):q(t)?Tc(e,t,n):yt(t)?kc(e,t,n):Yt(t)?wc(e,t,n):X(t)?Ec(e,t,n):L(t)?Sc(e,t.properties,n):de(t)?Oc(e,Le(t),be(t),n):Ie(t)?Pc(e,t,n):xt(t)?Ac(e,t,n):Q(t)?Cc(e,t.pattern,n):G(t)?jc(e,t.items,n):tn(t)?Fc(e,t,n):x(t)?Gc(e,t.anyOf,n):ae(t)?Nc(e,t,n):Ye(t)?Uc(e,t,n):T()}function WI(e,t){return z([...e,v(t)])}function Po(e,t,n){return k(e)?p.Update(WI(e,t),{},n):Dn(e,t,n)}function _c(e,t,n,r,a){let i=Oe(e,t,n),m=Wn(e,t,r);return Po(i,m,a)}function Dn(e,t,n={}){return I("Interface",[e,t],n)}function sn(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function Kc(e,t,n={}){return Po(e,t,n)}function HI(e,t,n){return e.includes(n)?!0:Hn([...e,n],t,t[n])}function zc(e,t,n){let r=wr(n);return Nt(e,t,r)}function Nt(e,t,n){return s.ShiftLeft(n,(r,a)=>Hn(e,t,r)?!0:Nt(e,t,a),()=>!1)}function Hn(e,t,n){return se(n)?HI(e,t,n.$ref):K(n)?Hn(e,t,n.items):oe(n)?Nt(e,t,[...n.parameters,n.instanceType]):ie(n)?Nt(e,t,[...n.parameters,n.returnType]):sn(n)?zc(e,t,n.parameters[1]):O(n)?Nt(e,t,n.allOf):L(n)?zc(e,t,n.properties):x(n)?Nt(e,t,n.anyOf):G(n)?Nt(e,t,n.items):de(n)?Hn(e,t,be(n)):!1}function Bc(e,t,n){return Hn(e,t,n)}function YI(e,t){return t.reduce((n,r)=>Bc([r],e,e[r])?[...n,r]:n,[])}function Vc(e){let t=kr(e);return YI(e,t)}function JI(e,t,n){return n.includes(t)?n:t in e?Yn(e,e[t],[...n,t]):J()}function Wc(e,t,n){let r=wr(t);return mn(e,r,n)}function mn(e,t,n){return t.reduce((r,a)=>Yn(e,a,r),n)}function Yn(e,t,n){return se(t)?JI(e,t.$ref,n):K(t)?Yn(e,t.items,n):oe(t)?mn(e,[...t.parameters,t.instanceType],n):ie(t)?mn(e,[...t.parameters,t.returnType],n):sn(t)?Wc(e,t.parameters[1],n):O(t)?mn(e,t.allOf,n):L(t)?Wc(e,t.properties,n):x(t)?mn(e,t.anyOf,n):G(t)?mn(e,t.items,n):de(t)?Yn(e,be(t),n):n}function Hc(e,t,n){return Yn(e,n,[t])}function ZI(e){return Vt()}function XI(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function Jn(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?ZI(e.$ref):K(e)?Re(Ut(e.items),Tr(e)):oe(e)?_e(Jn(e.parameters),Ut(e.instanceType)):ie(e)?Ke(Jn(e.parameters),Ut(e.returnType)):O(e)?ge(Jn(e.allOf)):L(e)?v(XI(e.properties)):de(e)?Gr(Qt(e),Ut(be(e))):x(e)?w(Jn(e.anyOf)):G(e)?ee(Jn(e.items)):e}function QI(e,t){return t in e?Ut(e[t]):me()}function Yc(e){return QI(e.$defs,e.$ref)}function eb(e,t,n){let r=Oe(e,U([],[]),t),a=Wn({},U([],[]),n);return z([...r,v(a)])}function tb(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=sn(i)?eb(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function Jc(e,t,n){let r=Hc(e,t,n),a=tb(e,r);return Be(a,t)}function Zc(e,t){return t in e?se(e[t])?Zc(e,e[t].$ref):e[t]:F()}function Je(e,t){return Zc(e,t)}function Xc(e){return ce(e)?Yc(e):Er(e)?me():e}function le(e,t,n){let r=Xc(t),a=Xc(n);return C(e,r,a)}var Cn="equal",nb="disjoint",Mn="left-inside",Ln="right-inside";function Zt(e,t){let n=[ae(e)?b.ExtendsFalse():le({},e,t),ae(e)?b.ExtendsTrue({}):le({},t,e)];return b.IsExtendsTrueLike(n[0])&&b.IsExtendsTrueLike(n[1])?Cn:b.IsExtendsTrueLike(n[0])&&b.IsExtendsFalse(n[1])?Mn:b.IsExtendsFalse(n[0])&&b.IsExtendsTrueLike(n[1])?Ln:nb}function rb(e,t){return t.filter(n=>Zt(e,n)!==Ln)}function ab(e,t){let n=t.some(r=>{let a=Zt(e,r);return s.IsEqual(a,Mn)||s.IsEqual(a,Cn)});return s.IsEqual(n,!1)}function ob(e,t){let n=Me(e);return Z(n)?[n]:ab(n,t)?[...rb(n,t),n]:t}function ib(e){return e.reduce((t,n)=>L(n)?[...t,n]:yt(n)?t:ob(n,t),[])}function so(e){let t=ib(e);return jn(t)}function Ao(e,t){return p.Update(Me(e),{},t)}function Qc(e,t,n,r){let a=d(e,t,n);return Ao(a,r)}function Zn(e,t=[]){return ht(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?Zn(e.parameters[2],Zn(e.parameters[3],[...t,e.parameters[0].$ref])):Zn(e.parameters[2],Zn(e.parameters[3],t)):ht(e)&&s.IsEqual(e.action,"Mapped")&&ht(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&se(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function sb(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function nl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>nl(a,m,[...n,[i,r]]),()=>n),()=>n)}function mb(e){return x(e)?[...e.anyOf]:[e]}function pb(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function el(e,t){return t.reduce((n,r)=>[...n,...pb(e,r)],[])}function tl(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?el(t,mb(n[1])):el(t,[n[1]]),[[]])}function rl(e,t,n){let r=Zn(n),a=sb(e,r),i=nl(t,a);return ht(n)&&s.IsEqual(n.action,"Conditional")||ht(n)&&s.IsEqual(n.action,"Mapped")?tl(i):[t]}function ub(){return["(not-resolvable)",F()]}function cb(){return["(not-generic)",F()]}function lb(e,t,n){return[e,gt(t,n)]}function db(e,t,n){return t in e?al(e,t,e[t],n):ub()}function al(e,t,n,r){return Bt(n)?lb(t,n.parameters,n.expression):se(n)?db(e,n.$ref,r):cb()}function ol(e,t,n){return al(e,"(anonymous)",t,n)}function fb(e,t,n){if(Y(t)||pn(t)||b.IsExtendsTrueLike(le({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function il(e,t,n,r,a){let i=d(e,t,a);return fb(n,i,r),p.Assign(e,{[n]:i})}function hb(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>Co(il(e,t,n.name,i,u),t,r,l),()=>Co(il(e,t,n.name,i,m),t,r,[]))}function Co(e,t,n,r){return s.ShiftLeft(n,(a,i)=>hb(e,t,a,i,r),()=>e)}function sl(e,t,n,r){return Co(e,t,n,r)}function gb(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function yb(e,t){return s.IsEqual(gb(e),t)}function xb(e,t,n,r,a,i){let m=sl(e,t,r,i),u=d(m,U([...t.callstack,n.$ref],t.visited),a);return d(m,U([],[]),u)}function Ib(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,xb(e,t,n,r,a,u)],[])}function bb(e,t,n,r,a,i){let m=rl(r,i,a),u=Ib(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:ke(u)}function va(e,t,n,r){let a=Oe(e,t,r),i=ol(e,n,r),m=i[0],u=i[1];return Bt(u)?yb(t,m)?Gn(st(m),a):bb(e,t,st(m),u.parameters,u.expression,a):Gn(n,a)}function Gn(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function ml(e,t){return va({},U([],[]),e,t)}function pn(e){return y(e,"Call")}function vb(e){return p.Discard(e,["~immutable"])}function pl(e,t){return p.Update(vb(e),{},t)}function ul(e,t,n,r){let a=d(e,t,n);return pl(a,r)}function cl(e,t){return e(t)}function ll(e,t){return s.IsString(t)?P(cl(e,t)):P(t)}function dl(e,t){let n=$e(t);return ut(e,n)}function fl(e,t){let n=t.map(r=>ut(e,r));return w(n)}function ut(e,t){return q(t)?ll(e,t.const):Q(t)?dl(e,t.pattern):x(t)?fl(e,t.anyOf):t}function Br(e,t={}){return I("Capitalize",[e],t)}function hl(e,t={}){return Mo(e,t)}function Vr(e,t={}){return I("Lowercase",[e],t)}function gl(e,t={}){return Lo(e,t)}function Wr(e,t={}){return I("Uncapitalize",[e],t)}function yl(e,t={}){return qo(e,t)}function Hr(e,t={}){return I("Uppercase",[e],t)}function xl(e,t={}){return jo(e,t)}var $b=e=>e[0].toUpperCase()+e.slice(1),Tb=e=>e.toLowerCase(),kb=e=>e[0].toLowerCase()+e.slice(1),wb=e=>e.toUpperCase();function Mo(e,t){return k([e])?p.Update(ut($b,e),{},t):Br(e,t)}function Lo(e,t){return k([e])?p.Update(ut(Tb,e),{},t):Vr(e,t)}function qo(e,t){return k([e])?p.Update(ut(kb,e),{},t):Wr(e,t)}function jo(e,t){return k([e])?p.Update(ut(wb,e),{},t):Hr(e,t)}function Il(e,t,n,r){let a=d(e,t,n);return Mo(a,r)}function bl(e,t,n,r){let a=d(e,t,n);return Lo(a,r)}function vl(e,t,n,r){let a=d(e,t,n);return qo(a,r)}function $l(e,t,n,r){let a=d(e,t,n);return jo(a,r)}function Yr(e,t,n,r,a={}){return I("Conditional",[e,t,n,r],a)}function Tl(e,t,n,r,a={}){return Fo({},U([],[]),e,t,n,r,a)}function Eb(e,t,n,r,a,i){let m=le(e,n,r);return b.IsExtendsUnion(m)?w([d(m.inferred,t,a),d(e,t,i)]):b.IsExtendsTrue(m)?d(m.inferred,t,a):d(e,t,i)}function Fo(e,t,n,r,a,i,m){return k([n,r])?p.Update(Eb(e,t,n,r,a,i),{},m):Yr(n,r,a,i,m)}function kl(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Fo(e,t,u,l,a,i,m)}function Jr(e,t={}){return I("ConstructorParameters",[e],t)}function wl(e,t={}){return Do(e,t)}function Rb(e){let t=oe(e)?e.parameters:[],n=wt({},U([],[]),t);return ee(n)}function Do(e,t){return k([e])?p.Update(Rb(e),{},t):Jr(e,t)}function El(e,t,n,r){let a=d(e,t,n);return Do(a,r)}function Zr(e,t,n={}){return I("Exclude",[e,t],n)}function Rl(e,t,n={}){return Xn(e,t,n)}function Xn(e,t,n){return k([e,t])?p.Update(Fr(e,t),{},n):Zr(e,t,n)}function Sl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Xn(i,m,a)}function Xr(e,t,n={}){return I("Extract",[e,t],n)}function Ol(e,t,n={}){return Go(e,t,n)}function Sb(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[e]:[]}function Ob(e,t){return e.reduce((n,r)=>[...n,...Sb(r,t)],[])}function Pl(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Ob(r,t);return ke(a)}function Go(e,t,n){return k([e,t])?p.Update(Pl(e,t),{},n):Xr(e,t,n)}function Al(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Go(i,m,a)}function Pb(e){return e.reduce((t,n)=>Ar(n)?[...t,P(n)]:t,[])}function un(e){let t=Pb(e);return w(t)}function Nn(e,t,n={}){return I("Index",[e,t],n)}function Cl(e,t,n={}){let r=s.IsArray(t)?un(t):t;return No(e,r,n)}function Ml(e,t){let n=Je(e,t);return Pe(n)}function Ll(e,t,n){let r=Ne(e,t,n);return Pe(r)}function Ab(e,t){let n=s.Keys(e).filter(h=>!s.HasPropertyKey(t,h)),r=s.Keys(t).filter(h=>!s.HasPropertyKey(e,h)),a=s.Keys(e).filter(h=>s.HasPropertyKey(t,h)),i=n.reduce((h,$)=>({...h,[$]:e[$]}),{}),m=r.reduce((h,$)=>({...h,[$]:t[$]}),{}),u=a.reduce((h,$)=>({...h,[$]:z([e[$],t[$]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function ql(e){return e.reduce((t,n)=>Ab(t,Pe(n)),{})}function jl(e){let t=Us(ee(e));return Pe(t)}function Cb(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:ke([e[i],t[i]])}),{})}function Fl(e,t){return s.ShiftLeft(e,(n,r)=>Fl(r,Cb(t,Pe(n))),()=>t)}function Dl(e){return s.ShiftLeft(e,(t,n)=>Fl(n,Pe(t)),()=>J())}function Pe(e){return ce(e)?Ml(e.$defs,e.$ref):V(e)?Ll(e.if,e.then,e.else):O(e)?ql(e.allOf):x(e)?Dl(e.anyOf):G(e)?jl(e.items):L(e)?e.properties:{}}function cn(e){let t=Pe(e);return v(t)}var Mb=new RegExp("^(?:0|[1-9][0-9]*)$");function ln(e){let t=`${e}`;return Mb.test(t)?parseInt(t):e}function Lb(e){return P(ln(e))}function Gl(e){return e.map(t=>Nl(t))}function Nl(e){return O(e)?ge(Gl(e.allOf)):x(e)?w(Gl(e.anyOf)):q(e)?Lb(e.const):e}function Ul(e,t){let n=Nl(t),r=le({},n,Te());return b.IsExtendsTrueLike(r)?e:q(t)&&s.IsEqual(t.const,"length")?Te():F()}function _l(e,t){let n=Je(e,t);return we(n)}function Kl(e,t,n){let r=Ne(e,t,n);return we(r)}function zl(e){let t=Se(e);return we(t)}function Bl(e){let t=z(e);return we(t)}function Vl(e){return[`${e}`]}function Wl(e){let t=$e(e);return we(t)}function Hl(e){return e.reduce((t,n)=>[...t,...we(n)],[])}function we(e){return ce(e)?_l(e.$defs,e.$ref):V(e)?Kl(e.if,e.then,e.else):ye(e)?zl(e.enum):O(e)?Bl(e.allOf):q(e)?Vl(e.const):Q(e)?Wl(e.pattern):x(e)?Hl(e.anyOf):[]}function dn(e){return we(e)}function Qn(e,t){return t.map(n=>er(e,n))}function er(e,t){return K(t)?Re(er(e,t.items)):oe(t)?_e(Qn(e,t.parameters),er(e,t.instanceType)):ie(t)?Ke(Qn(e,t.parameters),er(e,t.returnType)):G(t)?ee(Qn(e,t.items)):x(t)?w(Qn(e,t.anyOf)):O(t)?ge(Qn(e,t.allOf)):_r(t)?v(e):t}function Yl(e,t){return er(e,t)}function qb(e,t){let n=t in e?e[t]:F();return Yl(e,n)}function Jl(e,t){return t.reduce((n,r)=>[...n,qb(e,r)],[])}function jb(e,t){let n=dn(t),r=Jl(e,n);return ke(r)}var Fb=new RegExp(bt);function Db(e){return e.filter(n=>Fb.test(n))}function Gb(e){let t=kr(e),n=Db(t),r=Jl(e,n);return ke(r)}function Zl(e,t){return X(t)?Gb(e):jb(e,t)}function Nb(e){return P(ln(e))}function Xl(e){return e.map(t=>Uo(t))}function Uo(e){return O(e)?ge(Xl(e.allOf)):x(e)?w(Xl(e.anyOf)):q(e)?Nb(e.const):e}function Ub(e,t){return e.reduceRight((n,r,a)=>{let i=le({},P(a),t);return b.IsExtendsTrueLike(i)?[r,...n]:n},[])}function _b(e,t){let n=Uo(t),r=Ub(e,n);return mt(r)}function Kb(e){return mt(e)}function Ql(e,t){return q(t)&&s.IsEqual(t.const,"length")?P(e.length):X(t)||xe(t)?Kb(e):_b(e,t)}function ed(e,t){return K(e)?Ul(e.items,t):L(e)?Zl(e.properties,t):G(e)?Ql(e.items,t):F()}function zb(e){return ce(e)||V(e)||O(e)||x(e)?cn(e):e}function No(e,t,n){return k([e,t])?p.Update(ed(zb(e),t),{},n):Nn(e,t,n)}function td(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return No(i,m,a)}function Qr(e,t={}){return I("InstanceType",[e],t)}function nd(e,t={}){return _o(e,t)}function Bb(e){return oe(e)?e.instanceType:F()}function _o(e,t){return k([e])?p.Update(Bb(e),{},t):Qr(e,t)}function rd(e,t,n,r={}){let a=d(e,t,n);return _o(a,r)}function Un(e,t={}){return I("KeyOf",[e],t)}function ad(e,t={}){return Ko(e,t)}function od(){return w([Te(),Ce(),Jt()])}function id(e){return Te()}function Vb(e){return e.reduce((n,r)=>Ar(r)?[...n,P(ln(r))]:J(),[])}function sd(e){let t=s.Keys(e),n=Vb(t);return mt(n)}function md(e){return Qt(e)}function pd(e){let t=e.map((n,r)=>P(r));return mt(t)}function ud(e){return Z(e)?od():K(e)?id(e.items):L(e)?sd(e.properties):de(e)?md(e):G(e)?pd(e.items):F()}function Wb(e){return ce(e)||V(e)||O(e)||x(e)?cn(e):e}function Ko(e,t){return k([e])?p.Update(ud(Wb(e)),{},t):Un(e,t)}function cd(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function Fn(e,t,n,r,a={}){return I("Mapped",[e,t,n,r],a)}function ld(e,t,n,r,a={}){return zo({},U([],[]),e,t,n,r,a)}function Hb(e){let t=$e(e);return $a(t)}function Yb(e){return e.reduce((t,n)=>[...t,...$a(n)],[])}function Jb(e){let t=Se(e);return $a(t)}function Zb(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function $a(e){return ye(e)?Jb(e.enum):q(e)?Zb(e.const):Q(e)?Hb(e.pattern):x(e)?Yb(e.anyOf):[e]}function dd(e){return $a(e)}function Xb(e){return Q(e)?$e(e.pattern):e}function Qb(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=Xb(u),f=d(m,t,i);return vs(l)||$s(l)?{[l.const]:f}:{}}function ev(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,Qb(e,t,n,u,a,i)],[])}function tv(e){return e.reduce((t,n)=>[...t,v(n)],[])}function fd(e,t,n,r,a,i){let m=dd(r),u=ev(e,t,n,m,a,i),l=tv(u);return z(l)}function zo(e,t,n,r,a,i,m){return k([r])?p.Update(fd(e,t,n,r,a,i),{},m):Fn(n,r,a,i,m)}function hd(e,t,n,r,a,i,m){let u=d(e,t,r);return zo(e,t,n,u,a,i,m)}function nv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:Jc(r,m,t[m])}),{})}function rv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>!n.includes(i)).reduce((i,m)=>({...i,[m]:d(r,U([],[]),t[m])}),{})}function av(e,t,n){let r=Vc(t),a=nv(e,t,r),i=rv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Ta(e,t,n,r){return av(e,n,r)}function ea(e,t={}){return I("NonNullable",[e],t)}function gd(e,t={}){return Bo(e,t)}function ov(e){let t=w([Ht(),en()]);return Xn(e,t,{})}function Bo(e,t){return k([e])?p.Update(ov(e),{},t):ea(e,t)}function yd(e,t,n,r){let a=d(e,t,n);return Bo(a,r)}function ta(e,t,n={}){return I("Omit",[e,t],n)}function xd(e,t,n={}){let r=s.IsArray(t)?un(t):t;return Vo(e,r,n)}function ka(e){let t=cn(e);return L(t)?t.properties:J()}function iv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Id(e,t){let n=ka(e),r=dn(t),a=iv(n,r);return v(a)}function Vo(e,t,n){return k([e,t])?p.Update(Id(e,t),{},n):ta(e,t,n)}function bd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Vo(i,m,a)}function na(e,t={}){return I("Parameters",[e],t)}function vd(e,t={}){return Wo(e,t)}function sv(e){let t=ie(e)?e.parameters:[],n=wt({},U([],[]),t);return ee(n)}function Wo(e,t){return k([e])?p.Update(sv(e),{},t):na(e,t)}function $d(e,t,n,r){let a=d(e,t,n);return Wo(a,r)}function ra(e,t={}){return I("Partial",[e],t)}function Td(e,t={}){return Ho(e,t)}function kd(e,t){let n=Je(e,t),r=Ze(n);return Be(p.Assign(e,{[t]:r}),t)}function wd(e,t,n){let r=Ne(e,t,n);return Ze(r)}function Ed(e){let t=z(e);return Ze(t)}function Rd(e){let t=e.map(n=>Ze(n));return w(t)}function Sd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:At(e[a])}),{});return v(t)}function Ze(e){return ce(e)?kd(e.$defs,e.$ref):V(e)?wd(e.if,e.then,e.else):O(e)?Ed(e.allOf):x(e)?Rd(e.anyOf):L(e)?Sd(e.properties):v({})}function Ho(e,t){return k([e])?p.Update(Ze(e),{},t):ra(e,t)}function Od(e,t,n,r){let a=d(e,t,n);return Ho(a,r)}function aa(e,t,n={}){return I("Pick",[e,t],n)}function Pd(e,t,n={}){let r=s.IsArray(t)?un(t):t;return Yo(e,r,n)}function mv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Ad(e,t){let n=ka(e),r=dn(t),a=mv(n,r);return v(a)}function Yo(e,t,n){return k([e,t])?p.Update(Ad(e,t),{},n):aa(e,t,n)}function Cd(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Yo(i,m,a)}function oa(e,t={}){return I("ReadonlyObject",[e],t)}function Jo(e,t={}){return Zo(e,t)}var Md=Jo;function Ld(e){return Wt(Re(e))}function qd(e,t){let n=Je(e,t),r=Xe(n);return Be(p.Assign(e,{[t]:r}),t)}function jd(e,t,n){let r=Ne(e,t,n);return Xe(r)}function Fd(e){let t=z(e);return Xe(t)}function Dd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Lt(e[a])}),{});return v(t)}function Gd(e){return Wt(ee(e))}function Nd(e){let t=e.map(n=>Xe(n));return w(t)}function Xe(e){return K(e)?Ld(e.items):ce(e)?qd(e.$defs,e.$ref):V(e)?jd(e.if,e.then,e.else):O(e)?Fd(e.allOf):L(e)?Dd(e.properties):G(e)?Gd(e.items):x(e)?Nd(e.anyOf):e}function Zo(e,t){return k([e])?p.Update(Xe(e),{},t):oa(e)}function Ud(e,t,n,r){let a=d(e,t,n);return Zo(a,r)}function _d(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,U(t.callstack,[...t.visited,r]),e[r]):n}function Kd(e,t){let n=Je(e,t),r=Qe(n);return Be(p.Assign(e,{[t]:r}),t)}function zd(e,t,n){let r=Ne(e,t,n);return Qe(r)}function Bd(e){let t=z(e);return Qe(t)}function Vd(e){let t=e.map(n=>Qe(n));return w(t)}function Wd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:jr(e[a])}),{});return v(t)}function Qe(e){return ce(e)?Kd(e.$defs,e.$ref):V(e)?zd(e.if,e.then,e.else):O(e)?Bd(e.allOf):x(e)?Vd(e.anyOf):L(e)?Wd(e.properties):v({})}function ia(e,t={}){return I("Required",[e],t)}function Hd(e,t={}){return Xo(e,t)}function Xo(e,t){return k([e])?p.Update(Qe(e),{},t):ia(e,t)}function Yd(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function sa(e,t={}){return I("ReturnType",[e],t)}function Jd(e,t={}){return Qo(e,t)}function pv(e){return ie(e)?e.returnType:F()}function Qo(e,t){return k([e])?p.Update(pv(e),{},t):sa(e,t)}function Zd(e,t,n,r={}){let a=d(e,t,n);return Qo(a,r)}function ma(e,t){return I("With",[e,t],{})}function Xd(e,t){return ei(e,t)}function ei(e,t){return k([e])?p.Update(e,{},t):ma(e,t)}function Qd(e,t,n,r){let a=d(e,t,n);return ei(a,r)}function uv(e){return vt(e)?G(e.items)?ti(e.items.items):Y(e.items)?[e]:se(e.items)?[e]:[F()]:[e]}function ti(e){return e.reduce((n,r)=>[...n,...uv(r)],[])}function U(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Wn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function wt(e,t,n){let r=Oe(e,t,n);return ti(r)}function Oe(e,t,n){return n.map(r=>d(e,t,r))}function cv(e,t){let n=he(e)?wn(t,{}):t,r=qt(e)?kn(n,{}):n;return Mt(e)?tr(r,{}):r}function lv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?ef(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?ul(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?Ji(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?js(e,t,r[0],a):s.IsEqual(n,"AddOptional")?Zi(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Gs(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Il(e,t,r[0],a):s.IsEqual(n,"Conditional")?kl(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?El(e,t,r[0],a):s.IsEqual(n,"Evaluate")?Qc(e,t,r[0],a):s.IsEqual(n,"Exclude")?Sl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Al(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?td(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?rd(e,t,r[0],a):s.IsEqual(n,"Interface")?_c(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?cd(e,t,r[0],a):s.IsEqual(n,"Lowercase")?bl(e,t,r[0],a):s.IsEqual(n,"Mapped")?hd(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Ta(e,t,r[0],a):s.IsEqual(n,"NonNullable")?yd(e,t,r[0],a):s.IsEqual(n,"Pick")?Cd(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?$d(e,t,r[0],a):s.IsEqual(n,"Partial")?Od(e,t,r[0],a):s.IsEqual(n,"Omit")?bd(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Ud(e,t,r[0],a):s.IsEqual(n,"Record")?nm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?Yd(e,t,r[0],a):s.IsEqual(n,"ReturnType")?Zd(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?ic(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?vl(e,t,r[0],a):s.IsEqual(n,"Uppercase")?$l(e,t,r[0],a):s.IsEqual(n,"With")?Qd(e,t,r[0],r[1]):I(n,r,a)}function dv(e,t,n){let r=se(n)?_d(e,t,n,n.$ref):K(n)?Re(d(e,t,n.items),Tr(n)):pn(n)?va(e,t,n.target,n.arguments):oe(n)?_e(Oe(e,t,n.parameters),d(e,t,n.instanceType),Xi(n)):ie(n)?Ke(Oe(e,t,n.parameters),d(e,t,n.returnType),Qi(n)):V(n)?Ct(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),os(n)):O(n)?ge(Oe(e,t,n.allOf),us(n)):L(n)?v(Wn(e,t,n.properties),rs(n)):de(n)?rm(Le(n),d(e,t,be(n))):vt(n)?Dt(d(e,t,n.items)):G(n)?ee(wt(e,t,n.items),qs(n)):x(n)?w(Oe(e,t,n.anyOf),ks(n)):n;return cv(n,r)}function d(e,t,n){return ht(n)?lv(e,t,n.action,n.parameters,n.options):dv(e,t,n)}function ni(e,t){return d(e,U([],[]),t)}function fv(e){return p.Update(e,{"~immutable":!0},{})}function tr(e,t){return p.Update(fv(e),{},t)}function ef(e,t,n,r){let a=d(e,t,n);return tr(a,r)}function au(e,t={}){return I("AddImmutable",[e],t)}function Wt(e,t={}){return tr(e,t)}function ou(e,t={}){return I("Evaluate",[e],t)}function tf(e,t={}){return Ao(e,t)}function iu(e,t={}){return I("Module",[e],t)}function nf(e,t={}){return Ta({},U([],[]),e,t)}function rf(...e){let[t,n,r]=Ve.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=tc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,U([],[]),a[0]):F();return p.Update(i,{},r)}var D={};Rt(D,{Any:()=>Vt,Array:()=>Re,BigInt:()=>On,Boolean:()=>Or,Call:()=>ml,Capitalize:()=>hl,Codec:()=>Sr,Conditional:()=>Tl,Constructor:()=>_e,ConstructorParameters:()=>wl,Cyclic:()=>Be,Decode:()=>fs,DecodeBuilder:()=>Sn,Dependent:()=>Ct,Encode:()=>hs,EncodeBuilder:()=>Rn,Enum:()=>ps,Evaluate:()=>tf,Exclude:()=>Rl,Extends:()=>le,ExtendsResult:()=>b,Extract:()=>Ol,Function:()=>Ke,Generic:()=>gt,Identifier:()=>Pn,Immutable:()=>gs,Index:()=>Cl,Infer:()=>En,InstanceType:()=>nd,Instantiate:()=>ni,Integer:()=>jt,Interface:()=>Kc,Intersect:()=>ge,IsAny:()=>Z,IsArray:()=>K,IsBigInt:()=>He,IsBoolean:()=>Ae,IsCall:()=>pn,IsCodec:()=>Rr,IsConstructor:()=>oe,IsCyclic:()=>ce,IsDependent:()=>V,IsEnum:()=>ye,IsEnumValue:()=>ms,IsFunction:()=>ie,IsGeneric:()=>Bt,IsIdentifier:()=>bs,IsImmutable:()=>Mt,IsInfer:()=>Y,IsInteger:()=>xe,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>q,IsNever:()=>yt,IsNull:()=>Yt,IsNumber:()=>X,IsObject:()=>L,IsOptional:()=>he,IsParameter:()=>Ts,IsReadonly:()=>qt,IsRecord:()=>de,IsRef:()=>se,IsRefine:()=>to,IsRest:()=>vt,IsSchema:()=>re,IsString:()=>Ie,IsSymbol:()=>xt,IsTemplateLiteral:()=>Q,IsThis:()=>_r,IsTuple:()=>G,IsUndefined:()=>tn,IsUnion:()=>x,IsUnknown:()=>ae,IsUnsafe:()=>Er,IsVoid:()=>Ye,KeyOf:()=>ad,Literal:()=>P,Lowercase:()=>gl,Mapped:()=>ld,Module:()=>nf,Never:()=>F,NonNullable:()=>gd,Null:()=>Ht,Number:()=>Te,Object:()=>v,Omit:()=>xd,Optional:()=>ts,Parameter:()=>Ft,Parameters:()=>vd,Partial:()=>Td,Pick:()=>Pd,Readonly:()=>ys,ReadonlyObject:()=>Jo,ReadonlyType:()=>Md,Record:()=>Gr,RecordKey:()=>Qt,RecordPattern:()=>Le,RecordValue:()=>be,Ref:()=>st,Refine:()=>xs,Required:()=>Hd,Rest:()=>Dt,ReturnType:()=>Jd,Script:()=>rf,String:()=>Ce,Symbol:()=>Jt,TemplateLiteral:()=>mc,This:()=>Ur,Tuple:()=>ee,Uncapitalize:()=>yl,Undefined:()=>en,Union:()=>w,Unknown:()=>me,Unsafe:()=>as,Uppercase:()=>xl,Void:()=>Kr,With:()=>Xd});var nr="submit_test_gap_candidates",rr="submit_filtered_test_gaps",ar="submit_solver_gaps",Z4=D.Object({verdict:D.Union([D.Literal("PASS"),D.Literal("FAIL")],{description:"FAIL only for a genuine blocking issue (clear rubric violation, agent-fault-worthy gap, unfair/undiscoverable test requirement, or a real determinism/regression risk). Optional, minor, or stylistic points are NOT grounds for FAIL \u2014 put those in `notes` instead and use PASS."}),summary:D.String({description:"One short sentence summarizing the verdict."}),reasons:D.Array(D.String(),{description:"Specific BLOCKING justifications only, citing rubric item IDs and concrete evidence from the files you read. Required (non-empty) when verdict is FAIL. Use an empty array when verdict is PASS."}),notes:D.Array(D.String(),{description:"Non-blocking, optional/minor observations or suggested improvements \u2014 the kind of feedback a real reviewer leaves as 'Minor/optional' without failing the task. Include these regardless of verdict; use an empty array if you truly have none."})});var hv=D.Object({statement:D.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:D.Array(D.Object({description:D.String({description:"A fair, publicly observable missing behavioral test."}),risk:D.String({description:"Why an incorrect implementation could pass the current tests despite this missing behavior."})}),{description:"All candidate positive and negative gaps for this sentence; there is no maximum or target count, so include every distinct evidence-backed gap and relevant edge case rather than stopping at 10; use an empty array only when exhaustive analysis finds none."})});function af(e){return{name:nr,label:"Submit Candidate Test Gaps",description:"Submit one candidate-gap list for one prompt sentence. Call this after each sentence so the orchestrator can track the todo list; empty lists are required when that sentence has no gaps.",parameters:hv,async execute(t,n){let r=e.statements??[];return r.push({statement:n.statement,gaps:n.gaps??[]}),e.statements=r,{content:[{type:"text",text:`Recorded ${n.gaps?.length??0} candidate gap(s)`}],details:void 0}}}}var gv=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:D.String({description:"Why this is genuinely grounded in agent_prompt.md or the repo, fair to test per the fairness methodology, and a real (non-duplicate) coverage hole in test.patch \u2014 for negative gaps, cite the prompt's prohibition/constraint and why no existing test catches the forbidden outcome."})}),{description:"The filtered, final list of confirmed test gaps. Use an empty array if none of the candidates survive strict scrutiny."})});function of(e){return{name:rr,label:"Submit Filtered Test Gaps",description:"Submit your final, strictly filtered list of confirmed test gaps. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have independently verified each candidate.",parameters:gv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Confirmed ${r.length} gap(s) after filtering`}],details:void 0}}}}var yv=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The specific behavioral gap: a way one or more solver's diff differs materially from what agent_prompt.md/solution.patch require, despite that solver passing `./test.sh new`."}),justification:D.String({description:"Why this is a genuine requirement from agent_prompt.md or solution.patch (cite the specific requirement/line) that the solver's diff misses, contradicts, or diverges from \u2014 and why the current tests fail to catch that divergence."}),evidence:D.String({description:"Which solver(s) (by index) exhibit this, and the specific part of their diff that grounds the gap."})}),{description:"Concrete, diff-grounded behavioral gaps \u2014 cases where a passing solver's materially different approach reveals that `test.sh new` under-specifies a real requirement. Use an empty array if the solvers converged on equivalent behavior; do not manufacture gaps just to report something."})});function sf(e){return{name:ar,label:"Submit Solver Gaps",description:"Submit your final list of behavioral gaps found by comparing the solver diffs against the real solution.patch. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have finished comparing every solver.",parameters:yv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Recorded ${r.length} solver gap(s)`}],details:void 0}}}}function xv(e){return[e,"You are working inside the actual repository (this is your current directory) in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Read `agent_prompt.md` for the task requirements and inspect the repository's existing source/code files with read/grep/find/ls. Base the analysis on the prompt and the observable behavior supported by those code files."]}var Iv=["Thoroughness \u2014 your job is high recall on genuine gaps only:","- There is no target count or cap: do not stop at 10 (or any other arbitrary number). For each prompt sentence, enumerate as many distinct uncovered required behaviors and edge cases as the files justify, then continue until an additional sweep finds no new genuine gap.","- Find every gap you can justify with concrete evidence. Do not stop after the first obvious ones \u2014 keep reading until you have systematically covered the prompt and relevant repository code.","- After your first pass, run at least one deliberate second sweep (re-read `agent_prompt.md` and grep/read the relevant code files) before submitting \u2014 but if that sweep still finds nothing, submit an empty list.","- Do not self-censor or merge distinct genuine gaps into one \u2014 the validator will prune. Never invent or pad the list to seem thorough; an empty array is correct when exhaustive analysis truly finds none.","- Hunt subtle gaps too: behaviors that may be missed under other valid inputs, repository conventions, interaction effects, ordering/timing, and branches in the relevant source code that need behavioral coverage.","- Include a candidate only when you can cite specific grounding and a concrete false-pass risk \u2014 not to meet a quota."],mf=["Ground rules \u2014 do not overreach:","- Every gap must trace back to a specific requirement or sentence in `agent_prompt.md`, or to behavior that is unambiguous from the existing, visible repo. Do not invent requirements the prompt doesn't support.","- Do not propose gaps for things `agent_prompt.md` leaves intentionally open, or for implementation details/style the prompt doesn't mandate.","- Read the relevant source files carefully and distinguish genuinely required behavior from speculation; focus on public outcomes and edge cases that deserve behavioral coverage.","- Keep findings strictly behavioral and publicly observable: a user, caller, or documented public contract must be able to observe the required outcome. Do not report internal helper calls, private state, implementation structure, call order, file placement, or other incidental mechanics.","- Do not require DOM classes, DOM/data/test attributes, selectors, or exact string literals unless the prompt explicitly names them or they are an established, already-present public contract in the repository. Prefer a visible outcome or public API behavior that accepts equivalent implementations."];function pf(e,t){let n=[...xv("You are an exhaustive behavioral test-gap finder. Review the task prompt sentence by sentence, finding both missing required-behavior (positive) and missing forbidden/wrong-behavior (negative) tests."),"","First split `agent_prompt.md` into its meaningful sentences using periods (`.`) as the sentence boundary. Create an explicit TODO checklist of every resulting requirement sentence. Work through it one item at a time; do not finish until every item is checked off.","","Before analyzing each sentence, use read/grep/find/ls to inspect the relevant source files and their closest analogues. Use that code context to understand the public contracts, conventions, branches, guards, early returns, state transitions, side effects, boundary handling, and negative/prohibited outcomes required by the sentence. Report every distinct, prompt-required behavioral edge case or prohibition that a plausible implementation could miss. Include positive and negative gaps together for that sentence. There is no maximum number of gaps: keep enumerating distinct missing behaviors for this sentence, including boundary, empty, repeated, interacting, and other relevant edge cases; do not treat 10 as sufficient.","",...Iv,"",...mf,"","Test-coverage checklist for calibration:",e];return n.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements."),n.push("","For every candidate, state the missing fair behavioral test, the relevant source behavior or branch that led you to investigate it, and why a plausible incorrect implementation could evade that test. The prompt sentence is the required specification: do not report incidental implementation details it does not require. Do not propose the exact test implementation.",`After completing EACH TODO sentence, call \`${nr}\` with that exact sentence and its gap array (including an empty array when none exist). You may and must call the tool multiple times: once per sentence. Only finish after every TODO item has been submitted.`),n.join(`
|
|
12
|
-
`)}function
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
15
|
-
`)}var
|
|
11
|
+
`,e),([t,n])=>[[t],n]),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]),pc=(e,t=[])=>o(o(So(e),([n,r])=>o(oI(r),([a,i])=>[[n,a],i])),([n,r])=>pc(r,[...t,n]),()=>[t,e]),iI=e=>o(o(pc(e),([t,n])=>o(o(o(So(n),([r,a])=>[[r],a]),([r,a])=>[r,a],()=>o([[],n],([r,a])=>[r,a],()=>[])),([r,a])=>[[t,r],a])),([t,n])=>[uu(t),n]),So=e=>o(o(aI(e),([t,n])=>o(o(eI(n),([r,a])=>[r,a],()=>o(tI(n),([r,a])=>[r,a],()=>o(nI(n),([r,a])=>[r,a],()=>o(rI(n),([r,a])=>[r,a],()=>[])))),([r,a])=>o(ju(a),([i,m])=>[[t,r,i],m]))),([t,n])=>[cu(t),n]),sI=e=>o(o(So(e),([t,n])=>o(iI(n),([r,a])=>[[t,r],a])),([t,n])=>[lu(t),n]),uc=e=>o(o(sI(e),([t,n])=>[t,n],()=>o(px(e),([t,n])=>[t,n],()=>o(S(e),([t,n])=>[t,n],()=>[]))),([t,n])=>[t,n]);function cc(e){let t=ko(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:J()}function pI(e){return e.join("|")}function uI(e){return e.slice(1,e.length-1)}function cI(e,t,n){return wt(t,`${n}${e}`)}function lI(e,t){return wt(e,`${t}${Ss}`)}function dI(e,t){return wt(e,`${t}${Mr}`)}function fI(e,t){return wt(e,`${t}${qr}`)}function hI(e,t){return Bn(w([P("false"),P("true")]),e,t)}function gI(e,t){return wt(e,`${t}${jr}`)}function yI(e,t,n){return wt(t,`${n}${uI(e)}`)}function xI(e,t,n){let r=Vn(e,{});return Bn(r,t,n)}function II(e,t,n){let r=Se(e);return Bn(r,t,n)}function lc(e,t,n,r=[]){return s.ShiftLeft(e,(a,i)=>lc(i,t,n,[...r,Bn(a,[],"")]),()=>wt(t,`${n}(${pI(r)})`))}function Bn(e,t,n){return ye(e)?II(e.enum,t,n):xe(e)?dI(t,n):q(e)?cI(e.const,t,n):He(e)?lI(t,n):Ae(e)?hI(t,n):X(e)?fI(t,n):Ie(e)?gI(t,n):Q(e)?yI(e.pattern,t,n):fc(e)?xI(e.parameters[0],t,n):x(e)?lc(e.anyOf,t,n):ps}function wt(e,t){return s.ShiftLeft(e,(n,r)=>Bn(n,r,t),()=>t)}function bI(e){return`^${wt(e,"")}$`}function dc(e){let t=bI(e);return Dr(t)}function Vn(e,t){return k(e)?p.Update(dc(e),{},t):Wr(e,t)}function hc(e,t,n,r){let a=Oe(e,t,n);return Vn(a,r)}function Wr(e,t={}){return I("TemplateLiteral",[e],t)}function fc(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function gc(e){return Vn(e,{})}function vI(e){let t=cc(e);return gc(t)}function yc(e,t={}){let n=s.IsString(e)?vI(e):gc(e);return p.Update(n,{},t)}function Q(e){return y(e,"TemplateLiteral")}var b={};St(b,{ExtendsFalse:()=>T,ExtendsTrue:()=>g,ExtendsUnion:()=>Oo,IsExtendsFalse:()=>$I,IsExtendsTrue:()=>Ic,IsExtendsTrueLike:()=>pn,IsExtendsUnion:()=>xc,Match:()=>U});function Oo(e){return p.Create({"~kind":"ExtendsUnion"},{inferred:e})}function xc(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function g(e){return p.Create({"~kind":"ExtendsTrue"},{inferred:e})}function Ic(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function T(){return p.Create({"~kind":"ExtendsFalse"},{})}function $I(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function pn(e){return xc(e)||Ic(e)}function U(e,t,n){return pn(e)?t(e.inferred):n()}function TI(e,t,n,r){return U(C(e,n,r),a=>g(p.Assign(p.Assign(e,a),{[t]:n})),()=>T())}function kI(e,t){return g(e)}function wI(e,t,n,r,a){return U(C(e,t,n),i=>U(C(i,t,r),m=>g(m),()=>T()),()=>U(C(e,t,a),i=>g(i),()=>T()))}function EI(e,t,n){let r=Se(n);return C(e,t,r)}function bc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>bc(i,t,a),()=>T()),()=>g(e))}function RI(e,t,n){let r=Te(n);return C(e,t,r)}function vc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>vc(e,t,a)),()=>T())}function j(e,t,n){return Z(n)?kI(e,t):V(n)?wI(e,t,n.if,n.then,n.else):ye(n)?EI(e,t,n.enum):Y(n)?TI(e,n.name,t,n.extends):O(n)?bc(e,t,n.allOf):Q(n)?RI(e,t,n.pattern):x(n)?vc(e,t,n.anyOf):ae(n)?g(e):T()}function $c(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):Oo(e)}function SI(e,t){let n=Lt(e),r=Lt(t);return n&&r||!n&&r?!0:!(n&&!r)}function Tc(e,t,n,r){return K(r)?SI(t,r)?C(e,n,r.items):T():j(e,t,r)}function kc(e,t,n){return He(n)?g(e):j(e,t,n)}function wc(e,t,n){return Ae(n)?g(e):j(e,t,n)}function OI(e,t,n,r,a){let i=Y(r)?t:r,m=Y(r)?r:t,u=he(t),l=he(r);return!u&&l?T():U(C(e,i,m),f=>Wn(f,n,a),()=>T())}function PI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>OI(e,t,n,a,i),()=>he(t)?g(e):T())}function AI(e,t,n){return s.ShiftLeft(t,(r,a)=>PI(e,r,a,n),()=>g(e))}function Wn(e,t,n){return AI(e,t,n)}function ba(e,t,n){return Ye(n)?g(e):C(e,t,n)}function Ec(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):oe(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.instanceType),()=>T()):T()}function Rc(e,t,n,r,a){return U(C(e,t,a),()=>C(e,n,a),()=>C(e,r,a))}function Sc(e,t,n){let r=Se(t);return C(e,r,n)}function Oc(e,t,n,r){return Z(r)?g(e):ae(r)?g(e):ie(r)?U(Wn(e,t,r.parameters),a=>ba(a,n,r.returnType),()=>T()):T()}function Pc(e,t,n){return xe(n)?g(e):X(n)?g(e):j(e,t,n)}function Ac(e,t,n){let r=z(t);return C(e,r,n)}function va(e,t,n){return t===n?g(e):T()}function CI(e,t,n){return q(n)?va(e,t,n.const):He(n)?g(e):j(e,P(t),n)}function MI(e,t,n){return q(n)?va(e,t,n.const):Ae(n)?g(e):j(e,P(t),n)}function LI(e,t,n){return q(n)?va(e,t,n.const):X(n)?g(e):j(e,P(t),n)}function qI(e,t,n){return q(n)?va(e,t,n.const):Ie(n)?g(e):j(e,P(t),n)}function Cc(e,t,n){return s.IsBigInt(t.const)?CI(e,t.const,n):s.IsBoolean(t.const)?MI(e,t.const,n):s.IsNumber(t.const)?LI(e,t.const,n):s.IsString(t.const)?qI(e,t.const,n):J()}function Mc(e,t,n){return Y(n)?j(e,t,n):g(e)}function Lc(e,t,n){return Xt(n)?g(e):j(e,t,n)}function qc(e,t,n){return X(n)?g(e):j(e,t,n)}function jI(e,t,n){return he(t)?he(n)?g(e):T():g(e)}function FI(e,t,n){return Y(n)&&xt(n.extends)?T():U(C(e,t,n),r=>jI(r,t,n),()=>T())}function DI(e,t){return e.reduce((n,r)=>r in t?pn(t[r])?{...n,...t[r].inferred}:J():J(),{})}function GI(e,t,n){let r={};for(let m of s.Keys(n))r[m]=m in t?FI({},t[m],n[m]):he(n[m])?Y(n[m])?g(p.Assign(e,{[n[m].name]:n[m].extends})):g(e):T();let a=s.Values(r).every(m=>pn(m)),i=a?DI(s.Keys(r),r):{};return a?g(i):T()}function NI(e,t,n){let r=GI(e,t,n);return pn(r)?g(p.Assign(e,r.inferred)):T()}function _I(e,t,n){return NI(e,t,n)}function UI(e,t){return s.Keys(t).reduce((n,r)=>({...n,[r]:s.HasPropertyKey(e,r)?x(n[r])?w([...n[r].anyOf,t[r]]):w([e[r],t[r]]):t[r]}),e)}function jc(e,t,n,r){return s.ShiftLeft(t,(a,i)=>U(C({},e[a],n),m=>jc(e,i,n,UI(r,m)),()=>T()),()=>g(r))}function KI(e,t,n,r){let a=s.Keys(t);return jc(t,a,r,e)}function Fc(e,t,n){return de(n)?KI(e,t,Le(n),be(n)):L(n)?_I(e,t,n.properties):j(e,v(t),n)}function zI(e,t){return s.IsEqual(s.Keys(t).length,0)?g(e):T()}function BI(e,t,n,r,a){return C(e,n,a)}function Dc(e,t,n,r){return de(r)?BI(e,Kr(t),n,Kr(Le(r)),be(r)):L(r)?zI(e,r.properties):Z(r)?g(e):ae(r)?g(e):T()}function Gc(e,t,n){return Ie(n)?g(e):j(e,t,n)}function Nc(e,t,n){return It(n)?g(e):j(e,t,n)}function _c(e,t,n){let r=Te(t);return C(e,r,n)}function Po(e,t){return p.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function Hn(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"name")&&s.HasPropertyKey(e,"type")&&s.IsEqual(e["~kind"],"Inferrable")&&s.IsString(e.name)&&s.IsObject(e.type)}function Ao(e){return $t(e)?Y(e.items)?K(e.items.extends)?Po(e.items.name,e.items.extends.items):ae(e.items.extends)?Po(e.items.name,e.items.extends):void 0:J():void 0}function $a(e){return Y(e)?Po(e.name,e.extends):void 0}function Co(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>U(C({},r,t),()=>Co(a,t,[...n,r]),()=>{}),()=>n)}function Uc(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:ee(a)})):T()}function Ta(e,t,n,r){let a=Co(n,r);return s.IsArray(a)?g(p.Assign(e,{[t]:w(a)})):T()}function VI(e){return[...e].reverse()}function Mo(e,t){return t?VI(e):e}function WI(e){let t=e.length>0?e[0]:void 0,n=re(t)?Ao(t):void 0;return re(n)}function HI(e,t,n,r,a,i){return U(C(e,n,a),m=>Kc(m,t,r,i),()=>T())}function YI(e,t,n,r,a){let i=Ao(r);return Hn(i)?Uc(e,i.name,Mo(n,t),i.type):s.ShiftLeft(n,(m,u)=>HI(e,t,m,u,r,a),()=>T())}function JI(e,t,n,r){return s.ShiftLeft(r,(a,i)=>YI(e,t,n,a,i),()=>s.IsEqual(n.length,0)?g(e):T())}function Kc(e,t,n,r){return JI(e,t,n,r)}function ZI(e,t,n){let r=Et(e,_([],[]),n),a=WI(r);return Kc(e,a,Mo(t,a),Mo(r,a))}function zc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):s.ShiftLeft(t,(a,i)=>U(C(e,a,n),m=>zc(m,i,n),()=>T()),()=>g(e))}function Bc(e,t,n){let r=Et(e,_([],[]),t);return G(n)?ZI(e,r,n.items):K(n)?zc(e,r,n.items):j(e,ee(r),n)}function Vc(e,t,n){return Ye(n)?g(e):an(n)?g(e):j(e,t,n)}function Wc(e,t,n){return s.ShiftLeft(n,(r,a)=>U(C(e,t,r),i=>g(i),()=>Wc(e,t,a)),()=>T())}function Lo(e,t,n){return s.ShiftLeft(t,(r,a)=>U(Wc(e,r,n),i=>Lo(i,a,n),()=>T()),()=>g(e))}function Hc(e,t,n){let r=$a(n);return Hn(r)?Ta(e,r.name,t,r.type):x(n)?Lo(e,t,n.anyOf):Lo(e,t,[n])}function Yc(e,t,n){return Y(n)?j(e,t,n):Z(n)?g(e):ae(n)?g(e):T()}function Jc(e,t,n){return Ye(n)?g(e):j(e,t,n)}function C(e,t,n){return Z(t)?$c(e,t,n):K(t)?Tc(e,t,t.items,n):He(t)?kc(e,t,n):Ae(t)?wc(e,t,n):oe(t)?Ec(e,t.parameters,t.instanceType,n):V(t)?Rc(e,t.if,t.then,t.else,n):ye(t)?Sc(e,t.enum,n):ie(t)?Oc(e,t.parameters,t.returnType,n):xe(t)?Pc(e,t,n):O(t)?Ac(e,t.allOf,n):q(t)?Cc(e,t,n):xt(t)?Mc(e,t,n):Xt(t)?Lc(e,t,n):X(t)?qc(e,t,n):L(t)?Fc(e,t.properties,n):de(t)?Dc(e,Le(t),be(t),n):Ie(t)?Gc(e,t,n):It(t)?Nc(e,t,n):Q(t)?_c(e,t.pattern,n):G(t)?Bc(e,t.items,n):an(t)?Vc(e,t,n):x(t)?Hc(e,t.anyOf,n):ae(t)?Yc(e,t,n):Ye(t)?Jc(e,t,n):T()}function XI(e,t){return z([...e,v(t)])}function qo(e,t,n){return k(e)?p.Update(XI(e,t),{},n):Nn(e,t,n)}function Zc(e,t,n,r,a){let i=Oe(e,t,n),m=Yn(e,t,r);return qo(i,m,a)}function Nn(e,t,n={}){return I("Interface",[e,t],n)}function un(e){return re(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function Xc(e,t,n={}){return qo(e,t,n)}function QI(e,t,n){return e.includes(n)?!0:Jn([...e,n],t,t[n])}function Qc(e,t,n){let r=Sr(n);return _t(e,t,r)}function _t(e,t,n){return s.ShiftLeft(n,(r,a)=>Jn(e,t,r)?!0:_t(e,t,a),()=>!1)}function Jn(e,t,n){return se(n)?QI(e,t,n.$ref):K(n)?Jn(e,t,n.items):oe(n)?_t(e,t,[...n.parameters,n.instanceType]):ie(n)?_t(e,t,[...n.parameters,n.returnType]):un(n)?Qc(e,t,n.parameters[1]):O(n)?_t(e,t,n.allOf):L(n)?Qc(e,t,n.properties):x(n)?_t(e,t,n.anyOf):G(n)?_t(e,t,n.items):de(n)?Jn(e,t,be(n)):!1}function el(e,t,n){return Jn(e,t,n)}function eb(e,t){return t.reduce((n,r)=>el([r],e,e[r])?[...n,r]:n,[])}function tl(e){let t=Rr(e);return eb(e,t)}function tb(e,t,n){return n.includes(t)?n:t in e?Zn(e,e[t],[...n,t]):J()}function nl(e,t,n){let r=Sr(t);return cn(e,r,n)}function cn(e,t,n){return t.reduce((r,a)=>Zn(e,a,r),n)}function Zn(e,t,n){return se(t)?tb(e,t.$ref,n):K(t)?Zn(e,t.items,n):oe(t)?cn(e,[...t.parameters,t.instanceType],n):ie(t)?cn(e,[...t.parameters,t.returnType],n):un(t)?nl(e,t.parameters[1],n):O(t)?cn(e,t.allOf,n):L(t)?nl(e,t.properties,n):x(t)?cn(e,t.anyOf,n):G(t)?cn(e,t.items,n):de(t)?Zn(e,be(t),n):n}function rl(e,t,n){return Zn(e,n,[t])}function nb(e){return Yt()}function rb(e){return s.Keys(e).reduce((t,n)=>({...t,[n]:Ut(e[n])}),{})}function Xn(e){return e.reduce((t,n)=>[...t,Ut(n)],[])}function Ut(e){return se(e)?nb(e.$ref):K(e)?Re(Ut(e.items),Er(e)):oe(e)?Ue(Xn(e.parameters),Ut(e.instanceType)):ie(e)?Ke(Xn(e.parameters),Ut(e.returnType)):O(e)?ge(Xn(e.allOf)):L(e)?v(rb(e.properties)):de(e)?Ur(nn(e),Ut(be(e))):x(e)?w(Xn(e.anyOf)):G(e)?ee(Xn(e.items)):e}function ab(e,t){return t in e?Ut(e[t]):me()}function al(e){return ab(e.$defs,e.$ref)}function ob(e,t,n){let r=Oe(e,_([],[]),t),a=Yn({},_([],[]),n);return z([...r,v(a)])}function ib(e,t){return s.Keys(e).filter(r=>t.includes(r)).reduce((r,a)=>{let i=e[a],m=un(i)?ob(e,i.parameters[0],i.parameters[1]):i;return{...r,[a]:m}},{})}function ol(e,t,n){let r=rl(e,t,n),a=ib(e,r);return Be(a,t)}function il(e,t){return t in e?se(e[t])?il(e,e[t].$ref):e[t]:F()}function Je(e,t){return il(e,t)}function sl(e){return ce(e)?al(e):Or(e)?me():e}function le(e,t,n){let r=sl(t),a=sl(n);return C(e,r,a)}var Ln="equal",sb="disjoint",qn="left-inside",jn="right-inside";function en(e,t){let n=[ae(e)?b.ExtendsFalse():le({},e,t),ae(e)?b.ExtendsTrue({}):le({},t,e)];return b.IsExtendsTrueLike(n[0])&&b.IsExtendsTrueLike(n[1])?Ln:b.IsExtendsTrueLike(n[0])&&b.IsExtendsFalse(n[1])?qn:b.IsExtendsFalse(n[0])&&b.IsExtendsTrueLike(n[1])?jn:sb}function mb(e,t){return t.filter(n=>en(e,n)!==jn)}function pb(e,t){let n=t.some(r=>{let a=en(e,r);return s.IsEqual(a,qn)||s.IsEqual(a,Ln)});return s.IsEqual(n,!1)}function ub(e,t){let n=Me(e);return Z(n)?[n]:pb(n,t)?[...mb(n,t),n]:t}function cb(e){return e.reduce((t,n)=>L(n)?[...t,n]:xt(n)?t:ub(n,t),[])}function lo(e){let t=cb(e);return Dn(t)}function jo(e,t){return p.Update(Me(e),{},t)}function ml(e,t,n,r){let a=d(e,t,n);return jo(a,r)}function Qn(e,t=[]){return gt(e)&&s.IsEqual(e.action,"Conditional")?se(e.parameters[0])?Qn(e.parameters[2],Qn(e.parameters[3],[...t,e.parameters[0].$ref])):Qn(e.parameters[2],Qn(e.parameters[3],t)):gt(e)&&s.IsEqual(e.action,"Mapped")&>(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&se(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function lb(e,t){return e.reduce((n,r)=>[...n,t.includes(r.name)],[])}function cl(e,t,n=[]){return s.ShiftLeft(e,(r,a)=>s.ShiftLeft(t,(i,m)=>cl(a,m,[...n,[i,r]]),()=>n),()=>n)}function db(e){return x(e)?[...e.anyOf]:[e]}function fb(e,t){return e.reduce((n,r)=>[...n,[...r,t]],[])}function pl(e,t){return t.reduce((n,r)=>[...n,...fb(e,r)],[])}function ul(e){return e.reduce((t,n)=>s.IsEqual(n[0],!0)?pl(t,db(n[1])):pl(t,[n[1]]),[[]])}function ll(e,t,n){let r=Qn(n),a=lb(e,r),i=cl(t,a);return gt(n)&&s.IsEqual(n.action,"Conditional")||gt(n)&&s.IsEqual(n.action,"Mapped")?ul(i):[t]}function hb(){return["(not-resolvable)",F()]}function gb(){return["(not-generic)",F()]}function yb(e,t,n){return[e,yt(t,n)]}function xb(e,t,n){return t in e?dl(e,t,e[t],n):hb()}function dl(e,t,n,r){return Ht(n)?yb(t,n.parameters,n.expression):se(n)?xb(e,n.$ref,r):gb()}function fl(e,t,n){return dl(e,"(anonymous)",t,n)}function Ib(e,t,n){if(Y(t)||ln(t)||b.IsExtendsTrueLike(le({},t,n)))return;let r={parameter:e,expect:n,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:r})}function hl(e,t,n,r,a){let i=d(e,t,a);return Ib(n,i,r),p.Assign(e,{[n]:i})}function bb(e,t,n,r,a){let i=d(e,t,n.extends),m=d(e,t,n.equals);return s.ShiftLeft(a,(u,l)=>Fo(hl(e,t,n.name,i,u),t,r,l),()=>Fo(hl(e,t,n.name,i,m),t,r,[]))}function Fo(e,t,n,r){return s.ShiftLeft(n,(a,i)=>bb(e,t,a,i,r),()=>e)}function gl(e,t,n,r){return Fo(e,t,n,r)}function vb(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function $b(e,t){return s.IsEqual(vb(e),t)}function Tb(e,t,n,r,a,i){let m=gl(e,t,r,i),u=d(m,_([...t.callstack,n.$ref],t.visited),a);return d(m,_([],[]),u)}function kb(e,t,n,r,a,i){return i.reduce((m,u)=>[...m,Tb(e,t,n,r,a,u)],[])}function wb(e,t,n,r,a,i){let m=ll(r,i,a),u=kb(e,t,n,r,a,m);return s.IsEqual(u.length,1)?u[0]:we(u)}function ka(e,t,n,r){let a=Oe(e,t,r),i=fl(e,n,r),m=i[0],u=i[1];return Ht(u)?$b(t,m)?_n(st(m),a):wb(e,t,st(m),u.parameters,u.expression,a):_n(n,a)}function _n(e,t){return p.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function yl(e,t){return ka({},_([],[]),e,t)}function ln(e){return y(e,"Call")}function Eb(e){return p.Discard(e,["~immutable"])}function xl(e,t){return p.Update(Eb(e),{},t)}function Il(e,t,n,r){let a=d(e,t,n);return xl(a,r)}function bl(e,t){return e(t)}function vl(e,t){return s.IsString(t)?P(bl(e,t)):P(t)}function $l(e,t){let n=Te(t);return ut(e,n)}function Tl(e,t){let n=t.map(r=>ut(e,r));return w(n)}function ut(e,t){return q(t)?vl(e,t.const):Q(t)?$l(e,t.pattern):x(t)?Tl(e,t.anyOf):t}function Hr(e,t={}){return I("Capitalize",[e],t)}function kl(e,t={}){return Do(e,t)}function Yr(e,t={}){return I("Lowercase",[e],t)}function wl(e,t={}){return Go(e,t)}function Jr(e,t={}){return I("Uncapitalize",[e],t)}function El(e,t={}){return No(e,t)}function Zr(e,t={}){return I("Uppercase",[e],t)}function Rl(e,t={}){return _o(e,t)}var Rb=e=>e[0].toUpperCase()+e.slice(1),Sb=e=>e.toLowerCase(),Ob=e=>e[0].toLowerCase()+e.slice(1),Pb=e=>e.toUpperCase();function Do(e,t){return k([e])?p.Update(ut(Rb,e),{},t):Hr(e,t)}function Go(e,t){return k([e])?p.Update(ut(Sb,e),{},t):Yr(e,t)}function No(e,t){return k([e])?p.Update(ut(Ob,e),{},t):Jr(e,t)}function _o(e,t){return k([e])?p.Update(ut(Pb,e),{},t):Zr(e,t)}function Sl(e,t,n,r){let a=d(e,t,n);return Do(a,r)}function Ol(e,t,n,r){let a=d(e,t,n);return Go(a,r)}function Pl(e,t,n,r){let a=d(e,t,n);return No(a,r)}function Al(e,t,n,r){let a=d(e,t,n);return _o(a,r)}function Xr(e,t,n,r,a={}){return I("Conditional",[e,t,n,r],a)}function Cl(e,t,n,r,a={}){return Uo({},_([],[]),e,t,n,r,a)}function Ab(e,t,n,r,a,i){let m=le(e,n,r);return b.IsExtendsUnion(m)?w([d(m.inferred,t,a),d(e,t,i)]):b.IsExtendsTrue(m)?d(m.inferred,t,a):d(e,t,i)}function Uo(e,t,n,r,a,i,m){return k([n,r])?p.Update(Ab(e,t,n,r,a,i),{},m):Xr(n,r,a,i,m)}function Ml(e,t,n,r,a,i,m){let u=d(e,t,n),l=d(e,t,r);return Uo(e,t,u,l,a,i,m)}function Qr(e,t={}){return I("ConstructorParameters",[e],t)}function Ll(e,t={}){return Ko(e,t)}function Cb(e){let t=oe(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Ko(e,t){return k([e])?p.Update(Cb(e),{},t):Qr(e,t)}function ql(e,t,n,r){let a=d(e,t,n);return Ko(a,r)}function ea(e,t,n={}){return I("Exclude",[e,t],n)}function jl(e,t,n={}){return er(e,t,n)}function er(e,t,n){return k([e,t])?p.Update(Nr(e,t),{},n):ea(e,t,n)}function Fl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return er(i,m,a)}function ta(e,t,n={}){return I("Extract",[e,t],n)}function Dl(e,t,n={}){return zo(e,t,n)}function Mb(e,t){let n=le({},e,t);return b.IsExtendsTrueLike(n)?[e]:[]}function Lb(e,t){return e.reduce((n,r)=>[...n,...Mb(r,t)],[])}function Gl(e,t){let n=Me(e),r=x(n)?n.anyOf:[n],a=Lb(r,t);return we(a)}function zo(e,t,n){return k([e,t])?p.Update(Gl(e,t),{},n):ta(e,t,n)}function Nl(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return zo(i,m,a)}function qb(e){return e.reduce((t,n)=>Lr(n)?[...t,P(n)]:t,[])}function dn(e){let t=qb(e);return w(t)}function Un(e,t,n={}){return I("Index",[e,t],n)}function _l(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Bo(e,r,n)}function Ul(e,t){let n=Je(e,t);return Pe(n)}function Kl(e,t,n){let r=Ne(e,t,n);return Pe(r)}function jb(e,t){let n=s.Keys(e).filter(h=>!s.HasPropertyKey(t,h)),r=s.Keys(t).filter(h=>!s.HasPropertyKey(e,h)),a=s.Keys(e).filter(h=>s.HasPropertyKey(t,h)),i=n.reduce((h,$)=>({...h,[$]:e[$]}),{}),m=r.reduce((h,$)=>({...h,[$]:t[$]}),{}),u=a.reduce((h,$)=>({...h,[$]:z([e[$],t[$]])}),{}),l=p.Assign(i,m);return p.Assign(l,u)}function zl(e){return e.reduce((t,n)=>jb(t,Pe(n)),{})}function Bl(e){let t=Js(ee(e));return Pe(t)}function Fb(e,t){return s.Keys(e).filter(a=>a in t).reduce((a,i)=>({...a,[i]:we([e[i],t[i]])}),{})}function Vl(e,t){return s.ShiftLeft(e,(n,r)=>Vl(r,Fb(t,Pe(n))),()=>t)}function Wl(e){return s.ShiftLeft(e,(t,n)=>Vl(n,Pe(t)),()=>J())}function Pe(e){return ce(e)?Ul(e.$defs,e.$ref):V(e)?Kl(e.if,e.then,e.else):O(e)?zl(e.allOf):x(e)?Wl(e.anyOf):G(e)?Bl(e.items):L(e)?e.properties:{}}function fn(e){let t=Pe(e);return v(t)}var Db=new RegExp("^(?:0|[1-9][0-9]*)$");function hn(e){let t=`${e}`;return Db.test(t)?parseInt(t):e}function Gb(e){return P(hn(e))}function Hl(e){return e.map(t=>Yl(t))}function Yl(e){return O(e)?ge(Hl(e.allOf)):x(e)?w(Hl(e.anyOf)):q(e)?Gb(e.const):e}function Jl(e,t){let n=Yl(t),r=le({},n,ke());return b.IsExtendsTrueLike(r)?e:q(t)&&s.IsEqual(t.const,"length")?ke():F()}function Zl(e,t){let n=Je(e,t);return Ee(n)}function Xl(e,t,n){let r=Ne(e,t,n);return Ee(r)}function Ql(e){let t=Se(e);return Ee(t)}function ed(e){let t=z(e);return Ee(t)}function td(e){return[`${e}`]}function nd(e){let t=Te(e);return Ee(t)}function rd(e){return e.reduce((t,n)=>[...t,...Ee(n)],[])}function Ee(e){return ce(e)?Zl(e.$defs,e.$ref):V(e)?Xl(e.if,e.then,e.else):ye(e)?Ql(e.enum):O(e)?ed(e.allOf):q(e)?td(e.const):Q(e)?nd(e.pattern):x(e)?rd(e.anyOf):[]}function gn(e){return Ee(e)}function tr(e,t){return t.map(n=>nr(e,n))}function nr(e,t){return K(t)?Re(nr(e,t.items)):oe(t)?Ue(tr(e,t.parameters),nr(e,t.instanceType)):ie(t)?Ke(tr(e,t.parameters),nr(e,t.returnType)):G(t)?ee(tr(e,t.items)):x(t)?w(tr(e,t.anyOf)):O(t)?ge(tr(e,t.allOf)):Br(t)?v(e):t}function ad(e,t){return nr(e,t)}function Nb(e,t){let n=t in e?e[t]:F();return ad(e,n)}function od(e,t){return t.reduce((n,r)=>[...n,Nb(e,r)],[])}function _b(e,t){let n=gn(t),r=od(e,n);return we(r)}var Ub=new RegExp(vt);function Kb(e){return e.filter(n=>Ub.test(n))}function zb(e){let t=Rr(e),n=Kb(t),r=od(e,n);return we(r)}function id(e,t){return X(t)?zb(e):_b(e,t)}function Bb(e){return P(hn(e))}function sd(e){return e.map(t=>Vo(t))}function Vo(e){return O(e)?ge(sd(e.allOf)):x(e)?w(sd(e.anyOf)):q(e)?Bb(e.const):e}function Vb(e,t){return e.reduceRight((n,r,a)=>{let i=le({},P(a),t);return b.IsExtendsTrueLike(i)?[r,...n]:n},[])}function Wb(e,t){let n=Vo(t),r=Vb(e,n);return mt(r)}function Hb(e){return mt(e)}function md(e,t){return q(t)&&s.IsEqual(t.const,"length")?P(e.length):X(t)||xe(t)?Hb(e):Wb(e,t)}function pd(e,t){return K(e)?Jl(e.items,t):L(e)?id(e.properties,t):G(e)?md(e.items,t):F()}function Yb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Bo(e,t,n){return k([e,t])?p.Update(pd(Yb(e),t),{},n):Un(e,t,n)}function ud(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Bo(i,m,a)}function na(e,t={}){return I("InstanceType",[e],t)}function cd(e,t={}){return Wo(e,t)}function Jb(e){return oe(e)?e.instanceType:F()}function Wo(e,t){return k([e])?p.Update(Jb(e),{},t):na(e,t)}function ld(e,t,n,r={}){let a=d(e,t,n);return Wo(a,r)}function Kn(e,t={}){return I("KeyOf",[e],t)}function dd(e,t={}){return Ho(e,t)}function fd(){return w([ke(),Ce(),Qt()])}function hd(e){return ke()}function Zb(e){return e.reduce((n,r)=>Lr(r)?[...n,P(hn(r))]:J(),[])}function gd(e){let t=s.Keys(e),n=Zb(t);return mt(n)}function yd(e){return nn(e)}function xd(e){let t=e.map((n,r)=>P(r));return mt(t)}function Id(e){return Z(e)?fd():K(e)?hd(e.items):L(e)?gd(e.properties):de(e)?yd(e):G(e)?xd(e.items):F()}function Xb(e){return ce(e)||V(e)||O(e)||x(e)?fn(e):e}function Ho(e,t){return k([e])?p.Update(Id(Xb(e)),{},t):Kn(e,t)}function bd(e,t,n,r){let a=d(e,t,n);return Ho(a,r)}function Gn(e,t,n,r,a={}){return I("Mapped",[e,t,n,r],a)}function vd(e,t,n,r,a={}){return Yo({},_([],[]),e,t,n,r,a)}function Qb(e){let t=Te(e);return wa(t)}function ev(e){return e.reduce((t,n)=>[...t,...wa(n)],[])}function tv(e){let t=Se(e);return wa(t)}function nv(e){return s.IsNumber(e)?[P(`${e}`)]:[P(e)]}function wa(e){return ye(e)?tv(e.enum):q(e)?nv(e.const):Q(e)?Qb(e.pattern):x(e)?ev(e.anyOf):[e]}function $d(e){return wa(e)}function rv(e){return Q(e)?Te(e.pattern):e}function av(e,t,n,r,a,i){let m=p.Assign(e,{[n.name]:r}),u=d(m,t,a),l=rv(u),f=d(m,t,i);return Ps(l)||As(l)?{[l.const]:f}:{}}function ov(e,t,n,r,a,i){return r.reduce((m,u)=>[...m,av(e,t,n,u,a,i)],[])}function iv(e){return e.reduce((t,n)=>[...t,v(n)],[])}function Td(e,t,n,r,a,i){let m=$d(r),u=ov(e,t,n,m,a,i),l=iv(u);return z(l)}function Yo(e,t,n,r,a,i,m){return k([r])?p.Update(Td(e,t,n,r,a,i),{},m):Gn(n,r,a,i,m)}function kd(e,t,n,r,a,i,m){let u=d(e,t,r);return Yo(e,t,n,u,a,i,m)}function sv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>n.includes(i)).reduce((i,m)=>({...i,[m]:ol(r,m,t[m])}),{})}function mv(e,t,n){let r=p.Assign(e,t);return s.Keys(t).filter(i=>!n.includes(i)).reduce((i,m)=>({...i,[m]:d(r,_([],[]),t[m])}),{})}function pv(e,t,n){let r=tl(t),a=sv(e,t,r),i=mv(e,t,r),m={...a,...i};return p.Update(m,{},n)}function Ea(e,t,n,r){return pv(e,n,r)}function ra(e,t={}){return I("NonNullable",[e],t)}function wd(e,t={}){return Jo(e,t)}function uv(e){let t=w([Zt(),rn()]);return er(e,t,{})}function Jo(e,t){return k([e])?p.Update(uv(e),{},t):ra(e,t)}function Ed(e,t,n,r){let a=d(e,t,n);return Jo(a,r)}function aa(e,t,n={}){return I("Omit",[e,t],n)}function Rd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return Zo(e,r,n)}function Ra(e){let t=fn(e);return L(t)?t.properties:J()}function cv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?r:{...r,[a]:e[a]},{})}function Sd(e,t){let n=Ra(e),r=gn(t),a=cv(n,r);return v(a)}function Zo(e,t,n){return k([e,t])?p.Update(Sd(e,t),{},n):aa(e,t,n)}function Od(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return Zo(i,m,a)}function oa(e,t={}){return I("Parameters",[e],t)}function Pd(e,t={}){return Xo(e,t)}function lv(e){let t=ie(e)?e.parameters:[],n=Et({},_([],[]),t);return ee(n)}function Xo(e,t){return k([e])?p.Update(lv(e),{},t):oa(e,t)}function Ad(e,t,n,r){let a=d(e,t,n);return Xo(a,r)}function ia(e,t={}){return I("Partial",[e],t)}function Cd(e,t={}){return Qo(e,t)}function Md(e,t){let n=Je(e,t),r=Ze(n);return Be(p.Assign(e,{[t]:r}),t)}function Ld(e,t,n){let r=Ne(e,t,n);return Ze(r)}function qd(e){let t=z(e);return Ze(t)}function jd(e){let t=e.map(n=>Ze(n));return w(t)}function Fd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Ct(e[a])}),{});return v(t)}function Ze(e){return ce(e)?Md(e.$defs,e.$ref):V(e)?Ld(e.if,e.then,e.else):O(e)?qd(e.allOf):x(e)?jd(e.anyOf):L(e)?Fd(e.properties):v({})}function Qo(e,t){return k([e])?p.Update(Ze(e),{},t):ia(e,t)}function Dd(e,t,n,r){let a=d(e,t,n);return Qo(a,r)}function sa(e,t,n={}){return I("Pick",[e,t],n)}function Gd(e,t,n={}){let r=s.IsArray(t)?dn(t):t;return ei(e,r,n)}function dv(e,t){return s.Keys(e).reduce((r,a)=>t.includes(a)?p.Assign(r,{[a]:e[a]}):r,{})}function Nd(e,t){let n=Ra(e),r=gn(t),a=dv(n,r);return v(a)}function ei(e,t,n){return k([e,t])?p.Update(Nd(e,t),{},n):sa(e,t,n)}function _d(e,t,n,r,a){let i=d(e,t,n),m=d(e,t,r);return ei(i,m,a)}function ma(e,t={}){return I("ReadonlyObject",[e],t)}function ti(e,t={}){return ni(e,t)}var Ud=ti;function Kd(e){return Jt(Re(e))}function zd(e,t){let n=Je(e,t),r=Xe(n);return Be(p.Assign(e,{[t]:r}),t)}function Bd(e,t,n){let r=Ne(e,t,n);return Xe(r)}function Vd(e){let t=z(e);return Xe(t)}function Wd(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:qt(e[a])}),{});return v(t)}function Hd(e){return Jt(ee(e))}function Yd(e){let t=e.map(n=>Xe(n));return w(t)}function Xe(e){return K(e)?Kd(e.items):ce(e)?zd(e.$defs,e.$ref):V(e)?Bd(e.if,e.then,e.else):O(e)?Vd(e.allOf):L(e)?Wd(e.properties):G(e)?Hd(e.items):x(e)?Yd(e.anyOf):e}function ni(e,t){return k([e])?p.Update(Xe(e),{},t):ma(e)}function Jd(e,t,n,r){let a=d(e,t,n);return ni(a,r)}function Zd(e,t,n,r){return t.visited.includes(r)?n:r in e?d(e,_(t.callstack,[...t.visited,r]),e[r]):n}function Xd(e,t){let n=Je(e,t),r=Qe(n);return Be(p.Assign(e,{[t]:r}),t)}function Qd(e,t,n){let r=Ne(e,t,n);return Qe(r)}function ef(e){let t=z(e);return Qe(t)}function tf(e){let t=e.map(n=>Qe(n));return w(t)}function nf(e){let t=s.Keys(e).reduce((r,a)=>({...r,[a]:Gr(e[a])}),{});return v(t)}function Qe(e){return ce(e)?Xd(e.$defs,e.$ref):V(e)?Qd(e.if,e.then,e.else):O(e)?ef(e.allOf):x(e)?tf(e.anyOf):L(e)?nf(e.properties):v({})}function pa(e,t={}){return I("Required",[e],t)}function rf(e,t={}){return ri(e,t)}function ri(e,t){return k([e])?p.Update(Qe(e),{},t):pa(e,t)}function af(e,t,n,r){let a=d(e,t,n);return ri(a,r)}function ua(e,t={}){return I("ReturnType",[e],t)}function of(e,t={}){return ai(e,t)}function fv(e){return ie(e)?e.returnType:F()}function ai(e,t){return k([e])?p.Update(fv(e),{},t):ua(e,t)}function sf(e,t,n,r={}){let a=d(e,t,n);return ai(a,r)}function ca(e,t){return I("With",[e,t],{})}function mf(e,t){return oi(e,t)}function oi(e,t){return k([e])?p.Update(e,{},t):ca(e,t)}function pf(e,t,n,r){let a=d(e,t,n);return oi(a,r)}function hv(e){return $t(e)?G(e.items)?ii(e.items.items):Y(e.items)?[e]:se(e.items)?[e]:[F()]:[e]}function ii(e){return e.reduce((n,r)=>[...n,...hv(r)],[])}function _(e,t){return{callstack:e,visited:t}}function k(e){return s.ShiftLeft(e,(t,n)=>se(t)?!1:k(n),()=>!0)}function Yn(e,t,n){return s.Keys(n).reduce((r,a)=>({...r,[a]:d(e,t,n[a])}),{})}function Et(e,t,n){let r=Oe(e,t,n);return ii(r)}function Oe(e,t,n){return n.map(r=>d(e,t,r))}function gv(e,t){let n=he(e)?Rn(t,{}):t,r=jt(e)?En(n,{}):n;return Lt(e)?rr(r,{}):r}function yv(e,t,n,r,a){return s.IsEqual(n,"AddImmutable")?uf(e,t,r[0],a):s.IsEqual(n,"RemoveImmutable")?Il(e,t,r[0],a):s.IsEqual(n,"AddReadonly")?os(e,t,r[0],a):s.IsEqual(n,"RemoveReadonly")?Bs(e,t,r[0],a):s.IsEqual(n,"AddOptional")?is(e,t,r[0],a):s.IsEqual(n,"RemoveOptional")?Hs(e,t,r[0],a):s.IsEqual(n,"Capitalize")?Sl(e,t,r[0],a):s.IsEqual(n,"Conditional")?Ml(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"ConstructorParameters")?ql(e,t,r[0],a):s.IsEqual(n,"Evaluate")?ml(e,t,r[0],a):s.IsEqual(n,"Exclude")?Fl(e,t,r[0],r[1],a):s.IsEqual(n,"Extract")?Nl(e,t,r[0],r[1],a):s.IsEqual(n,"Index")?ud(e,t,r[0],r[1],a):s.IsEqual(n,"InstanceType")?ld(e,t,r[0],a):s.IsEqual(n,"Interface")?Zc(e,t,r[0],r[1],a):s.IsEqual(n,"KeyOf")?bd(e,t,r[0],a):s.IsEqual(n,"Lowercase")?Ol(e,t,r[0],a):s.IsEqual(n,"Mapped")?kd(e,t,r[0],r[1],r[2],r[3],a):s.IsEqual(n,"Module")?Ea(e,t,r[0],a):s.IsEqual(n,"NonNullable")?Ed(e,t,r[0],a):s.IsEqual(n,"Pick")?_d(e,t,r[0],r[1],a):s.IsEqual(n,"Parameters")?Ad(e,t,r[0],a):s.IsEqual(n,"Partial")?Dd(e,t,r[0],a):s.IsEqual(n,"Omit")?Od(e,t,r[0],r[1],a):s.IsEqual(n,"ReadonlyObject")?Jd(e,t,r[0],a):s.IsEqual(n,"Record")?cm(e,t,r[0],r[1],a):s.IsEqual(n,"Required")?af(e,t,r[0],a):s.IsEqual(n,"ReturnType")?sf(e,t,r[0],a):s.IsEqual(n,"TemplateLiteral")?hc(e,t,r[0],a):s.IsEqual(n,"Uncapitalize")?Pl(e,t,r[0],a):s.IsEqual(n,"Uppercase")?Al(e,t,r[0],a):s.IsEqual(n,"With")?pf(e,t,r[0],r[1]):I(n,r,a)}function xv(e,t,n){let r=se(n)?Zd(e,t,n,n.$ref):K(n)?Re(d(e,t,n.items),Er(n)):ln(n)?ka(e,t,n.target,n.arguments):oe(n)?Ue(Oe(e,t,n.parameters),d(e,t,n.instanceType),ss(n)):ie(n)?Ke(Oe(e,t,n.parameters),d(e,t,n.returnType),ms(n)):V(n)?Mt(d(e,t,n.if),d(e,t,n.then),d(e,t,n.else),fs(n)):O(n)?ge(Oe(e,t,n.allOf),Is(n)):L(n)?v(Yn(e,t,n.properties),ls(n)):de(n)?lm(Le(n),d(e,t,be(n))):$t(n)?Gt(d(e,t,n.items)):G(n)?ee(Et(e,t,n.items),zs(n)):x(n)?w(Oe(e,t,n.anyOf),Ms(n)):n;return gv(n,r)}function d(e,t,n){return gt(n)?yv(e,t,n.action,n.parameters,n.options):xv(e,t,n)}function si(e,t){return d(e,_([],[]),t)}function Iv(e){return p.Update(e,{"~immutable":!0},{})}function rr(e,t){return p.Update(Iv(e),{},t)}function uf(e,t,n,r){let a=d(e,t,n);return rr(a,r)}function du(e,t={}){return I("AddImmutable",[e],t)}function Jt(e,t={}){return rr(e,t)}function fu(e,t={}){return I("Evaluate",[e],t)}function cf(e,t={}){return jo(e,t)}function hu(e,t={}){return I("Module",[e],t)}function lf(e,t={}){return Ea({},_([],[]),e,t)}function df(...e){let[t,n,r]=Ve.Match(e,{2:(m,u)=>s.IsString(m)?[{},m,u]:[m,u,{}],3:(m,u,l)=>[m,u,l],1:m=>[{},m,{}]}),a=uc(n),i=s.IsArray(a)&&s.IsEqual(a.length,2)?d(t,_([],[]),a[0]):F();return p.Update(i,{},r)}var D={};St(D,{Any:()=>Yt,Array:()=>Re,BigInt:()=>An,Boolean:()=>Cr,Call:()=>yl,Capitalize:()=>kl,Codec:()=>Ar,Conditional:()=>Cl,Constructor:()=>Ue,ConstructorParameters:()=>Ll,Cyclic:()=>Be,Decode:()=>Ts,DecodeBuilder:()=>Pn,Dependent:()=>Mt,Encode:()=>ks,EncodeBuilder:()=>On,Enum:()=>xs,Evaluate:()=>cf,Exclude:()=>jl,Extends:()=>le,ExtendsResult:()=>b,Extract:()=>Dl,Function:()=>Ke,Generic:()=>yt,Identifier:()=>Cn,Immutable:()=>ws,Index:()=>_l,Infer:()=>Sn,InstanceType:()=>cd,Instantiate:()=>si,Integer:()=>Ft,Interface:()=>Xc,Intersect:()=>ge,IsAny:()=>Z,IsArray:()=>K,IsBigInt:()=>He,IsBoolean:()=>Ae,IsCall:()=>ln,IsCodec:()=>Pr,IsConstructor:()=>oe,IsCyclic:()=>ce,IsDependent:()=>V,IsEnum:()=>ye,IsEnumValue:()=>ys,IsFunction:()=>ie,IsGeneric:()=>Ht,IsIdentifier:()=>Os,IsImmutable:()=>Lt,IsInfer:()=>Y,IsInteger:()=>xe,IsIntersect:()=>O,IsKind:()=>y,IsLiteral:()=>q,IsNever:()=>xt,IsNull:()=>Xt,IsNumber:()=>X,IsObject:()=>L,IsOptional:()=>he,IsParameter:()=>Cs,IsReadonly:()=>jt,IsRecord:()=>de,IsRef:()=>se,IsRefine:()=>io,IsRest:()=>$t,IsSchema:()=>re,IsString:()=>Ie,IsSymbol:()=>It,IsTemplateLiteral:()=>Q,IsThis:()=>Br,IsTuple:()=>G,IsUndefined:()=>an,IsUnion:()=>x,IsUnknown:()=>ae,IsUnsafe:()=>Or,IsVoid:()=>Ye,KeyOf:()=>dd,Literal:()=>P,Lowercase:()=>wl,Mapped:()=>vd,Module:()=>lf,Never:()=>F,NonNullable:()=>wd,Null:()=>Zt,Number:()=>ke,Object:()=>v,Omit:()=>Rd,Optional:()=>us,Parameter:()=>Dt,Parameters:()=>Pd,Partial:()=>Cd,Pick:()=>Gd,Readonly:()=>Es,ReadonlyObject:()=>ti,ReadonlyType:()=>Ud,Record:()=>Ur,RecordKey:()=>nn,RecordPattern:()=>Le,RecordValue:()=>be,Ref:()=>st,Refine:()=>Rs,Required:()=>rf,Rest:()=>Gt,ReturnType:()=>of,Script:()=>df,String:()=>Ce,Symbol:()=>Qt,TemplateLiteral:()=>yc,This:()=>zr,Tuple:()=>ee,Uncapitalize:()=>El,Undefined:()=>rn,Union:()=>w,Unknown:()=>me,Unsafe:()=>ds,Uppercase:()=>Rl,Void:()=>Vr,With:()=>mf});var ar="submit_test_gap_candidates",or="submit_filtered_test_gaps",ir="submit_solver_gaps",r8=D.Object({verdict:D.Union([D.Literal("PASS"),D.Literal("FAIL")],{description:"FAIL only for a genuine blocking issue (clear rubric violation, agent-fault-worthy gap, unfair/undiscoverable test requirement, or a real determinism/regression risk). Optional, minor, or stylistic points are NOT grounds for FAIL \u2014 put those in `notes` instead and use PASS."}),summary:D.String({description:"One short sentence summarizing the verdict."}),reasons:D.Array(D.String(),{description:"Specific BLOCKING justifications only, citing rubric item IDs and concrete evidence from the files you read. Required (non-empty) when verdict is FAIL. Use an empty array when verdict is PASS."}),notes:D.Array(D.String(),{description:"Non-blocking, optional/minor observations or suggested improvements \u2014 the kind of feedback a real reviewer leaves as 'Minor/optional' without failing the task. Include these regardless of verdict; use an empty array if you truly have none."})});var bv=D.Object({statement:D.String({description:"One sentence from agent_prompt.md, copied verbatim."}),gaps:D.Array(D.Object({description:D.String({description:"A fair, publicly observable missing behavioral test."}),risk:D.String({description:"Why an incorrect implementation could pass the current tests despite this missing behavior."})}),{description:"All candidate positive and negative gaps for this sentence; there is no maximum or target count, so include every distinct evidence-backed gap and relevant edge case rather than stopping at 10; use an empty array only when exhaustive analysis finds none."})});function ff(e){return{name:ar,label:"Submit Candidate Test Gaps",description:"Submit one candidate-gap list for one prompt sentence. Call this after each sentence so the orchestrator can track the todo list; empty lists are required when that sentence has no gaps.",parameters:bv,async execute(t,n){let r=e.statements??[];return r.push({statement:n.statement,gaps:n.gaps??[]}),e.statements=r,{content:[{type:"text",text:`Recorded ${n.gaps?.length??0} candidate gap(s)`}],details:void 0}}}}var vv=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The confirmed, real, fair test gap (may be reworded for clarity). Keep POSITIVE:/NEGATIVE: prefix when applicable."}),justification:D.String({description:"Why this is genuinely grounded in agent_prompt.md or the repo, fair to test per the fairness methodology, and a real (non-duplicate) coverage hole in test.patch \u2014 for negative gaps, cite the prompt's prohibition/constraint and why no existing test catches the forbidden outcome."})}),{description:"The filtered, final list of confirmed test gaps. Use an empty array if none of the candidates survive strict scrutiny."})});function hf(e){return{name:or,label:"Submit Filtered Test Gaps",description:"Submit your final, strictly filtered list of confirmed test gaps. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have independently verified each candidate.",parameters:vv,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Confirmed ${r.length} gap(s) after filtering`}],details:void 0}}}}var $v=D.Object({gaps:D.Array(D.Object({description:D.String({description:"The specific behavioral gap: a way one or more solver's diff differs materially from what agent_prompt.md/solution.patch require, despite that solver passing `./test.sh new`."}),justification:D.String({description:"Why this is a genuine requirement from agent_prompt.md or solution.patch (cite the specific requirement/line) that the solver's diff misses, contradicts, or diverges from \u2014 and why the current tests fail to catch that divergence."}),evidence:D.String({description:"Which solver(s) (by index) exhibit this, and the specific part of their diff that grounds the gap."})}),{description:"Concrete, diff-grounded behavioral gaps \u2014 cases where a passing solver's materially different approach reveals that `test.sh new` under-specifies a real requirement. Use an empty array if the solvers converged on equivalent behavior; do not manufacture gaps just to report something."})});function gf(e){return{name:ir,label:"Submit Solver Gaps",description:"Submit your final list of behavioral gaps found by comparing the solver diffs against the real solution.patch. This is the ONLY way to report your result \u2014 call it exactly once, as your last action, after you have finished comparing every solver.",parameters:$v,async execute(t,n){let r=n.gaps??[];return e.gaps=r,{content:[{type:"text",text:`Recorded ${r.length} solver gap(s)`}],details:void 0}}}}function Tv(e){return[e,"You are working inside the actual repository (this is your current directory) in read-only mode. You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Read `agent_prompt.md` for the task requirements and inspect the repository's existing source/code files with read/grep/find/ls. Base the analysis on the prompt and the observable behavior supported by those code files."]}var kv=["Thoroughness \u2014 your job is high recall on genuine gaps only:","- There is no target count or cap: do not stop at 10 (or any other arbitrary number). For each prompt sentence, enumerate as many distinct uncovered required behaviors and edge cases as the files justify, then continue until an additional sweep finds no new genuine gap.","- Find every gap you can justify with concrete evidence. Do not stop after the first obvious ones \u2014 keep reading until you have systematically covered the prompt and relevant repository code.","- After your first pass, run at least one deliberate second sweep (re-read `agent_prompt.md` and grep/read the relevant code files) before submitting \u2014 but if that sweep still finds nothing, submit an empty list.","- Do not self-censor or merge distinct genuine gaps into one \u2014 the validator will prune. Never invent or pad the list to seem thorough; an empty array is correct when exhaustive analysis truly finds none.","- Hunt subtle gaps too: behaviors that may be missed under other valid inputs, repository conventions, interaction effects, ordering/timing, and branches in the relevant source code that need behavioral coverage.","- Include a candidate only when you can cite specific grounding and a concrete false-pass risk \u2014 not to meet a quota."],yf=["Ground rules \u2014 do not overreach:","- Every gap must trace back to a specific requirement or sentence in `agent_prompt.md`, or to behavior that is unambiguous from the existing, visible repo. Do not invent requirements the prompt doesn't support.","- Do not propose gaps for things `agent_prompt.md` leaves intentionally open, or for implementation details/style the prompt doesn't mandate.","- Read the relevant source files carefully and distinguish genuinely required behavior from speculation; focus on public outcomes and edge cases that deserve behavioral coverage.","- Keep findings strictly behavioral and publicly observable: a user, caller, or documented public contract must be able to observe the required outcome. Do not report internal helper calls, private state, implementation structure, call order, file placement, or other incidental mechanics.","- Do not require DOM classes, DOM/data/test attributes, selectors, or exact string literals unless the prompt explicitly names them or they are an established, already-present public contract in the repository. Prefer a visible outcome or public API behavior that accepts equivalent implementations."],wv=["General calibration for validation:","- Check the required semantic properties and observable outcomes, while allowing valid additional data or equivalent implementations that do not weaken the contract.","- Assert relationships and effects required by the prompt rather than selecting an arbitrary concrete value when the prompt or an established public contract does not determine one.","- Compare behavior semantically. Do not reject equivalent representations merely because their syntax, formatting, ordering, or serialization differs unless that representation is part of the stated contract.","- Require exact wording, formatting, timing, or reporting details only when the prompt or an established public contract makes them observable requirements; otherwise validate the underlying operation or result.","- Do not invent behavior for cases the prompt leaves open. Treat examples, defaults, neighboring implementation choices, and reference-solution conventions as context, not as additional requirements."];function xf(e,t){let n=[...Tv("You are an exhaustive behavioral test-gap finder. Review the task prompt sentence by sentence, finding both missing required-behavior (positive) and missing forbidden/wrong-behavior (negative) tests."),"","First split `agent_prompt.md` into its meaningful sentences using periods (`.`) as the sentence boundary. Create an explicit TODO checklist of every resulting requirement sentence. Work through it one item at a time; do not finish until every item is checked off.","","Before analyzing each sentence, use read/grep/find/ls to inspect the relevant source files and their closest analogues. Use that code context to understand the public contracts, conventions, branches, guards, early returns, state transitions, side effects, boundary handling, and negative/prohibited outcomes required by the sentence. Report every distinct, prompt-required behavioral edge case or prohibition that a plausible implementation could miss. Include positive and negative gaps together for that sentence. There is no maximum number of gaps: keep enumerating distinct missing behaviors for this sentence, including boundary, empty, repeated, interacting, and other relevant edge cases; do not treat 10 as sufficient.","",...kv,"",...yf,"","Test-coverage checklist for calibration:",e];return n.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements."),n.push("","For every candidate, state the missing fair behavioral test, the relevant source behavior or branch that led you to investigate it, and why a plausible incorrect implementation could evade that test. The prompt sentence is the required specification: do not report incidental implementation details it does not require. Do not propose the exact test implementation.",`After completing EACH TODO sentence, call \`${ar}\` with that exact sentence and its gap array (including an empty array when none exist). You may and must call the tool multiple times: once per sentence. Only finish after every TODO item has been submitted.`),n.join(`
|
|
12
|
+
`)}function If(e,t,n){let r=["You are a strict, skeptical fairness auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code or edit files.","Two specialized research agents reviewed `agent_prompt.md` and the repository's source/code files sentence by sentence, proposing both positive (missing required-behavior) and negative (missing forbidden/wrong-behavior) gaps. It submitted the following per-sentence candidate report:","",JSON.stringify(e,null,2),"","Your job is to independently re-verify the files yourself and FILTER this list down to only candidates that are ALL of the following:","1. Genuinely grounded \u2014 actually required by a specific statement in `agent_prompt.md`, or unambiguous from clearly visible, existing repo behavior. Drop anything speculative, nice-to-have, or invented beyond what the prompt actually asks for.","2. Fair to test \u2014 verifying it would not require undiscoverable private internals, an invented/unnamed API, or exact incidental implementation structure. Judge this precisely against the fairness guidance below.","3. A real, distinct behavioral gap \u2014 drop near-duplicate candidates and keep only the clearest phrasing of each distinct gap. Retain a candidate only when the source code and prompt provide concrete grounding for a behavior that deserves an explicit public-outcome check.","4. Behaviorally testable through a public contract \u2014 drop candidates that would require an internal helper, private state, implementation structure, call order, DOM class/attribute/data hook, selector, or exact string literal. The sole exceptions are details explicitly named in `agent_prompt.md` or already established as a public contract in the existing repository.","","Be strict: when genuinely unsure whether a candidate holds up, drop it rather than keep it. It is fine \u2014 expected, even \u2014 to return an empty list if none of the candidates survive scrutiny.","","Checklist for the tests focus area, for calibration:",t];return r.push("","Fairness: keep only behavior that a user, caller, or existing public contract can observe. Do not require private helpers, internal state, implementation structure, call order, selectors, or incidental strings unless the task explicitly makes them public requirements.","",...wv),r.push("","For every gap you keep, give a short justification citing where in `agent_prompt.md` or the repo it is grounded. Preserve POSITIVE:/NEGATIVE: prefix when applicable.",`When you are done, call the \`${or}\` tool exactly once with your final filtered list (which may be empty). That tool call is your only way to report a result.`),r.join(`
|
|
13
|
+
`)}function bf(){return["You are a adversarial tester. Your goal is to find the most minimal, shortcut implementation that makes all new tests pass \u2014 not a full, correct solution. This is intentional: we want to discover whether the test suite lets through an implementation that barely satisfies the assertions without properly implementing the prompt's required behavior.","`agent_prompt.md` in the repo root describes the intended task. Tests for it already exist and are currently failing.","","Goal: make ALL of the new tests pass with the least amount of real logic possible.","1. Run `bash test.sh new` to see the failures and what the tests expect. Read the failing tests carefully \u2014 they are the only spec you need to satisfy.","2. Understand exactly what each test assertion checks. Ask, 'what is the minimum thing I can do \u2014 a stub, a hardcoded return, a mockish pass-through, a trivial branch \u2014 to satisfy this test?', not 'what does agent_prompt.md intend?'. Skim `agent_prompt.md` only enough to understand what the test file names and assertions refer to, then rely on the test errors to drive what to implement.","3. Prefer the most minimal implementation possible:"," - Hardcode a return value if the test expects one."," - Add only the code paths a test actually exercises; leave anything untested unimplemented."," - Mock the minimum number of dependencies (or none) that the test error forces you to touch."," - Use the most direct, trivial, shortcut approach \u2014 do not build abstractions, do not handle unobserved edge cases, do not add defensive code.","4. Before declaring success, also run `bash test.sh base` to confirm your changes cause no regressions. The shortcut must not break existing tests \u2014 that would be a false positive from a different angle.","5. Re-run `bash test.sh new` and iterate until both the new tests and the base tests pass, or you're confident you cannot pass more without adding real logic.","","Rules:","- Do NOT modify the test files or `test.sh`. Only change application/library code.","- You have shell access \u2014 install any dependencies you need.","- The prompt is not your spec: the tests are. Implement exactly what the tests demand, nothing more. If you can satisfy a test with a hardcoded return, do it."].join(`
|
|
14
|
+
`)}function Ev(e){let t=e.status==="ok"?e.passed?"PASSED all new tests":"did NOT pass all new tests":`did not complete normally (status: ${e.status})`;return`- Solver ${e.index} \u2014 ${t} \u2014 solution.diff / test_output.txt in \`${vn}/solver_${e.index}/\``}function vf(e,t,n){let r=["You are a strict, skeptical behavioral-gap auditor for a coding-agent benchmark task.","You are working inside a throwaway, read-only copy of a git repository (this is your current directory). You have access to read/grep/find/ls tools only \u2014 you cannot execute code, apply patches, or edit files.","The repo root contains `agent_prompt.md` (the real task description), `solution.patch` (a unified diff of the real golden/reference solution), and `test.patch` (a unified diff adding the hidden tests).","",`Separately, several coding agents ('solvers') were each given the same \`agent_prompt.md\` plus the failing tests from \`test.patch\` \u2014 but never \`solution.patch\` \u2014 and asked to implement the task TDD-style, iterating with real shell access until the tests passed or they gave up. Each solver's diff and full \`test.sh new\` output \u2014 captured and verified independently by the harness, not self-reported \u2014 is saved under \`${vn}/solver_<index>/\` (\`solution.diff\`, \`test_output.txt\`), with a \`${vn}/manifest.json\` summary. Use read/grep/find/ls to open exactly what you need. Status summary:`,"",...e.map(Ev),"","Your job: compare the reference `solution.patch` with each solver's `solution.diff` to find concrete BEHAVIORAL GAPS. Keep only a difference where: (a) `agent_prompt.md` explicitly requires the behavior, (b) the solver passed the relevant tests (even if it failed elsewhere), (c) the reference and solver produce observably different behavior for a real edge case or scenario, and (d) a fair public-facing test could distinguish them. The reference solution is evidence for scenarios to inspect, never a specification by itself.","","How to work:","1. Read `agent_prompt.md` sentence by sentence and note every distinct requirement, constraint, and prohibition.","2. Read `solution.patch` to see how the reference solution satisfies those requirements.","3. For each solver, read its `solution.diff` and compare it against the reference behavior. Look specifically for a solver shortcut, missed constraint, edge case, or side effect that the PROMPT requires, where the solver still passes because the tests do not observe the behavioral difference.","4. A solver that did not pass the full suite may still provide evidence for a completed, relevant part of its diff, but only when its test output shows the failure is unrelated to that behavior (or shows the relevant tests already passed). Do not treat its failing behavior as a gap, and do not infer gaps from a hypothetical wrong implementation.","5. Treat multiple solvers converging on the same divergent-but-passing shortcut as stronger evidence of a real gap, not proof it's acceptable \u2014 the tests are what's under scrutiny, not majority solver behavior.","",...yf,"- Every gap must be evidenced by an actual, cited solver diff and a contrasting reference behavior. For a solver that failed the full suite, also cite its test output showing that the relevant behavior already passed or is unrelated to the failure. Cite the prompt sentence that makes the behavioral difference required; do not report a gap that is purely theoretical or based only on the reference implementation.","- It is fine, and expected, to submit an empty list if the solvers that passed all converged on behavior equivalent to the reference solution with no material gaps.","- Do not self-censor for volume, but do not pad the list either \u2014 only include what you can concretely justify with cited evidence.","","For reference, here is the checklist for the tests focus area (use it to calibrate what good coverage looks like, not as a list of gaps to report verbatim):",t];return n&&r.push("","Fairness methodology (context on what a fair, in-scope requirement looks like):",n),r.push("",`When you are done, call the \`${ir}\` tool exactly once with your final list (which may be empty). That tool call is your only way to report a result.`),r.join(`
|
|
15
|
+
`)}var Rv=900*1e3,mi=["read","grep","find","ls"];function Pa(e){return e==="off"?void 0:e}async function Aa(e,t,n=Rv){let r=t.aborted?"cancelled":"done";return await Promise.race([e().then(()=>{t.aborted||(r="done")}),new Promise(a=>{setTimeout(()=>{r="timedOut",a()},n)}),new Promise(a=>{if(t.aborted)return a();t.addEventListener("abort",()=>{r="cancelled",a()},{once:!0})})]),r}async function Ca(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,ar],customTools:[ff(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt(xf(e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.statements?{status:"ok",gaps:t.statements}:{status:"noSubmission",gaps:[]}}var Sv=["read","grep","find","ls","write","edit","bash"];async function $f(e){let t=e.model;try{let n=Oa.inMemory(),{session:r}=await Sa({cwd:e.solverDir,model:t,thinkingLevel:Pa(e.thinkingLevel),tools:[...Sv],sessionManager:n}),a=await Aa(async()=>{await r.prompt(bf())},e.cancelSignal,e.timeoutMinutes*60*1e3);return a!=="done"&&await r.abort(),{outcome:a,trajectory:n.getEntries()}}catch{return{outcome:"error",trajectory:[]}}}async function Tf(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,ir],customTools:[gf(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt(vf(e.solverResults,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}async function Ma(e){let t={},n=e.model,{session:r}=await Sa({cwd:e.tempDir,model:n,thinkingLevel:Pa(e.thinkingLevel),tools:[...mi,or],customTools:[hf(t)],sessionManager:Oa.inMemory()});try{let a=await Aa(async()=>{await r.prompt(If(e.statementReports,e.testRubric,e.fairnessRules))},e.cancelSignal);if(a!=="done")return await r.abort(),{status:a,gaps:[]}}catch{return{status:"error",gaps:[]}}return t.gaps?{status:"ok",gaps:t.gaps}:{status:"noSubmission",gaps:[]}}var Rt="checks_progress";function sr(e,t,n,r){let a=n>0?Math.min(1,t/n):0,i=Math.round(24*a),m="\u2588".repeat(i)+"\u2591".repeat(Math.max(0,24-i)),u=r?` pass:${r.passed} fail:${r.failed}`:"";return[`checks: ${e} [${m}] ${t}/${n}${u}`]}import{existsSync as Ov,readFileSync as Pv}from"node:fs";var pi=["agent_prompt.md","solution.patch","test.patch"];function ui(e=new Date){let t=(i,m=2)=>String(i).padStart(m,"0"),n=-e.getTimezoneOffset(),r=n>=0?"+":"-",a=Math.abs(n);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.${t(e.getMilliseconds(),3)}${r}${t(Math.floor(a/60))}:${t(a%60)}`}function kf(e){try{if(!Ov(e))return{};let t=JSON.parse(Pv(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function wf(e){let t={...e.existingReport,timestamp:ui(),model:`${e.config.provider}/${e.config.modelId}`,thinkingLevel:e.config.thinkingLevel};return delete t.overall,delete t.reports,e.runGapFinder&&(t.testGaps=e.testGaps,e.gapAnalysisIncomplete?t.testGapAnalysisNote=`Gap analysis did not fully complete (sentence finder: ${e.gapFinderStatus}, review: ${e.gapFilterStatus}); testGaps may be incomplete.`:delete t.testGapAnalysisNote),e.runSolverGapFinder&&(t.solverRunSummary=e.solverResults.map(n=>({index:n.index,status:n.status,passed:n.passed,durationMs:n.durationMs,totalTests:n.totalTests,failedTests:n.failedTests,artifactsDir:n.artifactsDir})),t.solverGaps=e.solverGaps,e.solverGapAnalysisIncomplete?t.solverGapAnalysisNote=`Solver-gap analysis did not fully complete (comparison reviewer: ${e.solverComparisonStatus}); solverGaps may be incomplete.`:delete t.solverGapAnalysisNote),t}function Ef(e){let t=Math.round(e/1e3);return t>=60?`${Math.floor(t/60)}m ${t%60}s`:`${t}s`}function Rf(e){let t=Array.isArray(e.merged.testGaps)?e.merged.testGaps.length:0,n=e.runSolverGapFinder&&Array.isArray(e.merged.solverRunSummary)?e.merged.solverRunSummary.map(i=>({...i,durationMs:i.durationMs??0})):[],r=Array.isArray(e.merged.solverGaps)?e.merged.solverGaps.length:0,a=[];return e.runGapFinder&&a.push(t>0?`${t} test gap(s) found`:"no test gaps found"),e.runSolverGapFinder&&a.push(`${n.filter(i=>i.passed).length}/${n.length} solvers passed, ${r} gap(s) found`),{content:`Gap finders: ${a.join(" | ")}`,details:{gapsCount:t,showGaps:e.runGapFinder,showSolverGaps:e.runSolverGapFinder,solverDetails:n,solverGapsCount:r}}}var Sf=`## The problem description (aka the task)\r
|
|
16
16
|
P1: Aligns with the repo's philosophy\r
|
|
17
17
|
P2: Self-contained \u2014 solvable from the repo and description alone\r
|
|
18
18
|
P3: Clear, concise, and unambiguous \u2014 describes what to build or fix and don't leave points for guessing\r
|
|
@@ -39,7 +39,7 @@ That's the golden solution \u2014 the proof that your task is solvable and that
|
|
|
39
39
|
S1: The solution should meet all the requirements. (If it's missing a requirement and it manages to pass your tests, you're in a bad position \u{1F620}.)\r
|
|
40
40
|
S2: No regressions and follow existing code patterns. Don't break existing working code by mistake (we'll still run the repo's existing tests).\r
|
|
41
41
|
S3: No irrelevant changes to the code \u2014 if something is unrelated to your task, keep it as it is.\r
|
|
42
|
-
S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,
|
|
42
|
+
S4: No AI slop (weird comments, unexplained defensive code, new coding patterns, etc).`,Av=`# Agent Evaluation Guidelines\r
|
|
43
43
|
\r
|
|
44
44
|
This file describes how to align a task prompt, reference solution, and tests for fair coding-agent evaluation. It is generic and can be reused across repositories and tasks.\r
|
|
45
45
|
\r
|
|
@@ -307,6 +307,11 @@ For every failure cluster, answer:\r
|
|
|
307
307
|
- Requires one exact option ID or registry key when the prompt only requires the user-visible action.\r
|
|
308
308
|
- Reassigns mocked exported state and then blames the implementation for not following the new object identity.\r
|
|
309
309
|
- Treats one internal observation point as mandatory even though the same required outcome can be observed through another public or repo-valid path.\r
|
|
310
|
+
- Check required semantic properties and observable outcomes, while allowing valid additional data or equivalent implementations that do not weaken the contract.\r
|
|
311
|
+
- Assert relationships and effects required by the prompt rather than selecting an arbitrary concrete value when the prompt or an established public contract does not determine one.\r
|
|
312
|
+
- Compare behavior semantically; do not reject equivalent representations merely because syntax, formatting, ordering, or serialization differs unless that representation is part of the stated contract.\r
|
|
313
|
+
- Require exact wording, formatting, timing, or reporting details only when the prompt or an established public contract makes them observable requirements; otherwise validate the underlying operation or result.\r
|
|
314
|
+
- Do not invent behavior for cases the prompt leaves open. Treat examples, defaults, neighboring implementation choices, and reference-solution conventions as context, not as additional requirements.\r
|
|
310
315
|
\r
|
|
311
316
|
---\r
|
|
312
317
|
\r
|
|
@@ -319,9 +324,9 @@ Keep changes separated when possible:\r
|
|
|
319
324
|
- Avoid unrelated dependency or lockfile changes.\r
|
|
320
325
|
- Regenerate patches after every prompt/test/solution change.\r
|
|
321
326
|
\r
|
|
322
|
-
---`;function
|
|
323
|
-
`).trim(),te=H?
|
|
324
|
-
`)):["(no output)"];if(!n.expanded){let ue=Math.max(0,te.length-
|
|
327
|
+
---`;function La(){return(Sf.split(/\r?\n(?=## )/g).find(t=>/^## The tests/i.test(t.trim()))??Sf).trim()}function qa(){return Av.trim()}var ja=!1,yn;function Fa(){return ja}function Of(){return ja=!0,yn=new AbortController,yn}function Pf(){ja=!1,yn=void 0}function Af(){return!ja||!yn||yn.signal.aborted?!1:(yn.abort(),!0)}import{existsSync as Cv}from"node:fs";import{join as Mv}from"node:path";import{keyHint as Lv}from"@earendil-works/pi-coding-agent";import{Text as qv,wrapTextWithAnsi as jv}from"@earendil-works/pi-tui";var mr="analyze_test_gaps",Cf=6;function Mf(e){e.registerTool({name:mr,label:"Gap Finder",description:"Run the sentence-by-sentence behavioral test-gap analysis on the current task and its repository source files: a read-only finder agent splits agent_prompt.md into sentences and proposes missing positive/negative behavioral tests per sentence, then a read-only fairness reviewer filters out unfair or internally-observable candidates (skipped when the finder found nothing). Returns the confirmed gaps as the tool result (details.testGaps). Never writes or modifies files.",promptSnippet:"Analyze the task's hidden tests for behavioral coverage gaps",promptGuidelines:["Use analyze_test_gaps when you need the confirmed list of fair behavioral test gaps for the current task's hidden tests."],parameters:D.Object({}),renderCall(t,n,r){let a=r.state;r.executionStarted&&a.startedAt===void 0&&(a.startedAt=Date.now(),a.endedAt=void 0);let i=r.lastComponent??new qv("",0,0);return i.setText(""),i},renderResult(t,n,r,a){let i=a.state;i.startedAt!==void 0&&n.isPartial&&!i.interval&&(i.interval=setInterval(()=>a.invalidate(),1e3)),(!n.isPartial||a.isError)&&(i.endedAt??=Date.now(),i.interval&&(clearInterval(i.interval),i.interval=void 0));let m=n.isPartial?"Elapsed":"Took",u=i.endedAt??Date.now(),l=i.startedAt!==void 0?Gv(u-i.startedAt):"\u2014",f=t.details,h=Array.isArray(f?.testGaps)?f.testGaps.length:void 0,$=[`${m} ${l}`];h!==void 0&&$.push(`${h} gap${h===1?"":"s"}`);let E=r.fg("toolTitle",r.bold("Gap Finder"))+r.fg("muted",` ${$.join(" \xB7 ")}`),H=(t.content??[]).map(ue=>ue.type==="text"?ue.text:"").join(`
|
|
328
|
+
`).trim(),te=H?Fv(H.split(`
|
|
329
|
+
`)):["(no output)"];if(!n.expanded){let ue=Math.max(0,te.length-Cf);te=te.slice(0,Cf),ue>0&&te.push(`... (${ue} more lines, ${Lv("app.tools.expand","to expand")})`)}let ne=a.lastComponent instanceof Da?a.lastComponent:new Da;return ne.setContent(E,te,r),ne},async execute(t,n,r,a,i){if(!fr(i.cwd))throw new Error("analyze_test_gaps is disabled for this project. Enable it with /analyze:on.");let m=Mv(i.cwd,"agent_prompt.md");if(!Cv(m))throw new Error("Missing required file in project root: agent_prompt.md");let u=ji()??ve(),l=u,f=l?i.modelRegistry.find(l.provider,l.modelId):i.model;if(!f||l&&!i.modelRegistry.hasConfiguredAuth(f))throw new Error("No model configured/authenticated for analyze_test_gaps. Set one via /checks --config (Analyze Tool section).");let h=u?.thinkingLevel??"off",$=new AbortController;r&&(r.aborted?$.abort():r.addEventListener("abort",()=>$.abort(),{once:!0}));let E={tempDir:i.cwd,model:f,thinkingLevel:h,testRubric:La(),fairnessRules:qa(),cancelSignal:$.signal};a?.({content:[{type:"text",text:"Finding behavioral test gaps sentence by sentence..."}],details:{}});let A=await Ca(E);if($.signal.aborted)throw new Error("Cancelled by user.");if(A.status!=="ok")throw new Error(`Gap finder did not complete (status: ${A.status}).`);let H=A.gaps.reduce((ne,ue)=>ne+ue.gaps.length,0),te=[];if(H>0){a?.({content:[{type:"text",text:`Validating ${H} candidate gap(s)...`}],details:{}});let ne=await Ma({...E,statementReports:A.gaps});if($.signal.aborted)throw new Error("Cancelled by user.");if(ne.status!=="ok")throw new Error(`Gap review did not complete (status: ${ne.status}).`);te=ne.gaps}return{content:[{type:"text",text:Nv(te)}],details:{testGaps:te}}}})}function Fv(e){let t=[],n=!1;for(let r of e)/^\s*\d+\.\s+/.test(r)?(n=!1,t.push(r)):/^\s*Justification:/i.test(r)?n=!0:n||t.push(r);return t}var Da=class{header="";styledLines=[];theme;cachedWidth=-1;cachedLines=[];setContent(t,n,r){this.header=t,this.styledLines=n.map(a=>Dv(a,r)),this.theme=r,this.cachedWidth=-1}invalidate(){this.cachedWidth=-1}render(t){if(this.cachedWidth!==t){let n=this.theme,r=[];this.header&&r.push(this.header,"");for(let a of this.styledLines)n?r.push(...jv(a,t)):r.push(a);this.cachedLines=r,this.cachedWidth=t}return this.cachedLines}};function Dv(e,t){let n=e.match(/^(\d+)\.\s+(.*)$/);return n?`${t.fg("accent",`${n[1]}.`)} ${t.fg("muted",n[2]??"")}`:t.fg("toolOutput",e)}function Gv(e){return`${Math.floor(e/1e3)}s`}function Nv(e){return e.length===0?"Gap analysis complete: no confirmed behavioral test gaps were found.":["Below are the gaps found by another agent. If they are fair under our prompt, we need to add tests to fix the gap. If not fair, do not mind those \u2014 only add tests for gaps that are absolutely fair.","",...e.map((n,r)=>`${r+1}. ${n.description}
|
|
325
330
|
Justification: ${n.justification}`)].join(`
|
|
326
|
-
`)}var
|
|
327
|
-
`),"info");return}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(
|
|
331
|
+
`)}var Ga=!1,Lf=!1,Kt=!1;function ci(e){return e.getActiveTools().map(n=>typeof n=="string"?n:n.name)}function li(){return Ga}function _v(e){return ci(e).includes(mr)}function Na(e){return li()!==_v(e)}function Uv(e){Lf||(Mf(e),Lf=!0)}function Kv(e,t){let n=ci(e);if(t){if(n.length===0){Kt=!0;return}let r=new Set(n);r.add(mr),r.size!==n.length&&e.setActiveTools([...r])}else{let r=n.filter(a=>a!==mr);r.length!==n.length&&e.setActiveTools(r)}Kt=Na(e)}function xn(e){let t=li();t&&Uv(e),Kv(e,t)}function di(e,t){Ga=lr(t),Kt=!0,qf(e)}function qf(e,t=0){let n=li(),r=ci(e);if(n&&r.length===0&&t<8){queueMicrotask(()=>qf(e,t+1));return}xn(e)}function jf(e){for(let t of[0,50,150,400])setTimeout(()=>{(Kt||Na(e))&&xn(e)},t)}function Ff(){return Kt}function fi(e,t,n){Ga=n,dr(t,n),Kt=!0,xn(e)}function Df(e,t){Ga=lr(t),Kt=!0,xn(e)}var Jv="Ctrl+Shift+X",gi=[{value:"--gap-finder",label:"--gap-finder",description:"Find and validate behavioral test-coverage gaps"},{value:"--solver-gap-finder",label:"--solver-gap-finder",description:"Use TDD solver attempts to find behavioral gaps"},{value:"--config",label:"--config",description:"Configure gap-finder models"}];function Zv(e){let t=e.trimStart(),n=/\s$/.test(t),r=t.trimEnd().split(/\s+/).filter(Boolean),a=n?"":r.at(-1)??"",i=new Set(n?r:r.slice(0,-1)),m=n?t:t.slice(0,t.length-a.length),u=i.has("--config"),l=[...i].some(h=>h!=="--config"),f=gi.filter(h=>!i.has(h.value)&&!u&&!(l&&h.value==="--config")&&h.value.startsWith(a));return f.length?f.map(h=>({...h,value:`${m}${h.value}`})):null}async function hi(e,t,n){let r=Fi();if(r.length===0)return e.ui.notify("No enabledModels configured in settings.json.","error"),null;let a=e.modelRegistry.getAll(),i=r.map(f=>{let h=Di(f);if(!h)return null;let $=a.find(H=>H.provider===h.provider&&H.id===h.modelId),E=t?.provider===h.provider&&t?.modelId===h.modelId,A=$?`${$.name} (${f})`:f;return{ref:f,parsed:h,display:E?`${A} [current]`:A,isCurrent:E}}).filter(f=>f!==null);if(i.length===0)return e.ui.notify("Could not resolve any enabledModels entries.","error"),null;let m=[...i].sort((f,h)=>f.isCurrent===h.isCurrent?0:f.isCurrent?-1:1),u=await e.ui.select(n,m.map(f=>f.display));if(!u)return null;let l=i.find(f=>f.display===u);return l?{provider:l.parsed.provider,modelId:l.parsed.modelId}:null}function In(e,t,n){let r=e.modelRegistry.getAll().find(a=>a.provider===t&&a.id===n);return Li(r)}var _a={provider:"",modelId:"",thinkingLevel:"off",timeoutMinutes:Wa,solverCount:Ya,saveArtifacts:Ja},Ua={provider:"",modelId:"",thinkingLevel:"off"};function zf(e,t,n,r){let a=t?In(e,t.provider,t.modelId):["off"],i=n.provider?In(e,n.provider,n.modelId):["off"],m=r.provider?In(e,r.provider,r.modelId):["off"];return[{id:"reviewer-model",section:"Reviewer",label:"Model",value:t?`${t.provider}/${t.modelId}`:"not set",kind:"model"},{id:"reviewer-thinking",section:"Reviewer",label:"Thinking level",value:t?.thinkingLevel??"off",kind:"cycle",values:a},{id:"solvergap-model",section:"Solver",label:"Model",value:n.provider?`${n.provider}/${n.modelId}`:"not set",kind:"model"},{id:"solvergap-thinking",section:"Solver",label:"Thinking level",value:n.thinkingLevel,kind:"cycle",values:i},{id:"solvergap-timeout",section:"Solver",label:"Timeout",value:`${n.timeoutMinutes} min`,kind:"cycle",values:[10,20,30,40,50,Ai].filter((u,l,f)=>u>=Pi&&f.indexOf(u)===l).map(u=>`${u} min`)},{id:"solvergap-solver-count",section:"Solver",label:"Parallel agents",value:String(n.solverCount),kind:"cycle",values:Array.from({length:Ci-Ha+1},(u,l)=>`${Ha+l}`)},{id:"solvergap-save-artifacts",section:"Solver",label:"Save artifacts",value:n.saveArtifacts?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-enabled",section:"Analyze Tool",label:"Enabled here",value:fr(e.cwd)?"on":"off",kind:"cycle",values:["on","off"]},{id:"analyze-model",section:"Analyze Tool",label:"Model",value:r.provider?`${r.provider}/${r.modelId}`:"not set",kind:"model"},{id:"analyze-thinking",section:"Analyze Tool",label:"Thinking level",value:r.thinkingLevel,kind:"cycle",values:m}]}var yi=class{constructor(t,n,r,a,i,m){this.ctx=t;this.settingsListTheme=n;this.theme=r;this.onCycleSaved=a;this.onActivateModel=i;this.onExit=m;this.rows=zf(t,ve(),ve()?.solverGap??_a,ve()?.analyzeGap??Ua)}selectedIndex=0;rows;refresh(){let t=ve();this.rows=zf(this.ctx,t,t?.solverGap??_a,t?.analyzeGap??Ua),this.selectedIndex=Math.min(this.selectedIndex,this.rows.length-1)}invalidate(){}render(t){let n=[],r=Math.min(30,Math.max(...this.rows.map(i=>i.label.length))),a;for(let i=0;i<this.rows.length;i++){let m=this.rows[i];if(!m)continue;m.section!==a&&(a!==void 0&&n.push(""),n.push(this.theme.bold(this.theme.fg("accent",m.section))),a=m.section);let u=i===this.selectedIndex,l=u?this.settingsListTheme.cursor:" ",f=m.label+" ".repeat(Math.max(0,r-m.label.length)),h=this.settingsListTheme.label(f,u),$=this.settingsListTheme.value(m.value,u);n.push(`${l}${h} ${$}`)}return n}handleInput(t){if(Bt(t,zt.ctrl("s"))||Bt(t,zt.escape)||Bt(t,zt.ctrl("c"))){this.onExit();return}if(Bt(t,zt.up)){this.selectedIndex=this.selectedIndex===0?this.rows.length-1:this.selectedIndex-1;return}if(Bt(t,zt.down)){this.selectedIndex=this.selectedIndex===this.rows.length-1?0:this.selectedIndex+1;return}if(Bt(t,zt.enter)||Bt(t,zt.return)||t===" "){let n=this.rows[this.selectedIndex];if(!n)return;if(n.kind==="model"){this.onActivateModel(n.id);return}if(!n.values||n.values.length===0)return;let r=ve();if(!r){this.ctx.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");return}let a=r.solverGap??_a,i=r.analyzeGap??Ua,m=n.values.indexOf(n.value),u=n.values[(m+1)%n.values.length];if(u===void 0)return;n.id==="reviewer-thinking"?Fe({...r,thinkingLevel:u,solverGap:a,analyzeGap:i}):n.id==="solvergap-thinking"?Fe({...r,solverGap:{...a,thinkingLevel:u}}):n.id==="solvergap-timeout"?Fe({...r,solverGap:{...a,timeoutMinutes:Number.parseInt(u,10)}}):n.id==="solvergap-solver-count"?Fe({...r,solverGap:{...a,solverCount:Number.parseInt(u,10)}}):n.id==="solvergap-save-artifacts"?Fe({...r,solverGap:{...a,saveArtifacts:u==="on"}}):n.id==="analyze-enabled"?dr(this.ctx.cwd,u==="on"):n.id==="analyze-thinking"&&Fe({...r,analyzeGap:{...i,thinkingLevel:u}}),this.refresh(),this.onCycleSaved()}}};async function Xv(e,t){if(t.mode!=="tui"){t.ui.notify("/checks --config requires interactive mode","error");return}let n=0;for(;;){let r=await t.ui.custom((u,l,f,h)=>{let $=new yi(t,Wv(),l,()=>{Df(e,t.cwd),u.requestRender()},A=>h(A),()=>h(void 0));$.selectedIndex=n;let E=new Hv;return E.addChild(new Kf(l.bold(l.fg("accent","Checks settings")))),E.addChild({render:A=>$.render(A),invalidate:()=>$.invalidate()}),E.addChild(new Yv(1)),E.addChild(new Kf(l.fg("dim","\u2191\u2193 navigate enter select ctrl+s save & exit esc cancel"))),{render(A){return E.render(A)},invalidate(){E.invalidate()},handleInput(A){$.handleInput(A),n=$.selectedIndex,u.requestRender()}}});if(!r)return;let a=ve(),i=a?.solverGap??_a,m=a?.analyzeGap??Ua;if(r==="reviewer-model"){let u=await hi(t,a,"Select reviewer model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(a?.thinkingLevel??"off")?a?.thinkingLevel??"off":l[0]??"off";Fe({...u,thinkingLevel:f,solverGap:i,analyzeGap:m,enabledProjects:a?.enabledProjects??Xa(),enableAnalyzeTool:a?.enableAnalyzeTool}),t.ui.notify(`Reviewer model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="solvergap-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before solver-gap-finder settings.","warning");continue}let u=await hi(t,i.provider?i:null,"Select solver model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(i.thinkingLevel)?i.thinkingLevel:l[0]??"off";Fe({...a,solverGap:{...i,...u,thinkingLevel:f}}),t.ui.notify(`Solver model saved: ${u.provider}/${u.modelId}`,"info");continue}if(r==="analyze-model"){if(!a){t.ui.notify("Set the reviewer model first \u2014 it's required before analyze-tool settings.","warning");continue}let u=await hi(t,m.provider?m:null,"Select analyze tool model");if(!u)continue;let l=In(t,u.provider,u.modelId),f=l.includes(m.thinkingLevel)?m.thinkingLevel:l[0]??"off";Fe({...a,analyzeGap:{...m,...u,thinkingLevel:f}}),t.ui.notify(`Analyze tool model saved: ${u.provider}/${u.modelId}`,"info")}}}function Bf(e){e.registerCommand("checks",{description:"Find behavioral gaps in test coverage. Requires an option \u2014 see /checks.",getArgumentCompletions:Zv,handler:async(t,n)=>{let r=t.trim();if(!r){n.ui.notify(gi.map(N=>`${N.value} \u2014 ${N.description}`).join(`
|
|
332
|
+
`),"info");return}let a=[...new Set(r.split(/\s+/).filter(Boolean))],i=new Set(gi.map(N=>N.value)),m=a.filter(N=>!i.has(N));if(m.length){n.ui.notify(`Unknown option(s): ${m.join(", ")}. Run /checks with no arguments to see options.`,"warning");return}if(a.includes("--config")){a.length>1?n.ui.notify("--config cannot be combined with other options.","warning"):await Xv(e,n);return}let u=a.includes("--gap-finder"),l=a.includes("--solver-gap-finder");if(!u&&!l)return;if(Fa()){n.ui.notify("A checks run is already in progress.","warning");return}let f=ve();if(!f){n.ui.notify("No gap-finder model configured. Run /checks --config first.","error");return}let h=n.modelRegistry.find(f.provider,f.modelId);if(!h||!n.modelRegistry.hasConfiguredAuth(h)){n.ui.notify("Configured behavioral gap-finder model is unavailable or unauthenticated. Run /checks --config.","error");return}let $=pi.filter(N=>!Nf(et(n.cwd,N)));if($.length){n.ui.notify(`Missing required file(s): ${$.join(", ")}`,"error");return}let E=null,A;if(l){if(E=qi(),!E||!Nf(et(n.cwd,"test.sh"))){n.ui.notify("Configure solver gap finder and provide test.sh before running it.","error");return}if(A=n.modelRegistry.find(E.provider,E.modelId),!A||!n.modelRegistry.hasConfiguredAuth(A)){n.ui.notify("Configured solver gap-finder model is unavailable or unauthenticated.","error");return}}let H=Of(),te=E?.solverCount??0,ne=(u?2:0)+(l?te+1:0);n.ui.setWidget(Rt,sr("preparing clean snapshot",0,ne)),n.ui.notify(`gap finders (${a.join(" ")}) started. Press ${Jv} to cancel.`,"info");let ue,tt=[];try{let N=et(Uf(),`checks-${Gf()}`);_f(N,{recursive:!0}),ue=N;let nt=await xr(e,n.cwd,N);if(nt.status==="error"){n.ui.notify(`checks: ${nt.error}`,"error");return}for(let qe of pi)zv(et(n.cwd,qe),et(N,qe));let _e=La(),ct=qa(),rt=0,lt={status:"ok",gaps:[]},Vt={status:"ok",gaps:[]};if(u){let qe={tempDir:N,model:h,thinkingLevel:f.thinkingLevel,testRubric:_e,fairnessRules:ct,cancelSignal:H.signal};if(n.ui.setWidget(Rt,sr("finding sentence-by-sentence test gaps",rt,ne)),lt=await Ca(qe),rt+=1,n.ui.setWidget(Rt,sr("reviewing test gaps",rt,ne)),lt.gaps.reduce((za,Ba)=>za+Ba.gaps.length,0)>0&&(Vt=await Ma({...qe,statementReports:lt.gaps})),rt+=1,H.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let dt=[],pr={status:"ok",gaps:[]};if(l&&E){let qe=[],Ka=at=>{qe.push(at),rt+=1,n.ui.setWidget(Rt,sr("solver gap finder: solving",rt,ne,{passed:qe.filter(je=>je.passed).length,failed:qe.filter(je=>!je.passed).length}))},za=await Promise.all(Array.from({length:te},async(at,je)=>{let bn=et(Uf(),`checks-solvergap-${Gf()}`);return _f(bn,{recursive:!0}),tt.push(bn),{index:je+1,setup:await Ni({pi:e,repoDir:n.cwd,solverDir:bn,testPatchPath:et(n.cwd,"test.patch"),agentPromptPath:et(n.cwd,"agent_prompt.md")})}})),Ba=ui().replace(/[:.]/g,"-");if(dt=await Promise.all(za.map(async({index:at,setup:je})=>{if(je.status!=="ok"){let ki={index:at,status:je.status,passed:!1,diff:"",testOutputTail:je.error,durationMs:0,totalTests:null,failedTests:null};return Ka(ki),ki}let bn=Date.now(),{outcome:$i,trajectory:Hf}=await $f({pi:e,solverDir:je.solverDir,model:A,thinkingLevel:E.thinkingLevel,timeoutMinutes:E.timeoutMinutes,cancelSignal:H.signal}),{testOutputXmlPath:Yf,...Va}=await _i({pi:e,index:at,workspace:je,status:$i==="done"?"ok":$i,durationMs:Date.now()-bn}),Jf=E.saveArtifacts?Ui({repoDir:n.cwd,runId:Ba,index:at,trajectory:Hf,solutionPatch:Va.diff,testOutputXmlPath:Yf,testOutputTail:Va.testOutputTail}):void 0,Ti={...Va,artifactsDir:Jf};return Ka(Ti),Ti})),dt.some(at=>at.status!=="patchFailed"&&at.status!=="error")&&(Ki(N,dt),pr=await Tf({tempDir:N,model:h,thinkingLevel:f.thinkingLevel,solverResults:dt,testRubric:_e,fairnessRules:ct,cancelSignal:H.signal})),rt+=1,H.signal.aborted){n.ui.notify("checks: cancelled.","warning");return}}let Wf=u&&(lt.status!=="ok"||lt.gaps.length>0&&Vt.status!=="ok"),Ii=wf({existingReport:kf(et(n.cwd,"shipd_report.json")),config:f,runGapFinder:u,testGaps:Vt.gaps,gapAnalysisIncomplete:Wf,gapFinderStatus:lt.status,gapFilterStatus:Vt.status,runSolverGapFinder:l,solverResults:dt,solverGaps:pr.gaps,solverGapAnalysisIncomplete:l&&(dt.some(qe=>qe.status==="error")||pr.status!=="ok"),solverComparisonStatus:pr.status}),bi=Rf({merged:Ii,runGapFinder:u,runSolverGapFinder:l});e.sendMessage({customType:"shipd_checks_report",content:bi.content,display:!0,details:bi.details});let vi=et(n.cwd,"shipd_report.json");Vv(vi,JSON.stringify(Ii,null,2),"utf-8"),n.ui.notify(`checks: wrote details to ${vi}`,"info")}catch(N){n.ui.notify(`checks failed: ${N instanceof Error?N.message:String(N)}`,"error")}finally{n.ui.setWidget(Rt,void 0),ue&&Bv(ue,{recursive:!0,force:!0});for(let N of tt)zi(N);Pf()}}})}var Vf=e$.ctrlShift("x");function n$(e){e.registerCommand("analyze:on",{description:"Enable the Gap Finder tool for this project folder",handler:async(t,n)=>{fi(e,n.cwd,!0),n.ui.notify("Gap Finder tool ON in this project","info")}}),e.registerCommand("analyze:off",{description:"Disable the Gap Finder tool for this project folder",handler:async(t,n)=>{fi(e,n.cwd,!1),n.ui.notify("Gap Finder tool OFF in this project","info")}}),e.registerMessageRenderer("shipd_checks_report",(t,n,r)=>{let a=t.details??{},i=new Qv;i.addChild(new xi(r.bold(r.fg("accent","Checks")),0,0));let m=!1,u=l=>{i.addChild(new xi(l,0,0)),m=!0};if(a.showGaps){let l=a.gapsCount??0;u(l>0?r.fg("warning",` \u26A0 ${l} test gap(s) found`):r.fg("success"," \u2713 no test gaps found"))}if(a.showSolverGaps){let l=a.solverDetails??[],f=l.filter(A=>A.passed).length,h=a.solverGapsCount??0;i.addChild(new t$(1)),u(r.bold(r.fg("accent","Solver gap finder")));for(let A of l){let H=A.passed?r.fg("success","\u2713"):r.fg("error","\u2717"),te=A.passed?"passed":A.status==="ok"?"failed tests":A.status;u(` ${H} Solver ${A.index}: ${te} (${Ef(A.durationMs)})`)}let $=f===l.length&&l.length>0?r.fg("success",`${f}/${l.length} solvers passed`):r.fg("warning",`${f}/${l.length} solvers passed`),E=h>0?r.fg("warning",`${h} behavioral gap(s) found`):r.fg("success","no behavioral gaps found");u(` ${$}, ${E}`)}return m||i.addChild(new xi(r.fg("dim"," nothing to report"),0,0)),i}),e.registerShortcut(Vf,{description:"Cancel an in-progress /checks run",handler:t=>{Fa()&&Af()&&(t.ui.setWidget(Rt,[`checks: cancelling (${Vf})...`]),t.ui.notify("checks: cancelling...","warning"))}}),r$(e),Bf(e)}function r$(e){e.on("session_start",(t,n)=>{di(e,n.cwd),(t.reason==="resume"||t.reason==="reload"||t.reason==="startup")&&jf(e)}),e.on("session_tree",async(t,n)=>{di(e,n.cwd)}),e.on("before_agent_start",()=>{!Ff()&&!Na(e)||xn(e)})}export{n$ as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sreetej510/pi-shipd-checks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "Pi extension that runs a strict, multi-agent fairness review of a benchmark task's agent_prompt.md, test.patch, and solution.patch, plus behavioral test-gap analysis, via /checks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|