-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathcomet-hook-router.mjs
More file actions
166 lines (161 loc) · 222 KB
/
Copy pathcomet-hook-router.mjs
File metadata and controls
166 lines (161 loc) · 222 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env node
import { createRequire as __cometCreateRequire } from 'module';
const require = __cometCreateRequire(import.meta.url);
var Ff=Object.create;var kn=Object.defineProperty;var Wf=Object.getOwnPropertyDescriptor;var qf=Object.getOwnPropertyNames;var Hf=Object.getPrototypeOf,Gf=Object.prototype.hasOwnProperty;var ji=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var M=(t,e,i)=>()=>{if(i)throw i[0];try{return t&&(e=t(t=0)),e}catch(r){throw i=[r],r}};var v=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(i){throw e=0,i}},zf=(t,e)=>{for(var i in e)kn(t,i,{get:e[i],enumerable:!0})},Vf=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qf(e))!Gf.call(t,n)&&n!==i&&kn(t,n,{get:()=>e[n],enumerable:!(r=Wf(e,n))||r.enumerable});return t};var xt=(t,e,i)=>(i=t!=null?Ff(Hf(t)):{},Vf(e||!t||!t.__esModule?kn(i,"default",{value:t,enumerable:!0}):i,t));var C=v($=>{"use strict";var Sn=Symbol.for("yaml.alias"),Ja=Symbol.for("yaml.document"),Li=Symbol.for("yaml.map"),Ua=Symbol.for("yaml.pair"),En=Symbol.for("yaml.scalar"),$i=Symbol.for("yaml.seq"),he=Symbol.for("yaml.node.type"),Kf=t=>!!t&&typeof t=="object"&&t[he]===Sn,Jf=t=>!!t&&typeof t=="object"&&t[he]===Ja,Uf=t=>!!t&&typeof t=="object"&&t[he]===Li,Yf=t=>!!t&&typeof t=="object"&&t[he]===Ua,Ya=t=>!!t&&typeof t=="object"&&t[he]===En,Xf=t=>!!t&&typeof t=="object"&&t[he]===$i;function Xa(t){if(t&&typeof t=="object")switch(t[he]){case Li:case $i:return!0}return!1}function Qf(t){if(t&&typeof t=="object")switch(t[he]){case Sn:case Li:case En:case $i:return!0}return!1}var Zf=t=>(Ya(t)||Xa(t))&&!!t.anchor;$.ALIAS=Sn;$.DOC=Ja;$.MAP=Li;$.NODE_TYPE=he;$.PAIR=Ua;$.SCALAR=En;$.SEQ=$i;$.hasAnchor=Zf;$.isAlias=Kf;$.isCollection=Xa;$.isDocument=Jf;$.isMap=Uf;$.isNode=Qf;$.isPair=Yf;$.isScalar=Ya;$.isSeq=Xf});var Rt=v(Cn=>{"use strict";var L=C(),W=Symbol("break visit"),Qa=Symbol("skip children"),se=Symbol("remove node");function Di(t,e){let i=Za(e);L.isDocument(t)?rt(null,t.contents,i,Object.freeze([t]))===se&&(t.contents=null):rt(null,t,i,Object.freeze([]))}Di.BREAK=W;Di.SKIP=Qa;Di.REMOVE=se;function rt(t,e,i,r){let n=es(t,e,i,r);if(L.isNode(n)||L.isPair(n))return ts(t,r,n),rt(t,n,i,r);if(typeof n!="symbol"){if(L.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let a=rt(o,e.items[o],i,r);if(typeof a=="number")o=a-1;else{if(a===W)return W;a===se&&(e.items.splice(o,1),o-=1)}}}else if(L.isPair(e)){r=Object.freeze(r.concat(e));let o=rt("key",e.key,i,r);if(o===W)return W;o===se&&(e.key=null);let a=rt("value",e.value,i,r);if(a===W)return W;a===se&&(e.value=null)}}return n}async function Bi(t,e){let i=Za(e);L.isDocument(t)?await nt(null,t.contents,i,Object.freeze([t]))===se&&(t.contents=null):await nt(null,t,i,Object.freeze([]))}Bi.BREAK=W;Bi.SKIP=Qa;Bi.REMOVE=se;async function nt(t,e,i,r){let n=await es(t,e,i,r);if(L.isNode(n)||L.isPair(n))return ts(t,r,n),nt(t,n,i,r);if(typeof n!="symbol"){if(L.isCollection(e)){r=Object.freeze(r.concat(e));for(let o=0;o<e.items.length;++o){let a=await nt(o,e.items[o],i,r);if(typeof a=="number")o=a-1;else{if(a===W)return W;a===se&&(e.items.splice(o,1),o-=1)}}}else if(L.isPair(e)){r=Object.freeze(r.concat(e));let o=await nt("key",e.key,i,r);if(o===W)return W;o===se&&(e.key=null);let a=await nt("value",e.value,i,r);if(a===W)return W;a===se&&(e.value=null)}}return n}function Za(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function es(t,e,i,r){if(typeof i=="function")return i(t,e,r);if(L.isMap(e))return i.Map?.(t,e,r);if(L.isSeq(e))return i.Seq?.(t,e,r);if(L.isPair(e))return i.Pair?.(t,e,r);if(L.isScalar(e))return i.Scalar?.(t,e,r);if(L.isAlias(e))return i.Alias?.(t,e,r)}function ts(t,e,i){let r=e[e.length-1];if(L.isCollection(r))r.items[t]=i;else if(L.isPair(r))t==="key"?r.key=i:r.value=i;else if(L.isDocument(r))r.contents=i;else{let n=L.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Cn.visit=Di;Cn.visitAsync=Bi});var Pn=v(rs=>{"use strict";var is=C(),ed=Rt(),td={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},id=t=>t.replace(/[!,[\]{}]/g,e=>td[e]),_t=class t{constructor(e,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,i)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,i){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[o,a]=r;return this.tags[o]=a,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[o]=r;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let a=/^\d+\.\d+$/.test(o);return i(6,`Unsupported YAML version ${o}`,a),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(e,i){if(e==="!")return"!";if(e[0]!=="!")return i(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let a=e.slice(2,-1);return a==="!"||a==="!!"?(i(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&i("Verbatim tags must end with a >"),a)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||i(`The ${e} tag has no suffix`);let o=this.tags[r];if(o)try{return o+decodeURIComponent(n)}catch(a){return i(String(a)),null}return r==="!"?e:(i(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[i,r]of Object.entries(this.tags))if(e.startsWith(r))return i+id(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&is.isNode(e.contents)){let o={};ed.visit(e.contents,(a,s)=>{is.isNode(s)&&s.tag&&(o[s.tag]=!0)}),n=Object.keys(o)}else n=[];for(let[o,a]of r)o==="!!"&&a==="tag:yaml.org,2002:"||(!e||n.some(s=>s.startsWith(a)))&&i.push(`%TAG ${o} ${a}`);return i.join(`
`)}};_t.defaultYaml={explicit:!1,version:"1.2"};_t.defaultTags={"!!":"tag:yaml.org,2002:"};rs.Directives=_t});var Mi=v(At=>{"use strict";var ns=C(),rd=Rt();function nd(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(i)}return!0}function os(t){let e=new Set;return rd.visit(t,{Value(i,r){r.anchor&&e.add(r.anchor)}}),e}function as(t,e){for(let i=1;;++i){let r=`${t}${i}`;if(!e.has(r))return r}}function od(t,e){let i=[],r=new Map,n=null;return{onAnchor:o=>{i.push(o),n??(n=os(t));let a=as(e,n);return n.add(a),a},setAnchors:()=>{for(let o of i){let a=r.get(o);if(typeof a=="object"&&a.anchor&&(ns.isScalar(a.node)||ns.isCollection(a.node)))a.node.anchor=a.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=o,s}}},sourceObjects:r}}At.anchorIsValid=nd;At.anchorNames=os;At.createNodeAnchors=od;At.findNewAnchor=as});var xn=v(ss=>{"use strict";function Tt(t,e,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,o=r.length;n<o;++n){let a=r[n],s=Tt(t,r,String(n),a);s===void 0?delete r[n]:s!==a&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let o=r.get(n),a=Tt(t,r,n,o);a===void 0?r.delete(n):a!==o&&r.set(n,a)}else if(r instanceof Set)for(let n of Array.from(r)){let o=Tt(t,r,n,n);o===void 0?r.delete(n):o!==n&&(r.delete(n),r.add(o))}else for(let[n,o]of Object.entries(r)){let a=Tt(t,r,n,o);a===void 0?delete r[n]:a!==o&&(r[n]=a)}return t.call(e,i,r)}ss.applyReviver=Tt});var Ne=v(ls=>{"use strict";var ad=C();function cs(t,e,i){if(Array.isArray(t))return t.map((r,n)=>cs(r,String(n),i));if(t&&typeof t.toJSON=="function"){if(!i||!ad.hasAnchor(t))return t.toJSON(e,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(t,r),i.onCreate=o=>{r.res=o,delete i.onCreate};let n=t.toJSON(e,i);return i.onCreate&&i.onCreate(n),n}return typeof t=="bigint"&&!i?.keep?Number(t):t}ls.toJS=cs});var Fi=v(fs=>{"use strict";var sd=xn(),us=C(),cd=Ne(),Rn=class{constructor(e){Object.defineProperty(this,us.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:o}={}){if(!us.isDocument(e))throw new TypeError("A document argument is required");let a={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=cd.toJS(this,"",a);if(typeof n=="function")for(let{count:c,res:l}of a.anchors.values())n(l,c);return typeof o=="function"?sd.applyReviver(o,{"":s},"",s):s}};fs.NodeBase=Rn});var Ot=v(ds=>{"use strict";var ld=Mi(),ud=Rt(),ot=C(),fd=Fi(),dd=Ne(),_n=class extends fd.NodeBase{constructor(e){super(ot.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],ud.visit(e,{Node:(o,a)=>{(ot.isAlias(a)||ot.hasAnchor(a))&&r.push(a)}}),i&&(i.aliasResolveCache=r));let n;for(let o of r){if(o===this)break;o.anchor===this.source&&(n=o)}return n}toJSON(e,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:o}=i,a=this.resolve(n,i);if(!a){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(a);if(s||(dd.toJS(a,null,i),s=r.get(a)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Wi(n,a,r)),s.count*s.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(e,i,r){let n=`*${this.source}`;if(e){if(ld.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${n} `}return n}};function Wi(t,e,i){if(ot.isAlias(e)){let r=e.resolve(t),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(ot.isCollection(e)){let r=0;for(let n of e.items){let o=Wi(t,n,i);o>r&&(r=o)}return r}else if(ot.isPair(e)){let r=Wi(t,e.key,i),n=Wi(t,e.value,i);return Math.max(r,n)}return 1}ds.Alias=_n});var O=v(An=>{"use strict";var hd=C(),md=Fi(),pd=Ne(),gd=t=>!t||typeof t!="function"&&typeof t!="object",ke=class extends md.NodeBase{constructor(e){super(hd.SCALAR),this.value=e}toJSON(e,i){return i?.keep?this.value:pd.toJS(this.value,e,i)}toString(){return String(this.value)}};ke.BLOCK_FOLDED="BLOCK_FOLDED";ke.BLOCK_LITERAL="BLOCK_LITERAL";ke.PLAIN="PLAIN";ke.QUOTE_DOUBLE="QUOTE_DOUBLE";ke.QUOTE_SINGLE="QUOTE_SINGLE";An.Scalar=ke;An.isScalarValue=gd});var It=v(ms=>{"use strict";var wd=Ot(),Le=C(),hs=O(),vd="tag:yaml.org,2002:";function yd(t,e,i){if(e){let r=i.filter(o=>o.tag===e),n=r.find(o=>!o.format)??r[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return i.find(r=>r.identify?.(t)&&!r.format)}function bd(t,e,i){if(Le.isDocument(t)&&(t=t.contents),Le.isNode(t))return t;if(Le.isPair(t)){let u=i.schema[Le.MAP].createNode?.(i.schema,null,i);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:o,schema:a,sourceObjects:s}=i,c;if(r&&t&&typeof t=="object"){if(c=s.get(t),c)return c.anchor??(c.anchor=n(t)),new wd.Alias(c.anchor);c={anchor:null,node:null},s.set(t,c)}e?.startsWith("!!")&&(e=vd+e.slice(2));let l=yd(t,e,a.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new hs.Scalar(t);return c&&(c.node=u),u}l=t instanceof Map?a[Le.MAP]:Symbol.iterator in Object(t)?a[Le.SEQ]:a[Le.MAP]}o&&(o(l),delete i.onTagObj);let f=l?.createNode?l.createNode(i.schema,t,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,t,i):new hs.Scalar(t);return e?f.tag=e:l.default||(f.tag=l.tag),c&&(c.node=f),f}ms.createNode=bd});var Hi=v(qi=>{"use strict";var Nd=It(),ce=C(),kd=Fi();function Tn(t,e,i){let r=i;for(let n=e.length-1;n>=0;--n){let o=e[n];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let a=[];a[o]=r,r=a}else r=new Map([[o,r]])}return Nd.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var ps=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,On=class extends kd.NodeBase{constructor(e,i){super(e),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(e){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(i.schema=e),i.items=i.items.map(r=>ce.isNode(r)||ce.isPair(r)?r.clone(e):r),this.range&&(i.range=this.range.slice()),i}addIn(e,i){if(ps(e))this.add(i);else{let[r,...n]=e,o=this.get(r,!0);if(ce.isCollection(o))o.addIn(n,i);else if(o===void 0&&this.schema)this.set(r,Tn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[i,...r]=e;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(ce.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(e,i){let[r,...n]=e,o=this.get(r,!0);return n.length===0?!i&&ce.isScalar(o)?o.value:o:ce.isCollection(o)?o.getIn(n,i):void 0}hasAllNullValues(e){return this.items.every(i=>{if(!ce.isPair(i))return!1;let r=i.value;return r==null||e&&ce.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[i,...r]=e;if(r.length===0)return this.has(i);let n=this.get(i,!0);return ce.isCollection(n)?n.hasIn(r):!1}setIn(e,i){let[r,...n]=e;if(n.length===0)this.set(r,i);else{let o=this.get(r,!0);if(ce.isCollection(o))o.setIn(n,i);else if(o===void 0&&this.schema)this.set(r,Tn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};qi.Collection=On;qi.collectionFromPath=Tn;qi.isEmptyPath=ps});var jt=v(Gi=>{"use strict";var Sd=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function In(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var Ed=(t,e,i)=>t.endsWith(`
`)?In(i,e):i.includes(`
`)?`
`+In(i,e):(t.endsWith(" ")?"":" ")+i;Gi.indentComment=In;Gi.lineComment=Ed;Gi.stringifyComment=Sd});var ws=v(Lt=>{"use strict";var Cd="flow",jn="block",zi="quoted";function Pd(t,e,i="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:o=20,onFold:a,onOverflow:s}={}){if(!n||n<0)return t;n<o&&(o=0);let c=Math.max(1+o,1+n-e.length);if(t.length<=c)return t;let l=[],f={},u=n-e.length;typeof r=="number"&&(r>n-Math.max(2,o)?l.push(0):u=n-r);let d,m,w=!1,h=-1,p=-1,y=-1;i===jn&&(h=gs(t,h,e.length),h!==-1&&(u=h+c));for(let k;k=t[h+=1];){if(i===zi&&k==="\\"){switch(p=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(k===`
`)i===jn&&(h=gs(t,h,e.length)),u=h+e.length+c,d=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
`&&m!==" "){let S=t[h+1];S&&S!==" "&&S!==`
`&&S!==" "&&(d=h)}if(h>=u)if(d)l.push(d),u=d+c,d=void 0;else if(i===zi){for(;m===" "||m===" ";)m=k,k=t[h+=1],w=!0;let S=h>y+1?h-2:p-1;if(f[S])return t;l.push(S),f[S]=!0,u=S+c,d=void 0}else w=!0}m=k}if(w&&s&&s(),l.length===0)return t;a&&a();let b=t.slice(0,l[0]);for(let k=0;k<l.length;++k){let S=l[k],E=l[k+1]||t.length;S===0?b=`
${e}${t.slice(0,E)}`:(i===zi&&f[S]&&(b+=`${t[S]}\\`),b+=`
${e}${t.slice(S+1,E)}`)}return b}function gs(t,e,i){let r=e,n=e+1,o=t[n];for(;o===" "||o===" ";)if(e<n+i)o=t[++e];else{do o=t[++e];while(o&&o!==`
`);r=e,n=e+1,o=t[n]}return r}Lt.FOLD_BLOCK=jn;Lt.FOLD_FLOW=Cd;Lt.FOLD_QUOTED=zi;Lt.foldFlowLines=Pd});var Dt=v(vs=>{"use strict";var Z=O(),Se=ws(),Ki=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ji=t=>/^(%|---|\.\.\.)/m.test(t);function xd(t,e,i){if(!e||e<0)return!1;let r=e-i,n=t.length;if(n<=r)return!1;for(let o=0,a=0;o<n;++o)if(t[o]===`
`){if(o-a>r)return!0;if(a=o+1,n-a<=r)return!1}return!0}function $t(t,e){let i=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=e,n=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Ji(t)?" ":""),a="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(a+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{a+=i.slice(s,c);let f=i.substr(c+2,4);switch(f){case"0000":a+="\\0";break;case"0007":a+="\\a";break;case"000b":a+="\\v";break;case"001b":a+="\\e";break;case"0085":a+="\\N";break;case"00a0":a+="\\_";break;case"2028":a+="\\L";break;case"2029":a+="\\P";break;default:f.substr(0,2)==="00"?a+="\\x"+f.substr(2):a+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(a+=i.slice(s,c)+`
`;i[c+2]==="\\"&&i[c+3]==="n"&&i[c+4]!=='"';)a+=`
`,c+=2;a+=o,i[c+2]===" "&&(a+="\\"),c+=1,s=c+1}break;default:c+=1}return a=s?a+i.slice(s):i,r?a:Se.foldFlowLines(a,o,Se.FOLD_QUOTED,Ki(e,!1))}function Ln(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
`)||/[ \t]\n|\n[ \t]/.test(t))return $t(t,e);let i=e.indent||(Ji(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
${i}`)+"'";return e.implicitKey?r:Se.foldFlowLines(r,i,Se.FOLD_FLOW,Ki(e,!1))}function at(t,e){let{singleQuote:i}=e.options,r;if(i===!1)r=$t;else{let n=t.includes('"'),o=t.includes("'");n&&!o?r=Ln:o&&!n?r=$t:r=i?Ln:$t}return r(t,e)}var $n;try{$n=new RegExp(`(^|(?<!
))
+(?!
|$)`,"g")}catch{$n=/\n+(?!\n|$)/g}function Vi({comment:t,type:e,value:i},r,n,o){let{blockQuote:a,commentString:s,lineWidth:c}=r.options;if(!a||/\n[\t ]+$/.test(i))return at(i,r);let l=r.indent||(r.forceBlockIndent||Ji(i)?" ":""),f=a==="literal"?!0:a==="folded"||e===Z.Scalar.BLOCK_FOLDED?!1:e===Z.Scalar.BLOCK_LITERAL?!0:!xd(i,c,l.length);if(!i)return f?`|
`:`>
`;let u,d;for(d=i.length;d>0;--d){let E=i[d-1];if(E!==`
`&&E!==" "&&E!==" ")break}let m=i.substring(d),w=m.indexOf(`
`);w===-1?u="-":i===m||w!==m.length-1?(u="+",o&&o()):u="",m&&(i=i.slice(0,-m.length),m[m.length-1]===`
`&&(m=m.slice(0,-1)),m=m.replace($n,`$&${l}`));let h=!1,p,y=-1;for(p=0;p<i.length;++p){let E=i[p];if(E===" ")h=!0;else if(E===`
`)y=p;else break}let b=i.substring(0,y<p?y+1:p);b&&(i=i.substring(b.length),b=b.replace(/\n+/g,`$&${l}`));let S=(h?l?"2":"1":"")+u;if(t&&(S+=" "+s(t.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let E=i.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),g=!1,P=Ki(r,!0);a!=="folded"&&e!==Z.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{g=!0});let N=Se.foldFlowLines(`${b}${E}${m}`,l,Se.FOLD_BLOCK,P);if(!g)return`>${S}
${l}${N}`}return i=i.replace(/\n+/g,`$&${l}`),`|${S}
${l}${b}${i}${m}`}function Rd(t,e,i,r){let{type:n,value:o}=t,{actualString:a,implicitKey:s,indent:c,indentStep:l,inFlow:f}=e;if(s&&o.includes(`
`)||f&&/[[\]{},]/.test(o))return at(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return s||f||!o.includes(`
`)?at(o,e):Vi(t,e,i,r);if(!s&&!f&&n!==Z.Scalar.PLAIN&&o.includes(`
`))return Vi(t,e,i,r);if(Ji(o)){if(c==="")return e.forceBlockIndent=!0,Vi(t,e,i,r);if(s&&c===l)return at(o,e)}let u=o.replace(/\n+/g,`$&
${c}`);if(a){let d=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(u),{compat:m,tags:w}=e.doc.schema;if(w.some(d)||m?.some(d))return at(o,e)}return s?u:Se.foldFlowLines(u,c,Se.FOLD_FLOW,Ki(e,!1))}function _d(t,e,i,r){let{implicitKey:n,inFlow:o}=e,a=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:s}=t;s!==Z.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(a.value)&&(s=Z.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case Z.Scalar.BLOCK_FOLDED:case Z.Scalar.BLOCK_LITERAL:return n||o?at(a.value,e):Vi(a,e,i,r);case Z.Scalar.QUOTE_DOUBLE:return $t(a.value,e);case Z.Scalar.QUOTE_SINGLE:return Ln(a.value,e);case Z.Scalar.PLAIN:return Rd(a,e,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=n&&f||u;if(l=c(d),l===null)throw new Error(`Unsupported default string type ${d}`)}return l}vs.stringifyString=_d});var Bt=v(Dn=>{"use strict";var Ad=Mi(),Ee=C(),Td=jt(),Od=Dt();function Id(t,e){let i=Object.assign({blockQuote:!0,commentString:Td.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function jd(t,e){if(e.tag){let n=t.filter(o=>o.tag===e.tag);if(n.length>0)return n.find(o=>o.format===e.format)??n[0]}let i,r;if(Ee.isScalar(e)){r=e.value;let n=t.filter(o=>o.identify?.(r));if(n.length>1){let o=n.filter(a=>a.test);o.length>0&&(n=o)}i=n.find(o=>o.format===e.format)??n.find(o=>!o.format)}else r=e,i=t.find(n=>n.nodeClass&&r instanceof n.nodeClass);if(!i){let n=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${n} value`)}return i}function Ld(t,e,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],o=(Ee.isScalar(t)||Ee.isCollection(t))&&t.anchor;o&&Ad.anchorIsValid(o)&&(i.add(o),n.push(`&${o}`));let a=t.tag??(e.default?null:e.tag);return a&&n.push(r.directives.tagString(a)),n.join(" ")}function $d(t,e,i,r){if(Ee.isPair(t))return t.toString(e,i,r);if(Ee.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let n,o=Ee.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>n=c});n??(n=jd(e.doc.schema.tags,o));let a=Ld(o,n,e);a.length>0&&(e.indentAtStart=(e.indentAtStart??0)+a.length+1);let s=typeof n.stringify=="function"?n.stringify(o,e,i,r):Ee.isScalar(o)?Od.stringifyString(o,e,i,r):o.toString(e,i,r);return a?Ee.isScalar(o)||s[0]==="{"||s[0]==="["?`${a} ${s}`:`${a}
${e.indent}${s}`:s}Dn.createStringifyContext=Id;Dn.stringify=$d});var ks=v(Ns=>{"use strict";var me=C(),ys=O(),bs=Bt(),Mt=jt();function Dd({key:t,value:e},i,r,n){let{allNullValues:o,doc:a,indent:s,indentStep:c,options:{commentString:l,indentSeq:f,simpleKeys:u}}=i,d=me.isNode(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(me.isCollection(t)||!me.isNode(t)&&typeof t=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let m=!u&&(!t||d&&e==null&&!i.inFlow||me.isCollection(t)||(me.isScalar(t)?t.type===ys.Scalar.BLOCK_FOLDED||t.type===ys.Scalar.BLOCK_LITERAL:typeof t=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!m&&(u||!o),indent:s+c});let w=!1,h=!1,p=bs.stringify(t,i,()=>w=!0,()=>h=!0);if(!m&&!i.inFlow&&p.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(i.inFlow){if(o||e==null)return w&&r&&r(),p===""?"?":m?`? ${p}`:p}else if(o&&!u||e==null&&m)return p=`? ${p}`,d&&!w?p+=Mt.lineComment(p,i.indent,l(d)):h&&n&&n(),p;w&&(d=null),m?(d&&(p+=Mt.lineComment(p,i.indent,l(d))),p=`? ${p}
${s}:`):(p=`${p}:`,d&&(p+=Mt.lineComment(p,i.indent,l(d))));let y,b,k;me.isNode(e)?(y=!!e.spaceBefore,b=e.commentBefore,k=e.comment):(y=!1,b=null,k=null,e&&typeof e=="object"&&(e=a.createNode(e))),i.implicitKey=!1,!m&&!d&&me.isScalar(e)&&(i.indentAtStart=p.length+1),h=!1,!f&&c.length>=2&&!i.inFlow&&!m&&me.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(i.indent=i.indent.substring(2));let S=!1,E=bs.stringify(e,i,()=>S=!0,()=>h=!0),g=" ";if(d||y||b){if(g=y?`
`:"",b){let P=l(b);g+=`
${Mt.indentComment(P,i.indent)}`}E===""&&!i.inFlow?g===`
`&&k&&(g=`
`):g+=`
${i.indent}`}else if(!m&&me.isCollection(e)){let P=E[0],N=E.indexOf(`
`),_=N!==-1,G=i.inFlow??e.flow??e.items.length===0;if(_||!G){let it=!1;if(_&&(P==="&"||P==="!")){let j=E.indexOf(" ");P==="&"&&j!==-1&&j<N&&E[j+1]==="!"&&(j=E.indexOf(" ",j+1)),(j===-1||N<j)&&(it=!0)}it||(g=`
${i.indent}`)}}else(E===""||E[0]===`
`)&&(g="");return p+=g+E,i.inFlow?S&&r&&r():k&&!S?p+=Mt.lineComment(p,i.indent,l(k)):h&&n&&n(),p}Ns.stringifyPair=Dd});var Mn=v(Bn=>{"use strict";var Ss=ji("process");function Bd(t,...e){t==="debug"&&console.log(...e)}function Md(t,e){(t==="debug"||t==="warn")&&(typeof Ss.emitWarning=="function"?Ss.emitWarning(e):console.warn(e))}Bn.debug=Bd;Bn.warn=Md});var Zi=v(Qi=>{"use strict";var Xi=C(),Es=O(),Ui="<<",Yi={identify:t=>t===Ui||typeof t=="symbol"&&t.description===Ui,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Es.Scalar(Symbol(Ui)),{addToJSMap:Cs}),stringify:()=>Ui},Fd=(t,e)=>(Yi.identify(e)||Xi.isScalar(e)&&(!e.type||e.type===Es.Scalar.PLAIN)&&Yi.identify(e.value))&&t?.doc.schema.tags.some(i=>i.tag===Yi.tag&&i.default);function Cs(t,e,i){let r=Ps(t,i);if(Xi.isSeq(r))for(let n of r.items)Fn(t,e,n);else if(Array.isArray(r))for(let n of r)Fn(t,e,n);else Fn(t,e,r)}function Fn(t,e,i){let r=Ps(t,i);if(!Xi.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,t,Map);for(let[o,a]of n)e instanceof Map?e.has(o)||e.set(o,a):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:a,writable:!0,enumerable:!0,configurable:!0});return e}function Ps(t,e){return t&&Xi.isAlias(e)?e.resolve(t.doc,t):e}Qi.addMergeToJSMap=Cs;Qi.isMergeKey=Fd;Qi.merge=Yi});var qn=v(_s=>{"use strict";var Wd=Mn(),xs=Zi(),qd=Bt(),Rs=C(),Wn=Ne();function Hd(t,e,{key:i,value:r}){if(Rs.isNode(i)&&i.addToJSMap)i.addToJSMap(t,e,r);else if(xs.isMergeKey(t,i))xs.addMergeToJSMap(t,e,r);else{let n=Wn.toJS(i,"",t);if(e instanceof Map)e.set(n,Wn.toJS(r,n,t));else if(e instanceof Set)e.add(n);else{let o=Gd(i,n,t),a=Wn.toJS(r,o,t);o in e?Object.defineProperty(e,o,{value:a,writable:!0,enumerable:!0,configurable:!0}):e[o]=a}}return e}function Gd(t,e,i){if(e===null)return"";if(typeof e!="object")return String(e);if(Rs.isNode(t)&&i?.doc){let r=qd.createStringifyContext(i.doc,{});r.anchors=new Set;for(let o of i.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=t.toString(r);if(!i.mapKeyWarned){let o=JSON.stringify(n);o.length>40&&(o=o.substring(0,36)+'..."'),Wd.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(e)}_s.addPairToJSMap=Hd});var Ce=v(Hn=>{"use strict";var As=It(),zd=ks(),Vd=qn(),er=C();function Kd(t,e,i){let r=As.createNode(t,void 0,i),n=As.createNode(e,void 0,i);return new tr(r,n)}var tr=class t{constructor(e,i=null){Object.defineProperty(this,er.NODE_TYPE,{value:er.PAIR}),this.key=e,this.value=i}clone(e){let{key:i,value:r}=this;return er.isNode(i)&&(i=i.clone(e)),er.isNode(r)&&(r=r.clone(e)),new t(i,r)}toJSON(e,i){let r=i?.mapAsMap?new Map:{};return Vd.addPairToJSMap(i,r,this)}toString(e,i,r){return e?.doc?zd.stringifyPair(this,e,i,r):JSON.stringify(this)}};Hn.Pair=tr;Hn.createPair=Kd});var Gn=v(Os=>{"use strict";var $e=C(),Ts=Bt(),ir=jt();function Jd(t,e,i){return(e.inFlow??t.flow?Yd:Ud)(t,e,i)}function Ud({comment:t,items:e},i,{blockItemPrefix:r,flowChars:n,itemIndent:o,onChompKeep:a,onComment:s}){let{indent:c,options:{commentString:l}}=i,f=Object.assign({},i,{indent:o,type:null}),u=!1,d=[];for(let w=0;w<e.length;++w){let h=e[w],p=null;if($e.isNode(h))!u&&h.spaceBefore&&d.push(""),rr(i,d,h.commentBefore,u),h.comment&&(p=h.comment);else if($e.isPair(h)){let b=$e.isNode(h.key)?h.key:null;b&&(!u&&b.spaceBefore&&d.push(""),rr(i,d,b.commentBefore,u))}u=!1;let y=Ts.stringify(h,f,()=>p=null,()=>u=!0);p&&(y+=ir.lineComment(y,o,l(p))),u&&p&&(u=!1),d.push(r+y)}let m;if(d.length===0)m=n.start+n.end;else{m=d[0];for(let w=1;w<d.length;++w){let h=d[w];m+=h?`
${c}${h}`:`
`}}return t?(m+=`
`+ir.indentComment(l(t),c),s&&s()):u&&a&&a(),m}function Yd({items:t},e,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:o,flowCollectionPadding:a,options:{commentString:s}}=e;r+=o;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),l=!1,f=0,u=[];for(let w=0;w<t.length;++w){let h=t[w],p=null;if($e.isNode(h))h.spaceBefore&&u.push(""),rr(e,u,h.commentBefore,!1),h.comment&&(p=h.comment);else if($e.isPair(h)){let b=$e.isNode(h.key)?h.key:null;b&&(b.spaceBefore&&u.push(""),rr(e,u,b.commentBefore,!1),b.comment&&(l=!0));let k=$e.isNode(h.value)?h.value:null;k?(k.comment&&(p=k.comment),k.commentBefore&&(l=!0)):h.value==null&&b?.comment&&(p=b.comment)}p&&(l=!0);let y=Ts.stringify(h,c,()=>p=null);l||(l=u.length>f||y.includes(`
`)),w<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=u.reduce((b,k)=>b+k.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),p&&(y+=ir.lineComment(y,r,s(p))),u.push(y),f=u.length}let{start:d,end:m}=i;if(u.length===0)return d+m;if(!l){let w=u.reduce((h,p)=>h+p.length+2,2);l=e.options.lineWidth>0&&w>e.options.lineWidth}if(l){let w=d;for(let h of u)w+=h?`
${o}${n}${h}`:`
`;return`${w}
${n}${m}`}else return`${d}${a}${u.join(" ")}${a}${m}`}function rr({indent:t,options:{commentString:e}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let o=ir.indentComment(e(r),t);i.push(o.trimStart())}}Os.stringifyCollection=Jd});var xe=v(Vn=>{"use strict";var Xd=Gn(),Qd=qn(),Zd=Hi(),Pe=C(),nr=Ce(),eh=O();function Ft(t,e){let i=Pe.isScalar(e)?e.value:e;for(let r of t)if(Pe.isPair(r)&&(r.key===e||r.key===i||Pe.isScalar(r.key)&&r.key.value===i))return r}var zn=class extends Zd.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Pe.MAP,e),this.items=[]}static from(e,i,r){let{keepUndefined:n,replacer:o}=r,a=new this(e),s=(c,l)=>{if(typeof o=="function")l=o.call(i,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||n)&&a.items.push(nr.createPair(c,l,r))};if(i instanceof Map)for(let[c,l]of i)s(c,l);else if(i&&typeof i=="object")for(let c of Object.keys(i))s(c,i[c]);return typeof e.sortMapEntries=="function"&&a.items.sort(e.sortMapEntries),a}add(e,i){let r;Pe.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new nr.Pair(e,e?.value):r=new nr.Pair(e.key,e.value);let n=Ft(this.items,r.key),o=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);Pe.isScalar(n.value)&&eh.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(o){let a=this.items.findIndex(s=>o(r,s)<0);a===-1?this.items.push(r):this.items.splice(a,0,r)}else this.items.push(r)}delete(e){let i=Ft(this.items,e);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(e,i){let n=Ft(this.items,e)?.value;return(!i&&Pe.isScalar(n)?n.value:n)??void 0}has(e){return!!Ft(this.items,e)}set(e,i){this.add(new nr.Pair(e,i),!0)}toJSON(e,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let o of this.items)Qd.addPairToJSMap(i,n,o);return n}toString(e,i,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!Pe.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Xd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:i})}};Vn.YAMLMap=zn;Vn.findPair=Ft});var st=v(js=>{"use strict";var th=C(),Is=xe(),ih={collection:"map",default:!0,nodeClass:Is.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return th.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,i)=>Is.YAMLMap.from(t,e,i)};js.map=ih});var Re=v(Ls=>{"use strict";var rh=It(),nh=Gn(),oh=Hi(),ar=C(),ah=O(),sh=Ne(),Kn=class extends oh.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ar.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let i=or(e);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(e,i){let r=or(e);if(typeof r!="number")return;let n=this.items[r];return!i&&ar.isScalar(n)?n.value:n}has(e){let i=or(e);return typeof i=="number"&&i<this.items.length}set(e,i){let r=or(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[r];ar.isScalar(n)&&ah.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(e,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let o of this.items)r.push(sh.toJS(o,String(n++),i));return r}toString(e,i,r){return e?nh.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(e,i,r){let{replacer:n}=r,o=new this(e);if(i&&Symbol.iterator in Object(i)){let a=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(a++);s=n.call(i,c,s)}o.items.push(rh.createNode(s,void 0,r))}}return o}};function or(t){let e=ar.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Ls.YAMLSeq=Kn});var ct=v(Ds=>{"use strict";var ch=C(),$s=Re(),lh={collection:"seq",default:!0,nodeClass:$s.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return ch.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,i)=>$s.YAMLSeq.from(t,e,i)};Ds.seq=lh});var Wt=v(Bs=>{"use strict";var uh=Dt(),fh={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,i,r){return e=Object.assign({actualString:!0},e),uh.stringifyString(t,e,i,r)}};Bs.string=fh});var sr=v(Ws=>{"use strict";var Ms=O(),Fs={identify:t=>t==null,createNode:()=>new Ms.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ms.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Fs.test.test(t)?t:e.options.nullStr};Ws.nullTag=Fs});var Jn=v(Hs=>{"use strict";var dh=O(),qs={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new dh.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},i){if(t&&qs.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?i.options.trueStr:i.options.falseStr}};Hs.boolTag=qs});var lt=v(Gs=>{"use strict";function hh({format:t,minFractionDigits:e,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let a=o.indexOf(".");a<0&&(a=o.length,o+=".");let s=e-(o.length-a-1);for(;s-- >0;)o+="0"}return o}Gs.stringifyNumber=hh});var Yn=v(cr=>{"use strict";var mh=O(),Un=lt(),ph={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Un.stringifyNumber},gh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Un.stringifyNumber(t)}},wh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new mh.Scalar(parseFloat(t)),i=t.indexOf(".");return i!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-i-1),e},stringify:Un.stringifyNumber};cr.float=wh;cr.floatExp=gh;cr.floatNaN=ph});var Qn=v(ur=>{"use strict";var zs=lt(),lr=t=>typeof t=="bigint"||Number.isInteger(t),Xn=(t,e,i,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),i);function Vs(t,e,i){let{value:r}=t;return lr(r)&&r>=0?i+r.toString(e):zs.stringifyNumber(t)}var vh={identify:t=>lr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,i)=>Xn(t,2,8,i),stringify:t=>Vs(t,8,"0o")},yh={identify:lr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,i)=>Xn(t,0,10,i),stringify:zs.stringifyNumber},bh={identify:t=>lr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,i)=>Xn(t,2,16,i),stringify:t=>Vs(t,16,"0x")};ur.int=yh;ur.intHex=bh;ur.intOct=vh});var Js=v(Ks=>{"use strict";var Nh=st(),kh=sr(),Sh=ct(),Eh=Wt(),Ch=Jn(),Zn=Yn(),eo=Qn(),Ph=[Nh.map,Sh.seq,Eh.string,kh.nullTag,Ch.boolTag,eo.intOct,eo.int,eo.intHex,Zn.floatNaN,Zn.floatExp,Zn.float];Ks.schema=Ph});var Xs=v(Ys=>{"use strict";var xh=O(),Rh=st(),_h=ct();function Us(t){return typeof t=="bigint"||Number.isInteger(t)}var fr=({value:t})=>JSON.stringify(t),Ah=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:fr},{identify:t=>t==null,createNode:()=>new xh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:fr},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:fr},{identify:Us,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:i})=>i?BigInt(t):parseInt(t,10),stringify:({value:t})=>Us(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:fr}],Th={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Oh=[Rh.map,_h.seq].concat(Ah,Th);Ys.schema=Oh});var io=v(Qs=>{"use strict";var qt=ji("buffer"),to=O(),Ih=Dt(),jh={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof qt.Buffer=="function")return qt.Buffer.from(t,"base64");if(typeof atob=="function"){let i=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(i.length);for(let n=0;n<i.length;++n)r[n]=i.charCodeAt(n);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:i},r,n,o){if(!i)return"";let a=i,s;if(typeof qt.Buffer=="function")s=a instanceof qt.Buffer?a.toString("base64"):qt.Buffer.from(a.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<a.length;++l)c+=String.fromCharCode(a[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=to.Scalar.BLOCK_LITERAL),e!==to.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),f=new Array(l);for(let u=0,d=0;u<l;++u,d+=c)f[u]=s.substr(d,c);s=f.join(e===to.Scalar.BLOCK_LITERAL?`
`:" ")}return Ih.stringifyString({comment:t,type:e,value:s},r,n,o)}};Qs.binary=jh});var mr=v(hr=>{"use strict";var dr=C(),ro=Ce(),Lh=O(),$h=Re();function Zs(t,e){if(dr.isSeq(t))for(let i=0;i<t.items.length;++i){let r=t.items[i];if(!dr.isPair(r)){if(dr.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let n=r.items[0]||new ro.Pair(new Lh.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
${n.key.commentBefore}`:r.commentBefore),r.comment){let o=n.value??n.key;o.comment=o.comment?`${r.comment}
${o.comment}`:r.comment}r=n}t.items[i]=dr.isPair(r)?r:new ro.Pair(r)}}else e("Expected a sequence for this tag");return t}function ec(t,e,i){let{replacer:r}=i,n=new $h.YAMLSeq(t);n.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let a of e){typeof r=="function"&&(a=r.call(e,String(o++),a));let s,c;if(Array.isArray(a))if(a.length===2)s=a[0],c=a[1];else throw new TypeError(`Expected [key, value] tuple: ${a}`);else if(a&&a instanceof Object){let l=Object.keys(a);if(l.length===1)s=l[0],c=a[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=a;n.items.push(ro.createPair(s,c,i))}return n}var Dh={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Zs,createNode:ec};hr.createPairs=ec;hr.pairs=Dh;hr.resolvePairs=Zs});var ao=v(oo=>{"use strict";var tc=C(),no=Ne(),Ht=xe(),Bh=Re(),ic=mr(),De=class t extends Bh.YAMLSeq{constructor(){super(),this.add=Ht.YAMLMap.prototype.add.bind(this),this.delete=Ht.YAMLMap.prototype.delete.bind(this),this.get=Ht.YAMLMap.prototype.get.bind(this),this.has=Ht.YAMLMap.prototype.has.bind(this),this.set=Ht.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,i){if(!i)return super.toJSON(e);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let o,a;if(tc.isPair(n)?(o=no.toJS(n.key,"",i),a=no.toJS(n.value,o,i)):o=no.toJS(n,"",i),r.has(o))throw new Error("Ordered maps must not include duplicate keys");r.set(o,a)}return r}static from(e,i,r){let n=ic.createPairs(e,i,r),o=new this;return o.items=n.items,o}};De.tag="tag:yaml.org,2002:omap";var Mh={collection:"seq",identify:t=>t instanceof Map,nodeClass:De,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let i=ic.resolvePairs(t,e),r=[];for(let{key:n}of i.items)tc.isScalar(n)&&(r.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new De,i)},createNode:(t,e,i)=>De.from(t,e,i)};oo.YAMLOMap=De;oo.omap=Mh});var sc=v(so=>{"use strict";var rc=O();function nc({value:t,source:e},i){return e&&(t?oc:ac).test.test(e)?e:t?i.options.trueStr:i.options.falseStr}var oc={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new rc.Scalar(!0),stringify:nc},ac={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new rc.Scalar(!1),stringify:nc};so.falseTag=ac;so.trueTag=oc});var cc=v(pr=>{"use strict";var Fh=O(),co=lt(),Wh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:co.stringifyNumber},qh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():co.stringifyNumber(t)}},Hh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new Fh.Scalar(parseFloat(t.replace(/_/g,""))),i=t.indexOf(".");if(i!==-1){let r=t.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:co.stringifyNumber};pr.float=Hh;pr.floatExp=qh;pr.floatNaN=Wh});var uc=v(zt=>{"use strict";var lc=lt(),Gt=t=>typeof t=="bigint"||Number.isInteger(t);function gr(t,e,i,{intAsBigInt:r}){let n=t[0];if((n==="-"||n==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(i){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let a=BigInt(t);return n==="-"?BigInt(-1)*a:a}let o=parseInt(t,i);return n==="-"?-1*o:o}function lo(t,e,i){let{value:r}=t;if(Gt(r)){let n=r.toString(e);return r<0?"-"+i+n.substr(1):i+n}return lc.stringifyNumber(t)}var Gh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,i)=>gr(t,2,2,i),stringify:t=>lo(t,2,"0b")},zh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,i)=>gr(t,1,8,i),stringify:t=>lo(t,8,"0")},Vh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,i)=>gr(t,0,10,i),stringify:lc.stringifyNumber},Kh={identify:Gt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,i)=>gr(t,2,16,i),stringify:t=>lo(t,16,"0x")};zt.int=Vh;zt.intBin=Gh;zt.intHex=Kh;zt.intOct=zh});var fo=v(uo=>{"use strict";var yr=C(),wr=Ce(),vr=xe(),Be=class t extends vr.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let i;yr.isPair(e)?i=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?i=new wr.Pair(e.key,null):i=new wr.Pair(e,null),vr.findPair(this.items,i.key)||this.items.push(i)}get(e,i){let r=vr.findPair(this.items,e);return!i&&yr.isPair(r)?yr.isScalar(r.key)?r.key.value:r.key:r}set(e,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=vr.findPair(this.items,e);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new wr.Pair(e))}toJSON(e,i){return super.toJSON(e,i,Set)}toString(e,i,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(e,i,r){let{replacer:n}=r,o=new this(e);if(i&&Symbol.iterator in Object(i))for(let a of i)typeof n=="function"&&(a=n.call(i,a,a)),o.items.push(wr.createPair(a,null,r));return o}};Be.tag="tag:yaml.org,2002:set";var Jh={collection:"map",identify:t=>t instanceof Set,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,i)=>Be.from(t,e,i),resolve(t,e){if(yr.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Be,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};uo.YAMLSet=Be;uo.set=Jh});var mo=v(br=>{"use strict";var Uh=lt();function ho(t,e){let i=t[0],r=i==="-"||i==="+"?t.substring(1):t,n=a=>e?BigInt(a):Number(a),o=r.replace(/_/g,"").split(":").reduce((a,s)=>a*n(60)+n(s),n(0));return i==="-"?n(-1)*o:o}function fc(t){let{value:e}=t,i=a=>a;if(typeof e=="bigint")i=a=>BigInt(a);else if(isNaN(e)||!isFinite(e))return Uh.stringifyNumber(t);let r="";e<0&&(r="-",e*=i(-1));let n=i(60),o=[e%n];return e<60?o.unshift(0):(e=(e-o[0])/n,o.unshift(e%n),e>=60&&(e=(e-o[0])/n,o.unshift(e))),r+o.map(a=>String(a).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Yh={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:i})=>ho(t,i),stringify:fc},Xh={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>ho(t,!1),stringify:fc},dc={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(dc.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,o,a,s]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,o||0,a||0,s||0,c),f=e[8];if(f&&f!=="Z"){let u=ho(f,!1);Math.abs(u)<30&&(u*=60),l-=6e4*u}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};br.floatTime=Xh;br.intTime=Yh;br.timestamp=dc});var pc=v(mc=>{"use strict";var Qh=st(),Zh=sr(),em=ct(),tm=Wt(),im=io(),hc=sc(),po=cc(),Nr=uc(),rm=Zi(),nm=ao(),om=mr(),am=fo(),go=mo(),sm=[Qh.map,em.seq,tm.string,Zh.nullTag,hc.trueTag,hc.falseTag,Nr.intBin,Nr.intOct,Nr.int,Nr.intHex,po.floatNaN,po.floatExp,po.float,im.binary,rm.merge,nm.omap,om.pairs,am.set,go.intTime,go.floatTime,go.timestamp];mc.schema=sm});var Cc=v(yo=>{"use strict";var yc=st(),cm=sr(),bc=ct(),lm=Wt(),um=Jn(),wo=Yn(),vo=Qn(),fm=Js(),dm=Xs(),Nc=io(),Vt=Zi(),kc=ao(),Sc=mr(),gc=pc(),Ec=fo(),kr=mo(),wc=new Map([["core",fm.schema],["failsafe",[yc.map,bc.seq,lm.string]],["json",dm.schema],["yaml11",gc.schema],["yaml-1.1",gc.schema]]),vc={binary:Nc.binary,bool:um.boolTag,float:wo.float,floatExp:wo.floatExp,floatNaN:wo.floatNaN,floatTime:kr.floatTime,int:vo.int,intHex:vo.intHex,intOct:vo.intOct,intTime:kr.intTime,map:yc.map,merge:Vt.merge,null:cm.nullTag,omap:kc.omap,pairs:Sc.pairs,seq:bc.seq,set:Ec.set,timestamp:kr.timestamp},hm={"tag:yaml.org,2002:binary":Nc.binary,"tag:yaml.org,2002:merge":Vt.merge,"tag:yaml.org,2002:omap":kc.omap,"tag:yaml.org,2002:pairs":Sc.pairs,"tag:yaml.org,2002:set":Ec.set,"tag:yaml.org,2002:timestamp":kr.timestamp};function mm(t,e,i){let r=wc.get(e);if(r&&!t)return i&&!r.includes(Vt.merge)?r.concat(Vt.merge):r.slice();let n=r;if(!n)if(Array.isArray(t))n=[];else{let o=Array.from(wc.keys()).filter(a=>a!=="yaml11").map(a=>JSON.stringify(a)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)n=n.concat(o);else typeof t=="function"&&(n=t(n.slice()));return i&&(n=n.concat(Vt.merge)),n.reduce((o,a)=>{let s=typeof a=="string"?vc[a]:a;if(!s){let c=JSON.stringify(a),l=Object.keys(vc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(s)||o.push(s),o},[])}yo.coreKnownTags=hm;yo.getTags=mm});var ko=v(Pc=>{"use strict";var bo=C(),pm=st(),gm=ct(),wm=Wt(),Sr=Cc(),vm=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,No=class t{constructor({compat:e,customTags:i,merge:r,resolveKnownTags:n,schema:o,sortMapEntries:a,toStringDefaults:s}){this.compat=Array.isArray(e)?Sr.getTags(e,"compat"):e?Sr.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=n?Sr.coreKnownTags:{},this.tags=Sr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,bo.MAP,{value:pm.map}),Object.defineProperty(this,bo.SCALAR,{value:wm.string}),Object.defineProperty(this,bo.SEQ,{value:gm.seq}),this.sortMapEntries=typeof a=="function"?a:a===!0?vm:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Pc.Schema=No});var Rc=v(xc=>{"use strict";var ym=C(),So=Bt(),Kt=jt();function bm(t,e){let i=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(i.push(c),r=!0):t.directives.docStart&&(r=!0)}r&&i.push("---");let n=So.createStringifyContext(t,e),{commentString:o}=n.options;if(t.commentBefore){i.length!==1&&i.unshift("");let c=o(t.commentBefore);i.unshift(Kt.indentComment(c,""))}let a=!1,s=null;if(t.contents){if(ym.isNode(t.contents)){if(t.contents.spaceBefore&&r&&i.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);i.push(Kt.indentComment(f,""))}n.forceBlockIndent=!!t.comment,s=t.contents.comment}let c=s?void 0:()=>a=!0,l=So.stringify(t.contents,n,()=>s=null,c);s&&(l+=Kt.lineComment(l,"",o(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(So.stringify(t.contents,n));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
`)?(i.push("..."),i.push(Kt.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=t.comment;c&&a&&(c=c.replace(/^\n+/,"")),c&&((!a||s)&&i[i.length-1]!==""&&i.push(""),i.push(Kt.indentComment(o(c),"")))}return i.join(`
`)+`
`}xc.stringifyDocument=bm});var Jt=v(_c=>{"use strict";var Nm=Ot(),ut=Hi(),V=C(),km=Ce(),Sm=Ne(),Em=ko(),Cm=Rc(),Eo=Mi(),Pm=xn(),xm=It(),Co=Pn(),Po=class t{constructor(e,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,V.NODE_TYPE,{value:V.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=o;let{version:a}=o;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Co.Directives({version:a}),this.setSchema(a,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(t.prototype,{[V.NODE_TYPE]:{value:V.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=V.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ft(this.contents)&&this.contents.add(e)}addIn(e,i){ft(this.contents)&&this.contents.addIn(e,i)}createAlias(e,i){if(!e.anchor){let r=Eo.anchorNames(this);e.anchor=!i||r.has(i)?Eo.findNewAnchor(i||"a",r):i}return new Nm.Alias(e.anchor)}createNode(e,i,r){let n;if(typeof i=="function")e=i.call({"":e},"",e),n=i;else if(Array.isArray(i)){let p=b=>typeof b=="number"||b instanceof String||b instanceof Number,y=i.filter(p).map(String);y.length>0&&(i=i.concat(y)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:o,anchorPrefix:a,flow:s,keepUndefined:c,onTagObj:l,tag:f}=r??{},{onAnchor:u,setAnchors:d,sourceObjects:m}=Eo.createNodeAnchors(this,a||"a"),w={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:u,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:m},h=xm.createNode(e,f,w);return s&&V.isCollection(h)&&(h.flow=!0),d(),h}createPair(e,i,r={}){let n=this.createNode(e,null,r),o=this.createNode(i,null,r);return new km.Pair(n,o)}delete(e){return ft(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ut.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):ft(this.contents)?this.contents.deleteIn(e):!1}get(e,i){return V.isCollection(this.contents)?this.contents.get(e,i):void 0}getIn(e,i){return ut.isEmptyPath(e)?!i&&V.isScalar(this.contents)?this.contents.value:this.contents:V.isCollection(this.contents)?this.contents.getIn(e,i):void 0}has(e){return V.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return ut.isEmptyPath(e)?this.contents!==void 0:V.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,i){this.contents==null?this.contents=ut.collectionFromPath(this.schema,[e],i):ft(this.contents)&&this.contents.set(e,i)}setIn(e,i){ut.isEmptyPath(e)?this.contents=i:this.contents==null?this.contents=ut.collectionFromPath(this.schema,Array.from(e),i):ft(this.contents)&&this.contents.setIn(e,i)}setSchema(e,i={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Co.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Co.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Em.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:o,reviver:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Sm.toJS(this.contents,i??"",s);if(typeof o=="function")for(let{count:l,res:f}of s.anchors.values())o(f,l);return typeof a=="function"?Pm.applyReviver(a,{"":c},"",c):c}toJSON(e,i){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:i})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let i=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Cm.stringifyDocument(this,e)}};function ft(t){if(V.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}_c.Document=Po});var Xt=v(Yt=>{"use strict";var Ut=class extends Error{constructor(e,i,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=i}},xo=class extends Ut{constructor(e,i,r){super("YAMLParseError",e,i,r)}},Ro=class extends Ut{constructor(e,i,r){super("YAMLWarning",e,i,r)}},Rm=(t,e)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>e.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let o=n-1,a=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&a.length>80){let s=Math.min(o-39,a.length-79);a="…"+a.substring(s),o-=s-1}if(a.length>80&&(a=a.substring(0,79)+"…"),r>1&&/^ *$/.test(a.substring(0,o))){let s=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
`),a=s+a}if(/[^ ]/.test(a)){let s=1,c=i.linePos[1];c?.line===r&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-o)));let l=" ".repeat(o)+"^".repeat(s);i.message+=`:
${a}
${l}
`}};Yt.YAMLError=Ut;Yt.YAMLParseError=xo;Yt.YAMLWarning=Ro;Yt.prettifyError=Rm});var Qt=v(Ac=>{"use strict";function _m(t,{flow:e,indicator:i,next:r,offset:n,onError:o,parentIndent:a,startOnNewline:s}){let c=!1,l=s,f=s,u="",d="",m=!1,w=!1,h=null,p=null,y=null,b=null,k=null,S=null,E=null;for(let N of t)switch(w&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&o(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),w=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!e&&(i!=="doc-start"||r?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),f=!0;break;case"comment":{f||o(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let _=N.source.substring(1)||" ";u?u+=d+_:u=_,d="",l=!1;break}case"newline":l?u?u+=N.source:(!S||i!=="seq-item-ind")&&(c=!0):d+=N.source,l=!0,m=!0,(p||y)&&(b=N),f=!0;break;case"anchor":p&&o(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&o(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=N,E??(E=N.offset),l=!1,f=!1,w=!0;break;case"tag":{y&&o(N,"MULTIPLE_TAGS","A node can have at most one tag"),y=N,E??(E=N.offset),l=!1,f=!1,w=!0;break}case i:(p||y)&&o(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),S&&o(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${e??"collection"}`),S=N,l=i==="seq-item-ind"||i==="explicit-key-ind",f=!1;break;case"comma":if(e){k&&o(N,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=N,l=!1,f=!1;break}default:o(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,f=!1}let g=t[t.length-1],P=g?g.offset+g.source.length:n;return w&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&o(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=a||r?.type==="block-map"||r?.type==="block-seq")&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:c,comment:u,hasNewline:m,anchor:p,tag:y,newlineAfterProp:b,end:P,start:E??P}}Ac.resolveProps=_m});var Er=v(Tc=>{"use strict";function _o(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let i of e.start)if(i.type==="newline")return!0;if(e.sep){for(let i of e.sep)if(i.type==="newline")return!0}if(_o(e.key)||_o(e.value))return!0}return!1;default:return!0}}Tc.containsNewline=_o});var Ao=v(Oc=>{"use strict";var Am=Er();function Tm(t,e,i){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&Am.containsNewline(e)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Oc.flowIndentCheck=Tm});var To=v(jc=>{"use strict";var Ic=C();function Om(t,e,i){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let n=typeof r=="function"?r:(o,a)=>o===a||Ic.isScalar(o)&&Ic.isScalar(a)&&o.value===a.value;return e.some(o=>n(o.key,i))}jc.mapIncludes=Om});var Fc=v(Mc=>{"use strict";var Lc=Ce(),Im=xe(),$c=Qt(),jm=Er(),Dc=Ao(),Lm=To(),Bc="All mapping items must start at the same column";function $m({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=o?.nodeClass??Im.YAMLMap,s=new a(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let f of r.items){let{start:u,key:d,sep:m,value:w}=f,h=$c.resolveProps(u,{indicator:"explicit-key-ind",next:d??m?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),p=!h.found;if(p){if(d&&(d.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==r.indent&&n(c,"BAD_INDENT",Bc)),!h.anchor&&!h.tag&&!m){l=h.end,h.comment&&(s.comment?s.comment+=`
`+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||jm.containsNewline(d))&&n(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",Bc);i.atKey=!0;let y=h.end,b=d?t(i,d,h,n):e(i,y,u,null,h,n);i.schema.compat&&Dc.flowIndentCheck(r.indent,d,n),i.atKey=!1,Lm.mapIncludes(i,s.items,b)&&n(y,"DUPLICATE_KEY","Map keys must be unique");let k=$c.resolveProps(m??[],{indicator:"map-value-ind",next:w,offset:b.range[2],onError:n,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=k.end,k.found){p&&(w?.type==="block-map"&&!k.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<k.found.offset-1024&&n(b.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=w?t(i,w,k,n):e(i,c,m,null,k,n);i.schema.compat&&Dc.flowIndentCheck(r.indent,w,n),c=S.range[2];let E=new Lc.Pair(b,S);i.options.keepSourceTokens&&(E.srcToken=f),s.items.push(E)}else{p&&n(b.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(b.comment?b.comment+=`
`+k.comment:b.comment=k.comment);let S=new Lc.Pair(b);i.options.keepSourceTokens&&(S.srcToken=f),s.items.push(S)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}Mc.resolveBlockMap=$m});var qc=v(Wc=>{"use strict";var Dm=Re(),Bm=Qt(),Mm=Ao();function Fm({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=o?.nodeClass??Dm.YAMLSeq,s=new a(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:f,value:u}of r.items){let d=Bm.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?n(d.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=d.end,d.comment&&(s.comment=d.comment);continue}let m=u?t(i,u,d,n):e(i,d.end,f,null,d,n);i.schema.compat&&Mm.flowIndentCheck(r.indent,u,n),c=m.range[2],s.items.push(m)}return s.range=[r.offset,c,l??c],s}Wc.resolveBlockSeq=Fm});var dt=v(Hc=>{"use strict";function Wm(t,e,i,r){let n="";if(t){let o=!1,a="";for(let s of t){let{source:c,type:l}=s;switch(l){case"space":o=!0;break;case"comment":{i&&!o&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";n?n+=a+f:n=f,a="";break}case"newline":n&&(a+=c),o=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:n,offset:e}}Hc.resolveEnd=Wm});var Kc=v(Vc=>{"use strict";var qm=C(),Hm=Ce(),Gc=xe(),Gm=Re(),zm=dt(),zc=Qt(),Vm=Er(),Km=To(),Oo="Block collections are not allowed within flow collections",Io=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Jm({composeNode:t,composeEmptyNode:e},i,r,n,o){let a=r.start.source==="{",s=a?"flow map":"flow sequence",c=o?.nodeClass??(a?Gc.YAMLMap:Gm.YAMLSeq),l=new c(i.schema);l.flow=!0;let f=i.atRoot;f&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let u=r.offset+r.start.source.length;for(let p=0;p<r.items.length;++p){let y=r.items[p],{start:b,key:k,sep:S,value:E}=y,g=zc.resolveProps(b,{flow:s,indicator:"explicit-key-ind",next:k??S?.[0],offset:u,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!S&&!E){p===0&&g.comma?n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):p<r.items.length-1&&n(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),g.comment&&(l.comment?l.comment+=`
`+g.comment:l.comment=g.comment),u=g.end;continue}!a&&i.options.strict&&Vm.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)g.comma&&n(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(g.comma||n(g.start,"MISSING_CHAR",`Missing , between ${s} items`),g.comment){let P="";e:for(let N of b)switch(N.type){case"comma":case"space":break;case"comment":P=N.source.substring(1);break e;default:break e}if(P){let N=l.items[l.items.length-1];qm.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
`+P:N.comment=P,g.comment=g.comment.substring(P.length+1)}}if(!a&&!S&&!g.found){let P=E?t(i,E,g,n):e(i,g.end,S,null,g,n);l.items.push(P),u=P.range[2],Io(E)&&n(P.range,"BLOCK_IN_FLOW",Oo)}else{i.atKey=!0;let P=g.end,N=k?t(i,k,g,n):e(i,P,b,null,g,n);Io(k)&&n(N.range,"BLOCK_IN_FLOW",Oo),i.atKey=!1;let _=zc.resolveProps(S??[],{flow:s,indicator:"map-value-ind",next:E,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!a&&!g.found&&i.options.strict){if(S)for(let j of S){if(j===_.found)break;if(j.type==="newline"){n(j,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.start<_.found.offset-1024&&n(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?n(E,"MISSING_CHAR",`Missing space after : in ${s}`):n(_.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let G=E?t(i,E,_,n):_.found?e(i,_.end,S,null,_,n):null;G?Io(E)&&n(G.range,"BLOCK_IN_FLOW",Oo):_.comment&&(N.comment?N.comment+=`
`+_.comment:N.comment=_.comment);let it=new Hm.Pair(N,G);if(i.options.keepSourceTokens&&(it.srcToken=y),a){let j=l;Km.mapIncludes(i,j.items,N)&&n(P,"DUPLICATE_KEY","Map keys must be unique"),j.items.push(it)}else{let j=new Gc.YAMLMap(i.schema);j.flow=!0,j.items.push(it);let Ka=(G??N).range;j.range=[N.range[0],Ka[1],Ka[2]],l.items.push(j)}u=G?G.range[2]:_.end}}let d=a?"}":"]",[m,...w]=r.end,h=u;if(m?.source===d)h=m.offset+m.source.length;else{let p=s[0].toUpperCase()+s.substring(1),y=f?`${p} must end with a ${d}`:`${p} in block collection must be sufficiently indented and end with a ${d}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",y),m&&m.source.length!==1&&w.unshift(m)}if(w.length>0){let p=zm.resolveEnd(w,h,i.options.strict,n);p.comment&&(l.comment?l.comment+=`
`+p.comment:l.comment=p.comment),l.range=[r.offset,h,p.offset]}else l.range=[r.offset,h,h];return l}Vc.resolveFlowCollection=Jm});var Uc=v(Jc=>{"use strict";var Um=C(),Ym=O(),Xm=xe(),Qm=Re(),Zm=Fc(),ep=qc(),tp=Kc();function jo(t,e,i,r,n,o){let a=i.type==="block-map"?Zm.resolveBlockMap(t,e,i,r,o):i.type==="block-seq"?ep.resolveBlockSeq(t,e,i,r,o):tp.resolveFlowCollection(t,e,i,r,o),s=a.constructor;return n==="!"||n===s.tagName?(a.tag=s.tagName,a):(n&&(a.tag=n),a)}function ip(t,e,i,r,n){let o=r.tag,a=o?e.directives.tagName(o.source,d=>n(o,"TAG_RESOLVE_FAILED",d)):null;if(i.type==="block-seq"){let{anchor:d,newlineAfterProp:m}=r,w=d&&o?d.offset>o.offset?d:o:d??o;w&&(!m||m.offset<w.offset)&&n(w,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!o||!a||a==="!"||a===Xm.YAMLMap.tagName&&s==="map"||a===Qm.YAMLSeq.tagName&&s==="seq")return jo(t,e,i,n,a);let c=e.schema.tags.find(d=>d.tag===a&&d.collection===s);if(!c){let d=e.schema.knownTags[a];if(d?.collection===s)e.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else return d?n(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${s} collection, but expects ${d.collection??"scalar"}`,!0):n(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${a}`,!0),jo(t,e,i,n,a)}let l=jo(t,e,i,n,a,c),f=c.resolve?.(l,d=>n(o,"TAG_RESOLVE_FAILED",d),e.options)??l,u=Um.isNode(f)?f:new Ym.Scalar(f);return u.range=l.range,u.tag=a,c?.format&&(u.format=c.format),u}Jc.composeCollection=ip});var $o=v(Yc=>{"use strict";var Lo=O();function rp(t,e,i){let r=e.offset,n=np(e,t.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let o=n.mode===">"?Lo.Scalar.BLOCK_FOLDED:Lo.Scalar.BLOCK_LITERAL,a=e.source?op(e.source):[],s=a.length;for(let h=a.length-1;h>=0;--h){let p=a[h][1];if(p===""||p==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&a.length>0?`
`.repeat(Math.max(1,a.length-1)):"",p=r+n.length;return e.source&&(p+=e.source.length),{value:h,type:o,comment:n.comment,range:[r,p,p]}}let c=e.indent+n.indent,l=e.offset+n.length,f=0;for(let h=0;h<s;++h){let[p,y]=a[h];if(y===""||y==="\r")n.indent===0&&p.length>c&&(c=p.length);else{p.length<c&&i(l+p.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=p.length),f=h,c===0&&!t.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=p.length+y.length+1}for(let h=a.length-1;h>=s;--h)a[h][0].length>c&&(s=h+1);let u="",d="",m=!1;for(let h=0;h<f;++h)u+=a[h][0].slice(c)+`
`;for(let h=f;h<s;++h){let[p,y]=a[h];l+=p.length+y.length+1;let b=y[y.length-1]==="\r";if(b&&(y=y.slice(0,-1)),y&&p.length<c){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-y.length-(b?2:1),"BAD_INDENT",S),p=""}o===Lo.Scalar.BLOCK_LITERAL?(u+=d+p.slice(c)+y,d=`
`):p.length>c||y[0]===" "?(d===" "?d=`
`:!m&&d===`
`&&(d=`
`),u+=d+p.slice(c)+y,d=`
`,m=!0):y===""?d===`
`?u+=`
`:d=`
`:(u+=d+y,d=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let h=s;h<a.length;++h)u+=`
`+a[h][0].slice(c);u[u.length-1]!==`
`&&(u+=`
`);break;default:u+=`
`}let w=r+n.length+e.source.length;return{value:u,type:o,comment:n.comment,range:[r,w,w]}}function np({offset:t,props:e},i,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],o=n[0],a=0,s="",c=-1;for(let d=1;d<n.length;++d){let m=n[d];if(!s&&(m==="-"||m==="+"))s=m;else{let w=Number(m);!a&&w?a=w:c===-1&&(c=t+d)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,f="",u=n.length;for(let d=1;d<e.length;++d){let m=e[d];switch(m.type){case"space":l=!0;case"newline":u+=m.source.length;break;case"comment":i&&!l&&r(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=m.source.length,f=m.source.substring(1);break;case"error":r(m,"UNEXPECTED_TOKEN",m.message),u+=m.source.length;break;default:{let w=`Unexpected token in block scalar header: ${m.type}`;r(m,"UNEXPECTED_TOKEN",w);let h=m.source;h&&typeof h=="string"&&(u+=h.length)}}}return{mode:o,indent:a,chomp:s,comment:f,length:u}}function op(t){let e=t.split(/\n( *)/),i=e[0],r=i.match(/^( *)/),o=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let a=1;a<e.length;a+=2)o.push([e[a],e[a+1]]);return o}Yc.resolveBlockScalar=rp});var Bo=v(Qc=>{"use strict";var Do=O(),ap=dt();function sp(t,e,i){let{offset:r,type:n,source:o,end:a}=t,s,c,l=(d,m,w)=>i(r+d,m,w);switch(n){case"scalar":s=Do.Scalar.PLAIN,c=cp(o,l);break;case"single-quoted-scalar":s=Do.Scalar.QUOTE_SINGLE,c=lp(o,l);break;case"double-quoted-scalar":s=Do.Scalar.QUOTE_DOUBLE,c=up(o,l);break;default:return i(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let f=r+o.length,u=ap.resolveEnd(a,f,e,i);return{value:c,type:s,comment:u.comment,range:[r,f,u.offset]}}function cp(t,e){let i="";switch(t[0]){case" ":i="a tab character";break;case",":i="flow indicator character ,";break;case"%":i="directive indicator character %";break;case"|":case">":{i=`block scalar indicator ${t[0]}`;break}case"@":case"`":{i=`reserved character ${t[0]}`;break}}return i&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),Xc(t)}function lp(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Xc(t.slice(1,-1)).replace(/''/g,"'")}function Xc(t){let e,i;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
`,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let n=r[1],o=" ",a=e.lastIndex;for(i.lastIndex=a;r=i.exec(t);)r[1]===""?o===`
`?n+=o:o=`
`:(n+=o+r[1],o=" "),a=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=a,r=s.exec(t),n+o+(r?.[1]??"")}function up(t,e){let i="";for(let r=1;r<t.length-1;++r){let n=t[r];if(!(n==="\r"&&t[r+1]===`
`))if(n===`
`){let{fold:o,offset:a}=fp(t,r);i+=o,r=a}else if(n==="\\"){let o=t[++r],a=dp[o];if(a)i+=a;else if(o===`
`)for(o=t[r+1];o===" "||o===" ";)o=t[++r+1];else if(o==="\r"&&t[r+1]===`
`)for(o=t[++r+1];o===" "||o===" ";)o=t[++r+1];else if(o==="x"||o==="u"||o==="U"){let s=o==="x"?2:o==="u"?4:8;i+=hp(t,r+1,s,e),r+=s}else{let s=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let o=r,a=t[r+1];for(;a===" "||a===" ";)a=t[++r+1];a!==`
`&&!(a==="\r"&&t[r+2]===`
`)&&(i+=r>o?t.slice(o,r+1):n)}else i+=n}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),i}function fp(t,e){let i="",r=t[e+1];for(;(r===" "||r===" "||r===`
`||r==="\r")&&!(r==="\r"&&t[e+2]!==`
`);)r===`
`&&(i+=`
`),e+=1,r=t[e+1];return i||(i=" "),{fold:i,offset:e}}var dp={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function hp(t,e,i,r){let n=t.substr(e,i),a=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(a)}catch{let s=t.substr(e-2,i+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}Qc.resolveFlowScalar=sp});var tl=v(el=>{"use strict";var Me=C(),Zc=O(),mp=$o(),pp=Bo();function gp(t,e,i,r){let{value:n,type:o,comment:a,range:s}=e.type==="block-scalar"?mp.resolveBlockScalar(t,e,r):pp.resolveFlowScalar(e,t.options.strict,r),c=i?t.directives.tagName(i.source,u=>r(i,"TAG_RESOLVE_FAILED",u)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[Me.SCALAR]:c?l=wp(t.schema,n,c,i,r):e.type==="scalar"?l=vp(t,n,e,r):l=t.schema[Me.SCALAR];let f;try{let u=l.resolve(n,d=>r(i??e,"TAG_RESOLVE_FAILED",d),t.options);f=Me.isScalar(u)?u:new Zc.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);r(i??e,"TAG_RESOLVE_FAILED",d),f=new Zc.Scalar(n)}return f.range=s,f.source=n,o&&(f.type=o),c&&(f.tag=c),l.format&&(f.format=l.format),a&&(f.comment=a),f}function wp(t,e,i,r,n){if(i==="!")return t[Me.SCALAR];let o=[];for(let s of t.tags)if(!s.collection&&s.tag===i)if(s.default&&s.test)o.push(s);else return s;for(let s of o)if(s.test?.test(e))return s;let a=t.knownTags[i];return a&&!a.collection?(t.tags.push(Object.assign({},a,{default:!1,test:void 0})),a):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),t[Me.SCALAR])}function vp({atKey:t,directives:e,schema:i},r,n,o){let a=i.tags.find(s=>(s.default===!0||t&&s.default==="key")&&s.test?.test(r))||i[Me.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[Me.SCALAR];if(a.tag!==s.tag){let c=e.tagString(a.tag),l=e.tagString(s.tag),f=`Value may be parsed as either ${c} or ${l}`;o(n,"TAG_RESOLVE_FAILED",f,!0)}}return a}el.composeScalar=gp});var rl=v(il=>{"use strict";function yp(t,e,i){if(e){i??(i=e.length);for(let r=i-1;r>=0;--r){let n=e[r];switch(n.type){case"space":case"comment":case"newline":t-=n.source.length;continue}for(n=e[++r];n?.type==="space";)t+=n.source.length,n=e[++r];break}}return t}il.emptyScalarPosition=yp});var al=v(Fo=>{"use strict";var bp=Ot(),Np=C(),kp=Uc(),nl=tl(),Sp=dt(),Ep=rl(),Cp={composeNode:ol,composeEmptyNode:Mo};function ol(t,e,i,r){let n=t.atKey,{spaceBefore:o,comment:a,anchor:s,tag:c}=i,l,f=!0;switch(e.type){case"alias":l=Pp(t,e,r),(s||c)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=nl.composeScalar(t,e,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=kp.composeCollection(Cp,t,e,i,r),s&&(l.anchor=s.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);r(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",u),f=!1}}return l??(l=Mo(t,e.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&t.options.stringKeys&&(!Np.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),a&&(e.type==="scalar"&&e.source===""?l.comment=a:l.commentBefore=a),t.options.keepSourceTokens&&f&&(l.srcToken=e),l}function Mo(t,e,i,r,{spaceBefore:n,comment:o,anchor:a,tag:s,end:c},l){let f={type:"scalar",offset:Ep.emptyScalarPosition(e,i,r),indent:-1,source:""},u=nl.composeScalar(t,f,s,l);return a&&(u.anchor=a.source.substring(1),u.anchor===""&&l(a,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=c),u}function Pp({options:t},{offset:e,source:i,end:r},n){let o=new bp.Alias(i.substring(1));o.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&n(e+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let a=e+i.length,s=Sp.resolveEnd(r,a,t.strict,n);return o.range=[e,a,s.offset],s.comment&&(o.comment=s.comment),o}Fo.composeEmptyNode=Mo;Fo.composeNode=ol});var ll=v(cl=>{"use strict";var xp=Jt(),sl=al(),Rp=dt(),_p=Qt();function Ap(t,e,{offset:i,start:r,value:n,end:o},a){let s=Object.assign({_directives:e},t),c=new xp.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=_p.resolveProps(r,{indicator:"doc-start",next:n??o?.[0],offset:i,onError:a,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&a(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?sl.composeNode(l,n,f,a):sl.composeEmptyNode(l,f.end,r,null,f,a);let u=c.contents.range[2],d=Rp.resolveEnd(o,u,!1,a);return d.comment&&(c.comment=d.comment),c.range=[i,u,d.offset],c}cl.composeDoc=Ap});var qo=v(dl=>{"use strict";var Tp=ji("process"),Op=Pn(),Ip=Jt(),Zt=Xt(),ul=C(),jp=ll(),Lp=dt();function ei(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:i}=t;return[e,e+(typeof i=="string"?i.length:1)]}function fl(t){let e="",i=!1,r=!1;for(let n=0;n<t.length;++n){let o=t[n];switch(o[0]){case"#":e+=(e===""?"":r?`
`:`
`)+(o.substring(1)||" "),i=!0,r=!1;break;case"%":t[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:e,afterEmptyLine:r}}var Wo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,o)=>{let a=ei(i);o?this.warnings.push(new Zt.YAMLWarning(a,r,n)):this.errors.push(new Zt.YAMLParseError(a,r,n))},this.directives=new Op.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,i){let{comment:r,afterEmptyLine:n}=fl(this.prelude);if(r){let o=e.contents;if(i)e.comment=e.comment?`${e.comment}
${r}`:r;else if(n||e.directives.docStart||!o)e.commentBefore=r;else if(ul.isCollection(o)&&!o.flow&&o.items.length>0){let a=o.items[0];ul.isPair(a)&&(a=a.key);let s=a.commentBefore;a.commentBefore=s?`${r}
${s}`:r}else{let a=o.commentBefore;o.commentBefore=a?`${r}
${a}`:r}}if(i){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:fl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,i=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(i,r)}*next(e){switch(Tp.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(i,r,n)=>{let o=ei(e);o[0]+=i,this.onError(o,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let i=jp.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(i,!1),this.doc&&(yield this.doc),this.doc=i,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let i=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",i);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Lp.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),i.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new Zt.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new Ip.Document(void 0,r);this.atDirectives&&this.onError(i,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,i,i],this.decorate(n,!1),yield n}}};dl.Composer=Wo});var pl=v(Cr=>{"use strict";var $p=$o(),Dp=Bo(),Bp=Xt(),hl=Dt();function Mp(t,e=!0,i){if(t){let r=(n,o,a)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,o,a);else throw new Bp.YAMLParseError([s,s+1],o,a)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Dp.resolveFlowScalar(t,e,r);case"block-scalar":return $p.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function Fp(t,e){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:o=-1,type:a="PLAIN"}=e,s=hl.stringifyString({type:a,value:t},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:r,source:`
`}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
`),f=s.substring(0,l),u=s.substring(l+1)+`
`,d=[{type:"block-scalar-header",offset:o,indent:r,source:f}];return ml(d,c)||d.push({type:"newline",offset:-1,indent:r,source:`
`}),{type:"block-scalar",offset:o,indent:r,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:s,end:c};default:return{type:"scalar",offset:o,indent:r,source:s,end:c}}}function Wp(t,e,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:o=!1,type:a}=i,s="indent"in t?t.indent:null;if(r&&typeof s=="number"&&(s+=2),!a)switch(t.type){case"single-quoted-scalar":a="QUOTE_SINGLE";break;case"double-quoted-scalar":a="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:a="PLAIN"}let c=hl.stringifyString({type:a,value:e},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":qp(t,c);break;case'"':Ho(t,c,"double-quoted-scalar");break;case"'":Ho(t,c,"single-quoted-scalar");break;default:Ho(t,c,"scalar")}}function qp(t,e){let i=e.indexOf(`
`),r=e.substring(0,i),n=e.substring(i+1)+`
`;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=r,t.source=n}else{let{offset:o}=t,a="indent"in t?t.indent:-1,s=[{type:"block-scalar-header",offset:o,indent:a,source:r}];ml(s,"end"in t?t.end:void 0)||s.push({type:"newline",offset:-1,indent:a,source:`
`});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:a,props:s,source:n})}}function ml(t,e){if(e)for(let i of e)switch(i.type){case"space":case"comment":t.push(i);break;case"newline":return t.push(i),!0}return!1}function Ho(t,e,i){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=i,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),n=e.length;t.props[0].type==="block-scalar-header"&&(n-=t.props[0].source.length);for(let o of r)o.offset+=n;delete t.props,Object.assign(t,{type:i,source:e,end:r});break}case"block-map":case"block-seq":{let n={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
`};delete t.items,Object.assign(t,{type:i,source:e,end:[n]});break}default:{let r="indent"in t?t.indent:-1,n="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:i,indent:r,source:e,end:n})}}}Cr.createScalarToken=Fp;Cr.resolveAsScalar=Mp;Cr.setScalarValue=Wp});var wl=v(gl=>{"use strict";var Hp=t=>"type"in t?xr(t):Pr(t);function xr(t){switch(t.type){case"block-scalar":{let e="";for(let i of t.props)e+=xr(i);return e+t.source}case"block-map":case"block-seq":{let e="";for(let i of t.items)e+=Pr(i);return e}case"flow-collection":{let e=t.start.source;for(let i of t.items)e+=Pr(i);for(let i of t.end)e+=i.source;return e}case"document":{let e=Pr(t);if(t.end)for(let i of t.end)e+=i.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let i of t.end)e+=i.source;return e}}}function Pr({start:t,key:e,sep:i,value:r}){let n="";for(let o of t)n+=o.source;if(e&&(n+=xr(e)),i)for(let o of i)n+=o.source;return r&&(n+=xr(r)),n}gl.stringify=Hp});var Nl=v(bl=>{"use strict";var Go=Symbol("break visit"),Gp=Symbol("skip children"),vl=Symbol("remove item");function Fe(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),yl(Object.freeze([]),t,e)}Fe.BREAK=Go;Fe.SKIP=Gp;Fe.REMOVE=vl;Fe.itemAtPath=(t,e)=>{let i=t;for(let[r,n]of e){let o=i?.[r];if(o&&"items"in o)i=o.items[n];else return}return i};Fe.parentCollection=(t,e)=>{let i=Fe.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function yl(t,e,i){let r=i(e,t);if(typeof r=="symbol")return r;for(let n of["key","value"]){let o=e[n];if(o&&"items"in o){for(let a=0;a<o.items.length;++a){let s=yl(Object.freeze(t.concat([[n,a]])),o.items[a],i);if(typeof s=="number")a=s-1;else{if(s===Go)return Go;s===vl&&(o.items.splice(a,1),a-=1)}}typeof r=="function"&&n==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}bl.visit=Fe});var Rr=v(q=>{"use strict";var zo=pl(),zp=wl(),Vp=Nl(),Vo="\uFEFF",Ko="",Jo="",Uo="",Kp=t=>!!t&&"items"in t,Jp=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Up(t){switch(t){case Vo:return"<BOM>";case Ko:return"<DOC>";case Jo:return"<FLOW_END>";case Uo:return"<SCALAR>";default:return JSON.stringify(t)}}function Yp(t){switch(t){case Vo:return"byte-order-mark";case Ko:return"doc-mode";case Jo:return"flow-error-end";case Uo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
`:case`\r
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}q.createScalarToken=zo.createScalarToken;q.resolveAsScalar=zo.resolveAsScalar;q.setScalarValue=zo.setScalarValue;q.stringify=zp.stringify;q.visit=Vp.visit;q.BOM=Vo;q.DOCUMENT=Ko;q.FLOW_END=Jo;q.SCALAR=Uo;q.isCollection=Kp;q.isScalar=Jp;q.prettyToken=Up;q.tokenType=Yp});var Qo=v(Sl=>{"use strict";var ti=Rr();function ee(t){switch(t){case void 0:case" ":case`
`:case"\r":case" ":return!0;default:return!1}}var kl=new Set("0123456789ABCDEFabcdef"),Xp=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),_r=new Set(",[]{}"),Qp=new Set(` ,[]{}
\r `),Yo=t=>!t||Qp.has(t),Xo=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,i=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,i=this.buffer[e];for(;i===" "||i===" ";)i=this.buffer[++e];return!i||i==="#"||i===`
`?!0:i==="\r"?this.buffer[e+1]===`
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let i=this.buffer[e];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+e];if(i==="\r"){let n=this.buffer[r+e+1];if(n===`
`||!n&&!this.atEnd)return e+r+1}return i===`
`||r>=this.indentNext||!i&&!this.atEnd?e+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&ee(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===ti.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let i=e.length,r=e.indexOf("#");for(;r!==-1;){let o=e[r-1];if(o===" "||o===" "){i=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let o=e[i-1];if(o===" "||o===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-i),yield*this.pushNewline(),"stream"}return yield ti.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&ee(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,i==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ee(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ee(i)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(e[i]){case"#":yield*this.pushCount(e.length-i);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Yo),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,i,r=-1;do e=yield*this.pushNewline(),e>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(e+i>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&ee(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield ti.FLOW_END,yield*this.parseLineStart();let o=0;for(;n[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),n[o]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Yo),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let a=this.charAt(1);if(this.flowKey||ee(a)||a===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),i=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let o=0;for(;this.buffer[i-1-o]==="\\";)o+=1;if(o%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
`,this.pos);if(n!==-1){for(;n!==-1;){let o=this.continueScalar(n+1);if(o===-1)break;n=r.indexOf(`
`,o)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let i=this.buffer[++e];if(i==="+")this.blockScalarKeep=!0;else if(i>"0"&&i<="9")this.blockScalarIndent=Number(i)-1;else if(i!=="-")break}return yield*this.pushUntil(i=>ee(i)||i==="#")}*parseBlockScalar(){let e=this.pos-1,i=0,r;e:for(let o=this.pos;r=this.buffer[o];++o)switch(r){case" ":i+=1;break;case`
`:e=o,i=0;break;case"\r":{let a=this.buffer[o+1];if(!a&&!this.atEnd)return this.setNext("block-scalar");if(a===`
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
`;)r=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let o=e-1,a=this.buffer[o];a==="\r"&&(a=this.buffer[--o]);let s=o;for(;a===" ";)a=this.buffer[--o];if(a===`
`&&o>=this.pos&&o+1+i>s)e=o;else break}while(!0);return yield ti.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let o=this.buffer[r+1];if(ee(o)||e&&_r.has(o))break;i=r}else if(ee(n)){let o=this.buffer[r+1];if(n==="\r"&&(o===`
`?(r+=1,n=`
`,o=this.buffer[r+1]):i=r),o==="#"||e&&_r.has(o))break;if(n===`
`){let a=this.continueScalar(r+1);if(a===-1)break;r=Math.max(r,a-2)}}else{if(e&&_r.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield ti.SCALAR,yield*this.pushToIndex(i+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,i){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Yo),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ee(r)||i&&_r.has(r)){i?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,i=this.buffer[e];for(;!ee(i)&&i!==">";)i=this.buffer[++e];return yield*this.pushToIndex(i===">"?e+1:e,!1)}else{let e=this.pos+1,i=this.buffer[e];for(;i;)if(Xp.has(i))i=this.buffer[++e];else if(i==="%"&&kl.has(this.buffer[e+1])&&kl.has(this.buffer[e+2]))i=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||e&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(e){let i=this.pos,r=this.buffer[i];for(;!e(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};Sl.Lexer=Xo});var ea=v(El=>{"use strict";var Zo=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let i=0,r=this.lineStarts.length;for(;i<r;){let o=i+r>>1;this.lineStarts[o]<e?i=o+1:r=o}if(this.lineStarts[i]===e)return{line:i+1,col:1};if(i===0)return{line:0,col:e};let n=this.lineStarts[i-1];return{line:i,col:e-n+1}}}};El.LineCounter=Zo});var ia=v(_l=>{"use strict";var Zp=ji("process"),Cl=Rr(),eg=Qo();function _e(t,e){for(let i=0;i<t.length;++i)if(t[i].type===e)return!0;return!1}function Pl(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Rl(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ar(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function ht(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function Tr(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let i=0;i<e.length;++i)t.push(e[i])}function xl(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!_e(e.start,"explicit-key-ind")&&!_e(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Rl(e.value)?e.value.end?Tr(e.value.end,e.sep):e.value.end=e.sep:Tr(e.start,e.sep),delete e.sep)}var ta=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new eg.Lexer,this.onNewLine=e}*parse(e,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,i))yield*this.next(r);i||(yield*this.end())}*next(e){if(this.source=e,Zp.env.LOG_TOKENS&&console.log("|",Cl.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let i=Cl.tokenType(e);if(i)if(i==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=i,yield*this.step(),i){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let i=e??this.stack.pop();if(!i)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield i;else{let r=this.peek(1);switch(i.type==="block-scalar"?i.indent="indent"in r?r.indent:0:i.type==="flow-collection"&&r.type==="document"&&(i.indent=0),i.type==="flow-collection"&&xl(i),r.type){case"document":r.value=i;break;case"block-scalar":r.props.push(i);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:i,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=i;else{Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];n.value?r.items.push({start:[],value:i}):n.value=i;break}case"flow-collection":{let n=r.items[r.items.length-1];!n||n.value?r.items.push({start:[],key:i,sep:[]}):n.sep?n.value=i:Object.assign(n,{key:i,sep:[]});return}default:yield*this.pop(),yield*this.pop(i)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(i.type==="block-map"||i.type==="block-seq")){let n=i.items[i.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Pl(n.start)===-1&&(i.indent===0||n.start.every(o=>o.type!=="comment"||o.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Pl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let i=Ar(this.peek(2)),r=ht(i),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let i=this.source.indexOf(`
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
`,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Tr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",o=[];if(n&&i.sep&&!i.value){let a=[];for(let s=0;s<i.sep.length;++s){let c=i.sep[s];switch(c.type){case"newline":a.push(s);break;case"space":break;case"comment":c.indent>e.indent&&(a.length=0);break;default:a.length=0}}a.length>=2&&(o=i.sep.splice(a[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(_e(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Rl(i.key)&&!_e(i.sep,"newline")){let a=ht(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:s,sep:c}]})}else o.length>0?i.sep=i.sep.concat(o,this.sourceToken):i.sep.push(this.sourceToken);else if(_e(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let a=ht(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?e.items.push({start:o,key:null,sep:[this.sourceToken]}):_e(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let a=this.flowScalar(this.type);n||i.value?(e.items.push({start:o,key:a,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(a):(Object.assign(i,{key:a,sep:[]}),this.onKeyLine=!0);return}default:{let a=this.startBlockValue(e);if(a){if(a.type==="block-seq"){if(!i.explicitKey&&i.sep&&!_e(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:o});this.stack.push(a);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let i=e.items[e.items.length-1];switch(this.type){case"newline":if(i.value){let r="end"in i.value?i.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Tr(n,i.start),n.push(this.sourceToken),e.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=e.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;i.value||_e(i.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let i=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?e.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?e.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!i||i.value?e.items.push({start:[],key:n,sep:[]}):i.sep?this.stack.push(n):Object.assign(i,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=Ar(r),o=ht(n);xl(e);let a=e.end.splice(1,e.end.length);a.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:a}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let i=this.source.indexOf(`
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
`,i)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=Ar(e),r=ht(i);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let i=Ar(e),r=ht(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,i){return this.type!=="comment"||this.indent<=i?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};_l.Parser=ta});var jl=v(ri=>{"use strict";var Al=qo(),tg=Jt(),ii=Xt(),ig=Mn(),rg=C(),ng=ea(),Tl=ia();function Ol(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new ng.LineCounter||null,prettyErrors:e}}function og(t,e={}){let{lineCounter:i,prettyErrors:r}=Ol(e),n=new Tl.Parser(i?.addNewLine),o=new Al.Composer(e),a=Array.from(o.compose(n.parse(t)));if(r&&i)for(let s of a)s.errors.forEach(ii.prettifyError(t,i)),s.warnings.forEach(ii.prettifyError(t,i));return a.length>0?a:Object.assign([],{empty:!0},o.streamInfo())}function Il(t,e={}){let{lineCounter:i,prettyErrors:r}=Ol(e),n=new Tl.Parser(i?.addNewLine),o=new Al.Composer(e),a=null;for(let s of o.compose(n.parse(t),!0,t.length))if(!a)a=s;else if(a.options.logLevel!=="silent"){a.errors.push(new ii.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(a.errors.forEach(ii.prettifyError(t,i)),a.warnings.forEach(ii.prettifyError(t,i))),a}function ag(t,e,i){let r;typeof e=="function"?r=e:i===void 0&&e&&typeof e=="object"&&(i=e);let n=Il(t,i);if(!n)return null;if(n.warnings.forEach(o=>ig.warn(n.options.logLevel,o)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},i))}function sg(t,e,i){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:i===void 0&&e&&(i=e),typeof i=="string"&&(i=i.length),typeof i=="number"){let n=Math.round(i);i=n<1?void 0:n>8?{indent:8}:{indent:n}}if(t===void 0){let{keepUndefined:n}=i??e??{};if(!n)return}return rg.isDocument(t)&&!r?t.toString(i):new tg.Document(t,r,i).toString(i)}ri.parse=ag;ri.parseAllDocuments=og;ri.parseDocument=Il;ri.stringify=sg});var mt=v(x=>{"use strict";var cg=qo(),lg=Jt(),ug=ko(),ra=Xt(),fg=Ot(),Ae=C(),dg=Ce(),hg=O(),mg=xe(),pg=Re(),gg=Rr(),wg=Qo(),vg=ea(),yg=ia(),Or=jl(),Ll=Rt();x.Composer=cg.Composer;x.Document=lg.Document;x.Schema=ug.Schema;x.YAMLError=ra.YAMLError;x.YAMLParseError=ra.YAMLParseError;x.YAMLWarning=ra.YAMLWarning;x.Alias=fg.Alias;x.isAlias=Ae.isAlias;x.isCollection=Ae.isCollection;x.isDocument=Ae.isDocument;x.isMap=Ae.isMap;x.isNode=Ae.isNode;x.isPair=Ae.isPair;x.isScalar=Ae.isScalar;x.isSeq=Ae.isSeq;x.Pair=dg.Pair;x.Scalar=hg.Scalar;x.YAMLMap=mg.YAMLMap;x.YAMLSeq=pg.YAMLSeq;x.CST=gg;x.Lexer=wg.Lexer;x.LineCounter=vg.LineCounter;x.Parser=yg.Parser;x.parse=Or.parse;x.parseAllDocuments=Or.parseAllDocuments;x.parseDocument=Or.parseDocument;x.stringify=Or.stringify;x.visit=Ll.visit;x.visitAsync=Ll.visitAsync});import Ir from"path";function Ng(t,e){if(typeof t!="string")throw new Error(`${e} must be a string`);let i=t.trim();if(i.length===0||Ir.posix.isAbsolute(i)||Ir.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${e} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${e} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${e} must not contain empty or dot path segments`);return r}function pt(t){let e=Ng(t,"native.artifact_root");return e.length===0?".":e.join("/")}function Bl(t,e="docs"){let i=t??e;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function ai(t,e,i=!1){if(typeof t!="string")throw new Error(`${e} must be a string`);let r=t.trim().replaceAll("\\","/");if(r.length===0||Ir.posix.isAbsolute(r)||Ir.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${e} must be relative to its declared path base`);let n=r.split("/");if(n.some(o=>o===".."))throw new Error(`${e} must stay inside its declared path base`);if(n.some(o=>o===""||o==="."))throw new Error(`${e} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${e} cannot contain wildcards`);return n.join("/")}function ni(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function Ml(t,e,i){let r=t??e;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function $r(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0")||t.startsWith("/")||t.split("/").includes(".."))throw new Error(`${e} contains an unsafe pattern`);if(t.length>jr)throw new Error(`${e} exceeds ${jr} characters`);let i=0;for(let r=0;r<t.length;r+=1)t[r]==="?"?i+=1:t[r]==="*"&&(i+=1,t[r+1]==="*"&&(r+=1));if(i>Lr)throw new Error(`${e} contains more than ${Lr} wildcard tokens`);return t}function $l(t,e,i){if(t===void 0)return[...i];if(!Array.isArray(t))throw new Error(`${e} contains an unsafe pattern`);return[...new Set(t.map(r=>$r(r,e)))].sort((r,n)=>r.localeCompare(n,"en"))}function na(t,e,i){let r=t??e;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function kg(t){if(t===void 0)return{...le,include:[...le.include],exclude:[...le.exclude]};let e=ni(t,"native.snapshot");return{include:$l(e.include,"native.snapshot.include",le.include),exclude:$l(e.exclude,"native.snapshot.exclude",le.exclude),max_files:na(e.max_files,le.max_files,"native.snapshot.max_files"),max_total_bytes:na(e.max_total_bytes,le.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:na(e.max_duration_ms,le.max_duration_ms,"native.snapshot.max_duration_ms")}}function Sg(t){if(t===void 0)return;let e=ni(t,"native.pending_root_move"),i=e.id,r=e.from_artifact_root,n=e.to_artifact_root,o=e.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(o!=="copying"&&o!=="ready"&&o!=="switched")throw new Error("native.pending_root_move.stage is invalid");let a;if(e.cleanup!==void 0){let s=ni(e.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,f=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof f!="string"||!/^[a-f0-9]{64}$/u.test(f))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");a={kind:c,state:l,manifestHash:f}}return{id:i,fromArtifactRoot:pt(r),toArtifactRoot:pt(n),stage:o,...a?{cleanup:a}:{}}}function Eg(t,e={}){let i=ni(t,"native"),r=i.artifact_root??(e.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"sequential";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let o=i.archive_confirmation??"automatic";if(o!=="automatic"&&o!=="required")throw new Error("native.archive_confirmation must be automatic or required");let a=i.max_verify_failures??Dl;if(!Number.isSafeInteger(a)||a<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Sg(i.pending_root_move);return{artifact_root:pt(r),language:Ml(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:o,max_verify_failures:a,snapshot:kg(i.snapshot),...s?{pending_root_move:s}:{}}}function Cg(t){let e=ni(t,"classic"),i=e.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=e.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=e.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:Bl(e.artifact_layout),language:Ml(e.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Pg(t){let e=t??!0;if(typeof e!="boolean")throw new Error("ambient_resume must be true or false");return e}function xg(t,e,i,r,n){let o=t.schema!==void 0;if(!(o||t.default_workflow!==void 0||t.workflows!==void 0||!n.allowPartialProject&&t.native!==void 0)||n.allowPartialProject&&!o)return null;if(t.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(t.default_workflow!=="native"&&t.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let s=t.workflows??[t.default_workflow];if(!Array.isArray(s)||s.length===0||s.some(l=>l!=="native"&&l!=="classic"))throw new Error("workflows must contain native and/or classic");let c=[...new Set(s)];if(!c.includes(t.default_workflow))throw new Error("workflows must include default_workflow");if(c.includes("native")&&!e)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:t.default_workflow,workflows:c,ambient_resume:r,...e?{native:e}:{},...i?{classic:i}:{}}}function gt(t,e={}){let i=(0,oa.parseDocument)(t,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,o=Pg(n.ambient_resume),a=n.native===void 0?void 0:Eg(n.native,{allowMissingArtifactRoot:e.allowMissingNativeFields}),s=n.classic===void 0?void 0:Cg(n.classic),c=xg(n,a,s,o,{allowPartialProject:e.allowPartialProject??!1});return{value:n,config:c,ambient_resume:o,...a?{native:a}:{},...s?{classic:s}:{}}}var oa,oi,jr,Lr,Dl,bg,le,ue=M(()=>{"use strict";oa=xt(mt(),1),oi=64*1024,jr=1024,Lr=64,Dl=5,bg=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],le={include:["**/*"],exclude:[...bg],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4}});function Te(t){return t!==0&&t!==0n&&t!=="0"}function fe(t,e){return Te(t.dev)&&Te(e.dev)&&Te(t.ino)&&Te(e.ino)}function T(t,e){let i=Te(t.dev)&&Te(e.dev);if(i&&t.dev!==e.dev)return!1;let r=Te(t.ino)&&Te(e.ino);return r&&t.ino!==e.ino?!1:i&&r?!0:t.birthtime===e.birthtime}var fi=M(()=>{"use strict"});import{constants as Dr,promises as We}from"fs";function ua(t){return"birthtimeNs"in t&&typeof t.birthtimeNs=="bigint"?t.birthtimeNs:t.birthtimeMs}function Wl(t){return"ctimeNs"in t&&typeof t.ctimeNs=="bigint"?t.ctimeNs:t.ctimeMs}function di(t){return{dev:t.dev,ino:t.ino,birthtime:ua(t)}}function Br(t,e){let i=di(t),r=di(e);return fe(i,r)?T(i,r):T(i,r)&&ua(t)===ua(e)&&Wl(t)===Wl(e)&&t.size===e.size}async function hi(t,e,i={}){if(!Number.isSafeInteger(e)||e<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,o=await We.lstat(t,{bigint:n});if(!o.isFile()||o.isSymbolicLink())throw new ge("not-regular-file",`${r} must be a regular file`);if(BigInt(o.size)>BigInt(e))throw new ge("too-large",`${r} exceeds ${e} bytes`);let a=await We.realpath(t);await i.verify?.("pre-open",{realPath:a,identity:di(o)});let s=process.platform==="win32"?Dr.O_RDONLY:Dr.O_RDONLY|Dr.O_NOFOLLOW|Dr.O_NONBLOCK,c;try{c=await We.open(t,s)}catch(l){throw l.code==="ELOOP"?new ge("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,f,u]=await Promise.all([c.stat({bigint:n}),We.lstat(t,{bigint:n}),We.realpath(t)]);if(!l.isFile()||!f.isFile()||f.isSymbolicLink()||u!==a||!Br(o,l)||!Br(o,f))throw new ge("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:u,identity:di(l)}),await i.hooks?.afterOpen?.();let d=[],m=0,w=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let b=e+1-m,{bytesRead:k}=await c.read(w,0,Math.min(w.length,b),null);if(k===0)break;if(m+=k,m>e)throw new ge("too-large",`${r} exceeds ${e} bytes`);d.push(Buffer.from(w.subarray(0,k)))}await i.hooks?.beforeFinalCheck?.();let[h,p,y]=await Promise.all([c.stat({bigint:n}),We.lstat(t,{bigint:n}),We.realpath(t)]);if(!p.isFile()||p.isSymbolicLink()||y!==a||!Br(o,h)||!Br(o,p))throw new ge("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:y,identity:di(h)}),{bytes:Buffer.concat(d,m),stat:h,realPath:y}}finally{await c.close()}}var ge,Mr=M(()=>{"use strict";fi();ge=class extends Error{reason;constructor(e,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=e}}});import{promises as Fr}from"fs";import Oe from"path";function Ig(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}function fa(t,e){let i=Oe.relative(t,e);return i===""||!Oe.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Oe.sep}`)}async function ql(t,e){let i=Oe.resolve(t),r=await Fr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${e} project root must be a real directory`);return Fr.realpath(i)}async function Hl(t,e,i,r){let n=t;for(let o=0;o<i.length;o++){n=Oe.join(n,i[o]);let a;try{a=await Fr.lstat(n)}catch(f){if(Ig(f))return{exists:!1,kind:"missing"};throw f}let s=Oe.relative(t,n).replaceAll("\\","/");if(a.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=o===i.length-1;if(!c&&!a.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!a.isFile()||r.expected==="directory"&&!a.isDirectory()||r.expected==="any"&&!a.isFile()&&!a.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await Fr.realpath(n);if(!fa(e,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:a.isFile()?"file":a.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function H(t,e,i){let r=ai(e,i.label),n=Oe.resolve(t),o=await ql(n,i.label),a=r.split("/"),s=Oe.resolve(n,...a);if(!fa(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Hl(n,o,a,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function te(t,e,i,r){let n=await H(t,e,{label:r.label,expected:"file"});if(!n.exists){let a=new Error(`${r.label} does not exist`);throw a.code="ENOENT",a}let o=await ql(n.projectRoot,r.label);return hi(n.target,i,{...r,verify:async(a,s)=>{if(!fa(o,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await Hl(n.projectRoot,o,n.relative.split("/"),{label:r.label,expected:"file"})}})}var we=M(()=>{"use strict";Mr();ue()});import{createHash as jg}from"crypto";function Lg(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function qe(t,e={}){return(await pi(t,e)).document}async function $g(t){try{return(await te(t,mi,oi,{label:mi})).bytes}catch(e){if(Lg(e))return null;throw e}}function Dg(t){return t?{exists:!0,sha256:jg("sha256").update(t).digest("hex")}:{exists:!1,sha256:null}}async function pi(t,e={}){let i=await $g(t);return{document:i?gt(i.toString("utf8"),e):null,identity:Dg(i)}}async function da(t){return(await qe(t))?.config??null}var mi,He=M(()=>{"use strict";ue();we();mi=".comet/config.yaml"});import{randomUUID as Bg}from"crypto";import{constants as Mg,promises as I}from"fs";import D from"path";async function ha(t,e){try{return await I.link(t,e),{linked:!0}}catch(i){let r=i.code;if(r!=="ENOTSUP"&&r!=="EOPNOTSUPP")throw i}return await I.copyFile(t,e,Mg.COPYFILE_EXCL),{linked:!1}}function yt(t,e){let i=D.relative(t,e);return i===""||!D.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${D.sep}`)}function qr(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Fg(t,e){return T(t,qr(e))}function Wr(t,e){let i=qr(t),r=qr(e);return fe(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Hr(t){let e=await I.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Contained atomic write parent must be a real directory: ${t}`);return{path:t,realPath:await I.realpath(t),...qr(e)}}async function Ie(t){for(let e of t){let i=await I.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!Fg(e,i)||await I.realpath(e.path)!==e.realPath)throw new Error(`Contained atomic write parent changed before commit: ${e.path}`)}}async function Wg(t,e){let i=D.resolve(t),r=D.resolve(e);if(!yt(i,r))throw new Error(`Contained atomic write parent is outside its managed root: ${e}`);let n=[await Hr(i)],o=D.relative(i,r).split(D.sep).filter(Boolean),a=i;for(let s of o){await Ie(n),a=D.join(a,s);try{await I.mkdir(a)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Hr(a);if(!yt(n[0].realPath,c.realPath))throw new Error(`Contained atomic write parent resolves outside its managed root: ${a}`);n.push(c)}return await Ie(n),n}async function qg(t,e){let i=D.resolve(t),r=D.resolve(e);if(!yt(i,r))throw new Error(`Contained file parent is outside its managed root: ${e}`);let n=[await Hr(i)],o=D.relative(i,r).split(D.sep).filter(Boolean),a=i;for(let s of o){a=D.join(a,s);try{let c=await Hr(a);if(!yt(n[0].realPath,c.realPath))throw new Error(`Contained file parent resolves outside its managed root: ${a}`);n.push(c)}catch(c){if(c.code==="ENOENT")return null;throw c}}return await Ie(n),n}async function Gl(t){let e;try{e=await I.open(t,"r"),await e.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await e?.close()}}async function Hg(t,e,i){let r=D.dirname(t),n=await Wg(i.containedRoot,r),o=D.join(r,`.${D.basename(t)}.${Bg()}.tmp`),a,s;try{await i.beforeTemporaryOpen?.(),a=await I.open(o,"wx"),s=await a.stat();let[c,l]=await Promise.all([I.lstat(o),I.realpath(o)]);if(await Ie(n),!c.isFile()||c.isSymbolicLink()||!Wr(s,c)||!yt(n[0].realPath,l))throw new Error("Contained atomic write temporary file opened outside its managed parent");if(typeof e=="string"?await a.writeFile(e,"utf8"):await a.writeFile(e),await a.sync(),!Wr(s,await a.stat()))throw new Error("Contained atomic write temporary file changed while writing");await a.close(),a=void 0,await i.beforeCommit?.(),await Ie(n);let f=await I.lstat(o);if(!f.isFile()||f.isSymbolicLink()||!Wr(f,s))throw new Error("Contained atomic write temporary file changed before commit");i.exclusive?(await ha(o,t),await I.unlink(o)):await I.rename(o,t),await Gl(r)}catch(c){await a?.close();try{await Ie(n),await I.rm(o,{force:!0})}catch{}throw c}}async function ve(t,e,i){await Hg(t,e,i)}async function ma(t,e){let i=D.dirname(t),r=await qg(e.containedRoot,i);if(!r)return!1;let n,o;try{n=await I.lstat(t),o=await I.realpath(t)}catch(c){if(c.code==="ENOENT")return!1;throw c}if(!n.isFile()||n.isSymbolicLink()||!yt(r[0].realPath,o))throw new Error("Contained file removal target must be a regular file inside its managed root");await e.beforeRemove?.(),await Ie(r);let[a,s]=await Promise.all([I.lstat(t),I.realpath(t)]);if(!a.isFile()||a.isSymbolicLink()||!Wr(n,a)||s!==o)throw new Error("Contained file removal target changed before removal");return await I.unlink(t),await Ie(r),await Gl(i),!0}var Ge=M(()=>{"use strict";fi()});var wk,pa=M(()=>{"use strict";Ge();He();we();wk=16*1024});var zr=M(()=>{"use strict";Ge();ue();He();we();pa()});var Xr=M(()=>{"use strict"});var fu=M(()=>{"use strict"});var Ra=M(()=>{"use strict";Xr()});var du=M(()=>{"use strict";Xr();Ra()});var Ow,mu=M(()=>{"use strict";Ow=xt(mt(),1);Ge();ue();we()});var pu=M(()=>{"use strict";Xr();Ge();fu();du();ue();mu();we();He();zr();pa();Ra()});import{TextDecoder as jw}from"util";function gu(t){return{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs}}function Lw(t,e){try{return new jw("utf-8",{fatal:!0}).decode(t.bytes)}catch(i){throw new Error(`${e} is not valid UTF-8`,{cause:i})}}async function _a(t,e,i,r,n={}){try{let o=await te(t,e,i,{label:r,hooks:n.hooks});return{result:o,text:Lw(o,r)}}catch(o){let a=o.code;if(a==="ENOENT"||a==="ENOTDIR")return null;throw o}}async function wu(t,e,i,r,n={}){return(await _a(t,e,i,r,n))?.text??null}async function vu(t,e,i,r,n,o={}){if(Buffer.byteLength(i,"utf8")>r)throw new Error(`${n} exceeds ${r} bytes`);let a=await _a(t,e,r,n),s=await H(t,e,{label:n,expected:"file"});await ve(s.target,i,{containedRoot:s.projectRoot,beforeCommit:async()=>{await o.beforeCommit?.();let c=await _a(t,e,r,n);if(!(!a&&!c)){if(!a||!c)throw new Error(`${n} changed before commit`);if(a.result.realPath!==c.result.realPath||!T(gu(a.result.stat),gu(c.result.stat))||a.text!==c.text)throw new Error(`${n} changed before commit`)}}})}async function yu(t,e,i,r={}){let n=await H(t,e,{label:i,expected:"file"});return n.exists?ma(n.target,{containedRoot:n.projectRoot,beforeRemove:r.beforeRemove}):!1}var bu=M(()=>{"use strict";pu();fi()});var Cu={};zf(Cu,{RUN_STATE_FILE:()=>Qr,applyRunStateToDocument:()=>ku,readRunState:()=>Aa,removeRunState:()=>Eu,runStateFromDocument:()=>Si,writeRunState:()=>Ta});import $w from"path";function ki(t,e){let i=t[e];if(typeof i!="string"||i.length===0)throw new Error(`Invalid Run state: ${e} must be a non-empty string`);return i}function Ni(t,e){let i=ki(t,e);if($w.isAbsolute(i)||/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Run state: ${e} must stay inside the change directory`);return i}function Dw(t){let e=t.run_retries??"{}",i;try{i=typeof e=="string"?JSON.parse(e):e}catch(r){throw new Error("Invalid Run state: run_retries must be a JSON object",{cause:r})}if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Invalid Run state: run_retries must be a JSON object");for(let r of Object.values(i))if(!Number.isInteger(r)||Number(r)<0)throw new Error("Invalid Run state: retry counts must be non-negative integers");return i}function Si(t){if(!t.run_id)return null;let e=ki(t,"run_id"),i=ki(t,"skill"),r=ki(t,"skill_version"),n=ki(t,"skill_hash"),o=Ni(t,"pending_ref"),a=Ni(t,"trajectory_ref"),s=Ni(t,"context_ref"),c=Ni(t,"artifacts_ref"),l=Ni(t,"checkpoint_ref"),f=Number(t.iteration);if(!Number.isInteger(f)||f<0)throw new Error("Invalid Run state: iteration must be a non-negative integer");if(t.orchestration!=="deterministic"&&t.orchestration!=="adaptive")throw new Error("Invalid Run state: orchestration must be deterministic or adaptive");if(t.run_status!=="running"&&t.run_status!=="waiting"&&t.run_status!=="completed"&&t.run_status!=="failed")throw new Error("Invalid Run state: run_status is invalid");return{runId:e,skill:i,skillVersion:r,skillHash:n,orchestration:t.orchestration,currentStep:Nu(t,"current_step"),iteration:f,pending:Nu(t,"pending"),pendingRef:o,trajectoryRef:a,contextRef:s,artifactsRef:c,checkpointRef:l,status:t.run_status,retries:Dw(t)}}function ku(t,e){e?t.run_id=e.runId:delete t.run_id}function Bw(t){return{runId:t.runId,skill:t.skill,skillVersion:t.skillVersion,skillHash:t.skillHash,orchestration:t.orchestration,currentStep:t.currentStep,iteration:t.iteration,pending:t.pending,pendingRef:t.pendingRef,trajectoryRef:t.trajectoryRef,contextRef:t.contextRef,artifactsRef:t.artifactsRef,checkpointRef:t.checkpointRef,status:t.status,retries:t.retries}}function Mw(t){let e={run_id:t.runId,skill:t.skill,skill_version:t.skillVersion,skill_hash:t.skillHash,orchestration:t.orchestration,current_step:t.currentStep,iteration:t.iteration,pending:t.pending,pending_ref:t.pendingRef,trajectory_ref:t.trajectoryRef,context_ref:t.contextRef,artifacts_ref:t.artifactsRef,checkpoint_ref:t.checkpointRef,run_status:t.status,run_retries:JSON.stringify(t.retries)};return Si(e)}async function Aa(t,e={}){let i=await wu(t,Qr,Su,"Run state",e);if(i===null)return null;let r=JSON.parse(i);return Mw(r)}async function Ta(t,e,i={}){await vu(t,Qr,JSON.stringify(Bw(e),null,2),Su,"Run state",i)}async function Eu(t,e={}){await yu(t,Qr,"Run state",e)}var Nu,Qr,Su,Ei=M(()=>{"use strict";bu();Nu=(t,e)=>{let i=t[e];return i==null?null:String(i)};Qr=".comet/run-state.json",Su=256*1024});import Mf from"path";import{promises as Bf}from"fs";ue();import{promises as wt}from"fs";import R from"path";import Rg from"os";var sa=".comet/config.yaml";async function aa(t){try{return await wt.lstat(t),!0}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function _g(t){try{let e=await wt.readFile(t,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(e)}catch(e){if(e.code==="ENOENT")return!1;throw e}}function si(t,e){let i=R.relative(t,e);return i===""||!R.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${R.sep}`)}async function ci(t){let e=[],i=t;for(;!await aa(i);){let n=R.dirname(i);if(n===i)break;e.push(R.basename(i)),i=n}let r=await wt.realpath(i);return R.resolve(r,...e.reverse())}async function Fl(t){try{return(await wt.lstat(t)).isSymbolicLink()}catch(e){if(e.code==="ENOENT")return!1;throw e}}async function li(t){let e=R.resolve(t);try{(await wt.stat(e)).isDirectory()||(e=R.dirname(e))}catch(n){if(n.code!=="ENOENT")throw n}let i=e,r=R.resolve(Rg.homedir());for(;;){if(!(e===r&&i!==r)){let a=R.join(e,...sa.split("/")),s=e===i||await _g(a);if(await aa(a)&&s)return e}if(await aa(R.join(e,".git")))return e;let o=R.dirname(e);if(o===e)return i;e=o}}function ca(t){return pt(t)}async function Ag(t,e){let i=ca(e),r=R.resolve(t,...i.split("/")),n=await wt.realpath(t),o=await ci(r);if(!si(n,o))throw new Error("native.artifact_root resolves outside the project root");return r}async function la(t,e){let i=ca(e),r=await Ag(t,i),n=R.join(r,"comet");if(await Fl(n))throw new Error("The configured Native comet root must not be a symbolic link");let[o,a]=await Promise.all([ci(r),ci(n)]);if(!si(o,a))throw new Error("The configured Native comet root resolves outside its artifact root");return{projectRoot:R.resolve(t),configFile:R.join(t,...sa.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:R.join(n,"specs"),changesDir:R.join(n,"changes"),archiveDir:R.join(n,"archive"),runtimeDir:R.join(n,"runtime"),locksDir:R.join(n,"runtime","locks"),transactionsDir:R.join(n,"runtime","transactions")}}function vt(t,e){return si(R.resolve(t),R.resolve(e))}async function pe(t,e){let i=R.resolve(t),r=R.resolve(e);if(!si(i,r))throw new Error(`Path is outside the Native root: ${e}`);if(await Fl(i))throw new Error(`Native root must not be a symbolic link: ${t}`);let[n,o]=await Promise.all([ci(i),ci(r)]);if(!si(n,o))throw new Error(`Path resolves outside the Native root: ${e}`);return r}import{promises as Jg}from"fs";import A from"path";import{promises as Tg}from"fs";async function ui(t){try{return await Tg.access(t),!0}catch(e){if(Og(e))return!1;throw e}}function Og(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}ue();He();zr();we();var ze=class extends Error{code="classic-layout-unavailable";constructor(e="Classic artifact layout is unavailable from .comet/config.yaml"){super(e),this.name="ClassicLayoutUnavailableError"}},Vl=".comet/config.yaml";function Ug(t){let e=t?.code;return e==="ENOENT"||e==="ENOTDIR"}async function Kl(t){await H(t,Vl,{label:Vl,expected:"file"})}function Jl(t,e){let i=A.resolve(t),r=e==="docs"?A.join(i,"docs"):i,n=A.join(r,"openspec"),o=A.join(i,"docs","superpowers");return{projectRoot:i,artifactLayout:e,openSpecBase:r,openSpecRoot:n,changesDir:A.join(n,"changes"),archiveDir:A.join(n,"changes","archive"),specsDir:A.join(n,"specs"),superpowersRoot:o,superpowersSpecsDir:A.join(o,"specs"),superpowersPlansDir:A.join(o,"plans"),superpowersReportsDir:A.join(o,"reports")}}async function Yg(t){await Kl(t);let e=await qe(t,{allowPartialProject:!0,allowMissingNativeFields:!0});if(!e?.config)throw new ze;if(!(e.config.workflows??[e.config.default_workflow]).includes("classic"))throw new ze("Classic artifact layout is unavailable because Classic is not enabled");return e.classic?.artifact_layout??"legacy"}async function Xg(t,e){return Jl(t,e??await Yg(t))}async function Qg(t,e){let i=await Xg(t,e),r=i.artifactLayout==="legacy"?"docs":"legacy",n=Jl(t,r).openSpecRoot,[o,a]=await Promise.all([H(i.projectRoot,B(i.projectRoot,i.openSpecRoot),{label:"Configured Classic OpenSpec root",expected:"directory"}),H(i.projectRoot,B(i.projectRoot,n),{label:"Alternate Classic OpenSpec root",expected:"directory"})]),s=o.exists,c=a.exists;return{paths:i,configuredRootExists:s,alternateRoot:n,alternateRootExists:c,dualRoots:s&&c}}async function Zg(t,e){let i=[t.openSpecRoot,t.changesDir,t.archiveDir,t.specsDir,e,t.superpowersRoot,t.superpowersSpecsDir,t.superpowersPlansDir,t.superpowersReportsDir];for(let r of i){let n=B(t.projectRoot,r);await H(t.projectRoot,n,{label:`Classic managed physical path ${n}`,expected:"directory"})}}async function ye(t,e){let i=await Qg(t,e);if(await Zg(i.paths,i.alternateRoot),!i.configuredRootExists){let r=B(i.paths.projectRoot,i.paths.openSpecRoot),n=B(i.paths.projectRoot,i.alternateRoot);throw new ze(`Configured Classic OpenSpec root is missing: ${r} (alternate ${n} is ${i.alternateRootExists?"present":"missing"})`)}return i.paths}async function Vr(t,e){let i=A.join(A.resolve(t),".comet","classic-root-move.json");if(await ui(i))throw new Error("Classic root move transaction is incomplete; inspect it with comet doctor and recover it explicitly before writing");let r=await ye(t,e);if(!await ui(r.openSpecRoot))throw new Error(`Configured Classic OpenSpec root is missing: ${B(r.projectRoot,r.openSpecRoot)}`);return r}async function Ul(t){let e=A.resolve(t),i=null;try{(await Jg.lstat(e)).isDirectory()||(e=A.dirname(e))}catch(r){if(!Ug(r))throw r}for(;;){A.basename(e)==="openspec"&&(i=A.dirname(e));let r=A.join(e,".comet","config.yaml"),n=!1;if(await ui(r))try{await Kl(e);let a=(await qe(e))?.value;n=!!a&&typeof a=="object"&&!Array.isArray(a)&&(a.schema==="comet.project.v1"||a.default_workflow!==void 0||a.native!==void 0)}catch{}if(n||await ui(A.join(e,".git")))return e;let o=A.dirname(e);if(o===e)return i??A.resolve(t);e=o}}function B(t,e){return A.relative(A.resolve(t),e).replaceAll("\\","/")}import{readFileSync as ew}from"fs";import Yl from"path";var tw=new Set(["applypatch","create","createfile","deletefile","edit","editfile","patch","strreplaceeditor","write","writefile","writefiletool"]),iw=new Set(["glob","grep","listfiles","read","readfile","search","view"]),Ql=["file_path","filePath","path","target_file","targetFile"],Zl=["file_paths","filePaths","paths","files","targets"],eu=["operations","edits"],rw=["patch","diff","patchText","patch_text","changes"],va=new Set(["claude","codex","windsurf","github-copilot","gemini","amazon-q","qwen","kiro","codebuddy","qoder"]);function ya(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Xl(t){return t.toLowerCase().replace(/[^a-z0-9]+/gu,"")}function nw(t){for(let e of["tool_name","toolName","tool","name"]){let i=t[e];if(typeof i=="string"&&i.trim())return i.trim()}return null}function ow(t){for(let e of["cwd","working_directory","workspaceRoot"]){let i=t[e];if(!(typeof i!="string"||!i.trim()||!Yl.isAbsolute(i.trim())))return Yl.resolve(i.trim())}}function aw(t){if(typeof t!="string")return t;let e=t.trim();if(!e.startsWith("{")&&!e.startsWith("["))return t;try{return JSON.parse(e)}catch{return t}}function sw(t){for(let e of["tool_input","toolInput","toolArgs","tool_args","arguments"])if(t[e]!==void 0)return aw(t[e]);return t}function wa(t){let e=[],i=[/^\*\*\* (?:Add|Update|Delete) File:\s+(.+?)\s*$/gmu,/^\+\+\+\s+(?:b\/)?(.+?)\s*$/gmu];for(let r of i)for(let n of t.matchAll(r)){let o=n[1]?.trim();o&&o!=="/dev/null"&&e.push(o)}return e}function Ve(t,e){if(typeof e=="string"){let i=e.trim();i&&t.push(i);return}if(Array.isArray(e)){for(let i of e)Ve(t,i);return}if(ya(e)){for(let i of Ql)Ve(t,e[i]);for(let i of Zl)Ve(t,e[i]);for(let i of eu)Ve(t,e[i])}}function cw(t,e){let i=[],r=[e,t].filter(ya);for(let n of r){for(let o of Ql)Ve(i,n[o]);for(let o of Zl)Ve(i,n[o]);for(let o of eu)Ve(i,n[o]);for(let o of rw){let a=n[o];typeof a=="string"&&i.push(...wa(a))}}return typeof e=="string"&&i.push(...wa(e)),[...new Set(i)]}function gi(t,e){if(e?.trim())return{intent:"write",targets:[e.trim()],toolName:null};if(!t.trim())return{intent:"unknown",targets:[],toolName:null};let i;try{i=JSON.parse(t)}catch{let a=wa(t);return a.length>0?{intent:"write",targets:[...new Set(a)],toolName:"apply_patch"}:{intent:"unknown",targets:[],toolName:null}}if(!ya(i))return{intent:"unknown",targets:[],toolName:null};let r=nw(i),n=cw(i,sw(i)),o=ow(i);return r&&tw.has(Xl(r))?{intent:n.length>0?"write":"unknown",targets:n,toolName:r,...o?{cwd:o}:{}}:r&&iw.has(Xl(r))?{intent:"non-write",targets:[],toolName:r,...o?{cwd:o}:{}}:r?{intent:"unknown",targets:n,toolName:r,...o?{cwd:o}:{}}:{intent:n.length>0?"write":"unknown",targets:n,toolName:null,...o?{cwd:o}:{}}}function ba(){let t=process.env.FILE_PATH;if(t?.trim()||process.stdin.isTTY)return gi("",t);try{return gi(ew(0,"utf8"),t)}catch{return gi("",t)}}function tu(t,e){return va.has(t)?t==="github-copilot"?{exitCode:0,stdout:e.allowed?`{}
`:`${JSON.stringify({permissionDecision:"deny",permissionDecisionReason:e.reason})}
`,stderr:""}:e.allowed?{exitCode:0,stdout:"",stderr:""}:{exitCode:2,stdout:"",stderr:`${e.reason}
`}:{exitCode:64,stdout:"",stderr:`Unsupported Comet Hook platform: ${t}
`}}var wi=null;async function iu(t){if(wi!==null)return t();wi={entries:new Map};try{return await t()}finally{wi=null}}function ru(t,e){let i=t;for(let r of e)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function K(t,e){return(...i)=>{let r=wi;if(r===null)return e(...i);let n=ru(`async:${t}`,i),o=r.entries.get(n);if(o)return o.value;let a=e(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:a}),a}}function Na(t,e){return(...i)=>{let r=wi;if(r===null)return e(...i);let n=ru(`sync:${t}`,i),o=r.entries.get(n);if(o)return o.value;let a=e(...i);return r.entries.set(n,{value:a}),a}}import{promises as on,readFileSync as SE}from"fs";import J from"path";import ou from"path";Ge();ue();we();import vi from"path";var qk=2*1024*1024;function uw(t,e,i){let r=vi.resolve(t),n=vi.isAbsolute(e)?vi.resolve(e):vi.resolve(r,e),o=vi.relative(r,n).replaceAll("\\","/");return{root:r,relative:ai(o,i),target:n}}async function bt(t,e,i){let r=uw(t,e,i.label);return H(r.root,r.relative,i)}async function nu(t,e,i){return(await bt(t,e,{label:i.label,expected:i.expected??"any"})).exists}function ka(t){return t?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t)?t.includes("..")?"Change name cannot contain '..' (path traversal not allowed)":null:`Invalid change name: '${t}'
Valid format: lowercase kebab-case (a-z, 0-9, single hyphens)`:"Change name cannot be empty"}function Sa(t){let e=ka(t);if(e)throw new Error(e)}function fw(t,e){return{label:B(t,e),directory:e}}async function dw(t,e,i){let r=fw(t,e);if(!(await bt(t,e,{label:i,expected:"directory"})).exists)return{change:r,exists:!1,stateExists:!1};let o=await bt(t,ou.join(e,".comet.yaml"),{label:`${i} state`,expected:"file"});return{change:r,exists:!0,stateExists:o.exists}}async function yi(t,e=process.cwd()){Sa(t);let i=await ye(e),r=await dw(i.projectRoot,ou.join(i.changesDir,t),`Classic active change ${t}`);return{...r.change,exists:r.exists,stateExists:r.stateExists}}import{promises as Ea}from"fs";import z from"path";function au(t,e){let i=z.relative(t,e);return i===""||i!==".."&&!i.startsWith(`..${z.sep}`)&&!z.isAbsolute(i)}async function hw(t){let e=z.resolve(t),i=z.parse(e).root,r=[],n=e;for(;n&&n!==i;)try{let o=await Ea.realpath(n);return z.join(o,...r.reverse())}catch(o){let a=o.code;if(a!=="ENOENT"&&a!=="ENOTDIR")throw o;r.push(z.basename(n)),n=z.dirname(n)}try{let o=await Ea.realpath(i);return z.join(o,...r.reverse())}catch{return null}}async function Kr(t,e){let i=z.resolve(t),r=await Ea.realpath(i),n=[],o=[];for(let a of e){let s=z.isAbsolute(a)?z.resolve(a):z.resolve(i,a),c=await hw(s);((c?au(r,c):au(i,s))?n:o).push(a)}return{projectTargets:n,externalTargets:o}}var Ca=xt(mt(),1);import{execFileSync as su}from"child_process";import{randomUUID as mw}from"crypto";import{promises as bi}from"fs";import cu from"path";function pw(t){try{let e=su("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();return e&&e!=="HEAD"?e:null}catch{return null}}var gw=Na("liveGitBranch",t=>pw(t));function ww(t){try{return su("git",["rev-parse","--is-inside-work-tree"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim()==="true"}catch{return!1}}var vw=Na("isGitWorkTree",t=>ww(t)),yw=["current","branch","worktree"];function lu(t){return yw.includes(t)}function bw(t){return lu(t.isolation)?t.boundBranch===null&&t.currentBranch===null&&t.gitWorkTree===!1?{status:"not-applicable"}:t.boundBranch===null?t.currentBranch===null?{status:"unbound-detached"}:{status:"needs-heal",branch:t.currentBranch}:t.currentBranch===t.boundBranch?{status:"ok"}:{status:"drift",boundBranch:t.boundBranch,currentBranch:t.currentBranch}:{status:"not-applicable"}}async function Jr(t,e){let i=cu.join(t,".comet.yaml"),r=(0,Ca.parseDocument)(await bi.readFile(i,"utf8"),{uniqueKeys:!1});if(r.errors.length>0)throw new Error(`Invalid .comet.yaml: ${r.errors[0].message}`);let n=r.toJS()??{},o=typeof n.isolation=="string"?n.isolation:null,a=typeof n.bound_branch=="string"&&n.bound_branch!==""?n.bound_branch:null,s=lu(o),c=gw(e.cwd),l=s&&a===null&&c===null?vw(e.cwd):!0,f=bw({isolation:o,boundBranch:a,currentBranch:c,gitWorkTree:l});return f.status==="needs-heal"&&e.heal?(await Nw(t,f.branch),{status:"healed",branch:f.branch,bindingRequired:s,currentBranch:c}):{...f,bindingRequired:s,currentBranch:c}}async function Nw(t,e){let i=cu.join(t,".comet.yaml"),r=(0,Ca.parseDocument)(await bi.readFile(i,"utf8"),{uniqueKeys:!1});r.set("bound_branch",e);let n=`${i}.${mw()}.tmp`;try{await bi.writeFile(n,r.toString(),"utf8"),await bi.rename(n,i)}catch(o){throw await bi.rm(n,{force:!0}),o}}function kw(t){return t??"detached HEAD"}function Ur(t,e,i){return`change '${t}' is bound to branch '${e}', but current branch is '${kw(i)}'`}function Yr(t){return`change '${t}' uses a branch-bound workspace mode but has no bound branch and HEAD is detached; checkout a branch first before continuing.`}Mr();import Sw from"path";var Pa="comet.selection.v2",Ew=16*1024;function xa(t){return Sw.join(t,".comet","current-change.json")}function Cw(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function uu(t){return t===null||typeof t=="string"}function Pw(t){let e;try{e=JSON.parse(t)}catch(i){throw new Error(`current change selection contains invalid JSON: ${i instanceof Error?i.message:String(i)}`,{cause:i})}if(!Cw(e))throw new Error("current change selection must be a JSON object");if(e.version===1){if(typeof e.change!="string")throw new Error("legacy current change selection change must be a string");if(e.branch!==void 0&&!uu(e.branch))throw new Error("legacy current change selection branch must be a string or null");return{selection:{schema:Pa,workflow:"classic",change:e.change,branch:e.branch??null},legacy:!0}}if(e.schema!==Pa)throw new Error(`current change selection schema must be ${Pa}`);if(e.workflow!=="native"&&e.workflow!=="classic")throw new Error("current change selection workflow must be native or classic");if(typeof e.change!="string")throw new Error("current change selection change must be a string");if(!uu(e.branch))throw new Error("current change selection branch must be a string or null");if(e.workflow==="native"&&e.branch!==null)throw new Error("Native current change selection branch must be null");return{selection:e,legacy:!1}}async function Nt(t){let e;try{let r=xa(t),{bytes:n}=await hi(r,Ew,{label:"current change selection"});e=n.toString("utf8")}catch(r){if(r.code==="ENOENT")return{status:"missing"};throw new Error(`cannot read current change selection: ${r instanceof Error?r.message:String(r)}`,{cause:r})}return{status:"selected",...Pw(e)}}var tn=xt(mt(),1);Ge();we();import en from"path";Ei();var Ia=["full","hotfix","tweak"],Pu=1,Ru=["open","design","build","verify","archive"],Fw=["en","zh-CN"],Ww=["off","beta"],qw=["subagent-driven-development","executing-plans","direct"],Hw=["plan-ready"],Gw=["confirmed"],zw=["tdd","direct"],Vw=["off","standard","thorough"],Kw=["current","branch","worktree"],Jw=["light","full"],Uw=["pending","pass","fail"],Yw=["pending","handled"],Xw=["pending","confirmed"],ja=["workflow","language","phase","context_compression","build_mode","build_pause","subagent_dispatch","tdd_mode","review_mode","isolation","bound_branch","verify_mode","auto_transition","base_ref","design_doc","plan","verify_result","verify_failures","verification_report","branch_status","created_at","verified_at","archive_confirmation","archived","direct_override","handoff_context","handoff_hash","classic_profile","classic_migration"],Qw=["run_id"],_u=new Set([...ja,...Qw]),Zw=["workflow","phase","design_doc","plan","build_mode","isolation","verify_mode","verify_result","verified_at","archived"];function xu(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function kt(t,e){let i=t[e];if(i==null||i==="")return null;if(typeof i!="string")throw new Error(`Invalid Classic state: ${e} must be a string or null`);return i}function F(t,e,i,r=!0){let n=t[e];if(n==null||n===""){if(r)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof n!="string"||!i.includes(n))throw new Error(`Invalid Classic state: ${e} must be one of ${i.join(", ")}${r?" or null":""}`);return n}function Oa(t,e,i=!0){let r=t[e];if(r==null||r===""){if(i)return null;throw new Error(`Invalid Classic state: ${e} is required`)}if(typeof r!="boolean")throw new Error(`Invalid Classic state: ${e} must be true or false`);return r}function ev(t,e,i=0){let r=t[e];if(r==null||r==="")return i;if(typeof r!="number"||!Number.isInteger(r)||r<0)throw new Error(`Invalid Classic state: ${e} must be a non-negative integer`);return r}function Zr(t,e){let i=kt(t,e);if(i===null)return null;if(/^(?:[A-Za-z]:|[\\/]|~)/u.test(i)||i.split(/[\\/]/u).includes(".."))throw new Error(`Invalid Classic state: ${e} must be a relative repository path`);return i}function tv(t,e){let i=kt(t,e);if(i!==null&&!/^[a-f0-9]{64}$/u.test(i))throw new Error(`Invalid Classic state: ${e} must be a sha256 hex digest`);return i}function iv(t){let e=t.classic_migration;if(e==null||e==="")return null;if(e!==Pu)throw new Error(`Invalid Classic state: classic_migration must be ${Pu}`);return e}function rv(t){if(!ja.some(i=>xu(t,i)))return null;for(let i of Zw)if(!xu(t,i))return null;return{workflow:F(t,"workflow",Ia,!1),language:F(t,"language",Fw),phase:F(t,"phase",Ru,!1),contextCompression:F(t,"context_compression",Ww),buildMode:F(t,"build_mode",qw),buildPause:F(t,"build_pause",Hw),subagentDispatch:F(t,"subagent_dispatch",Gw),tddMode:F(t,"tdd_mode",zw),reviewMode:F(t,"review_mode",Vw),isolation:F(t,"isolation",Kw),boundBranch:kt(t,"bound_branch"),verifyMode:F(t,"verify_mode",Jw),autoTransition:Oa(t,"auto_transition"),baseRef:kt(t,"base_ref"),designDoc:Zr(t,"design_doc"),plan:Zr(t,"plan"),verifyResult:F(t,"verify_result",Uw,!1),verifyFailures:ev(t,"verify_failures"),verificationReport:Zr(t,"verification_report"),branchStatus:F(t,"branch_status",Yw),createdAt:kt(t,"created_at"),verifiedAt:kt(t,"verified_at"),archiveConfirmation:F(t,"archive_confirmation",Xw),archived:Oa(t,"archived",!1),directOverride:Oa(t,"direct_override"),handoffContext:Zr(t,"handoff_context"),handoffHash:tv(t,"handoff_hash"),classicProfile:F(t,"classic_profile",Ia),classicMigration:iv(t)}}function Au(t,e){let i=e??null;if(i===null&&e===void 0&&t.run_id&&t.skill)try{i=Si(t)}catch(r){let n=r instanceof Error?r.message:String(r);throw new Error(n.replace(/^Invalid Run state:/u,"Invalid Classic state:"),{cause:r})}return{classic:rv(t),run:i,unknownKeys:Object.keys(t).filter(r=>!_u.has(r))}}function Tu(t){let e=t.workflow,i=t.phase,r=t.archived,n=t.design_doc;return{workflow:typeof e=="string"&&Ia.includes(e)?e:null,phase:typeof i=="string"&&Ru.includes(i)?i:null,archived:r===!0,designDoc:typeof n=="string"&&n!==""?n:null,unknownKeys:Object.keys(t).filter(o=>!_u.has(o))}}Ei();var nv=2*1024*1024;function Ci(t){let e=t.toJS();if(e===null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("Invalid Classic state document: root must be a mapping");return e}function ov(t){let e=["skill","skill_version","skill_hash","orchestration","current_step","iteration","pending","pending_ref","trajectory_ref","context_ref","artifacts_ref","checkpoint_ref","run_status","run_retries"];for(let i of e)t.delete(i)}function av(t){let e=!1;for(let i of["build_command","verify_command"])t.has(i)&&(t.delete(i),e=!0);return e}async function Ou(t){let e;try{e=(await te(en.dirname(t),en.basename(t),nv,{label:"Classic state document"})).bytes.toString("utf8")}catch(r){if(r.code!=="ENOENT")throw r;return new tn.Document({})}let i=(0,tn.parseDocument)(e);if(i.errors.length>0)throw new Error(`Invalid Classic state document: ${i.errors[0].message}`);return Ci(i),i}async function rn(t,e={}){let i=e.migrate!==!1,r=en.join(t,".comet.yaml"),n=await Ou(r),o=Ci(n),a=av(n);a&&(o=Ci(n));let s=await Aa(t);if(!s&&o.run_id&&o.skill){let{runStateFromDocument:c}=await Promise.resolve().then(()=>(Ei(),Cu));s=c(o),s&&i&&(await Ta(t,s),ov(n),a=!0)}return a&&i&&await ve(r,n.toString(),{containedRoot:t}),Au(Ci(n),s)}async function Iu(t){let e=await Ou(en.join(t,".comet.yaml"));return Tu(Ci(e))}var uv=K("readCometCurrentSelection",t=>Nt(t));async function fv(t,e){Sa(e);let i=await yi(e,t);if(!i.stateExists)throw new Error(`Cannot select current change '${e}': active change state not found`);let r=await rn(i.directory,{migrate:!1});if(!r.classic)throw new Error(`Cannot select current change '${e}': Classic state is incomplete`);if(r.classic.archived)throw new Error(`Cannot select current change '${e}': change is archived`);return i.directory}async function nn(t){let e;try{e=await uv(t)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}if(e.status==="missing")return{status:"missing"};if(e.selection.workflow!=="classic")return{status:"stale",reason:`current change '${e.selection.change}' belongs to Native, not Classic`};let i=e.selection,r;try{r=await fv(t,i.change)}catch(o){return{status:"stale",reason:o instanceof Error?o.message:String(o)}}let n=await Jr(r,{heal:!1,cwd:t});return n.status==="drift"?{status:"stale",reason:Ur(i.change,n.boundBranch,n.currentBranch)}:n.status==="unbound-detached"?{status:"stale",reason:Yr(i.change)}:n.status==="ok"?{status:"selected",selection:i}:i.branch!==null&&n.currentBranch!==i.branch?{status:"stale",reason:`current change '${i.change}' was selected on branch '${i.branch}', current branch is '${n.currentBranch??"detached HEAD"}'`}:{status:"selected",selection:i}}import Ke from"node:path";async function ju(t,e){if(!e||e==="null")return{status:"missing",recordedPath:null};let i=await ye(t),r=Ke.resolve(t,e),n=Ke.relative(i.superpowersPlansDir,r);return Ke.isAbsolute(e)||!n||n.startsWith(`..${Ke.sep}`)||Ke.isAbsolute(n)||n.includes(Ke.sep)||Ke.extname(n).toLowerCase()!==".md"?{status:"broken",recordedPath:e}:await nu(t,e,{label:`Classic build plan ${e}`,expected:"file"})?{status:"ready",recordedPath:e}:{status:"broken",recordedPath:e}}function ie(t,e){return{exitCode:t,stderr:e+`
`}}function be(t){return ie(0,`[COMET-HOOK] allowed: ${t}`)}function xi(t){return t.replaceAll("\\","/").replace(/\/+/gu,"/")}function Je(t){let e=xi(t);return process.platform==="win32"?e.toLowerCase():e}function Lu(t,e){let i=xi(J.relative(e,t));return i===""?"":i.startsWith("../")||i===".."||J.isAbsolute(i)?null:i}async function dv(t){let e=J.resolve(t),i=J.parse(e).root,r=[],n=e;for(;n&&n!==i;)try{let o=await on.realpath(n);return J.join(o,...r.reverse())}catch(o){let a=o.code;if(a!=="ENOENT"&&a!=="ENOTDIR")throw o;r.push(J.basename(n)),n=J.dirname(n)}try{let o=await on.realpath(i);return J.join(o,...r.reverse())}catch{return null}}async function hv(t,e){let i=J.isAbsolute(t)?t:J.resolve(e,t),r=xi(i),n=Lu(i,e);if(n!==null)return n;try{let o=await dv(i),a=await on.realpath(e);if(o){let s=Lu(o,a);if(s!==null)return s;r=xi(o)}}catch{if(!J.isAbsolute(t))return xi(t).replace(/^\.\//u,"")}return r.replace(/^\.\//u,"")}async function Mu(t){try{let e=await rn(t,{migrate:!1}),i=Array.from(new Set(e.unknownKeys)).sort();if(i.length>0)throw new Error(`Invalid Classic state: unknown field(s): ${i.join(", ")}`);if(!e.classic)throw new Error("Classic state projection is unavailable");return{changeDir:t,phase:e.classic.phase,classic:e.classic,archived:e.classic.archived}}catch(e){let i=await Iu(t);return i.phase?{changeDir:t,phase:i.phase,classic:null,archived:i.archived,invalidState:e instanceof Error&&e.message.includes("unknown field")}:null}}async function mv(t){let e=(await ye(t)).changesDir,i=[];if(!(await bt(t,e,{label:"Classic changes directory",expected:"directory"})).exists)return i;for(let n of(await on.readdir(e,{withFileTypes:!0})).sort((o,a)=>o.name.localeCompare(a.name))){if(n.name==="archive"||ka(n.name))continue;let o=await yi(n.name,t);if(!o.exists||!o.stateExists)continue;let a=await Mu(o.directory);!a||a.archived||i.push(a)}return i}var Ri=K("classicActiveChanges",t=>mv(t)),Fu=K("classicPlanReadiness",ju);async function Wu(t){return(await Ri(t)).map(e=>({workflow:"classic",name:re(e),phase:e.phase}))}function qu(t,e){return`${B(t,e.superpowersRoot)}/`}function Hu(t,e){return Je(t).startsWith(Je(e))}function pv(t,e){return[{prefix:`${B(t,e.superpowersSpecsDir)}/`,field:"designDoc",wireField:"design_doc",phase:"design"},{prefix:`${B(t,e.superpowersPlansDir)}/`,field:"plan",wireField:"plan",phase:"build"},{prefix:`${B(t,e.superpowersReportsDir)}/`,field:"verificationReport",wireField:"verification_report",phase:"verify"}]}function gv(t,e){let i=Je(t),r=e.find(o=>i.startsWith(Je(o.prefix)));if(!r)return null;let n=i.slice(Je(r.prefix).length);return!n||n.includes("/")||!n.endsWith(".md")?null:r}function Gu(t,e){return t.classic?.[e.field]??null}function wv(t,e){return t.classic!==null&&t.phase===e.phase&&!Gu(t,e)}async function $u(t,e,i){return wv(e,i)?!0:i.field!=="plan"||e.phase!=="build"?!1:(await Fu(t,e.classic?.plan??null)).status==="broken"}function zu(t){return t.phase==="design"||t.phase==="build"||t.phase==="verify"}function re(t){return t.changeDir?J.basename(t.changeDir):null}var vv=new Set(["design","plan","verify","verification","verification-report","report"]);function Du(t){return t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}function yv(t,e){return[e.classic?.designDoc,e.classic?.plan,e.classic?.verificationReport].some(r=>r&&Je(r)===Je(t))}function bv(t,e){let r=(t.split("/").at(-1)??t).replace(/\.[^.]+$/u,"");if(r===e)return!0;let n=[...vv].map(Du).join("|");return new RegExp(`(^|[-_.])${Du(e)}[-_.](${n})$`,"u").test(r)}async function Nv(t,e){let i=await Ri(e),r=i.find(a=>yv(t,a));if(r)return{governing:r,match:"recorded"};let o=i.filter(zu).filter(a=>{let s=re(a);return s!==null&&bv(t,s)}).sort((a,s)=>(re(s)?.length??0)-(re(a)?.length??0))[0];return o?{governing:o,match:"named"}:null}async function Bu(t,e,i){let r=await Ri(t);if(r.length===0)return null;if(i)return r.find(a=>re(a)===i)??{blockedResult:Pi(e,`selected change '${i}' is no longer active`)};let n=await nn(t);if(n.status==="stale")return{blockedResult:Pi(e,n.reason)};if(n.status==="selected"){let o=r.find(a=>re(a)===n.selection.change);return o||{blockedResult:Pi(e,`selected change '${n.selection.change}' is no longer active`)}}if(r.length===1){let o=r[0];if(o.changeDir!==null){let a=await Jr(o.changeDir,{heal:!1,cwd:t}),s=re(o)??"unknown";if(a.status==="drift")return{blockedResult:Pi(e,Ur(s,a.boundBranch,a.currentBranch))};if(a.status==="unbound-detached")return{blockedResult:Pi(e,Yr(s))}}return o}return{blockedResult:Tv(e,r.map(o=>re(o)).filter(Boolean))}}async function kv(t,e,i,r){let n=`${B(e,i.changesDir)}/`;if(t.startsWith(n)){let o=t.slice(n.length),[a]=o.split("/");if(a&&a!=="archive"){let s=await yi(a,e);if(s.stateExists){let c=await Mu(s.directory);return c||{changeDir:s.directory,phase:"open",classic:null,archived:!1}}return{changeDir:s.directory,phase:"open",classic:null,archived:!1}}}if(Hu(t,qu(e,i))){let o=await Nv(t,e);if(o?.match==="recorded")return{...o.governing,superpowersArtifact:"matched"};let a=gv(t,pv(e,i));if(o)return a?{...o.governing,superpowersArtifact:await $u(e,o.governing,a)?"matched":"unmatched",superpowersSlot:a}:{...o.governing,superpowersArtifact:"matched"};if(a){let l=await Bu(e,t,r);return!l||"blockedResult"in l?l:{...l,superpowersArtifact:await $u(e,l,a)?"matched":"unmatched",superpowersSlot:a}}let s=await Ri(e),c=r?s.find(l=>re(l)===r)??null:s[0]??null;return c?{...c,superpowersArtifact:"unmatched"}:null}return Bu(e,t,r)}function Sv(t){return!t.includes("/")&&t.endsWith(".md")}function Ev(t){return t.startsWith(".comet/")||t.includes("/.comet/")}function Cv(t){return t===".superpowers"||t.startsWith(".superpowers/")}function Pv(t,e,i){if(!t.startsWith(i))return null;let r=t.endsWith("/.comet.yaml")||t.endsWith("/.openspec.yaml"),n=t.endsWith("/proposal.md")||t.endsWith("/design.md")||t.endsWith("/tasks.md"),o=t.includes("/.comet/"),a=t.includes("/specs/");return e==="open"&&(n||r||o||a)?`${t} (phase: open, openspec artifacts)`:e==="design"&&(n||r||o||a)?`${t} (phase: design, handoff/spec)`:e==="build"&&(t.endsWith("/tasks.md")||r||a)?`${t} (phase: build, spec/tasks)`:e==="verify"&&(t.endsWith("/tasks.md")||r)?`${t} (phase: verify, tasks/state)`:e==="archive"&&r?`${t} (phase: archive, state)`:null}function xv(t,e){let i=e==="open"?[" BLOCKED: source writes are not allowed during open"," This phase does not allow source writes"," ALLOWED: create proposal/design/tasks artifacts and run guard"," NEXT: finish clarification and artifacts, then run guard --apply"]:e==="design"?[" BLOCKED: source writes are not allowed during design"," This phase does not allow source writes"," ALLOWED: run brainstorming, create the Design Doc, and run guard"," NEXT: finish the Design Doc, then run comet guard <change-name> design --apply to enter build"]:[" BLOCKED: source writes are not allowed during archive"," This phase does not allow source writes"," ALLOWED: confirm archive state and run the archive script"];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",` Current phase: ${e}`,` Target file: ${t}`,"",...i,""].join(`
`))}function Rv(t){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," Current phase: build (workflow: full), but design_doc is empty",` Target file: ${t}`,""," BLOCKED: full workflow source writes require a recorded Design Doc"," This phase does not allow source writes until design_doc is recorded"," NEXT: return to design, create/link the Design Doc, then run guard again",""].join(`
`))}function _v(t,e,i,r,n){let o=re(e)??"<change-name>",a=i.status==="missing",s=a?"classic-build-plan-missing":"classic-build-plan-broken",c=a?"plan is not recorded":"the recorded plan path does not resolve to a file",l=a?[]:[`RECORDED_PLAN: ${i.recordedPath}`],f=e.changeDir?B(r,e.changeDir):"<classic-change-dir>",u=B(r,n.superpowersPlansDir),d=a?`comet state set ${o} plan <repository-relative-plan-path>`:`comet state set ${o} plan <new-repository-relative-plan-path>`,m=a?["2. Load the Superpowers writing-plans Skill.",`3. Read the Design Doc path from "comet state get ${o} design_doc" and read ${f}/tasks.md.`,`4. Create the implementation plan under ${u}/.`,"5. Record the plan path:",` ${d}`]:[`2. Restore the plan file at ${i.recordedPath}, or load the Superpowers writing-plans Skill and create a replacement under ${u}/.`,"3. When creating a replacement, record its path:",` ${d}`];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",`ERROR_CODE: ${s}`,`CHANGE: ${o}`,"WORKFLOW: full","PHASE: build",`TARGET: ${t}`,`STATE: ${c}`,...l,"","BLOCKED: project source writes require a ready Superpowers implementation plan.","","ALLOWED_RECOVERY_WRITES:",`- ${u}/<plan-file>.md`,"- Comet state updates performed by the comet CLI",`- ${f} artifacts allowed by the build phase`,"","RECOVERY:",`1. Invoke /comet-build for ${o} and resume Step 1.`,...m,`${a?"6":"4"}. Verify recovery:`,` comet state check ${o} build --recover`,"","SUCCESS: plan is reported as DONE and recovery advances beyond plan creation.",`RETRY: retry the original Write/Edit for ${t} only after SUCCESS.`,"PROHIBITED: do not treat tasks.md as the implementation plan or write project source before SUCCESS.","If writing-plans is unavailable, stop and report the missing Skill instead of bypassing this check.",""].join(`
`))}function Av(t,e){let i=e.superpowersSlot,r=i?Gu(e,i):null,n=i?e.phase!==i.phase?[` BLOCKED: ${i.wireField} cannot be first-written in phase ${e.phase}`,` Expected phase: ${i.phase}`," NEXT: resume the matching Comet phase or use an already recorded artifact path"]:r?[` BLOCKED: ${i.wireField} is already recorded for this change`,` Recorded path: ${r}`," NEXT: write the recorded artifact or explicitly correct the state path"]:[" BLOCKED: standard Superpowers artifact state is incomplete"," NEXT: validate the active change state, then retry the matching phase"]:[" BLOCKED: unmatched Superpowers artifact"," This docs/superpowers/ path does not match any active change artifact"," NEXT: use a recorded artifact path or a standard phase artifact directory"];return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝","",` Current phase: ${e.phase}`,` Target file: ${t}`,"",...n,""].join(`
`))}function Tv(t,e){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," BLOCKED: multiple active changes require a current change",` Target file: ${t}`,` Active changes: ${e.join(", ")}`,""," NEXT: run comet state select <change-name>, then retry the source write",""].join(`
`))}function Pi(t,e){return ie(2,["","╔══════════════════════════════════════════╗","║ COMET PHASE GUARD — WRITE BLOCKED ║","╚══════════════════════════════════════════╝",""," BLOCKED: current change selection is stale or invalid",` Target file: ${t}`,` Reason: ${e}`,""," NEXT: run comet state select <change-name>, then retry the source write",""].join(`
`))}async function Ov(t,e,i,r=Kr){try{if((await r(t,[e])).projectTargets.length===0)return be(`${e} (outside guarded project)`)}catch(l){return ie(2,[`[COMET-HOOK] blocked: scope could not be determined safely for ${e}.`,`REASON: ${l instanceof Error?l.message:String(l)}`,"NEXT: verify that the project root is accessible, then retry the write."].join(`
`))}let n=await hv(e,t),o;try{o=await Vr(t)}catch(l){return ie(2,`[COMET-HOOK] blocked: ${l instanceof Error?l.message:String(l)}`)}if(Ev(n))return be(`${n} (whitelist: comet config)`);if(Cv(n))return be(`${n} (whitelist: superpowers workspace)`);if(n==="CLAUDE.md"||n==="CHANGELOG.md"||n==="README.md"||Sv(n))return be(`${n} (whitelist: root markdown)`);let a;try{a=await kv(n,t,o,i)}catch(l){return ie(2,`[COMET-HOOK] blocked: ${l instanceof Error?l.message:String(l)}`)}if(!a)return be("no active comet change");if("blockedResult"in a)return a.blockedResult;if(a.archived)return be(`${n} (own change archived)`);let s=a.phase,c=Pv(n,s,`${B(t,o.openSpecRoot)}/`);if(c)return be(c);if(Hu(n,qu(t,o))){if(a.superpowersArtifact==="matched"&&zu(a))return be(`${n} (phase: ${s}, superpowers)`);if(a.superpowersArtifact==="unmatched")return Av(n,a)}if(a.invalidState)return ie(2,`[COMET-HOOK] blocked: active Classic state is invalid; repair .comet.yaml before writing ${n}`);if(s==="build"&&a.classic?.workflow==="full"&&!a.classic.designDoc)return Rv(n);if(s==="build"&&a.classic?.workflow==="full"){let l=await Fu(t,a.classic.plan);if(l.status!=="ready")return _v(n,a,l,t,o)}return s==="build"||s==="verify"?be(`${n} (phase: ${s})`):xv(n,s)}async function Vu(t,e,i,r={}){if(i.intent!=="non-write")try{await Vr(t)}catch(a){return{allowed:!1,reason:a instanceof Error?a.message:String(a),workflow:"classic",change:e}}let n;try{n=await Ri(t)}catch(a){return{allowed:!1,reason:a instanceof Error?a.message:String(a),workflow:"classic",change:e}}let o=n.find(a=>re(a)===e);if(!o)return{allowed:!1,reason:`Selected Classic change ${e} is missing or archived; resume /comet-classic before retrying`,workflow:"classic",change:e};if(i.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(i.intent==="unknown"||i.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"classic",change:e,phase:o.phase};for(let a of i.targets){let s=await Ov(t,a,e,r.scopeTargets);if(s.exitCode!==0)return{allowed:!1,reason:s.stderr?.trim()||"Classic phase guard blocked the write",workflow:"classic",change:e,phase:o.phase}}return{allowed:!0,reason:`Classic write allowed in ${o.phase}`,workflow:"classic",change:e,phase:o.phase}}import{promises as cb}from"fs";import Pt from"path";var za=xt(mt(),1);import{promises as Wy}from"fs";import et from"path";import{createHash as $v}from"node:crypto";import{promises as ne}from"node:fs";import U from"node:path";import{TextDecoder as Dv}from"node:util";var Iv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),jv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Lv(t){return t.toLowerCase().startsWith(".env")}function La(t){let i=t.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Lv(r))?"environment-file":i.some(r=>jv.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Iv.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}fi();var Bv=1024*1024;function $a(t,e){let i=U.relative(t,e);return i===""||!U.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${U.sep}`)}function Mv(t){let e=U.posix.normalize(t);if(t.length===0||t!==t.trim()||t.includes("\\")||Array.from(t).some(n=>{let o=n.codePointAt(0)??0;return o<=31||o===127})||U.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes("..")||e!==t||e==="."||t.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${t}`);let i=t.toLowerCase(),r=La(t);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${t}`);return t}function Fv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native artifact byte limit must be a positive integer");return t}function Wv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function an(t,e){let i={...t,birthtime:t.birthtimeMs},r={...e,birthtime:e.birthtimeMs};return fe(i,r)?T(i,r):T(i,r)&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.size===e.size}async function Ku(t){let e=await ne.lstat(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${t}`);return{path:t,realPath:await ne.realpath(t),dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs}}async function qv(t,e){let i=U.resolve(t),r=U.resolve(e);if(!$a(i,r))throw new Error("Native artifact path is outside its root");let n=[await Ku(i)],o=i;for(let a of U.relative(i,r).split(U.sep).filter(Boolean)){o=U.join(o,a);let s=await Ku(o);if(!$a(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${o}`);n.push(s)}return n}async function Ju(t){for(let e of t){let i=await ne.lstat(e.path);if(!i.isDirectory()||i.isSymbolicLink()||!Wv(e,i)||await ne.realpath(e.path)!==e.realPath)throw new Error(`Native artifact parent changed while reading: ${e.path}`)}}async function sn(t){let e=Mv(t.ref),i=Fv(t.maxBytes??Bv),r=U.resolve(t.root,...e.split("/")),n=await qv(t.root,U.dirname(r));await t.hooks?.afterParentChainCaptured?.();let o=await ne.lstat(r);if(!o.isFile()||o.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${e}`);if(o.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);let a=await ne.realpath(r);if(!$a(n[0].realPath,a))throw new Error(`Native artifact resolves outside its root: ${e}`);let s=await ne.open(r,"r");try{let[c,l,f]=await Promise.all([s.stat(),ne.lstat(r),ne.realpath(r)]);if(await Ju(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||f!==a||!an(o,c)||!an(c,l))throw new Error(`Native artifact changed while opening: ${e}`);await t.hooks?.afterOpen?.();let u=[],d=0,m=Buffer.allocUnsafe(Math.min(64*1024,i+1));for(;;){let k=i+1-d,S=await s.read(m,0,Math.min(m.length,k),null);if(S.bytesRead===0)break;if(d+=S.bytesRead,d>i)throw new Error(`Native artifact exceeds ${i} bytes: ${e}`);u.push(Buffer.from(m.subarray(0,S.bytesRead)))}await t.hooks?.beforeFinalCheck?.();let[w,h,p]=await Promise.all([s.stat(),ne.lstat(r),ne.realpath(r)]);if(await Ju(n),!h.isFile()||h.isSymbolicLink()||p!==a||!an(c,w)||!an(c,h))throw new Error(`Native artifact changed while reading: ${e}`);let y=Buffer.concat(u,d),b;try{b=new Dv("utf-8",{fatal:!0}).decode(y)}catch(k){throw new Error(`Native artifact is not valid UTF-8: ${e}`,{cause:k})}return{ref:e,size:d,hash:$v("sha256").update(y).digest("hex"),text:b}}finally{await s.close()}}ue();He();zr();var cn=$r;async function ln(t){let e=(await qe(t))?.config??null;return e?.native?e:null}import{AsyncLocalStorage as Hv}from"async_hooks";Mr();var rC=16*1024;var nC=new Hv;import{TextDecoder as Qv}from"util";import{createHash as Gv}from"node:crypto";import{constants as un,promises as oe}from"node:fs";import ae from"node:path";import{TextDecoder as zv}from"node:util";function dn(t,e){let i=ae.relative(t,e);return i===""||!ae.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ae.sep}`)}function Vv(t){if(!Number.isSafeInteger(t)||t<1)throw new Error("Native protected file byte limit must be a positive integer");return t}function Kv(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})}function Jv(t){return{dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs,ctimeMs:t.ctimeMs,mtimeMs:t.mtimeMs,size:t.size}}function fn(t,e){return T({...t,birthtime:t.birthtimeMs},{...e,birthtime:e.birthtimeMs})&&t.birthtimeMs===e.birthtimeMs&&t.ctimeMs===e.ctimeMs&&t.mtimeMs===e.mtimeMs&&t.size===e.size}async function Ba(t,e){let i=await oe.lstat(t);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${e} parent must be a real directory: ${t}`);return{path:t,realPath:await oe.realpath(t),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function Uv(t,e,i){let r=ae.resolve(t),n=ae.resolve(e);if(!dn(r,n))throw new Error(`${i} is outside its managed root`);let o=[await Ba(r,i)],a=r;for(let s of ae.relative(r,n).split(ae.sep).filter(Boolean)){await Ue(o,i),a=ae.join(a,s);let c=await Ba(a,i);if(!dn(o[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${a}`);o.push(c)}return await Ue(o,i),o}async function Ue(t,e){for(let i of t){let r=await oe.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!Kv(i,r)||await oe.realpath(i.path)!==i.realPath)throw new Error(`${e} parent changed during I/O: ${i.path}`)}}async function Yv(t,e,i){let r=[],n=0,o=Buffer.allocUnsafe(Math.min(64*1024,e+1));for(;;){let a=e+1-n,{bytesRead:s}=await t.read(o,0,Math.min(o.length,a),null);if(s===0)break;if(n+=s,n>e)throw new Error(`${i} exceeds ${e} bytes`);r.push(Buffer.from(o.subarray(0,s)))}return Buffer.concat(r,n)}async function Uu(t){let e=Vv(t.maxBytes),i=ae.resolve(t.file),r=await Uv(t.root,ae.dirname(i),t.label),n=await Promise.all((t.forbiddenRoots??[]).map(f=>Ba(ae.resolve(f),t.label)));await t.hooks?.afterParentChainCaptured?.(),await Ue(r,t.label);let o=await oe.lstat(i);if(!o.isFile()||o.isSymbolicLink())throw new Error(`${t.label} must be a regular file`);if(o.size>e)throw new Error(`${t.label} exceeds ${e} bytes`);let a=Jv(o),s=await oe.realpath(i);if(!dn(r[0].realPath,s))throw new Error(`${t.label} resolves outside its managed root`);if(n.some(f=>dn(f.realPath,s)))throw new Error(`${t.label} resolves inside an excluded root`);let c=process.platform==="win32"?un.O_RDONLY:un.O_RDONLY|un.O_NOFOLLOW|un.O_NONBLOCK,l=await oe.open(i,c);try{let f=await l.stat();await t.hooks?.afterOpen?.();let[u,d]=await Promise.all([oe.lstat(i),oe.realpath(i)]);if(await Ue(r,t.label),await Ue(n,t.label),!f.isFile()||!u.isFile()||u.isSymbolicLink()||d!==s||!fn(a,f)||!fn(a,u))throw new Error(`${t.label} changed while opening`);await t.hooks?.beforeRead?.();let m=await Yv(l,e,t.label);await t.hooks?.beforeFinalCheck?.();let[w,h,p]=await Promise.all([l.stat(),oe.lstat(i),oe.realpath(i)]);if(await Ue(r,t.label),await Ue(n,t.label),!h.isFile()||h.isSymbolicLink()||p!==s||!fn(a,w)||!fn(a,h))throw new Error(`${t.label} changed while reading`);return{bytes:m,hash:Gv("sha256").update(m).digest("hex"),size:m.length}}finally{await l.close()}}async function Yu(t){let e=await Uu(t),i;try{i=new zv("utf-8",{fatal:!0}).decode(e.bytes)}catch(r){throw new Error(`${t.label} is not valid UTF-8`,{cause:r})}return{...e,text:i}}var kC=256*1024,SC=1024*1024,EC=16*1024;var CC=64*1024*1024;var PC=new Qv("utf-8",{fatal:!0});import mn from"path";import{createHash as Zv}from"crypto";function Zu(t){return Zv("sha256").update(t).digest("hex")}var KC={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024},ty=1e3,iy=8*1024*1024,ry=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,ny=new Set(["schema","origin","capture","createdAt","complete","limits","entries","omitted","omittedCount","omissionOverflow","policy"]),oy=new Set(["maxFiles","maxFileBytes","maxTotalBytes","maxManifestBytes","maxDurationMs"]),ay=new Set(["schema","include","exclude","hash"]),sy=new Set(["provider","gitSelection","physicalSelection","projection"]),cy=new Set(["provider","selection"]),ly=new Set(["schema","status","stageBefore","combined","stageAfter","finalStageBefore","finalCombined","finalStageAfter"]),uy=new Set(["hash","recordCount","storedRecordCount","stdoutBytes","overflow"]),fy=new Set(["schema","status","before","after"]),dy=new Set(["hash","visitedNodeCount","recordCount","storedRecordCount","encodedBytes","overflow","unstable"]),hy=new Set(["path","hash","size","type","gitObjectId"]),my=new Set(["path","size","type","reason"]),py=new Set(["ref","hash","count"]),gy=new Set(["change-created","legacy-migration","explicit"]),wy=new Set(["file","directory","other"]),vy=new Set(["file-size","file-count","total-size","manifest-size","changed-during-read","unreadable","gitlink-unavailable","gitlink-dirty","gitlink-changed","legacy-gitlink-boundary","git-enumeration-limit","git-selection-changed","physical-enumeration-limit","physical-selection-changed"]),pn=/^[a-f0-9]{64}$/u,yy=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;var JC=64*1024,UC=64*1024;var YC={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},XC={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};function hn(t,e){return t.hash===e.hash&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.stdoutBytes===e.stdoutBytes&&t.overflow===e.overflow}var QC=(1n<<256n)-1n;function by(t,e){return t.hash===e.hash&&t.visitedNodeCount===e.visitedNodeCount&&t.recordCount===e.recordCount&&t.storedRecordCount===e.storedRecordCount&&t.encodedBytes===e.encodedBytes&&t.overflow===e.overflow&&t.unstable===e.unstable}function Ny(t){return Buffer.byteLength(JSON.stringify(t,null,2)+`
`)}function ky(t,e){return Zu(`comet.native.snapshot-policy.v1
${JSON.stringify({include:t,exclude:e,hash:"sha256"})}`)}function Ma(t,e,i){let r=new Set(e),n=[...e];for(;n.length>0;){if(i&&!i())return null;let o=n.pop(),a=t[o];a&&(a.kind==="star"||a.kind==="globstar"||a.kind==="globstar-slash")&&!r.has(o+1)&&(r.add(o+1),n.push(o+1))}return r}function Sy(t){let e=0;return()=>e>0?(e-=1,!0):t()?(e=63,!0):!1}function ef(t){let e=cn(t,"Native snapshot pattern"),i=[];for(let r=0;r<e.length;r+=1){let n=e[r];n==="*"&&e[r+1]==="*"?(r+=1,e[r+1]==="/"?(r+=1,i.push({kind:"globstar-slash"})):i.push({kind:"globstar"})):n==="*"?i.push({kind:"star"}):n==="?"?i.push({kind:"question"}):i.push({kind:"literal",value:n})}return(r,n)=>{let o=n?Sy(n):void 0;if(o&&!o())return!1;let a=Ma(i,new Set([0]),o);if(a===null)return!1;for(let s of r){if(o&&!o())return!1;let c=new Set;for(let l of a){if(o&&!o())return!1;let f=i[l];f&&(f.kind==="literal"&&f.value===s||f.kind==="question"&&s!=="/"?c.add(l+1):f.kind==="star"&&s!=="/"||f.kind==="globstar"?c.add(l):f.kind==="globstar-slash"&&(c.add(l),s==="/"&&c.add(l+1)))}if(a=Ma(i,c,o),a===null||a.size===0)return!1}return Ma(i,a,o)?.has(i.length)??!1}}function Ey(t){if(t===void 0)return;let e=[...new Set(t.include.map(n=>cn(n,"include")))].sort((n,o)=>n.localeCompare(o,"en")),i=[...new Set(t.exclude.map(n=>cn(n,"exclude")))].sort((n,o)=>n.localeCompare(o,"en"));if(e.length===0)throw new Error("Native snapshot policy include must not be empty");let r=ky(e,i);if("hash"in t&&t.hash!==r)throw new Error("Native snapshot policy hash is invalid");return{manifest:{schema:"comet.native.snapshot-policy.v1",include:e,exclude:i,hash:r},includeMatchers:e.map(ef),excludeMatchers:i.map(ef),excludedDirectoryPrefixes:i.flatMap(n=>{if(!n.endsWith("/**"))return[];let o=n.slice(0,-3);return/[*?]/u.test(o)?[]:[o]}).sort((n,o)=>n.localeCompare(o,"en"))}}function Y(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be an object`);return t}function X(t,e,i){let r=Object.keys(t).find(n=>!e.has(n));if(r)throw new Error(`${i} contains unknown field: ${r}`)}function Et(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function de(t,e){if(!Number.isSafeInteger(t)||t<0)throw new Error(`${e} must be a non-negative integer`);return t}function nf(t,e){if(typeof t!="string"||t.length===0||t.includes("\\")||t.includes("\0"))throw new Error(`${e} must be a normalized project-relative path`);let i=mn.posix.normalize(t);if(i!==t||mn.posix.isAbsolute(t)||i===".."||i.startsWith("../"))throw new Error(`${e} must stay inside the project root`);return t}function Cy(t,e){let i=Y(t,`Native snapshot entry ${e}`);X(i,hy,`Native snapshot entry ${e}`);let r=nf(i.path,`Native snapshot entry ${e} path`);if(typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`Native snapshot entry ${e} hash is invalid`);if(i.type!=="file")throw new Error(`Native snapshot entry ${e} type is invalid`);let n={path:r,hash:i.hash,size:de(i.size,`Native snapshot entry ${e} size`),type:"file"};if(i.gitObjectId!==void 0){if(typeof i.gitObjectId!="string"||!yy.test(i.gitObjectId))throw new Error(`Native snapshot entry ${e} gitObjectId is invalid`);n.gitObjectId=i.gitObjectId}return n}function Py(t,e){let i=Y(t,`Native snapshot omission ${e}`);if(X(i,my,`Native snapshot omission ${e}`),!wy.has(i.type))throw new Error(`Native snapshot omission ${e} type is invalid`);if(!vy.has(i.reason))throw new Error(`Native snapshot omission ${e} reason is invalid`);return{path:nf(i.path,`Native snapshot omission ${e} path`),size:i.size===null?null:de(i.size,`Native snapshot omission ${e} size`),type:i.type,reason:i.reason}}function xy(t){let e=Y(t,"Native snapshot omission overflow");if(X(e,py,"Native snapshot omission overflow"),typeof e.hash!="string"||!pn.test(e.hash))throw new Error("Native snapshot omission overflow hash is invalid");let i=`native-snapshot://omitted-overflow/${e.hash}`;if(e.ref!==i)throw new Error("Native snapshot omission overflow ref is invalid");return{ref:i,hash:e.hash,count:Et(e.count,"Native snapshot omission overflow count")}}function St(t,e){let i=Y(t,e);if(X(i,uy,e),typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean")throw new Error(`${e} overflow flag is invalid`);let r=de(i.recordCount,`${e} recordCount`),n=de(i.storedRecordCount,`${e} storedRecordCount`),o=de(i.stdoutBytes,`${e} stdoutBytes`);if(n>r||!i.overflow&&n!==r)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,recordCount:r,storedRecordCount:n,stdoutBytes:o,overflow:i.overflow}}function tf(t){let e=Y(t,"Native Git selection evidence");if(X(e,ly,"Native Git selection evidence"),e.schema!=="comet.native.git-selection.v1")throw new Error("Native Git selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native Git selection evidence status is invalid");let i=St(e.stageBefore,"Native Git selection stageBefore"),r=St(e.combined,"Native Git selection combined"),n=St(e.stageAfter,"Native Git selection stageAfter"),o=St(e.finalStageBefore,"Native Git selection finalStageBefore"),a=St(e.finalCombined,"Native Git selection finalCombined"),s=St(e.finalStageAfter,"Native Git selection finalStageAfter"),c=[i,r,n,o,a,s].some(u=>u.overflow),l=!hn(i,n)||!hn(n,o)||!hn(r,a)||!hn(o,s),f=c&&l?"overflow-and-changed":c?"overflow":"changed";if(!c&&!l)throw new Error("Native Git selection evidence must describe an exceptional selection");if(e.status!==f)throw new Error("Native Git selection evidence status is inconsistent");return{schema:"comet.native.git-selection.v1",status:f,stageBefore:i,combined:r,stageAfter:n,finalStageBefore:o,finalCombined:a,finalStageAfter:s}}function rf(t,e){let i=Y(t,e);if(X(i,dy,e),typeof i.hash!="string"||!pn.test(i.hash))throw new Error(`${e} hash is invalid`);if(typeof i.overflow!="boolean"||typeof i.unstable!="boolean")throw new Error(`${e} flags are invalid`);let r=de(i.visitedNodeCount,`${e} visitedNodeCount`),n=de(i.recordCount,`${e} recordCount`),o=de(i.storedRecordCount,`${e} storedRecordCount`),a=de(i.encodedBytes,`${e} encodedBytes`);if(o>n||!i.overflow&&o!==n)throw new Error(`${e} stored record count is inconsistent`);return{hash:i.hash,visitedNodeCount:r,recordCount:n,storedRecordCount:o,encodedBytes:a,overflow:i.overflow,unstable:i.unstable}}function Ry(t){let e=Y(t,"Native physical selection evidence");if(X(e,fy,"Native physical selection evidence"),e.schema!=="comet.native.physical-selection.v1")throw new Error("Native physical selection evidence schema is invalid");if(e.status!=="overflow"&&e.status!=="changed"&&e.status!=="overflow-and-changed")throw new Error("Native physical selection evidence status is invalid");let i=rf(e.before,"Native physical selection before"),r=rf(e.after,"Native physical selection after"),n=i.overflow||r.overflow,o=i.unstable||r.unstable||!by(i,r);if(!n&&!o)throw new Error("Native physical selection evidence must describe an exceptional selection");let a=n&&o?"overflow-and-changed":n?"overflow":"changed";if(e.status!==a)throw new Error("Native physical selection evidence status is inconsistent");return{schema:"comet.native.physical-selection.v1",status:a,before:i,after:r}}function _y(t){let e=Y(t,"Native content snapshot manifest");if(X(e,ny,"Native content snapshot manifest"),e.schema!=="comet.native.content-snapshot.v1")throw new Error("Unsupported Native content snapshot schema");if(!gy.has(e.origin))throw new Error("Native content snapshot origin is invalid");let i;if(e.capture!==void 0){let g=Y(e.capture,"Native content snapshot capture");if(X(g,sy,"Native content snapshot capture"),g.provider!=="git"&&g.provider!=="physical-tree")throw new Error("Native content snapshot capture provider is invalid");let P=g.gitSelection===void 0?void 0:tf(g.gitSelection),N=g.physicalSelection===void 0?void 0:Ry(g.physicalSelection),_=null;if(g.projection!==void 0){let G=Y(g.projection,"Native content snapshot projection");if(X(G,cy,"Native content snapshot projection"),G.provider!=="git")throw new Error("Native content snapshot projection provider is invalid");_={provider:"git",...G.selection===void 0?{}:{selection:tf(G.selection)}}}if(g.provider==="git"){if(N||_)throw new Error("Native Git capture cannot include physical or projection evidence");i={provider:"git",...P?{gitSelection:P}:{}}}else{if(P)throw new Error("Native physical-tree capture cannot include direct Git evidence");if(N&&_)throw new Error("Native physical-tree capture cannot combine selection and projection");i=_?{provider:"physical-tree",projection:_}:{provider:"physical-tree",...N?{physicalSelection:N}:{}}}}if(typeof e.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))throw new Error("Native content snapshot timestamp is invalid");if(typeof e.complete!="boolean")throw new Error("Native content snapshot complete flag is invalid");let r=Y(e.limits,"Native content snapshot limits");X(r,oy,"Native content snapshot limits");let n={maxFiles:Et(r.maxFiles,"Native snapshot maxFiles"),maxFileBytes:Et(r.maxFileBytes,"Native snapshot maxFileBytes"),maxTotalBytes:Et(r.maxTotalBytes,"Native snapshot maxTotalBytes"),maxManifestBytes:Et(r.maxManifestBytes,"Native snapshot maxManifestBytes"),...r.maxDurationMs===void 0?{}:{maxDurationMs:Et(r.maxDurationMs,"Native snapshot maxDurationMs")}},o;if(e.policy!==void 0){let g=Y(e.policy,"Native snapshot policy");if(X(g,ay,"Native snapshot policy"),g.schema!=="comet.native.snapshot-policy.v1")throw new Error("Native snapshot policy schema is invalid");if(!Array.isArray(g.include)||!Array.isArray(g.exclude))throw new Error("Native snapshot policy patterns must be arrays");o=Ey({include:g.include,exclude:g.exclude,hash:g.hash,schema:"comet.native.snapshot-policy.v1"}).manifest}if(!Array.isArray(e.entries)||!Array.isArray(e.omitted))throw new Error("Native content snapshot entries and omissions must be arrays");let a=e.entries.map(Cy),s=e.omitted.map(Py),c=de(e.omittedCount,"Native content snapshot omittedCount"),l=e.omissionOverflow===void 0?void 0:xy(e.omissionOverflow);if(a.length>n.maxFiles)throw new Error("Native content snapshot exceeds its file-count limit");if(a.some(g=>g.size>n.maxFileBytes)||a.reduce((g,P)=>g+P.size,0)>n.maxTotalBytes)throw new Error("Native content snapshot exceeds its byte limits");if(new Set(a.map(g=>g.path)).size!==a.length)throw new Error("Native content snapshot contains duplicate paths");if(s.length>ty||c<s.length)throw new Error("Native content snapshot omission count is invalid");let f=c-s.length;if(f===0&&l||f>0&&l?.count!==f)throw new Error("Native content snapshot omission overflow is inconsistent");if(e.complete!==(c===0))throw new Error("Native content snapshot completeness is inconsistent");let u=s.filter(g=>g.reason==="git-enumeration-limit"),d=s.filter(g=>g.reason==="git-selection-changed");for(let g of[...u,...d])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native Git selection omission must use the project-root sentinel");if(u.length>1||d.length>1)throw new Error("Native Git selection omissions must not be duplicated");let m=i?.provider==="git"?i.gitSelection:i?.projection?.selection,w=m?.status==="overflow"||m?.status==="overflow-and-changed",h=m?.status==="changed"||m?.status==="overflow-and-changed";if(w!==(u.length===1))throw new Error("Native Git enumeration omission and selection evidence are inconsistent");if(h!==(d.length===1))throw new Error("Native Git selection-change omission and selection evidence are inconsistent");let p=s.filter(g=>g.reason==="physical-enumeration-limit"),y=s.filter(g=>g.reason==="physical-selection-changed");for(let g of[...p,...y])if(g.path!=="."||g.size!==null||g.type!=="directory")throw new Error("Native physical selection omission must use the project-root sentinel");if(p.length>1||y.length>1)throw new Error("Native physical selection omissions must not be duplicated");let b=i?.physicalSelection,k=b?.status==="overflow"||b?.status==="overflow-and-changed",S=b?.status==="changed"||b?.status==="overflow-and-changed";if(k!==(p.length===1))throw new Error("Native physical enumeration omission and evidence are inconsistent");if(S!==(y.length===1))throw new Error("Native physical selection-change omission and evidence are inconsistent");let E={schema:"comet.native.content-snapshot.v1",origin:e.origin,...i?{capture:i}:{},createdAt:e.createdAt,complete:e.complete,limits:n,...o?{policy:o}:{},entries:a,omitted:s,omittedCount:c,...l?{omissionOverflow:l}:{}};if(Ny(E)>n.maxManifestBytes)throw new Error("Native content snapshot exceeds its manifest byte limit");return E}function Ay(t,e){if(!ry.test(e))throw new Error(`Invalid Native change name: ${e}`);let i=mn.join(t.changesDir,e);if(!vt(t.changesDir,i))throw new Error("Native change path escaped");return mn.join(i,"runtime","baseline-manifest.json")}async function of(t,e){let i=Ay(t,e);await pe(t.nativeRoot,i);try{let r=await Yu({root:t.nativeRoot,file:i,maxBytes:iy,label:"Native baseline snapshot manifest"});return _y(JSON.parse(r.text))}catch(r){if(r.code==="ENOENT")return null;throw r}}Ei();var fP={runStateBytes:256*1024,trajectoryBytes:8*1024*1024,trajectoryEvents:4096,trajectoryEventBytes:256*1024,checkpointBytes:256*1024,pendingActionBytes:256*1024,contextBytes:1024*1024,artifactsBytes:1024*1024};import{createHash as jy}from"node:crypto";import{promises as gn}from"node:fs";import je from"node:path";import{execFileSync as Oy}from"child_process";import Ai from"path";function _i(t,e){return Oy("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Iy(t,e){let i=Ai.normalize(t),r=Ai.normalize(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function af(t){try{let e=Ai.resolve(_i(t,["rev-parse","--show-toplevel"])),r=_i(t,["worktree","list","--porcelain","-z"]).split("\0").find(a=>a.startsWith("worktree ")),n=r?Ai.resolve(r.slice(9)):e,o=null;try{o=_i(t,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Iy(e,n),currentWorktreeRoot:e,primaryWorktreeRoot:n,currentBranch:o}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function sf(t){try{_i(t,["rev-parse","--is-inside-work-tree"])}catch{return[]}return _i(t,["worktree","list","--porcelain","-z"]).split("\0").filter(i=>i.startsWith("worktree ")).map(i=>Ai.resolve(i.slice(9)))}var Ti=/^[a-f0-9]{64}$/u,Ly=16*1024,Wa=process.platform;function ff(t,e){let i=je.relative(t,e);return je.isAbsolute(i)||i===".."||i.startsWith(`..${je.sep}`)?null:i.replaceAll("\\","/")||"."}function df(t){return Array.from(t).some(e=>{let i=e.codePointAt(0)??0;return i<=31||i===127})}function hf(t,e){if(t.length===0||df(t)||t.includes("\\")||je.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(t)||t.split("/").includes(".."))throw new Error(`${e} must be a portable project-relative path`);let i=je.posix.normalize(t);if(i!==t||i===".."||i.startsWith("../"))throw new Error(`${e} must be a normalized project-relative path`);return i}function qa(t,e){return jy("sha256").update(`${t}
${e}`).digest("hex")}async function cf(t,e){let i=await gn.realpath(e),r=await gn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Wa==="win32"?je.normalize(i).toLowerCase():i;return qa(t,`${n}
${r.dev}
${r.ino}
${r.birthtimeMs}`)}async function lf(t,e){let i=await gn.realpath(e),r=await gn.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=Wa==="win32"?je.normalize(i).toLowerCase():i;return qa(t,n)}function $y(t){if(typeof t!="string")throw new Error("Native workspace capturedAt is invalid");let e=new Date(t);if(!Number.isFinite(e.getTime())||e.toISOString()!==t)throw new Error("Native workspace capturedAt is invalid");return t}function uf(t,e){if(t===null)return null;if(typeof t!="string"||t.length===0||t.trim()!==t||df(t))throw new Error(`${e} must be a non-empty branch name or null`);return t}function mf(t){if(!new Set(["current","branch","worktree"]).has(t.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(uf(t.changeBranch,"Native workspace change branch"),uf(t.targetBranch,"Native workspace target branch"),(t.isolation==="branch"||t.isolation==="worktree")&&(t.changeBranch===null||t.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function wn(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Native workspace identity must be an object");let e=t,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(e).filter(a=>!i.has(a));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.join(", ")}`);if(e.schema!=="comet.native.workspace.v2"&&e.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(e.capturedRevision)||e.capturedRevision<1||typeof e.nativeRootRef!="string"||!Ti.test(String(e.projectRootId))||!Ti.test(String(e.nativeRootId)))throw new Error("Native workspace identity is invalid");$y(e.capturedAt),hf(e.nativeRootRef,"Native workspace root ref");let n=e.projectRootPathId!==void 0,o=e.nativeRootPathId!==void 0;if(n!==o)throw new Error("Native workspace path identities must be provided together");if(n&&!Ti.test(String(e.projectRootPathId))||o&&!Ti.test(String(e.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(e.sessionHash!==void 0&&!Ti.test(String(e.sessionHash)))throw new Error("Native workspace session hash is invalid");if(e.schema==="comet.native.workspace.v2"){if(e.isolation!==void 0||e.changeBranch!==void 0||e.targetBranch!==void 0||e.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof e.isolation!="string"||e.changeBranch===void 0||e.targetBranch===void 0||e.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(mf(e),e.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(e.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function Dy(t,e){return je.join(t.changesDir,e,"runtime","workspace.json")}function By(t,e){let i=ff(t.nativeRoot,Dy(t,e));if(!i||i===".")throw new Error("Native workspace file escaped its root");return hf(i,"Native workspace file ref")}async function My(t,e){try{let i=await sn({root:t.nativeRoot,ref:By(t,e),maxBytes:Ly});return JSON.parse(i.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Fy(t){if(!Number.isSafeInteger(t.revision)||t.revision<1)throw new Error("Native workspace revision must be a positive integer");let e=ff(t.paths.projectRoot,t.paths.nativeRoot);if(!e)throw new Error("Native root is outside the project root");let[i,r,n,o]=await Promise.all([cf("comet.native.workspace-project-root.v2",t.paths.projectRoot),cf("comet.native.workspace-native-root.v2",t.paths.nativeRoot),lf("comet.native.workspace-project-root-path.v2",t.paths.projectRoot),lf("comet.native.workspace-native-root-path.v2",t.paths.nativeRoot)]),a=(t.now??new Date).toISOString();if(t.finish&&!t.binding)throw new Error("Native workspace finish requires a workspace binding");t.binding&&mf(t.binding);let s={capturedAt:a,capturedRevision:t.revision,nativeRootRef:e,projectRootId:i,nativeRootId:r,projectRootPathId:n,nativeRootPathId:o,...t.sessionId?{sessionHash:qa("comet.native.workspace-session.v2",`${i}
${r}
${t.sessionId}`)}:{}},c=t.binding?{schema:"comet.native.workspace.v3",...s,...t.binding,finish:t.finish??null}:{schema:"comet.native.workspace.v2",...s};return wn(c),c}async function pf(t,e){let i=await My(t,e);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(wn(i),i)}async function gf(t){wn(t.identity);let e=await Fy({paths:t.paths,name:"workspace-advisory",revision:t.identity.capturedRevision}),i=[],r=[];return e.nativeRootRef!==t.identity.nativeRootRef&&i.push("native-root-ref"),t.identity.projectRootPathId&&t.identity.nativeRootPathId?(e.projectRootPathId!==t.identity.projectRootPathId&&i.push("project-root-path"),e.nativeRootPathId!==t.identity.nativeRootPathId&&i.push("native-root-path")):(e.projectRootId!==t.identity.projectRootId&&i.push("project-root-legacy-identity"),e.nativeRootId!==t.identity.nativeRootId&&i.push("native-root-legacy-identity")),Wa==="win32"&&i.length>0&&i.every(o=>o==="project-root-legacy-identity"||o==="native-root-legacy-identity")?r.push("workspace-inspection-unavailable"):i.length>0&&r.push("workspace-root-changed"),{state:r.length===0?"aligned":r.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:r,driftComponents:i}}async function wf(t){if(wn(t.identity),t.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await gf(t)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let i=af(t.paths.projectRoot);return t.identity.changeBranch===null?i.isGitWorktree?{state:"drifted",code:"workspace-branch-changed",message:"Native change was created outside Git but is now being accessed inside Git"}:{state:"aligned",code:null,message:null}:i.isGitWorktree?i.currentBranch!==t.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${t.identity.changeBranch}, but the current branch is ${i.currentBranch??"detached HEAD"}`}:t.identity.isolation==="worktree"&&!i.isSecondaryWorktree?{state:"drifted",code:"workspace-kind-changed",message:"Native change is bound to a linked Git worktree"}:{state:"aligned",code:null,message:null}:{state:"drifted",code:"workspace-vcs-unavailable",message:"Native change requires its bound Git working directory"}}async function vf(t,e){let i=await pf(t,e);if(i===null)return null;let r=await wf({paths:t,identity:i});if(r.state==="drifted")throw new Error(`${r.code}: ${r.message}`);return i}var Ye="comet.native.v3",Xe="comet.native.v2",Qe="comet.native.v1";var yf=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],qy=new Set(yf),bf=new Set([...yf,"minimum_runtime_version","revision"]),Hy=new Set([...bf,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]),Gy=new Set(["capability","operation","source","base_hash"]),zy=new Set(["shape","build","verify","archive"]),Vy=new Set(["implicit","confirmed"]),Ky=new Set(["pending","pass","fail"]),Ct="comet-state.yaml",Ga=/^[a-f0-9]{64}$/u,Nf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u,Jy=/^runtime\/evidence\/(scopes|allowances|verifications)\/([a-f0-9]{64})\.json$/u,vn=class extends Error{constructor(i,r){super(`Native change ${i} uses ${r}; run comet native doctor ${i} --repair before mutating it`);this.change=i;this.schema=r;this.name="NativeSchemaMigrationRequiredError"}change;schema;code="native-schema-migration-required"},tt=class extends Error{constructor(i,r){super(i!==Ye||r===null?`Unsupported Native change schema ${i} for runtime protocol ${3}`:`Native change ${i} requires runtime protocol ${r}; current protocol is ${3}`);this.schema=i;this.minimumRuntimeVersion=r;this.name="NativeRuntimeCompatibilityError"}schema;minimumRuntimeVersion;code="native-runtime-incompatible"};var tx=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
`);function Ii(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`${e} must be a mapping`);return t}function kf(t,e,i){let r=Object.keys(t).filter(n=>!e.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function yn(t){if(!Nf.test(t))throw new Error(`Invalid Native change name: ${t}`)}function Uy(t){if(!Nf.test(t))throw new Error(`Invalid Native capability id: ${t}`)}function Sf(t,e){if(t.length===0||et.isAbsolute(t)||/^(?:[A-Za-z]:|~|[\\/])/u.test(t)||t.split(/[\\/]/u).includes(".."))throw new Error(`${e} must stay inside the Native change`)}function Yy(t,e){let i=Ii(t,`spec_changes[${e}]`);if(kf(i,Gy,`spec_changes[${e}]`),typeof i.capability!="string")throw new Error("spec change capability is required");if(Uy(i.capability),i.operation!=="create"&&i.operation!=="replace"&&i.operation!=="remove")throw new Error(`Invalid spec operation for ${i.capability}`);let r=i.source,n=i.base_hash;if(r!==void 0&&typeof r!="string")throw new Error(`Spec source for ${i.capability} must be a string`);if(typeof r=="string"&&Sf(r,`Spec source for ${i.capability}`),i.operation==="create"){if(!r)throw new Error(`Create spec ${i.capability} requires source`);if(n!==null)throw new Error(`Create spec ${i.capability} requires null base_hash`)}else if(i.operation==="replace"){if(!r)throw new Error(`Replace spec ${i.capability} requires source`);if(typeof n!="string"||!Ga.test(n))throw new Error(`Replace spec ${i.capability} requires a SHA-256 base_hash`)}else{if(r!==void 0)throw new Error(`Remove spec ${i.capability} forbids source`);if(typeof n!="string"||!Ga.test(n))throw new Error(`Remove spec ${i.capability} requires a SHA-256 base_hash`)}return{capability:i.capability,operation:i.operation,...typeof r=="string"?{source:r}:{},base_hash:n}}function Xy(t){return/^\d{4}-\d{2}-\d{2}$/u.test(t)?new Date(`${t}T00:00:00.000Z`).toISOString().slice(0,10)===t:!1}function Va(t,e){if(kf(t,e,Ct),typeof t.name!="string")throw new Error("Native change name is required");if(yn(t.name),t.language!=="en"&&t.language!=="zh-CN")throw new Error("Native change language must be en or zh-CN");if(typeof t.phase!="string"||!zy.has(t.phase))throw new Error("Native change phase is invalid");if(t.brief!=="brief.md")throw new Error("Native change brief must be brief.md");if(t.approval!==null&&!Vy.has(t.approval))throw new Error("Native change approval is invalid");if(!Array.isArray(t.spec_changes))throw new Error("Native spec_changes must be an array");let i=t.spec_changes.map(Yy),r=i.map(n=>n.capability).filter((n,o,a)=>a.indexOf(n)!==o);if(r.length>0)throw new Error(`Duplicate Native capability operation: ${[...new Set(r)].join(", ")}`);if(typeof t.verification_result!="string"||!Ky.has(t.verification_result))throw new Error("Native verification_result is invalid");if(t.verification_report!==null&&typeof t.verification_report!="string")throw new Error("Native verification_report must be a string or null");if(typeof t.verification_report=="string"&&Sf(t.verification_report,"Native verification_report"),typeof t.archived!="boolean")throw new Error("Native archived must be boolean");if(typeof t.created_at!="string"||!Xy(t.created_at))throw new Error("Native created_at must be a valid YYYY-MM-DD date");if(t.run_id!==null&&(typeof t.run_id!="string"||t.run_id.length===0))throw new Error("Native run_id must be a non-empty string or null");return{name:t.name,language:t.language,phase:t.phase,brief:"brief.md",approval:t.approval,spec_changes:i,verification_result:t.verification_result,verification_report:t.verification_report,archived:t.archived,created_at:t.created_at,run_id:t.run_id}}function Ef(t){let e=Ii(t,Ct);if(e.schema!==Qe)throw new Error(`Expected ${Qe}`);return{schema:Qe,...Va(e,qy)}}function Oi(t,e){if(!Number.isSafeInteger(t)||t<1)throw new Error(`${e} must be a positive integer`);return t}function Ha(t,e,i){if(t===null)return null;let r=typeof t=="string"?Jy.exec(t):null;if(!r||r[1]!==i)throw new Error(`${e} must be null or runtime/evidence/${i}/<sha256>.json relative to the Native change`);return t}function Qy(t){if(t==null)return null;if(typeof t!="string"||!Ga.test(t))throw new Error("Native approved_contract_hash must be null or a SHA-256 hash");return t}function Zy(t){if(t===void 0)return"legacy-v1";if(t!=="legacy-v1")throw new Error("Native verification_protocol must be legacy-v1");return t}function Cf(t){let e=Ii(t,Ct);if(e.schema!==Xe)throw new Error(`Expected ${Xe}`);if(Oi(e.minimum_runtime_version,"Native v2 minimum_runtime_version")!==2)throw new Error(`Native ${Xe} minimum_runtime_version must be 2`);return{schema:Xe,minimum_runtime_version:2,revision:Oi(e.revision,"Native v2 revision"),...Va(e,bf)}}function eb(t){let e=Ii(t,Ct);if(e.schema!==Ye){if(e.schema===Qe||e.schema===Xe){let a=e.schema===Qe?Ef(e):Cf(e);throw new vn(a.name,a.schema)}throw new tt(typeof e.schema=="string"?e.schema:"(missing)",typeof e.minimum_runtime_version=="number"?e.minimum_runtime_version:null)}let i=Oi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)throw new tt(e.schema,i);if(i!==3)throw new Error(`Native ${e.schema} minimum_runtime_version must be ${3}`);let r=Oi(e.revision,"Native revision"),n=Va(e,Hy),o=Qy(e.approved_contract_hash);if(n.approval===null&&o!==null)throw new Error("Native approved_contract_hash requires an approval");return{schema:Ye,minimum_runtime_version:3,revision:r,verification_protocol:Zy(e.verification_protocol),...n,approved_contract_hash:o,implementation_scope:Ha(e.implementation_scope,"Native implementation_scope","scopes"),verification_evidence:Ha(e.verification_evidence,"Native verification_evidence","verifications"),partial_allowance:Ha(e.partial_allowance,"Native partial_allowance","allowances")}}function tb(t){let e=Ii(t,Ct);if(e.schema===Qe){let n=Ef(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:1,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(e.schema===Xe){let n=Cf(e);return{status:"migration-required",schema:n.schema,minimumRuntimeVersion:n.minimum_runtime_version,state:n,message:`Native change ${n.name} requires migration to ${Ye}`}}if(e.schema!==Ye){let n=typeof e.minimum_runtime_version=="number"&&Number.isSafeInteger(e.minimum_runtime_version)?e.minimum_runtime_version:null;return{status:"runtime-incompatible",schema:typeof e.schema=="string"?e.schema:"(missing)",minimumRuntimeVersion:n,state:null,message:new tt(typeof e.schema=="string"?e.schema:"(missing)",n).message}}let i=Oi(e.minimum_runtime_version,"Native minimum_runtime_version");if(i>3)return{status:"runtime-incompatible",schema:e.schema,minimumRuntimeVersion:i,state:null,message:new tt(e.schema,i).message};let r=eb(e);return{status:"current",schema:r.schema,minimumRuntimeVersion:r.minimum_runtime_version,state:r}}function Pf(t,e){yn(e);let i=et.join(t.changesDir,e);if(!vt(t.changesDir,i))throw new Error("Native change path escaped");return i}async function ib(t,e){let i=et.join(Pf(t,e),"runtime","schema-migration.json");await pe(t.nativeRoot,i);try{return await Wy.lstat(i),!0}catch(r){if(r.code==="ENOENT")return!1;throw r}}var rb=256*1024;async function nb(t,e=et.dirname(t)){let i=et.relative(e,t).split(et.sep).join("/"),r=await sn({root:e,ref:i,maxBytes:rb}),n=(0,za.parseDocument)(r.text,{uniqueKeys:!0});if(n.errors.length>0)throw new Error(`Invalid Native change file ${t}: ${n.errors[0].message}`);return n.toJS()}async function ob(t,e){let i=et.join(Pf(t,e),Ct);await pe(t.nativeRoot,i);let r=tb(await nb(i,t.nativeRoot));if(r.state&&r.state.name!==e)throw new Error(`Native change directory/name mismatch: ${e}`);return await ib(t,e)?{status:"migration-required",schema:r.schema,minimumRuntimeVersion:r.minimumRuntimeVersion,state:r.state,message:`Native schema migration is incomplete for ${e}; run doctor --repair`}:(r.status==="current"&&r.state&&await ab(t,r.state),r)}async function ab(t,e){if(await of(t,e.name)!==null&&e.verification_protocol!=="legacy-v1")throw new Error(`Native verification protocol is unsupported: ${e.verification_protocol}`)}async function bn(t,e){let i=await ob(t,e);if(i.status==="migration-required")throw new vn(e,i.schema);if(i.status==="runtime-incompatible"||!i.state)throw new tt(i.schema,i.minimumRuntimeVersion);return await vf(t,e),i.state}var sx=16*1024;async function sb(t){let e=await Nt(t.projectRoot);return e.status==="missing"||e.selection.workflow!=="native"?null:(yn(e.selection.change),e.selection)}async function xf(t){let e=await sb(t);return e?(await bn(t,e.change),e.change):null}function Nn(t,e){let i=Pt.relative(t,e);return i===""||!i.startsWith("..")&&!Pt.isAbsolute(i)}function lb(t,e,i){return i.targets.length>0&&i.targets.every(r=>{let n=Pt.resolve(t,r);return Nn(t,n)?Pt.relative(t,n).replaceAll("\\","/")===".comet/config.yaml"||Nn(e,n):!0})}async function ub(t){let e=await ln(t);if(!e||!(e.workflows??[e.default_workflow]).includes("native"))return null;let i=await la(t,e.native.artifact_root),r;try{r=await cb.readdir(i.changesDir,{withFileTypes:!0})}catch(o){if(o.code==="ENOENT")return{paths:i,changes:[]};throw o}let n=[];for(let o of r.sort((a,s)=>a.name.localeCompare(s.name))){if(!o.isDirectory()||o.isSymbolicLink())continue;let a=await bn(i,o.name);a.archived||n.push(a)}return{paths:i,changes:n}}var Rf=K("nativeActiveContext",t=>ub(t));async function _f(t){return((await Rf(t))?.changes??[]).map(i=>({workflow:"native",name:i.name,phase:i.phase}))}async function Af(t,e,i){let r=await Rf(t);if(!r)return{allowed:!0,reason:"Native workflow is not enabled"};if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(r.changes.length===0)return{allowed:!0,reason:lb(t,r.paths.nativeRoot,e)?"Native control artifact write":"No Native changes exist"};let n;if(i){if(n=r.changes.find(s=>s.name===i),!n)return{allowed:!1,reason:`Selected Native change ${i} is missing or archived; resume /comet-native before retrying`,workflow:"native",change:i}}else if(r.changes.length===1)n=r.changes[0];else{let s=await xf(r.paths);if(n=r.changes.find(c=>c.name===s),!n)return{allowed:!1,reason:"Multiple Native changes are active; select the change to resume before writing code",workflow:"native"}}if(n.phase==="build")return{allowed:!0,reason:"Native change is in Build",workflow:"native",phase:n.phase,change:n.name};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target was not attributed to the guarded project",workflow:"native",phase:n.phase,change:n.name};let o=!1,a=!1;for(let s of e.targets){let c=Pt.resolve(t,s);if(!Nn(t,c)){a=!0;continue}if(Pt.relative(t,c).replaceAll("\\","/")===".comet/config.yaml"||Nn(r.paths.nativeRoot,c)){o=!0;continue}return{allowed:!1,reason:`Native change ${n.name} is in ${n.phase}; implementation writes are only allowed in build. Resume /comet-native to continue safely`,workflow:"native",phase:n.phase,change:n.name}}return{allowed:!0,reason:o?"Native control artifact write":a?"Write target is outside the guarded project":"No guarded write target was provided",workflow:"native",phase:n.phase,change:n.name}}He();var Tf=K("readWorkflowProjectConfig",t=>da(t)),Nx=K("discoverNativeProject",t=>li(t));var fb=K("readCometCurrentSelection",t=>Nt(t)),jf={listNative:_f,listClassic:Wu,inspectNative:Af,inspectClassic:Vu};function db(t){return t?t.workflows??[t.default_workflow]:["classic"]}async function Of(t,e,i,r,n={}){let o=async()=>{if(!e.includes("classic"))return[];if(r?.workflow==="classic")return r.candidates;try{return await i.listClassic(t)}catch(c){if(n.tolerateUnavailableClassic&&c instanceof ze)return[];throw c}},[a,s]=await Promise.all([e.includes("native")?r?.workflow==="native"?r.candidates:i.listNative(t):[],o()]);return[...a,...s]}function If(t,e){return t.length===0?{status:"none",staleSelection:e}:t.length===1?{status:"inferred",owner:t[0],staleSelection:e}:{status:"ambiguous",candidates:t,staleSelection:e}}async function hb(t,e=jf){let i=await Tf(t),r=db(i),n;try{n=await fb(t)}catch(o){return{status:"stale",code:"selection-unreadable",reason:o instanceof Error?o.message:String(o)}}if(n.status==="selected"){let o=n.selection;if(!r.includes(o.workflow))return{status:"stale",code:"workflow-disabled",reason:`selected workflow '${o.workflow}' is not enabled for this project`};let a;try{a=o.workflow==="native"?await e.listNative(t):await e.listClassic(t)}catch(c){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${c instanceof Error?c.message:String(c)}`}}let s=a.find(c=>c.name===o.change);if(!s){let c={code:"target-missing",reason:`selected ${o.workflow} change '${o.change}' is missing or archived`};try{let l=await Of(t,r,e,{workflow:o.workflow,candidates:a});return If(l,c)}catch(l){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${l instanceof Error?l.message:String(l)}`}}}if(o.workflow==="classic"){let c=await nn(t);if(c.status!=="selected")return{status:"stale",code:"classic-selection-invalid",reason:c.status==="stale"?c.reason:`selected Classic change '${o.change}' is no longer active`}}return{status:"owned",owner:s}}try{let o=await Of(t,r,e,void 0,{tolerateUnavailableClassic:!0});return If(o)}catch(o){return{status:"stale",code:"change-state-unreadable",reason:`cannot safely enumerate active Comet changes: ${o instanceof Error?o.message:String(o)}`}}}async function Lf(t,e,i=jf){if(e.intent==="non-write")return{allowed:!0,reason:"Hook event is not a write"};if(e.intent==="unknown"||e.targets.length===0)return{allowed:!0,reason:"Hook write target is outside Comet attribution"};let r;try{let n=await(i.scopeTargets??Kr)(t,e.targets);if(n.projectTargets.length===0)return{allowed:!0,reason:"Write targets are outside the guarded project"};r={...e,targets:n.projectTargets}}catch(n){return{allowed:!1,reason:["Comet Hook Router scope could not be determined safely.",`Reason: ${n instanceof Error?n.message:String(n)}`,"Next: verify that the project root is accessible, then retry the write."].join(" ")}}try{let n=await hb(t,i);if(n.status==="none")return{allowed:!0,reason:"No active Comet change"};if(n.status==="stale")return{allowed:!1,reason:`${n.reason}. Resume /comet-native or /comet-classic and select the current change before retrying`};if(n.status==="ambiguous")return{allowed:!1,reason:`Multiple active Comet changes require one current selection: ${n.candidates.map(a=>`${a.workflow}:${a.name}`).join(", ")}`};let o=n.owner;return o.workflow==="native"?i.inspectNative(t,r,o.name):i.inspectClassic(t,o.name,r)}catch(n){return{allowed:!1,reason:`Comet Hook Router failed closed: ${n instanceof Error?n.message:String(n)}`}}}import{promises as mb}from"fs";import Q from"path";function pb(t,e){let i=Q.resolve(t),r=Q.resolve(e);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function gb(t,e){let i=Q.relative(t,e);return i===""||i!==".."&&!i.startsWith(`..${Q.sep}`)&&!Q.isAbsolute(i)}function $f(t,e){return[...e].sort((i,r)=>r.length-i.length).find(i=>gb(i,t))??null}async function wb(t){for(let e of[".git",Q.join(".comet","config.yaml")])try{await mb.lstat(Q.join(t,e))}catch(i){throw i.code!=="ENOENT"?i:new Error(`linked worktree ${t} is not initialized for Comet: missing ${e.replaceAll("\\","/")}`,{cause:i})}}async function Df(t,e){let i=Q.resolve(t),r=sf(i);if(r.length<2||e.targets.length===0)return i;let o=(e.cwd?$f(Q.resolve(e.cwd),r):null)??i,a=new Map;for(let c of e.targets){let l=Q.isAbsolute(c)?Q.resolve(c):Q.resolve(o,c),f=$f(l,r);if(!f)continue;let u=process.platform==="win32"?f.toLowerCase():f;a.set(u,f)}if(a.size===0)return i;if(a.size>1)throw new Error("one Hook request cannot write across multiple Git worktrees");let[s]=a.values();return pb(s,i)||await wb(s),s}var vb="Usage: comet-hook-router --platform <platform-id> [--project-root <project-root>]";function yb(t){let e,i;for(let r=0;r<t.length;r++){let n=t[r];if(n==="--platform"){e=t[++r];continue}if(n==="--project-root"){i=t[++r];continue}throw new Error(`Unknown argument: ${n}`)}if(!e||e.startsWith("--"))throw new Error("--platform is required");if(!va.has(e))throw new Error(`unsupported Hook platform: ${e}`);if(i?.startsWith("--"))throw new Error("--project-root requires a value");return{platformId:e,...i?{projectRoot:Mf.resolve(i)}:{}}}async function bb(t,e){if(t.projectRoot)return e?Df(t.projectRoot,e):t.projectRoot;let i=await li(process.cwd());for(let o of[[".comet","config.yaml"],[".git"]])try{return await Bf.lstat(Mf.join(i,...o)),i}catch(a){if(a.code!=="ENOENT")throw a}let r=await Ul(process.cwd()),n=await ye(r);try{return await Bf.lstat(n.changesDir),r}catch(o){if(o.code!=="ENOENT")throw o}return null}async function Nb(t){let e;try{e=yb(t)}catch(n){return process.stderr.write(`${n instanceof Error?n.message:String(n)}
${vb}
`),64}let i;try{let n=ba(),o=await bb(e,n);i=o?await iu(()=>Lf(o,n)):{allowed:!0,reason:"No Comet project discovered"}}catch(n){i={allowed:!1,reason:`Comet Hook Router failed closed during project discovery: ${n instanceof Error?n.message:String(n)}`}}let r=tu(e.platformId,i);return r.stdout&&process.stdout.write(r.stdout),r.stderr&&process.stderr.write(r.stderr),r.exitCode}process.exitCode=await Nb(process.argv.slice(2));export{bb as projectRootFrom,Nb as runCometHookRouter};