howtofixcli 0.7.13 → 0.7.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-27TRKD65.js +2 -0
- package/dist/chunk-3FYCFLNK.js +1 -0
- package/dist/chunk-56SEAGAQ.js +1 -0
- package/dist/chunk-6FUWMLWO.js +1 -0
- package/dist/chunk-7CHDNTH6.js +1 -0
- package/dist/chunk-7DTQKDO4.js +2 -0
- package/dist/chunk-AGGIYXN7.js +2 -0
- package/dist/chunk-AUDMRGWF.js +189 -0
- package/dist/chunk-CPJKKHGH.js +1 -0
- package/dist/chunk-DAPXGSGD.js +12 -0
- package/dist/chunk-DOD7MUGX.js +1 -0
- package/dist/chunk-DV2BBBBJ.js +2 -0
- package/dist/chunk-EIBOS5KO.js +5 -0
- package/dist/chunk-EYWOVCSS.js +6 -0
- package/dist/chunk-FPXVDP32.js +8 -0
- package/dist/chunk-GXB7RZHH.js +1 -0
- package/dist/chunk-HT3MFLAV.js +34 -0
- package/dist/chunk-ILDDDLRC.js +1 -0
- package/dist/chunk-JFYVRWJI.js +2 -0
- package/dist/chunk-JMKK26AT.js +2 -0
- package/dist/chunk-LAHVHRCS.js +2 -0
- package/dist/chunk-LOOFOBTS.js +1 -0
- package/dist/chunk-LSJC73DG.js +1 -0
- package/dist/chunk-MOKUBKE7.js +1 -0
- package/dist/chunk-N345KWWK.js +1 -0
- package/dist/chunk-ONZLNFQ2.js +3 -0
- package/dist/chunk-ORJ2QZBG.js +3 -0
- package/dist/chunk-PCALBZOO.js +2 -0
- package/dist/chunk-SX5VE6XA.js +110 -0
- package/dist/chunk-TSEKPGK4.js +1 -0
- package/dist/chunk-UNK5HRQR.js +1 -0
- package/dist/chunk-UTYFLLSM.js +1 -0
- package/dist/chunk-V2RPZMLK.js +1 -0
- package/dist/chunk-V3R4FYTJ.js +1 -0
- package/dist/chunk-V656XVXV.js +8 -0
- package/dist/chunk-VLMQSD25.js +1 -0
- package/dist/chunk-WKUJ7CFO.js +1 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/chunk-WUPU6LTD.js +4 -0
- package/dist/chunk-WX3V5P7U.js +5 -0
- package/dist/chunk-Y7YM5R75.js +5 -0
- package/dist/chunk-YW7NORH3.js +2 -0
- package/dist/main.js +99 -540
- package/package.json +17 -64
- package/dist/account-credential.js +0 -136
- package/dist/account-credential.test.js +0 -38
- package/dist/activity.js +0 -124
- package/dist/agent-defs.js +0 -237
- package/dist/agent-limiter.js +0 -68
- package/dist/agents.js +0 -554
- package/dist/anim.js +0 -361
- package/dist/args.js +0 -228
- package/dist/at-file.js +0 -28
- package/dist/brand-extension.js +0 -87
- package/dist/brand.js +0 -76
- package/dist/browser.js +0 -58
- package/dist/cache-report.js +0 -139
- package/dist/checkpoint.js +0 -437
- package/dist/claims.js +0 -167
- package/dist/cli-auth.js +0 -142
- package/dist/cli-checkin.js +0 -120
- package/dist/cli-credentials.js +0 -254
- package/dist/clipboard.js +0 -149
- package/dist/collapse.js +0 -129
- package/dist/commands.js +0 -294
- package/dist/compaction-guard.js +0 -81
- package/dist/context-extension.js +0 -17
- package/dist/dcp/commands.js +0 -172
- package/dist/dcp/compress-state.js +0 -139
- package/dist/dcp/compress.js +0 -329
- package/dist/dcp/dcp-extension.js +0 -295
- package/dist/dcp/dedup.js +0 -93
- package/dist/dcp/ids.js +0 -189
- package/dist/dcp/index.js +0 -25
- package/dist/dcp/middle-prune.js +0 -76
- package/dist/dcp/prompts.js +0 -68
- package/dist/dcp/protected-content.js +0 -221
- package/dist/dcp/protected.js +0 -161
- package/dist/dcp/prune.js +0 -418
- package/dist/dcp/state.js +0 -176
- package/dist/device-id.js +0 -90
- package/dist/device-id.test.js +0 -23
- package/dist/errors.js +0 -63
- package/dist/extensions.js +0 -48
- package/dist/fatal.js +0 -35
- package/dist/feed.js +0 -498
- package/dist/fs-atomic.js +0 -54
- package/dist/gateway-errors.js +0 -90
- package/dist/git.js +0 -230
- package/dist/goal-extension.js +0 -88
- package/dist/goal.js +0 -222
- package/dist/hooks-extension.js +0 -176
- package/dist/hooks.js +0 -443
- package/dist/howtofix-account.js +0 -735
- package/dist/hud-line.js +0 -153
- package/dist/hwid.js +0 -130
- package/dist/interrupt.js +0 -60
- package/dist/json-events.js +0 -50
- package/dist/level-style.js +0 -112
- package/dist/loop-guard.js +0 -95
- package/dist/lsp-tools.js +0 -32
- package/dist/lsp.js +0 -429
- package/dist/mcp-config.js +0 -85
- package/dist/mcp-lifecycle.js +0 -147
- package/dist/model-catalog.js +0 -217
- package/dist/model-facts.js +0 -35
- package/dist/model-resolve.js +0 -65
- package/dist/notes.js +0 -78
- package/dist/oauth-login.js +0 -568
- package/dist/paths.js +0 -61
- package/dist/permissions.js +0 -298
- package/dist/plan-mode.js +0 -363
- package/dist/preset-command.js +0 -227
- package/dist/preset-extension.js +0 -35
- package/dist/preset-mcp.js +0 -292
- package/dist/presets.js +0 -727
- package/dist/prompt-files.js +0 -103
- package/dist/prompt-text.js +0 -41
- package/dist/proxy.js +0 -137
- package/dist/quality/ast.js +0 -196
- package/dist/quality/cognitive.js +0 -83
- package/dist/quality/cyclomatic.js +0 -30
- package/dist/quality/halstead.js +0 -83
- package/dist/quality/index.js +0 -18
- package/dist/quality/length.js +0 -3
- package/dist/quality/maintainability.js +0 -15
- package/dist/quality/nesting.js +0 -57
- package/dist/quality/report.js +0 -803
- package/dist/quality/smells.js +0 -67
- package/dist/quality-tool.js +0 -63
- package/dist/read-only-commands.js +0 -597
- package/dist/repo-map.js +0 -292
- package/dist/rtk.js +0 -193
- package/dist/sandbox.js +0 -105
- package/dist/schema.js +0 -214
- package/dist/session-lifecycle.js +0 -19
- package/dist/session-retention.js +0 -111
- package/dist/session.js +0 -447
- package/dist/sessions.js +0 -100
- package/dist/settings.js +0 -148
- package/dist/skills.js +0 -35
- package/dist/slop-tool.js +0 -96
- package/dist/spend-cap.js +0 -43
- package/dist/subagent.js +0 -171
- package/dist/tar.js +0 -146
- package/dist/theme.js +0 -79
- package/dist/thinking.js +0 -45
- package/dist/todo.js +0 -114
- package/dist/tool-loadout.js +0 -97
- package/dist/tool-render.js +0 -769
- package/dist/tools.js +0 -176
- package/dist/ui.js +0 -4778
- package/dist/update.js +0 -551
- package/dist/usage-segment.js +0 -69
- package/dist/web-tools.js +0 -46
- package/dist/web.js +0 -265
- package/dist/welcome.js +0 -179
- package/dist/workflow-engine.js +0 -246
- package/dist/workflow-progress.js +0 -446
- package/dist/workflow-view.js +0 -195
- package/dist/workflow.js +0 -349
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import{r as Xp}from"./chunk-JFYVRWJI.js";import{b as Qp}from"./chunk-27TRKD65.js";import{D as lt,G as Jp,H as jn,a as ji}from"./chunk-V656XVXV.js";import{a as or}from"./chunk-UTYFLLSM.js";import{a as At}from"./chunk-WOT6VMZA.js";import{spawn as e1}from"node:child_process";import{existsSync as t1,readFileSync as r1}from"node:fs";import{join as n1}from"node:path";var q={};At(q,{Match:()=>lC});function lC(e,t){return t[e.length]?.(...e)??(()=>{throw Error("Invalid Arguments")})()}var Ae={};At(Ae,{Get:()=>zi,Reset:()=>cR,Set:()=>pR});var s={};At(s,{CodePointCount:()=>PC,Counted:()=>DC,Entries:()=>_C,EntriesRegExp:()=>jC,Every:()=>MC,EveryAll:()=>vC,GraphemeCount:()=>wC,HasPropertyKey:()=>LC,IsArray:()=>Mo,IsBigInt:()=>Oo,IsBoolean:()=>nf,IsClassInstance:()=>RC,IsConstructor:()=>$C,IsDeepEqual:()=>Om,IsEqual:()=>J,IsFunction:()=>of,IsGreaterEqualThan:()=>af,IsGreaterThan:()=>kC,IsInteger:()=>Pm,IsLessEqualThan:()=>sf,IsLessThan:()=>TC,IsMaxLength:()=>AC,IsMinLength:()=>OC,IsMultipleOf:()=>CC,IsNull:()=>Gi,IsNumber:()=>Bi,IsObject:()=>vo,IsObjectNotArray:()=>EC,IsString:()=>Ki,IsSymbol:()=>SC,IsUndefined:()=>Am,IsUnsafePropertyKey:()=>uf,IsValueLike:()=>mf,Keys:()=>Ui,ShiftLeft:()=>Hi,Some:()=>FC,SomeAll:()=>NC,Symbols:()=>qC,Values:()=>UC});function _n(e,t,r){return e>=t&&e<=r}function gC(e){return e===8205}function Yp(e){return _n(e,127462,127487)}function xC(e){return _n(e,65024,65039)}function yC(e){return _n(e,768,879)||_n(e,6832,6911)||_n(e,7616,7679)||_n(e,65056,65071)}function _i(e){return e>65535?2:1}function Zp(e,t){for(;t<e.length;){let r=e.codePointAt(t);if(yC(r)||xC(r))t+=_i(r);else break}return t}function IC(e,t){let r=e.codePointAt(t),n=t+_i(r);for(n=Zp(e,n);n<e.length-1&&gC(e.codePointAt(n));){let o=e.codePointAt(n+1);n+=1+_i(o),n=Zp(e,n)}return Yp(r)&&n<e.length&&Yp(e.codePointAt(n))&&(n+=_i(e.codePointAt(n))),n}function ef(e){let t=0,r=0;for(;r<e.length;)r=IC(e,r),t++;return t}function qi(e){let t=0,r=0,n=0;for(;r<e.length;){let o=e.charCodeAt(r++)>>10;t+=+((n<<8|o)!==13879),n=o}return t}function tf(e,t){return e.length<=t||e.length<=t<<1&&qi(e)<=t}function rf(e,t){return e.length>=t<<1||e.length>=t&&qi(e)>=t}function Mo(e){return Array.isArray(e)}function Oo(e){return J(typeof e,"bigint")}function nf(e){return J(typeof e,"boolean")}function $C(e){if(Am(e)||!of(e))return!1;let t=Function.prototype.toString.call(e);return!!(/^class\s/.test(t)||/\[native code\]/.test(t))}function of(e){return J(typeof e,"function")}function Pm(e){return Number.isInteger(e)}function Gi(e){return J(e,null)}function Bi(e){return Number.isFinite(e)}function EC(e){return vo(e)&&!Mo(e)}function vo(e){return J(typeof e,"object")&&!Gi(e)}function Ki(e){return J(typeof e,"string")}function SC(e){return J(typeof e,"symbol")}function Am(e){return J(e,void 0)}function J(e,t){return e===t}function kC(e,t){return e>t}function TC(e,t){return e<t}function sf(e,t){return e<=t}function af(e,t){return e>=t}function CC(e,t){if(Oo(e)||Oo(t))return BigInt(e)%BigInt(t)===0n;let r=1e-10;if(!Bi(e)||Pm(e)&&1/t%1===0)return!0;let n=e%t;return Math.min(Math.abs(n),Math.abs(n-t),Math.abs(n+t))<r}function RC(e){if(!vo(e))return!1;let t=globalThis.Object.getPrototypeOf(e);return Gi(t)?!1:J(typeof t.constructor,"function")&&!(J(t.constructor,globalThis.Object)||J(t.constructor.name,"Object"))}function mf(e){return Oo(e)||nf(e)||Gi(e)||Bi(e)||Ki(e)||Am(e)}function wC(e){return ef(e)}function PC(e){return qi(e)}function AC(e,t){return tf(e,t)}function OC(e,t){return rf(e,t)}function MC(e,t,r){return e.every((n,o)=>o<t||r(n,o))}function vC(e,t,r){let n=!0;return e.forEach((o,i)=>{i>=t&&!r(o,i)&&(n=!1)}),n}function FC(e,t){return e.some((r,n)=>t(r,n))}function NC(e,t){let r=!1;return e.forEach((n,o)=>{t(n,o)&&(r=!0)}),r}function DC(e,t){return e.reduce((r,n,o)=>t(n,o)?++r:r,0)}function Hi(e,t,r){return J(e.length,0)?r():t(e[0],e.slice(1))}function uf(e){return J(e,"__proto__")||J(e,"constructor")||J(e,"prototype")}function LC(e,t){return uf(t)?Object.prototype.hasOwnProperty.call(e,t):t in e}function jC(e){return Ui(e).map(t=>[new RegExp(`^${t}$`),e[t]])}function _C(e){return Object.entries(e)}function Ui(e){return Object.getOwnPropertyNames(e)}function qC(e){return Object.getOwnPropertySymbols(e)}function UC(e){return Object.values(e)}function GC(e,t){if(!vo(t))return!1;let r=Ui(e);return J(r.length,Ui(t).length)&&r.every(n=>Om(e[n],t[n]))}function BC(e,t){return Mo(t)&&J(e.length,t.length)&&e.every((r,n)=>Om(e[n],t[n]))}function Om(e,t){return Mo(e)?BC(e,t):vo(e)?GC(e,t):J(e,t)}var Ne={};At(Ne,{IsBigInt64Array:()=>nR,IsBigUint64Array:()=>oR,IsBoolean:()=>KC,IsDate:()=>sR,IsFloat32Array:()=>tR,IsFloat64Array:()=>rR,IsInt16Array:()=>QC,IsInt32Array:()=>ZC,IsInt8Array:()=>VC,IsMap:()=>mR,IsNumber:()=>HC,IsRegExp:()=>iR,IsSet:()=>aR,IsString:()=>zC,IsTypeArray:()=>WC,IsUint16Array:()=>YC,IsUint32Array:()=>eR,IsUint8Array:()=>JC,IsUint8ClampedArray:()=>XC});function KC(e){return e instanceof Boolean}function HC(e){return e instanceof Number}function zC(e){return e instanceof String}function WC(e){return globalThis.ArrayBuffer.isView(e)}function VC(e){return e instanceof globalThis.Int8Array}function JC(e){return e instanceof globalThis.Uint8Array}function XC(e){return e instanceof globalThis.Uint8ClampedArray}function QC(e){return e instanceof globalThis.Int16Array}function YC(e){return e instanceof globalThis.Uint16Array}function ZC(e){return e instanceof globalThis.Int32Array}function eR(e){return e instanceof globalThis.Uint32Array}function tR(e){return e instanceof globalThis.Float32Array}function rR(e){return e instanceof globalThis.Float64Array}function nR(e){return e instanceof globalThis.BigInt64Array}function oR(e){return e instanceof globalThis.BigUint64Array}function iR(e){return e instanceof globalThis.RegExp}function sR(e){return e instanceof globalThis.Date}function aR(e){return e instanceof globalThis.Set}function mR(e){return e instanceof globalThis.Map}var cf=s;var Wt={immutableTypes:!1,maxErrors:8,maxParseErrors:1,maxInstantiationCount:128,useAcceleration:!0,exactOptionalPropertyTypes:!1,enumerableKind:!1,correctiveParse:!1,unionPrioritySort:!0};function cR(){Wt.immutableTypes=!1,Wt.maxErrors=8,Wt.maxParseErrors=1,Wt.maxInstantiationCount=128,Wt.useAcceleration=!0,Wt.exactOptionalPropertyTypes=!1,Wt.enumerableKind=!1,Wt.correctiveParse=!1,Wt.unionPrioritySort=!0}function pR(e){for(let t of s.Keys(e)){let r=e[t];r!==void 0&&Object.defineProperty(Wt,t,{value:r})}}function zi(){return Wt}function Wi(e){return s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>s.IsObject(t)&&s.HasPropertyKey(t,"check")&&s.HasPropertyKey(t,"error")&&s.IsFunction(t.check)&&s.IsFunction(t.error))}function gt(e){return s.IsObject(e)&&!s.IsArray(e)}function ln(e){return s.IsBoolean(e)}function v(e){return gt(e)||ln(e)}function Vi(e){return s.HasPropertyKey(e,"additionalItems")&&v(e.additionalItems)}function qt(e){return s.HasPropertyKey(e,"additionalProperties")&&v(e.additionalProperties)}function Ji(e){return s.HasPropertyKey(e,"allOf")&&s.IsArray(e.allOf)&&e.allOf.every(t=>v(t))}function pf(e){return s.HasPropertyKey(e,"$anchor")&&s.IsString(e.$anchor)}function Xi(e){return s.HasPropertyKey(e,"anyOf")&&s.IsArray(e.anyOf)&&e.anyOf.every(t=>v(t))}function Mm(e){return s.HasPropertyKey(e,"const")}function Ur(e){return s.HasPropertyKey(e,"contains")&&v(e.contains)}function bt(e){return s.HasPropertyKey(e,"default")}function vm(e){return s.HasPropertyKey(e,"dependencies")&&s.IsObject(e.dependencies)&&Object.values(e.dependencies).every(t=>v(t)||s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Fm(e){return s.HasPropertyKey(e,"dependentRequired")&&s.IsObject(e.dependentRequired)&&Object.values(e.dependentRequired).every(t=>s.IsArray(t)&&t.every(r=>s.IsString(r)))}function Qi(e){return s.HasPropertyKey(e,"dependentSchemas")&&s.IsObject(e.dependentSchemas)&&Object.values(e.dependentSchemas).every(t=>v(t))}function Gr(e){return s.HasPropertyKey(e,"$dynamicAnchor")&&s.IsString(e.$dynamicAnchor)}function Yi(e){return s.HasPropertyKey(e,"$dynamicRef")&&s.IsString(e.$dynamicRef)}function Zi(e){return s.HasPropertyKey(e,"else")&&v(e.else)}function Nm(e){return s.HasPropertyKey(e,"enum")&&s.IsArray(e.enum)}function Dm(e){return s.HasPropertyKey(e,"exclusiveMaximum")&&(s.IsNumber(e.exclusiveMaximum)||s.IsBigInt(e.exclusiveMaximum))}function kr(e){return s.HasPropertyKey(e,"exclusiveMinimum")&&(s.IsNumber(e.exclusiveMinimum)||s.IsBigInt(e.exclusiveMinimum))}function Fo(e){return s.HasPropertyKey(e,"format")&&s.IsString(e.format)}function ut(e){return s.HasPropertyKey(e,"$id")&&s.IsString(e.$id)}function es(e){return s.HasPropertyKey(e,"if")&&v(e.if)}function gn(e){return s.HasPropertyKey(e,"items")&&(v(e.items)||s.IsArray(e.items)&&e.items.every(t=>v(t)))}function ts(e){return gn(e)&&s.IsArray(e.items)}function Lm(e){return s.HasPropertyKey(e,"maximum")&&(s.IsNumber(e.maximum)||s.IsBigInt(e.maximum))}function jm(e){return s.HasPropertyKey(e,"maxContains")&&s.IsNumber(e.maxContains)}function No(e){return s.HasPropertyKey(e,"maxItems")&&s.IsNumber(e.maxItems)}function _m(e){return s.HasPropertyKey(e,"maxLength")&&s.IsNumber(e.maxLength)}function qm(e){return s.HasPropertyKey(e,"maxProperties")&&s.IsNumber(e.maxProperties)}function Tr(e){return s.HasPropertyKey(e,"minimum")&&(s.IsNumber(e.minimum)||s.IsBigInt(e.minimum))}function xn(e){return s.HasPropertyKey(e,"minContains")&&s.IsNumber(e.minContains)}function yn(e){return s.HasPropertyKey(e,"minItems")&&s.IsNumber(e.minItems)}function Do(e){return s.HasPropertyKey(e,"minLength")&&s.IsNumber(e.minLength)}function Lo(e){return s.HasPropertyKey(e,"minProperties")&&s.IsNumber(e.minProperties)}function Um(e){return s.HasPropertyKey(e,"multipleOf")&&(s.IsNumber(e.multipleOf)||s.IsBigInt(e.multipleOf))}function rs(e){return s.HasPropertyKey(e,"not")&&v(e.not)}function ns(e){return s.HasPropertyKey(e,"oneOf")&&s.IsArray(e.oneOf)&&e.oneOf.every(t=>v(t))}function jo(e){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)}function qn(e){return s.HasPropertyKey(e,"patternProperties")&&s.IsObject(e.patternProperties)&&Object.values(e.patternProperties).every(t=>v(t))}function In(e){return s.HasPropertyKey(e,"prefixItems")&&s.IsArray(e.prefixItems)&&e.prefixItems.every(t=>v(t))}function Un(e){return s.HasPropertyKey(e,"properties")&&s.IsObject(e.properties)&&Object.values(e.properties).every(t=>v(t))}function os(e){return s.HasPropertyKey(e,"propertyNames")&&(s.IsObject(e.propertyNames)||v(e.propertyNames))}function fR(e){return s.HasPropertyKey(e,"$recursiveAnchor")&&s.IsBoolean(e.$recursiveAnchor)}function _o(e){return fR(e)&&s.IsEqual(e.$recursiveAnchor,!0)}function is(e){return s.HasPropertyKey(e,"$recursiveRef")&&s.IsString(e.$recursiveRef)}function ss(e){return s.HasPropertyKey(e,"$ref")&&s.IsString(e.$ref)}function hn(e){return s.HasPropertyKey(e,"required")&&s.IsArray(e.required)&&e.required.every(t=>s.IsString(t))}function as(e){return s.HasPropertyKey(e,"then")&&v(e.then)}function Gm(e){return s.HasPropertyKey(e,"type")&&(s.IsString(e.type)||s.IsArray(e.type)&&e.type.every(t=>s.IsString(t)))}function Br(e){return s.HasPropertyKey(e,"uniqueItems")&&s.IsBoolean(e.uniqueItems)}function qo(e){return s.HasPropertyKey(e,"unevaluatedItems")&&v(e.unevaluatedItems)}function Uo(e){return s.HasPropertyKey(e,"unevaluatedProperties")&&v(e.unevaluatedProperties)}var ct=class{constructor(){let t=new Set,r=new Set;this.stack=[{indices:t,keys:r}]}Push(){let t=new Set,r=new Set;return this.stack.push({indices:t,keys:r}),!0}Pop(){return this.stack.pop(),!0}AddIndex(t){return this.GetIndices().add(t),!0}AddKey(t){return this.GetKeys().add(t),!0}GetIndices(){return this.stack[this.stack.length-1].indices}GetKeys(){return this.stack[this.stack.length-1].keys}Merge(t){for(let r of t)r.GetIndices().forEach(n=>this.GetIndices().add(n)),r.GetKeys().forEach(n=>this.GetKeys().add(n));return!0}},Ye=class extends ct{constructor(){super(),this.errors=[]}AtCapacity(){return this.errors.length>=Ae.Get().maxErrors}AddError(t,r,n,o){return this.AddErrorObject({keyword:t,schemaPath:r,instancePath:n,params:o})}AddErrors(t){return t.forEach(r=>this.AddErrorObject(r)),!1}GetErrors(){return this.errors}AddErrorObject(t){return this.AtCapacity()||this.errors.push(t),!1}};function ff(e,t,r,n){return s.Every(r["~refine"],0,(o,i)=>o.check(n))}function df(e,t,r,n,o,i){return s.EveryAll(o["~refine"],0,(a,m)=>a.check(i)||t.AddError("~refine",r,n,{index:m,message:a.error(i)}))}var Go="urn:typebox:root";function Cr(e,t){return URL.canParse(e,t)?new URL(e,t):s.IsEqual(t,Go)?new URL(`${t}:${e}`):new URL(`${t.slice(0,t.lastIndexOf(":"))}:${e}`)}function Bn(e,t){let r=gt(t)&&ut(t)?Cr(t.$id,Go).href:Go;return{context:e,schema:t,lexicalSchema:t,lexicalBase:r,resourceBase:r,referenceBase:r,ids:[],useResourceBaseForReference:!0,recursiveAnchor:void 0,dynamicAnchors:[],resourceEntries:new Map,pendingResource:!0,enteredResource:!1}}function Bm(e,t,r=!0){if(ln(t))return e;if(Array.isArray(t))return t.reduce((o,i)=>Bm(o,i,!1),e);if(!gt(t)||!r&&ut(t))return e;let n=!r&&Gr(t)?[...e,t]:e;return Object.keys(t).reduce((o,i)=>Bm(o,t[i],!1),n)}function Bo(e,t){return e.resourceEntries.get(t)}function lf(e,t){return e.enteredResource||Bo(e,t)!==void 0}function dR(e){return!/^[A-Za-z][A-Za-z0-9+.-]*:/.test(e.$id)}function lR(e,t){return ut(t)?[...e.ids,t]:e.ids}function gR(e,t){return e.recursiveAnchor??(_o(t)?t:void 0)}function xR(e,t){let r=ut(t)?Bm(e.dynamicAnchors,t):e.dynamicAnchors;return Gr(t)?[...r,t]:r}function yR(e,t){return ut(t)?!1:e.pendingResource}function gf(e,t){let r=Bo(e,t);return r?r.base:ut(t)?Cr(t.$id,e.lexicalBase).href:e.lexicalBase}function xf(e,t){let r=Bo(e,t);return r?r.base:ut(t)&&e.pendingResource?Cr(t.$id,e.resourceBase).href:e.resourceBase}function yf(e,t){return ut(t)?!dR(t):e.useResourceBaseForReference}function IR(e,t){let r=lf(e,t),n=yf(e,t);return r||n?xf(e,t):gf(e,t)}function hR(e,t){let r=Bo(e,t);return r?r.root:ut(t)?t:e.lexicalSchema}function bR(e,t){return gt(t)&&(ut(t)||Gr(t)||s.IsUndefined(e.recursiveAnchor)&&_o(t)||!s.IsUndefined(Bo(e,t)))}function Kn(e,t){return bR(e,t)?{...e,ids:lR(e,t),dynamicAnchors:xR(e,t),recursiveAnchor:gR(e,t),pendingResource:yR(e,t),lexicalBase:gf(e,t),resourceBase:xf(e,t),useResourceBaseForReference:yf(e,t),referenceBase:IR(e,t),lexicalSchema:hR(e,t),enteredResource:lf(e,t)}:e}function If(e){return gn(e)&&s.IsArray(e.items)}function hf(e,t,r,n){return If(r)?s.Every(n,0,(i,a)=>s.IsLessThan(a,r.items.length)||Ot(e,t,r.additionalItems,i)&&t.AddIndex(a)):!0}function bf(e,t,r,n,o,i){return If(o)?s.Every(i,0,(m,c)=>{let p=`${r}/additionalItems`,f=`${n}/${c}`;return s.IsLessThan(c,o.items.length)||Mt(e,t,p,f,o.additionalItems,m)&&t.AddIndex(c)}):!0}function $t(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Kr(e){return new RegExp(e,"u")}function $R(e){return`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`}function $f(e){let t=[];return qn(e)&&t.push(...s.Keys(e.patternProperties)),Un(e)&&t.push(...s.Keys(e.properties).map($R)),s.IsEqual(t.length,0)?"(?!)":`(${t.join("|")})`}function Ef(e,t,r,n){let o=Kr($f(r));return s.Every(s.Keys(n),0,(a,m)=>o.test(a)||Ot(e,t,r.additionalProperties,n[a])&&t.AddKey(a))}function Sf(e,t,r,n,o,i){let a=Kr($f(o)),m=[];return s.EveryAll(s.Keys(i),0,(p,f)=>{let d=`${r}/additionalProperties`,g=`${n}/${$t(p)}`,y=a.test(p)||Mt(e,t,d,g,o.additionalProperties,i[p])&&t.AddKey(p);return y||m.push(p),y})||t.AddError("additionalProperties",r,n,{additionalProperties:m})}function kf(e,t,r,n){let o=r.allOf.reduce((i,a)=>{let m=new ct;return X(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,r.allOf.length)&&t.Merge(o)}function Tf(e,t,r,n,o,i){let a=[],m=o.allOf.reduce((p,f,d)=>{let g=`${r}/allOf/${d}`,y=new Ye,h=ae(e,y,g,n,f,i);return h||a.push(y),h?[...p,y]:p},[]),c=s.IsEqual(m.length,o.allOf.length)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c}function Cf(e,t,r,n){let o=r.anyOf.reduce((i,a)=>{let m=new ct;return X(e,m,a,n)?[...i,m]:i},[]);return s.IsGreaterThan(o.length,0)&&t.Merge(o)}function Rf(e,t,r,n,o,i){let a=[],m=o.anyOf.reduce((p,f,d)=>{let g=new Ye,y=`${r}/anyOf/${d}`,h=ae(e,g,y,n,f,i);return h||a.push(g),h?[...p,g]:p},[]),c=s.IsGreaterThan(m.length,0)&&t.Merge(m);return c||a.forEach(p=>t.AddErrors(p.GetErrors())),c||t.AddError("anyOf",r,n,{})}function zm(e,t,r,n){return r}function wf(e,t,r,n,o,i){return zm(e,t,o,i)||t.AddError("boolean",r,n,{})}function Wm(e,t,r,n){return s.IsValueLike(r.const)?s.IsEqual(n,r.const):s.IsDeepEqual(n,r.const)}function Pf(e,t,r,n,o,i){return Wm(e,t,o,i)||t.AddError("const",r,n,{allowedValue:o.const})}function ER(e){return!(xn(e)&&s.IsEqual(e.minContains,0))}function Vm(e,t,r,n){return ER(r)?!s.IsEqual(n.length,0)&&s.SomeAll(n,(o,i)=>X(e,t,r.contains,o)&&t.AddIndex(i)):!0}function Af(e,t,r,n,o,i){return Vm(e,t,o,i)||t.AddError("contains",r,n,{minContains:1})}function Of(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependencies),0,([a,m])=>!s.HasPropertyKey(n,a)||(s.IsArray(m)?m.every(c=>s.HasPropertyKey(n,c)):X(e,t,m,n)));return o||i}function Mf(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependencies),0,([c,p])=>{let f=`${r}/dependencies/${$t(c)}`;return!s.HasPropertyKey(i,c)||(s.IsArray(p)?p.every(d=>s.HasPropertyKey(i,d)||t.AddError("dependencies",r,n,{property:c,dependencies:p})):ae(e,t,f,n,p,i))});return a||m}function vf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentRequired),0,([a,m])=>!s.HasPropertyKey(n,a)||m.every(c=>s.HasPropertyKey(n,c)));return o||i}function Ff(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentRequired),0,([c,p])=>!s.HasPropertyKey(i,c)||s.EveryAll(p,0,f=>s.HasPropertyKey(i,f)||t.AddError("dependentRequired",r,n,{property:c,dependencies:p})));return a||m}function Nf(e,t,r,n){let o=s.IsEqual(s.Keys(n).length,0),i=s.Every(s.Entries(r.dependentSchemas),0,([a,m])=>!s.HasPropertyKey(n,a)||X(e,t,m,n));return o||i}function Df(e,t,r,n,o,i){let a=s.IsEqual(s.Keys(i).length,0),m=s.EveryAll(s.Entries(o.dependentSchemas),0,([c,p])=>{let f=`${r}/dependentSchemas/${$t(c)}`;return!s.HasPropertyKey(i,c)||ae(e,t,f,n,p,i)});return a||m}var Ut={};At(Ut,{DynamicRef:()=>ZR,RecursiveRef:()=>XR,Ref:()=>VR});var sr={};At(sr,{Delete:()=>CR,Get:()=>kR,Has:()=>SR,Indices:()=>Ho,Set:()=>TR});function jf(e){throw Error(e)}function Lf(){jf("Pointer contains unsafe property key")}function Jm(){jf("Cannot set value")}function Ho(e){let t=e.split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~"));return t[0]===""?t.slice(1):t}function SR(e,t){let r=e;for(let n of Ho(t)){if(!s.IsObject(r)||!s.HasPropertyKey(r,n))return!1;r=r[n]}return!0}function kR(e,t){let r=e;for(let n of Ho(t)){if(!s.IsObject(r)||s.IsUnsafePropertyKey(n))return;r=r[n]}return r}function _f(e,t,r){let n=e;for(let o of t)s.IsUnsafePropertyKey(o)&&Lf(),n=s.IsObject(n)?n[o]:void 0;return s.IsUnsafePropertyKey(r)&&Lf(),s.IsObject(n)||Jm(),n}function TR(e,t,r){let n=Ho(t),o=n.pop();return s.IsUndefined(o)&&Jm(),_f(e,n,o)[o]=r,e}function CR(e,t){let r=Ho(t),n=r.pop();s.IsUndefined(n)&&Jm();let o=_f(e,r,n);return s.IsArray(o)&&/^(0|[1-9]\d*)$/.test(n)?o.splice(Number(n),1):delete o[n],e}function Ym(e,t){return gt(e)&&ut(e)?Cr(e.$id,t.href):t}function Zm(e){return Cr(e,Go)}function Xm(e){return e.href.split("#")[0]}function RR(e,t,r){return Qm(e,Zm(t),r)}function wR(e,t){return t.$ref.startsWith("#")||e.enteredResource?e.lexicalSchema:e.schema}function PR(e){return e.startsWith("#/")}function qf(e,t){if(s.IsObject(e)&&Gr(e)&&s.IsEqual(e.$dynamicAnchor,t))return e;if(s.IsObject(e))for(let r of s.Keys(e)){let n=qf(e[r],t);if(n)return n}}function Qm(e,t,r){if(s.IsEqual(e,r))return t.href;let n=Ym(e,t);if(s.IsArray(e))for(let o of e){let i=Qm(o,n,r);if(!s.IsUndefined(i))return i}else if(s.IsObject(e))for(let o of s.Keys(e)){let i=Qm(e[o],n,r);if(!s.IsUndefined(i))return i}}function Uf(e,t){if(t.href.endsWith("#"))return e;if(!t.hash.startsWith("#"))return;let r=decodeURIComponent(t.hash.slice(1));if(r.startsWith("/"))return sr.Get(e,r)}function AR(e,t,r){if(!ut(e))return;if(s.IsEqual(e.$id,r.hash))return e;let n=new URL(r.href,t.href);if(s.IsEqual(t.pathname,n.pathname))return r.hash.startsWith("#")?Uf(e,r):e}function OR(e,t,r){if(!pf(e))return;let n=new URL(`#${e.$anchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function MR(e,t,r){if(!Gr(e))return;let n=new URL(`#${e.$dynamicAnchor}`,t.href),o=new URL(r.href,t.href);return s.IsEqual(n.href,o.href)?e:void 0}function vR(e,t,r){if(gt(e))return AR(e,t,r)??OR(e,t,r)??MR(e,t,r)??Uf(e,r)}function FR(e,t,r){if(s.IsArray(e))return e.reduce((n,o)=>{let i=ms(o,t,r);return s.IsUndefined(i)?n:i},void 0)}function NR(e,t,r){if(s.IsObject(e))return s.Keys(e).reduce((n,o)=>{if(s.IsEqual(o,"const")||s.IsEqual(o,"enum"))return n;let i=ms(e[o],t,r);return s.IsUndefined(i)?n:i},void 0)}function ms(e,t,r){let n=Ym(e,t);return vR(e,n,r)??FR(e,n,r)??NR(e,n,r)}function DR(e,t,r,n){let o=us(e,t,r,n);return gt(o)&&ut(o)?o:void 0}function LR(e,t,r){if(!t.$ref.startsWith("#")||!gt(e.schema)||s.HasPropertyKey(e.schema,"$schema"))return;let n=RR(e.lexicalSchema,e.referenceBase,r);if(!(s.IsUndefined(n)||s.IsEqual(n,e.referenceBase)))return{target:r,base:n,root:e.lexicalSchema}}function jR(e,t,r){let n=e.context[t];if(gt(n))return{target:r,base:t,root:n}}function _R(e,t,r,n,o){let i=o?jR(e,n,r):void 0;return s.IsUndefined(i)?LR(e,t,r):i}function qR(e,t,r){if(ut(r))return;let n=DR(e.context,e.schema,e.referenceBase,t);if(!(!n||e.ids.includes(n)))return{resource:n}}function UR(e,t){return s.HasPropertyKey(e,t)?e[t]:void 0}function GR(e,t,r){return ms(e,t,r)}function BR(e,t,r){let n=Xm(r);if(!s.HasPropertyKey(e,n)||s.IsEqual(n,Xm(t)))return;let o=e[n],i=Ym(o,new URL(n));return s.IsEqual(r.hash,"")?o:ms(o,i,r)}function us(e,t,r,n){let o=Zm(r),i=Cr(n,o.href);return UR(e,n)??GR(t,o,i)??BR(e,o,i)}function KR(e,t){if(!t)return e;let r=new Map(e.resourceEntries);return r.set(t.target,{base:t.base,root:t.root}),{...e,resourceEntries:r}}function HR(e,t){return t?Kn(e,t.resource):e}function Gf(e,t,r,n){let o=KR({...e,pendingResource:t},r);return HR(o,n)}function zR(e,t,r){let n=Xm(Cr(t.$ref,e.referenceBase)),o=!s.IsEqual(n,e.resourceBase),i=_R(e,t,r,n,o),a=o?qR(e,n,r):void 0;return{schema:r,stack:Gf(e,!0,i,a)}}function WR(e,t){return{schema:t,stack:Gf(e,!s.IsUndefined(t))}}function VR(e,t){let r=us(e.context,wR(e,t),e.referenceBase,t.$ref);return gt(r)?zR(e,t,r):WR(e,r)}function JR(e){return gt(e.lexicalSchema)&&_o(e.lexicalSchema)}function XR(e,t){let r=JR(e)?e.recursiveAnchor:e.lexicalSchema;return us(e.context,r,e.lexicalBase,t.$recursiveRef)}function Bf(e,t){return Cr(t.$dynamicRef,Zm(e.lexicalBase).href).hash}function Kf(e,t){return e.dynamicAnchors.find(r=>s.IsEqual(r.$dynamicAnchor,t))??qf(e.schema,t)}function QR(e,t,r){if(!gt(r)||!Gr(r))return r;let n=Bf(e,t);return PR(n)?r:Kf(e,r.$dynamicAnchor)}function YR(e,t){let r=Bf(e,t);return Kf(e,decodeURIComponent(r.slice(1)))}function ZR(e,t){let r=t.$dynamicRef.startsWith("#")?e.lexicalSchema:e.schema,n=us(e.context,r,e.lexicalBase,t.$dynamicRef);return s.IsUndefined(n)?YR(e,t):QR(e,t,n)}function Hf(e,t,r,n){let o=Ut.DynamicRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return v(o)&&X(i,t,o,n)}function zf(e,t,r,n,o,i){let a=Ut.DynamicRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return v(a)&&ae(m,t,r,n,a,i)}function ru(e,t,r,n){return s.Some(r.enum,o=>s.IsValueLike(o)?s.IsEqual(n,o):s.IsDeepEqual(n,o))}function Wf(e,t,r,n,o,i){return ru(e,t,o,i)||t.AddError("enum",r,n,{allowedValues:o.enum})}function nu(e,t,r,n){return s.IsLessThan(n,r.exclusiveMaximum)}function Vf(e,t,r,n,o,i){return nu(e,t,o,i)||t.AddError("exclusiveMaximum",r,n,{comparison:"<",limit:o.exclusiveMaximum})}function ou(e,t,r,n){return s.IsGreaterThan(n,r.exclusiveMinimum)}function Jf(e,t,r,n,o,i){return ou(e,t,o,i)||t.AddError("exclusiveMinimum",r,n,{comparison:">",limit:o.exclusiveMinimum})}var Jo={};At(Jo,{Clear:()=>Ed,Entries:()=>Gw,Get:()=>Hw,Has:()=>Kw,IsDate:()=>zn,IsDateTime:()=>cs,IsDuration:()=>ps,IsEmail:()=>fs,IsHostname:()=>bs,IsIPv4:()=>Ss,IsIPv6:()=>ks,IsIdnEmail:()=>$s,IsIdnHostname:()=>Es,IsIri:()=>Cs,IsIriReference:()=>Ts,IsJsonPointer:()=>ws,IsJsonPointerUriFragment:()=>Rs,IsRegex:()=>Ps,IsRelativeJsonPointer:()=>As,IsTime:()=>Wn,IsUri:()=>vs,IsUriReference:()=>Os,IsUriTemplate:()=>Ms,IsUrl:()=>Fs,IsUuid:()=>Ns,Reset:()=>Sd,Set:()=>Bw,Test:()=>zw});var ew=[0,31,28,31,30,31,30,31,31,30,31,30,31],tw=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;function rw(e){return e%4===0&&(e%100!==0||e%400===0)}function zn(e){let t=tw.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&rw(r)?29:ew[n])}var nw=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))?$/;function Wn(e,t=!0){let r=nw.exec(e);if(!r||t&&!r[4]&&!r[5])return!1;let n=+r[1],o=+r[2],i=+r[3];if(n>23||o>59||i>60)return!1;if(r[5]){let f=+r[6],d=+r[7];if(f>23||d>59)return!1}if(i<60)return!0;let a=r[5]==="-"?-1:1,m=+(r[6]||0),c=+(r[7]||0);return((n*60+o-a*(m*60+c))%1440+1440)%1440===1439}var ow=/^(?:\[!?(?:(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13}(?:\/(?!\.{1,2}[/\]])[A-Za-z._][A-Za-z._0-9+-]{0,13})*|[+-](?:[01][0-9]|2[0-3]):[0-5][0-9])\](?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*|(?:\[!?[a-z_][a-z_0-9-]*=[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*\])*)$/;function cs(e){let t=e.indexOf("["),r=t===-1?e:e.slice(0,t);if(t!==-1&&!ow.test(e.slice(t)))return!1;let n=r.split(/T/i);return n.length===2&&zn(n[0])&&Wn(n[1])}var iw=/^P((\d+Y(\d+M(\d+D)?)?|\d+M(\d+D)?|\d+D)(T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S))?|T(\d+H(\d+M(\d+S)?)?|\d+M(\d+S)?|\d+S)|\d+W)$/;function ps(e){return iw.test(e)}var sw=/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;function fs(e){return sw.test(e)}var Xf=/^(?!-).*(?<!-)$/,Qf=/^(?!..--)/,Yf=/^[a-zA-Z0-9-]*$/,qG=new RegExp("^\\p{ASCII}*$","u"),Vn=/[^\p{ASCII}]/u;var aw=/[0-9]/,Zf=/[\u{0660}-\u{0669}]/u,mw=/[\u{06f0}-\u{06f9}]/u,uw=/[\u{002e}\u{002c}\u{003a}\u{002f}]/u,cw=/[\u{002d}\u{002b}]/u,iu=new RegExp("\\p{Mn}","u"),pw=new RegExp("\\p{Mc}","u"),UG=new RegExp("\\p{Me}","u"),ed=/[\p{Mn}\p{Mc}\p{Me}]/u,su=new RegExp("\\p{L}","u"),fw=new RegExp("\\p{Nd}","u"),td=new RegExp("\\p{Script=Greek}","u"),ds=new RegExp("\\p{Script=Hebrew}","u"),rd=/[\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Han}]/u,nd=/[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Mandaic}]/u,au=/[\u{094d}\u{09cd}\u{0a4d}\u{0acd}\u{0b4d}\u{0bcd}\u{0c4d}\u{0ccd}\u{0d3b}\u{0d3c}\u{0d4d}\u{0dca}\u{1b44}\u{1baa}\u{1bab}\u{a9c0}\u{11046}\u{1107f}\u{110b9}\u{11133}\u{11134}\u{111c0}\u{11235}\u{1134d}\u{11442}\u{114c2}\u{115bf}\u{1163f}\u{116b6}\u{11c3f}\u{11d44}\u{11d45}]/u,od=/[\u{0640}\u{07fa}\u{302e}\u{302f}\u{3031}\u{3032}\u{3033}\u{3034}\u{3035}\u{303b}]/u,dw=/[\u{00b7}\u{0375}\u{05f3}\u{05f4}\u{200c}\u{200d}\u{30fb}]/u,lw=/[\u{00df}\u{03c2}\u{06fd}\u{06fe}\u{0f0b}\u{3007}]/u,id=new RegExp([aw,mw].map(e=>e.source).join("|"),"u"),sd=new RegExp([su,cw,uw,fw,iu,pw,dw,lw].map(e=>e.source).join("|"),"u");function ad(e){return Xf.test(e)&&Qf.test(e)&&Yf.test(e)}var Jt=36,Wo=1,Vo=26,xw=38,yw=700,ud=72,cd=128;function mu(){throw null}function ls(e){return e.toLowerCase().startsWith("xn--")}function pd(e,t,r){e=r?Math.floor(e/yw):e>>1,e+=Math.floor(e/t);let n=0;for(;e>(Jt-Wo)*Vo>>1;)e=Math.floor(e/(Jt-Wo)),n+=Jt;return n+Math.floor((Jt-Wo+1)*e/(e+xw))}function gs(e){let t=[],r=cd,n=0,o=ud,i=e.lastIndexOf("-");if(i>0)for(let m=0;m<i;m++){let c=e.charCodeAt(m);c>=128&&mu(),t.push(c)}let a=i<0?0:i+1;for(;a<e.length;){let m=n,c=1,p=Jt;for(;;){a>=e.length&&mu();let d=e.charCodeAt(a++),g;d>=97&&d<=122?g=d-97:d>=48&&d<=57?g=d-48+26:mu(),n+=g*c;let y=p<=o?Wo:p>=o+Vo?Vo:p-o;if(g<y)break;c*=Jt-y,p+=Jt}let f=t.length+1;o=pd(n-m,f,m===0),r+=Math.floor(n/f),n%=f,t.splice(n,0,r),n++}return String.fromCodePoint(...t)}function md(e){return e<26?String.fromCharCode(e+97):String.fromCharCode(e-26+48)}var Iw=new RegExp(Vn.source,"gu");function fd(e){let t=e.replace(Iw,""),r=t.length,n=r>0?[t,"-"]:[],o=Array.from(e,p=>p.codePointAt(0)),i=cd,a=0,m=ud,c=r;for(;c<o.length;){let p=1/0;for(let f of o)f>=i&&f<p&&(p=f);a+=(p-i)*(c+1),i=p;for(let f of o)if(f<i&&a++,f===i){let d=a;for(let g=Jt;;g+=Jt){let y=g<=m?Wo:g>=m+Vo?Vo:g-m;if(d<y)break;let h=y+(d-y)%(Jt-y);n.push(md(h)),d=Math.floor((d-y)/(Jt-y))}n.push(md(d)),m=pd(a,c+1,c===r),a=0,c++}a++,i++}return n.join("")}var hw=/^(?:R|AL|AN|EN|ES|CS|ET|ON|BN|NSM)$/,dd=/^(?:L|EN|ES|CS|ET|ON|BN|NSM)$/,bw=/^(?:R|AL|AN)$/;function ld(e){if(ls(e))try{return xs(gs(e.slice(4).toLowerCase()))}catch{return!1}return xs(e)}function gd(e){let t=String.fromCodePoint(e);return id.test(t)?"EN":Zf.test(t)?"AN":iu.test(t)?"NSM":ds.test(t)?"R":nd.test(t)?"AL":su.test(t)?"L":"ON"}function xs(e){for(let t of e)if(bw.test(gd(t.codePointAt(0))))return!0;return!1}function ys(e){let t=!1,r=dd,n=!1,o=!1,i=!0;for(let a of e){let m=gd(a.codePointAt(0));if(i){if(m!=="L"&&m!=="R"&&m!=="AL")return!1;t=m==="R"||m==="AL",r=t?hw:dd,i=!1}if(!r.test(m))return!1;m==="EN"?n=!0:m==="AN"&&(o=!0)}return!(t&&n&&o)}function $w(e){return Vn.test(e)&&fd(e).length+4>63}function Ew(e){return e[0]==="-"||e[e.length-1]==="-"?!0:e.slice(2).join("").startsWith("--")}function Is(e){if($w(e)||xs(e)&&!ys(e))return!1;let t=[...e],r=t.map(i=>i.codePointAt(0)),n=r.length;if(Ew(t)||ed.test(t[0]))return!1;let o=!1;for(let i=0;i<n;i++){let a=r[i],m=t[i];if(od.test(m)||!sd.test(m))return!1;rd.test(m)&&(o=!0);let c=r[i-1],p=r[i+1];switch(a){case 183:if(c!==108||p!==108)return!1;break;case 885:if(!p||!td.test(t[i+1]))return!1;break;case 1523:case 1524:if(!c||!ds.test(t[i-1]))return!1;break;case 8204:if(!c||c<128&&!au.test(t[i-1]))return!1;break;case 8205:if(!c||!au.test(t[i-1]))return!1;break;case 12539:break}}return!(e.includes("\u30FB")&&!o)}function hs(e){if(!ls(e))return!1;try{let t=e.slice(4).toLowerCase();if(t.lastIndexOf("-")===0)return!1;let r=gs(t);return Vn.test(r)?Is(r):!1}catch{return!1}}function Sw(e){return e.length>0&&e.length<=63}function kw(e){return Sw(e)&&(hs(e)||ad(e))}function hd(e){return e.length===0||e.length>253||e.charCodeAt(e.length-1)===46?!1:e.split(".").every(t=>kw(t))}function Tw(e){return e.length>0&&e.length<=63}function Cw(e){return Tw(e)&&(hs(e)||Is(e))}function Rw(e){return e.replace(/[\uff01-\uff5e]/g,t=>String.fromCharCode(t.charCodeAt(0)-65248)).normalize("NFC").replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu,"").replace(/[\u002E\u3002\uFF0E\uFF61]/g,".")}function bd(e){if(e.length===0||e.includes(" "))return!1;let t=Rw(e);if(t.length>253)return!1;let r=t.split("."),n=r.some(o=>ld(o));return r.every(o=>Cw(o)&&(!n||ys(o)))}function bs(e){return hd(e)}var ww=/^(?:[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+(?:\.[A-Za-z0-9!#$%&'*+\/=?^_`{|}~\u{0080}-\u{10FFFF}-]+)*|"(?:[^"\\]|\\.)*")@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-)(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,62})(?<!-))*$/iu;function $s(e){return ww.test(e.normalize("NFC"))}function Es(e){return bd(e)}var Pw=/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;function Ss(e){return Pw.test(e)}var Aw=/^(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)$/i;function ks(e){return Aw.test(e)}var Ow=/[\x00-\x20\x7F\\]|%(?![0-9a-fA-F]{2})/,Mw=/^[a-zA-Z][a-zA-Z0-9+\-.]*\/\//;function Ts(e){return!Ow.test(e)&&!Mw.test(e)&&URL.canParse(e,"http://example.com")}var vw=/[\x00-\x20<>\^`{|}\\]/,Fw=/%(?![0-9a-fA-F]{2})/;function Cs(e){return vw.test(e)||Fw.test(e)?!1:URL.canParse(e)}var Nw=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;function Rs(e){return Nw.test(e)}var Dw=/^(?:\/(?:[^~/]|~0|~1)*)*$/;function ws(e){return Dw.test(e)}function Ps(e){try{return new RegExp(e,"u"),!0}catch{return!1}}var Lw=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function As(e){return Lw.test(e)}var jw=/^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Os(e){return jw.test(e)}var _w=/^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;function Ms(e){return _w.test(e)}var qw=/^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,3}[\da-f]{1,4})?::[\da-f]{1,4}:(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,4}[\da-f]{1,4})?::(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,5}[\da-f]{1,4})?::[\da-f]{1,4}|(?:(?:[\da-f]{1,4}:){0,6}[\da-f]{1,4})?::)|v[0-9a-f]+\.[-a-z0-9._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function vs(e){return qw.test(e)}function Fs(e){return URL.canParse(e)}var Uw=/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function Ns(e){return Uw.test(e)}var pe=new Map;function Ed(){pe.clear()}function Gw(){return[...pe.entries()]}function Bw(e,t){pe.set(e,t)}function Kw(e){return pe.has(e)}function Hw(e){return pe.get(e)}function zw(e,t){return pe.get(e)?.(t)??!0}function Sd(){Ed(),pe.set("date-time",cs),pe.set("date",zn),pe.set("duration",ps),pe.set("email",fs),pe.set("hostname",bs),pe.set("idn-email",$s),pe.set("idn-hostname",Es),pe.set("ipv4",Ss),pe.set("ipv6",ks),pe.set("iri-reference",Ts),pe.set("iri",Cs),pe.set("json-pointer-uri-fragment",Rs),pe.set("json-pointer",ws),pe.set("regex",Ps),pe.set("relative-json-pointer",As),pe.set("time",Wn),pe.set("uri-reference",Os),pe.set("uri-template",Ms),pe.set("uri",vs),pe.set("url",Fs),pe.set("uuid",Ns)}Sd();function cu(e,t,r,n){return Jo.Test(r.format,n)}function kd(e,t,r,n,o,i){return cu(e,t,o,i)||t.AddError("format",r,n,{format:o.format})}function Td(e,t,r,n){let o=as(r)?r.then:!0,i=Zi(r)?r.else:!0;return X(e,t,r.if,n)?X(e,t,o,n):X(e,t,i,n)}function Cd(e,t,r,n,o,i){let a=as(o)?o.then:!0,m=Zi(o)?o.else:!0,c=new Ye,p=ae(e,c,`${r}/if`,n,o.if,i)?ae(e,c,`${r}/then`,n,a,i)||t.AddError("if",r,n,{failingKeyword:"then"}):ae(e,t,`${r}/else`,n,m,i)||t.AddError("if",r,n,{failingKeyword:"else"});return p&&t.Merge([c]),p}function Ww(e,t,r,n){return s.Every(r.items,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ot(e,t,o,n[i])&&t.AddIndex(i))}function Vw(e,t,r,n,o,i){return s.EveryAll(o.items,0,(a,m)=>{let c=`${r}/items/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||Mt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function Jw(e,t,r,n){let o=In(r)?r.prefixItems.length:0;return s.Every(n,o,(i,a)=>Ot(e,t,r.items,i)&&t.AddIndex(a))}function Xw(e,t,r,n,o,i){let a=In(o)?o.prefixItems.length:0;return s.EveryAll(i,a,(m,c)=>{let p=`${r}/items`,f=`${n}/${c}`;return Mt(e,t,p,f,o.items,m)&&t.AddIndex(c)})}function Rd(e,t,r,n){return ts(r)?Ww(e,t,r,n):Jw(e,t,r,n)}function wd(e,t,r,n,o,i){return ts(o)?Vw(e,t,r,n,o,i):Xw(e,t,r,n,o,i)}function Qw(e){return Ur(e)}function pu(e,t,r,n){if(!Qw(r))return!0;let o=s.Counted(n,i=>X(e,t,r.contains,i));return s.IsLessEqualThan(o,r.maxContains)}function Pd(e,t,r,n,o,i){let a=xn(o)?o.minContains:1;return pu(e,t,o,i)||t.AddError("contains",r,n,{minContains:a,maxContains:o.maxContains})}function fu(e,t,r,n){return s.IsLessEqualThan(n,r.maximum)}function Ad(e,t,r,n,o,i){return fu(e,t,o,i)||t.AddError("maximum",r,n,{comparison:"<=",limit:o.maximum})}function du(e,t,r,n){return s.IsLessEqualThan(n.length,r.maxItems)}function Od(e,t,r,n,o,i){return du(e,t,o,i)||t.AddError("maxItems",r,n,{limit:o.maxItems})}function lu(e,t,r,n){return s.IsMaxLength(n,r.maxLength)}function Md(e,t,r,n,o,i){return lu(e,t,o,i)||t.AddError("maxLength",r,n,{limit:o.maxLength})}function gu(e,t,r,n){return s.IsLessEqualThan(s.Keys(n).length,r.maxProperties)}function vd(e,t,r,n,o,i){return gu(e,t,o,i)||t.AddError("maxProperties",r,n,{limit:o.maxProperties})}function Yw(e){return Ur(e)}function xu(e,t,r,n){if(!Yw(r))return!0;let o=s.Counted(n,(i,a)=>X(e,t,r.contains,i)&&t.AddIndex(a));return s.IsGreaterEqualThan(o,r.minContains)}function Fd(e,t,r,n,o,i){return xu(e,t,o,i)||t.AddError("contains",r,n,{minContains:o.minContains})}function yu(e,t,r,n){return s.IsGreaterEqualThan(n,r.minimum)}function Nd(e,t,r,n,o,i){return yu(e,t,o,i)||t.AddError("minimum",r,n,{comparison:">=",limit:o.minimum})}function Iu(e,t,r,n){return s.IsGreaterEqualThan(n.length,r.minItems)}function Dd(e,t,r,n,o,i){return Iu(e,t,o,i)||t.AddError("minItems",r,n,{limit:o.minItems})}function hu(e,t,r,n){return s.IsMinLength(n,r.minLength)}function Ld(e,t,r,n,o,i){return hu(e,t,o,i)||t.AddError("minLength",r,n,{limit:o.minLength})}function bu(e,t,r,n){return s.IsGreaterEqualThan(s.Keys(n).length,r.minProperties)}function jd(e,t,r,n,o,i){return bu(e,t,o,i)||t.AddError("minProperties",r,n,{limit:o.minProperties})}function $u(e,t,r,n){return s.IsMultipleOf(n,r.multipleOf)}function _d(e,t,r,n,o,i){return $u(e,t,o,i)||t.AddError("multipleOf",r,n,{multipleOf:o.multipleOf})}function Eu(e,t,r,n){let o=new ct;return!X(e,o,r.not,n)&&t.Merge([o])}function qd(e,t,r,n,o,i){return Eu(e,t,o,i)||t.AddError("not",r,n,{})}function Ud(e,t,r,n){let o=r.oneOf.reduce((i,a)=>{let m=new ct;return X(e,m,a,n)?[...i,m]:i},[]);return s.IsEqual(o.length,1)&&t.Merge(o)}function Gd(e,t,r,n,o,i){let a=[],m=[],c=o.oneOf.reduce((f,d,g)=>{let y=new Ye,h=`${r}/oneOf/${g}`,I=ae(e,y,h,n,d,i);return I&&m.push(g),I||a.push(y),I?[...f,y]:f},[]),p=s.IsEqual(c.length,1)&&t.Merge(c);return!p&&s.IsEqual(m.length,0)&&a.forEach(f=>t.AddErrors(f.GetErrors())),p||t.AddError("oneOf",r,n,{passingSchemas:m})}function Su(e,t,r,n){return(s.IsString(r.pattern)?Kr(r.pattern):r.pattern).test(n)}function Bd(e,t,r,n,o,i){return Su(e,t,o,i)||t.AddError("pattern",r,n,{pattern:o.pattern})}function Kd(e,t,r,n){return s.Every(s.Entries(r.patternProperties),0,([o,i])=>{let a=Kr(o);return s.Every(s.Entries(n),0,([m,c])=>!a.test(m)||Ot(e,t,i,c)&&t.AddKey(m))})}function Hd(e,t,r,n,o,i){return s.EveryAll(s.Entries(o.patternProperties),0,([a,m])=>{let c=`${r}/patternProperties/${$t(a)}`,p=Kr(a);return s.EveryAll(s.Entries(i),0,([f,d])=>{let g=`${n}/${$t(f)}`;return!p.test(f)||Mt(e,t,c,g,m,d)&&t.AddKey(f)})})}function zd(e,t,r,n){return s.IsEqual(n.length,0)||s.Every(r.prefixItems,0,(o,i)=>s.IsLessEqualThan(n.length,i)||Ot(e,t,o,n[i])&&t.AddIndex(i))}function Wd(e,t,r,n,o,i){return s.IsEqual(i.length,0)||s.EveryAll(o.prefixItems,0,(a,m)=>{let c=`${r}/prefixItems/${m}`,p=`${n}/${m}`;return s.IsLessEqualThan(i.length,m)||Mt(e,t,c,p,a,i[m])&&t.AddIndex(m)})}function ku(e,t){return e.includes(t)||Ae.Get().exactOptionalPropertyTypes}function Tu(e,t){return s.IsUndefined(e[t])}function Vd(e,t,r,n){let o=hn(r)?r.required:[];return s.Every(s.Entries(r.properties),0,([a,m])=>{let c=!s.HasPropertyKey(n,a)||Ot(e,t,m,n[a])&&t.AddKey(a);return ku(o,a)?c:Tu(n,a)||c})}function Jd(e,t,r,n,o,i){let a=hn(o)?o.required:[];return s.EveryAll(s.Entries(o.properties),0,([c,p])=>{let f=`${r}/properties/${$t(c)}`,d=`${n}/${$t(c)}`,g=()=>!s.HasPropertyKey(i,c)||Mt(e,t,f,d,p,i[c])&&t.AddKey(c);return ku(a,c)?g():Tu(i,c)||g()})}function Xd(e,t,r,n){return s.Every(s.Keys(n),0,(o,i)=>X(e,t,r.propertyNames,o))}function Qd(e,t,r,n,o,i){let a=[];return s.EveryAll(s.Keys(i),0,(c,p)=>{let f=`${n}/${$t(c)}`,d=`${r}/propertyNames`,g=ae(e,t,d,f,o.propertyNames,c);return g||a.push(c),g})||t.AddError("propertyNames",r,n,{propertyNames:a})}function Yd(e,t,r,n){let o=Ut.RecursiveRef(e,r)??!1,i=o?{...e,pendingResource:!0}:e;return v(o)&&X(i,t,o,n)}function Zd(e,t,r,n,o,i){let a=Ut.RecursiveRef(e,o)??!1,m=a?{...e,pendingResource:!0}:e;return v(a)&&ae(m,t,r,n,a,i)}function el(e,t,r,n){let o=Ut.Ref(e,r),i=o.schema??!1,a=new ct,m=v(i)&&X(o.stack,a,i,n);return m&&t.Merge([a]),m}function tl(e,t,r,n,o,i){let a=Ut.Ref(e,o),m=a.schema??!1,c=new Ye,p=v(m)&&ae(a.stack,c,r,n,m,i);return p&&t.Merge([c]),p||t.AddErrors(c.GetErrors()),p}function rl(e,t,r,n){return s.Every(r.required,0,o=>s.HasPropertyKey(n,o))}function nl(e,t,r,n,o,i){let a=[];return s.EveryAll(o.required,0,c=>{let p=s.HasPropertyKey(i,c);return p||a.push(c),p})||t.AddError("required",r,n,{requiredProperties:a})}function Cu(e,t,r,n,o){return s.IsEqual(r,"object")?s.IsObjectNotArray(o):s.IsEqual(r,"array")?s.IsArray(o):s.IsEqual(r,"boolean")?s.IsBoolean(o):s.IsEqual(r,"integer")?s.IsInteger(o):s.IsEqual(r,"number")?s.IsNumber(o):s.IsEqual(r,"null")?s.IsNull(o):s.IsEqual(r,"string")?s.IsString(o):s.IsEqual(r,"bigint")?s.IsBigInt(o):s.IsEqual(r,"constructor")?s.IsConstructor(o):s.IsEqual(r,"function")?s.IsFunction(o):s.IsEqual(r,"symbol")?s.IsSymbol(o):s.IsEqual(r,"undefined")?s.IsUndefined(o):s.IsEqual(r,"void")?s.IsUndefined(o):!0}function ol(e,t,r,n,o){return s.Some(r,i=>Cu(e,t,i,n,o))}function il(e,t,r,n){return s.IsArray(r.type)?ol(e,t,r.type,r,n):Cu(e,t,r.type,r,n)}function sl(e,t,r,n,o,i){return(s.IsArray(o.type)?ol(e,t,o.type,o,i):Cu(e,t,o.type,o,i))||t.AddError("type",r,n,{type:o.type})}function al(e,t,r,n){let o=t.GetIndices();return s.Every(n,0,(i,a)=>(o.has(a)||X(e,t,r.unevaluatedItems,i))&&t.AddIndex(a))}function ml(e,t,r,n,o,i){let a=t.GetIndices(),m=[];return s.EveryAll(i,0,(p,f)=>{let d=new Ye,g=(a.has(f)||ae(e,d,r,n,o.unevaluatedItems,p))&&t.AddIndex(f);return g||m.push(f),g})||t.AddError("unevaluatedItems",r,n,{unevaluatedItems:m})}function ul(e,t,r,n){let o=t.GetKeys();return s.Every(s.Entries(n),0,([i,a])=>o.has(i)||X(e,t,r.unevaluatedProperties,a)&&t.AddKey(i))}function cl(e,t,r,n,o,i){let a=t.GetKeys(),m=[];return s.EveryAll(s.Entries(i),0,([p,f])=>{let d=new Ye,g=a.has(p)||ae(e,d,r,n,o.unevaluatedProperties,f)&&t.AddKey(p);return g||m.push(p),g})||t.AddError("unevaluatedProperties",r,n,{unevaluatedProperties:m})}var Rr={};At(Rr,{Hash:()=>xl,HashCode:()=>d0});function he(){throw new Error("Unreachable")}function Zw(e){let t=new Set,r=e;for(;r&&r!==Object.prototype;){for(let n of Reflect.ownKeys(r))n!=="constructor"&&typeof n!="symbol"&&t.add(n);r=Object.getPrototypeOf(r)}return[...t]}function e0(e){return typeof e=="number"}var St={Array:0,BigInt:1,Boolean:2,Date:3,Constructor:4,Function:5,Null:6,Number:7,Object:8,RegExp:9,String:10,Symbol:11,TypeArray:12,Undefined:13},Ls=8997,Xo=33826,js=40164,_s=52210,dl=new Float64Array(1),ll=new DataView(dl.buffer),gl=new Uint8Array(dl.buffer);function Ue(e){let t=Ls^e,r=t*435,n=Xo*435+(r>>>16),o=js*435+(n>>>16)+(t<<8),i=_s*435+(o>>>16)+(Xo<<8);Ls=r&65535,Xo=n&65535,js=o&65535,_s=i&65535}function t0(e){Ue(St.Array);for(let t of e)Hr(t)}function r0(e){Ue(St.BigInt),ll.setBigInt64(0,e);for(let t of gl)Ue(t)}function pl(e){Ue(St.Boolean),Ue(e?1:0)}function n0(e){Ue(St.Constructor),Hr(e.toString())}function o0(e){Ue(St.Date),Hr(e.getTime())}function i0(e){Ue(St.Function),Hr(e.toString())}function s0(e){Ue(St.Null)}function fl(e){Ue(St.Number),ll.setFloat64(0,e,!0);for(let t of gl)Ue(t)}function a0(e){Ue(St.Object);for(let t of Zw(e).sort())Hr(t),Hr(e[t])}function m0(e){Ue(St.RegExp),Ru(e.toString())}var u0=new TextEncoder;function Ru(e){Ue(St.String);for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r>127){for(let n of u0.encode(e.slice(t)))Ue(n);return}Ue(r)}}function c0(e){Ue(St.Symbol),Hr(e.toString())}function p0(e){Ue(St.TypeArray);let t=new Uint8Array(e.buffer);for(let r=0;r<t.length;r++)Ue(t[r])}function f0(e){return Ue(St.Undefined)}function Hr(e){return Ne.IsTypeArray(e)?p0(e):Ne.IsDate(e)?o0(e):Ne.IsRegExp(e)?m0(e):Ne.IsBoolean(e)?pl(e.valueOf()):Ne.IsString(e)?Ru(e.valueOf()):Ne.IsNumber(e)?fl(e.valueOf()):e0(e)?fl(e):s.IsArray(e)?t0(e):s.IsBoolean(e)?pl(e):s.IsBigInt(e)?r0(e):s.IsConstructor(e)?n0(e):s.IsNull(e)?s0(e):s.IsObject(e)?a0(e):s.IsString(e)?Ru(e):s.IsSymbol(e)?c0(e):s.IsUndefined(e)?f0(e):s.IsFunction(e)?i0(e):he()}function Ds(e){return e.toString(16).padStart(4,"0")}function d0(e){return BigInt(`0x${xl(e)}`)}function xl(e){return Ls=8997,Xo=33826,js=40164,_s=52210,Hr(e),`${Ds(_s)}${Ds(js)}${Ds(Xo)}${Ds(Ls)}`}function yl(e){return!s.IsEqual(e.uniqueItems,!1)}function Il(e,t,r,n){if(!yl(r))return!0;let o=new Set(n.map(Rr.Hash)).size,i=n.length;return s.IsEqual(o,i)}function hl(e,t,r,n,o,i){if(!yl(o))return!0;let a=new Set,m=i.reduce((p,f,d)=>{let g=Rr.Hash(f);return a.has(g)?[...p,d]:(a.add(g),p)},[]);return s.IsEqual(m.length,0)||t.AddError("uniqueItems",r,n,{duplicateItems:m})}function Ot(e,t,r,n){return t.Push()&&X(e,t,r,n)&&t.Pop()}function X(e,t,r,n){let o=Kn(e,r);return ln(r)?zm(o,t,r,n):(!Gm(r)||il(o,t,r,n))&&(!(s.IsObject(n)&&!s.IsArray(n))||(!hn(r)||rl(o,t,r,n))&&(!qt(r)||Ef(o,t,r,n))&&(!vm(r)||Of(o,t,r,n))&&(!Fm(r)||vf(o,t,r,n))&&(!Qi(r)||Nf(o,t,r,n))&&(!qn(r)||Kd(o,t,r,n))&&(!Un(r)||Vd(o,t,r,n))&&(!os(r)||Xd(o,t,r,n))&&(!Lo(r)||bu(o,t,r,n))&&(!qm(r)||gu(o,t,r,n)))&&(!s.IsArray(n)||(!Vi(r)||hf(o,t,r,n))&&(!Ur(r)||Vm(o,t,r,n))&&(!gn(r)||Rd(o,t,r,n))&&(!xn(r)||xu(o,t,r,n))&&(!jm(r)||pu(o,t,r,n))&&(!yn(r)||Iu(o,t,r,n))&&(!No(r)||du(o,t,r,n))&&(!In(r)||zd(o,t,r,n))&&(!Br(r)||Il(o,t,r,n)))&&(!s.IsString(n)||(!Do(r)||hu(o,t,r,n))&&(!_m(r)||lu(o,t,r,n))&&(!Fo(r)||cu(o,t,r,n))&&(!jo(r)||Su(o,t,r,n)))&&(!(s.IsNumber(n)||s.IsBigInt(n))||(!kr(r)||ou(o,t,r,n))&&(!Dm(r)||nu(o,t,r,n))&&(!Tr(r)||yu(o,t,r,n))&&(!Lm(r)||fu(o,t,r,n))&&(!Um(r)||$u(o,t,r,n)))&&(!ss(r)||el(o,t,r,n))&&(!is(r)||Yd(o,t,r,n))&&(!Yi(r)||Hf(o,t,r,n))&&(!Mm(r)||Wm(o,t,r,n))&&(!Nm(r)||ru(o,t,r,n))&&(!es(r)||Td(o,t,r,n))&&(!rs(r)||Eu(o,t,r,n))&&(!Ji(r)||kf(o,t,r,n))&&(!Xi(r)||Cf(o,t,r,n))&&(!ns(r)||Ud(o,t,r,n))&&(!qo(r)||!s.IsArray(n)||al(o,t,r,n))&&(!Uo(r)||!s.IsObject(n)||ul(o,t,r,n))&&(!Wi(r)||ff(o,t,r,n))}function Mt(e,t,r,n,o,i){return t.Push()&&ae(e,t,r,n,o,i)&&t.Pop()}function ae(e,t,r,n,o,i){if(t.AtCapacity())return!1;let a=Kn(e,o);return ln(o)?wf(a,t,r,n,o,i):!!(+(!Gm(o)||sl(a,t,r,n,o,i))&+(!(s.IsObject(i)&&!s.IsArray(i))||!!(+(!hn(o)||nl(a,t,r,n,o,i))&+(!qt(o)||Sf(a,t,r,n,o,i))&+(!vm(o)||Mf(a,t,r,n,o,i))&+(!Fm(o)||Ff(a,t,r,n,o,i))&+(!Qi(o)||Df(a,t,r,n,o,i))&+(!qn(o)||Hd(a,t,r,n,o,i))&+(!Un(o)||Jd(a,t,r,n,o,i))&+(!os(o)||Qd(a,t,r,n,o,i))&+(!Lo(o)||jd(a,t,r,n,o,i))&+(!qm(o)||vd(a,t,r,n,o,i))))&+(!s.IsArray(i)||!!(+(!Vi(o)||bf(a,t,r,n,o,i))&+(!Ur(o)||Af(a,t,r,n,o,i))&+(!gn(o)||wd(a,t,r,n,o,i))&+(!xn(o)||Fd(a,t,r,n,o,i))&+(!jm(o)||Pd(a,t,r,n,o,i))&+(!yn(o)||Dd(a,t,r,n,o,i))&+(!No(o)||Od(a,t,r,n,o,i))&+(!In(o)||Wd(a,t,r,n,o,i))&+(!Br(o)||hl(a,t,r,n,o,i))))&+(!s.IsString(i)||!!(+(!Do(o)||Ld(a,t,r,n,o,i))&+(!_m(o)||Md(a,t,r,n,o,i))&+(!Fo(o)||kd(a,t,r,n,o,i))&+(!jo(o)||Bd(a,t,r,n,o,i))))&+(!(s.IsNumber(i)||s.IsBigInt(i))||!!(+(!kr(o)||Jf(a,t,r,n,o,i))&+(!Dm(o)||Vf(a,t,r,n,o,i))&+(!Tr(o)||Nd(a,t,r,n,o,i))&+(!Lm(o)||Ad(a,t,r,n,o,i))&+(!Um(o)||_d(a,t,r,n,o,i))))&+(!ss(o)||tl(a,t,r,n,o,i))&+(!is(o)||Zd(a,t,r,n,o,i))&+(!Yi(o)||zf(a,t,r,n,o,i))&+(!Mm(o)||Pf(a,t,r,n,o,i))&+(!Nm(o)||Wf(a,t,r,n,o,i))&+(!es(o)||Cd(a,t,r,n,o,i))&+(!rs(o)||qd(a,t,r,n,o,i))&+(!Ji(o)||Tf(a,t,r,n,o,i))&+(!Xi(o)||Rf(a,t,r,n,o,i))&+(!ns(o)||Gd(a,t,r,n,o,i))&+(!qo(o)||!s.IsArray(i)||ml(a,t,r,n,o,i))&+(!Uo(o)||!s.IsObject(i)||cl(a,t,r,n,o,i)))&&(!Wi(o)||df(a,t,r,n,o,i))}function $l(e){switch(e.keyword){case"additionalProperties":return"must not have additional properties";case"anyOf":return"must match a schema in anyOf";case"boolean":return"schema is false";case"const":return"must be equal to constant";case"contains":return"must contain at least 1 valid item";case"dependencies":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"dependentRequired":return`must have properties ${e.params.dependencies.join(", ")} when property ${e.params.property} is present`;case"enum":return"must be equal to one of the allowed values";case"exclusiveMaximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"exclusiveMinimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"format":return`must match format "${e.params.format}"`;case"if":return`must match "${e.params.failingKeyword}" schema`;case"maxItems":return`must not have more than ${e.params.limit} items`;case"maxLength":return`must not have more than ${e.params.limit} characters`;case"maxProperties":return`must not have more than ${e.params.limit} properties`;case"maximum":return`must be ${e.params.comparison} ${e.params.limit}`;case"minItems":return`must not have fewer than ${e.params.limit} items`;case"minLength":return`must not have fewer than ${e.params.limit} characters`;case"minProperties":return`must not have fewer than ${e.params.limit} properties`;case"minimum":return`must be ${e.params.comparison} ${e.params.limit}`;case"multipleOf":return`must be multiple of ${e.params.multipleOf}`;case"not":return"must not be valid";case"oneOf":return"must match exactly one schema in oneOf";case"pattern":return`must match pattern "${e.params.pattern}"`;case"propertyNames":return`property names ${e.params.propertyNames.join(", ")} are invalid`;case"required":return`must have required properties ${e.params.requiredProperties.join(", ")}`;case"type":return typeof e.params.type=="string"?`must be ${e.params.type}`:`must be either ${e.params.type.join(" or ")}`;case"unevaluatedItems":return"must not have unevaluated items";case"unevaluatedProperties":return"must not have unevaluated properties";case"uniqueItems":return"must not have duplicate items";case"~refine":return e.params.message;default:return"an unknown validation error occurred"}}var l0=$l;function El(){return l0}var l={};At(l,{Assign:()=>x0,Clone:()=>y0,Create:()=>h0,Discard:()=>b0,Metrics:()=>Xt,Update:()=>k0});var Xt={assign:0,create:0,clone:0,discard:0,update:0};function vt(e){return[...s.Keys(e),...s.Symbols(e)]}function Sl(e,t){if(!t.has(e)){t.add(e);for(let r of vt(e)){let n=Object.getOwnPropertyDescriptor(e,r);!n||!("value"in n)||s.IsObject(n.value)&&Sl(n.value,t)}Object.freeze(e)}}function zr(e){return Ae.Get().immutableTypes&&Sl(e,new WeakSet),e}function x0(e,t){Xt.assign+=1;let r={},n=vt(t),o=vt(e);for(let i of o)n.includes(i)||Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i));for(let i of n)Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i));return zr(r)}function y0(e){Xt.clone+=1;let t={};for(let r of vt(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function kl(e,t){return{...e,...t}}function I0(e,t){for(let r of Object.keys(t))Object.defineProperty(e,r,{configurable:!0,writable:!0,enumerable:!1,value:t[r]});return e}function h0(e,t,r={}){Xt.create+=1;let n=kl(t,r),o=Ae.Get().enumerableKind?kl(n,e):I0(n,e);return zr(o)}function b0(e,t){Xt.discard+=1;let r={};for(let n of vt(e)){if(t.includes(n))continue;let o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,o)}return zr(r)}function $0(e,t,r,n){for(let o of vt(e)){if(s.IsUnsafePropertyKey(o)||t.includes(o)||r.includes(o))continue;let i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,i)}}function E0(e,t,r){let n=Ae.Get().enumerableKind;for(let o of t)s.IsUnsafePropertyKey(o)||Object.defineProperty(r,o,{configurable:!0,writable:!0,enumerable:n,value:e[o]})}function S0(e,t,r){for(let n of t)s.IsUnsafePropertyKey(n)||Object.defineProperty(r,n,{configurable:!0,enumerable:!0,writable:!0,value:e[n]})}function k0(e,t,r){Xt.update+=1;let n={},o=vt(t),i=vt(r);return $0(e,o,i,n),E0(t,o,n),S0(r,i,n),zr(n)}function qs(...e){let[t,r,n]=q.Match(e,{3:(f,d,g)=>[f,d,g],2:(f,d)=>[{},f,d]}),o=Bn(t,r),i=new Ye,a=ae(o,i,"#","",r,n),m=i.GetErrors(),c=El(),p=m.map(f=>({...f,message:c(f)}));return[a,p]}var Cl=0;function Us(){let e=zi();Cl=e.maxErrors,e.maxErrors=e.maxParseErrors}function Gs(){let e=zi();e.maxErrors=Cl}function Pu(...e){let[t,r,n]=q.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),o=Bn(t,r),i=new ct;return X(o,i,r,n)}function B(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return Pu(t,r,n)}function Qt(...e){let[t,r,n]=q.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]}),[o,i]=qs(t,r,n);return i}var wr=class extends Error{constructor(t,r,n){super(t),Object.defineProperty(this,"cause",{value:{source:t,errors:n,value:r},writable:!1,configurable:!1,enumerable:!1})}};function Bs(...e){let[t,r,n]=q.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});if(!B(t,r,n))throw new wr("Assert",n,Qt(t,r,n))}function k(e,t){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],t)}function de(e){return s.IsObject(e)}function T(e,t,r){return l.Create({"~kind":"Deferred"},{type:"deferred",action:e,parameters:t,options:r},{})}function Wr(e){return k(e,"Deferred")}function ar(e,t){return l.Update(e,{"~readonly":!0},t)}function Rl(e,t,r,n){let o=$(e,t,r);return ar(o,n)}function mr(e,t){return l.Update(e,{"~optional":!0},t)}function wl(e,t,r,n){let o=$(e,t,r);return mr(o,n)}function xt(e,t){return l.Create({"~kind":"Array"},{type:"array",items:e},t)}function H(e){return k(e,"Array")}function Jn(e){return l.Discard(e,["~kind","type","items"])}function ur(e,t,r={}){return l.Create({"~kind":"Constructor"},{type:"constructor",parameters:e,instanceType:t},r)}function be(e){return k(e,"Constructor")}function Pl(e){return l.Discard(e,["~kind","type","parameters","instanceType"])}function cr(e,t,r={}){return l.Create({"~kind":"Function"},{type:"function",parameters:e,returnType:t},r)}function $e(e){return k(e,"Function")}function Al(e){return l.Discard(e,["~kind","type","parameters","returnType"])}function qe(e,t){return l.Create({"~kind":"Ref"},{$ref:e},t)}function Z(e){return k(e,"Ref")}function Vr(e,t){return l.Create({"~kind":"Generic"},{type:"generic",parameters:e,expression:t})}function Xn(e){return k(e,"Generic")}function Qn(e){return l.Create({"~kind":"Any"},{},e)}function ye(e){return k(e,"Any")}var Ol="(?!)";function re(e){return l.Create({"~kind":"Never"},{not:{}},e)}function yt(e){return k(e,"Never")}function pr(e,t={}){return T("AddOptional",[e],t)}function Ks(e,t={}){return mr(e,t)}function Ml(e){return Ks(e)}function Oe(e){return de(e)&&s.HasPropertyKey(e,"~optional")}function vl(e){return s.Keys(e).filter(t=>!Oe(e[t]))}function Hs(e){return s.Keys(e)}function zs(e){return s.Values(e)}function A(e,t={}){let r=vl(e),n=r.length>0?{required:r}:{};return l.Create({"~kind":"Object"},{type:"object",...n,properties:e},t)}function w(e){return k(e,"Object")}function Fl(e){return l.Discard(e,["~kind","type","properties","required"])}function De(e){return l.Create({"~kind":"Unknown"},{},e)}function Me(e){return k(e,"Unknown")}function fr(e,t,r){let n=s.Keys(e).reduce((o,i)=>({...o,[i]:l.Update(e[i],{},{$id:i})}),{});return l.Create({"~kind":"Cyclic"},{$defs:n,$ref:t},r)}function ie(e){return k(e,"Cyclic")}function Nl(e){return l.Update(e,{"~unsafe":null},{})}function Ws(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"~unsafe")&&s.IsNull(e["~unsafe"])}function Qo(...e){let[t,r]=q.Match(e,{2:(n,o)=>[n,o,o],1:n=>[n,De(),De()]});return l.Create({"~kind":"Infer"},{type:"infer",name:t,extends:r},{})}function ve(e){return k(e,"Infer")}function $n(e,t,r,n={}){return l.Create({"~kind":"Dependent"},{if:e,then:t,else:r},n)}function Ee(e){return k(e,"Dependent")}function Dl(e){return l.Discard(e,["~kind","if","then","else"])}function Ll(e){return s.IsObjectNotArray(e)}function jl(e){return s.Keys(e).filter(r=>isNaN(r)).reduce((r,n)=>[...r,e[n]],[])}function _l(e){return s.IsString(e)||s.IsNumber(e)}function ql(e,t){let r=Ll(e)?jl(e):e;return l.Create({"~kind":"Enum"},{enum:r},t)}function Se(e){return k(e,"Enum")}function nt(e,t={}){return l.Create({"~kind":"Intersect"},{allOf:e},t)}function P(e){return k(e,"Intersect")}function Ul(e){return l.Discard(e,["~kind","allOf"])}var Yo=class{constructor(t,r){this.type=t,this.decode=r}Encode(t){let r=this.type,n=pt(r)?a=>this.decode(r["~codec"].decode(a)):this.decode,o=pt(r)?a=>r["~codec"].encode(t(a)):t,i={decode:n,encode:o};return l.Update(this.type,{"~codec":i},{})}},Zo=class{constructor(t){this.type=t}Decode(t){return new Yo(this.type,t)}};function Vs(e){return new Zo(e)}function Gl(e,t){return Vs(e).Decode(t).Encode(()=>{throw Error("Encode not implemented")})}function Bl(e,t){return Vs(e).Decode(()=>{throw Error("Decode not implemented")}).Encode(t)}function pt(e){return de(e)&&s.HasPropertyKey(e,"~codec")&&s.IsObject(e["~codec"])&&s.HasPropertyKey(e["~codec"],"encode")&&s.HasPropertyKey(e["~codec"],"decode")}function Kl(e){return Yn(e)}function En(e){return de(e)&&s.HasPropertyKey(e,"~immutable")}function dr(e,t={}){return T("AddReadonly",[e],t)}function Js(e,t={}){return ar(e,t)}function Hl(e){return Js(e)}function Pr(e){return de(e)&&s.HasPropertyKey(e,"~readonly")}function R0(e,t){let r=ei(e)?[...e["~refine"],t]:[t];return l.Update(e,{"~refine":r},{})}function zl(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,()=>"Refine Error"]});return R0(t,{check:r,error:n})}function w0(e){return s.IsObjectNotArray(e)&&s.HasPropertyKey(e,"check")&&s.HasPropertyKey(e,"error")&&s.IsFunction(e.check)&&s.IsFunction(e.error)}function ei(e){return de(e)&&s.HasPropertyKey(e,"~refine")&&s.IsArray(e["~refine"])&&s.Every(e["~refine"],0,t=>w0(t))}var Wl="-?(?:0|[1-9][0-9]*)n";function ti(e){return l.Create({"~kind":"BigInt"},{type:"bigint"},e)}function kt(e){return k(e,"BigInt")}function Xs(e){return l.Create({"~kind":"Boolean"},{type:"boolean"},e)}function ft(e){return k(e,"Boolean")}function ri(e){return l.Create({"~kind":"Identifier"},{name:e})}function Vl(e){return k(e,"Identifier")}var Qs="-?(?:0|[1-9][0-9]*)";function Sn(e){return l.Create({"~kind":"Integer"},{type:"integer"},e)}function Ge(e){return k(e,"Integer")}var Au=class extends Error{constructor(t){super("Invalid Literal value"),Object.defineProperty(this,"cause",{value:{value:t},writable:!1,configurable:!1,enumerable:!1})}};function P0(e){return s.IsBigInt(e)?"bigint":s.IsBoolean(e)?"boolean":s.IsNumber(e)?"number":s.IsString(e)?"string":(()=>{throw new Au(e)})()}function U(e,t){return l.Create({"~kind":"Literal"},{type:P0(e),const:e},t)}function Ys(e){return s.IsBigInt(e)||s.IsBoolean(e)||s.IsNumber(e)||s.IsString(e)}function Jl(e){return K(e)&&s.IsBigInt(e.const)}function Xl(e){return K(e)&&s.IsBoolean(e.const)}function Zs(e){return K(e)&&s.IsNumber(e.const)}function ea(e){return K(e)&&s.IsString(e.const)}function K(e){return k(e,"Literal")}function Zn(e){return l.Create({"~kind":"Null"},{type:"null"},e)}function lr(e){return k(e,"Null")}var ta="-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?";function Tt(e){return l.Create({"~kind":"Number"},{type:"number"},e)}function le(e){return k(e,"Number")}function eo(e){return l.Create({"~kind":"Symbol"},{type:"symbol"},e)}function gr(e){return k(e,"Symbol")}function kn(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[o,i,i],1:o=>[o,De(),De()]});return l.Create({"~kind":"Parameter"},{name:t,extends:r,equals:n},{})}function Ql(e){return k(e,"Parameter")}var ra=".*";function Ze(e){return l.Create({"~kind":"String"},{type:"string"},e)}function Le(e){return k(e,"String")}function F(e,t={}){return l.Create({"~kind":"Union"},{anyOf:e},t)}function E(e){return k(e,"Union")}function Yl(e){return l.Discard(e,["~kind","anyOf"])}function ni(e){let t=Zl(e);return s.IsEqual(t.length,2)?t[0]:[]}function A0(e){return!0}function eg(e){return s.ShiftLeft(e,(t,r)=>O0(t)?eg(r):!1,()=>!0)}function tg(e){return s.IsEqual(e.length,0)?!1:eg(e)}function O0(e){return E(e)?tg(e.anyOf):K(e)?A0(e.const):!1}function na(e){return tg(e)}function oa(e){return l.Create({"~kind":"TemplateLiteral"},{type:"string",pattern:e},{})}function rg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>rg(o,t,[...r,`${n}${t}`]),()=>r)}function M0(e,t){return s.IsEqual(e.length,0)?[`${t}`]:rg(e,t)}function ng(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>ng(e,o,[...r,...og(e,n)]),()=>r)}function og(e,t){return E(t)?ng(e,t.anyOf):K(t)?M0(e,t.const):he()}function ig(e,t){return s.ShiftLeft(t,(r,n)=>ig(og(e,r),n),()=>e)}function v0(e){return e.map(t=>U(t))}function F0(e){let t=ig([],e),r=v0(t);return F(r)}function N0(e){return s.IsEqual(e.length,0)?he():s.IsEqual(e.length,1)&&K(e[0])?e[0]:F0(e)}function Ou(e){let t=ni(e);return s.IsEqual(t.length,0)?Ze():na(t)?N0(t):oa(e)}function to(e){let t=Ou(e);return se(t)?Ze():t}function It(e,t){let r="object",n={[e]:t};return l.Create({"~kind":"Record"},{type:r,patternProperties:n})}function sg(e){return It(Yt,e)}function ag(e){return A({true:e,false:e})}function ke(e,t={}){let[r,n,o]=[e,e.length,!1];return l.Create({"~kind":"Tuple"},{type:"array",additionalItems:o,items:r,minItems:n},t)}function j(e){return k(e,"Tuple")}function mg(e){return l.Discard(e,["~kind","type","items","minItems","additionalItems"])}function Mu(e){return e.reduceRight((r,n,o)=>({[o]:n,...r}),{})}function ug(e){let t=Mu(e.items);return A(t)}function D0(e){return l.Discard(e,["~optional"])}function Tn(e,t){return l.Update(D0(e),{},t)}function cg(e,t,r,n){let o=$(e,t,r);return Tn(o,n)}function L0(e){return l.Discard(e,["~readonly"])}function ro(e,t){return l.Update(L0(e),{},t)}function pg(e,t,r,n){let o=$(e,t,r);return ro(o,n)}function ia(e,t){let r=Pr(e)&&Pr(t),n=Oe(e)&&Oe(t),o=Te([e,t]),i=ro(Tn(o,{}),{});return r&&n?ar(mr(i,{}),{}):r?ar(i,{}):n?mr(i,{}):i}function fg(e,t){let r=Pr(e)||Pr(t),n=Oe(e)||Oe(t),o=ro(Tn(e,{}),{}),i=ro(Tn(t,{}),{}),a=ht([o,i]);return r&&n?ar(mr(a,{}),{}):r?ar(a,{}):n?mr(a,{}):a}function j0(e,t,r){return r in e?r in t?ia(e[r],t[r]):e[r]:r in t?t[r]:re()}function _0(e,t){return[...new Set([...s.Keys(e),...s.Keys(t)])].reduce((o,i)=>({...o,[i]:j0(e,t,i)}),{})}function dg(e){return w(e)?e.properties:j(e)?Mu(e.items):{}}function lg(e,t){let r=dg(e),n=dg(t),o=_0(r,n);return A(o)}function q0(e,t){let r=no(e,t);return s.IsEqual(r,ii)?e:s.IsEqual(r,si)||s.IsEqual(r,oi)?t:re()}function gg(e){return w(e)||j(e)}function U0(e,t){let r=gg(e),n=gg(t);return r&&n?lg(e,t):r&&!n?e:!r&&n?t:q0(e,t)}function xg(e,t){return yt(e)||ye(e)?e:Me(e)||yt(t)||ye(t)?t:Me(t)?e:U0(e,t)}function G0(e,t){return E(e)||E(t)}function B0(e,t){let r=Gt(e),n=Gt(t);return G0(r,n)?Te([r,n]):xg(r,n)}function yg(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>yg(e,o,[...r,B0(n,e)]),()=>s.IsEqual(r.length,0)?[e]:r)}function Ig(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>Ig(o,t,[...r,...ai([n],t)]),()=>r)}function ai(e,t=[]){return s.ShiftLeft(e,(r,n)=>E(r)?ai(n,Ig(r.anyOf,t)):ai(n,yg(r,t)),()=>t)}function K0(e,t){let r=et({},e,t);return M.IsExtendsTrueLike(r)?[]:[e]}function hg(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>hg(o,t,[...r,...K0(n,t)]),()=>r)}function sa(e,t){let r=Gt(e),n=E(r)?r.anyOf:[r],o=hg(n,t);return ht(o)}function Zt(e,t,r){let n=Te([e,t]),o=sa(r,e);return ht([n,o])}function dt(e,t=[]){return s.ShiftLeft(e,(r,n)=>dt(n,[...t,U(r)]),()=>ht(t))}function Te(e){let t=ai(e),r=vu(t);return ht(r)}function ot(e){let t=to(e);return Gt(t)}function ht(e){let t=vu(e);return Jr(t)}function Gt(e){return Ee(e)?Zt(e.if,e.then,e.else):Se(e)?dt(e.enum):P(e)?Te(e.allOf):se(e)?ot(e.pattern):E(e)?ht(e.anyOf):e}function Jr(e){return s.IsEqual(e.length,1)?e[0]:s.IsEqual(e.length,0)?re():F(e)}function bg(e,t){let r=dt(e);return Xr(r,t)}function $g(e,t){return It(Qr,t)}function Eg(e,t){let r=Te(e);return Xr(r,t)}function Sg(e,t){return s.IsString(e)||s.IsNumber(e)?A({[e]:t}):s.IsEqual(e,!1)?A({false:t}):s.IsEqual(e,!0)?A({true:t}):A({})}function kg(e,t){return It(oo,t)}function Tg(e,t){return s.HasPropertyKey(e,"pattern")&&(s.IsString(e.pattern)||e.pattern instanceof RegExp)?It(e.pattern.toString(),t):It(Yt,t)}function Cg(e,t){let r=ni(e);return na(r)?Xr(ot(e),t):It(e,t)}function H0(e){return E(e)?Yr(e.anyOf):[e]}function Yr(e,t=[]){return s.ShiftLeft(e,(r,n)=>Yr(n,[...t,...H0(r)]),()=>t)}function z0(e){return e.some(t=>Le(t)||le(t)||Ge(t))}function W0(e,t){return s.IsEqual(z0(e),!0)?It(Yt,t):void 0}function V0(e,t){return e.reduce((r,n)=>K(n)&&(s.IsString(n.const)||s.IsNumber(n.const))?{...r,[n.const]:t}:r,{})}function J0(e,t){let r=V0(e,t);return A(r)}function Rg(e,t){let r=Yr(e),n=W0(r,t);return de(n)?n:J0(r,t)}function Xr(e,t){return ye(e)?sg(t):ft(e)?ag(t):Se(e)?bg(e.enum,t):Ge(e)?$g(e,t):P(e)?Eg(e.allOf,t):K(e)?Sg(e.const,t):le(e)?kg(e,t):E(e)?Rg(e.anyOf,t):Le(e)?Tg(e,t):se(e)?Cg(e.pattern,t):A({})}function Fu(e,t,r){return _([e])?l.Update(Xr(e,t),{},r):aa(e,t,r)}function wg(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Fu(i,a,o)}var Qr=`^${Qs}$`,oo=`^${ta}$`,Yt=`^${ra}$`;function aa(e,t,r={}){return T("Record",[e,t],r)}function io(e,t,r={}){return Fu(e,t,r)}function Pg(e,t){return It(e,t)}function ma(e){return s.IsEqual(e,Yt)?Ze():s.IsEqual(e,Qr)?Sn():s.IsEqual(e,oo)?Tt():Ou(e)}function Fe(e){return s.Keys(e.patternProperties)[0]}function so(e){let t=Fe(e);return ma(t)}function me(e){return e.patternProperties[Fe(e)]}function te(e){return k(e,"Record")}function Cn(e){return l.Create({"~kind":"Rest"},{type:"rest",items:e},{})}function Zr(e){return k(e,"Rest")}function ua(e){return l.Create({"~kind":"This"},{$ref:"#"},e)}function ca(e){return k(e,"This")}function ao(e){return l.Create({"~kind":"Undefined"},{type:"undefined"},e)}function Bt(e){return k(e,"Undefined")}function pa(e){return l.Create({"~kind":"Void"},{type:"void"},e)}function Ct(e){return k(e,"Void")}function Q0(e,t){return s.IsEqual(e,"Array")?xt(t[0]):s.IsEqual(e,"Capitalize")?da(t[0]):s.IsEqual(e,"ConstructorParameters")?Ia(t[0]):s.IsEqual(e,"Evaluate")?My(t[0]):s.IsEqual(e,"Exclude")?ha(t[0],t[1]):s.IsEqual(e,"Extract")?ba(t[0],t[1]):s.IsEqual(e,"Index")?pi(t[0],t[1]):s.IsEqual(e,"InstanceType")?$a(t[0]):s.IsEqual(e,"Lowercase")?la(t[0]):s.IsEqual(e,"NonNullable")?Ea(t[0]):s.IsEqual(e,"Omit")?Sa(t[0],t[1]):s.IsEqual(e,"Parameters")?ka(t[0]):s.IsEqual(e,"Partial")?Ta(t[0]):s.IsEqual(e,"Pick")?Ca(t[0],t[1]):s.IsEqual(e,"Readonly")?Ra(t[0]):s.IsEqual(e,"KeyOf")?fi(t[0]):s.IsEqual(e,"Record")?aa(t[0],t[1]):s.IsEqual(e,"Required")?wa(t[0]):s.IsEqual(e,"ReturnType")?Pa(t[0]):s.IsEqual(e,"Uncapitalize")?ga(t[0]):s.IsEqual(e,"Uppercase")?xa(t[0]):ci(qe(e),t)}function Rn(){throw Error("Unreachable")}function Fg(e,t=[]){return s.ShiftLeft(e,(r,n)=>Fg(n,[...t,r[1]]),()=>t)}function Ar(e){return s.IsEqual(e.length,3)?[e[0],...Fg(e[1])]:[]}function Ng(e){return kn(e[0],e[2],e[4])}function Dg(e){return kn(e[0],e[2],e[2])}function Lg(e){return kn(e[0],De(),e[2])}function jg(e){return kn(e,De(),De())}function _g(e){return Ar(e)}function qg(e){return e[1]}function Ug(e){return Ar(e)}function Gg(e){return e[1]}function Bg(e){return Q0(e[0],e[1])}function Kg(e){return null}function Hg(e){return Ze()}function zg(e){return Tt()}function Wg(e){return Xs()}function Vg(e){return ao()}function Jg(e){return Zn()}function Xg(e){return Sn()}function Qg(e){return ti()}function Yg(e){return De()}function Zg(e){return Qn()}function ex(e){return A({})}function tx(e){return re()}function rx(e){return eo()}function nx(e){return pa()}function ox(e){return ua()}function ix(e){return U(BigInt(e))}function sx(e){return U(s.IsEqual(e,"true"))}function ax(e){return U(parseFloat(e))}function mx(e){return U(e)}function ux(e){return e[1]}function cx(e){return U(e)}function px(e){return s.IsEqual(e.length,3)?[e[0],e[1],...e[2]]:[e[0]]}function fx(e){return e[1]}function dx(e){return fa(e)}function lx(e){return s.IsEqual(e.length,6)?$n(e[1],e[3],e[5]):$n(e[1],e[3],De())}function gx(e){return e.length>0}function xx(e){return e.reduce((t,r)=>s.IsEqual(r.length,3)?[...t,[r[1]]]:[...t,[]],[])}function yx(e){return s.IsEqual(e.length,6)?[e[1],e[3],e[5]]:[]}function Ix(e){return s.IsArray(e)&&s.IsEqual(e.length,3)?e[1]:e}function hx(e){return s.IsEqual(e.length,2)?e[1]:[]}function Ag(e,t){return t.reduce((r,n)=>{let o=n;return s.IsEqual(o.length,1)?pi(r,o[0]):s.IsEqual(o.length,0)?xt(r):Rn()},e)}function Og(e,t){return s.IsEqual(t.length,3)?ya(e,t[0],t[1],t[2]):e}function Y0(e,t){return s.IsArray(t)&&s.IsEqual(t.length,0)?e:Aa(e,t)}function bx(e){let[t,r,n,o,i]=e;return Y0(Og(t?fi(Ag(r,n)):Ag(r,n),o),i)}function Nu(e,t){return s.IsEqual(t.length,3)?(()=>{let[r,n,o]=t,i=Nu(n,o);if(s.IsEqual(r,"&"))return P(i)?nt([e,...i.allOf]):nt([e,i]);if(s.IsEqual(r,"|"))return E(i)?F([e,...i.anyOf]):F([e,i]);Rn()})():e}function $x(e){let[t,r]=e;return Nu(t,r)}function Ex(e){let[t,r]=e;return Nu(t,r)}function Sx(e){return Ay(e[1])}function kx(e){return e[1]}function Tx(e){return Vr(e[0],e[2])}function Cx(e){return s.IsEqual(e.length,4)?Qo(e[1],e[3]):s.IsEqual(e.length,2)?Qo(e[1],De()):Rn()}function Rx(e){return`${e}`}function wx(e){return Ge(e[3])?Qr:le(e[3])?oo:gr(e[3])?Yt:Le(e[3])?Yt:Rn()}function Px(e){return e.length>0}function Ax(e){return e.length>0}function Ox(e){let[t,r,n,o,i]=e;return{[r]:t&&n?dr(pr(i)):t&&!n?dr(i):!t&&n?pr(i):i}}function Mx(e){return Ar(e)}function vx(e){return e.reduce((t,r)=>s.HasPropertyKey(r,Qr)||s.HasPropertyKey(r,oo)||s.HasPropertyKey(r,Yt)?[t[0],l.Assign(t[1],r)]:[l.Assign(t[0],r),t[1]],[{},{}])}function Fx(e){return vx(e[1])}function Nx(e){let[t,r]=e,n=s.IsEqual(s.Keys(r).length,0)?{}:{patternProperties:r};return A(t,n)}function Dx(e){return s.IsEqual(e.length,5)?dr(pr(e[4])):s.IsEqual(e.length,3)?e[2]:s.IsEqual(e.length,4)?s.IsEqual(e[2],"readonly")?dr(e[3]):pr(e[3]):Rn()}function Lx(e){if(!s.IsArray(e)||!s.IsEqual(e.length,3))return e;let[t,r,n]=e;return t&&n?dr(pr(r)):t&&!n?dr(r):!t&&n?pr(r):r}function jx(e){return s.IsEqual(e.length,2)?Cn(e[1]):s.IsEqual(e.length,1)?e[0]:Rn()}function _x(e){return Ar(e)}function qx(e){return ke(e[1])}function Ux(e){return dr(pr(e[4]))}function Gx(e){return dr(e[3])}function Bx(e){return pr(e[3])}function Kx(e){return e[2]}function Hx(e){return s.IsEqual(e.length,2)?Cn(e[1]):s.IsEqual(e.length,1)?e[0]:Rn()}function zx(e){return Ar(e)}function Wx(e){return cr(e[1],e[4])}function Vx(e){return ur(e[2],e[5])}function Mg(e,t){return s.IsEqual(e,"remove")?Oy(t):s.IsEqual(e,"add")?dr(t):t}function Jx(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 vg(e,t){return s.IsEqual(e,"remove")?Py(t):s.IsEqual(e,"add")?pr(t):t}function Xx(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 Qx(e){return s.IsEqual(e.length,2)?[e[1]]:[]}function Yx(e){return s.IsArray(e[6])&&s.IsEqual(e[6].length,1)?mi(ri(e[3]),e[5],e[6][0],Mg(e[1],vg(e[8],e[10]))):mi(ri(e[3]),e[5],qe(e[3]),Mg(e[1],vg(e[8],e[10])))}function Zx(e){return qe(e)}function ey(e){return BigInt(e)}function ty(e){return parseFloat(e)}function ry(e){return s.IsEqual(e,"true")}function ny(e){return null}function oy(e){return{[e[0]]:e[2]}}function iy(e){return Ar(e)}function Z0(e){return e.reduce((t,r)=>l.Assign(t,r),{})}function sy(e){return Z0(e[1])}function ay(e){return Ar(e)}function my(e){return e[1]}function uy(e){return ti()}function cy(e){return Ze()}function py(e){return Tt()}function fy(e){return Sn()}function dy(e){return re()}function ly(e){return U(e)}function gy(e){return F(e[1])}function xy(e){return e.length===3?[...e[0],...e[2]]:e.length===1?[...e[0]]:[]}function yy(e){return[e[0],...e[1]]}function Iy(e){return e[1]}function hy(e){return Ar(e)}function by(e){return s.IsEqual(e.length,2)?e[1]:[]}function $y(e){let t=e[2],r=e[3],[n,o]=e[4],i=s.IsEqual(s.Keys(o).length,0)?{}:{patternProperties:o};return{[e[1]]:Vr(t,ui(r,n,i))}}function Ey(e){let t=e[2],[r,n]=e[3],o=s.IsEqual(s.Keys(n).length,0)?{}:{patternProperties:n};return{[e[1]]:ui(t,r,o)}}function Sy(e){return{[e[1]]:Vr(e[2],e[4])}}function ky(e){return{[e[1]]:e[3]}}function Ty(e){return null}function Cy(e){return Ar(e)}function Ry(e){return e[1]}function wy(e){let[t,r]=[e[0],e[1]];return vy(l.Assign(t,vx(r)[0]))}function di(e){return J(e.length,2)}function z(e,t,r){return di(e)?t(e[0],e[1]):r()}function rP(e,t){return J(t.indexOf(e),0)?[e,t.slice(e.length)]:[]}function Ie(e,t){for(let r=0;r<e.length;r++){let n=rP(e[r],t);if(di(n))return n}return[]}function Du(e,t){return Array.from({length:t-e+1},(r,n)=>String.fromCharCode(e+n))}var Fy=[...Du(97,122),...Du(65,90)],Lu="0",ju=Du(49,57),mo=[Lu,...ju],Ny=" ",uo=`
|
|
2
|
+
`;var en="_",Oa=".",Dy="$",Ma="-";var Ly="//",jy="/*",oP="*/";function _y(e){let t=e.indexOf(oP);return J(t,-1)?"":e.slice(t+2)}function qy(e){let t=e.indexOf(uo);return J(t,-1)?"":e.slice(t)}function iP(e){return e.replace(/^[ \t\r\f\v]+/,"")}function va(e){let t=iP(e);return t.startsWith(jy)?va(_y(t.slice(2))):t.startsWith(Ly)?va(qy(t.slice(2))):t}function Ve(e){let t=e.trimStart();return t.startsWith(jy)?Ve(_y(t.slice(2))):t.startsWith(Ly)?Ve(qy(t.slice(2))):t}function Fa(e,t){return z(Ie([e],t),(r,n)=>[r,n],()=>["",t])}function sP(e,t){return e.includes(t)}function co(e,t,r,n=""){return z(Ie(e,r),(o,i)=>sP(t,o)?co(e,t,i,n):co(e,t,i,`${n}${o}`),()=>[n,r])}function aP(e){return Ie(ju,e)}var mP=[...mo,en];function uP(e){return co(mP,[en],e)}function cP(e){return z(Ie([Lu],e),(t,r)=>[t,r],()=>z(aP(e),(t,r)=>z(uP(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[]))}function Na(e){return cP(Ve(e))}function pP(e){return Fa(Ma,e)}function fP(e){return z(pP(e),(t,r)=>z(Na(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Uy(e){return fP(Ve(e))}function dP(e){return z(Uy(e),(t,r)=>z(Ie(["n"],r),(n,o)=>[`${t}`,o],()=>[]),()=>[])}function _u(e){return dP(e)}function qu(e,t){return Ie([e],t)}function x(e,t){return J(e,"")?["",t]:e.startsWith(uo)?qu(e,va(t)):e.startsWith(Ny)?qu(e,t):qu(e,Ve(t))}var Gy=[...Fy,en,Dy];function lP(e){return Ie(Gy,e)}var gP=[...Gy,...mo];function By(e,t=""){return z(Ie(gP,e),(r,n)=>By(n,`${t}${r}`),()=>[t,e])}function xP(e){return z(lP(e),(t,r)=>z(By(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Ce(e){return xP(Ve(e))}var yP=[...mo,en];function IP(e){return di(Ie([Oa],e))}function Ky(e){return z(co(yP,[en],e),(t,r)=>J(t,"")?[]:[t,r],()=>[])}function hP(e){return z(Ie([Oa],e),(t,r)=>z(Ky(r),(n,o)=>[`0${t}${n}`,o],()=>[]),()=>[])}function bP(e){return z(Na(e),(t,r)=>z(Ie([Oa],r),(n,o)=>z(Ky(o),(i,a)=>[`${t}${n}${i}`,a],()=>[`${t}`,o]),()=>[`${t}`,r]),()=>[])}function $P(e){return IP(e)?hP(e):bP(e)}function Hy(e){return $P(Ve(e))}function EP(e){return Fa(Ma,e)}function SP(e){return z(EP(e),(t,r)=>z(Hy(r),(n,o)=>[`${t}${n}`,o],()=>[]),()=>[])}function Da(e){return SP(Ve(e))}function kP(e){return J(e,"")?[]:[e.slice(0,1),e.slice(1)]}function zy(e,t){return Hi(e,(r,n)=>t.startsWith(r)?!0:zy(n,t),()=>!1)}function tn(e,t,r=""){return z(kP(t),(n,o)=>zy(e,t)?[r,t]:tn(e,o,`${r}${n}`),()=>[])}function TP(e,t,r){return z(Ie([e],r),(n,o)=>z(tn([t],o),(i,a)=>z(Ie([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function CP(e,t,r){return z(Ie([e],r),(n,o)=>z(tn([uo,t],o),(i,a)=>z(Ie([t],a),(m,c)=>[`${i}`,c],()=>[]),()=>[]),()=>[])}function Wy(e,t,r,n){return r?TP(e,t,Ve(n)):CP(e,t,Ve(n))}function RP(e,t){return Ie(e,t)}function wP(e,t){return Wy(e,e,!1,t)}function PP(e,t){return z(RP(e,t),(r,n)=>wP(r,`${r}${n}`),()=>[])}function La(e,t){return PP(e,Ve(t))}function Vy(e,t){return z(tn(e,t),(r,n)=>J(r,"")?[]:[r,n],()=>[])}var u=(e,t,r=()=>[])=>e.length===2?t(e):r(),OP=e=>u(u(Ce(e),([t,r])=>u(x("extends",r),([n,o])=>u(Q(o),([i,a])=>u(x("=",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Ng(t),r]),MP=e=>u(u(Ce(e),([t,r])=>u(x("extends",r),([n,o])=>u(Q(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Dg(t),r]),vP=e=>u(u(Ce(e),([t,r])=>u(x("=",r),([n,o])=>u(Q(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Lg(t),r]),FP=e=>u(Ce(e),([t,r])=>[jg(t),r]),Qy=e=>u(u(OP(e),([t,r])=>[t,r],()=>u(MP(e),([t,r])=>[t,r],()=>u(vP(e),([t,r])=>[t,r],()=>u(FP(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),Yy=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Qy(n),([o,i])=>[[r,o],i])),([r,n])=>Yy(n,[...t,r]),()=>[t,e]),NP=e=>u(u(u(Qy(e),([t,r])=>u(Yy(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[_g(t),r]),Bu=e=>u(u(x("<",e),([t,r])=>u(NP(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[qg(t),r]),Zy=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Q(n),([o,i])=>[[r,o],i])),([r,n])=>Zy(n,[...t,r]),()=>[t,e]),DP=e=>u(u(u(Q(e),([t,r])=>u(Zy(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ug(t),r]),LP=e=>u(u(x("<",e),([t,r])=>u(DP(r),([n,o])=>u(x(">",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Gg(t),r]),jP=e=>u(u(Ce(e),([t,r])=>u(LP(r),([n,o])=>[[t,n],o])),([t,r])=>[Bg(t),r]),eI=e=>u(u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Kg(t),r]),tI=e=>u(x("string",e),([t,r])=>[Hg(t),r]),rI=e=>u(x("number",e),([t,r])=>[zg(t),r]),_P=e=>u(x("boolean",e),([t,r])=>[Wg(t),r]),qP=e=>u(x("undefined",e),([t,r])=>[Vg(t),r]),UP=e=>u(x("null",e),([t,r])=>[Jg(t),r]),nI=e=>u(x("integer",e),([t,r])=>[Xg(t),r]),GP=e=>u(x("bigint",e),([t,r])=>[Qg(t),r]),BP=e=>u(x("unknown",e),([t,r])=>[Yg(t),r]),KP=e=>u(x("any",e),([t,r])=>[Zg(t),r]),HP=e=>u(x("object",e),([t,r])=>[ex(t),r]),zP=e=>u(x("never",e),([t,r])=>[tx(t),r]),oI=e=>u(x("symbol",e),([t,r])=>[rx(t),r]),WP=e=>u(x("void",e),([t,r])=>[nx(t),r]),VP=e=>u(x("this",e),([t,r])=>[ox(t),r]),JP=e=>u(u(x("${",e),([t,r])=>u(Q(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[ux(t),r]),Uu=e=>u(tn(["${","`"],e),([t,r])=>[cx(t),r]),iI=e=>u(u(u(Uu(e),([t,r])=>u(JP(r),([n,o])=>u(iI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(Uu(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(Uu(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[px(t),r]),Ku=e=>u(u(x("`",e),([t,r])=>u(iI(r),([n,o])=>u(x("`",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[fx(t),r]),XP=e=>u(Ku(e),([t,r])=>[dx(t),r]),QP=e=>u(u(u(x("if",e),([t,r])=>u(Q(r),([n,o])=>u(x("then",o),([i,a])=>u(Q(a),([m,c])=>u(x("else",c),([p,f])=>u(Q(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u(u(x("if",e),([t,r])=>u(Q(r),([n,o])=>u(x("then",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>[])),([t,r])=>[lx(t),r]),YP=e=>u(_u(e),([t,r])=>[ix(t),r]),ZP=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[sx(t),r]),eA=e=>u(Da(e),([t,r])=>[ax(t),r]),tA=e=>u(La(["'",'"'],e),([t,r])=>[mx(t),r]),rA=e=>u(u(u(x("keyof",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[gx(t),r]),sI=(e,t=[])=>u(u(u(x("[",e),([r,n])=>u(Q(n),([o,i])=>u(x("]",i),([a,m])=>[[r,o,a],m]))),([r,n])=>[r,n],()=>u(u(x("[",e),([r,n])=>u(x("]",n),([o,i])=>[[r,o],i])),([r,n])=>[r,n],()=>[])),([r,n])=>sI(n,[...t,r]),()=>[t,e]),nA=e=>u(sI(e),([t,r])=>[xx(t),r]),oA=e=>u(u(u(x("extends",e),([t,r])=>u(Q(r),([n,o])=>u(x("?",o),([i,a])=>u(Q(a),([m,c])=>u(x(":",c),([p,f])=>u(Q(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[yx(t),r]),iA=e=>u(u(u(x("(",e),([t,r])=>u(Q(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(tI(e),([t,r])=>[t,r],()=>u(rI(e),([t,r])=>[t,r],()=>u(_P(e),([t,r])=>[t,r],()=>u(qP(e),([t,r])=>[t,r],()=>u(UP(e),([t,r])=>[t,r],()=>u(nI(e),([t,r])=>[t,r],()=>u(GP(e),([t,r])=>[t,r],()=>u(BP(e),([t,r])=>[t,r],()=>u(KP(e),([t,r])=>[t,r],()=>u(HP(e),([t,r])=>[t,r],()=>u(zP(e),([t,r])=>[t,r],()=>u(oI(e),([t,r])=>[t,r],()=>u(WP(e),([t,r])=>[t,r],()=>u(VP(e),([t,r])=>[t,r],()=>u(YP(e),([t,r])=>[t,r],()=>u(ZP(e),([t,r])=>[t,r],()=>u(eA(e),([t,r])=>[t,r],()=>u(tA(e),([t,r])=>[t,r],()=>u(XP(e),([t,r])=>[t,r],()=>u(QP(e),([t,r])=>[t,r],()=>u(xA(e),([t,r])=>[t,r],()=>u(hA(e),([t,r])=>[t,r],()=>u(TA(e),([t,r])=>[t,r],()=>u(kA(e),([t,r])=>[t,r],()=>u(PA(e),([t,r])=>[t,r],()=>u(jP(e),([t,r])=>[t,r],()=>u(AA(e),([t,r])=>[t,r],()=>[])))))))))))))))))))))))))))),([t,r])=>[Ix(t),r]),sA=e=>u(u(u(x("with",e),([t,r])=>u(SI(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[hx(t),r]),aI=e=>u(u(rA(e),([t,r])=>u(iA(r),([n,o])=>u(nA(o),([i,a])=>u(oA(a),([m,c])=>u(sA(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[bx(t),r]),mI=e=>u(u(u(x("&",e),([t,r])=>u(aI(r),([n,o])=>u(mI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),uI=e=>u(u(aI(e),([t,r])=>u(mI(r),([n,o])=>[[t,n],o])),([t,r])=>[$x(t),r]),cI=e=>u(u(u(x("|",e),([t,r])=>u(uI(r),([n,o])=>u(cI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),ja=e=>u(u(uI(e),([t,r])=>u(cI(r),([n,o])=>[[t,n],o])),([t,r])=>[Ex(t),r]),aA=e=>u(u(x("readonly",e),([t,r])=>u(ja(r),([n,o])=>[[t,n],o])),([t,r])=>[Sx(t),r]),mA=e=>u(u(x("|",e),([t,r])=>u(ja(r),([n,o])=>[[t,n],o])),([t,r])=>[kx(t),r]),uA=e=>u(u(Bu(e),([t,r])=>u(x("=",r),([n,o])=>u(Q(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Tx(t),r]),cA=e=>u(u(u(x("infer",e),([t,r])=>u(Ce(r),([n,o])=>u(x("extends",o),([i,a])=>u(ja(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(x("infer",e),([t,r])=>u(Ce(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>[])),([t,r])=>[Cx(t),r]),Q=e=>u(u(cA(e),([t,r])=>[t,r],()=>u(mA(e),([t,r])=>[t,r],()=>u(aA(e),([t,r])=>[t,r],()=>u(ja(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),pA=e=>u(Da(e),([t,r])=>[Rx(t),r]),fA=e=>u(Ce(e),([t,r])=>[t,r]),dA=e=>u(La(["'",'"'],e),([t,r])=>[t,r]),lA=e=>u(u(x("[",e),([t,r])=>u(Ce(r),([n,o])=>u(x(":",o),([i,a])=>u(u(nI(a),([m,c])=>[m,c],()=>u(rI(a),([m,c])=>[m,c],()=>u(tI(a),([m,c])=>[m,c],()=>u(oI(a),([m,c])=>[m,c],()=>[])))),([m,c])=>u(x("]",c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[wx(t),r]),pI=e=>u(u(pA(e),([t,r])=>[t,r],()=>u(fA(e),([t,r])=>[t,r],()=>u(dA(e),([t,r])=>[t,r],()=>u(lA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),fI=e=>u(u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Px(t),r]),dI=e=>u(u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ax(t),r]),lI=e=>u(u(fI(e),([t,r])=>u(pI(r),([n,o])=>u(dI(o),([i,a])=>u(x(":",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Ox(t),r]),_a=e=>u(u(u(x(",",e),([t,r])=>u(x(`
|
|
3
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>u(x(`
|
|
4
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(",",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
5
|
+
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))))),([t,r])=>[t,r]),gI=(e,t=[])=>u(u(_a(e),([r,n])=>u(lI(n),([o,i])=>[[r,o],i])),([r,n])=>gI(n,[...t,r]),()=>[t,e]),gA=e=>u(u(u(lI(e),([t,r])=>u(gI(r),([n,o])=>u(u(_a(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Mx(t),r]),Hu=e=>u(u(x("{",e),([t,r])=>u(gA(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Fx(t),r]),xA=e=>u(Hu(e),([t,r])=>[Nx(t),r]),yA=e=>u(u(u(Ce(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[t,r],()=>u(u(Ce(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Ce(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[t,r],()=>u(u(Ce(e),([t,r])=>u(x(":",r),([n,o])=>u(Q(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])))),([t,r])=>[Dx(t),r]),Jy=e=>u(u(yA(e),([t,r])=>[t,r],()=>u(u(fI(e),([t,r])=>u(Q(r),([n,o])=>u(dI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>[])),([t,r])=>[Lx(t),r]),xI=e=>u(u(u(x("...",e),([t,r])=>u(Jy(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(Jy(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[jx(t),r]),yI=(e,t=[])=>u(u(x(",",e),([r,n])=>u(xI(n),([o,i])=>[[r,o],i])),([r,n])=>yI(n,[...t,r]),()=>[t,e]),IA=e=>u(u(u(xI(e),([t,r])=>u(yI(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[_x(t),r]),hA=e=>u(u(x("[",e),([t,r])=>u(IA(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[qx(t),r]),bA=e=>u(u(Ce(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(x("readonly",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Ux(t),r]),$A=e=>u(u(Ce(e),([t,r])=>u(x(":",r),([n,o])=>u(x("readonly",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Gx(t),r]),EA=e=>u(u(Ce(e),([t,r])=>u(x("?",r),([n,o])=>u(x(":",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Bx(t),r]),SA=e=>u(u(Ce(e),([t,r])=>u(x(":",r),([n,o])=>u(Q(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Kx(t),r]),Xy=e=>u(u(bA(e),([t,r])=>[t,r],()=>u($A(e),([t,r])=>[t,r],()=>u(EA(e),([t,r])=>[t,r],()=>u(SA(e),([t,r])=>[t,r],()=>[])))),([t,r])=>[t,r]),II=e=>u(u(u(x("...",e),([t,r])=>u(Xy(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(Xy(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[])),([t,r])=>[Hx(t),r]),hI=(e,t=[])=>u(u(x(",",e),([r,n])=>u(II(n),([o,i])=>[[r,o],i])),([r,n])=>hI(n,[...t,r]),()=>[t,e]),bI=e=>u(u(u(II(e),([t,r])=>u(hI(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[zx(t),r]),kA=e=>u(u(x("(",e),([t,r])=>u(bI(r),([n,o])=>u(x(")",o),([i,a])=>u(x("=>",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Wx(t),r]),TA=e=>u(u(x("new",e),([t,r])=>u(x("(",r),([n,o])=>u(bI(o),([i,a])=>u(x(")",a),([m,c])=>u(x("=>",c),([p,f])=>u(Q(f),([d,g])=>[[t,n,i,m,p,d],g])))))),([t,r])=>[Vx(t),r]),CA=e=>u(u(u(x("+",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("readonly",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("readonly",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[Jx(t),r]),RA=e=>u(u(u(x("+",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("-",e),([t,r])=>u(x("?",r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x("?",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])))),([t,r])=>[Xx(t),r]),wA=e=>u(u(u(x("as",e),([t,r])=>u(Q(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Qx(t),r]),PA=e=>u(u(x("{",e),([t,r])=>u(CA(r),([n,o])=>u(x("[",o),([i,a])=>u(Ce(a),([m,c])=>u(x("in",c),([p,f])=>u(Q(f),([d,g])=>u(wA(g),([y,h])=>u(x("]",h),([I,b])=>u(RA(b),([C,N])=>u(x(":",N),([G,mt])=>u(Q(mt),([Qe,xe])=>u(eI(xe),([V,_r])=>u(x("}",_r),([tt,Sr])=>[[t,n,i,m,p,d,y,I,C,G,Qe,V,tt],Sr]))))))))))))),([t,r])=>[Yx(t),r]),AA=e=>u(Ce(e),([t,r])=>[Zx(t),r]),OA=e=>u(_u(e),([t,r])=>[ey(t),r]),MA=e=>u(Da(e),([t,r])=>[ty(t),r]),vA=e=>u(u(x("true",e),([t,r])=>[t,r],()=>u(x("false",e),([t,r])=>[t,r],()=>[])),([t,r])=>[ry(t),r]),FA=e=>u(La(['"',"'"],e),([t,r])=>[t,r]),NA=e=>u(x("null",e),([t,r])=>[ny(t),r]),DA=e=>u(x("undefined",e),([t,r])=>[void 0,r]),$I=e=>u(u(pI(e),([t,r])=>u(x(":",r),([n,o])=>u(zu(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[oy(t),r]),EI=(e,t=[])=>u(u(_a(e),([r,n])=>u($I(n),([o,i])=>[[r,o],i])),([r,n])=>EI(n,[...t,r]),()=>[t,e]),LA=e=>u(u(u($I(e),([t,r])=>u(EI(r),([n,o])=>u(u(_a(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[iy(t),r]),SI=e=>u(u(x("{",e),([t,r])=>u(LA(r),([n,o])=>u(x("}",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[sy(t),r]),kI=(e,t=[])=>u(u(x(",",e),([r,n])=>u(zu(n),([o,i])=>[[r,o],i])),([r,n])=>kI(n,[...t,r]),()=>[t,e]),jA=e=>u(u(u(zu(e),([t,r])=>u(kI(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[ay(t),r]),_A=e=>u(u(x("[",e),([t,r])=>u(jA(r),([n,o])=>u(x("]",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[my(t),r]),zu=e=>u(u(OA(e),([t,r])=>[t,r],()=>u(MA(e),([t,r])=>[t,r],()=>u(vA(e),([t,r])=>[t,r],()=>u(FA(e),([t,r])=>[t,r],()=>u(NA(e),([t,r])=>[t,r],()=>u(DA(e),([t,r])=>[t,r],()=>u(SI(e),([t,r])=>[t,r],()=>u(_A(e),([t,r])=>[t,r],()=>[])))))))),([t,r])=>[t,r]),qA=e=>u(x("-?(?:0|[1-9][0-9]*)n",e),([t,r])=>[uy(t),r]),UA=e=>u(x(".*",e),([t,r])=>[cy(t),r]),GA=e=>u(x("-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?",e),([t,r])=>[py(t),r]),BA=e=>u(x("-?(?:0|[1-9][0-9]*)",e),([t,r])=>[fy(t),r]),KA=e=>u(x("(?!)",e),([t,r])=>[dy(t),r]),HA=e=>u(Vy(["-?(?:0|[1-9][0-9]*)n",".*","-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?","-?(?:0|[1-9][0-9]*)","(?!)","(",")","$","|"],e),([t,r])=>[ly(t),r]),zA=e=>u(u(qA(e),([t,r])=>[t,r],()=>u(UA(e),([t,r])=>[t,r],()=>u(GA(e),([t,r])=>[t,r],()=>u(BA(e),([t,r])=>[t,r],()=>u(KA(e),([t,r])=>[t,r],()=>u(WA(e),([t,r])=>[t,r],()=>u(HA(e),([t,r])=>[t,r],()=>[]))))))),([t,r])=>[t,r]),WA=e=>u(u(x("(",e),([t,r])=>u(Wu(r),([n,o])=>u(x(")",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[gy(t),r]),TI=e=>u(u(u(Gu(e),([t,r])=>u(x("|",r),([n,o])=>u(TI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u(u(Gu(e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[]))),([t,r])=>[xy(t),r]),Gu=e=>u(u(zA(e),([t,r])=>u(Wu(r),([n,o])=>[[t,n],o])),([t,r])=>[yy(t),r]),Wu=e=>u(u(TI(e),([t,r])=>[t,r],()=>u(Gu(e),([t,r])=>[t,r],()=>[])),([t,r])=>[t,r]),Zl=e=>u(u(x("^",e),([t,r])=>u(Wu(r),([n,o])=>u(x("$",o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Iy(t),r]),CI=(e,t=[])=>u(u(x(",",e),([r,n])=>u(Q(n),([o,i])=>[[r,o],i])),([r,n])=>CI(n,[...t,r]),()=>[t,e]),VA=e=>u(u(u(Q(e),([t,r])=>u(CI(r),([n,o])=>u(u(x(",",o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[hy(t),r]),RI=e=>u(u(u(x("extends",e),([t,r])=>u(VA(r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[by(t),r]),JA=e=>u(u(x("interface",e),([t,r])=>u(Ce(r),([n,o])=>u(Bu(o),([i,a])=>u(RI(a),([m,c])=>u(Hu(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[$y(t),r]),XA=e=>u(u(x("interface",e),([t,r])=>u(Ce(r),([n,o])=>u(RI(o),([i,a])=>u(Hu(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[Ey(t),r]),QA=e=>u(u(x("type",e),([t,r])=>u(Ce(r),([n,o])=>u(Bu(o),([i,a])=>u(x("=",a),([m,c])=>u(Q(c),([p,f])=>[[t,n,i,m,p],f]))))),([t,r])=>[Sy(t),r]),YA=e=>u(u(x("type",e),([t,r])=>u(Ce(r),([n,o])=>u(x("=",o),([i,a])=>u(Q(a),([m,c])=>[[t,n,i,m],c])))),([t,r])=>[ky(t),r]),ZA=e=>u(u(u(x("export",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Ty(t),r]),wI=e=>u(u(u(x(";",e),([t,r])=>u(x(`
|
|
6
|
+
`,r),([n,o])=>[[t,n],o])),([t,r])=>[t,r],()=>u(u(x(";",e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>u(u(x(`
|
|
7
|
+
`,e),([t,r])=>[[t],r]),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]),PI=(e,t=[])=>u(u(wI(e),([r,n])=>u(Vu(n),([o,i])=>[[r,o],i])),([r,n])=>PI(n,[...t,r]),()=>[t,e]),eO=e=>u(u(u(Vu(e),([t,r])=>u(PI(r),([n,o])=>u(u(wI(o),([i,a])=>[[i],a],()=>[[],o]),([i,a])=>[[t,n,i],a]))),([t,r])=>[t,r],()=>u([[],e],([t,r])=>[t,r],()=>[])),([t,r])=>[Cy(t),r]),Vu=e=>u(u(ZA(e),([t,r])=>u(u(JA(r),([n,o])=>[n,o],()=>u(XA(r),([n,o])=>[n,o],()=>u(QA(r),([n,o])=>[n,o],()=>u(YA(r),([n,o])=>[n,o],()=>[])))),([n,o])=>u(eI(o),([i,a])=>[[t,n,i],a]))),([t,r])=>[Ry(t),r]),tO=e=>u(u(Vu(e),([t,r])=>u(eO(r),([n,o])=>[[t,n],o])),([t,r])=>[wy(t),r]),AI=e=>u(u(tO(e),([t,r])=>[t,r],()=>u(uA(e),([t,r])=>[t,r],()=>u(Q(e),([t,r])=>[t,r],()=>[]))),([t,r])=>[t,r]);function OI(e){let t=Ku(`\`${e}\``);return s.IsEqual(t.length,2)?t[0]:he()}function nO(e){return e.join("|")}function oO(e){return e.slice(1,e.length-1)}function iO(e,t,r){return rn(t,`${r}${e}`)}function sO(e,t){return rn(e,`${t}${Wl}`)}function aO(e,t){return rn(e,`${t}${Qs}`)}function mO(e,t){return rn(e,`${t}${ta}`)}function uO(e,t){return li(F([U("false"),U("true")]),e,t)}function cO(e,t){return rn(e,`${t}${ra}`)}function pO(e,t,r){return rn(t,`${r}${oO(e)}`)}function fO(e,t,r){let n=gi(e,{});return li(n,t,r)}function dO(e,t,r){let n=dt(e);return li(n,t,r)}function MI(e,t,r,n=[]){return s.ShiftLeft(e,(o,i)=>MI(i,t,r,[...n,li(o,[],"")]),()=>rn(t,`${r}(${nO(n)})`))}function li(e,t,r){return Se(e)?dO(e.enum,t,r):Ge(e)?aO(t,r):K(e)?iO(e.const,t,r):kt(e)?sO(t,r):ft(e)?uO(t,r):le(e)?mO(t,r):Le(e)?cO(t,r):se(e)?pO(e.pattern,t,r):FI(e)?fO(e.parameters[0],t,r):E(e)?MI(e.anyOf,t,r):Ol}function rn(e,t){return s.ShiftLeft(e,(r,n)=>li(r,n,t),()=>t)}function lO(e){return`^${rn(e,"")}$`}function vI(e){let t=lO(e);return oa(t)}function gi(e,t){return _(e)?l.Update(vI(e),{},t):fa(e,t)}function NI(e,t,r,n){let o=Ft(e,t,r);return gi(o,n)}function fa(e,t={}){return T("TemplateLiteral",[e],t)}function FI(e){return de(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"TemplateLiteral")}function DI(e){return gi(e,{})}function gO(e){let t=OI(e);return DI(t)}function LI(e,t={}){let r=s.IsString(e)?gO(e):DI(e);return l.Update(r,{},t)}function se(e){return k(e,"TemplateLiteral")}var M={};At(M,{ExtendsFalse:()=>L,ExtendsTrue:()=>S,ExtendsUnion:()=>Ju,IsExtendsFalse:()=>xO,IsExtendsTrue:()=>_I,IsExtendsTrueLike:()=>xr,IsExtendsUnion:()=>jI,Match:()=>Re});function Ju(e){return l.Create({"~kind":"ExtendsUnion"},{inferred:e})}function jI(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsUnion")&&s.IsObject(e.inferred)}function S(e){return l.Create({"~kind":"ExtendsTrue"},{inferred:e})}function _I(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.HasPropertyKey(e,"inferred")&&s.IsEqual(e["~kind"],"ExtendsTrue")&&s.IsObject(e.inferred)}function L(){return l.Create({"~kind":"ExtendsFalse"},{})}function xO(e){return s.IsObject(e)&&s.HasPropertyKey(e,"~kind")&&s.IsEqual(e["~kind"],"ExtendsFalse")}function xr(e){return jI(e)||_I(e)}function Re(e,t,r){return xr(e)?t(e.inferred):r()}function yO(e,t,r,n){return Re(W(e,r,n),o=>S(l.Assign(l.Assign(e,o),{[t]:r})),()=>L())}function IO(e,t){return S(e)}function hO(e,t,r,n,o){return Re(W(e,t,r),i=>Re(W(i,t,n),a=>S(a),()=>L()),()=>Re(W(e,t,o),i=>S(i),()=>L()))}function bO(e,t,r){let n=dt(r);return W(e,t,n)}function qI(e,t,r){return s.ShiftLeft(r,(n,o)=>Re(W(e,t,n),i=>qI(i,t,o),()=>L()),()=>S(e))}function $O(e,t,r){let n=ot(r);return W(e,t,n)}function UI(e,t,r){return s.ShiftLeft(r,(n,o)=>Re(W(e,t,n),i=>S(i),()=>UI(e,t,o)),()=>L())}function ee(e,t,r){return ye(r)?IO(e,t):Ee(r)?hO(e,t,r.if,r.then,r.else):Se(r)?bO(e,t,r.enum):ve(r)?yO(e,r.name,t,r.extends):P(r)?qI(e,t,r.allOf):se(r)?$O(e,t,r.pattern):E(r)?UI(e,t,r.anyOf):Me(r)?S(e):L()}function GI(e,t,r){return ve(r)?ee(e,t,r):ye(r)?S(e):Me(r)?S(e):Ju(e)}function EO(e,t){let r=En(e),n=En(t);return r&&n||!r&&n?!0:!(r&&!n)}function BI(e,t,r,n){return H(n)?EO(t,n)?W(e,r,n.items):L():ee(e,t,n)}function KI(e,t,r){return kt(r)?S(e):ee(e,t,r)}function HI(e,t,r){return ft(r)?S(e):ee(e,t,r)}function SO(e,t,r,n,o){let i=ve(n)?t:n,a=ve(n)?n:t,m=Oe(t),c=Oe(n);return!m&&c?L():Re(W(e,i,a),p=>xi(p,r,o),()=>L())}function kO(e,t,r,n){return s.ShiftLeft(n,(o,i)=>SO(e,t,r,o,i),()=>Oe(t)?S(e):L())}function TO(e,t,r){return s.ShiftLeft(t,(n,o)=>kO(e,n,o,r),()=>S(e))}function xi(e,t,r){return TO(e,t,r)}function qa(e,t,r){return Ct(r)?S(e):W(e,t,r)}function zI(e,t,r,n){return ye(n)?S(e):Me(n)?S(e):be(n)?Re(xi(e,t,n.parameters),o=>qa(o,r,n.instanceType),()=>L()):L()}function WI(e,t,r,n,o){return Re(W(e,t,o),()=>W(e,r,o),()=>W(e,n,o))}function VI(e,t,r){let n=dt(t);return W(e,n,r)}function JI(e,t,r,n){return ye(n)?S(e):Me(n)?S(e):$e(n)?Re(xi(e,t,n.parameters),o=>qa(o,r,n.returnType),()=>L()):L()}function XI(e,t,r){return Ge(r)?S(e):le(r)?S(e):ee(e,t,r)}function QI(e,t,r){let n=Te(t);return W(e,n,r)}function Ua(e,t,r){return t===r?S(e):L()}function CO(e,t,r){return K(r)?Ua(e,t,r.const):kt(r)?S(e):ee(e,U(t),r)}function RO(e,t,r){return K(r)?Ua(e,t,r.const):ft(r)?S(e):ee(e,U(t),r)}function wO(e,t,r){return K(r)?Ua(e,t,r.const):le(r)?S(e):ee(e,U(t),r)}function PO(e,t,r){return K(r)?Ua(e,t,r.const):Le(r)?S(e):ee(e,U(t),r)}function YI(e,t,r){return s.IsBigInt(t.const)?CO(e,t.const,r):s.IsBoolean(t.const)?RO(e,t.const,r):s.IsNumber(t.const)?wO(e,t.const,r):s.IsString(t.const)?PO(e,t.const,r):he()}function ZI(e,t,r){return ve(r)?ee(e,t,r):S(e)}function eh(e,t,r){return lr(r)?S(e):ee(e,t,r)}function th(e,t,r){return le(r)?S(e):ee(e,t,r)}function AO(e,t,r){return Oe(t)?Oe(r)?S(e):L():S(e)}function OO(e,t,r){return ve(r)&&yt(r.extends)?L():Re(W(e,t,r),n=>AO(n,t,r),()=>L())}function MO(e,t){return e.reduce((r,n)=>n in t?xr(t[n])?{...r,...t[n].inferred}:he():he(),{})}function vO(e,t,r){let n={};for(let a of s.Keys(r))n[a]=a in t?OO({},t[a],r[a]):Oe(r[a])?ve(r[a])?S(l.Assign(e,{[r[a].name]:r[a].extends})):S(e):L();let o=s.Values(n).every(a=>xr(a)),i=o?MO(s.Keys(n),n):{};return o?S(i):L()}function FO(e,t,r){let n=vO(e,t,r);return xr(n)?S(l.Assign(e,n.inferred)):L()}function NO(e,t,r){return FO(e,t,r)}function DO(e,t){return s.Keys(t).reduce((r,n)=>({...r,[n]:s.HasPropertyKey(e,n)?E(r[n])?F([...r[n].anyOf,t[n]]):F([e[n],t[n]]):t[n]}),e)}function rh(e,t,r,n){return s.ShiftLeft(t,(o,i)=>Re(W({},e[o],r),a=>rh(e,i,r,DO(n,a)),()=>L()),()=>S(n))}function LO(e,t,r,n){let o=s.Keys(t);return rh(t,o,n,e)}function nh(e,t,r){return te(r)?LO(e,t,Fe(r),me(r)):w(r)?NO(e,t,r.properties):ee(e,A(t),r)}function jO(e,t){return s.IsEqual(s.Keys(t).length,0)?S(e):L()}function _O(e,t,r,n,o){return W(e,r,o)}function oh(e,t,r,n){return te(n)?_O(e,ma(t),r,ma(Fe(n)),me(n)):w(n)?jO(e,n.properties):ye(n)?S(e):Me(n)?S(e):L()}function ih(e,t,r){return Le(r)?S(e):ee(e,t,r)}function sh(e,t,r){return gr(r)?S(e):ee(e,t,r)}function ah(e,t,r){let n=ot(t);return W(e,n,r)}function Xu(e,t){return l.Create({"~kind":"Inferrable"},{name:e,type:t},{})}function yi(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 Qu(e){return Zr(e)?ve(e.items)?H(e.items.extends)?Xu(e.items.name,e.items.extends.items):Me(e.items.extends)?Xu(e.items.name,e.items.extends):void 0:he():void 0}function Ga(e){return ve(e)?Xu(e.name,e.extends):void 0}function mh(e,t){let r=[];for(let n of e){if(!xr(W({},n,t)))return;r.push(n)}return r}function uh(e,t,r,n){let o=mh(r,n);return s.IsArray(o)?S(l.Assign(e,{[t]:ke(o)})):L()}function Ba(e,t,r,n){let o=mh(r,n);return s.IsArray(o)?S(l.Assign(e,{[t]:F(o)})):L()}function qO(e){return[...e].reverse()}function Yu(e,t){return t?qO(e):e}function UO(e){let t=e.length>0?e[0]:void 0,r=de(t)?Qu(t):void 0;return de(r)}function GO(e,t,r,n,o,i){return Re(W(e,r,o),a=>ch(a,t,n,i),()=>L())}function BO(e,t,r,n,o){let i=Qu(n);return yi(i)?uh(e,i.name,Yu(r,t),i.type):s.ShiftLeft(r,(a,m)=>GO(e,t,a,m,n,o),()=>L())}function KO(e,t,r,n){return s.ShiftLeft(n,(o,i)=>BO(e,t,r,o,i),()=>s.IsEqual(r.length,0)?S(e):L())}function ch(e,t,r,n){return KO(e,t,r,n)}function HO(e,t,r){let n=nn(e,ce([],[]),r),o=UO(n);return ch(e,o,Yu(t,o),Yu(n,o))}function zO(e,t,r){for(let n of t){let o=W(e,n,r);if(!xr(o))return o;e=o.inferred}return S(e)}function WO(e,t,r){let n=Ga(r);return yi(n)?Ba(e,n.name,t,n.type):zO(e,t,r)}function ph(e,t,r){let n=nn(e,ce([],[]),t);return j(r)?HO(e,n,r.items):H(r)?WO(e,n,r.items):ee(e,ke(n),r)}function fh(e,t,r){return Ct(r)?S(e):Bt(r)?S(e):ee(e,t,r)}function dh(e,t,r){return s.ShiftLeft(r,(n,o)=>Re(W(e,t,n),i=>S(i),()=>dh(e,t,o)),()=>L())}function Zu(e,t,r){return s.ShiftLeft(t,(n,o)=>Re(dh(e,n,r),i=>Zu(i,o,r),()=>L()),()=>S(e))}function lh(e,t,r){let n=Ga(r);return yi(n)?Ba(e,n.name,t,n.type):E(r)?Zu(e,t,r.anyOf):Zu(e,t,[r])}function gh(e,t,r){return ve(r)?ee(e,t,r):ye(r)?S(e):Me(r)?S(e):L()}function xh(e,t,r){return Ct(r)?S(e):ee(e,t,r)}function W(e,t,r){return ye(t)?GI(e,t,r):H(t)?BI(e,t,t.items,r):kt(t)?KI(e,t,r):ft(t)?HI(e,t,r):be(t)?zI(e,t.parameters,t.instanceType,r):Ee(t)?WI(e,t.if,t.then,t.else,r):Se(t)?VI(e,t.enum,r):$e(t)?JI(e,t.parameters,t.returnType,r):Ge(t)?XI(e,t,r):P(t)?QI(e,t.allOf,r):K(t)?YI(e,t,r):yt(t)?ZI(e,t,r):lr(t)?eh(e,t,r):le(t)?th(e,t,r):w(t)?nh(e,t.properties,r):te(t)?oh(e,Fe(t),me(t),r):Le(t)?ih(e,t,r):gr(t)?sh(e,t,r):se(t)?ah(e,t.pattern,r):j(t)?ph(e,t.items,r):Bt(t)?fh(e,t,r):E(t)?lh(e,t.anyOf,r):Me(t)?gh(e,t,r):Ct(t)?xh(e,t,r):L()}function VO(e,t){return Te([...e,A(t)])}function ec(e,t,r){return _(e)?l.Update(VO(e,t),{},r):ui(e,t,r)}function yh(e,t,r,n,o){let i=Ft(e,t,r),a=Ii(e,t,n);return ec(i,a,o)}function ui(e,t,r={}){return T("Interface",[e,t],r)}function po(e){return de(e)&&s.HasPropertyKey(e,"action")&&s.IsEqual(e.action,"Interface")}function Ih(e,t,r={}){return ec(e,t,r)}function JO(e,t,r){return e.includes(r)?!0:hi([...e,r],t,t[r])}function hh(e,t,r){let n=zs(r);return wn(e,t,n)}function wn(e,t,r){return s.ShiftLeft(r,(n,o)=>hi(e,t,n)?!0:wn(e,t,o),()=>!1)}function hi(e,t,r){return Z(r)?JO(e,t,r.$ref):H(r)?hi(e,t,r.items):be(r)?wn(e,t,[...r.parameters,r.instanceType]):$e(r)?wn(e,t,[...r.parameters,r.returnType]):po(r)?hh(e,t,r.parameters[1]):P(r)?wn(e,t,r.allOf):w(r)?hh(e,t,r.properties):E(r)?wn(e,t,r.anyOf):j(r)?wn(e,t,r.items):te(r)?hi(e,t,me(r)):!1}function bh(e,t,r){return hi(e,t,r)}function XO(e,t){return t.reduce((r,n)=>bh([n],e,e[n])?[...r,n]:r,[])}function $h(e){let t=Hs(e);return XO(e,t)}function QO(e,t,r){return r.includes(t)?r:t in e?bi(e,e[t],[...r,t]):he()}function Eh(e,t,r){let n=zs(t);return fo(e,n,r)}function fo(e,t,r){return t.reduce((n,o)=>bi(e,o,n),r)}function bi(e,t,r){return Z(t)?QO(e,t.$ref,r):H(t)?bi(e,t.items,r):be(t)?fo(e,[...t.parameters,t.instanceType],r):$e(t)?fo(e,[...t.parameters,t.returnType],r):po(t)?Eh(e,t.parameters[1],r):P(t)?fo(e,t.allOf,r):w(t)?Eh(e,t.properties,r):E(t)?fo(e,t.anyOf,r):j(t)?fo(e,t.items,r):te(t)?bi(e,me(t),r):r}function Sh(e,t,r){return bi(e,r,[t])}function YO(e){return Qn()}function ZO(e){return s.Keys(e).reduce((t,r)=>({...t,[r]:Pn(e[r])}),{})}function $i(e){return e.reduce((t,r)=>[...t,Pn(r)],[])}function Pn(e){return Z(e)?YO(e.$ref):H(e)?xt(Pn(e.items),Jn(e)):be(e)?ur($i(e.parameters),Pn(e.instanceType)):$e(e)?cr($i(e.parameters),Pn(e.returnType)):P(e)?nt($i(e.allOf)):w(e)?A(ZO(e.properties)):te(e)?io(so(e),Pn(me(e))):E(e)?F($i(e.anyOf)):j(e)?ke($i(e.items)):e}function eM(e,t){return t in e?Pn(e[t]):De()}function kh(e){return eM(e.$defs,e.$ref)}function tM(e,t,r){let n=Ft(e,ce([],[]),t),o=Ii({},ce([],[]),r);return Te([...n,A(o)])}function rM(e,t){return s.Keys(e).filter(n=>t.includes(n)).reduce((n,o)=>{let i=e[o],a=po(i)?tM(e,i.parameters[0],i.parameters[1]):i;return{...n,[o]:a}},{})}function Th(e,t,r){let n=Sh(e,t,r),o=rM(e,n);return fr(o,t)}function Ch(e,t){return t in e?Z(e[t])?Ch(e,e[t].$ref):e[t]:re()}function yr(e,t){return Ch(e,t)}function Rh(e){return ie(e)?kh(e):Ws(e)?De():e}function et(e,t,r){let n=Rh(t),o=Rh(r);return W(e,n,o)}var oi=0,Ei=1,ii=2,si=3;function no(e,t){let r=[et({},e,t),et({},t,e)];return M.IsExtendsTrueLike(r[0])&&M.IsExtendsTrueLike(r[1])?oi:M.IsExtendsTrueLike(r[0])&&M.IsExtendsFalse(r[1])?ii:M.IsExtendsFalse(r[0])&&M.IsExtendsTrueLike(r[1])?si:Ei}function tc(e,t,r=[],n=t){return s.ShiftLeft(t,(o,i)=>{let a=no(e,o);return s.IsEqual(a,ii)||s.IsEqual(a,oi)?n:s.IsEqual(a,Ei)?tc(e,i,[...r,o],n):tc(e,i,r,n)},()=>[...r,e])}function nM(e,t,r){let n=Gt(e);return ye(n)?[n]:Me(n)?[n]:yt(n)?Ka(t,r):w(n)?Ka(t,[...r,n]):Ka(t,tc(n,r))}function Ka(e,t=[]){return s.ShiftLeft(e,(r,n)=>nM(r,n,t),()=>t)}function vu(e){let t=Ka(e);return Yr(t)}function rc(e,t){return l.Update(Gt(e),{},t)}function wh(e,t,r,n){let o=$(e,t,r);return rc(o,n)}function Si(e,t=[]){return Wr(e)&&s.IsEqual(e.action,"Conditional")?Z(e.parameters[0])?Si(e.parameters[2],Si(e.parameters[3],[...t,e.parameters[0].$ref])):Si(e.parameters[2],Si(e.parameters[3],t)):Wr(e)&&s.IsEqual(e.action,"Mapped")&&Wr(e.parameters[1])&&s.IsEqual(e.parameters[1].action,"KeyOf")&&Z(e.parameters[1].parameters[0])?[...t,e.parameters[1].parameters[0].$ref]:t}function oM(e,t){return e.reduce((r,n)=>[...r,t.includes(n.name)],[])}function Oh(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>s.ShiftLeft(t,(i,a)=>Oh(o,a,[...r,[i,n]]),()=>r),()=>r)}function iM(e){return se(e)?ot(e.pattern):Se(e)?dt(e.enum):e}function sM(e){let t=iM(e);return E(t)?[...t.anyOf]:[t]}function aM(e,t){return e.reduce((r,n)=>[...r,[...n,t]],[])}function Ph(e,t){return t.reduce((r,n)=>[...r,...aM(e,n)],[])}function Ah(e){return e.reduce((t,r)=>s.IsEqual(r[0],!0)?Ph(t,sM(r[1])):Ph(t,[r[1]]),[[]])}function Mh(e,t,r){let n=Si(r),o=oM(e,n),i=Oh(t,o);return Wr(r)&&s.IsEqual(r.action,"Conditional")||Wr(r)&&s.IsEqual(r.action,"Mapped")?Ah(i):[t]}function mM(){return["(not-resolvable)",re()]}function uM(){return["(not-generic)",re()]}function cM(e,t,r){return[e,Vr(t,r)]}function pM(e,t,r){return t in e?vh(e,t,e[t],r):mM()}function vh(e,t,r,n){return Xn(r)?cM(t,r.parameters,r.expression):Z(r)?pM(e,r.$ref,n):uM()}function Fh(e,t,r){return vh(e,"(anonymous)",t,r)}function fM(e,t,r){if(ve(t)||lo(t)||M.IsExtendsTrueLike(et({},t,r)))return;let n={parameter:e,expect:r,actual:t};throw new Error(`Argument for parameter ${e} does not satisfy constraint`,{cause:n})}function Nh(e,t,r,n,o){let i=$(e,t,o);return fM(r,i,n),l.Assign(e,{[r]:i})}function dM(e,t,r,n,o){let i=$(e,t,r.extends),a=$(e,t,r.equals);return s.ShiftLeft(o,(m,c)=>nc(Nh(e,t,r.name,i,m),t,n,c),()=>nc(Nh(e,t,r.name,i,a),t,n,[]))}function nc(e,t,r,n){return s.ShiftLeft(r,(o,i)=>dM(e,t,o,i,n),()=>e)}function Dh(e,t,r,n){return nc(e,t,r,n)}var oc=0,ic=0;function lM(){if(!s.IsLessThan(ic,Ae.Get().maxInstantiationCount))throw Error("Type instantiation is excessively deep and possibly infinite")}function gM(){lM(),ic++,oc++}function xM(){oc--,s.IsEqual(oc,0)&&(ic=0)}function yM(e){return s.IsGreaterThan(e.callstack.length,0)?e.callstack[e.callstack.length-1]:""}function IM(e,t){return s.IsEqual(yM(e),t)}function hM(e,t,r,n,o,i){gM();try{let a=Dh(e,t,n,i),m=$(a,ce([...t.callstack,r.$ref],t.visited),o);return $(a,ce([],[]),m)}finally{xM()}}function bM(e,t,r,n,o,i){return i.reduce((a,m)=>{let c=hM(e,t,r,n,o,m);return[...a,c]},[])}function $M(e,t,r,n,o,i){let a=Mh(n,i,o),m=bM(e,t,r,n,o,a);return s.IsEqual(m.length,1)?m[0]:ht(m)}function Ha(e,t,r,n){let o=Ft(e,t,n),i=Fh(e,r,n),a=i[0],m=i[1];return Xn(m)?IM(t,a)?ci(qe(a),o):$M(e,t,qe(a),m.parameters,m.expression,o):ci(r,o)}function ci(e,t){return l.Create({"~kind":"Call"},{type:"call",target:e,arguments:t},{})}function Lh(e,t){return Ha({},ce([],[]),e,t)}function lo(e){return k(e,"Call")}function EM(e){return l.Discard(e,["~immutable"])}function jh(e,t){return l.Update(EM(e),{},t)}function _h(e,t,r,n){let o=$(e,t,r);return jh(o,n)}function qh(e,t){return e(t)}function Uh(e,t){return s.IsString(t)?U(qh(e,t)):U(t)}function Gh(e,t){let r=ot(t);return Or(e,r)}function Bh(e,t){let r=t.map(n=>Or(e,n));return F(r)}function Or(e,t){return K(t)?Uh(e,t.const):se(t)?Gh(e,t.pattern):E(t)?Bh(e,t.anyOf):t}function da(e,t={}){return T("Capitalize",[e],t)}function Kh(e,t={}){return sc(e,t)}function la(e,t={}){return T("Lowercase",[e],t)}function Hh(e,t={}){return ac(e,t)}function ga(e,t={}){return T("Uncapitalize",[e],t)}function zh(e,t={}){return mc(e,t)}function xa(e,t={}){return T("Uppercase",[e],t)}function Wh(e,t={}){return uc(e,t)}var SM=e=>e[0].toUpperCase()+e.slice(1),kM=e=>e.toLowerCase(),TM=e=>e[0].toLowerCase()+e.slice(1),CM=e=>e.toUpperCase();function sc(e,t){return _([e])?l.Update(Or(SM,e),{},t):da(e,t)}function ac(e,t){return _([e])?l.Update(Or(kM,e),{},t):la(e,t)}function mc(e,t){return _([e])?l.Update(Or(TM,e),{},t):ga(e,t)}function uc(e,t){return _([e])?l.Update(Or(CM,e),{},t):xa(e,t)}function Vh(e,t,r,n){let o=$(e,t,r);return sc(o,n)}function Jh(e,t,r,n){let o=$(e,t,r);return ac(o,n)}function Xh(e,t,r,n){let o=$(e,t,r);return mc(o,n)}function Qh(e,t,r,n){let o=$(e,t,r);return uc(o,n)}function ya(e,t,r,n,o={}){return T("Conditional",[e,t,r,n],o)}function Yh(e,t,r,n,o={}){return cc({},ce([],[]),e,t,r,n,o)}function RM(e,t,r,n,o,i){let a=et(e,r,n);return M.IsExtendsUnion(a)?F([$(a.inferred,t,o),$(e,t,i)]):M.IsExtendsTrue(a)?$(a.inferred,t,o):$(e,t,i)}function cc(e,t,r,n,o,i,a){return _([r,n])?l.Update(RM(e,t,r,n,o,i),{},a):ya(r,n,o,i,a)}function Zh(e,t,r,n,o,i,a){let m=$(e,t,r),c=$(e,t,n);return cc(e,t,m,c,o,i,a)}function Ia(e,t={}){return T("ConstructorParameters",[e],t)}function eb(e,t={}){return pc(e,t)}function wM(e){let t=be(e)?e.parameters:[],r=nn({},ce([],[]),t);return ke(r)}function pc(e,t){return _([e])?l.Update(wM(e),{},t):Ia(e,t)}function tb(e,t,r,n){let o=$(e,t,r);return pc(o,n)}function ha(e,t,r={}){return T("Exclude",[e,t],r)}function rb(e,t,r={}){return ki(e,t,r)}function ki(e,t,r){return _([e,t])?l.Update(sa(e,t),{},r):ha(e,t,r)}function nb(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return ki(i,a,o)}function ba(e,t,r={}){return T("Extract",[e,t],r)}function ob(e,t,r={}){return fc(e,t,r)}function PM(e,t){let r=et({},e,t);return M.IsExtendsTrueLike(r)?[e]:[]}function ib(e,t,r=[]){return s.ShiftLeft(e,(n,o)=>ib(o,t,[...r,...PM(n,t)]),()=>r)}function sb(e,t){let r=Gt(e),n=E(r)?r.anyOf:[r],o=ib(n,t);return ht(o)}function fc(e,t,r){return _([e,t])?l.Update(sb(e,t),{},r):ba(e,t,r)}function ab(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return fc(i,a,o)}function AM(e){return e.reduce((t,r)=>Ys(r)?[...t,U(r)]:t,[])}function go(e){let t=AM(e);return F(t)}function pi(e,t,r={}){return T("Index",[e,t],r)}function mb(e,t,r={}){let n=s.IsArray(t)?go(t):t;return dc(e,n,r)}function ub(e,t){let r=yr(e,t);return Nt(r)}function cb(e,t,r){let n=Zt(e,t,r);return Nt(n)}function OM(e,t){let r=s.Keys(e).filter(f=>!s.HasPropertyKey(t,f)),n=s.Keys(t).filter(f=>!s.HasPropertyKey(e,f)),o=s.Keys(e).filter(f=>s.HasPropertyKey(t,f)),i=r.reduce((f,d)=>({...f,[d]:e[d]}),{}),a=n.reduce((f,d)=>({...f,[d]:t[d]}),{}),m=o.reduce((f,d)=>({...f,[d]:ia(e[d],t[d])}),{}),c=l.Assign(i,a);return l.Assign(c,m)}function pb(e){return e.reduce((t,r)=>OM(t,Nt(r)),{})}function fb(e){let t=ug(ke(e));return Nt(t)}function MM(e,t){return s.Keys(e).filter(o=>o in t).reduce((o,i)=>({...o,[i]:fg(e[i],t[i])}),{})}function db(e,t){return s.ShiftLeft(e,(r,n)=>db(n,MM(t,Nt(r))),()=>t)}function lb(e){return s.ShiftLeft(e,(t,r)=>db(r,Nt(t)),()=>he())}function Nt(e){return ie(e)?ub(e.$defs,e.$ref):Ee(e)?cb(e.if,e.then,e.else):P(e)?pb(e.allOf):E(e)?lb(e.anyOf):j(e)?fb(e.items):w(e)?e.properties:{}}function xo(e){let t=Nt(e);return A(t)}var vM=new RegExp("^(?:0|[1-9][0-9]*)$");function yo(e){let t=`${e}`;return vM.test(t)?parseInt(t):e}function FM(e){return U(yo(e))}function gb(e){return e.map(t=>xb(t))}function xb(e){return P(e)?nt(gb(e.allOf)):E(e)?F(gb(e.anyOf)):K(e)?FM(e.const):e}function yb(e,t){let r=xb(t),n=et({},r,Tt());return M.IsExtendsTrueLike(n)?e:K(t)&&s.IsEqual(t.const,"length")?Tt():re()}function Ib(e,t){let r=yr(e,t);return Rt(r)}function hb(e,t,r){let n=Zt(e,t,r);return Rt(n)}function bb(e){let t=dt(e);return Rt(t)}function $b(e){let t=Te(e);return Rt(t)}function Eb(e){return[`${e}`]}function Sb(e){let t=ot(e);return Rt(t)}function kb(e){return e.reduce((t,r)=>[...t,...Rt(r)],[])}function Rt(e){return ie(e)?Ib(e.$defs,e.$ref):Ee(e)?hb(e.if,e.then,e.else):Se(e)?bb(e.enum):P(e)?$b(e.allOf):K(e)?Eb(e.const):se(e)?Sb(e.pattern):E(e)?kb(e.anyOf):[]}function Io(e){return Rt(e)}function Ti(e,t){return t.map(r=>Ci(e,r))}function Ci(e,t){return H(t)?xt(Ci(e,t.items)):be(t)?ur(Ti(e,t.parameters),Ci(e,t.instanceType)):$e(t)?cr(Ti(e,t.parameters),Ci(e,t.returnType)):j(t)?ke(Ti(e,t.items)):E(t)?F(Ti(e,t.anyOf)):P(t)?nt(Ti(e,t.allOf)):ca(t)?A(e):t}function Tb(e,t){return Ci(e,t)}function NM(e,t){let r=t in e?e[t]:re();return Tb(e,r)}function Cb(e,t){return t.reduce((r,n)=>[...r,NM(e,n)],[])}function DM(e,t){let r=Io(t),n=Cb(e,r);return ht(n)}var LM=new RegExp(Qr);function jM(e){return e.filter(r=>LM.test(r))}function _M(e){let t=Hs(e),r=jM(t),n=Cb(e,r);return ht(n)}function Rb(e,t){return le(t)?_M(e):DM(e,t)}function qM(e){return U(yo(e))}function wb(e){return e.map(t=>lc(t))}function lc(e){return P(e)?nt(wb(e.allOf)):E(e)?F(wb(e.anyOf)):K(e)?qM(e.const):e}function UM(e,t){return e.reduceRight((r,n,o)=>{let i=et({},U(o),t);return M.IsExtendsTrueLike(i)?[n,...r]:r},[])}function GM(e,t){let r=lc(t),n=UM(e,r);return Jr(n)}function BM(e){return Jr(e)}function Pb(e,t){return K(t)&&s.IsEqual(t.const,"length")?U(e.length):le(t)||Ge(t)?BM(e):GM(e,t)}function Ab(e,t){return H(e)?yb(e.items,t):w(e)?Rb(e.properties,t):j(e)?Pb(e.items,t):re()}function KM(e){return ie(e)||Ee(e)||P(e)||E(e)?xo(e):e}function dc(e,t,r){return _([e,t])?l.Update(Ab(KM(e),t),{},r):pi(e,t,r)}function Ob(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return dc(i,a,o)}function $a(e,t={}){return T("InstanceType",[e],t)}function Mb(e,t={}){return gc(e,t)}function HM(e){return be(e)?e.instanceType:re()}function gc(e,t){return _([e])?l.Update(HM(e),{},t):$a(e,t)}function vb(e,t,r,n={}){let o=$(e,t,r);return gc(o,n)}function fi(e,t={}){return T("KeyOf",[e],t)}function Fb(e,t={}){return xc(e,t)}function Nb(){return F([Tt(),Ze(),eo()])}function Db(e){return Tt()}function zM(e){return e.reduce((r,n)=>Ys(n)?[...r,U(yo(n))]:he(),[])}function Lb(e){let t=s.Keys(e),r=zM(t);return Jr(r)}function jb(e){return so(e)}function _b(e){let t=e.map((r,n)=>U(n));return Jr(t)}function qb(e){return ye(e)?Nb():H(e)?Db(e.items):w(e)?Lb(e.properties):te(e)?jb(e):j(e)?_b(e.items):re()}function WM(e){return ie(e)||Ee(e)||P(e)||E(e)?xo(e):e}function xc(e,t){return _([e])?l.Update(qb(WM(e)),{},t):fi(e,t)}function Ub(e,t,r,n){let o=$(e,t,r);return xc(o,n)}function mi(e,t,r,n,o={}){return T("Mapped",[e,t,r,n],o)}function Gb(e,t,r,n,o={}){return yc({},ce([],[]),e,t,r,n,o)}function VM(e){let t=ot(e);return za(t)}function JM(e){return e.reduce((t,r)=>[...t,...za(r)],[])}function XM(e){let t=dt(e);return za(t)}function QM(e){return s.IsNumber(e)?[U(`${e}`)]:[U(e)]}function za(e){return Se(e)?XM(e.enum):K(e)?QM(e.const):se(e)?VM(e.pattern):E(e)?JM(e.anyOf):[e]}function Bb(e){return za(e)}function YM(e){return se(e)?ot(e.pattern):e}function ZM(e,t,r,n,o,i){let a=l.Assign(e,{[r.name]:n}),m=$(a,t,o),c=YM(m),p=$(a,t,i);return Zs(c)||ea(c)?{[c.const]:p}:{}}function ev(e,t,r,n,o,i){return n.reduce((a,m)=>[...a,ZM(e,t,r,m,o,i)],[])}function tv(e){return e.reduce((t,r)=>[...t,A(r)],[])}function Kb(e,t,r,n,o,i){let a=Bb(n),m=ev(e,t,r,a,o,i),c=tv(m);return Te(c)}function yc(e,t,r,n,o,i,a){return _([n])?l.Update(Kb(e,t,r,n,o,i),{},a):mi(r,n,o,i,a)}function Hb(e,t,r,n,o,i,a){let m=$(e,t,n);return yc(e,t,r,m,o,i,a)}function rv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>r.includes(i)).reduce((i,a)=>({...i,[a]:Th(n,a,t[a])}),{})}function nv(e,t,r){let n=l.Assign(e,t);return s.Keys(t).filter(i=>!r.includes(i)).reduce((i,a)=>({...i,[a]:$(n,ce([],[]),t[a])}),{})}function ov(e,t,r){let n=$h(t),o=rv(e,t,n),i=nv(e,t,n),a={...o,...i};return l.Update(a,{},r)}function Wa(e,t,r,n){return ov(e,r,n)}function Ea(e,t={}){return T("NonNullable",[e],t)}function zb(e,t={}){return Ic(e,t)}function iv(e){let t=F([Zn(),ao()]);return ki(e,t,{})}function Ic(e,t){return _([e])?l.Update(iv(e),{},t):Ea(e,t)}function Wb(e,t,r,n){let o=$(e,t,r);return Ic(o,n)}function Sa(e,t,r={}){return T("Omit",[e,t],r)}function Vb(e,t,r={}){let n=s.IsArray(t)?go(t):t;return hc(e,n,r)}function Va(e){let t=xo(e);return w(t)?t.properties:he()}function sv(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?n:{...n,[o]:e[o]},{})}function Jb(e,t){let r=Va(e),n=Io(t),o=sv(r,n);return A(o)}function hc(e,t,r){return _([e,t])?l.Update(Jb(e,t),{},r):Sa(e,t,r)}function Xb(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return hc(i,a,o)}function ka(e,t={}){return T("Parameters",[e],t)}function Qb(e,t={}){return bc(e,t)}function av(e){let t=$e(e)?e.parameters:[],r=nn({},ce([],[]),t);return ke(r)}function bc(e,t){return _([e])?l.Update(av(e),{},t):ka(e,t)}function Yb(e,t,r,n){let o=$(e,t,r);return bc(o,n)}function Ta(e,t={}){return T("Partial",[e],t)}function Zb(e,t={}){return $c(e,t)}function e$(e,t){let r=yr(e,t),n=Ir(r);return fr(l.Assign(e,{[t]:n}),t)}function t$(e,t,r){let n=Zt(e,t,r);return Ir(n)}function r$(e){let t=Te(e);return Ir(t)}function n$(e){let t=e.map(r=>Ir(r));return F(t)}function o$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:Ks(e[o])}),{});return A(t)}function Ir(e){return ie(e)?e$(e.$defs,e.$ref):Ee(e)?t$(e.if,e.then,e.else):P(e)?r$(e.allOf):E(e)?n$(e.anyOf):w(e)?o$(e.properties):A({})}function $c(e,t){return _([e])?l.Update(Ir(e),{},t):Ta(e,t)}function i$(e,t,r,n){let o=$(e,t,r);return $c(o,n)}function Ca(e,t,r={}){return T("Pick",[e,t],r)}function s$(e,t,r={}){let n=s.IsArray(t)?go(t):t;return Ec(e,n,r)}function mv(e,t){return s.Keys(e).reduce((n,o)=>t.includes(o)?l.Assign(n,{[o]:e[o]}):n,{})}function a$(e,t){let r=Va(e),n=Io(t),o=mv(r,n);return A(o)}function Ec(e,t,r){return _([e,t])?l.Update(a$(e,t),{},r):Ca(e,t,r)}function m$(e,t,r,n,o){let i=$(e,t,r),a=$(e,t,n);return Ec(i,a,o)}function Ra(e,t={}){return T("ReadonlyObject",[e],t)}function Sc(e,t={}){return kc(e,t)}var u$=Sc;function c$(e){return Yn(xt(e))}function p$(e,t){let r=yr(e,t),n=hr(r);return fr(l.Assign(e,{[t]:n}),t)}function f$(e,t,r){let n=Zt(e,t,r);return hr(n)}function d$(e){let t=Te(e);return hr(t)}function l$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:Js(e[o])}),{});return A(t)}function g$(e){return Yn(ke(e))}function x$(e){let t=e.map(r=>hr(r));return F(t)}function hr(e){return H(e)?c$(e.items):ie(e)?p$(e.$defs,e.$ref):Ee(e)?f$(e.if,e.then,e.else):P(e)?d$(e.allOf):w(e)?l$(e.properties):j(e)?g$(e.items):E(e)?x$(e.anyOf):e}function kc(e,t){return _([e])?l.Update(hr(e),{},t):Ra(e)}function y$(e,t,r,n){let o=$(e,t,r);return kc(o,n)}function I$(e,t,r,n){return t.visited.includes(n)?r:n in e?$(e,ce(t.callstack,[...t.visited,n]),e[n]):r}function h$(e,t){let r=yr(e,t),n=br(r);return fr(l.Assign(e,{[t]:n}),t)}function b$(e,t,r){let n=Zt(e,t,r);return br(n)}function $$(e){let t=Te(e);return br(t)}function E$(e){let t=e.map(r=>br(r));return F(t)}function Py(e,t={}){return T("RemoveOptional",[e],t)}function S$(e,t={}){return Tn(e,t)}function k$(e){let t=s.Keys(e).reduce((n,o)=>({...n,[o]:S$(e[o])}),{});return A(t)}function br(e){return ie(e)?h$(e.$defs,e.$ref):Ee(e)?b$(e.if,e.then,e.else):P(e)?$$(e.allOf):E(e)?E$(e.anyOf):w(e)?k$(e.properties):A({})}function wa(e,t={}){return T("Required",[e],t)}function T$(e,t={}){return Tc(e,t)}function Tc(e,t){return _([e])?l.Update(br(e),{},t):wa(e,t)}function C$(e,t,r,n){let o=$(e,t,r);return Tc(o,n)}function Pa(e,t={}){return T("ReturnType",[e],t)}function R$(e,t={}){return Cc(e,t)}function uv(e){return $e(e)?e.returnType:re()}function Cc(e,t){return _([e])?l.Update(uv(e),{},t):Pa(e,t)}function w$(e,t,r,n={}){let o=$(e,t,r);return Cc(o,n)}function Aa(e,t){return T("With",[e,t],{})}function Ja(e,t){return Rc(e,t)}function Rc(e,t){return _([e])?l.Update(e,{},t):Aa(e,t)}function P$(e,t,r,n){let o=$(e,t,r);return Rc(o,n)}function cv(e){return Zr(e)?j(e.items)?wc(e.items.items):ve(e.items)?[e]:Z(e.items)?[e]:[re()]:[e]}function wc(e){return e.reduce((r,n)=>[...r,...cv(n)],[])}function ce(e,t){return{callstack:e,visited:t}}function _(e){return s.ShiftLeft(e,(t,r)=>Z(t)?!1:_(r),()=>!0)}function Ii(e,t,r){return s.Keys(r).reduce((n,o)=>({...n,[o]:$(e,t,r[o])}),{})}function nn(e,t,r){let n=Ft(e,t,r);return wc(n)}function Ft(e,t,r){return r.map(n=>$(e,t,n))}function pv(e,t){let r=Oe(e)?mr(t,{}):t,n=Pr(e)?ar(r,{}):r;return En(e)?Ri(n,{}):n}function fv(e,t,r,n,o){return s.IsEqual(r,"AddImmutable")?A$(e,t,n[0],o):s.IsEqual(r,"RemoveImmutable")?_h(e,t,n[0],o):s.IsEqual(r,"AddReadonly")?Rl(e,t,n[0],o):s.IsEqual(r,"RemoveReadonly")?pg(e,t,n[0],o):s.IsEqual(r,"AddOptional")?wl(e,t,n[0],o):s.IsEqual(r,"RemoveOptional")?cg(e,t,n[0],o):s.IsEqual(r,"Capitalize")?Vh(e,t,n[0],o):s.IsEqual(r,"Conditional")?Zh(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"ConstructorParameters")?tb(e,t,n[0],o):s.IsEqual(r,"Evaluate")?wh(e,t,n[0],o):s.IsEqual(r,"Exclude")?nb(e,t,n[0],n[1],o):s.IsEqual(r,"Extract")?ab(e,t,n[0],n[1],o):s.IsEqual(r,"Index")?Ob(e,t,n[0],n[1],o):s.IsEqual(r,"InstanceType")?vb(e,t,n[0],o):s.IsEqual(r,"Interface")?yh(e,t,n[0],n[1],o):s.IsEqual(r,"KeyOf")?Ub(e,t,n[0],o):s.IsEqual(r,"Lowercase")?Jh(e,t,n[0],o):s.IsEqual(r,"Mapped")?Hb(e,t,n[0],n[1],n[2],n[3],o):s.IsEqual(r,"Module")?Wa(e,t,n[0],o):s.IsEqual(r,"NonNullable")?Wb(e,t,n[0],o):s.IsEqual(r,"Pick")?m$(e,t,n[0],n[1],o):s.IsEqual(r,"Parameters")?Yb(e,t,n[0],o):s.IsEqual(r,"Partial")?i$(e,t,n[0],o):s.IsEqual(r,"Omit")?Xb(e,t,n[0],n[1],o):s.IsEqual(r,"ReadonlyObject")?y$(e,t,n[0],o):s.IsEqual(r,"Record")?wg(e,t,n[0],n[1],o):s.IsEqual(r,"Required")?C$(e,t,n[0],o):s.IsEqual(r,"ReturnType")?w$(e,t,n[0],o):s.IsEqual(r,"TemplateLiteral")?NI(e,t,n[0],o):s.IsEqual(r,"Uncapitalize")?Xh(e,t,n[0],o):s.IsEqual(r,"Uppercase")?Qh(e,t,n[0],o):s.IsEqual(r,"With")?P$(e,t,n[0],n[1]):T(r,n,o)}function dv(e,t,r){let n=Z(r)?I$(e,t,r,r.$ref):H(r)?xt($(e,t,r.items),Jn(r)):lo(r)?Ha(e,t,r.target,r.arguments):be(r)?ur(Ft(e,t,r.parameters),$(e,t,r.instanceType),Pl(r)):$e(r)?cr(Ft(e,t,r.parameters),$(e,t,r.returnType),Al(r)):Ee(r)?$n($(e,t,r.if),$(e,t,r.then),$(e,t,r.else),Dl(r)):P(r)?nt(Ft(e,t,r.allOf),Ul(r)):w(r)?A(Ii(e,t,r.properties),Fl(r)):te(r)?Pg(Fe(r),$(e,t,me(r))):Zr(r)?Cn($(e,t,r.items)):j(r)?ke(nn(e,t,r.items),mg(r)):E(r)?F(Ft(e,t,r.anyOf),Yl(r)):r;return pv(r,n)}function $(e,t,r){return Wr(r)?fv(e,t,r.action,r.parameters,r.options):dv(e,t,r)}function Dt(e,t){return $(e,ce([],[]),t)}function Ri(e,t){return l.Update(e,{"~immutable":!0},t)}function A$(e,t,r,n){let o=$(e,t,r);return Ri(o,n)}function Ay(e,t={}){return T("AddImmutable",[e],t)}function Yn(e,t={}){return Ri(e,t)}function Oy(e,t={}){return T("RemoveReadonly",[e],t)}function My(e,t={}){return T("Evaluate",[e],t)}function Be(e,t={}){return rc(e,t)}function vy(e,t={}){return T("Module",[e],t)}function O$(e,t={}){return Wa({},ce([],[]),e,t)}function lv(e,t){let r=no(e,t);return s.IsEqual(r,si)||s.IsEqual(r,Ei)?1:0}function M$(e,t,r=[]){return s.ShiftLeft(t,(n,o)=>s.IsEqual(lv(e,n),1)?M$(e,o,[...r,n]):[...r,e,...t],()=>[...r,e])}function v$(e,t=[]){return s.ShiftLeft(e,(r,n)=>v$(n,M$(r,t)),()=>t)}function F$(e){return v$(e)}function N$(...e){let[t,r,n]=q.Match(e,{2:(a,m)=>s.IsString(a)?[{},a,m]:[a,m,{}],3:(a,m,c)=>[a,m,c],1:a=>[{},a,{}]}),o=AI(r),i=s.IsArray(o)&&s.IsEqual(o.length,2)?$(t,ce([],[]),o[0]):re();return l.Update(i,{},n)}function D$(e,t,r){return s.IsArray(r)?r.map(n=>Ke(e,t.items,n)):r}function L$(e,t,r){return Ke({...e,...t.$defs},qe(t.$ref),r)}function gv(e,t){let r=s.HasPropertyKey(t,"unevaluatedProperties")?{additionalProperties:t.unevaluatedProperties}:{},n=Dt(e,t),o=Be(n);return w(o)?Ja(o,r):o}function j$(e,t,r){let n=gv(e,t);return Ke(e,n,r)}function Xa(e){return s.HasPropertyKey(e,"additionalProperties")?e.additionalProperties:void 0}function _$(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return r;let n=Xa(t);for(let o of s.Keys(r)){if(s.HasPropertyKey(t.properties,o)&&de(t.properties[o])){r[o]=Ke(e,t.properties[o],r[o]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||de(n)&&B(e,n,r[o])){r[o]=Ke(e,n,r[o]);continue}delete r[o]}return r}function q$(e,t,r){if(!s.IsObject(r))return r;let n=Xa(t),[o,i]=[new RegExp(Fe(t)),me(t)];for(let a of s.Keys(r)){if(o.test(a)){r[a]=Ke(e,i,r[a]);continue}if(s.IsBoolean(n)&&s.IsEqual(n,!0)||de(n)&&B(e,n,r[a])){r[a]=Ke(e,n,r[a]);continue}delete r[a]}return r}function U$(e,t,r){return s.HasPropertyKey(e,t.$ref)?Ke(e,e[t.$ref],r):r}function G$(e,t,r){if(!s.IsArray(r))return r;let n=Math.min(r.length,t.items.length);for(let o=0;o<n;o++)r[o]=Ke(e,t.items[o],r[o]);return s.IsGreaterThan(r.length,n)?r.slice(0,n):r}function xv(e){return s.HasPropertyKey(e,"~kind")||s.HasPropertyKey(e,"~unsafe")}function yv(e){let t={};for(let r of s.Keys(e)){if(s.IsUnsafePropertyKey(r))continue;let n=Object.getOwnPropertyDescriptor(e,r);n.value=On(n.value),s.IsEqual(n.enumerable,!0)?t[r]=n.value:Object.defineProperty(t,r,n)}return t}function Iv(e){let t={};for(let r of s.Keys(e))s.IsUnsafePropertyKey(r)||(t[r]=On(e[r]));for(let r of s.Symbols(e))t[r]=On(e[r]);return t}function hv(e){return s.IsClassInstance(e)?e:xv(e)?yv(e):Iv(e)}function bv(e){return e.map(t=>On(t))}function $v(e){return e.slice()}function Ev(e){return new RegExp(e.source,e.flags)}function Sv(e){return new Map(On([...e.entries()]))}function kv(e){return new Set(On([...e.values()]))}function On(e){return Ne.IsTypeArray(e)?$v(e):Ne.IsRegExp(e)?Ev(e):Ne.IsMap(e)?Sv(e):Ne.IsSet(e)?kv(e):s.IsArray(e)?bv(e):s.IsObject(e)?hv(e):e}function B$(e){return On(e)}function ue(e){return B$(e)}function K$(e,t,r){for(let n of t.anyOf){let o=Ke(e,n,ue(r));if(B(e,n,o))return o}return r}function Ke(e,t,r){return H(t)?D$(e,t,r):ie(t)?L$(e,t,r):P(t)?j$(e,t,r):w(t)?_$(e,t,r):te(t)?q$(e,t,r):Z(t)?U$(e,t,r):j(t)?G$(e,t,r):E(t)?K$(e,t,r):r}function Tv(e,t){return l.Assign(e,t)}function Cv(e){let t={};for(let r of cf.Keys(e))t[r]=wi(e[r]);return t}function Rv(e){return Ze({pattern:Fe(e)})}function wv(e){return Pc(F$(e))}function Pc(e){return e.map(t=>wi(t))}function wi(e){let t=H(e)?xt(wi(e.items),Jn(e)):P(e)?nt(Pc(e.allOf)):E(e)?F(wv(e.anyOf)):w(e)?A(Cv(e.properties)):te(e)?io(Rv(e),wi(me(e))):j(e)?ke(Pc(e.items)):e;return Tv(e,t)}function ho(e){return wi(e)}function er(...e){let[t,r,n]=q.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=Ae.Get().unionPrioritySort?ho(r):r;return Ke(t,o,n)}var Y={};At(Y,{Fail:()=>Mn,IsOk:()=>Ac,Ok:()=>R,TryArray:()=>Pv,TryBigInt:()=>Oc,TryBoolean:()=>Uv,TryNull:()=>zv,TryNumber:()=>Xv,TryString:()=>Qv,TryUndefined:()=>rF});function Ac(e){return s.IsObject(e)&&s.HasPropertyKey(e,"value")}function R(e){return{value:e}}function Mn(){}function Pv(e){return s.IsArray(e)?R(e):R([e])}function Av(e){return s.IsEqual(e,!0)?R(BigInt(1)):R(BigInt(0))}var Ov=/^-?(0|[1-9]\d*)n$/,Mv=/^-?(0|[1-9]\d*)\.\d+$/,vv=/^-?(0|[1-9]\d*)$/;function Fv(e){return Ov.test(e)}function Nv(e){return Mv.test(e)}function Dv(e){return vv.test(e)}function Lv(e){let t=e.toLowerCase();return Fv(e)?R(BigInt(e.slice(0,e.length-1))):Nv(e)?R(BigInt(e.split(".")[0])):Dv(e)?R(BigInt(e)):s.IsEqual(t,"false")?R(BigInt(0)):s.IsEqual(t,"true")?R(BigInt(1)):void 0}function Oc(e){return s.IsBigInt(e)?R(e):s.IsBoolean(e)?Av(e):s.IsNumber(e)?R(BigInt(Math.trunc(e))):s.IsNull(e)?R(BigInt(0)):s.IsString(e)?Lv(e):s.IsUndefined(e)?R(BigInt(0)):void 0}function jv(e){return s.IsEqual(e,BigInt(0))?R(!1):s.IsEqual(e,BigInt(1))?R(!0):void 0}function _v(e){return s.IsEqual(e,0)?R(!1):s.IsEqual(e,1)?R(!0):void 0}function qv(e){return s.IsEqual(e.toLowerCase(),"false")?R(!1):s.IsEqual(e.toLowerCase(),"true")?R(!0):s.IsEqual(e,"0")?R(!1):s.IsEqual(e,"1")?R(!0):void 0}function Uv(e){return s.IsBigInt(e)?jv(e):s.IsBoolean(e)?R(e):s.IsNumber(e)?_v(e):s.IsNull(e)?R(!1):s.IsString(e)?qv(e):s.IsUndefined(e)?R(!1):void 0}function Gv(e){return s.IsEqual(e,BigInt(0))?R(null):void 0}function Bv(e){return s.IsEqual(e,!1)?R(null):void 0}function Kv(e){return s.IsEqual(e,0)?R(null):void 0}function Hv(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?R(null):void 0}function zv(e){return s.IsBigInt(e)?Gv(e):s.IsBoolean(e)?Bv(e):s.IsNumber(e)?Kv(e):s.IsNull(e)?R(null):s.IsString(e)?Hv(e):s.IsUndefined(e)?R(null):void 0}var H$=BigInt(Number.MAX_SAFE_INTEGER),z$=BigInt(Number.MIN_SAFE_INTEGER);function Wv(e){return e<=H$&&e>=z$?R(Number(e)):void 0}function Vv(e){return R(e?1:0)}function Jv(e){let t=+e;if(s.IsNumber(t))return R(t);let r=e.toLowerCase();if(s.IsEqual(r,"false"))return R(0);if(s.IsEqual(r,"true"))return R(1);let n=Oc(e);return Ac(n)?n.value<=H$&&n.value>=z$?R(Number(n.value)):void 0:void 0}function Xv(e){return s.IsBigInt(e)?Wv(e):s.IsBoolean(e)?Vv(e):s.IsNumber(e)?R(e):s.IsNull(e)?R(0):s.IsString(e)?Jv(e):s.IsUndefined(e)?R(0):void 0}function Qv(e){return s.IsBigInt(e)?R(e.toString()):s.IsBoolean(e)?R(e.toString()):s.IsNumber(e)?R(e.toString()):s.IsNull(e)?R("null"):s.IsString(e)?R(e):s.IsUndefined(e)?R(""):void 0}function Yv(e){return s.IsEqual(e,BigInt(0))?R(void 0):void 0}function Zv(e){return s.IsEqual(e,!1)?R(void 0):void 0}function eF(e){return s.IsEqual(e,0)?R(void 0):void 0}function tF(e){let t=e.toLowerCase();return s.IsEqual(t,"undefined")||s.IsEqual(t,"null")||s.IsEqual(e,"")||s.IsEqual(e,"0")?R(void 0):void 0}function rF(e){return s.IsBigInt(e)?Yv(e):s.IsBoolean(e)?Zv(e):s.IsNumber(e)?eF(e):s.IsNull(e)?R(void 0):s.IsString(e)?tF(e):s.IsUndefined(e)?R(e):void 0}function W$(e,t,r){return Y.TryArray(r).value.map(o=>we(e,t.items,o))}function V$(e,t,r){let n=Y.TryBigInt(r);return Y.IsOk(n)?n.value:r}function J$(e,t,r){let n=Y.TryBoolean(r);return Y.IsOk(n)?n.value:r}function X$(e,t,r){return we({...e,...t.$defs},qe(t.$ref),r)}function Q$(e,t,r){return we(e,Be(t),r)}function Y$(e,t,r){let n=Y.TryNumber(r);return Y.IsOk(n)?Math.trunc(n.value):r}function Z$(e,t,r){let n=Dt(e,t),o=Be(n);return we(e,o,r)}function nF(e,t,r){let n=Y.TryBigInt(r);return Y.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function oF(e,t,r){let n=Y.TryBoolean(r);return Y.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function iF(e,t,r){let n=Y.TryNumber(r);return Y.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function sF(e,t,r){let n=Y.TryString(r);return Y.IsOk(n)&&s.IsEqual(t.const,n.value)?n.value:r}function eE(e,t,r){return s.IsEqual(t.const,r)?r:Jl(t)?nF(e,t,r):Xl(t)?oF(e,t,r):Zs(t)?iF(e,t,r):ea(t)?sF(e,t,r):he()}function tE(e,t,r){let n=Y.TryNull(r);return Y.IsOk(n)?n.value:r}function rE(e,t,r){let n=Y.TryNumber(r);return Y.IsOk(n)?n.value:r}function Qa(e,t,r,n){let o=s.Keys(n);for(let[i,a]of t)for(let m of o)i.test(m)||(n[m]=we(e,r,n[m]));return n}function Pi(e,t,r){return Oe(e)&&s.IsUndefined(r[t])}function aF(e,t,r){let n=s.EntriesRegExp(t.properties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)!i.test(m)||Pi(a,m,r)||(r[m]=we(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?Qa(e,n,t.additionalProperties,r):r}function nE(e,t,r){return s.IsObjectNotArray(r)?aF(e,t,r):r}function mF(e,t,r){let n=s.EntriesRegExp(t.patternProperties),o=s.Keys(r);for(let[i,a]of n)for(let m of o)i.test(m)&&(r[m]=we(e,a,r[m]));return s.HasPropertyKey(t,"additionalProperties")&&s.IsObject(t.additionalProperties)?Qa(e,n,t.additionalProperties,r):r}function oE(e,t,r){return s.IsObjectNotArray(r)?mF(e,t,r):r}function iE(e,t,r){return s.HasPropertyKey(e,t.$ref)?we(e,e[t.$ref],r):r}function sE(e,t,r){let n=Y.TryString(r);return Y.IsOk(n)?n.value:r}function aE(e,t,r){return we(e,Be(t),r)}function mE(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<Math.min(t.items.length,r.length);n++)r[n]=we(e,t.items[n],r[n]);return r}function uE(e,t,r){let n=Y.TryUndefined(r);return Y.IsOk(n)?n.value:r}function cE(e,t,r){if(t.anyOf.some(a=>B(e,a,r)))return r;let i=t.anyOf.map(a=>we(e,a,ue(r))).find(a=>B(e,t,a));return s.IsUndefined(i)?r:i}function pE(e,t,r){let n=Y.TryUndefined(r);return Y.IsOk(n)?void 0:r}function we(e,t,r){return H(t)?W$(e,t,r):kt(t)?V$(e,t,r):ft(t)?J$(e,t,r):ie(t)?X$(e,t,r):Se(t)?Q$(e,t,r):Ge(t)?Y$(e,t,r):P(t)?Z$(e,t,r):K(t)?eE(e,t,r):lr(t)?tE(e,t,r):le(t)?rE(e,t,r):w(t)?nE(e,t,r):te(t)?oE(e,t,r):Z(t)?iE(e,t,r):Le(t)?sE(e,t,r):se(t)?aE(e,t,r):j(t)?mE(e,t,r):Bt(t)?uE(e,t,r):E(t)?cE(e,t,r):Ct(t)?pE(e,t,r):r}function $r(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return we(t,r,n)}function fE(e,t,r){if(!s.IsArray(r))return r;for(let n=0;n<r.length;n++)r[n]=He(e,t.items,r[n]);return r}function dE(e,t,r){return He({...e,...t.$defs},qe(t.$ref),r)}function lE(e,t){return s.IsUndefined(t)?s.IsFunction(e.default)?e.default():ue(e.default):t}function gE(e,t,r){let n=Dt(e,t),o=Be(n);return He(e,o,r)}function xE(e,t,r){if(!s.IsObject(r))return r;let n=s.Keys(t.properties);for(let o of n){let i=He(e,t.properties[o],r[o]);s.IsUndefined(i)&&(Oe(t.properties[o])||!s.HasPropertyKey(t.properties[o],"default"))||(r[o]=i)}if(!qt(t)||s.IsBoolean(t.additionalProperties))return r;for(let o of s.Keys(r))n.includes(o)||(r[o]=He(e,t.additionalProperties,r[o]));return r}function yE(e,t,r){if(!s.IsObject(r))return r;let[n,o]=[new RegExp(Fe(t)),me(t)];for(let i of s.Keys(r))n.test(i)&&bt(o)&&(r[i]=He(e,o,r[i]));if(!qt(t))return r;for(let i of s.Keys(r))n.test(i)||(r[i]=He(e,t.additionalProperties,r[i]));return r}function IE(e,t,r){return s.HasPropertyKey(e,t.$ref)?He(e,e[t.$ref],r):r}function hE(e,t,r){if(!s.IsArray(r))return r;let[n,o]=[t.items,Math.max(t.items.length,r.length)];for(let i=0;i<o;i++)i<n.length&&(r[i]=He(e,n[i],r[i]));return r}function bE(e,t,r){for(let n of t.anyOf){let o=He(e,n,ue(r));if(B(e,n,o))return o}return r}function He(e,t,r){let n=bt(t)?lE(t,r):r;return H(t)?fE(e,t,n):ie(t)?dE(e,t,n):P(t)?gE(e,t,n):w(t)?xE(e,t,n):te(t)?yE(e,t,n):Z(t)?IE(e,t,n):j(t)?hE(e,t,n):E(t)?bE(e,t,n):n}function on(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return He(t,r,n)}function bo(e){return(...t)=>{let[r,n,o]=q.Match(t,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]});return e.reduce((i,a)=>a(r,n,i),o)}}function uF(e,t,r){return t["~codec"].decode(r)}function cF(e,t,r){return t["~codec"].encode(r)}function fe(e,t,r,n){return pt(r)?s.IsEqual(e,"Decode")?uF(t,r,n):cF(t,r,n):n}function pF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<n.length;o++)n[o]=ge(e,t,r.items,n[o]);return fe(e,t,r,n)}function fF(e,t,r,n){let o=fe(e,t,r,n);if(!s.IsArray(o))return o;for(let i=0;i<o.length;i++)o[i]=ge(e,t,r.items,o[i]);return o}function $E(e,t,r,n){return s.IsEqual(e,"Decode")?pF(e,t,r,n):fF(e,t,r,n)}function EE(e,t,r,n){return n=ge(e,{...t,...r.$defs},qe(r.$ref),n),fe(e,t,r,n)}function SE(e){return e.reduce((t,r)=>({...t,...r}),{})}function kE(e,t){for(let r of t)if(!s.IsDeepEqual(e,r))return r;return e}function dF(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return fe(e,t,r,n);let o=r.allOf.map(m=>ge(e,t,m,er(m,ue(n)))),a=o.every(m=>s.IsObject(m))?SE(o):kE(n,o);return fe(e,t,r,a)}function lF(e,t,r,n){if(s.IsEqual(r.allOf.length,0))return fe(e,t,r,n);let o=fe(e,t,r,n),i=r.allOf.map(m=>ge(e,t,m,er(m,ue(o))));return i.every(m=>s.IsObject(m))?SE(i):kE(o,i)}function TE(e,t,r,n){return s.IsEqual(e,"Decode")?dF(e,t,r,n):lF(e,t,r,n)}function gF(e,t,r,n){if(!s.IsObjectNotArray(n))return n;for(let o of s.Keys(r.properties))!s.HasPropertyKey(n,o)||Pi(r.properties[o],o,n)||(n[o]=ge(e,t,r.properties[o],n[o]));return fe(e,t,r,n)}function xF(e,t,r,n){let o=fe(e,t,r,n);if(!s.IsObjectNotArray(o))return o;for(let i of s.Keys(r.properties))!s.HasPropertyKey(o,i)||Pi(r.properties[i],i,o)||(o[i]=ge(e,t,r.properties[i],o[i]));return o}function CE(e,t,r,n){return s.IsEqual(e,"Decode")?gF(e,t,r,n):xF(e,t,r,n)}function yF(e,t,r,n){if(!s.IsObjectNotArray(n))return n;let o=new RegExp(Fe(r));for(let i of s.Keys(n))o.test(i)&&(n[i]=ge(e,t,me(r),n[i]));return fe(e,t,r,n)}function IF(e,t,r,n){let o=fe(e,t,r,n);if(!s.IsObjectNotArray(o))return o;let i=new RegExp(Fe(r));for(let a of s.Keys(o))i.test(a)&&(o[a]=ge(e,t,me(r),o[a]));return o}function RE(e,t,r,n){return s.IsEqual(e,"Decode")?yF(e,t,r,n):IF(e,t,r,n)}function wE(e,t,r,n){return s.HasPropertyKey(t,r.$ref)?ge(e,t,t[r.$ref],n):n}function PE(e,t,r,n){return s.IsEqual(e,"Decode")?fe(e,t,r,wE(e,t,r,n)):wE(e,t,r,fe(e,t,r,n))}function hF(e,t,r,n){if(!s.IsArray(n))return n;for(let o=0;o<Math.min(r.items.length,n.length);o++)n[o]=ge(e,t,r.items[o],n[o]);return fe(e,t,r,n)}function bF(e,t,r,n){let o=fe(e,t,r,n);if(!s.IsArray(o))return n;for(let i=0;i<Math.min(r.items.length,o.length);i++)o[i]=ge(e,t,r.items[i],o[i]);return o}function AE(e,t,r,n){return s.IsEqual(e,"Decode")?hF(e,t,r,n):bF(e,t,r,n)}function $F(e,t,r,n){for(let o of r.anyOf){if(!B(t,o,n))continue;let i=ge(e,t,o,n);return fe(e,t,r,i)}return n}function EF(e,t,r,n){let o=fe(e,t,r,n);for(let i of r.anyOf){let a=ge(e,t,i,ue(o));if(B(t,i,a))return a}return o}function OE(e,t,r,n){return s.IsEqual(e,"Decode")?$F(e,t,r,n):EF(e,t,r,n)}function ge(e,t,r,n){return H(r)?$E(e,t,r,n):ie(r)?EE(e,t,r,n):P(r)?TE(e,t,r,n):w(r)?CE(e,t,r,n):te(r)?RE(e,t,r,n):Z(r)?PE(e,t,r,n):j(r)?AE(e,t,r,n):E(r)?OE(e,t,r,n):fe(e,t,r,n)}var Mc=class extends wr{constructor(t,r){super("Decode",t,r)}};function SF(e,t,r){if(!B(e,t,r))throw new Mc(r,Qt(e,t,r));return r}function kF(e,t,r){let n=Ae.Get().unionPrioritySort?ho(t):t;return ge("Decode",e,n,r)}var TF=bo([(e,t,r)=>ue(r),(e,t,r)=>on(e,t,r),(e,t,r)=>$r(e,t,r),(e,t,r)=>er(e,t,r),(e,t,r)=>SF(e,t,r),(e,t,r)=>kF(e,t,r)]);function ME(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return TF(t,r,n)}var vc=class extends wr{constructor(t,r){super("Encode",t,r)}};function CF(e,t,r){if(!B(e,t,r))throw new vc(r,Qt(e,t,r));return r}function RF(e,t,r){let n=Ae.Get().unionPrioritySort?ho(t):t;return ge("Encode",e,n,r)}var wF=bo([(e,t,r)=>ue(r),(e,t,r)=>RF(e,t,r),(e,t,r)=>on(e,t,r),(e,t,r)=>$r(e,t,r),(e,t,r)=>er(e,t,r),(e,t,r)=>CF(e,t,r)]);function vE(...e){let[t,r,n]=q.Match(e,{3:(o,i,a)=>[o,i,a],2:(o,i)=>[{},o,i]});return wF(t,r,n)}function PF(e,t){return pt(t)||sn(e,t.items)}function AF(e,t){return pt(t)||FE({...e,...t.$defs},qe(t.$ref))}function OF(e,t){return pt(t)||t.allOf.some(r=>sn(e,r))}function MF(e,t){return pt(t)||s.Keys(t.properties).some(r=>sn(e,t.properties[r]))}function vF(e,t){return pt(t)||sn(e,me(t))}function FE(e,t){return Fc.has(t.$ref)?!1:(Fc.add(t.$ref),pt(t)||s.HasPropertyKey(e,t.$ref)&&sn(e,e[t.$ref]))}function FF(e,t){return pt(t)||t.items.some(r=>sn(e,r))}function NF(e,t){return pt(t)||t.anyOf.some(r=>sn(e,r))}function sn(e,t){return H(t)?PF(e,t):ie(t)?AF(e,t):P(t)?OF(e,t):w(t)?MF(e,t):te(t)?vF(e,t):Z(t)?FE(e,t):j(t)?FF(e,t):E(t)?NF(e,t):pt(t)}var Fc=new Set;function NE(...e){let[t,r]=q.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Fc.clear(),sn(t,r)}var Kt=class extends Error{constructor(t,r){super(r),this.type=t}};function DE(e,t){return s.IsFunction(t.default)?t.default(t):s.IsObject(t.default)?ue(t.default):t.default}function LE(e,t){if(Br(t)&&!bt(t))throw new Kt(t,"Arrays with uniqueItems constraints must specify a default annotation");let r=yn(t)?t.minItems:0;return Array.from({length:r},()=>Pe(e,t.items))}function jE(e,t){return kr(t)?BigInt(t.exclusiveMinimum)+BigInt(1):Tr(t)?BigInt(t.minimum):BigInt(0)}function _E(e,t){return!1}function qE(e,t){let r=Pe(e,t.instanceType);return class{constructor(){Object.assign(this,r)}}}function UE(e,t){return Pe({...e,...t.$defs},qe(t.$ref))}function GE(e,t){return Pe(e,Be(t))}function BE(e,t){let r=Pe(e,t.returnType);return()=>r}function KE(e,t){return kr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Tr(t)?t.minimum:0}function HE(e,t){let r=Dt(e,t),n=Be(r);return Pe(e,n)}function zE(e,t){return t.const}function WE(e,t){throw new Kt(t,"Cannot create TNever types")}function VE(e,t){return null}function JE(e,t){return kr(t)&&s.IsNumber(t.exclusiveMinimum)?t.exclusiveMinimum+1:Tr(t)?t.minimum:0}function XE(e,t){return(s.IsUndefined(t.required)?[]:t.required).reduce((n,o)=>({...n,[o]:Pe(e,t.properties[o])}),{})}function QE(e,t){if(Lo(t)&&!bt(t))throw new Kt(t,"Record with the minProperties constraint must have a default annotation");return{}}function YE(e,t){return s.HasPropertyKey(e,t.$ref)?Pe(e,e[t.$ref]):(()=>{throw new Kt(t,"Unable to deref Ref")})()}function ZE(e,t){if((jo(t)||Fo(t))&&!bt(t))throw Error("Strings with format or pattern constraints must specify default");let n=Do(t)?t.minLength:0;return"".padEnd(n)}function eS(e,t){return Symbol()}function tS(e,t){let r=to(t.pattern);if(Le(r))throw new Kt(t,"Unable to create TemplateLiteral due to infinite type expansion");return Pe(e,r)}function rS(e,t){return Array.from({length:t.minItems},(r,n)=>Pe(e,t.items[n]))}function nS(e,t){if(s.IsEqual(t.anyOf.length,0))throw Error("Unable to create Union with no variants");return Pe(e,t.anyOf[0])}function Pe(e,t){return bt(t)?DE(e,t):H(t)?LE(e,t):kt(t)?jE(e,t):ft(t)?_E(e,t):be(t)?qE(e,t):ie(t)?UE(e,t):Se(t)?GE(e,t):$e(t)?BE(e,t):Ge(t)?KE(e,t):P(t)?HE(e,t):K(t)?zE(e,t):yt(t)?WE(e,t):lr(t)?VE(e,t):le(t)?JE(e,t):w(t)?XE(e,t):te(t)?QE(e,t):Z(t)?YE(e,t):Le(t)?ZE(e,t):gr(t)?eS(e,t):se(t)?tS(e,t):j(t)?rS(e,t):Bt(t)?void 0:E(t)?nS(e,t):Ct(t)?void 0:void 0}function Je(...e){let[t,r]=q.Match(e,{2:(n,o)=>[n,o],1:n=>[{},n]});return Pe(t,r)}function Ya(e,t){return s.IsDeepEqual(e,t)}function Za(e){return Rr.Hash(e)}var em=class extends wr{constructor(t,r){super("Parse",t,r)}};function DF(e,t,r){Us();let n=Qt(e,t,r);if(Gs(),!B(e,t,r))throw new em(r,n);return r}var LF=bo([(e,t,r)=>ue(r),(e,t,r)=>on(e,t,r),(e,t,r)=>$r(e,t,r),(e,t,r)=>er(e,t,r),(e,t,r)=>DF(e,t,r)]);function oS(...e){let[t,r,n]=q.Match(e,{3:(a,m,c)=>[a,m,c],2:(a,m)=>[{},a,m]});if(B(t,r,n))return n;if(Ae.Get().correctiveParse)return LF(t,r,n);Us();let i=Qt(t,r,n);throw Gs(),new em(n,i)}function tm(e,t){return{type:"update",path:e,value:t}}function sS(e,t){return{type:"insert",path:e,value:t}}function aS(e){return{type:"delete",path:e}}function iS(e){if(!(s.IsObject(e)&&s.IsEqual(s.Symbols(e).length,0)))throw new Error("Cannot create diffs for objects with symbols keys")}function*jF(e,t,r){if(!s.IsObject(r)||s.IsArray(r))return yield tm(e,r);iS(t),iS(r);let n=s.Keys(t),o=s.Keys(r);for(let i of o)s.HasPropertyKey(t,i)||s.IsUnsafePropertyKey(i)||(yield sS(`${e}/${i}`,r[i]));for(let i of n)s.HasPropertyKey(r,i)&&(s.IsUnsafePropertyKey(i)||Ya(t,r)||(yield*rm(`${e}/${i}`,t[i],r[i])));for(let i of n)s.HasPropertyKey(r,i)||s.IsUnsafePropertyKey(i)||(yield aS(`${e}/${i}`))}function*_F(e,t,r){if(!s.IsArray(r))return yield tm(e,r);for(let n=0;n<Math.min(t.length,r.length);n++)yield*rm(`${e}/${n}`,t[n],r[n]);for(let n=0;n<r.length;n++)n<t.length||(yield sS(`${e}/${n}`,r[n]));for(let n=t.length-1;n>=0;n--)n<r.length||(yield aS(`${e}/${n}`))}function*qF(e,t,r){let n=globalThis.Object.getPrototypeOf(t).constructor.name,o=globalThis.Object.getPrototypeOf(r).constructor.name;if(Ne.IsTypeArray(r)&&s.IsEqual(t.length,r.length)&&s.IsEqual(n,o))for(let a=0;a<Math.min(t.length,r.length);a++)yield*rm(`${e}/${a}`,t[a],r[a]);else return yield tm(e,r)}function*UF(e,t,r){t!==r&&(yield tm(e,r))}function*rm(e,t,r){return Ne.IsTypeArray(t)?yield*qF(e,t,r):s.IsArray(t)?yield*_F(e,t,r):s.IsObject(t)?yield*jF(e,t,r):yield*UF(e,t,r)}function mS(e,t){return[...rm("",e,t)]}var GF=A({type:U("insert"),path:Ze(),value:De()}),BF=Object({type:U("update"),path:Ze(),value:De()}),KF=A({type:U("delete"),path:Ze()}),KRe=F([GF,BF,KF]);function HF(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function zF(e){return e.length===0}function uS(e,t){if(HF(t))return ue(t[0].value);if(zF(t))return ue(e);let r=ue(e);for(let n of t)switch(n.type){case"insert":{sr.Set(r,n.path,n.value);break}case"update":{sr.Set(r,n.path,n.value);break}case"delete":{sr.Delete(r,n.path);break}}return r}var Mr=class extends Error{constructor(t,r,n,o){super(o),this.context=t,this.type=r,this.value=n}};function WF(e){let[t,r]=[new Set,[]];for(let n of e){let o=Za(n);t.has(o)||(t.add(o),r.push(n))}return r}function cS(e,t,r){if(B(e,t,r))return r;let n=s.IsArray(r)?r:Je(e,t),o=yn(t)&&n.length<t.minItems?[...n,...Array.from({length:t.minItems-n.length},()=>Je(e,t))]:n,a=(No(t)&&o.length>t.maxItems?o.slice(0,t.maxItems):o).map(c=>je(e,t.items,c));if(!Br(t)||Br(t)&&!s.IsEqual(t.uniqueItems,!0))return a;let m=WF(a);if(!B(e,t,m))throw new Mr(e,t,r,"Failed to repair Array due to uniqueItems constraint");return m}function pS(e,t,r){return je(e,Be(t),r)}function fS(e,t,r){let n=Dt(e,t),o=Be(n);return je(e,o,r)}function dS(e,t,r){if(B(e,t,r))return r;if(!s.IsObjectNotArray(r))return Je(e,t);let n=new Set(s.IsUndefined(t.required)?[]:t.required),o={};for(let[a,m]of s.Entries(t.properties))!n.has(a)&&s.IsUndefined(r[a])||(o[a]=a in r?je(e,m,r[a]):Je(e,m));let i=s.Keys(t.properties);if(qt(t)&&s.IsObject(t.additionalProperties))for(let a of s.Keys(r))i.includes(a)||(o[a]=je(e,t.additionalProperties,r[a]));return o}function lS(e,t,r){if(B(e,t,r))return r;if(s.IsNull(r)||!s.IsObject(r)||s.IsArray(r))return Je(e,t);let n=new RegExp(Fe(t)),o=me(t),i=new Set,a={};for(let[m,c]of s.Entries(r))n.test(m)&&(a[m]=je(e,o,c),i.add(m));if(qt(t))for(let m of s.Keys(r))i.has(m)||(a[m]=je(e,t.additionalProperties,r[m]));return a}function gS(e,t,r){return s.HasPropertyKey(e,t.$ref)?je(e,e[t.$ref],r):(()=>{throw new Mr(e,t,r,"Unable to de-reference target type")})()}function xS(e,t,r){let n=to(t.pattern);return je(e,n,r)}function yS(e,t,r){return B(e,t,r)?r:s.IsArray(r)?t.items.map((n,o)=>je(e,n,r[o])):Je(e,t)}function IS(e,t,r){return Z(t)?s.HasPropertyKey(e,t.$ref)?IS(e,e[t.$ref],r):(()=>{throw new Error("Unable to Deref target")})():t}function VF(e,t,r){if(!(w(t)&&s.IsObject(r)))return 0;let n=s.Keys(r);return s.Entries(t.properties).reduce((i,[a,m])=>{let c=K(m)&&s.IsEqual(m.const,r[a])?100:0,p=B(e,m,r[a])?10:0,f=n.includes(a)?1:0;return i+(c+p+f)},0)}function hS(e,t,r){let n=t.anyOf.map(a=>IS(e,a,r)),[o,i]=[n[0],0];for(let a of n){let m=VF(e,a,r);m>i&&(o=a,i=m)}return o}function JF(e,t,r){let n=F(Yr(t.anyOf)),o=hS(e,n,r);return je(e,o,r)}function bS(e,t,r){return B(e,t,r)?ue(r):bt(t)?Je(e,t):JF(e,t,r)}function $S(e,t,r){if(B(e,t,r))return r;let n=$r(e,t,r);return B(e,t,n)?n:Je(e,t)}function XF(e,t,r){if(Ne.IsDate(r)||Ne.IsMap(r)||Ne.IsSet(r)||Ne.IsTypeArray(r)||s.IsConstructor(r)||s.IsFunction(r))throw new Mr(e,t,r,"Value is not repairable")}function QF(e,t,r){if(be(t)||$e(t)||yt(t))throw new Mr(e,t,r,"Type is not repairable")}function YF(e,t,r){return s.IsUndefined(r)&&!Bt(t)?Je(e,t):r}function ZF(e,t,r){return ei(t)?B(e,t,r)?r:Je(e,t):r}function je(e,t,r){XF(e,t,r),QF(e,t,r);let n=YF(e,t,r),o=H(t)?cS(e,t,n):Se(t)?pS(e,t,n):P(t)?fS(e,t,n):w(t)?dS(e,t,n):te(t)?lS(e,t,n):Z(t)?gS(e,t,n):se(t)?xS(e,t,n):j(t)?yS(e,t,n):E(t)?bS(e,t,n):$S(e,t,n);return ZF(e,t,o)}function ES(...e){let[t,r,n]=q.Match(e,{3:(i,a,m)=>[i,a,m],2:(i,a)=>[{},i,a]}),o=je(t,r,n);return Bs(t,r,o),o}var $o={};At($o,{Assert:()=>Bs,Check:()=>B,Clean:()=>er,Clone:()=>ue,Convert:()=>$r,Create:()=>Je,Decode:()=>ME,Default:()=>on,Diff:()=>mS,Encode:()=>vE,Equal:()=>Ya,Errors:()=>Qt,HasCodec:()=>NE,Hash:()=>Za,Parse:()=>oS,Patch:()=>uS,Pointer:()=>sr,Repair:()=>ES});var o1=n1(lt,"hooks.json"),SS=64*1024,CS=30,kS=["PreToolUse","PostToolUse","UserPromptSubmit","SessionStart","Stop","PreCompact","SessionEnd"];function dPe(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return"the rewrite is not a JSON object";if(!(e===null||typeof e!="object"))try{if($o.Check(e,t))return;let r=[...$o.Errors(e,t)][0];if(!r)return"the rewrite does not match the tool's schema";let n="instancePath"in r?String(r.instancePath):"";return`the rewrite does not match the tool's schema${n&&n!=="/"?` at \`${n}\``:""}: ${r.message}`}catch(r){return`the tool's schema could not be checked: ${r instanceof Error?r.message:String(r)}`}}function lPe(e=o1){let t=[],r={hooks:{}};try{if(!t1(e))return{config:r,diagnostics:t};let n=r1(e,"utf8");if(Buffer.byteLength(n,"utf8")>SS)return t.push({source:e,message:`skipped: larger than ${SS} bytes`}),{config:r,diagnostics:t};let o=JSON.parse(n),i=i1(o);for(let a of i.diagnostics)t.push({source:e,message:a});return{config:i.config,diagnostics:t}}catch(n){return t.push({source:e,message:`unreadable: ${n instanceof Error?n.message:String(n)}`}),{config:r,diagnostics:t}}}function i1(e){let t=[],r={hooks:{}};if(e===null||typeof e!="object"||Array.isArray(e))return{config:r,diagnostics:["expected a JSON object with a `hooks` key"]};let n=e.hooks;if(n===void 0)return{config:r,diagnostics:["no `hooks` key"]};if(n===null||typeof n!="object"||Array.isArray(n))return{config:r,diagnostics:["`hooks` must be an object keyed by event name"]};for(let[o,i]of Object.entries(n)){if(!kS.includes(o)){t.push(`unknown event \`${o}\` \u2014 supported: ${kS.join(", ")}`);continue}if(!Array.isArray(i)){t.push(`\`${o}\` must be an array of matchers`);continue}let a=[];for(let m of i){let c=s1(m,o,t);c&&a.push(c)}a.length&&(r.hooks[o]=a)}return{config:r,diagnostics:t}}function s1(e,t,r){if(e===null||typeof e!="object"||Array.isArray(e)){r.push(`\`${t}\`: a matcher must be an object`);return}let n=e,o=Array.isArray(n.hooks)?n.hooks:void 0;if(!o){r.push(`\`${t}\`: a matcher needs a \`hooks\` array`);return}let i=[];for(let m of o){if(m===null||typeof m!="object")continue;let c=m,p=typeof c.type=="string"?c.type:"command";if(p!=="command"){r.push(`\`${t}\`: only \`type: "command"\` is supported, got \`${p}\``);continue}if(typeof c.command!="string"||!c.command.trim()){r.push(`\`${t}\`: a hook needs a non-empty \`command\``);continue}let f=typeof c.timeout=="number"&&Number.isFinite(c.timeout)&&c.timeout>0?c.timeout:void 0;i.push({type:"command",command:c.command,timeout:f,...c.async===!0?{async:!0}:{},...c.once===!0?{once:!0}:{}})}return i.length?{matcher:typeof n.matcher=="string"?n.matcher:void 0,hooks:i}:void 0}function a1(e,t,r){let n=e.hooks[t];return n?n.filter(o=>{let i=o.matcher?.trim();if(!i||i==="*")return!0;if(r===void 0)return!1;let a=r.toLowerCase();return i.split("|").map(m=>m.trim().toLowerCase()).filter(Boolean).includes(a)}):[]}function TS(e,t,r={cwd:process.cwd()}){let n=r.timeoutS??CS;return new Promise(o=>{let i="",a="",m=!1,c=!1,p=e1(e,{cwd:r.cwd,shell:!0,stdio:["pipe","pipe","pipe"]});p.stdin?.on("error",()=>{}),p.stdout?.on("error",()=>{}),p.stderr?.on("error",()=>{});let f=setTimeout(()=>{m=!0,p.kill("SIGKILL")},n*1e3);p.stdout?.on("data",g=>{i+=g.toString("utf8")}),p.stderr?.on("data",g=>{a+=g.toString("utf8")});let d=g=>{c||(c=!0,clearTimeout(f),o({code:g,stdout:i,stderr:a,timedOut:m}))};p.on("error",g=>{a+=g.message,d(null)}),p.on("close",g=>d(g));try{p.stdin?.end(JSON.stringify(t))}catch{}})}function m1(e){let{code:t,stdout:r,stderr:n,timedOut:o}=e,i=n.trim();if(o)return{block:!1,error:`timed out after ${CS}s and was killed`};let a=u1(r),m=a?.hookSpecificOutput,c=typeof m?.additionalContext=="string"?m.additionalContext:typeof a?.additionalContext=="string"?a.additionalContext:void 0,p=typeof m?.permissionDecision=="string"?m.permissionDecision:void 0,f=typeof m?.permissionDecisionReason=="string"?m.permissionDecisionReason:void 0,d=m?.updatedInput,g=d!==null&&typeof d=="object"&&!Array.isArray(d)?d:void 0;return p==="deny"||p==="block"?{block:!0,reason:f||i||"denied by a hook",context:c}:p==="allow"?{block:!1,context:c,updatedInput:g}:t===2?{block:!0,reason:i||"blocked by a hook",context:c}:t!==0?{block:!1,context:c,updatedInput:g,error:`exited ${t===null?"without a status":t}${i?`: ${i}`:""}`}:!a&&r.trim()?{block:!1,context:r.trim()}:{block:!1,context:c,updatedInput:g}}function u1(e){let t=e.trim();if(t.startsWith("{"))try{let r=JSON.parse(t);return r&&typeof r=="object"&&!Array.isArray(r)?r:void 0}catch{return}}var Nc=new Set;function gPe(){Nc.clear()}async function xPe(e,t,r,n){let o=a1(e,t,r.tool_name);if(!o.length)return{outcome:{block:!1},ran:0};let i=[],a=0,m,c,p;for(let f of o)for(let d of f.hooks){if(d.once){let h=`${t}\0${d.command}`;if(Nc.has(h))continue;Nc.add(h)}if(a+=1,d.async){TS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}).catch(()=>{});continue}let g=await TS(d.command,r,{cwd:n.cwd,timeoutS:d.timeout}),y=m1(g);y.context&&i.push(y.context),y.error&&(c=y.error),y.updatedInput&&(p=y.updatedInput),y.block&&!m&&(m=y)}return m?{outcome:{block:!0,reason:m.reason,context:i.join(`
|
|
8
|
+
|
|
9
|
+
`)||void 0},ran:a}:{outcome:{block:!1,context:i.join(`
|
|
10
|
+
|
|
11
|
+
`)||void 0,error:c,updatedInput:p},ran:a}}import{existsSync as RS,readFileSync as c1}from"node:fs";function p1(e){return`${e}/.howtofix/mcp.json`}function Dc(e,t){if(!RS(e))return{};try{let n=JSON.parse(c1(e,"utf8"))?.mcpServers;return!n||typeof n!="object"||Array.isArray(n)?{}:n}catch(r){return t.push(`${e}: ${r instanceof Error?r.message:String(r)}`),{}}}function $Pe(e){let t=[];return Dc(ji(e??lt),t)}function EPe(e){let t=[],r=Dc(ji(e.agentDir??lt),t),n=p1(e.cwd),o=e.projectTrusted&&RS(n)?n:void 0,i=o?Dc(o,t):{},a=ji(e.agentDir??lt),m=new Map;for(let[c,p]of Object.entries(r))m.set(c,{name:c,config:p,source:a,scope:"global"});for(let[c,p]of Object.entries(i))m.set(c,{name:c,config:p,source:o,scope:"project"});return{servers:[...m.values()],errors:t,projectConfig:o}}import{mkdirSync as f1,readdirSync as d1,readFileSync as l1,renameSync as g1,unlinkSync as x1,writeFileSync as y1}from"node:fs";import{join as wS}from"node:path";var I1=180*1e3,CPe="presence";function PS(e,t){return wS(e.dir,`${t.replace(/[^A-Za-z0-9._-]/g,"_")}.json`)}function h1(e,t=Date.now()){let r;try{r=d1(e.dir)}catch{return[]}let n=[];for(let o of r)if(o.endsWith(".json"))try{let i=JSON.parse(l1(wS(e.dir,o),"utf8"));if(typeof i?.id!="string"||typeof i?.cwd!="string"||typeof i?.at!="number"||t-i.at>=I1)continue;n.push({id:i.id,cwd:i.cwd,host:typeof i.host=="string"?i.host:"",pid:typeof i.pid=="number"?i.pid:0,at:i.at,...typeof i.activity=="string"&&i.activity?{activity:i.activity}:{}})}catch{}return n.sort((o,i)=>i.at-o.at)}function RPe(e,t){f1(e.dir,{recursive:!0});let r=PS(e,t.id),n=`${r}.${process.pid}.tmp`;y1(n,JSON.stringify(t,null,2)),g1(n,r)}function wPe(e,t){try{x1(PS(e,t))}catch{}}function AS(e,t,r,n=Date.now()){return h1(e,n).filter(o=>o.cwd===t&&o.id!==r)}import{Type as Xe}from"@netrodev/hxf-ai";import{defineTool as nm}from"@netrodev/hxf-coding-agent";import{relative as P1,join as A1}from"node:path";import{mkdirSync as O1,writeFileSync as M1}from"node:fs";import{existsSync as OPe,mkdirSync as b1,readFileSync as $1,renameSync as E1,writeFileSync as S1}from"node:fs";import{dirname as k1,isAbsolute as T1,join as vS,relative as C1,resolve as OS,sep as MS}from"node:path";var R1=1800*1e3,w1=vS(".howtofix","claims.json");function FS(e){return vS(e,w1)}function jc(e,t){try{let r=$1(FS(e),"utf8"),n=JSON.parse(r);return(Array.isArray(n.claims)?[...n.claims]:[]).filter(i=>typeof i?.path=="string"&&typeof i?.holder=="string"&&typeof i?.at=="number"&&t-i.at<R1)}catch{return[]}}function NS(e,t){let r=FS(e);b1(k1(r),{recursive:!0});let n=`${r}.${process.pid}.tmp`;S1(n,JSON.stringify({version:1,claims:[...t]},null,2)),E1(n,r)}function DS(e,t){return T1(t)?OS(t):OS(e,t)}function LS(e,t){if(e===t)return!0;let r=n=>n.endsWith(MS)?n:n+MS;return e.startsWith(r(t))||t.startsWith(r(e))}function jS(e){let t=e.now??Date.now(),r=jc(e.root,t),n=[],o=[],i=[];for(let a of e.paths){if(!a.trim())continue;let m=DS(e.root,a.trim()),c=r.find(p=>p.holder!==e.holder&&LS(p.path,m));if(c){o.push({path:Lc(e.root,m),by:c.holder,reason:c.reason||"no reason given"});continue}n.push(Lc(e.root,m)),i.push({path:m,holder:e.holder,reason:e.reason,at:t})}if(i.length>0){let a=r.filter(m=>m.holder!==e.holder||!i.some(c=>c.path===m.path));NS(e.root,[...a,...i])}return{granted:n,conflicts:o}}function _S(e,t,r){let n=Date.now(),o=jc(e,n),i=r?.length?r.map(c=>DS(e,c.trim())).filter(Boolean):void 0,a=[],m=[];for(let c of o){let p=c.holder===t,f=i===void 0||i.some(d=>LS(c.path,d));p&&f?m.push(Lc(e,c.path)):a.push(c)}return NS(e,a),m}function _c(e,t=Date.now()){return jc(e,t)}function Lc(e,t){let r=C1(e,t);return r&&!r.startsWith("..")?r:t}var qc;function UPe(e){qc=e}var GPe=nm({name:"think",label:"think",description:"Private scratchpad. The text is not shown to the user. Use it before a non-obvious step.",promptSnippet:"think: private notes, not shown to the user",parameters:Xe.Object({thoughts:Xe.String({description:"Private notes"})}),async execute(){return{content:[{type:"text",text:"noted"}],details:{recorded:!0}}}}),BPe=nm({name:"ask",label:"ask",description:"Ask the user one question and wait for a selected answer. Use this instead of guessing when a choice blocks the task.",promptSnippet:"ask: ask the user to pick one option",parameters:Xe.Object({question:Xe.String(),options:Xe.Array(Xe.String(),{minItems:2})}),async execute(e,t){if(!qc)return{content:[{type:"text",text:"cancelled"}],details:{answer:"cancelled"}};let r=await qc(t.question,t.options);return{content:[{type:"text",text:r}],details:{answer:r}}}}),Ai;function KPe(e){Ai=e}var HPe=nm({name:"sessions",label:"sessions",description:"See the other HowToFix sessions working in this workspace, what they hold, and what they are doing. Use it to find who is blocking a claim, or to tell another session to release a file. Send a message with message + to.",promptSnippet:"sessions: other CLI sessions, and who holds what",parameters:Xe.Object({message:Xe.Optional(Xe.String({description:"Message text to leave for another session."})),to:Xe.Optional(Xe.String({description:"Session id to send the message to. Use `all` for every other session."}))}),async execute(e,t){let r=Ai,n=r?.presenceDir?.();if(!r||!n)return{content:[{type:"text",text:"the session registry is unavailable here"}],details:{}};let o=r.selfId?.()??"",i=r.root(),a=AS({dir:n},i);if(t.message&&t.message.trim()){let c=t.to?.trim()||"all",p=a.filter(f=>f.id!==o&&(c==="all"||f.id===c));if(p.length===0)return{content:[{type:"text",text:"no other session in this workspace to message"}],details:{sent:0}};for(let f of p){let d=A1(n,`${f.id.replace(/[^A-Za-z0-9._-]/g,"_")}.inbox`);try{O1(n,{recursive:!0}),M1(d,`${JSON.stringify({from:o,at:Date.now(),text:t.message.trim()})}
|
|
12
|
+
`,{flag:"a"})}catch{}}return{content:[{type:"text",text:`left a message for ${p.map(f=>f.id).join(", ")}`}],details:{sent:p.length}}}if(a.length===0)return{content:[{type:"text",text:"no other session in this workspace"}],details:{sessions:[]}};let m=a.map(c=>{let p=c.id===o?"this session":c.id,f=_c(i).filter(y=>y.holder===`session:${c.id}`),d=c.activity?` \u2014 ${c.activity}`:"",g=f.length>0?`
|
|
13
|
+
holds:
|
|
14
|
+
${f.map(y=>` ${US(i,y.path)} \u2014 ${y.reason}`).join(`
|
|
15
|
+
`)}`:"";return` ${p} (pid ${c.pid}${c.id===o?"":`, seen ${Math.round((Date.now()-c.at)/1e3)}s ago`})${d}${g}`});return{content:[{type:"text",text:`sessions in ${i}:
|
|
16
|
+
${m.join(`
|
|
17
|
+
`)}`}],details:{sessions:a}}}});function v1(e){let t=[];if(e.granted.length>0&&t.push(`claimed: ${e.granted.join(", ")}`),e.conflicts.length>0){t.push(""),t.push("refused \u2014 another agent is working on these:");for(let r of e.conflicts)t.push(` ${r.path} \u2014 held by ${r.by}: ${r.reason}`);t.push(""),t.push("Wait for the holder to release it, or work on something else. Do not edit a refused path.")}return t.length===0&&t.push("nothing to claim"),{text:t.join(`
|
|
18
|
+
`),isError:e.conflicts.length>0}}var qS=nm({name:"claim",label:"claim",description:"Claim files or directories before editing them, so a parallel agent cannot overwrite your work. Refused paths are held by someone else \u2014 do not edit them. Pass no paths to list every claim in this workspace.",promptSnippet:"claim: reserve files before editing",parameters:Xe.Object({paths:Xe.Optional(Xe.Array(Xe.String(),{description:"Files or directories to claim. Omit to list the current claims."})),reason:Xe.Optional(Xe.String({description:"Why you are taking them, shown to a refused agent."})),release:Xe.Optional(Xe.Boolean({description:"Release these paths instead of claiming them. Omit paths to release everything you hold."}))}),async execute(e,t){if(!Ai)return{content:[{type:"text",text:"claims are unavailable in this session"}],details:{},isError:!0};let r=Ai.root(),n=Ai.holder();if(t.release){let m=_S(r,n,t.paths);return{content:[{type:"text",text:m.length>0?`released: ${m.join(", ")}`:"you held nothing matching that"}],details:{released:m}}}if(!t.paths||t.paths.length===0){let m=_c(r);return m.length===0?{content:[{type:"text",text:"no active claims in this workspace"}],details:{claims:[]}}:{content:[{type:"text",text:m.map(p=>`${p.holder===n?"(you) ":""}${US(r,p.path)} \u2014 ${p.reason}`).join(`
|
|
19
|
+
`)}],details:{claims:m}}}let o=jS({root:r,holder:n,reason:t.reason??"no reason given",paths:t.paths}),{text:i,isError:a}=v1(o);return{content:[{type:"text",text:i}],isError:a,details:o}}});function US(e,t){let r=P1(e,t);return r&&!r.startsWith("..")?r:t}import{StringEnum as F1}from"@netrodev/hxf-ai";import{defineTool as N1}from"@netrodev/hxf-coding-agent";var O={};At(O,{Any:()=>Qn,Array:()=>xt,BigInt:()=>ti,Boolean:()=>Xs,Call:()=>Lh,Capitalize:()=>Kh,Codec:()=>Vs,Conditional:()=>Yh,Constructor:()=>ur,ConstructorParameters:()=>eb,Cyclic:()=>fr,Decode:()=>Gl,DecodeBuilder:()=>Zo,Dependent:()=>$n,Encode:()=>Bl,EncodeBuilder:()=>Yo,Enum:()=>ql,Evaluate:()=>Be,Exclude:()=>rb,Extends:()=>et,ExtendsResult:()=>M,Extract:()=>ob,Function:()=>cr,Generic:()=>Vr,Identifier:()=>ri,Immutable:()=>Kl,Index:()=>mb,Infer:()=>Qo,InstanceType:()=>Mb,Instantiate:()=>Dt,Integer:()=>Sn,Interface:()=>Ih,Intersect:()=>nt,IsAny:()=>ye,IsArray:()=>H,IsBigInt:()=>kt,IsBoolean:()=>ft,IsCall:()=>lo,IsCodec:()=>pt,IsConstructor:()=>be,IsCyclic:()=>ie,IsDependent:()=>Ee,IsEnum:()=>Se,IsEnumValue:()=>_l,IsFunction:()=>$e,IsGeneric:()=>Xn,IsIdentifier:()=>Vl,IsImmutable:()=>En,IsInfer:()=>ve,IsInteger:()=>Ge,IsIntersect:()=>P,IsKind:()=>k,IsLiteral:()=>K,IsNever:()=>yt,IsNull:()=>lr,IsNumber:()=>le,IsObject:()=>w,IsOptional:()=>Oe,IsParameter:()=>Ql,IsReadonly:()=>Pr,IsRecord:()=>te,IsRef:()=>Z,IsRefine:()=>ei,IsRest:()=>Zr,IsSchema:()=>de,IsString:()=>Le,IsSymbol:()=>gr,IsTemplateLiteral:()=>se,IsThis:()=>ca,IsTuple:()=>j,IsUndefined:()=>Bt,IsUnion:()=>E,IsUnknown:()=>Me,IsUnsafe:()=>Ws,IsVoid:()=>Ct,KeyOf:()=>Fb,Literal:()=>U,Lowercase:()=>Hh,Mapped:()=>Gb,Module:()=>O$,Never:()=>re,NonNullable:()=>zb,Null:()=>Zn,Number:()=>Tt,Object:()=>A,Omit:()=>Vb,Optional:()=>Ml,Parameter:()=>kn,Parameters:()=>Qb,Partial:()=>Zb,Pick:()=>s$,Readonly:()=>Hl,ReadonlyObject:()=>Sc,ReadonlyType:()=>u$,Record:()=>io,RecordKey:()=>so,RecordPattern:()=>Fe,RecordValue:()=>me,Ref:()=>qe,Refine:()=>zl,Required:()=>T$,Rest:()=>Cn,ReturnType:()=>R$,Script:()=>N$,String:()=>Ze,Symbol:()=>eo,TemplateLiteral:()=>LI,This:()=>ua,Tuple:()=>ke,Uncapitalize:()=>zh,Undefined:()=>ao,Union:()=>F,Unknown:()=>De,Unsafe:()=>Nl,Uppercase:()=>Wh,Void:()=>pa,With:()=>Ja});var D1={pending:"[ ]",in_progress:"[>]",completed:"[x]",dropped:"[-]"},L1=O.Object({op:F1(["init","start","done","drop","view"],{description:"init replaces the list; start/done/drop move one task; view reads it"}),items:O.Optional(O.Array(O.String(),{description:"Task labels for init. 5-10 words each, specific enough to execute without re-planning"})),task:O.Optional(O.String({description:"Exact label of the task to start, complete or drop"}))});function GS(e){if(e.length===0)return"Todo list is empty.";let t=e.filter(o=>o.status==="completed").length,r=e.map(o=>`${D1[o.status]} ${o.content}`),n=e.filter(o=>o.status==="pending"||o.status==="in_progress").length;return[`${t}/${e.length} done, ${n} open`,...r].join(`
|
|
20
|
+
`)}function j1(e,t,r,n){let o=e.map(i=>({...i}));switch(t){case"init":return!r||r.length===0?{todos:o,error:"init needs a non-empty items array"}:{todos:r.map(i=>({content:i,status:"pending"}))};case"view":return{todos:o};case"start":case"done":case"drop":{if(!n)return{todos:o,error:`${t} needs task`};let i=o.find(a=>a.content===n);if(!i)return{todos:o,error:`no task matches ${JSON.stringify(n)}`};if(t==="start"){for(let a of o)a.status==="in_progress"&&(a.status="pending");i.status="in_progress"}else i.status=t==="done"?"completed":"dropped";return{todos:o}}default:return{todos:o,error:`unknown op ${JSON.stringify(t)}`}}}function _1(e){let t=[];for(let r of e.sessionManager.getBranch()){if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="todo")continue;let o=n.details;o?.todos&&(t=o.todos)}return t}var BS=N1({name:"todo",label:"todo",description:"Track the plan for this task. Use `init` once with the whole plan (investigation through verification), then `start`/`done` as you go. Keep the list current so progress stays visible; do not re-init unless the plan materially changes.",promptSnippet:"todo: record and advance the plan for the current task",parameters:L1,async execute(e,t,r,n,o){let i=_1(o),{todos:a,error:m}=j1(i,t.op,t.items,t.task),c={op:t.op,todos:a,...m?{error:m}:{}};return{content:[{type:"text",text:m?`Error: ${m}
|
|
21
|
+
${GS(a)}`:GS(a)}],details:c,...m?{isError:!0}:{}}}});import{StringEnum as q1}from"@netrodev/hxf-ai";import{defineTool as U1}from"@netrodev/hxf-coding-agent";var vr=new Map,KS=2e3,HS=80;function zS(){return vr.size===0?"":["<shared-notes>","Working notes recorded with the `context` tool. They survive compaction and are visible to every agent on this task.",...[...vr].map(([t,r])=>`- ${t}: ${r}`),"</shared-notes>"].join(`
|
|
22
|
+
`)}function G1(e,t,r){if(e==="list")return vr.size===0?{text:"No notes."}:{text:[...vr].map(([n,o])=>`${n} = ${o}`).join(`
|
|
23
|
+
`)};if(!t)return{text:"Error: key is required",error:"key required"};if(t.length>HS)return{text:`Error: key longer than ${HS} characters`,error:"key too long"};if(e==="forget")return{text:vr.delete(t)?`Removed ${t}`:`No note named ${t}`};if(e==="set"){if(!r)return{text:"Error: value is required for set",error:"value required"};let n=r.length>KS?`${r.slice(0,KS)}\u2026`:r;return vr.set(t,n),{text:`Recorded ${t} (${vr.size} note${vr.size===1?"":"s"} held)`}}return{text:`Error: unknown op ${JSON.stringify(e)}`,error:"unknown op"}}var WS=U1({name:"context",label:"context",description:"Record a durable working note (a decision, a file's role, a fact you would otherwise re-derive). Notes survive context compaction and are visible to every agent on this task, including subagents. Use `set` to write, `list` to read, `forget` to remove.",promptSnippet:"context: durable notes shared with every agent on this task",parameters:O.Object({op:q1(["set","list","forget"],{description:"set writes a note, list reads all, forget removes one"}),key:O.Optional(O.String({description:"Short lookup key, e.g. 'auth-entrypoint'"})),value:O.Optional(O.String({description:"The fact to keep (for set)"}))}),async execute(e,t){let{text:r,error:n}=G1(t.op,t.key,t.value);return{content:[{type:"text",text:r}],details:{op:t.op,notes:Object.fromEntries(vr)},...n?{isError:!0}:{}}}});import{StringEnum as B1}from"@netrodev/hxf-ai";import{defineTool as K1}from"@netrodev/hxf-coding-agent";var VS="howtofix.goal",SOe="howtofix.goal.continue",JS=400,om=25,XS={active:"\u25CF",paused:"\u2016",done:"\u2713",cleared:"\u25CB"};function H1(e){if(!e||e.status==="cleared")return"No goal set.";let t=e.budget??om,r=[`${XS[e.status]} ${e.status}`,`${e.used}/${t} continuations`];return e.note&&r.push(e.note),`${r.join(" \xB7 ")}
|
|
24
|
+
${e.text}`}function kOe(e){if(!e||e.status==="cleared"||e.status==="done")return"";let t=e.budget??om,r=e.text.length>48?`${e.text.slice(0,47)}\u2026`:e.text;return`goal ${XS[e.status]} ${e.used}/${t} \xB7 ${r}`}function TOe(e){let t=["<goal>",e.text,`Status: ${e.status}.`];return e.status==="active"&&t.push("Work toward this goal until it is genuinely met. When it is, call the `goal` tool with",'op="complete" and a note naming the evidence; a command you ran or a file you checked.',"If you are blocked and cannot proceed, say so plainly instead of repeating an attempt."),t.push("</goal>"),t.join(`
|
|
25
|
+
`)}function COe(e){return["[goal] The goal is still open and you stopped without closing it:",` ${e.text}`,"","Continue from where you left off. Do not repeat work you already did. If the goal is met,",'call the `goal` tool with op="complete" and a note naming the evidence. Do not call it',"complete to escape a hard problem: if you cannot make progress, state what is blocking you.",`Continuations used: ${e.used}/${e.budget??om}.`].join(`
|
|
26
|
+
`)}var QS;function ROe(){return QS}function z1(e){QS=e}function wOe(e){if(!e)return{action:"stop",reason:"no goal",close:!1};if(e.status==="done")return{action:"stop",reason:"goal complete",close:!1};if(e.status==="cleared")return{action:"stop",reason:"goal cleared",close:!1};if(e.status==="paused")return{action:"stop",reason:"goal paused",close:!1};let t=e.budget??om;return e.used>=t?{action:"stop",reason:`budget exhausted (${t} continuations)`,close:!0}:{action:"continue"}}function W1(e,t,r,n,o){switch(t){case"view":return{goal:e};case"set":return r?.trim()?r.length>JS?{goal:e,error:`text longer than ${JS} characters`}:n!==void 0&&(!Number.isInteger(n)||n<1)?{goal:e,error:"budget must be a positive integer"}:{goal:{text:r.trim(),status:"active",used:0,...n===void 0?{}:{budget:n}}}:{goal:e,error:"set needs text"};case"pause":case"resume":case"complete":case"clear":return!e||e.status==="cleared"?{goal:e,error:"no goal to change"}:t==="resume"?e.status==="done"?{goal:e,error:"goal is complete; set a new one instead"}:{goal:{...e,status:"active",note:void 0}}:t==="pause"?{goal:{...e,status:"paused"}}:t==="clear"?{goal:{...e,status:"cleared"}}:o?.trim()?{goal:{...e,status:"done",note:o.trim()}}:{goal:e,error:"complete needs a note naming the evidence (a command you ran or a file you checked)"};default:return{goal:e,error:`unknown op ${JSON.stringify(t)}`}}}function V1(e){let t;for(let r of e.sessionManager.getBranch()){if(r.type==="custom"&&r.customType===VS){t=r.data;continue}if(r.type==="custom_message"&&r.customType===VS){t=r.details??t;continue}if(r.type!=="message")continue;let n=r.message;if(n.role!=="toolResult"||n.toolName!=="goal")continue;let o=n.details;o?.goal&&(t=o.goal)}return t}var J1=O.Object({op:B1(["set","view","pause","resume","complete","clear"],{description:"set starts a goal; complete closes it with evidence; pause/resume/clear manage it; view reads it"}),text:O.Optional(O.String({description:"The goal, in one sentence, as the user would state it (for set)"})),budget:O.Optional(O.Number({description:"Optional cap on automatic continuations before the run stops"})),note:O.Optional(O.String({description:"Evidence that the goal is met (required for complete)"}))}),POe=K1({name:"goal",label:"goal",description:"Track the goal for this session. The goal is already shown in your context every request, so you rarely need `view`. Call `complete` only when the goal is genuinely met, and pass a note naming the evidence. When a goal is active the harness continues the run if you stop without closing it, so closing it is how you stop.",promptSnippet:"goal: the session's objective, and how to close it",parameters:J1,async execute(e,t,r,n,o){let i=V1(o),{goal:a,error:m}=W1(i,t.op,t.text,t.budget,t.note);z1(a);let c=H1(a);return{content:[{type:"text",text:m?`Error: ${m}
|
|
27
|
+
${c}`:c}],details:{op:t.op,goal:a},...m?{isError:!0}:{}}}});import{existsSync as Bc,mkdirSync as YS,readFileSync as ZS}from"node:fs";import{dirname as ek,join as tk}from"node:path";import{defineTool as rk}from"@netrodev/hxf-coding-agent";function im(){return{state:"inactive",wasActive:!1}}function X1(e){return e?e.state==="pending"?{...e,state:"inactive"}:{...e}:im()}function DOe(e){return e.state!=="inactive"?e:{...e,state:"pending"}}function Q1(e){return e.state!=="pending"?e:{state:"active",wasActive:!0}}function Y1(e){return e.state!=="inactive"?e:{state:"active",wasActive:!0}}function Z1(e){return e.state!=="active"?e:{...e,state:"inactive"}}function LOe(e){return e.state==="inactive"?e:{...e,state:"inactive"}}function sm(e){return e.state==="active"}function eN(e,t){return e===t}function tN(e,t){return["<plan-mode>","Plan mode is active. Do not make any edits or writes to the system.",t?`A plan file exists at ${e}. Read it and refine it with the \`edit\` tool.`:`No plan is written yet. Write yours to ${e} with the \`write\` tool.`,"That file is the only path you may edit.","Explore first: read, search, and run read-only commands until the approach is clear.","End your turn with either `ask` to clarify a requirement, or `exit_plan_mode` to present","the plan for approval. Do not start implementing before the plan is approved.","</plan-mode>"].join(`
|
|
28
|
+
`)}function rN(e){return`Rejected: file edits are not allowed in plan mode. The only editable file is the plan file (${e}). Present the plan with exit_plan_mode first.`}var it,st=im(),Gc;function jOe(){return st}function _Oe(){return it}function qOe(){return sm(st)}function nk(){if(!(!it||!Bc(it)))try{let e=ZS(it,"utf8");return e.trim()?e:void 0}catch{return}}function ok(){return nk()!==void 0}function UOe(){return st.state==="inactive"?"":st.state==="pending"?"plan pending":ok()?"plan \u25CF ready":"plan \u25CF planning"}function ik(){return Gc?tk(Gc,"plan_mode.json"):void 0}function nN(){let e=ik();if(e)try{YS(ek(e),{recursive:!0}),or(e,JSON.stringify(st))}catch{}}function oN(){let e=ik();if(!e||!Bc(e))return im();try{return X1(JSON.parse(ZS(e,"utf8")))}catch{return im()}}function iN(e){Gc=e,it=tk(e,"plan.md"),st=oN()}function Kc(e){return st=e,nN(),st}function GOe(){return e=>{e.on("tool_call",async t=>{if(!sm(st)||t.toolName!=="edit"&&t.toolName!=="write")return;let r=t.input?.path;if(typeof r=="string"&&!(!it||eN(r,it)))return{block:!0,reason:rN(it)}})}}function BOe(){return e=>{e.on("session_start",async(t,r)=>{iN(r.sessionManager.getSessionDir())}),e.on("before_agent_start",async()=>{st.state==="pending"&&Kc(Q1(st))}),e.on("context_with_system",async t=>{if(!sm(st)||!it)return;let r=t.messages[0];if(!r||r.role!=="system")return;let n=tN(it,ok()),o=`${typeof r.content=="string"?r.content:""}
|
|
29
|
+
|
|
30
|
+
${n}`;return{messages:t.messages.map(a=>a===r?{...r,content:o}:a)}})}}var Uc=2e4;function sN(){if(it){try{YS(ek(it),{recursive:!0}),Bc(it)||or(it,"")}catch{return}return it}}var KOe=rk({name:"enter_plan_mode",label:"enter_plan_mode",description:"Enter plan mode to design an approach before writing code. Use it when a task has genuine ambiguity; several reasonable designs, or a restructuring where the wrong approach wastes significant effort. Do not use it for a clear fix, a rename, or a task that follows existing conventions. The user must approve entering.",promptSnippet:"enter_plan_mode: design first when the approach is genuinely ambiguous",parameters:O.Object({}),async execute(e,t,r,n,o){if(st.state!=="inactive")return{content:[{type:"text",text:`Plan mode is already ${st.state}.`}],details:{}};if(!o.hasUI)return{content:[{type:"text",text:"Plan mode needs an interactive session: there is no one to approve the plan. Proceed normally."}],details:{},isError:!0};if(!await o.ui.confirm("Enter plan mode?","The agent will explore and design an approach before editing anything."))return{content:[{type:"text",text:"The user declined plan mode. Proceed normally."}],details:{}};Kc(Y1(st));let a=sN();return{content:[{type:"text",text:["Plan mode is active. Edits are blocked except for the plan file.",a?`Write your plan to ${a}.`:"Write your plan to the session plan file."].join(`
|
|
31
|
+
`)}],details:{planFile:a}}}}),HOe=rk({name:"exit_plan_mode",label:"exit_plan_mode",description:"Present your plan for approval when you have finished planning. The plan is read from the plan file on disk, so write the file first. If the user asks for changes, stay in plan mode and revise it.",promptSnippet:"exit_plan_mode: present the written plan for approval",parameters:O.Object({}),executionMode:"sequential",async execute(e,t,r,n,o){if(!sm(st))return{content:[{type:"text",text:"Plan mode is not active."}],details:{},isError:!0};let i=nk();if(!i)return{content:[{type:"text",text:`No plan has been written yet. Write it to ${it??"the plan file"} before exiting plan mode.`}],details:{},isError:!0};if(!o.hasUI)return{content:[{type:"text",text:"Plan approval needs an interactive session."}],details:{},isError:!0};let a=i.length>Uc?`${i.slice(0,Uc)}
|
|
32
|
+
\u2026 (${i.length-Uc} more characters)`:i;return await o.ui.confirm("Approve this plan?",a)?(Kc(Z1(st)),{content:[{type:"text",text:"Plan approved. You may now implement it."}],details:{approved:!0,planFile:it}}):{content:[{type:"text",text:"The user did not approve the plan. Stay in plan mode, revise the plan file with the feedback, and present it again."}],details:{approved:!1}}}});function Eo(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>{let r=t;return r.type==="text"&&typeof r.text=="string"?r.text:""}).join(`
|
|
33
|
+
`):e==null?"":String(e)}function am(e,t){if(Array.isArray(e)){let r=e.map(o=>({...o})),n=r.filter(o=>o.type==="text");if(n.length>0){n[0].text=t;for(let o of n.slice(1))o.text="";return r}return[...r,{type:"text",text:t}]}return t}function sk(){return e=>{e.on("context_with_system",async t=>{let r=zS();if(!r)return;let n=t.messages[0];if(!n||n.role!=="system")return;let o=`${Eo(n.content)}
|
|
34
|
+
|
|
35
|
+
${r}`;return{messages:t.messages.map(a=>a===n?{...n,content:am(n.content,o)}:a)}})}}var aN=/^m(\d{4})$/,mN=/^b([1-9]\d*)$/,uN=/^@([1-9]\d*)@$/,cN=/^@b([1-9]\d*)@$/,ak="dcp-message-id";function Hc(){return{nextRef:1,keyToRef:{},refToKey:{}}}function an(e,t="xml"){let r=t==="compact"?Number.MAX_SAFE_INTEGER:9999;if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`Message ID index out of bounds: ${e}. Supported range is 1-${r}.`);return t==="compact"?`@${e}@`:`m${e.toString().padStart(4,"0")}`}function vn(e,t="xml"){if(!Number.isInteger(e)||e<1)throw new Error(`Invalid block ID: ${e}`);return t==="compact"?`@b${e}@`:`b${e}`}function mk(e,t="xml"){let n=e.trim().toLowerCase().match(t==="compact"?uN:aN);if(!n)return null;let o=Number.parseInt(n[1],10);if(!Number.isSafeInteger(o))return null;let i=t==="compact"?Number.MAX_SAFE_INTEGER:9999;return o<1||o>i?null:o}function uk(e,t="xml"){let n=e.trim().toLowerCase().match(t==="compact"?cN:mN);if(!n)return null;let o=Number.parseInt(n[1],10);return Number.isSafeInteger(o)?o:null}function zc(e,t="xml"){let r=e.trim().toLowerCase(),n=mk(r,t);if(n!==null)return{kind:"message",ref:an(n,t),index:n};let o=uk(r,t);return o!==null?{kind:"compressed-block",ref:vn(o,t),blockId:o}:null}function ck(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Wc(e){return!e.includes("<dcp-message-id")&&!e.includes("</dcp-message-id")?e:e.replace(/<dcp-message-id(?:\s[^>]*)?>[\s\S]*?<\/dcp-message-id>/gi,"").replace(/<dcp-message-id(?:\s[^>]*)?>[mb]?\d{0,6}/gi,"").replace(/<\/?dcp-message-id(?:\s[^>]*)?>?/gi,"")}function Oi(e,t,r="xml"){if(r==="compact"){if(e==="BLOCKED")return`
|
|
36
|
+
@blocked@`;let o=t?.priority;return`
|
|
37
|
+
${e}${o?` [${o}]`:""}`}let n=Object.entries(t||{}).sort(([o],[i])=>o.localeCompare(i)).map(([o,i])=>o.trim().length===0||typeof i!="string"||i.length===0?"":` ${o}="${ck(i)}"`).join("");return`
|
|
38
|
+
<${ak}${n}>${e}</${ak}>`}function pN(e){return e.role==="user"||e.role==="assistant"||e.role==="toolResult"}function pk(e){let t=new Map;return e.map(r=>{if(!pN(r))return null;let n=r.role==="toolResult"?`toolResult:${r.toolCallId}`:`${r.role}:${r.timestamp}`,o=t.get(n)??0;return t.set(n,o+1),r.role==="toolResult"?n:`${n}#${o}`})}function Vc(e,t){let r=0;for(let n of pk(t)){if(n===null||e.keyToRef[n]!==void 0)continue;let o=fN(e);e.keyToRef[n]=o,e.refToKey[String(o)]=n,r++}return r}function fN(e){let t=Number.isInteger(e.nextRef)?Math.max(1,e.nextRef):1;for(;t<=9999;){if(e.refToKey[String(t)]===void 0)return e.nextRef=t+1,t;t++}throw new Error(`Message ID alias capacity exceeded. Cannot allocate more than ${an(9999)} aliases in this session.`)}function mn(e,t){return pk(t).map(r=>r===null?null:e.keyToRef[r]??null)}import{Type as Fn}from"@netrodev/hxf-ai";import{defineTool as dN}from"@netrodev/hxf-coding-agent";var So="[Compressed conversation section]";function Mi(e){return Math.round(e.length/4)}function Jc(e){let t=e.prune.messages.nextBlockId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextBlockId=2,1):(e.prune.messages.nextBlockId=t+1,t)}function Xc(e){let t=e.prune.messages.nextRunId;return!Number.isInteger(t)||t<1?(e.prune.messages.nextRunId=2,1):(e.prune.messages.nextRunId=t+1,t)}function Qc(e,t,r="xml"){let n=Oi(vn(e,r),void 0,r),o=t.trim();return o.length===0?`${So}
|
|
39
|
+
${n}`:`${So}
|
|
40
|
+
${o}
|
|
41
|
+
|
|
42
|
+
${n}`}function Fr(e){return e.prune.messages.blocks.filter(t=>t.active).map(t=>({blockId:t.blockId,anchorIndex:t.anchorIndex,coveredIndices:t.coveredIndices,summary:t.summary}))}function Yc(e,t,r,n,o,i,a){let m=e.prune.messages,c=[...new Set(a.filter(b=>Number.isInteger(b)&&b>0))],p=new Set;for(let b of m.blocks)if(b.active)for(let C of b.coveredIndices)p.add(C);let f=new Set(r.indices);for(let b of c){let C=m.blocks.find(N=>N.blockId===b);if(C)for(let N of C.coveredIndices)f.add(N)}let d=[...f].sort((b,C)=>b-C),g=d.filter(b=>!p.has(b)),y=0;for(let b of g)y+=r.tokenByIndex.get(b)??0;let h={blockId:o,runId:t.runId,active:!0,deactivatedByUser:!1,mode:t.mode,topic:t.topic,startId:t.startId,endId:t.endId,anchorIndex:n,compressedTokens:y,summaryTokens:Mi(i),coveredIndices:d,consumedBlockIds:c,parentBlockIds:[],createdAt:Date.now(),summary:i};m.blocks.push(h);let I=Date.now();for(let b of c){let C=m.blocks.find(N=>N.blockId===b);!C||!C.active||(C.active=!1,C.deactivatedAt=I,C.deactivatedByBlockId=o,C.parentBlockIds.includes(o)||C.parentBlockIds.push(o))}return e.stats.totalCompressTokens+=y,{compressedTokens:y,coveredIndices:d,newlyCoveredIndices:g}}function dk(e,t="xml"){let r=[],n=t==="compact"?/@b([1-9]\d*)@/gi:/\(b(\d+)\)/gi,o;for(;(o=n.exec(e))!==null;){let i=Number.parseInt(o[1],10);Number.isInteger(i)&&r.push({raw:o[0],blockId:i,startIndex:o.index,endIndex:o.index+o[0].length})}return r}function lk(e){if(typeof e.topic!="string"||e.topic.trim().length===0)throw new Error("topic is required and must be a non-empty string");if(!Array.isArray(e.content)||e.content.length===0)throw new Error("content is required and must be a non-empty array");for(let t=0;t<e.content.length;t++){let r=e.content[t],n=`content[${t}]`;if(typeof r?.startId!="string"||r.startId.trim().length===0)throw new Error(`${n}.startId is required and must be a non-empty string`);if(typeof r?.endId!="string"||r.endId.trim().length===0)throw new Error(`${n}.endId is required and must be a non-empty string`);if(typeof r?.summary!="string"||r.summary.trim().length===0)throw new Error(`${n}.summary is required and must be a non-empty string`)}}function Zc(e,t,r,n){let o=new Set,i=new Map;for(let d of r)o.add(d.index),i.set(d.index,d.tokenCount??0);let a=fk(e,o,t.startId,"startId",n),m=fk(e,o,t.endId,"endId",n);if(a.index>m.index)throw new Error(`startId ${a.ref} appears after endId ${m.ref} in the conversation. Start must come before end.`);let c=[];for(let d of r)d.index>=a.index&&d.index<=m.index&&c.push(d.index);let p=new Set(c),f=e.prune.messages.blocks.filter(d=>d.active&&p.has(d.anchorIndex)).map(d=>d.blockId);return{startIdx:a.index,endIdx:m.index,indices:c,requiredBlockIds:f,tokenByIndex:i}}function fk(e,t,r,n,o){let i=zc(r,o);if(i===null){let m=o==="compact"?"@4@":"mNNNN",c=o==="compact"?"@b1@":"bN";throw new Error(`${n} is invalid. Use an injected message ID (${m}) or block ID (${c}).`)}let a;if(i.kind==="message")a=i.index;else{let m=e.prune.messages.blocks.find(c=>c.blockId===i.blockId&&c.active);a=m?m.anchorIndex:-1}if(a<0||!t.has(a))throw new Error(`${n} ${i.ref} is not available in the current conversation context. Choose an injected ID visible in context.`);return{ref:i.ref,index:a}}function gk(e,t,r,n="xml"){let i=[...e.map((m,c)=>{let p={startId:m.startId.trim(),endId:m.endId.trim(),summary:m.summary};return{index:c,entry:p,selection:Zc(t,p,r,n)}})].sort((m,c)=>m.selection.startIdx-c.selection.startIdx||m.selection.endIdx-c.selection.endIdx||m.index-c.index),a=[];for(let m=1;m<i.length;m++){let c=i[m-1],p=i[m];!c||!p||p.selection.startIdx>c.selection.endIdx||a.push(`content[${c.index}] (${c.entry.startId}..${c.entry.endId}) overlaps content[${p.index}] (${p.entry.startId}..${p.entry.endId}). Overlapping ranges cannot be compressed in the same batch.`)}if(a.length>0)throw new Error(a.length===1?a[0]:a.map(m=>`- ${m}`).join(`
|
|
43
|
+
`))}function xk(e,t,r,n="xml"){let o=new Set(t.prune.messages.blocks.filter(i=>i.active).map(i=>i.blockId));return e.map((i,a)=>{let m={startId:i.startId.trim(),endId:i.endId.trim(),summary:i.summary},c=Zc(t,m,r,n),p=new Set(c.requiredBlockIds),f=dk(m.summary,n),d=new Set,g=`content[${a}]`;for(let y of f){if(d.has(y.blockId))throw new Error(`${g}.summary duplicates placeholder ${y.raw}`);if(d.add(y.blockId),!p.has(y.blockId))throw new Error(o.has(y.blockId)?`${g}.summary references ${y.raw}, which is outside the selected range`:`${g}.summary references ${y.raw}, which is not an active compressed block`)}for(let y of c.requiredBlockIds)if(!d.has(y)){let h=n==="compact"?`@b${y}@`:`(b${y})`;throw new Error(`${g}.summary is missing the required placeholder ${h}`)}return f})}function yk(e,t,r,n="xml"){return e.map((o,i)=>{let a={startId:o.startId.trim(),endId:o.endId.trim(),summary:o.summary},m=Zc(t,a,r,n);return{index:i,entry:a,selection:m,anchorIndex:m.startIdx}})}function lN(e){let t=e.match(/^\s*\[Compressed conversation(?: section)?(?: b\d+)?\]/i);return t?e.slice(t[0].length).replace(/^(?:\r?\n)+/,"").replace(/(?:\r?\n)*<dcp-message-id>b\d+<\/dcp-message-id>\s*$/i,"").replace(/(?:\r?\n)*@b[1-9]\d*@\s*$/i,"").replace(/(?:\r?\n)+$/,""):e}function gN(e,t,r){if(t.length===0)return{expanded:e,consumedBlockIds:[]};let n="",o=0,i=[];for(let a of t){let m=r.prune.messages.blocks.find(c=>c.blockId===a.blockId&&c.active);if(!m)throw new Error(`Compressed block not found: ${a.raw}`);n+=e.slice(o,a.startIndex),n+=lN(m.summary),o=a.endIndex,i.push(a.blockId)}return n+=e.slice(o),{expanded:n,consumedBlockIds:i}}function Ik(e,t,r,n="xml"){lk(e),gk(e.content,t,r,n);let o=xk(e.content,t,r,n),i=yk(e.content,t,r,n),a=Xc(t),m=[];for(let[c,p]of i.entries()){let f=o[c]??[],{expanded:d,consumedBlockIds:g}=gN(p.entry.summary,f,t),y=Jc(t),h=Qc(y,d,n),I=Yc(t,{topic:e.topic,startId:p.entry.startId,endId:p.entry.endId,mode:"range",runId:a},p.selection,p.anchorIndex,y,h,g);m.push({blockId:y,runId:a,coveredCount:I.coveredIndices.length,compressedTokens:I.compressedTokens,summaryTokens:Mi(h),expandedSummary:d})}return m}function xN(e){let t=e.format??"xml",r=an(1,t),n=vn(2,t);return dN({name:"compress",label:"compress",description:`Collapse conversation ranges into stored compressed summaries, each marked with "${So}". Copy startId and endId from the injected IDs in context (message IDs like ${r}, block IDs like ${n}); startId must come before endId. Ranges in one call must not overlap, and each summary must reference every required block placeholder exactly once.`,promptSnippet:"compress: replace a conversation range with a stored summary",parameters:Fn.Object({topic:Fn.String({description:"Short label (3-5 words) for display - e.g., 'Auth System Exploration'"}),content:Fn.Array(Fn.Object({startId:Fn.String({description:`Message or block ID marking the beginning of range (e.g. ${r}, ${n})`}),endId:Fn.String({description:`Message or block ID marking the end of range (e.g. ${an(12,t)}, ${vn(5,t)})`}),summary:Fn.String({description:"Complete technical summary replacing all content in range"})}),{description:"One or more ranges to compress, each with start/end boundaries and a summary"})}),async execute(o,i){try{let a=Ik(i,e.state(),e.messages(),t),m=a.map(g=>g.blockId),c=a.reduce((g,y)=>g+y.coveredCount,0),p=a.reduce((g,y)=>g+y.compressedTokens,0),f=a.reduce((g,y)=>g+y.summaryTokens,0),d=Math.max(0,p-f);return{content:[{type:"text",text:`Compressed ${c} messages into ${So}`+(p>0?` - ${p} tokens replaced by ${f}, saving ${d}.`:".")}],details:{blockIds:m,runId:a[0]?.runId,messages:c,compressedTokens:p,summaryTokens:f}}}catch(a){let m=a instanceof Error?a.message:String(a);return{content:[{type:"text",text:m}],details:{error:m},isError:!0}}}})}import{existsSync as hk,mkdirSync as yN,readFileSync as bk,unlinkSync as IN}from"node:fs";import{dirname as hN,join as $k}from"node:path";function ep(e){try{let t=$k(e,".howtofix","dcp.json");if(!hk(t))return;let r=JSON.parse(bk(t,"utf8"));if(typeof r!="object"||r===null)return;let n=r.enabled;return typeof n=="boolean"?n:void 0}catch{return}}function tp(e){if(e.env!==void 0){let t=e.env.trim().toLowerCase();return{enabled:t!=="0"&&t!=="false",source:"env"}}return e.config!==void 0?{enabled:e.config,source:"config"}:e.runtime!==void 0?{enabled:e.runtime,source:"session"}:{enabled:!0,source:"default"}}function Ek(){return{messageIds:Hc(),prune:{tools:{},messages:{blocks:[],nextBlockId:1,nextRunId:1}},stats:{totalPruneTokens:0,totalCompressTokens:0}}}function um(e){let t=e.replace(/[^A-Za-z0-9._-]/g,"_")||"session";return $k(lt,"dcp",`${t}.json`)}function bN(e){if(typeof e!="object"||e===null)return!1;let t=e,r=t.prune?.messages,n=t.messageIds;return typeof t.prune=="object"&&t.prune!==null&&typeof t.prune.tools=="object"&&t.prune.tools!==null&&typeof r=="object"&&r!==null&&Array.isArray(r.blocks)&&Number.isInteger(r.nextBlockId)&&Number.isInteger(r.nextRunId)&&typeof n=="object"&&n!==null&&Number.isInteger(n.nextRef)&&typeof n.keyToRef=="object"&&n.keyToRef!==null&&typeof n.refToKey=="object"&&n.refToKey!==null&&typeof t.stats=="object"&&t.stats!==null&&Number.isFinite(t.stats.totalPruneTokens)&&Number.isFinite(t.stats.totalCompressTokens)}var mm=new Map;function vi(e){let t=mm.get(e);if(t)return t;let r;try{let o=um(e);if(hk(o)){let i=JSON.parse(bk(o,"utf8"));bN(i)&&(r=i)}}catch{r=void 0}let n=r??Ek();return mm.set(e,n),n}function un(e){let t=mm.get(e);if(!t)return;let r=um(e);yN(hN(r),{recursive:!0}),or(r,JSON.stringify(t))}function $N(e){mm.delete(e);try{IN(um(e))}catch{}}function tr(e){return e.replaceAll("\\","/")}function EN(e){return/[\\.^$+{}()|\[\]]/.test(e)?`\\${e}`:e}function rp(e,t){if(!t)return!1;let r=tr(e),n=tr(t),o="^";for(let i=0;i<n.length;i++){let a=n[i];if(a==="*"){if(n[i+1]==="*"){if(n[i+2]==="/"){o+="(?:.*/)?",i+=2;continue}o+=".*",i++;continue}o+="[^/]*";continue}if(a==="?"){o+="[^/]";continue}if(a==="/"){o+="/";continue}o+=EN(a)}return o+="$",new RegExp(o).test(r)}function cm(e,t){if(typeof t!="object"||t===null)return[];let r=[],n=t;if((e==="apply_patch"||e==="patch")&&typeof n.patchText=="string"){let o=/\*\*\* (?:Add|Delete|Update) File: ([^\n\r]+)/g,i;for(;(i=o.exec(n.patchText))!==null;)r.push(i[1].trim())}if(e==="multiedit"&&(typeof n.filePath=="string"&&r.push(n.filePath),Array.isArray(n.edits)))for(let o of n.edits)o&&typeof o=="object"&&typeof o.filePath=="string"&&r.push(o.filePath);return typeof n.filePath=="string"&&r.push(n.filePath),["read","write","edit"].includes(e)&&typeof n.path=="string"&&r.push(n.path),[...new Set(r)].filter(o=>o.length>0)}function Sk(e,t){return e.length===0||t.length===0?!1:e.some(r=>t.some(n=>rp(r,n)))}var SN=/[*?]/,Nn=["todo","goal","context","task"];function kk(e,t){if(!e||t.length===0)return!1;let r=new Set,n=[];for(let o of t)SN.test(o)?n.push(o):r.add(o);return r.has(e)?!0:n.some(o=>rp(e,o))}function pm(e,t,r,n,o){let i=[{tool:e,input:t}];if(e==="execute"&&Array.isArray(o?.toolCalls))for(let a of o.toolCalls)a&&typeof a=="object"&&typeof a.tool=="string"&&i.push({tool:a.tool,input:a.input});return i.some(a=>kk(a.tool,r)||Sk(cm(a.tool,a.input),n))}function op(e,t){return t==null?e:`${e}::${JSON.stringify(np(kN(t)))}`}function kN(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={};for(let[r,n]of Object.entries(e))n!=null&&(t[r]=n);return t}function np(e){if(typeof e!="object"||e===null)return e;if(Array.isArray(e))return e.map(np);let t={};for(let r of Object.keys(e).sort())t[r]=np(e[r]);return t}var ko="[Output removed to save context - information superseded or no longer needed]",ip="[input removed due to failed tool call]",Ck="[questions removed - see output for user's answers]",Rk=2e3,fm=["ask","question"],Tk=["read","grep","ls"],TN=["edit","write","multiedit","apply_patch","patch"];function CN(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function RN(e){if(!e)return{total:0,count:0};let t=0,r=0;for(let n of Object.values(e))typeof n=="string"&&(t+=n.length,r++);return{total:t,count:r}}function wN(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sp(e,t,r){let n=r?.bigOutputChars??Rk,o=new Map,i=[];for(let I=0;I<e.length;I++){let b=e[I];if(b.role==="assistant")for(let C of b.content)C.type==="toolCall"&&o.set(C.id,{name:C.name,args:C.arguments,callIndex:I});else if(b.role==="toolResult"){let C=o.get(b.toolCallId),N=b.toolName;i.push({index:I,callId:b.toolCallId,tool:N,isError:b.isError,text:CN(b.content),paths:C?cm(N,C.args):[],signature:op(N,C?.args),callIndex:C?.callIndex??-1})}}let a=t.planFile?tr(t.planFile):void 0,m=I=>I.index===0||Nn.includes(I.tool)||a!==void 0&&I.paths.some(b=>tr(b)===a),c=I=>I.callIndex<0||I.callIndex===0||Nn.includes(I.tool)||a!==void 0&&I.paths.some(b=>tr(b)===a),p=[],f=new Set,d=I=>{let b=`${I.kind}:${I.callId}`;f.has(b)||(f.add(b),p.push(I))},g=new Map;for(let I of i)if(!(I.isError||!Tk.includes(I.tool)&&!TN.includes(I.tool)))for(let b of I.paths){let C=tr(b),N=g.get(C);(N===void 0||I.index>N)&&g.set(C,I.index)}for(let I of i){if(I.isError||!Tk.includes(I.tool)||m(I)||I.text===ko)continue;I.paths.some(C=>(g.get(tr(C))??-1)>I.index)&&d({kind:"output",reason:"superseded-read",callId:I.callId,messageIndex:I.index,savedChars:Math.max(0,I.text.length-ko.length)})}let y=new Map;for(let I of i){if(I.isError)continue;let b=y.get(I.signature);(b===void 0||I.index>b)&&y.set(I.signature,I.index)}for(let I of i){if(!I.isError||m(I))continue;let b=y.get(I.signature);if(!(b===void 0||b<=I.index)&&(d({kind:"output",reason:"error-then-success",callId:I.callId,messageIndex:I.index,savedChars:Math.max(0,I.text.length-ko.length)}),!c(I))){let C=o.get(I.callId)?.args,{total:N,count:G}=RN(C);G>0&&d({kind:"failed-input",reason:"error-then-success",callId:I.callId,messageIndex:I.callIndex,savedChars:Math.max(0,N-G*ip.length)})}}if(t.files.length>0||t.identifiers.length>0){let I=[...t.files.map(tr),...a?[a]:[]],b=I.map(G=>G.split("/").pop()??"").filter(G=>G.length>0),C=t.identifiers.map(G=>new RegExp(`(?<![\\w.-])${wN(G)}(?![\\w.-])`)),N=G=>{let mt=tr(G);return I.some(Qe=>mt.includes(Qe))||b.some(Qe=>G.includes(Qe))?!0:C.some(Qe=>Qe.test(G))};for(let G of i)m(G)||fm.includes(G.tool)||G.text.length<=n||N(G.text)||d({kind:"output",reason:"unrelated-big-output",callId:G.callId,messageIndex:G.index,savedChars:Math.max(0,G.text.length-ko.length)})}let h=0;for(let I of p)h+=I.savedChars;return{ops:p,savedChars:h}}function ap(e,t){let r=new Set,n=new Set,o=new Set;for(let i of t)i.kind==="output"?r.add(i.callId):i.kind==="question-input"?n.add(i.callId):o.add(i.callId);return Ak(Pk(wk(e,r),n),o)}function wk(e,t){return t.size===0?[...e]:e.map((r,n)=>n===0||r.role!=="toolResult"||!t.has(r.toolCallId)||fm.includes(r.toolName)?r:{...r,content:[{type:"text",text:ko}]})}function Pk(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&!n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id)||!fm.includes(m.name))return m;let c={...m.arguments},p=!1;for(let f of["question","questions","options"])f in c&&(c[f]=Ck,p=!0);return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function Ak(e,t){if(t.size===0)return[...e];let r=new Set;for(let n of e)n.role==="toolResult"&&n.isError&&t.has(n.toolCallId)&&r.add(n.toolCallId);return r.size===0?[...e]:e.map((n,o)=>{if(o===0||n.role!=="assistant")return n;let i=!1,a=n.content.map(m=>{if(m.type!=="toolCall"||!r.has(m.id))return m;let c={},p=!1;for(let[f,d]of Object.entries(m.arguments))typeof d=="string"?(c[f]=ip,p=!0):c[f]=d;return p?(i=!0,{...m,arguments:c}):m});return i?{...n,content:a}:n})}function mp(e,t,r){if(t.length===0)return[...e];let n=mn(r,e),o=new Map;for(let d=0;d<n.length;d++){let g=n[d];g!==null&&o.set(g,d)}let i=new Set,a=new Map;for(let d of t){let g=[];for(let h of d.coveredIndices){let I=o.get(h);I!==void 0&&(i.add(I),g.push(I))}let y=o.get(d.anchorIndex)??(g.length>0?Math.min(...g):void 0);if(d.summary&&y!==void 0){let h=a.get(y);h?h.push(d.summary):a.set(y,[d.summary])}}let m=new Map,c=new Map;for(let d=0;d<e.length;d++){let g=e[d];if(g)if(g.role==="assistant"&&Array.isArray(g.content))for(let y of g.content)y.type==="toolCall"&&m.set(d,y.id);else g.role==="toolResult"&&c.set(g.toolCallId,d)}let p=[...i];for(;p.length>0;){let d=p.pop(),g=m.get(d);if(g!==void 0){let h=c.get(g);h!==void 0&&!i.has(h)&&(i.add(h),p.push(h))}let y=e[d];if(y?.role==="toolResult")for(let[h,I]of m)I===y.toolCallId&&!i.has(h)&&(i.add(h),p.push(h))}let f=[];for(let d=0;d<e.length;d++){let g=a.get(d);if(g){let y=e[d];for(let h of g){let I={role:"user",content:h,timestamp:y.timestamp};f.push(I)}}i.has(d)||f.push(e[d])}return f}var up={thresholdChars:8192,headChars:4096,tailChars:1024};function PN(e,t={}){let r=t.thresholdChars??up.thresholdChars,n=t.headChars??up.headChars,o=t.tailChars??up.tailChars;if(e.length<=r||n+o>=e.length)return{text:e,prunedChars:0};let i=n,a=e.charCodeAt(i-1);a>=55296&&a<=56319&&(i-=1);let m=e.length-o,c=e.charCodeAt(m);c>=56320&&c<=57343&&(m+=1);let p=e.slice(0,i),f=e.slice(m),d=m-i,g=`
|
|
44
|
+
|
|
45
|
+
[... ${d} characters pruned from the middle ...]
|
|
46
|
+
|
|
47
|
+
`;return{text:p+g+f,prunedChars:d-g.length}}function Ok(e,t={}){let r=0,n=0,o=!1,i=e.map(a=>{let m=a;if(m.role!=="toolResult"||!Array.isArray(m.content))return a;let c=m.content,p=!1,f=c.map(d=>{if(!d||typeof d!="object")return d;let g=d;if(g.type!=="text"||typeof g.text!="string")return d;let y=PN(g.text,t);return y.prunedChars<=0?d:(p=!0,r+=y.prunedChars,{...d,text:y.text})});return p?(o=!0,n+=1,{...a,content:f}):a});return{messages:o?i:e,savedChars:r,prunedResults:n}}function cp(e="xml"){let t=e==="compact",r=t?"@4@":"mNNNN",n=t?"@b1@":"bN",o=t?"@b1@":"(bN)";return`COMPRESSING A RANGE OF THIS CONVERSATION
|
|
48
|
+
|
|
49
|
+
This is what the \`compress\` tool is for, and how a range must be summarised when it is used. Reach for it when the conversation has grown long enough that its older turns cost more than they are worth - never as a way to answer the user, and never on a range they did not ask about. Nothing here is a standing instruction to summarise: it is the contract the tool's output is held to.
|
|
50
|
+
|
|
51
|
+
THE SUMMARY
|
|
52
|
+
Your summary must be EXHAUSTIVE. Capture file paths, function signatures, decisions made, constraints discovered, key findings... EVERYTHING that maintains context integrity. This is not a brief note - it is an authoritative record so faithful that the original conversation adds no value.
|
|
53
|
+
|
|
54
|
+
USER INTENT FIDELITY
|
|
55
|
+
When the compressed range includes user messages, preserve the user's intent with extra care. Do not change scope, constraints, priorities, acceptance criteria, or requested outcomes.
|
|
56
|
+
Directly quote user messages when they are short enough to include safely. Direct quotes are preferred when they best preserve exact meaning.
|
|
57
|
+
|
|
58
|
+
Yet be LEAN. Strip away the noise: failed attempts that led nowhere, verbose tool outputs, back-and-forth exploration. What remains should be pure signal - golden nuggets of detail that preserve full understanding with zero ambiguity.
|
|
59
|
+
|
|
60
|
+
COMPRESSED BLOCK PLACEHOLDERS
|
|
61
|
+
When the selected range includes previously compressed blocks, use this exact placeholder format when referencing one:
|
|
62
|
+
|
|
63
|
+
- \`${o}\`
|
|
64
|
+
|
|
65
|
+
Compressed block sections in context are clearly marked with a header:
|
|
66
|
+
|
|
67
|
+
- \`[Compressed conversation section]\`
|
|
68
|
+
|
|
69
|
+
${t?"Compressed block IDs look like `@b1@`, distinct from raw message IDs like `@4@`.":"Compressed block IDs always use the `bN` form (never `mNNNN`) and are represented in the same XML metadata tag format."}
|
|
70
|
+
|
|
71
|
+
Rules:
|
|
72
|
+
|
|
73
|
+
- Include every required block placeholder exactly once.
|
|
74
|
+
- Do not invent placeholders for blocks outside the selected range.
|
|
75
|
+
- Treat \`${o}\` placeholders as RESERVED TOKENS. Do not emit \`${o}\` text anywhere except intentional placeholders.
|
|
76
|
+
- If you need to mention a block in prose, use plain text like \`compressed ${t?"block 1":"bN"}\` (not as a placeholder).
|
|
77
|
+
- Preflight check before finalizing: the set of \`${o}\` placeholders in your summary must exactly match the required set, with no duplicates.
|
|
78
|
+
|
|
79
|
+
These placeholders are semantic references. They will be replaced with the full stored compressed block content when the tool processes your output.
|
|
80
|
+
|
|
81
|
+
FLOW PRESERVATION WITH PLACEHOLDERS
|
|
82
|
+
When you use compressed block placeholders, write the surrounding summary text so it still reads correctly AFTER placeholder expansion.
|
|
83
|
+
|
|
84
|
+
- Treat each placeholder as a stand-in for a full conversation segment, not a short label.
|
|
85
|
+
- Ensure transitions before and after each placeholder preserve chronology and causality.
|
|
86
|
+
- Do not write text that depends on the placeholder staying literal (for example, "as noted in \`${t?"@b2@":"(b2)"}\`").
|
|
87
|
+
- Your final meaning must be coherent once each placeholder is replaced with its full compressed block content.
|
|
88
|
+
|
|
89
|
+
BOUNDARY IDS
|
|
90
|
+
You specify boundaries by ID using the injected IDs visible in the conversation:
|
|
91
|
+
|
|
92
|
+
- \`${r}\` IDs identify raw messages
|
|
93
|
+
- \`${n}\` IDs identify previously compressed blocks
|
|
94
|
+
|
|
95
|
+
${t?"Each message has an ID like `@4@`. Copy the whole marker, including both `@` characters, into `startId` and `endId`.":"Each message has an ID inside XML metadata tags like `<dcp-message-id>...</dcp-message-id>`."}
|
|
96
|
+
The same ID tag appears in every tool output of the message it belongs to \u2014 each unique ID identifies one complete message.
|
|
97
|
+
Treat these tags as boundary metadata only, not as tool result content.
|
|
98
|
+
|
|
99
|
+
Rules:
|
|
100
|
+
|
|
101
|
+
- Pick \`startId\` and \`endId\` directly from injected IDs in context.
|
|
102
|
+
- IDs must exist in the current visible context.
|
|
103
|
+
- \`startId\` must appear before \`endId\`.
|
|
104
|
+
- Do not invent IDs. Use only IDs that are present in context.
|
|
105
|
+
|
|
106
|
+
BATCHING
|
|
107
|
+
When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
|
|
108
|
+
`}function pp(e,t,r,n){let o=new Map;if(t.idState){let m=mn(t.idState,t.messages);for(let c=0;c<m.length;c++){let p=m[c];p!==null&&o.set(p,c)}}let i=new Set;for(let m of Fr(r))if(!(n!==void 0&&m.blockId===n))for(let c of m.coveredIndices)i.add(c);let a=[];if(t.idState)for(let m of e.indices){if(i.has(m))continue;let c=o.get(m);c!==void 0&&a.push(c)}return a}function Mk(e){if(typeof e.content=="string")return e.content.trim()?[e.content]:[];let t=[];for(let r of e.content)r.type==="text"&&r.text.trim()&&t.push(r.text);return t}function vk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of pp(t,r,n,i)){let f=r.messages[p];if(!f||f.role!=="user")continue;let d=Mk(f)[0];d!==void 0&&a.push(d)}if(a.length===0)return e;let m=`
|
|
109
|
+
|
|
110
|
+
The following user messages were sent in this conversation verbatim:`,c=a.map(p=>`
|
|
111
|
+
${p}`).join("");return e+m+c}function Fk(e,t,r,n,o,i){if(!o)return e;let a=[];for(let p of pp(t,r,n,i)){let f=r.messages[p];if(!(!f||f.role!=="user"))for(let d of Mk(f))a.push(...Nk(d))}if(a.length===0)return e;let m=`
|
|
112
|
+
|
|
113
|
+
The following protected prompt information was included in this conversation verbatim:`,c=a.map(p=>`
|
|
114
|
+
${p}`).join("");return e+m+c}function Nk(e){let t=[],r=/<protect>([\s\S]*?)<\/protect>/gi;for(let n of e.matchAll(r)){let o=n[1]?.trim();o&&t.push(o)}return t}function Dk(e,t,r,n,o=[],i=[],a){let m=new Map,c=[];for(let y of pp(t,r,n,a)){let h=r.messages[y];if(h){if(h.role==="assistant"){for(let I of h.content)I.type==="toolCall"&&m.set(I.id,I.arguments);continue}if(h.role==="toolResult"){if(h.isError)continue;let I=h.content.filter(b=>b.type==="text").map(b=>b.text).join("");I.trim()&&c.push({toolCallId:h.toolCallId,toolName:h.toolName,text:I})}}}if(c.length===0)return e;let p=[...new Set([...Nn,...o])],f=[...i],d=[];for(let y of c){let h=m.get(y.toolCallId);pm(y.toolName,h,p,f)&&d.push(`
|
|
115
|
+
### Tool: ${y.toolName}
|
|
116
|
+
${y.text}`)}return d.length===0?e:e+`
|
|
117
|
+
|
|
118
|
+
The following protected tools were used in this conversation as well:`+d.join("")}function Lk(e,t,r){if(t.protectedEnriched)return;let n=t.coveredIndices;if(n.length>0){let o={startIdx:Math.min(...n),endIdx:Math.max(...n),indices:[...n],requiredBlockIds:[],tokenByIndex:new Map},i={messages:r,idState:e.messageIds},a=Dk(Fk(vk(t.summary,o,i,e,!0,t.blockId),o,i,e,!0,t.blockId),o,i,e,[],[],t.blockId);t.summary=a,t.summaryTokens=Mi(a)}t.protectedEnriched=!0}function jk(e,t){let r=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o===null)continue;let i=t[n],a=i&&"content"in i?Eo(i.content):"";r.push({index:o,tokenCount:Math.round(a.length/4)})}return r}var AN="COMPRESSED BLOCK PLACEHOLDERS",fp=new Map;function ON(e){return fp.get(e)??[]}function MN(e){fp.delete(e)}var _k;function vN(){return _k}function FN(e={}){return t=>{t.on("context_with_system",async(r,n)=>{let o=n?.sessionManager?.getSessionId()??"dcp-sessionless",i=vi(o);if(i.enabled===!1)return;let a=r.messages,m=a[0];if(!m||m.role!=="system")return;Vc(i.messageIds,a);let c=mn(i.messageIds,a);fp.set(o,jk(c,a)),_k=o;let p=NN(a),f=mp(p,Fr(i),i.messageIds),d=Ok(f);d.prunedResults>0&&(f=[...d.messages]);let g=e.keepSet?.()??{files:[],identifiers:[]},y=sp(f,g);if(y.ops.length>0){f=ap(f,y.ops);for(let I of y.ops)i.prune.tools[I.callId]=(i.prune.tools[I.callId]??0)+I.savedChars;i.stats.totalPruneTokens=Object.values(i.prune.tools).reduce((I,b)=>I+b,0)}for(let I of i.prune.messages.blocks)I.active&&!I.protectedEnriched&&Lk(i,I,a);un(o);let h=f.map((I,b)=>{if(b!==0||!("content"in I))return I;let C=Eo(I.content);return C.includes(AN)?I:{...I,content:am(I.content,`${C}
|
|
119
|
+
|
|
120
|
+
${cp()}`)}});return{messages:LN(h,i.messageIds)}})}}function NN(e){return e.map(t=>{if(t.role!=="assistant"||!("content"in t))return t;let r=DN(t.content);return r===t.content?t:{...t,content:r}})}function DN(e){if(typeof e=="string")return Wc(e);if(!Array.isArray(e))return e;let t=!1,r=e.map(n=>{if(!n||typeof n!="object"||!("type"in n)||n.type!=="text")return n;let o="text"in n&&typeof n.text=="string"?n.text:"",i=Wc(o);return i===o?n:(t=!0,{...n,text:i})});return t?r:e}function LN(e,t){let r=mn(t,e);return e.map((n,o)=>{let i=r[o];if(i==null||!("content"in n))return n;let a=Oi(an(i));return Eo(n.content).includes(a)?n:{...n,content:jN(n.content,a)}})}function jN(e,t){if(typeof e=="string")return e+t;if(!Array.isArray(e))return e;let r=!1,n=e.map(o=>{if(!o||typeof o!="object"||!("type"in o)||o.type!=="text")return o;r=!0;let i="text"in o&&typeof o.text=="string"?o.text:"";return{...o,text:i+t}});return r?n:[...n,{type:"text",text:t.trimStart()}]}var qk={on:"turn the transform on for this session",off:"turn it off; the full transcript is sent unchanged",status:"the switch, the block count, and the tokens saved",blocks:"list the active compressed blocks",stats:"prune and compress totals for this session",context:"what the next request will carry, and what was saved",decompress:"reopen one block by id, e.g. /dcp decompress b2",sweep:"drop blocks no longer referenced by the ref state"};function dp(e){return e<1e3?`${e}`:`${(e/1e3).toFixed(1)}k`}function _N(e,t,r){let[n]=e.trim().split(/\s+/),o=n===void 0||n===""?"status":n,i=vi(r);switch(o){case"on":return i.enabled=!0,un(r),"dcp: on";case"off":return i.enabled=!1,un(r),"dcp: off; the full transcript is sent unchanged";case"blocks":{let a=Fr(i);return a.length===0?"dcp: no active blocks":a.map(m=>{let c=String(m.anchorIndex).padStart(4,"0");return`b${m.blockId} covers ${m.coveredIndices.length} message(s), anchored at m${c}`}).join(`
|
|
121
|
+
`)}case"status":{let a=tp({runtime:i.enabled,config:ep(t)}),m=Fr(i),c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`dcp: ${a.enabled?"on":"off"} (source: ${a.source})`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`active blocks: ${m.length}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${dp(c)} chars)`,`compressed tokens total: ${i.stats.totalCompressTokens}`].join(`
|
|
122
|
+
`)}case"stats":{let a=i.prune.messages.blocks,m=a.filter(p=>p.active).length,c=Object.values(i.prune.tools).reduce((p,f)=>p+f,0);return[`blocks: ${m} active of ${a.length} total`,`compressed tokens: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${dp(c)} chars)`,`messages tracked: ${Object.keys(i.messageIds.keyToRef).length}`,`refs allocated: ${i.messageIds.nextRef-1}`].join(`
|
|
123
|
+
`)}case"context":{let a=Fr(i),m=new Set;for(let f of a)for(let d of f.coveredIndices)m.add(d);let c=Object.keys(i.messageIds.keyToRef).length,p=Object.values(i.prune.tools).reduce((f,d)=>f+d,0);return[`messages tracked: ${c}`,`messages replaced by a block: ${m.size}`,`messages sent: ${Math.max(0,c-m.size)}`,`active blocks: ${a.length}`,`compressed tokens total: ${i.stats.totalCompressTokens}`,`pruned tool calls: ${Object.keys(i.prune.tools).length} (${dp(p)} chars)`].join(`
|
|
124
|
+
`)}case"decompress":{let a=e.trim().split(/\s+/)[1],m=a===void 0?null:/^b?(\d+)$/i.exec(a);if(!m)return"dcp: give a block id, e.g. /dcp decompress b2";let c=Number(m[1]),p=i.prune.messages.blocks,f=p.find(g=>g.blockId===c);if(!f)return`dcp: no block b${c}`;let d=p.filter(g=>g.active&&g.consumedBlockIds.includes(c));if(d.length>0){let g=d.map(y=>`b${y.blockId}`).join(", ");return`dcp: b${c} was consumed by ${g}; decompress that one first`}if(!f.active)return`dcp: b${c} is already open`;f.active=!1,f.deactivatedByUser=!0,f.deactivatedAt=Date.now();for(let g of f.parentBlockIds){let y=p.find(h=>h.blockId===g);y&&(y.consumedBlockIds=y.consumedBlockIds.filter(h=>h!==c))}return un(r),`dcp: b${c} reopened; ${f.coveredIndices.length} message(s) are back`}case"sweep":{let a=new Set(Object.keys(i.messageIds.refToKey).map(Number)),m=i.prune.messages.blocks,c=m.length,p=m.filter(d=>d.active&&!d.coveredIndices.some(g=>a.has(g)));for(let d of p)d.active=!1,d.deactivatedAt=Date.now();i.prune.messages.blocks=m.filter(d=>d.active||d.deactivatedByUser);let f=c-i.prune.messages.blocks.length;return un(r),p.length===0?"dcp: nothing to sweep":`dcp: ${p.length} orphaned block(s) closed, ${f} dropped from state`}default:return`dcp: unknown subcommand '${o}'. try: ${Object.keys(qk).join(", ")}`}}import{Type as lm}from"@netrodev/hxf-ai";import{defineTool as Wk}from"@netrodev/hxf-coding-agent";import{promises as qN}from"node:dns";var UN=/^(127\.|10\.|192\.168\.|169\.254\.|0\.|221\.|222\.|223\.)/;function lp(e){if(UN.test(e))return!0;let t=/^172\.(\d+)\./.exec(e);if(!t)return!1;let r=Number(t[1]);return r>=16&&r<=31}function gp(e){let t=/^100\.(\d+)\.(\d+)\.(\d+)$/.exec(e);if(t){let n=Number(t[1]);return n>=64&&n<=127}let r=/^198\.(\d+)\./.exec(e);return r!==null&&(Number(r[1])===18||Number(r[1])===19)}function Gk(e){let t=e.toLowerCase().replace(/^\[|\]$/g,"").split("%")[0];if(t==="localhost"||t.endsWith(".localhost"))return!0;let r=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(r){let o=r[1];return lp(o)||gp(o)||o==="0.0.0.0"}let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(t);if(n){let o=Number.parseInt(n[1],16),i=Number.parseInt(n[2],16),a=`${o>>8&255}.${o&255}.${i>>8&255}.${i&255}`;return lp(a)||gp(a)||a==="0.0.0.0"}return t.includes(":")?!!(t==="::1"||t==="::"||/^f[cd][0-9a-f]{2}:/.test(t)||/^fe[89ab][0-9a-f]:/.test(t)):t==="0.0.0.0"?!0:lp(t)||gp(t)}var xp=8e4,yp=8;function dm(e){let t;try{t=new URL(e)}catch{return{ok:!1,reason:"not a URL"}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,reason:`refused protocol ${t.protocol}`};let r=t.hostname.toLowerCase();return r==="localhost"||r.endsWith(".localhost")||r==="::1"||r==="[::1]"?{ok:!1,reason:"refused loopback host"}:Gk(r)?{ok:!1,reason:"refused private address"}:{ok:!0,url:t}}function Bk(e){let t=e.replace(/<script[\s\S]*?<\/script>/gi," ").replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<noscript[\s\S]*?<\/noscript>/gi," ").replace(/<[^>]+>/g," ").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/\s+/g," ").trim();return t.length>xp?t.slice(0,xp):t}function GN(e){let t=[],r=/class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/gi,n;for(;(n=r.exec(e))&&t.length<yp;){let o=n[1]??"",i=Bk(n[2]??""),a=o,m=/[?&]uddg=([^&]+)/.exec(o);if(m)try{a=decodeURIComponent(m[1])}catch{a=o}else o.startsWith("//")&&(a=`https:${o}`);let c=dm(a);!c.ok||!i||t.push({title:i,url:c.url.toString(),snippet:""})}return t}var Kk="HowToFix (https://howtofix.id)";async function Hk(e,t={}){let r=e.trim();if(!r)return{ok:!1,error:"empty query"};let n=t.fetchFn??fetch,o=t.timeoutMs??15e3,i={"user-agent":t.userAgent??Kk,accept:"text/html, application/json"};try{if(t.braveKey){let p=`https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(r)}&count=${yp}`,f=await n(p,{headers:{...i,accept:"application/json","x-subscription-token":t.braveKey},signal:AbortSignal.timeout(o)});return f.ok?{ok:!0,hits:BN(await f.json()),provider:"brave"}:{ok:!1,error:`brave ${f.status}`}}let a=`https://html.duckduckgo.com/html/?q=${encodeURIComponent(r)}`,m=await n(a,{headers:i,signal:AbortSignal.timeout(o)});return m.ok?{ok:!0,hits:GN(await m.text()),provider:"ddg"}:{ok:!1,error:`search ${m.status}`}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}function BN(e){let t=[];if(e&&typeof e=="object"&&"web"in e){let n=e.web;n&&typeof n=="object"&&"results"in n&&Array.isArray(n.results)&&(t=n.results)}let r=[];for(let n of t){if(!n||typeof n!="object"||!("url"in n)||!("title"in n))continue;let o=n.url,i=n.title;if(typeof o!="string"||typeof i!="string")continue;let a=dm(o);if(!a.ok)continue;let m="description"in n?n.description:void 0;if(r.push({title:i,url:a.url.toString(),snippet:typeof m=="string"?m:""}),r.length>=yp)break}return r}var Uk=5,KN=new Set([301,302,303,307,308]);async function HN(e,t){let r=e.toLowerCase().replace(/^\[|\]$/g,"");if(r.includes(":")||/^[\d.]+$/.test(r))return{ok:!0};let n;try{n=await t(r)}catch(i){return{ok:!1,error:`could not resolve ${e}: ${i instanceof Error?i.message:String(i)}`}}if(n.length===0)return{ok:!1,error:`could not resolve ${e}`};let o=n.find(i=>Gk(i));return o!==void 0?{ok:!1,error:`refused ${e}: resolves to private address ${o}`}:{ok:!0}}async function zk(e,t={}){let r=dm(e);if(!r.ok)return{ok:!1,error:r.reason};let n=t.fetchFn??fetch,o=t.lookup??(m=>qN.lookup(m,{all:!0}).then(c=>c.map(p=>p.address))),i=AbortSignal.timeout(t.timeoutMs??2e4),a={"user-agent":t.userAgent??Kk,accept:"text/html, text/plain, application/json"};try{let m=r.url;for(let c=0;c<=Uk;c++){let p=dm(m.toString());if(!p.ok)return{ok:!1,error:`redirect refused: ${p.reason}`};let f=await HN(p.url.hostname,o);if(!f.ok)return{ok:!1,error:f.error};let d=await n(p.url,{headers:a,signal:i,redirect:"manual"});if(KN.has(d.status)){let I=d.headers.get("location");if(!I)return{ok:!1,error:`HTTP ${d.status} without a location`};try{m=new URL(I,p.url)}catch{return{ok:!1,error:"redirect location is not a URL"}}continue}if(!d.ok)return{ok:!1,error:`HTTP ${d.status}`};let g=d.headers.get("content-type")??"",y=await d.text(),h=/html/i.test(g)?Bk(y):y.slice(0,xp);return{ok:!0,url:m.toString(),contentType:g,text:h}}return{ok:!1,error:`too many redirects (max ${Uk})`}}catch(m){return{ok:!1,error:m instanceof Error?m.message:String(m)}}}function zN(e){return e.length===0?"no results":e.map((t,r)=>`${r+1}. ${t.title}
|
|
125
|
+
${t.url}${t.snippet?`
|
|
126
|
+
${t.snippet}`:""}`).join(`
|
|
127
|
+
`)}var Vk=Wk({name:"web_search",label:"web_search",description:"Search the public web. Use for current docs, changelogs, error messages, and anything not in this repo. Returns titles, URLs, and snippets. Follow a URL with web_fetch.",promptSnippet:"web_search: search the public web",parameters:lm.Object({query:lm.String({description:"Search query"})}),async execute(e,t){let r=await Hk(t.query,{braveKey:process.env.BRAVE_API_KEY});return r.ok?{content:[{type:"text",text:zN(r.hits)}],details:{count:r.hits.length,provider:r.provider}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}}),Jk=Wk({name:"web_fetch",label:"web_fetch",description:"Fetch a public http(s) URL and return its text. HTML is stripped to visible text. Local, loopback, and private addresses are refused.",promptSnippet:"web_fetch: read a public URL as text",parameters:lm.Object({url:lm.String({description:"http(s) URL"})}),async execute(e,t){let r=await zk(t.url);return r.ok?{content:[{type:"text",text:r.text}],details:{url:r.url,contentType:r.contentType,chars:r.text.length}}:{content:[{type:"text",text:r.error}],details:{error:r.error},isError:!0}}});import{spawn as WN}from"node:child_process";import{existsSync as Xk,readFileSync as VN}from"node:fs";import{delimiter as JN,isAbsolute as XN,join as Qk}from"node:path";import{fileURLToPath as QN,pathToFileURL as Dn}from"node:url";function Yk(e){let t=JSON.stringify(e);return`Content-Length: ${Buffer.byteLength(t,"utf8")}\r
|
|
128
|
+
\r
|
|
129
|
+
${t}`}var YN=32*1024*1024;function ZN(e){let t=[],r=0;for(;r<e.length;){let n=e.indexOf(`\r
|
|
130
|
+
\r
|
|
131
|
+
`,r);if(n===-1)break;let o=e.subarray(r,n).toString("utf8"),i=/Content-Length:\s*(\d+)/i.exec(o);if(!i)break;let a=Number(i[1]);if(!Number.isSafeInteger(a)||a<0||a>YN)throw new Error(`lsp frame of ${i[1]} bytes refused`);let m=n+4,c=m+a;if(c>e.length)break;let p=e.subarray(m,c).toString("utf8");try{let f=JSON.parse(p);f&&typeof f=="object"&&t.push(f)}catch{}r=c}return{messages:t,rest:e.subarray(r)}}var Ip=class{constructor(t){this.io=t;t.stdout.on("data",r=>{if(this.broken)return;this.buffer=Buffer.concat([this.buffer,r]);let n;try{n=ZN(this.buffer)}catch(o){this.buffer=Buffer.alloc(0),this.fail(o instanceof Error?o:new Error(String(o)));return}this.buffer=n.rest;for(let o of n.messages)this.dispatch(o)}),t.stdin.on("error",r=>{this.fail(r instanceof Error?r:new Error(String(r)))})}io;nextId=1;pending=new Map;buffer=Buffer.alloc(0);broken=null;opened=new Set;diagnosticsByUri=new Map;diagnosticsWaiters=new Map;fail(t){if(!this.broken){this.broken=t;for(let[r,n]of this.pending)this.pending.delete(r),n.reject(t)}}dispatch(t){if(t.method==="textDocument/publishDiagnostics"){let n=t.params;if(n?.uri){let o=Array.isArray(n.diagnostics)?n.diagnostics:[];this.diagnosticsByUri.set(n.uri,o);let i=this.diagnosticsWaiters.get(n.uri);if(i){this.diagnosticsWaiters.delete(n.uri);for(let a of i)a(o)}}return}if(t.id===void 0)return;let r=this.pending.get(Number(t.id));r&&(this.pending.delete(Number(t.id)),t.error?r.reject(new Error(t.error.message)):r.resolve(t.result))}request(t,r,n=1e4){if(this.broken)return Promise.reject(this.broken);let o=this.nextId++,i=Yk({jsonrpc:"2.0",id:o,method:t,params:r}),{promise:a,resolve:m,reject:c}=Promise.withResolvers(),p=setTimeout(()=>{this.pending.delete(o),c(new Error(`lsp ${t} timed out`))},n);this.pending.set(o,{resolve:f=>{clearTimeout(p),m(f)},reject:f=>{clearTimeout(p),c(f)}});try{this.io.stdin.write(i)}catch(f){let d=f instanceof Error?f:new Error(String(f));this.pending.delete(o),clearTimeout(p),c(d),this.fail(d)}return a}notify(t,r){if(!this.broken)try{this.io.stdin.write(Yk({jsonrpc:"2.0",method:t,params:r}))}catch(n){this.fail(n instanceof Error?n:new Error(String(n)))}}async initialize(){await this.request("initialize",{processId:null,rootUri:Dn(this.io.root).toString(),capabilities:{textDocument:{hover:{},definition:{},references:{},documentSymbol:{},publishDiagnostics:{}}}}),this.notify("initialized",{})}async hover(t,r,n){return(await this.request("textDocument/hover",{textDocument:{uri:Dn(t).toString()},position:{line:r,character:n}}))?.contents?.value}async definition(t,r,n){let o=await this.request("textDocument/definition",{textDocument:{uri:Dn(t).toString()},position:{line:r,character:n}});return Array.isArray(o)?o[0]:o??void 0}async references(t,r,n){let o=await this.request("textDocument/references",{textDocument:{uri:Dn(t).toString()},position:{line:r,character:n},context:{includeDeclaration:!0}});return Array.isArray(o)?o:[]}async documentSymbols(t){let r=await this.request("textDocument/documentSymbol",{textDocument:{uri:Dn(t).toString()}});return Array.isArray(r)?r:[]}diagnostics(t,r=2e3){let n=Dn(t).toString(),o=this.diagnosticsByUri.get(n);if(o)return Promise.resolve(o);let{promise:i,resolve:a}=Promise.withResolvers(),m=setTimeout(()=>{let p=this.diagnosticsWaiters.get(n);if(p){this.diagnosticsWaiters.delete(n);for(let f of p)f(this.diagnosticsByUri.get(n)??[])}},r),c=this.diagnosticsWaiters.get(n)??[];return c.push(p=>{clearTimeout(m),a(p)}),this.diagnosticsWaiters.set(n,c),i}async ensureOpen(t,r,n){let o=Dn(t).toString();this.opened.has(o)||(this.notify("textDocument/didOpen",{textDocument:{uri:o,languageId:n,version:1,text:r}}),this.opened.add(o))}dispose(){for(let[t,r]of this.pending)r.reject(new Error("lsp client disposed")),this.pending.delete(t);for(let[t,r]of this.diagnosticsWaiters){let n=this.diagnosticsByUri.get(t)??[];this.diagnosticsWaiters.delete(t);for(let o of r)o(n)}}},eD=[{command:"typescript-language-server",args:["--stdio"],languageId:"typescript",match:e=>/\.(ts|tsx|js|jsx|mts|cts)$/.test(e)},{command:"rust-analyzer",args:[],languageId:"rust",match:e=>e.endsWith(".rs")},{command:"gopls",args:[],languageId:"go",match:e=>e.endsWith(".go")},{command:"pylsp",args:[],languageId:"python",match:e=>e.endsWith(".py")}];function tD(e){return eD.find(t=>t.match(e))}var Nr=new Map;async function rD(e,t){let r=Nr.get(e.command);if(r)return await r.ready,r.client;let n=WN(e.command,e.args,{cwd:t,stdio:["pipe","pipe","ignore"]}),o=n.stdin,i=n.stdout;if(!o||!i)throw n.kill(),new Error(`${e.command}: stdio pipes unavailable`);let a=new Ip({stdin:o,stdout:i,root:t});n.on("error",()=>{let c=Nr.get(e.command);c?.child===n&&Nr.delete(e.command),c?.client.dispose()}),n.on("exit",()=>{Nr.get(e.command)?.child===n&&Nr.delete(e.command),a.dispose()});let m=a.initialize().catch(c=>{throw Nr.delete(e.command),n.kill(),c});return Nr.set(e.command,{client:a,child:n,ready:m}),await m,a}function nD(){for(let[e,t]of Nr)Nr.delete(e),t.client.dispose(),t.child.kill()}process.on("exit",nD);var oD={1:"error",2:"warning",3:"info",4:"hint"};function Zk(e){let t=e.uri;try{t=QN(e.uri)}catch{}let r=e.range?.start;return r?`${t}:${r.line+1}:${r.character+1}`:t}function eT(e,t=0){let r=[];for(let n of e){let o=(n.selectionRange??n.range)?.start.line;r.push(`${" ".repeat(t)}${n.name}${o===void 0?"":` :${o+1}`}`),n.children&&r.push(...eT(n.children,t+1))}return r}async function tT(e){try{let t=tD(e.file);if(!t)return{ok:!1,error:`no language server configured for ${e.file}`};if((e.action==="definition"||e.action==="references"||e.action==="hover")&&(e.line===void 0||!Number.isInteger(e.line)||e.line<1))return{ok:!1,error:`line required (1-based) for ${e.action}`};if(!(t.command.includes("/")?Xk(t.command):(process.env.PATH??"").split(JN).some(p=>Xk(Qk(p,t.command)))))return{ok:!1,error:`${t.command} is not on PATH. Install it to use lsp on ${e.file}.`};let o=XN(e.file)?e.file:Qk(e.root,e.file),i=VN(o,"utf8"),a=await rD(t,e.root);await a.ensureOpen(o,i,t.languageId);let m=(e.line??1)-1,c=0;if(e.symbol){let p=(i.split(`
|
|
132
|
+
`)[m]??"").indexOf(e.symbol);p>=0&&(c=p)}switch(e.action){case"definition":{let p=await a.definition(o,m,c);return p?{ok:!0,text:Zk(p),count:1}:{ok:!0,text:"no definition found",count:0}}case"references":{let f=(await a.references(o,m,c)).map(Zk);return{ok:!0,text:f.length>0?f.join(`
|
|
133
|
+
`):"no references found",count:f.length}}case"hover":{let p=(await a.hover(o,m,c))?.trim();return{ok:!0,text:p||"no hover at that position"}}case"symbols":{let p=eT(await a.documentSymbols(o));return{ok:!0,text:p.length>0?p.join(`
|
|
134
|
+
`):"no symbols in this file",count:p.length}}case"diagnostics":{let f=(await a.diagnostics(o)).map(d=>`${d.range.start.line+1}:${d.range.start.character+1} ${oD[d.severity??3]??"info"} ${d.message}`);return{ok:!0,text:f.length>0?f.join(`
|
|
135
|
+
`):"no diagnostics",count:f.length}}}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}import{StringEnum as iD}from"@netrodev/hxf-ai";import{defineTool as sD}from"@netrodev/hxf-coding-agent";var rT=sD({name:"lsp",label:"lsp",description:"Language-server query: definition, references, hover, symbols, or diagnostics for a file. Line is 1-based. Does not edit. If the server binary is missing the result says so; do not pretend grep is a substitute without telling the user.",promptSnippet:"lsp: definition, references, hover, symbols, diagnostics",parameters:O.Object({action:iD(["diagnostics","definition","references","hover","symbols"],{description:"Which language-server query to run"}),file:O.String({description:"File to query, relative to the project root"}),line:O.Optional(O.Number({description:"1-based line (definition, references, hover)"})),symbol:O.Optional(O.String({description:"Substring to locate on that line when column is omitted"}))}),async execute(e,t,r,n,o){let i=await tT({action:t.action,file:t.file,line:t.line,symbol:t.symbol,root:o.cwd});return i.ok?{content:[{type:"text",text:i.text}],details:{action:t.action,count:i.count}}:{content:[{type:"text",text:i.error}],details:{error:i.error},isError:!0}}});import{defineTool as LD}from"@netrodev/hxf-coding-agent";import{API as aD}from"typescript/unstable/async";import{SyntaxKind as Lt,visitEachChild as nT}from"typescript/unstable/ast";var oT=new Set([Lt.FunctionDeclaration,Lt.FunctionExpression,Lt.ArrowFunction,Lt.MethodDeclaration,Lt.Constructor,Lt.GetAccessor,Lt.SetAccessor]);function Co(e){return oT.has(e)}var mD=new Set([Lt.AmpersandAmpersandToken,Lt.BarBarToken,Lt.QuestionQuestionToken]);function gm(e){if(e.kind!==Lt.BinaryExpression)return!1;let t=ze(e,"operatorToken");return t!==void 0&&mD.has(t.kind)}function ze(e,t){let r=e[t];if(r&&typeof r=="object"&&typeof r.kind=="number")return r}function Fi(e,t){let r=e[t];return Array.isArray(r)?r:[]}function iT(e,t){return Fi(e,"modifiers").some(r=>r.kind===t)}function To(e){if(!e)return;let t=e.text;return typeof t=="string"?t:void 0}function uD(e,t){return e.getLineAndCharacterOfPosition(t).line+1}function hp(e,t){let r=e.getLineAndCharacterOfPosition(t.getStart(e)),n=e.getLineAndCharacterOfPosition(t.end);return{startLine:r.line+1,startColumn:r.character+1,endLine:n.line+1,endColumn:n.character+1}}function xm(e,t){t(e),nT(e,r=>(xm(r,t),r))}function Ni(e,t){t(e),nT(e,r=>(Co(r.kind)||Ni(r,t),r))}var cD=oT;function pD(e){let t=To(ze(e,"name"));if(t)return t;let r=ze(e,"parent");for(;r&&!cD.has(r.kind);){if(r.kind===Lt.VariableDeclaration||r.kind===Lt.PropertyAssignment){let n=To(ze(r,"name"));if(n)return n}r=ze(r,"parent")}return"<anonymous>"}function fD(e){let t=[];return xm(e,r=>{if(!Co(r.kind))return;let n=hp(e,r);t.push({name:pD(r),node:r,startLine:n.startLine,endLine:n.endLine})}),t}async function sT(e){let t=new Map;if(e.length===0)return t;let r=new aD({cwd:process.cwd()});try{let n=await r.updateSnapshot({openFiles:[...e]});for(let o of e)try{let i=await n.getDefaultProjectForFile(o);if(!i){t.set(o,{ok:!1,error:"no TypeScript project contains this file"});continue}let a=await i.program.getSourceFile(o);if(!a){t.set(o,{ok:!1,error:"the compiler could not read this file"});continue}let m=await i.program.getSyntacticDiagnostics(o);if(m.length>0){let c=m[0],p=uD(a,c.pos);t.set(o,{ok:!1,error:`line ${p}: ${c.text} (TS${c.code})`});continue}t.set(o,{ok:!0,sourceFile:a,functions:fD(a)})}catch(i){t.set(o,{ok:!1,error:i instanceof Error?i.message:String(i)})}}finally{await r.close()}return t}import{SyntaxKind as Er,visitEachChild as aT}from"typescript/unstable/ast";var dD=new Set([Er.IfStatement,Er.SwitchStatement,Er.ForStatement,Er.ForInStatement,Er.ForOfStatement,Er.WhileStatement,Er.DoStatement,Er.CatchClause]);function mT(e){let t=0,r=(o,i)=>{if(!Co(o.kind)){if(o.kind===Er.IfStatement){n(o,i,!1);return}if(dD.has(o.kind)){t+=1+i,aT(o,a=>(r(a,i+1),a));return}gm(o)&&(t+=1),aT(o,a=>(r(a,i),a))}},n=(o,i,a)=>{a||(t+=1+i);let m=ze(o,"expression");m&&r(m,i);let c=ze(o,"thenStatement");c&&r(c,i+1);let p=ze(o,"alternate");p&&(t+=1,p.kind===Er.IfStatement?n(p,i,!0):r(p,i+1))};return r(e,0),t}import{SyntaxKind as Dr}from"typescript/unstable/ast";var lD=new Set([Dr.IfStatement,Dr.ConditionalExpression,Dr.WhileStatement,Dr.DoStatement,Dr.ForStatement,Dr.ForInStatement,Dr.ForOfStatement,Dr.CatchClause,Dr.CaseClause]);function uT(e){let t=1;return Ni(e,r=>{(lD.has(r.kind)||gm(r))&&(t+=1)}),t}import{SyntaxKind as ne}from"typescript/unstable/ast";var gD=new Set([ne.BinaryExpression,ne.PrefixUnaryExpression,ne.PostfixUnaryExpression,ne.ConditionalExpression,ne.CallExpression,ne.NewExpression,ne.PropertyAccessExpression,ne.ElementAccessExpression,ne.AwaitExpression,ne.YieldExpression,ne.SpreadElement,ne.IfStatement,ne.WhileStatement,ne.DoStatement,ne.ForStatement,ne.ForInStatement,ne.ForOfStatement,ne.SwitchStatement,ne.ReturnStatement,ne.ThrowStatement,ne.TryStatement,ne.BreakStatement,ne.ContinueStatement]),xD=new Set([ne.StringLiteral,ne.NumericLiteral,ne.BigIntLiteral,ne.RegularExpressionLiteral,ne.NoSubstitutionTemplateLiteral]);function bp(e,t){e.set(t,(e.get(t)??0)+1)}function cT(e){let t=new Map,r=new Map;Ni(e,i=>{if(gD.has(i.kind)){let m=ze(i,"operatorToken");bp(t,ne[i.kind]+(m?`:${ne[m.kind]}`:""));return}let a=To(i);a!==void 0&&(i.kind===ne.Identifier||i.kind===ne.PrivateIdentifier?bp(r,`id:${a}`):xD.has(i.kind)&&bp(r,`lit:${a}`))});let n=t.size+r.size;if(n===0)return 0;let o=0;for(let i of t.values())o+=i;for(let i of r.values())o+=i;return Math.round(o*Math.log2(n)*100)/100}function pT(e){return e.endLine-e.startLine+1}function fT(e,t,r){let n=171-5.2*Math.log(Math.max(e,1))-.23*t-16.2*Math.log(Math.max(r,1));return Math.round(Math.max(0,n*100/171)*10)/10}import{SyntaxKind as rr,visitEachChild as yD}from"typescript/unstable/ast";var ID=new Set([rr.IfStatement,rr.SwitchStatement,rr.WhileStatement,rr.DoStatement,rr.ForStatement,rr.ForInStatement,rr.ForOfStatement,rr.TryStatement,rr.CatchClause]);function dT(e){let t=0,r=(n,o)=>{if(Co(n.kind))return;let i=o;if(ID.has(n.kind)&&(i=o+1,i>t&&(t=i)),n.kind===rr.IfStatement){let a=ze(n,"expression");a&&r(a,i);let m=ze(n,"thenStatement");m&&r(m,i);let c=ze(n,"alternate");c&&r(c,c.kind===rr.IfStatement?o:i);return}yD(n,a=>(r(a,i),a))};return r(e,0),t}import{spawnSync as hD}from"node:child_process";import{mkdirSync as vve,readdirSync as bD,readFileSync as $D,statSync as ED,writeFileSync as Fve}from"node:fs";import{extname as Sp,join as bT,relative as $T,resolve as SD}from"node:path";import{SyntaxKind as ym}from"typescript/unstable/ast";var lT={"god-function":"split it into smaller functions, one job each",incomprehensible:"extract helpers and simplify the flow before touching it",bloated:"long but linear; extract helpers","deeply-tangled":"nesting, not branching; flatten with early returns",fragile:"many branches; add guard clauses and tests around it"};function gT(e,t){let r=[];return t.cyclomatic>=1&&t.length>=1&&t.nesting>=1&&r.push({id:"god-function",label:"God Function",reason:`high cyclomatic complexity (${e.cyclomatic}), long body (${e.length} lines), and deep nesting (${e.nesting}) \u2014 likely doing too many things`}),t.cognitive>=1&&t.halstead>=1&&t.mi>=1&&r.push({id:"incomprehensible",label:"Incomprehensible",reason:`high cognitive complexity (${e.cognitive}) and Halstead volume (${e.halstead}) with MI ${e.mi} \u2014 very hard to understand`}),t.length>=1&&t.halstead>=1&&t.cyclomatic===0&&r.push({id:"bloated",label:"Bloated",reason:`large function (${e.length} lines) with high vocabulary (Halstead ${e.halstead}) but low branching \u2014 consider extracting helpers`}),t.nesting>=1&&t.cognitive>=1&&t.cyclomatic===0&&r.push({id:"deeply-tangled",label:"Deeply Tangled",reason:`nesting depth ${e.nesting} drives cognitive complexity ${e.cognitive} \u2014 flatten with early returns or extracted helpers`}),t.cyclomatic>=1&&t.mi>=1&&t.length===0&&r.push({id:"fragile",label:"Fragile",reason:`high cyclomatic complexity (${e.cyclomatic}) with MI ${e.mi} \u2014 many branches, hard to change safely`}),r}var kD=["ok","warn","error"],Rp=["cyclomatic","cognitive","nesting","length","halstead","mi","parameters","booleanParameters"];var Lr={cyclomatic:{warn:15,error:25},cognitive:{warn:12,error:20},nesting:{warn:4,error:5},length:{warn:60,error:120},halstead:{warn:500,error:1e3},mi:{warn:65,error:20},fileLines:{warn:400,error:800},exports:{warn:20,error:30},parameters:{warn:5,error:8}};function ET(){let e={cyclomatic:{...Lr.cyclomatic},cognitive:{...Lr.cognitive},nesting:{...Lr.nesting},length:{...Lr.length},halstead:{...Lr.halstead},mi:{...Lr.mi},fileLines:{...Lr.fileLines},exports:{...Lr.exports},parameters:{...Lr.parameters}};return{ignore:[],thresholds:e,ci:{failBelow:65,mode:"advisory"}}}var TD=["cyclomatic","cognitive","nesting","length","halstead","mi","fileLines","exports","parameters"];function $p(e){return typeof e=="number"&&Number.isFinite(e)}function wp(e){let t=ET(),r;try{r=JSON.parse($D(bT(e,".howtofix","quality.json"),"utf8"))}catch{return t}if(typeof r!="object"||r===null)return t;let n=r;if(typeof n.enabled=="boolean"&&(t.enabled=n.enabled),Array.isArray(n.ignore)&&(t.ignore=n.ignore.filter(o=>typeof o=="string")),typeof n.thresholds=="object"&&n.thresholds!==null){let o=n.thresholds;for(let i of TD){let a=o[i];if(typeof a!="object"||a===null)continue;let m=a;$p(m.warn)&&(t.thresholds[i].warn=m.warn),$p(m.error)&&(t.thresholds[i].error=m.error)}}if(typeof n.ci=="object"&&n.ci!==null){let o=n.ci;$p(o.failBelow)&&(t.ci.failBelow=o.failBelow),(o.mode==="advisory"||o.mode==="blocking")&&(t.ci.mode=o.mode)}return t}function ST(e,t){let r=process.env.HOWTOFIX_QUALITY;if(r!==void 0){let o=r.trim().toLowerCase();return o==="0"||o==="false"?{enabled:!1,source:"env"}:{enabled:!0,source:"env"}}let n=wp(e).enabled;return n!==void 0?{enabled:n,source:"config"}:t!==void 0?{enabled:t,source:"runtime"}:{enabled:!0,source:"default"}}function cn(e,t){return e>t.error?2:e>t.warn?1:0}function kT(e,t){return e<t.error?2:e<t.warn?1:0}function CD(e){let t=[];for(let r of Fi(e.node,"parameters"))ze(r,"type")?.kind===ym.BooleanKeyword&&t.push(To(ze(r,"name"))??"<pattern>");return t}function RD(e,t,r,n){let o=n.thresholds,i=ze(e.node,"body")??e.node,a={cyclomatic:uT(i),cognitive:mT(i),nesting:dT(i),length:pT(e),halstead:cT(i),mi:0};a.mi=fT(a.halstead,a.cyclomatic,a.length);let m=CD(e),c=Fi(e.node,"parameters").length,p={cyclomatic:{value:a.cyclomatic,rank:cn(a.cyclomatic,o.cyclomatic)},cognitive:{value:a.cognitive,rank:cn(a.cognitive,o.cognitive)},nesting:{value:a.nesting,rank:cn(a.nesting,o.nesting)},length:{value:a.length,rank:cn(a.length,o.length)},halstead:{value:a.halstead,rank:cn(a.halstead,o.halstead)},mi:{value:a.mi,rank:kT(a.mi,o.mi)},parameters:{value:c,rank:cn(c,o.parameters)},booleanParameters:{value:m.length,rank:m.length>0?1:0}},f={cyclomatic:p.cyclomatic.rank,cognitive:p.cognitive.rank,nesting:p.nesting.rank,length:p.length.rank,halstead:p.halstead.rank,mi:p.mi.rank},d=hp(t,e.node),g=0;for(let y of Rp)p[y].rank>g&&(g=p[y].rank);return{path:r,name:e.name,startLine:d.startLine,endLine:d.endLine,startColumn:d.startColumn,endColumn:d.endColumn,metrics:p,booleanParameterNames:m,smells:gT(a,f),worstRank:g}}function wD(e){let t=0;return xm(e,r=>{if(r.kind===ym.ExportDeclaration){let n=ze(r,"exportClause"),o=n?Fi(n,"elements"):[];t+=o.length>0?o.length:1;return}if(r.kind===ym.ExportAssignment){t+=1;return}iT(r,ym.ExportKeyword)&&(t+=1)}),t}function PD(e){if(e.length===0)return 0;let t=1;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&(t-=1),t}var xT={value:0,rank:0};function yT(e,t){return{path:e,ok:!1,error:t,lines:0,metrics:{lines:xT,exports:xT,mi:{value:100,rank:0}},functions:[]}}function Ep(e,t,r,n,o,i,a){i.rank!==0&&e.push({path:t.path,metric:o,detail:o==="booleanParameters"?r?.booleanParameterNames.join(", ")??String(i.value):`${i.value} (limit ${a})`,rank:i.rank,line:n.line,endLine:n.endLine,startColumn:n.startColumn,endColumn:n.endColumn,...r?{function:r.name}:{}})}async function TT(e,t=ET()){let r=await sT(e),n=new Map,o=[],i=t.thresholds;for(let a of e){let m=r.get(a);if(!m){let b=yT(a,"internal: file missing from the parse result");n.set(a,b),o.push({path:a,metric:"parse error",detail:b.error??"",rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}if(!m.ok){let b=yT(a,m.error);n.set(a,b),o.push({path:a,metric:"parse error",detail:m.error,rank:2,line:1,endLine:1,startColumn:1,endColumn:1});continue}let{sourceFile:c}=m,p=m.functions.map(b=>RD(b,c,a,t)),f=PD(c.text),d=wD(c),g=p.reduce((b,C)=>b+C.metrics.length.value,0),y=g===0?100:Math.round(p.reduce((b,C)=>b+C.metrics.mi.value*C.metrics.length.value,0)/g*10)/10,h={path:a,ok:!0,lines:f,metrics:{lines:{value:f,rank:cn(f,i.fileLines)},exports:{value:d,rank:cn(d,i.exports)},mi:{value:y,rank:kT(y,i.mi)}},functions:p};n.set(a,h);let I={line:1,endLine:Math.max(f,1),startColumn:1,endColumn:1};Ep(o,h,void 0,I,"file lines",h.metrics.lines,i.fileLines.warn),Ep(o,h,void 0,I,"exports",h.metrics.exports,i.exports.warn);for(let b of p){let C={line:b.startLine,endLine:b.endLine,startColumn:b.startColumn,endColumn:b.endColumn};for(let N of Rp)Ep(o,h,b,C,N,b.metrics[N],CT(N,i));for(let N of b.smells)o.push({path:a,metric:"smell",detail:`${N.label}: ${N.reason}`,rank:1,line:b.startLine,endLine:b.endLine,startColumn:b.startColumn,endColumn:b.endColumn,function:b.name})}}return{files:n,findings:o}}function Pp(e){let t=0,r=0;for(let n of e.files.values())if(n.ok)for(let o of n.functions)t+=o.metrics.length.value,r+=o.metrics.mi.value*o.metrics.length.value;return t===0?100:Math.round(r/t*10)/10}function Ap(e){let t=0,r=0,n=0,o=0;for(let i of e.files.values())i.ok||(t+=1),r+=i.functions.length;for(let i of e.findings)i.rank>=2?o+=1:n+=1;return{files:e.files.size,errorFiles:t,functions:r,findings:e.findings.length,warn:n,error:o,score:Pp(e)}}var AD=["ok","\u26A0","\u2717"],OD=[["cyclomatic","cyclomatic"],["cognitive","cognitive"],["nesting","nesting"],["length","length"],["halstead","halstead"],["mi","MI"],["parameters","parameters"],["booleanParameters","boolean params"]];function CT(e,t){return e==="mi"?t.mi.warn:e==="booleanParameters"?t.parameters.warn:t[e].warn}function kp(e,t,r,n){return`${e}${t.padEnd(15)} ${r.value} (limit ${n}) ${kD[r.rank]}`}function MD(e,t){let r=[` ${e.name.padEnd(30)} L${e.startLine}-${e.endLine}`];for(let[n,o]of OD){let i=e.metrics[n];if(i.rank!==0){if(n==="booleanParameters"){r.push(` ${o.padEnd(15)} ${e.booleanParameterNames.join(", ")} warn`);continue}r.push(kp(" ",o,i,CT(n,t.thresholds)))}}if(e.smells.length>0){r.push(` ${"smells".padEnd(15)} ${e.smells.map(n=>n.id).join(", ")}`);for(let n of e.smells)r.push(` \u2192 ${lT[n.id]??n.label}`)}return r}function IT(e){let t=e.smells.length;for(let r of Rp)e.metrics[r].rank>0&&(t+=1);return t}function vD(e,t){let r=[];for(let o of e.files.values())for(let i of o.functions)i.worstRank>0&&r.push(i);r.sort((o,i)=>{if(o.worstRank!==i.worstRank)return i.worstRank-o.worstRank;let a=IT(i)-IT(o);if(a!==0)return a;let m=i.metrics.cyclomatic.value-o.metrics.cyclomatic.value;return m!==0?m:`${o.path}:${o.name}`.localeCompare(`${i.path}:${i.name}`)});let n=new Map;for(let o of r.slice(0,t)){let i=n.get(o.path)??new Set;i.add(`${o.name}@${o.startLine}`),n.set(o.path,i)}return n}function RT(e,t,r={}){let n=Ap(e),o=r.top&&r.top>0?vD(e,r.top):void 0,i=[...e.files.values()].filter(p=>!o||(o.get(p.path)?.size??0)>0),a=Math.max(40,...i.map(p=>p.path.length)),m=[];for(let p of i){if(!p.ok){m.push(`${p.path.padEnd(a)} parse error`),m.push(` ${p.error}`);continue}m.push(`${p.path.padEnd(a)} MI ${p.metrics.mi.value} ${AD[p.metrics.mi.rank]}`),p.metrics.lines.rank>0&&m.push(kp(" ","file lines",p.metrics.lines,t.thresholds.fileLines.warn)),p.metrics.exports.rank>0&&m.push(kp(" ","exports",p.metrics.exports,t.thresholds.exports.warn));for(let f of p.functions)o&&!o.get(p.path)?.has(`${f.name}@${f.startLine}`)||f.worstRank===0&&f.smells.length===0||m.push(...MD(f,t))}m.length>0&&m.push("");let c=n.errorFiles>0?`, ${n.errorFiles} parse error(s)`:"";return m.push(`${n.findings} findings in ${n.files} files${c} \xB7 ${n.functions} functions \xB7 score ${n.score}`),m.join(`
|
|
136
|
+
`)}var Tp=new Set([".ts",".tsx",".mts",".cts"]),FD=new Set(["node_modules","dist","coverage"]);function Cp(e,t,r){for(let n of bD(e,{withFileTypes:!0})){let o=bT(e,n.name);if(n.isDirectory()){if(n.name.startsWith(".")||FD.has(n.name))continue;Cp(o,t,r);continue}n.isFile()&&Tp.has(Sp(n.name))&&r.push($T(t,o))}}function hT(e,t){let r=hD("git",["-C",e,...t],{encoding:"utf8"});if(r.error||r.status!==0){let n=r.error?r.error.message:r.stderr.trim()||`exit ${r.status}`;throw new Error(`git ${t.join(" ")} failed: ${n}`)}return r.stdout.split(`
|
|
137
|
+
`).filter(n=>n.trim().length>0)}function ND(e,t){let r=hT(e,["diff","--name-only","--diff-filter=ACMR",t]),n=hT(e,["ls-files","--others","--exclude-standard"]);return[...r,...n]}function DD(e,t){if(!t.includes("*")){let n=t.endsWith("/")?t:`${t}/`;return e===t||e.startsWith(n)}let r=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\0").replace(/\*/g,"[^/]*").replace(/\u0000/g,".*");return new RegExp(`^${r}$`).test(e)}function wT(e,t,r=[]){let n;if(t.changes)n=ND(e,t.base??"HEAD");else if(t.target){let i=SD(e,t.target),a=ED(i,{throwIfNoEntry:!1});if(!a)throw new Error(`no such path: ${t.target}`);if(a.isDirectory())n=[],Cp(i,e,n);else{if(!Tp.has(Sp(i)))throw new Error(`not a TypeScript source file: ${t.target}`);n=[$T(e,i)]}}else n=[],Cp(e,e,n);let o=new Set;for(let i of n)Tp.has(Sp(i))&&(r.some(a=>DD(i,a))||o.add(i));return[...o].sort()}var PT=6e3,AT=LD({name:"quality",label:"quality",description:"Measure code quality: cyclomatic and cognitive complexity, nesting depth, function length, Halstead volume, maintainability index, and compound smells like god-function and deeply-tangled. Read-only. Use it before reporting a task finished, especially on functions you just wrote or changed; it reports concrete numbers with line numbers and a suggested next step, so 'is this too complex' stops being a guess. Defaults to the changed files; pass a path to narrow it further.",promptSnippet:"quality: complexity and maintainability metrics for changed code",parameters:O.Object({path:O.Optional(O.String({description:"One file or directory, relative to the project root. Omit to scan the changed set."})),changes:O.Optional(O.Boolean({description:"Scan only files changed against the base ref. Default true when path is omitted."})),base:O.Optional(O.String({description:"Git ref for `changes`. Defaults to HEAD."})),top:O.Optional(O.Number({description:"Only report the N worst functions."}))}),async execute(e,t,r,n,o){let i=o.cwd??process.cwd(),a=ST(i);if(!a.enabled)return{content:[{type:"text",text:`quality metrics are off (source: ${a.source})`}],details:{off:!0}};let m=wp(i),c=t.changes??t.path===void 0,p=wT(i,{changes:c,base:t.base,target:t.path},m.ignore);if(p.length===0)return{content:[{type:"text",text:c?"no changed files to measure":"no source files found"}],details:{files:0}};let f=await TT(p,m),d=Ap(f),g=RT(f,m,{top:t.top});return{content:[{type:"text",text:g.length>PT?`${g.slice(0,PT)}
|
|
138
|
+
\u2026 (truncated; run the quality script for the full report)`:g}],details:{files:d.files,functions:d.functions,findings:d.findings,score:Pp(f)}}}});import{availableParallelism as jD}from"node:os";var _D=4;function qD(){let e=Qp(lt).agents;return e!==void 0?e:Math.max(1,Math.min(_D,jD()-2))}var Op=0,OT=[];async function Im(){for(;Op>=qD();)await new Promise(t=>OT.push(t));Op+=1;let e=!1;return()=>{e||(e=!0,Op-=1,OT.shift()?.())}}function MT(e,t){let r=e.find(o=>`${o.provider}/${o.id}`===t||o.id===t);if(r)return r;let n=t.toLowerCase();return e.find(o=>o.id.toLowerCase().includes(n)||`${o.provider}/${o.id}`.toLowerCase().includes(n))}var UD=["deepseek","qwen","claude","gpt-5","gpt-4","gemini","glm","mimo","kimi","llama"],GD=/(image|embedding|embed|whisper|tts|audio|video|rerank|moderation|dall-e|stable-diffusion|sora)/i;function BD(e){let t=r=>{if(GD.test(r))return 100;let n=UD.findIndex(o=>r.toLowerCase().includes(o));return n===-1?50:n};return e.map((r,n)=>({id:r,index:n})).sort((r,n)=>t(r.id)-t(n.id)||r.index-n.index).map(r=>r.id)}function cFe(e,t=[]){if(e.length===0)return;let r=e.filter(i=>t.includes(i.provider)),n=r.length>0?r:e,o=BD(n.map(i=>i.id))[0];return n.find(i=>i.id===o)??n[0]}import{mkdirSync as KD,readdirSync as HD,readFileSync as zD,unlinkSync as WD}from"node:fs";import{join as vp}from"node:path";import{createAgentSession as VD,DefaultResourceLoader as JD,SessionManager as XD}from"@netrodev/hxf-coding-agent";var Mp=["You are one agent on a shared task; siblings may be editing the same working tree right now.","Stay inside the files your assignment names. A file another agent owns is theirs to change: report what you need changed instead of changing it yourself, and never edit a file two agents were both given.","Never run project-wide validation (full builds, whole test suites, formatters, linters) unless your assignment explicitly tells you to.","Siblings' unfinished edits will make those runs fail for reasons that are not yours. Prove your own change with a scoped test, a targeted repro, or a smoke run instead."],QD=`You are a software architect planning an implementation. Your job is to explore the codebase and return a plan, not to write code.
|
|
139
|
+
|
|
140
|
+
## Read-only, by construction
|
|
141
|
+
You have no edit tool, no write tool, and no shell. Do not attempt to modify, create, move, or delete anything \u2014 the call would fail. Your output is text.
|
|
142
|
+
|
|
143
|
+
## Your process
|
|
144
|
+
1. Understand the requirement. If it is ambiguous in a way that changes the design, say so and name the options rather than silently picking one.
|
|
145
|
+
2. Explore: read the files involved, find the existing patterns and conventions with grep/find/ls, and trace the code paths the change touches. Follow the codebase's existing approach instead of inventing a new one.
|
|
146
|
+
3. Design: state the approach you recommend, not every alternative you considered. Note the trade-off that decided it.
|
|
147
|
+
4. Sequence: give the implementation as ordered steps, naming the files and functions to change at each one, and what to verify after each.
|
|
148
|
+
|
|
149
|
+
## Required output
|
|
150
|
+
End your reply with exactly this section, listing the 3-5 files most critical to the implementation, most important first:
|
|
151
|
+
|
|
152
|
+
### Critical Files for Implementation
|
|
153
|
+
- path/to/file.ts
|
|
154
|
+
- path/to/file.ts
|
|
155
|
+
|
|
156
|
+
Keep the plan concrete enough to execute without re-deriving it: name real paths and real function names you saw while exploring. If you could not confirm something, say which part you are unsure of instead of guessing.`,pn=new Map([["scout",{name:"scout",description:"read-only lookup",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Inspect only what the task needs. Do not edit.",...Mp].join(`
|
|
157
|
+
`),effort:"low"}],["architect",{name:"architect",description:"designs an implementation plan",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:QD,effort:"high"}],["task",{name:"task",description:"implements the assignment",tools:["read","bash","edit","write","grep","find","ls","context","todo","web_search","web_fetch","lsp"],prompt:["Do the assignment, then report files changed.",...Mp].join(`
|
|
158
|
+
`),effort:"medium"}],["reviewer",{name:"reviewer",description:"finds concrete issues",tools:["read","grep","find","ls","context","web_search","web_fetch","lsp"],prompt:["Return issues with file evidence. Do not edit.",...Mp].join(`
|
|
159
|
+
`),effort:"medium"}]]),RFe=new Set(pn.keys());function YD(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ZD(e){return e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${(e%6e4/1e3).toFixed(1)}s`}function wFe(e){let t=e.status==="parked"?"done":e.status==="error"?"failed":e.status,r=[];return e.model&&r.push(e.model),typeof e.toolUses=="number"&&r.push(`${e.toolUses} tool use${e.toolUses===1?"":"s"}`),typeof e.tokens=="number"&&e.tokens>0&&r.push(YD(e.tokens)),e.startedAt&&e.endedAt&&r.push(ZD(e.endedAt-e.startedAt)),`## ${e.agent}#${e.id} ${t}${r.length>0?` (${r.join(" \xB7 ")})`:""}`}var wt=[],eL=3,vT=8,PFe=6,hm=12;function bm(e){KD(jn,{recursive:!0}),or(vp(jn,`${e.id}.json`),JSON.stringify({...e,session:void 0},null,1))}function Fp(){let e;try{e=HD(jn)}catch{return}for(let t of e)if(t.endsWith(".json"))try{let r=JSON.parse(zD(vp(jn,t),"utf8"));if(r.status!=="parked"||wt.some(n=>n.id===r.id))continue;wt.push({...r,mail:r.mail??[]})}catch{}if(wt.length>hm){let t=wt.splice(0,wt.length-hm);for(let r of t){let n=r.session;r.session=void 0,n&&n.dispose();try{WD(vp(jn,`${r.id}.json`))}catch{}}}}function AFe(){if(Fp(),wt.length===0)return"no agents";let e=wt.map(t=>`${t.id} ${t.agent} ${t.status}${t.model?` model=${t.model}`:""}${t.background?" background":""} requests=${t.requests} ${t.task}`);return Ro&&e.unshift("background work in flight"),e.join(`
|
|
160
|
+
`)}function OFe(e){Fp();let t=wt.find(r=>r.id===e);return t?`${t.agent}#${t.id} ${t.status}
|
|
161
|
+
${t.result??t.task}`:`no agent ${e}`}async function $m(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}`);let r=e.worktree||e.cwd||process.cwd(),n=new JD({cwd:r,agentDir:lt,appendSystemPrompt:[t.prompt],additionalSkillPaths:Jp(r),extensionFactories:[Xp({interactive:!1}),sk()]});await n.reload();let{session:o}=await VD({cwd:r,agentDir:lt,sessionManager:XD.inMemory(r),resourceLoader:n,tools:t.tools,customTools:[WS,BS,Vk,Jk,rT,AT,qS],thinkingLevel:e.effort}),i=tL(e,t);if(i){let a=await o.modelRuntime.getAvailable(),m=MT(a,i);if(!m){o.dispose();let c=e.model?"asked for by the task":t.model?`named by the ${e.agent} definition${t.source?` (${t.source})`:""}`:"inherited from the parent session";throw new Error(`unknown model '${i}' ${c}. /model lists what this account can reach.`)}await o.setModel(m)}return o}async function MFe(e,t){Fp();let r=wt.find(o=>o.id===e);if(!r)return`no agent ${e}`;let n=r.session??await $m(r);if(r.session=n,r.status==="running"||n.isStreaming)return r.mail.push(t),bm(r),`queued for ${e}`;if(r.requests>=vT)return`${e} is out of budget (${r.requests} requests)`;r.status="running";try{await n.prompt(t),r.requests+=1,r.result=n.getLastAssistantText()?.trim()||r.result,r.status="parked"}catch(o){r.result=o instanceof Error?o.message:String(o),r.status="error"}return bm(r),`${e} ${r.status}`}function tL(e,t){for(let r of[e.model,t.model,e.parentModel]){let n=r?.trim();if(n)return n}}function FT(e){if(!(!e?.provider||!e.id))return`${e.provider}/${e.id}`}async function vFe(e){let t=pn.get(e.agent);if(!t)throw new Error(`unknown agent ${e.agent}. known: ${[...pn.keys()].join(", ")}`);if(wt.length>=hm)throw new Error(`${hm} agents is the limit (${wt.length} live or parked). Finish with the existing ones, or clear them with /agents, before spawning more.`);let r={id:`${Date.now().toString(36)}-${wt.length+1}`,cwd:e.cwd,agent:t.name,task:e.task.trim(),effort:e.effort||t.effort,model:(e.model||t.model)?.trim()||void 0,parentModel:e.parentModel?.trim()||void 0,background:e.background,status:"queued",requests:0,mail:[],worktree:e.worktree};return wt.push(r),bm(r),r}async function rL(e,t){if(!pn.get(e.agent))return;let n=e.session??await $m(e);e.session=n,e.startedAt=Date.now();try{let o=e.mail.splice(0).join(`
|
|
162
|
+
`);for(await n.prompt(`Task:
|
|
163
|
+
${e.task}${o?`
|
|
164
|
+
|
|
165
|
+
Messages:
|
|
166
|
+
${o}`:""}`),e.requests+=1;e.mail.length>0&&e.requests<vT;)await n.followUp(e.mail.splice(0).join(`
|
|
167
|
+
`)),e.requests+=1;if(t?.aborted)throw new Error("aborted");let i=n.getLastAssistantText()?.trim(),a=n.getSessionStats?.();if(!i&&(a?.toolCalls??0)===0)throw new Error(`agent produced no output (model ${n.model?.provider}/${n.model?.id} answered nothing; 0 tool calls). Check that the provider is reachable and the model is configured.`);e.result=i,e.status="parked"}catch(o){e.result=o instanceof Error?o.message:String(o),e.status="error"}finally{e.endedAt=Date.now();let o=n.getSessionStats?.();e.toolUses=o?.toolCalls,e.tokens=o?.tokens?.total,e.session=void 0,n.dispose(),bm(e);try{NT?.(e)}catch{}}}var NT;function FFe(e){NT=e}var Ro;function NFe(){Ro||(Ro=nL().catch(()=>{}).finally(()=>{Ro=void 0}))}async function nL(e){Ro&&await Ro.catch(()=>{});let t=()=>wt.find(n=>n.status==="queued"),r=async()=>{for(;;){if(e?.aborted)throw new Error("aborted");let n=t();if(!n)return;n.status="running";let o=await Im();try{await rL(n,e)}finally{o()}}};if(await Promise.all(Array.from({length:eL},r)),e?.aborted)throw new Error("aborted")}import{execFile as oL}from"node:child_process";import{cp as iL,readdir as sL,stat as DT}from"node:fs/promises";import{promisify as aL}from"node:util";import{tmpdir as mL}from"node:os";import{join as Em}from"node:path";var LT=aL(oL);async function Ht(e,t){try{let{stdout:r}=await LT("git",t,{cwd:e,encoding:"utf8",maxBuffer:8388608});return{ok:!0,output:r.trim()}}catch(r){let n=r&&typeof r=="object"&&"stderr"in r&&typeof r.stderr=="string"?r.stderr.trim():"",o=r instanceof Error?r.message:String(r);return{ok:!1,output:n||o}}}async function uL(e){return(await Ht(e,["rev-parse","--is-inside-work-tree"])).output==="true"}async function GFe(e){return(await Ht(e,["status","--porcelain"])).output.length>0}async function BFe(e,t){let r=await Ht(e,["add","-A"]);if(!r.ok)return r;let n=await Ht(e,["commit","-m",t]);return n.ok?{ok:!0,output:(await Ht(e,["log","-1","--oneline"])).output||n.output}:n}async function KFe(e){let t=await Ht(e,["reset","--soft","HEAD~1"]);return t.ok?{ok:!0,output:(await Ht(e,["log","-1","--oneline"])).output||"reset to the previous commit"}:t}async function HFe(e){let t=(await Ht(e,["diff"])).output,r=(await Ht(e,["diff","--cached"])).output;return[t,r].filter(Boolean).join(`
|
|
168
|
+
`)}function zFe(e,t=60){let r=e.split(`
|
|
169
|
+
`);if(r.length<=t)return e;let n=r.slice(0,t),o=r.length-t;return[...n,`\u2026 ${o} more line${o===1?"":"s"} not shown \u2014 /copy puts the full diff on the clipboard`].join(`
|
|
170
|
+
`)}var cL=["node_modules","vendor","target",".venv","venv","__pycache__",".pnpm-store","dist","build"],jT=1024*1024*1024;async function _T(e){let t=0,r;try{r=await sL(e,{withFileTypes:!0})}catch{return 0}for(let n of r){let o=Em(e,n.name);if(n.isDirectory())t+=await _T(o);else if(n.isFile())try{t+=(await DT(o)).size}catch{}if(t>jT)return t}return t}async function pL(e,t){let r=[];for(let n of cL){let o=Em(e,n),i=Em(t,n);try{if(!(await DT(o)).isDirectory())continue}catch{continue}if(await _T(o)>jT){r.push(n);continue}await fL(o,i)||r.push(n)}return r}async function fL(e,t){if(process.platform!=="win32")try{return await LT("cp",["-a",e,t],{maxBuffer:8*1024*1024}),!0}catch{}try{return await iL(e,t,{recursive:!0,force:!0,errorOnExist:!1,dereference:!1}),!0}catch{return!1}}async function qT(e,t){if(!await uL(e))return null;let r=t.replace(/[^A-Za-z0-9._-]/g,"-").slice(0,40)||"agent",n=Em(mL(),`howtofix-wt-${process.pid}-${Date.now()}-${r}`);if(!(await Ht(e,["worktree","add","--detach",n,"HEAD"])).ok)return null;let i=await pL(e,n);return{path:n,skipped:i,async remove(){await Ht(e,["worktree","remove","--force",n]),await Ht(e,["worktree","prune"])}}}import{detectCapabilities as dL,getTerminalColorMode as lL,parseColor as jr,styleText as UT}from"@netrodev/hxf-tui";function gL(){let e=process.env.NO_COLOR;if(e!==void 0&&e!=="")return"256color";try{return lL(dL())}catch{return"256color"}}var GT=gL();function xL(){let e=process.env.NO_COLOR;return e!==void 0&&e!==""}var _e={text:jr("#e6e6e6"),mute:jr("#8b8b8b"),dim:jr("#5c5c5c"),user:jr("#d0d0d0"),accent:jr("#c4b5fd"),tool:jr("#6ee7b7"),bad:jr("#f0a8a4"),warn:jr("#e6b15a"),line:jr("#3a3a3a")};function yL(e,t){if(xL()){let{bold:r,dim:n,italic:o,underline:i,strikethrough:a}=t;return!r&&!n&&!o&&!i&&!a?e:UT(e,{bold:r,dim:n,italic:o,underline:i,strikethrough:a},GT)}return UT(e,t,GT)}function at(e,t,r){return yL(e,{...r,fg:t})}var JFe={heading:e=>at(e,_e.text,{bold:!0}),link:e=>at(e,_e.accent,{underline:!0}),linkUrl:e=>at(e,_e.mute),code:e=>at(e,_e.text),codeBlock:e=>at(e,_e.text),codeBlockBorder:e=>at(e,_e.line),quote:e=>at(e,_e.mute,{italic:!0}),quoteBorder:e=>at(e,_e.line),hr:e=>at(e,_e.line),listBullet:e=>at(e,_e.mute),bold:e=>at(e,_e.text,{bold:!0}),italic:e=>at(e,_e.text,{italic:!0}),strikethrough:e=>at(e,_e.mute,{strikethrough:!0}),underline:e=>at(e,_e.text,{underline:!0})};import{truncateToWidth as Li,visibleWidth as nr}from"@netrodev/hxf-tui";var BT={text:_e.text,muted:_e.mute,dim:_e.dim,accent:_e.accent,success:_e.tool,error:_e.bad,border:_e.line},oe=(e,t,r=!1)=>r?at(t,BT[e],{bold:!0}):at(t,BT[e]),IL=25,hL=15e5,HT=420;function Po(e){let t=Math.max(0,Math.round(e/1e3)),r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h${String(n).padStart(2,"0")}m`:n>0?`${n}m${String(o).padStart(2,"0")}s`:`${o}s`}function ZFe(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:`${Math.floor(t/3600)}h`}function Lp(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}var Di=(e,t,r)=>Math.max(t,Math.min(r,e)),wo=(e,t)=>nr(e)>t?Li(e,Math.max(0,t),"\u2026"):e;function Sm(e,t,r="left"){if(t<=0)return"";let n=nr(e);if(n>t)return Li(e,t);let o=" ".repeat(t-n);return r==="right"?o+e:e+o}function jp(e,t,r,n=1){if(r<=0)return"";let o=nr(t);if(o>=r)return Li(t,r);let i=r-o-n;if(i<=0)return Sm(t,r,"right");let a=nr(e)>i?Li(e,i):e,m=" ".repeat(r-nr(a)-o);return a+m+t}function Np(e,t,r){let n=wo(e,Math.max(0,r-2)),o=Math.max(1,r-1-nr(n)),i=oe("border","\u250C\u2500 ")+oe("accent",n)+oe("border",` ${"\u2500".repeat(o)}\u2510`),a=oe("border",`\u2514${"\u2500".repeat(r+2)}\u2518`),m=oe("border","\u2502"),c=t.map(p=>`${m} ${Sm(p,r)} ${m}`);return[i,...c,a]}function bL(e,t,r,n){let o=n?.gap??1,i=n?.leftWidth??Di(Math.round(r*.38),28,44),a=r-i-o,m=Math.max(e.rows.length,t.rows.length),c=g=>{let y=[...g];for(;y.length<m;)y.push("");return y},p=Np(e.title,c(e.rows),i-4),f=Np(t.title,c(t.rows),a-4),d=" ".repeat(o);return p.map((g,y)=>g+d+(f[y]??Sm("",a)))}function zT(e,t,r){switch(e){case"running":return oe(t||r?"accent":"muted","\u25CF");case"failed":return oe("error","\u2717");default:return oe("success","\u2713")}}function WT(e,t,r,n=Date.now(),o=0){return t?n-o<HT?oe("success","\u2713",!0):oe("success","\u2713"):oe(r?"accent":"dim",String(e))}var KT="Workflow";function _p(e,t=Date.now()){let r=e.phases.map(o=>o.title),n=new Map(e.phases.map(o=>[o.title,o.detail]));for(let o of e.steps){let i=o.phase||KT;r.includes(i)||r.push(i)}return r.map((o,i)=>{let a=e.steps.filter(h=>(h.phase||KT)===o).map(h=>({...h,phaseIndex:i})),m=a.filter(h=>h.status!=="running").length,c=a.filter(h=>h.status==="failed").length,p=a.reduce((h,I)=>{let b=I.endedAt??t;return Math.max(h,b-I.startedAt)},0),f=-1;for(let h=0;h<a.length;h++){let I=a[h];I.status==="running"&&(f<0||I.startedAt>=a[f].startedAt)&&(f=h)}let d=n.get(o),g=a.length>0&&m===a.length&&c===0,y=g?a.reduce((h,I)=>Math.max(h,I.endedAt??0),0):0;return{title:o,...d?{detail:d}:{},agents:a,done:m,failed:c,outputTokens:a.reduce((h,I)=>h+I.outputTokens,0),elapsedMs:p,allDone:g,finishedAt:y,anchor:f}})}function qp(e){return e.steps.reduce((t,r)=>t+r.outputTokens,0)}function $L(e){return e.steps.reduce((t,r)=>t+(r.toolCalls??0),0)}function VT(e,t=Date.now()){return Math.max(0,(e.endedAt??t)-e.startedAt)}function EL(e){return e.steps.length>IL||qp(e)>hL}function SL(e){if(e.length===0)return 0;let t=e.map((r,n)=>({group:r,index:n})).filter(r=>r.group.anchor>=0);if(t.length>0)return t.reduce((r,n)=>{let o=n.group.agents[n.group.anchor],i=r.group.agents[r.group.anchor];return o.startedAt>=i.startedAt?n:r}).index;for(let r=e.length-1;r>=0;r--)if(e[r].agents.length>0)return r;return e.length-1}function JT(e,t=Date.now()){let r=_p(e,t),n=e.steps.length,o=e.steps.filter(p=>p.status!=="running").length,i=e.steps.filter(p=>p.status==="failed").length,a=[e.name],m=r.find(p=>p.anchor>=0);m?a.push(`${m.title} ${m.done}/${m.agents.length}`):r.length>0&&a.push(`${r[r.length-1].title} done`),a.push(`${o}/${n} agents`),a.push(`${Lp(qp(e))} tok`),a.push(Po(VT(e,t))),i>0&&a.push(`${i} failed`);let c=a.join(" \xB7 ");return EL(e)?`large workflow \xB7 ${c}`:c}var XT=16,kL=12,TL=18,CL=72,RL=24;function QT(e,t){if(e.status==="running"&&e.outputTokens===0)return[`idle ${Po(t-e.startedAt)}`,"idle"];let r=Lp(e.outputTokens),n=e.toolCalls??0,o=Po((e.endedAt??t)-e.startedAt);return[`${r} tok \xB7 ${n} tools \xB7 ${o}`,`${r} tok \xB7 ${n} tools`,`${r} tok`]}var wL=e=>e.status==="running"&&e.outputTokens===0;function Dp(e,t,r){if(e.length<=r)return{slice:e,start:0,more:0};let n=Math.max(1,r-1),o=Di(t-Math.floor(n/2),0,e.length-n),i=e.slice(o,o+n);return{slice:i,start:o,more:e.length-i.length}}function PL(e,t,r,n,o){let i=`${e.done}/${e.agents.length}`,a=r?oe("accent","\u276F"):" ",m=WT(t+1,e.allDone,r,o,e.finishedAt),c=Math.max(0,n-4-nr(i)),p=nr(e.title)>c?Li(e.title,c,"\u2026"):e.title,f=e.allDone&&o-e.finishedAt<HT,d=oe(f&&!r?"success":r?"accent":"text",p),g=`${a}${m} ${d}`,y=oe(r?"accent":"muted",i);return jp(g,y,n,1)}function AL(e,t,r,n,o,i){let a=t?oe("accent","\u276F"):" ",m=zT(e.status,t,r),c=oe(t?"accent":"text",Sm(e.label,n)),p=`${a}${m} ${c}`,f=Math.max(0,o-nr(p)-1),d=QT(e,i).find(y=>nr(y)<=f)??"",g=oe(t?"accent":wL(e)?"dim":"muted",d);return jp(p,g,o,1)}function OL(e,t,r,n){let o=[];return e.forEach((i,a)=>{let c=`${WT(a+1,i.allDone,a===r,n,i.finishedAt)} ${oe(a===r?"accent":"text",i.title)} ${oe("muted",`${i.done}/${i.agents.length}`)}`;o.push(wo(c,t));let{slice:p,more:f}=Dp(i.agents,0,XT);p.forEach((d,g)=>{let y=zT(d.status,!1,g===i.anchor),h=QT(d,n)[0]??"";o.push(wo(` ${y} ${oe("text",d.label)} ${oe("muted",h)}`,t))}),f>0&&o.push(wo(` ${oe("dim",`\u2026+${f} more`)}`,t))}),o}function ML(e,t,r){let n=r?.now??Date.now(),o=_p(e,n),i=e.steps,a=i.filter(tt=>tt.status!=="running").length,m=i.filter(tt=>tt.status==="failed").length,c=[`${a}/${i.length} agents`,`${Lp(qp(e))} tok`,`${$L(e)} tools`,Po(VT(e,n)),...m>0?[`${m} failed`]:[]].join(" \xB7 "),p=[jp(oe("accent",e.name,!0),oe("muted",c),t,2),...e.description?[oe("muted",wo(e.description,t))]:[]],f=r?.footer?[oe("muted",wo(r.footerText??vL(),t))]:[];if(o.length===0)return[...p,...Np("Phases",["(no agents yet)"],Math.max(0,t-4)),...f];let d=Di(r?.selectedPhase??SL(o),0,Math.max(0,o.length-1)),g=Di(Math.round(t*.38),28,44),y=t-g-1-4;if(t<CL||y<RL)return[...p,...OL(o,t,d,n),...f];let h=o[d],{slice:I,start:b,more:C}=Dp(o,d,kL),N=I.map((tt,Sr)=>PL(tt,b+Sr,b+Sr===d,g-4,n));C>0&&N.push(oe("dim",`\u2026+${C} more`));let G=r?.filter?r.filter(h.agents):h.agents,mt=G.length?Di(Math.max(...G.map(tt=>nr(tt.label))),6,TL):6,{slice:Qe,more:xe}=Dp(G,0,r?.agentWindow??XT),V=Qe.map((tt,Sr)=>AL(tt,!1,Sr===h.anchor,mt,y,n));xe>0&&V.push(oe("dim",`\u2026+${xe} more`));let _r=bL({title:"Phases",rows:N},{title:`${h.title} \xB7 ${G.length} agents${r?.filterLabel??""}`,rows:V},t,{leftWidth:g,gap:1});return[...p,..._r,...f]}function e1e(e,t=[],r=96,n,o){let i=ML(e,r,{now:e.endedAt??Date.now(),footer:!0,...n===void 0?{}:{selectedPhase:n},...o?.filter?{filter:o.filter}:{},...o?.footerText?{footerText:o.footerText}:{},...o?.filterLabel?{filterLabel:o.filterLabel}:{}}),a=new Set(t);if(o?.drill){let c=_p(e,e.endedAt??Date.now()),p=c[Math.max(0,Math.min(c.length-1,n??0))];for(let f of p?.agents??[])a.add(f.label)}if(a.size===0)return i;let m=[];for(let c of e.steps)if(a.has(c.label)){for(let p of c.tasks??[]){let f=p.status==="completed"?"[x]":p.status==="in_progress"?"[>]":"[ ]";m.push(` ${oe("muted",f)} ${oe("text",p.content)}`)}c.detail&&m.push(` ${oe("dim",c.detail)}`)}return m.length===0?i:[...i.slice(0,-1),...m,i[i.length-1]]}function vL(){return"\u2191/\u2193 phase \xB7 Enter drill in \xB7 Esc back out \xB7 f filter by status \xB7 p pause \xB7 x stop \xB7 s save script"}import{readFileSync as UL}from"node:fs";import{basename as GL}from"node:path";import{StringEnum as BL}from"@netrodev/hxf-ai";import{defineTool as KL}from"@netrodev/hxf-coding-agent";var Ln=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function YT(e){return e===null?"null":Array.isArray(e)?"array":Number.isInteger(e)?"integer":typeof e}function FL(e,t){let r=YT(e);return t==="number"?r==="number"||r==="integer":t==="integer"?r==="integer":r===t}function NL(e,t){if(typeof t!="string"||!t.startsWith("#/"))return;let r=e;for(let n of t.slice(2).split("/")){let o=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!Ln(r)&&!Array.isArray(r))return;r=r[o]}return Ln(r)?r:void 0}function fn(e,t,r,n,o){if(!Ln(t))return;if(t.$ref!==void 0){let a=NL(r,t.$ref);a&&fn(e,a,r,n,o);return}if(Array.isArray(t.allOf))for(let a of t.allOf)fn(e,a,r,n,o);for(let a of["anyOf","oneOf"]){let m=t[a];if(!Array.isArray(m)||m.length===0)continue;let c=m.filter(p=>{let f=[];return fn(e,p,r,n,f),f.length===0}).length;a==="anyOf"&&c===0&&o.push({path:n,message:"does not match any allowed shape"}),a==="oneOf"&&c!==1&&o.push({path:n,message:`must match exactly one shape (matched ${c})`})}let i=t.type;if(i!==void 0){let a=Array.isArray(i)?i.map(String):[String(i)];if(!a.some(m=>FL(e,m))){o.push({path:n,message:`expected ${a.join(" or ")}, got ${YT(e)}`});return}}if(Array.isArray(t.enum)&&!t.enum.some(a=>JSON.stringify(a)===JSON.stringify(e))&&o.push({path:n,message:`must be one of ${t.enum.map(a=>JSON.stringify(a)).join(", ")}`}),Ln(e)){let a=Ln(t.properties)?t.properties:{};if(Array.isArray(t.required))for(let m of t.required.map(String))m in e||o.push({path:n?`${n}.${m}`:m,message:"is required"});for(let[m,c]of Object.entries(a))m in e&&fn(e[m],c,r,n?`${n}.${m}`:m,o);if(t.additionalProperties===!1)for(let m of Object.keys(e))m in a||o.push({path:n?`${n}.${m}`:m,message:"is not an allowed property"});else if(Ln(t.additionalProperties))for(let[m,c]of Object.entries(e))m in a||fn(c,t.additionalProperties,r,n?`${n}.${m}`:m,o)}if(Array.isArray(e)&&t.items!==void 0){let a=t.items;Array.isArray(a)?e.forEach((m,c)=>{c<a.length&&fn(m,a[c],r,`${n}[${c}]`,o)}):e.forEach((m,c)=>fn(m,a,r,`${n}[${c}]`,o))}if(typeof e=="string"&&(typeof t.minLength=="number"&&e.length<t.minLength&&o.push({path:n,message:`is shorter than ${t.minLength} characters`}),typeof t.pattern=="string"))try{new RegExp(t.pattern).test(e)||o.push({path:n,message:`does not match ${t.pattern}`})}catch{}typeof e=="number"&&(typeof t.minimum=="number"&&e<t.minimum&&o.push({path:n,message:`is below ${t.minimum}`}),typeof t.maximum=="number"&&e>t.maximum&&o.push({path:n,message:`is above ${t.maximum}`}))}function ZT(e,t){if(!Ln(t))return[];let r=[];return fn(e,t,t,"",r),r}function eC(e){return e.map(t=>`- ${t.path||"(root)"}: ${t.message}`).join(`
|
|
171
|
+
`)}function tC(e){let t=e.trim(),r=/```(?:json)?\s*([\s\S]*?)```/.exec(t),n=[t,r?.[1]?.trim()].filter(o=>!!o);for(let o of n){try{return JSON.parse(o)}catch{}for(let i=0;i<o.length;i++){let a=o[i];if(a!=="{"&&a!=="[")continue;let m=a==="{"?"}":"]",c=0,p=!1,f=!1;for(let d=i;d<o.length;d++){let g=o[d];if(p){f?f=!1:g==="\\"?f=!0:g==='"'&&(p=!1);continue}if(g==='"')p=!0;else if(g===a)c++;else if(g===m&&(c--,c===0))try{return JSON.parse(o.slice(i,d+1))}catch{break}}}}}var DL=1e3,LL=4096,rC=100,nC=300*1e3;async function jL(e,t=rC,r=nC){let n=Date.now()+r;for(;e.isPaused?.();){if(e.signal?.aborted||Date.now()>=n)return!1;await new Promise(o=>setTimeout(o,t))}return!0}var We=class extends Error{constructor(t){super(t),this.name="WorkflowError"}};function _L(e){let t=0,r=[];return async function(){t>=e&&await new Promise(i=>r.push(i)),t++;let o=!1;return()=>{o||(o=!0,t--,r.shift()?.())}}}function oC(e){let t=e.lifetimeCap??DL,r=e.fanoutCap??LL,n=e.concurrency?_L(e.concurrency):null,o=async()=>{let b=await Im();if(!n)return b;let C=await n();return()=>{C(),b()}},i=0,a=0,m="",c=b=>e.onEvent?.(b),p=new Map,f=()=>e.onProgress?.([...p.values()]),d=async(b,C)=>{let N=C??{},G=typeof N.label=="string"?N.label:`agent-${i+1}`,mt=typeof N.phase=="string"?N.phase:m,Qe=typeof N.agentType=="string"?N.agentType:"task",xe=typeof N.effort=="string"?N.effort:void 0,V=typeof N.model=="string"?N.model:void 0,_r=typeof N.isolation=="string"?N.isolation:void 0,tt=N.schema;if(e.budgetTotal!=null&&a>=e.budgetTotal)throw new We(`budget exhausted: spent ${a} of ${e.budgetTotal} output tokens`);if(i>=t)throw new We(`lifetime cap reached: ${t} agent calls in one run`);i++;let Sr=i;if(e.isPaused?.()&&!await jL(e,rC,nC))return null;let dC=await o();try{if(e.signal?.aborted)return null;c({kind:"agent_start",label:G,phase:mt,ordinal:i}),p.set(Sr,{label:G,phase:mt,agentType:Qe,status:"running",outputTokens:0,...V?{model:V}:{},startedAt:Date.now()}),f();let Ao=(dn,qr,_t)=>{let zt=p.get(Sr);zt&&(zt.status=dn,zt.outputTokens=qr.outputTokens,zt.endedAt=Date.now(),qr.toolCalls!==void 0&&(zt.toolCalls=qr.toolCalls),qr.model!==void 0&&(zt.model=qr.model),_t&&(zt.detail=_t)),c({kind:"agent_end",label:G,ok:dn==="ok",outputTokens:qr.outputTokens}),f()},Wp=tt===void 0?1:2;for(let dn=0;dn<Wp;dn++){let qr=dn===0?String(b):void 0,_t=await y(qr??qL(String(b),g),{label:G,phase:mt,agentType:Qe,effort:xe,model:V,isolation:_r});if(_t===null)return Ao("failed",{text:"",outputTokens:0}),null;if(a+=_t.outputTokens,tt===void 0)return Ao("ok",_t,Up(_t.text)),_t.text;let zt=tC(_t.text),Vp=zt===void 0?[{path:"",message:"reply was not JSON"}]:ZT(zt,tt);if(Vp.length===0)return Ao("ok",_t,Up(_t.text)),zt;if(g=eC(Vp),dn===Wp-1)return Ao("failed",_t,`schema: ${Up(g)}`),null}return null}finally{dC()}},g="",y=async(b,C)=>{try{return await e.invoke({prompt:b,...C})}catch{return null}};return{agent:(b,C)=>d(b,C),parallel:async b=>{if(b.length>r)throw new We(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async N=>{try{return await N()}catch{return null}}))},pipeline:async(b,...C)=>{if(b.length>r)throw new We(`fan-out cap exceeded: ${b.length} items (max ${r})`);return await Promise.all(b.map(async(G,mt)=>{let Qe=G;for(let xe of C)try{Qe=await xe(Qe,G,mt)}catch{return null}return Qe}))},phase:b=>{m=String(b),c({kind:"phase",title:m})},log:b=>c({kind:"log",message:String(b)}),args:e.args,budget:{total:e.budgetTotal??null,spent:()=>a,remaining:()=>e.budgetTotal==null?1/0:Math.max(0,e.budgetTotal-a)}}}function qL(e,t){return`${e}
|
|
172
|
+
|
|
173
|
+
Your previous reply did not satisfy the required schema:
|
|
174
|
+
${t}
|
|
175
|
+
|
|
176
|
+
Reply with ONLY a corrected JSON value.`}function Up(e,t=80){let r=e.split(`
|
|
177
|
+
`).map(n=>n.trim()).find(n=>n.length>0)??"";return r.length>t?`${r.slice(0,t)}\u2026`:r}var Gp="workflow",iC=null;function g1e(e){iC=e}var HL=600*1e3;function zL(e){let t=e.replace(/^(?:\s+|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*/,""),r=/^export\s+const\s+meta\s*=\s*/.exec(t);if(!r)throw new We("a workflow script must start with `export const meta = { name, description }`");let n=e.length-t.length,o=r[0].length,i=0,a=null,m=-1;for(let y=o;y<t.length;y++){let h=t[y];if(a){h==="\\"?y++:h===a&&(a=null);continue}if(h==='"'||h==="'"||h==="`")a=h;else if(h==="{"||h==="[")i++;else if((h==="}"||h==="]")&&(i--,i===0)){m=y+1;break}}if(m===-1)throw new We("meta is not a closed literal object");let c=t.slice(o,m),p=e.slice(n+m).replace(/^\s*;/,"");if(/^\s*(import|export)\b/m.test(p))throw new We("a workflow body must not contain import or export declarations");if(/\bimport\s*\(/.test(p))throw new We("a workflow body must not use dynamic import()");let f;try{f=new Function(`"use strict"; return (${c});`)()}catch(y){throw new We(`meta must be a literal object: ${y instanceof Error?y.message:String(y)}`)}if(typeof f!="object"||f===null)throw new We("meta must be an object");let d=f;if(typeof d.name!="string"||!d.name.trim())throw new We("meta.name is required");if(typeof d.description!="string"||!d.description.trim())throw new We("meta.description is required");let g=Array.isArray(d.phases)?d.phases.filter(y=>typeof y=="object"&&y!==null).map(y=>({title:String(y.title??""),...typeof y.detail=="string"?{detail:y.detail}:{}})).filter(y=>y.title):void 0;return{meta:{name:d.name,description:d.description,...typeof d.whenToUse=="string"?{whenToUse:d.whenToUse}:{},...g?{phases:g}:{}},body:p}}function WL(e){let t=["agent","parallel","pipeline","phase","log","args","budget"],r=`"use strict"; return (async () => {
|
|
178
|
+
${e}
|
|
179
|
+
})();`,n;try{n=new Function(...t,r)}catch(o){throw new We(`workflow did not compile: ${o instanceof Error?o.message:String(o)}`)}return n}function VL(e){return e.getLastAssistantText()?.trim()??""}function JL(e){return async({prompt:t,agentType:r,effort:n,model:o,isolation:i})=>{let a=pn.get(r)??pn.get("task");if(!a)throw new We(`no agent named ${r}`);let m=i==="worktree"?await qT(process.cwd(),r):null,c=await $m({agent:a.name,effort:n??a.effort,...o?{model:o}:{},...e?{parentModel:e}:{},...m?{worktree:m.path}:{}});try{await c.prompt(`${a.prompt}
|
|
180
|
+
|
|
181
|
+
Task:
|
|
182
|
+
${t}`);let p=c.getSessionStats(),f=XL(c)??o;return{text:VL(c),outputTokens:p.tokens.output,toolCalls:p.toolCalls,...f?{model:f}:{}}}finally{c.dispose(),await m?.remove()}}}function XL(e){return e.model?.id??e.model?.name}var QL=O.Object({code:O.Optional(O.String({description:"The workflow script source"})),path:O.Optional(O.String({description:"Path to a workflow script, instead of code"})),agent:O.Optional(BL(["scout","task","reviewer"],{description:"Default agent profile for calls"})),budget:O.Optional(O.Number({description:"Output-token ceiling for the whole run"}))});function x1e(e){let t=()=>e??iC;return KL({name:"workflow",label:"workflow",description:"Run a JavaScript workflow that orchestrates many agents deterministically. Provide `code` (or `path`). The script starts with `export const meta = { name, description, phases }` and then uses the injected bindings: `agent(prompt, {label, phase, schema, effort, model, agentType, isolation})`, `parallel(thunks)`, `pipeline(items, ...stages)`, `phase(title)`, `log(msg)`, `args`, `budget`. `agent()` resolves null on failure and throws only when the budget or the call cap is exhausted, so null-check every result. `parallel()` takes thunks and never rejects; `pipeline()` has no barrier between items. Use it for fan-out, for builder-verifier loops that converge on a verdict, and for anything needing many agents whose order and count must be deterministic.",promptSnippet:"workflow: orchestrate many agents from one JavaScript script",parameters:QL,executionMode:"sequential",async execute(r,n,o,i,a){let m=n.path?UL(n.path,"utf8"):n.code??"";if(!m.trim())throw new We("provide code or path");let{meta:c,body:p}=zL(m);if(n.path){let xe=GL(n.path).replace(/\.(js|mjs|cjs|ts)$/,"");if(xe!==c.name)throw new We(`meta.name "${c.name}" must match the script filename "${xe}"`)}let f=WL(p),d=Date.now(),g=[],y=0,h=0,I=(xe,V)=>({name:c.name,...c.description?{description:c.description}:{},ok:xe,agents:h,outputTokens:y,startedAt:d,phases:c.phases??[],steps:g,...V?{error:V}:{}}),b=(xe,V)=>{a.ui.setStatus(Gp,V?void 0:JT(xe)),i?.({content:[],details:I(!1)})},C=xe=>{h=xe.length,y=xe.reduce((V,_r)=>V+_r.outputTokens,0),g.splice(0,g.length,...xe.map(V=>({label:V.label,phase:V.phase,agent:V.agentType,status:V.status,outputTokens:V.outputTokens,startedAt:V.startedAt,...V.toolCalls!==void 0?{toolCalls:V.toolCalls}:{},...V.model?{model:V.model}:{},...V.endedAt?{endedAt:V.endedAt}:{},...V.detail?{detail:V.detail}:{},...V.tasks?{tasks:V.tasks}:{}}))),b({name:c.name,...c.description?{description:c.description}:{},phases:c.phases??[],steps:g,startedAt:d},!1)},N=JL(FT(a?.model)),G=oC({invoke:n.agent?YL(N,n.agent):N,budgetTotal:n.budget??null,onProgress:C,...o?{signal:o}:{},...t()?.isPaused?{isPaused:t().isPaused}:{}}),mt=new AbortController,Qe=setTimeout(()=>mt.abort(),HL);o&&o.addEventListener("abort",()=>mt.abort(),{once:!0}),t()?.onStop?.(()=>mt.abort());try{let xe=await Promise.race([f(G.agent,G.parallel,G.pipeline,G.phase,G.log,G.args,G.budget),new Promise((_r,tt)=>mt.signal.addEventListener("abort",()=>tt(new We("workflow timed out or was aborted"))))]),V=Date.now();return a.ui.setStatus(Gp,void 0),{content:[{type:"text",text:`${c.name}: ${h} agent call(s), ${y} output tokens in ${Po(V-d)}
|
|
183
|
+
|
|
184
|
+
${ZL(xe)}`}],details:{...I(!0),endedAt:V}}}catch(xe){let V=xe instanceof Error?xe.message:String(xe);return a.ui.setStatus(Gp,void 0),{content:[{type:"text",text:`${c.name} failed after ${h} agent call(s): ${V}`}],details:{...I(!1,V),endedAt:Date.now()},isError:!0}}finally{clearTimeout(Qe),t()?.onStop?.(null)}}})}function YL(e,t){return r=>e({...r,agentType:t})}function ZL(e){if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}import{execFile as ej,execFileSync as tj}from"node:child_process";import{promisify as rj}from"node:util";import{createHash as mC}from"node:crypto";import{copyFileSync as nj,existsSync as km,mkdirSync as Tm,readFileSync as Hp,readdirSync as oj,rmSync as ij,statSync as Bp}from"node:fs";import{dirname as uC,join as Pt,resolve as Cm}from"node:path";var Kp=Pt(lt,"rewind"),Rm="refs/howtofix",sC=100,cC=30,pC="project.json",fC="checkpoints.json",aC=!1;function sj(e){let t=Cm(e);for(;;){if(km(Pt(t,".git")))return!0;let r=uC(t);if(r===t)return!1;t=r}}var aj=rj(ej);async function jt(e,t){let r={...process.env};for(let o of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_COMMON_DIR"])delete r[o];r.GIT_DIR=e.gitDir,r.GIT_WORK_TREE=e.root,r.GIT_AUTHOR_NAME=r.GIT_COMMITTER_NAME="howtofix",r.GIT_AUTHOR_EMAIL=r.GIT_COMMITTER_EMAIL="howtofix@local";let{stdout:n}=await aj("git",t,{cwd:e.root,env:r,encoding:"utf8",maxBuffer:8*1024*1024});return n.trim()}function mj(e){return mC("sha1").update(e).digest("hex").slice(0,16)}function T1e(e){let t=Cm(e).replace(/\/+$/,"")||"/",r=Pt(Kp,mj(t)),n=Pt(r,"git"),o={root:t,gitDir:n,metaFile:Pt(r,fC),disabled:!1};return!km(Pt(n,"HEAD"))&&!sj(t)?(o.disabled=!0,o):(Tm(r,{recursive:!0}),km(Pt(n,"HEAD"))||(Tm(n,{recursive:!0}),tj("git",["init","--quiet","--initial-branch=howtofix"],{env:{...process.env,GIT_DIR:n},stdio:["ignore","ignore","pipe"]})),uj(t,n),cj(r,t),aC||(aC=!0,fj({keep:r})),o)}function uj(e,t){let r=Pt(e,".git","info","exclude");try{if(!Bp(r).isFile())return;Tm(Pt(t,"info"),{recursive:!0}),nj(r,Pt(t,"info","exclude"))}catch{}}function cj(e,t){let r=Pt(e,pC),n=`${JSON.stringify({version:1,root:t})}
|
|
185
|
+
`;try{if(Hp(r,"utf8")===n)return}catch{}try{or(r,n)}catch{}}function wm(e){try{let t=JSON.parse(Hp(e.metaFile,"utf8"));if(t?.version===1&&t.sessions)return t}catch{}return{version:1,sessions:{}}}function zp(e,t){Tm(uC(e.metaFile),{recursive:!0}),or(e.metaFile,`${JSON.stringify(t,null,1)}
|
|
186
|
+
`)}function pj(e,t){return e.disabled?[]:[...wm(e).sessions[t]??[]].sort((r,n)=>r.at-n.at)}async function C1e(e,t,r){if(e.disabled)return null;let n;try{await jt(e,["add","-A","--ignore-errors","--"]),n=await jt(e,["write-tree"])}catch{return null}let i=pj(e,t).find(g=>g.tree===n),a=Date.now(),m=`${a.toString(36)}-${mC("sha1").update(`${n}:${a}`).digest("hex").slice(0,6)}`,c=i?.commit;if(!c){let g=["howtofix checkpoint",`session ${t}`,`created ${new Date(a).toISOString()}`,`prompt ${r.slice(0,200)}`].join(`
|
|
187
|
+
`);c=await jt(e,["commit-tree",n,"-m",g]),await jt(e,["update-ref",`${Rm}/${m}`,c])}let p={id:m,tree:n,commit:c,prompt:r,at:a},f=wm(e),d=[...f.sessions[t]??[],p];for(let g of d.slice(0,Math.max(0,d.length-sC)))try{await jt(e,["update-ref","-d",`${Rm}/${g.id}`])}catch{}return f.sessions[t]=d.slice(-sC),zp(e,f),p}async function R1e(e,t){let r=[];if(e.disabled)return{ok:!1,output:"checkpoints are off: this directory is not a git repository",removed:r};try{await jt(e,["read-tree","--reset","-u",t.tree])}catch(n){return{ok:!1,output:n instanceof Error?n.message:String(n),removed:r}}try{let n=await jt(e,["clean","-fd"]);for(let o of n.split(`
|
|
188
|
+
`)){let i=/^Removing\s+(.+)$/.exec(o.trim());i?.[1]&&r.push(i[1])}}catch{}return{ok:!0,output:`restored ${t.prompt||"the checkpoint"}`,removed:r}}async function w1e(e,t){if(e.disabled)return[];try{await jt(e,["add","-A","--ignore-errors","--"]);let r=await jt(e,["write-tree"]);return r===t.tree?[]:(await jt(e,["diff-tree","-r","--name-status","--no-commit-id",t.tree,r])).split(`
|
|
189
|
+
`).filter(Boolean).map(o=>{let[i,...a]=o.split(" ");return`${i?.[0]??"?"} ${a.at(-1)??""}`})}catch{return[]}}async function P1e(e,t={}){let r={droppedSessions:0,droppedRefs:0};if(e.disabled)return r;let n=(t.now??Date.now())-cC*24*60*60*1e3,o=wm(e),i=!1;for(let[a,m]of Object.entries(o.sessions))if(!(a===t.keep||m.reduce((p,f)=>Math.max(p,f.at),0)>=n)){delete o.sessions[a],i=!0,r.droppedSessions+=1;for(let p of m)try{await jt(e,["update-ref","-d",`${Rm}/${p.id}`]),r.droppedRefs+=1}catch{}}if(!i)return r;zp(e,o);try{await jt(e,["gc","--quiet","--prune=now"])}catch{}return r}function fj(e={}){let t={removedDirs:0,failed:[]},r;try{r=oj(Kp,{withFileTypes:!0})}catch{return t}let n=(e.now??Date.now())-cC*24*60*60*1e3,o=e.keep?Cm(e.keep):void 0;for(let i of r){if(!i.isDirectory())continue;let a=Pt(Kp,i.name);if(Cm(a)!==o)try{(dj(a)||lj(a)<n)&&(ij(a,{recursive:!0,force:!0}),t.removedDirs+=1)}catch{t.failed.push(i.name)}}return t}function dj(e){try{let t=JSON.parse(Hp(Pt(e,pC),"utf8"));return typeof t?.root!="string"||t.root.length===0?!1:!km(t.root)}catch{return!1}}function lj(e){try{return Bp(Pt(e,fC)).mtimeMs}catch{return Bp(e).mtimeMs}}async function A1e(e,t){if(e.disabled)return;let r=wm(e);for(let n of r.sessions[t]??[])try{await jt(e,["update-ref","-d",`${Rm}/${n.id}`])}catch{}delete r.sessions[t],zp(e,r)}export{Eo as a,am as b,o1 as c,dPe as d,lPe as e,gPe as f,xPe as g,$Pe as h,EPe as i,I1 as j,CPe as k,RPe as l,wPe as m,UPe as n,GPe as o,BPe as p,KPe as q,HPe as r,qS as s,O as t,BS as u,WS as v,VS as w,SOe as x,H1 as y,kOe as z,TOe as A,COe as B,ROe as C,z1 as D,wOe as E,W1 as F,V1 as G,POe as H,DOe as I,LOe as J,jOe as K,_Oe as L,qOe as M,UOe as N,Kc as O,GOe as P,BOe as Q,KOe as R,HOe as S,sk as T,Wc as U,xN as V,vi as W,$N as X,ON as Y,MN as Z,vN as _,FN as $,_N as aa,Vk as ba,Jk as ca,nD as da,rT as ea,AT as fa,_D as ga,qD as ha,MT as ia,BD as ja,cFe as ka,pn as la,RFe as ma,wFe as na,wt as oa,PFe as pa,AFe as qa,OFe as ra,MFe as sa,FT as ta,vFe as ua,FFe as va,NFe as wa,nL as xa,uL as ya,GFe as za,BFe as Aa,KFe as Ba,HFe as Ca,zFe as Da,qT as Ea,GT as Fa,_e as Ga,at as Ha,JFe as Ia,HT as Ja,Po as Ka,ZFe as La,_p as Ma,e1e as Na,g1e as Oa,x1e as Pa,cC as Qa,T1e as Ra,pj as Sa,C1e as Ta,R1e as Ua,w1e as Va,P1e as Wa,A1e as Xa};
|