reviewme 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- import{createRequire as qo}from"node:module";var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ot=qo(import.meta.url);var C=S(function(cl){var Cs=Symbol.for("yaml.alias"),Sr=Symbol.for("yaml.document"),wt=Symbol.for("yaml.map"),Er=Symbol.for("yaml.pair"),Ns=Symbol.for("yaml.scalar"),bt=Symbol.for("yaml.seq"),z=Symbol.for("yaml.node.type"),sl=(e)=>!!e&&typeof e==="object"&&e[z]===Cs,nl=(e)=>!!e&&typeof e==="object"&&e[z]===Sr,rl=(e)=>!!e&&typeof e==="object"&&e[z]===wt,il=(e)=>!!e&&typeof e==="object"&&e[z]===Er,vr=(e)=>!!e&&typeof e==="object"&&e[z]===Ns,ol=(e)=>!!e&&typeof e==="object"&&e[z]===bt;function Tr(e){if(e&&typeof e==="object")switch(e[z]){case wt:case bt:return!0}return!1}function al(e){if(e&&typeof e==="object")switch(e[z]){case Cs:case wt:case Ns:case bt:return!0}return!1}var ll=(e)=>(vr(e)||Tr(e))&&!!e.anchor;cl.ALIAS=Cs;cl.DOC=Sr;cl.MAP=wt;cl.NODE_TYPE=z;cl.PAIR=Er;cl.SCALAR=Ns;cl.SEQ=bt;cl.hasAnchor=ll;cl.isAlias=sl;cl.isCollection=Tr;cl.isDocument=nl;cl.isMap=rl;cl.isNode=al;cl.isPair=il;cl.isScalar=vr;cl.isSeq=ol});var qe=S(function(Rl){var P=C(),q=Symbol("break visit"),Ar=Symbol("skip children"),Y=Symbol("remove node");function _t(e,t){let s=Rr(t);if(P.isDocument(e)){if(Ae(null,e.contents,s,Object.freeze([e]))===Y)e.contents=null}else Ae(null,e,s,Object.freeze([]))}_t.BREAK=q;_t.SKIP=Ar;_t.REMOVE=Y;function Ae(e,t,s,n){let r=Cr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return Nr(e,n,r),Ae(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=Ae(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===Y)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=Ae("key",t.key,s,n);if(i===q)return q;else if(i===Y)t.key=null;let o=Ae("value",t.value,s,n);if(o===q)return q;else if(o===Y)t.value=null}}return r}async function St(e,t){let s=Rr(t);if(P.isDocument(e)){if(await Re(null,e.contents,s,Object.freeze([e]))===Y)e.contents=null}else await Re(null,e,s,Object.freeze([]))}St.BREAK=q;St.SKIP=Ar;St.REMOVE=Y;async function Re(e,t,s,n){let r=await Cr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return Nr(e,n,r),Re(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=await Re(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===Y)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=await Re("key",t.key,s,n);if(i===q)return q;else if(i===Y)t.key=null;let o=await Re("value",t.value,s,n);if(o===q)return q;else if(o===Y)t.value=null}}return r}function Rr(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Cr(e,t,s,n){if(typeof s==="function")return s(e,t,n);if(P.isMap(t))return s.Map?.(e,t,n);if(P.isSeq(t))return s.Seq?.(e,t,n);if(P.isPair(t))return s.Pair?.(e,t,n);if(P.isScalar(t))return s.Scalar?.(e,t,n);if(P.isAlias(t))return s.Alias?.(e,t,n);return}function Nr(e,t,s){let n=t[t.length-1];if(P.isCollection(n))n.items[e]=s;else if(P.isPair(n))if(e==="key")n.key=s;else n.value=s;else if(P.isDocument(n))n.contents=s;else{let r=P.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}Rl.visit=_t;Rl.visitAsync=St});var xs=S(function(kl){var xr=C(),xl=qe(),Ol={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ll=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Ol[t]);class F{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},F.defaultYaml,e),this.tags=Object.assign({},F.defaultTags,t)}clone(){let e=new F(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new F(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:F.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},F.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:F.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},F.defaultTags),this.atNextDocument=!1;let s=e.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(s.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),s.length<2)return!1}let[r,i]=s;return this.tags[r]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let i=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,i),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,s,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let r=this.tags[s];if(r)try{return r+decodeURIComponent(n)}catch(i){return t(String(i)),null}if(s==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+Ll(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),n;if(e&&s.length>0&&xr.isNode(e.contents)){let r={};xl.visit(e.contents,(i,o)=>{if(xr.isNode(o)&&o.tag)r[o.tag]=!0}),n=Object.keys(r)}else n=[];for(let[r,i]of s){if(r==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||n.some((o)=>o.startsWith(i)))t.push(`%TAG ${r} ${i}`)}return t.join(`
2
- `)}}F.defaultYaml={explicit:!1,version:"1.2"};F.defaultTags={"!!":"tag:yaml.org,2002:"};kl.Directives=F});var Et=S(function(ql){var Or=C(),Pl=qe();function Ml(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let s=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(s)}return!0}function Lr(e){let t=new Set;return Pl.visit(e,{Value(s,n){if(n.anchor)t.add(n.anchor)}}),t}function kr(e,t){for(let s=1;;++s){let n=`${e}${s}`;if(!t.has(n))return n}}function Dl(e,t){let s=[],n=new Map,r=null;return{onAnchor:(i)=>{s.push(i),r??(r=Lr(e));let o=kr(t,r);return r.add(o),o},setAnchors:()=>{for(let i of s){let o=n.get(i);if(typeof o==="object"&&o.anchor&&(Or.isScalar(o.node)||Or.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}ql.anchorIsValid=Ml;ql.anchorNames=Lr;ql.createNodeAnchors=Dl;ql.findNewAnchor=kr});var Os=S(function(jl){function Fe(e,t,s,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let r=0,i=n.length;r<i;++r){let o=n[r],a=Fe(e,n,String(r),o);if(a===void 0)delete n[r];else if(a!==o)n[r]=a}else if(n instanceof Map)for(let r of Array.from(n.keys())){let i=n.get(r),o=Fe(e,n,r,i);if(o===void 0)n.delete(r);else if(o!==i)n.set(r,o)}else if(n instanceof Set)for(let r of Array.from(n)){let i=Fe(e,n,r,r);if(i===void 0)n.delete(r);else if(i!==r)n.delete(r),n.add(i)}else for(let[r,i]of Object.entries(n)){let o=Fe(e,n,r,i);if(o===void 0)delete n[r];else if(o!==i)n[r]=o}return e.call(t,s,n)}jl.applyReviver=Fe});var ee=S(function(Hl){var Wl=C();function Ir(e,t,s){if(Array.isArray(e))return e.map((n,r)=>Ir(n,String(r),s));if(e&&typeof e.toJSON==="function"){if(!s||!Wl.hasAnchor(e))return e.toJSON(t,s);let n={aliasCount:0,count:1,res:void 0};s.anchors.set(e,n),s.onCreate=(i)=>{n.res=i,delete s.onCreate};let r=e.toJSON(t,s);if(s.onCreate)s.onCreate(r);return r}if(typeof e==="bigint"&&!s?.keep)return Number(e);return e}Hl.toJS=Ir});var vt=S(function(Xl){var Jl=Os(),Pr=C(),Vl=ee();class Mr{constructor(e){Object.defineProperty(this,Pr.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:n,reviver:r}={}){if(!Pr.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s==="number"?s:100},o=Vl.toJS(this,"",i);if(typeof n==="function")for(let{count:a,res:l}of i.anchors.values())n(l,a);return typeof r==="function"?Jl.applyReviver(r,{"":o},"",o):o}}Xl.NodeBase=Mr});var $e=S(function(tc){var zl=Et(),Ql=qe(),Ce=C(),Zl=vt(),ec=ee();class Dr extends Zl.NodeBase{constructor(e){super(Ce.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let s;if(t?.aliasResolveCache)s=t.aliasResolveCache;else if(s=[],Ql.visit(e,{Node:(r,i)=>{if(Ce.isAlias(i)||Ce.hasAnchor(i))s.push(i)}}),t)t.aliasResolveCache=s;let n=void 0;for(let r of s){if(r===this)break;if(r.anchor===this.source)n=r}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:s,doc:n,maxAliasCount:r}=t,i=this.resolve(n,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=s.get(i);if(!o)ec.toJS(i,null,t),o=s.get(i);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=Tt(n,i,s);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,s){let n=`*${this.source}`;if(e){if(zl.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(r)}if(e.implicitKey)return`${n} `}return n}}function Tt(e,t,s){if(Ce.isAlias(t)){let n=t.resolve(e),r=s&&n&&s.get(n);return r?r.count*r.aliasCount:0}else if(Ce.isCollection(t)){let n=0;for(let r of t.items){let i=Tt(e,r,s);if(i>n)n=i}return n}else if(Ce.isPair(t)){let n=Tt(e,t.key,s),r=Tt(e,t.value,s);return Math.max(n,r)}return 1}tc.Alias=Dr});var k=S(function(ac){var nc=C(),rc=vt(),ic=ee(),oc=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class he extends rc.NodeBase{constructor(e){super(nc.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:ic.toJS(this.value,e,t)}toString(){return String(this.value)}}he.BLOCK_FOLDED="BLOCK_FOLDED";he.BLOCK_LITERAL="BLOCK_LITERAL";he.PLAIN="PLAIN";he.QUOTE_DOUBLE="QUOTE_DOUBLE";he.QUOTE_SINGLE="QUOTE_SINGLE";ac.Scalar=he;ac.isScalarValue=oc});var Ue=S(function(pc){var dc=$e(),pe=C(),qr=k(),uc="tag:yaml.org,2002:";function fc(e,t,s){if(t){let n=s.filter((i)=>i.tag===t),r=n.find((i)=>!i.format)??n[0];if(!r)throw Error(`Tag ${t} not found`);return r}return s.find((n)=>n.identify?.(e)&&!n.format)}function hc(e,t,s){if(pe.isDocument(e))e=e.contents;if(pe.isNode(e))return e;if(pe.isPair(e)){let d=s.schema[pe.MAP].createNode?.(s.schema,null,s);return d.items.push(e),d}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:r,onTagObj:i,schema:o,sourceObjects:a}=s,l=void 0;if(n&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new dc.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=uc+t.slice(2);let c=fc(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new qr.Scalar(e);if(l)l.node=d;return d}c=e instanceof Map?o[pe.MAP]:(Symbol.iterator in Object(e))?o[pe.SEQ]:o[pe.MAP]}if(i)i(c),delete s.onTagObj;let p=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(s.schema,e,s):new qr.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}pc.createNode=hc});var At=S(function(wc){var gc=Ue(),J=C(),yc=vt();function Ls(e,t,s){let n=s;for(let r=t.length-1;r>=0;--r){let i=t[r];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return gc.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Fr=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class $r extends yc.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((s)=>J.isNode(s)||J.isPair(s)?s.clone(e):s),this.range)t.range=this.range.slice();return t}addIn(e,t){if(Fr(e))this.add(t);else{let[s,...n]=e,r=this.get(s,!0);if(J.isCollection(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let n=this.get(t,!0);if(J.isCollection(n))return n.deleteIn(s);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...n]=e,r=this.get(s,!0);if(n.length===0)return!t&&J.isScalar(r)?r.value:r;else return J.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!J.isPair(t))return!1;let s=t.value;return s==null||e&&J.isScalar(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let n=this.get(t,!0);return J.isCollection(n)?n.hasIn(s):!1}setIn(e,t){let[s,...n]=e;if(n.length===0)this.set(s,t);else{let r=this.get(s,!0);if(J.isCollection(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}}wc.Collection=$r;wc.collectionFromPath=Ls;wc.isEmptyPath=Fr});var Be=S(function(Tc){var Ec=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function ks(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var vc=(e,t,s)=>e.endsWith(`
1
+ import{createRequire as $o}from"node:module";var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ot=$o(import.meta.url);var C=S(function(fl){var Cs=Symbol.for("yaml.alias"),vr=Symbol.for("yaml.document"),wt=Symbol.for("yaml.map"),Er=Symbol.for("yaml.pair"),Ns=Symbol.for("yaml.scalar"),bt=Symbol.for("yaml.seq"),z=Symbol.for("yaml.node.type"),il=(e)=>!!e&&typeof e==="object"&&e[z]===Cs,ol=(e)=>!!e&&typeof e==="object"&&e[z]===vr,al=(e)=>!!e&&typeof e==="object"&&e[z]===wt,ll=(e)=>!!e&&typeof e==="object"&&e[z]===Er,Tr=(e)=>!!e&&typeof e==="object"&&e[z]===Ns,cl=(e)=>!!e&&typeof e==="object"&&e[z]===bt;function Ar(e){if(e&&typeof e==="object")switch(e[z]){case wt:case bt:return!0}return!1}function dl(e){if(e&&typeof e==="object")switch(e[z]){case Cs:case wt:case Ns:case bt:return!0}return!1}var ul=(e)=>(Tr(e)||Ar(e))&&!!e.anchor;fl.ALIAS=Cs;fl.DOC=vr;fl.MAP=wt;fl.NODE_TYPE=z;fl.PAIR=Er;fl.SCALAR=Ns;fl.SEQ=bt;fl.hasAnchor=ul;fl.isAlias=il;fl.isCollection=Ar;fl.isDocument=ol;fl.isMap=al;fl.isNode=dl;fl.isPair=ll;fl.isScalar=Tr;fl.isSeq=cl});var qe=S(function(xl){var P=C(),q=Symbol("break visit"),Rr=Symbol("skip children"),Y=Symbol("remove node");function _t(e,t){let s=Cr(t);if(P.isDocument(e)){if(Ae(null,e.contents,s,Object.freeze([e]))===Y)e.contents=null}else Ae(null,e,s,Object.freeze([]))}_t.BREAK=q;_t.SKIP=Rr;_t.REMOVE=Y;function Ae(e,t,s,n){let r=Nr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return xr(e,n,r),Ae(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=Ae(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===Y)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=Ae("key",t.key,s,n);if(i===q)return q;else if(i===Y)t.key=null;let o=Ae("value",t.value,s,n);if(o===q)return q;else if(o===Y)t.value=null}}return r}async function St(e,t){let s=Cr(t);if(P.isDocument(e)){if(await Re(null,e.contents,s,Object.freeze([e]))===Y)e.contents=null}else await Re(null,e,s,Object.freeze([]))}St.BREAK=q;St.SKIP=Rr;St.REMOVE=Y;async function Re(e,t,s,n){let r=await Nr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return xr(e,n,r),Re(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=await Re(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===Y)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=await Re("key",t.key,s,n);if(i===q)return q;else if(i===Y)t.key=null;let o=await Re("value",t.value,s,n);if(o===q)return q;else if(o===Y)t.value=null}}return r}function Cr(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Nr(e,t,s,n){if(typeof s==="function")return s(e,t,n);if(P.isMap(t))return s.Map?.(e,t,n);if(P.isSeq(t))return s.Seq?.(e,t,n);if(P.isPair(t))return s.Pair?.(e,t,n);if(P.isScalar(t))return s.Scalar?.(e,t,n);if(P.isAlias(t))return s.Alias?.(e,t,n);return}function xr(e,t,s){let n=t[t.length-1];if(P.isCollection(n))n.items[e]=s;else if(P.isPair(n))if(e==="key")n.key=s;else n.value=s;else if(P.isDocument(n))n.contents=s;else{let r=P.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}xl.visit=_t;xl.visitAsync=St});var xs=S(function(Ml){var Or=C(),kl=qe(),Il={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Pl=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Il[t]);class F{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},F.defaultYaml,e),this.tags=Object.assign({},F.defaultTags,t)}clone(){let e=new F(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new F(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:F.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},F.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:F.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},F.defaultTags),this.atNextDocument=!1;let s=e.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(s.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),s.length<2)return!1}let[r,i]=s;return this.tags[r]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let i=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,i),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,s,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let r=this.tags[s];if(r)try{return r+decodeURIComponent(n)}catch(i){return t(String(i)),null}if(s==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+Pl(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),n;if(e&&s.length>0&&Or.isNode(e.contents)){let r={};kl.visit(e.contents,(i,o)=>{if(Or.isNode(o)&&o.tag)r[o.tag]=!0}),n=Object.keys(r)}else n=[];for(let[r,i]of s){if(r==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||n.some((o)=>o.startsWith(i)))t.push(`%TAG ${r} ${i}`)}return t.join(`
2
+ `)}}F.defaultYaml={explicit:!1,version:"1.2"};F.defaultTags={"!!":"tag:yaml.org,2002:"};Ml.Directives=F});var vt=S(function(Ul){var Lr=C(),ql=qe();function Fl(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let s=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(s)}return!0}function kr(e){let t=new Set;return ql.visit(e,{Value(s,n){if(n.anchor)t.add(n.anchor)}}),t}function Ir(e,t){for(let s=1;;++s){let n=`${e}${s}`;if(!t.has(n))return n}}function $l(e,t){let s=[],n=new Map,r=null;return{onAnchor:(i)=>{s.push(i),r??(r=kr(e));let o=Ir(t,r);return r.add(o),o},setAnchors:()=>{for(let i of s){let o=n.get(i);if(typeof o==="object"&&o.anchor&&(Lr.isScalar(o.node)||Lr.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}Ul.anchorIsValid=Fl;Ul.anchorNames=kr;Ul.createNodeAnchors=$l;Ul.findNewAnchor=Ir});var Os=S(function(Hl){function Fe(e,t,s,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let r=0,i=n.length;r<i;++r){let o=n[r],a=Fe(e,n,String(r),o);if(a===void 0)delete n[r];else if(a!==o)n[r]=a}else if(n instanceof Map)for(let r of Array.from(n.keys())){let i=n.get(r),o=Fe(e,n,r,i);if(o===void 0)n.delete(r);else if(o!==i)n.set(r,o)}else if(n instanceof Set)for(let r of Array.from(n)){let i=Fe(e,n,r,r);if(i===void 0)n.delete(r);else if(i!==r)n.delete(r),n.add(i)}else for(let[r,i]of Object.entries(n)){let o=Fe(e,n,r,i);if(o===void 0)delete n[r];else if(o!==i)n[r]=o}return e.call(t,s,n)}Hl.applyReviver=Fe});var ee=S(function(Vl){var Jl=C();function Pr(e,t,s){if(Array.isArray(e))return e.map((n,r)=>Pr(n,String(r),s));if(e&&typeof e.toJSON==="function"){if(!s||!Jl.hasAnchor(e))return e.toJSON(t,s);let n={aliasCount:0,count:1,res:void 0};s.anchors.set(e,n),s.onCreate=(i)=>{n.res=i,delete s.onCreate};let r=e.toJSON(t,s);if(s.onCreate)s.onCreate(r);return r}if(typeof e==="bigint"&&!s?.keep)return Number(e);return e}Vl.toJS=Pr});var Et=S(function(Ql){var Xl=Os(),Mr=C(),zl=ee();class Dr{constructor(e){Object.defineProperty(this,Mr.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:n,reviver:r}={}){if(!Mr.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s==="number"?s:100},o=zl.toJS(this,"",i);if(typeof n==="function")for(let{count:a,res:l}of i.anchors.values())n(l,a);return typeof r==="function"?Xl.applyReviver(r,{"":o},"",o):o}}Ql.NodeBase=Dr});var $e=S(function(rc){var ec=vt(),tc=qe(),Ce=C(),sc=Et(),nc=ee();class qr extends sc.NodeBase{constructor(e){super(Ce.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let s;if(t?.aliasResolveCache)s=t.aliasResolveCache;else if(s=[],tc.visit(e,{Node:(r,i)=>{if(Ce.isAlias(i)||Ce.hasAnchor(i))s.push(i)}}),t)t.aliasResolveCache=s;let n=void 0;for(let r of s){if(r===this)break;if(r.anchor===this.source)n=r}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:s,doc:n,maxAliasCount:r}=t,i=this.resolve(n,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=s.get(i);if(!o)nc.toJS(i,null,t),o=s.get(i);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=Tt(n,i,s);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,s){let n=`*${this.source}`;if(e){if(ec.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(r)}if(e.implicitKey)return`${n} `}return n}}function Tt(e,t,s){if(Ce.isAlias(t)){let n=t.resolve(e),r=s&&n&&s.get(n);return r?r.count*r.aliasCount:0}else if(Ce.isCollection(t)){let n=0;for(let r of t.items){let i=Tt(e,r,s);if(i>n)n=i}return n}else if(Ce.isPair(t)){let n=Tt(e,t.key,s),r=Tt(e,t.value,s);return Math.max(n,r)}return 1}rc.Alias=qr});var k=S(function(dc){var oc=C(),ac=Et(),lc=ee(),cc=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class he extends ac.NodeBase{constructor(e){super(oc.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:lc.toJS(this.value,e,t)}toString(){return String(this.value)}}he.BLOCK_FOLDED="BLOCK_FOLDED";he.BLOCK_LITERAL="BLOCK_LITERAL";he.PLAIN="PLAIN";he.QUOTE_DOUBLE="QUOTE_DOUBLE";he.QUOTE_SINGLE="QUOTE_SINGLE";dc.Scalar=he;dc.isScalarValue=cc});var Ue=S(function(yc){var hc=$e(),pe=C(),Fr=k(),pc="tag:yaml.org,2002:";function mc(e,t,s){if(t){let n=s.filter((i)=>i.tag===t),r=n.find((i)=>!i.format)??n[0];if(!r)throw Error(`Tag ${t} not found`);return r}return s.find((n)=>n.identify?.(e)&&!n.format)}function gc(e,t,s){if(pe.isDocument(e))e=e.contents;if(pe.isNode(e))return e;if(pe.isPair(e)){let d=s.schema[pe.MAP].createNode?.(s.schema,null,s);return d.items.push(e),d}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:r,onTagObj:i,schema:o,sourceObjects:a}=s,l=void 0;if(n&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new hc.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=pc+t.slice(2);let c=mc(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let d=new Fr.Scalar(e);if(l)l.node=d;return d}c=e instanceof Map?o[pe.MAP]:(Symbol.iterator in Object(e))?o[pe.SEQ]:o[pe.MAP]}if(i)i(c),delete s.onTagObj;let p=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(s.schema,e,s):new Fr.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}yc.createNode=gc});var At=S(function(Sc){var bc=Ue(),J=C(),_c=Et();function Ls(e,t,s){let n=s;for(let r=t.length-1;r>=0;--r){let i=t[r];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return bc.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var $r=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Ur extends _c.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((s)=>J.isNode(s)||J.isPair(s)?s.clone(e):s),this.range)t.range=this.range.slice();return t}addIn(e,t){if($r(e))this.add(t);else{let[s,...n]=e,r=this.get(s,!0);if(J.isCollection(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let n=this.get(t,!0);if(J.isCollection(n))return n.deleteIn(s);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...n]=e,r=this.get(s,!0);if(n.length===0)return!t&&J.isScalar(r)?r.value:r;else return J.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!J.isPair(t))return!1;let s=t.value;return s==null||e&&J.isScalar(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let n=this.get(t,!0);return J.isCollection(n)?n.hasIn(s):!1}setIn(e,t){let[s,...n]=e;if(n.length===0)this.set(s,t);else{let r=this.get(s,!0);if(J.isCollection(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}}Sc.Collection=Ur;Sc.collectionFromPath=Ls;Sc.isEmptyPath=$r});var Be=S(function(Cc){var Ac=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function ks(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Rc=(e,t,s)=>e.endsWith(`
3
3
  `)?ks(s,t):s.includes(`
4
4
  `)?`
5
- `+ks(s,t):(e.endsWith(" ")?"":" ")+s;Tc.indentComment=ks;Tc.lineComment=vc;Tc.stringifyComment=Ec});var Br=S(function(xc){function Nc(e,t,s="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;if(r<i)i=0;let l=Math.max(1+i,1+r-t.length);if(e.length<=l)return e;let c=[],p={},d=r-t.length;if(typeof n==="number")if(n>r-Math.max(2,i))c.push(0);else d=r-n;let u=void 0,g=void 0,w=!1,f=-1,y=-1,_=-1;if(s==="block"){if(f=Ur(e,f,t.length),f!==-1)d=f+l}for(let h;h=e[f+=1];){if(s==="quoted"&&h==="\\"){switch(y=f,e[f+1]){case"x":f+=3;break;case"u":f+=5;break;case"U":f+=9;break;default:f+=1}_=f}if(h===`
6
- `){if(s==="block")f=Ur(e,f,t.length);d=f+t.length+l,u=void 0}else{if(h===" "&&g&&g!==" "&&g!==`
5
+ `+ks(s,t):(e.endsWith(" ")?"":" ")+s;Cc.indentComment=ks;Cc.lineComment=Rc;Cc.stringifyComment=Ac});var jr=S(function(kc){function Lc(e,t,s="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;if(r<i)i=0;let l=Math.max(1+i,1+r-t.length);if(e.length<=l)return e;let c=[],p={},d=r-t.length;if(typeof n==="number")if(n>r-Math.max(2,i))c.push(0);else d=r-n;let u=void 0,g=void 0,w=!1,f=-1,y=-1,_=-1;if(s==="block"){if(f=Br(e,f,t.length),f!==-1)d=f+l}for(let h;h=e[f+=1];){if(s==="quoted"&&h==="\\"){switch(y=f,e[f+1]){case"x":f+=3;break;case"u":f+=5;break;case"U":f+=9;break;default:f+=1}_=f}if(h===`
6
+ `){if(s==="block")f=Br(e,f,t.length);d=f+t.length+l,u=void 0}else{if(h===" "&&g&&g!==" "&&g!==`
7
7
  `&&g!=="\t"){let b=e[f+1];if(b&&b!==" "&&b!==`
8
- `&&b!=="\t")u=f}if(f>=d)if(u)c.push(u),d=u+l,u=void 0;else if(s==="quoted"){while(g===" "||g==="\t")g=h,h=e[f+=1],w=!0;let b=f>_+1?f-2:y-1;if(p[b])return e;c.push(b),p[b]=!0,d=b+l,u=void 0}else w=!0}g=h}if(w&&a)a();if(c.length===0)return e;if(o)o();let m=e.slice(0,c[0]);for(let h=0;h<c.length;++h){let b=c[h],E=c[h+1]||e.length;if(b===0)m=`
9
- ${t}${e.slice(0,E)}`;else{if(s==="quoted"&&p[b])m+=`${e[b]}\\`;m+=`
10
- ${t}${e.slice(b+1,E)}`}}return m}function Ur(e,t,s){let n=t,r=t+1,i=e[r];while(i===" "||i==="\t")if(t<r+s)i=e[++t];else{do i=e[++t];while(i&&i!==`
11
- `);n=t,r=t+1,i=e[r]}return n}xc.FOLD_BLOCK="block";xc.FOLD_FLOW="flow";xc.FOLD_QUOTED="quoted";xc.foldFlowLines=Nc});var Ke=S(function(qc){var B=k(),te=Br(),Ct=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Nt=(e)=>/^(%|---|\.\.\.)/m.test(e);function Pc(e,t,s){if(!t||t<0)return!1;let n=t-s,r=e.length;if(r<=n)return!1;for(let i=0,o=0;i<r;++i)if(e[i]===`
8
+ `&&b!=="\t")u=f}if(f>=d)if(u)c.push(u),d=u+l,u=void 0;else if(s==="quoted"){while(g===" "||g==="\t")g=h,h=e[f+=1],w=!0;let b=f>_+1?f-2:y-1;if(p[b])return e;c.push(b),p[b]=!0,d=b+l,u=void 0}else w=!0}g=h}if(w&&a)a();if(c.length===0)return e;if(o)o();let m=e.slice(0,c[0]);for(let h=0;h<c.length;++h){let b=c[h],v=c[h+1]||e.length;if(b===0)m=`
9
+ ${t}${e.slice(0,v)}`;else{if(s==="quoted"&&p[b])m+=`${e[b]}\\`;m+=`
10
+ ${t}${e.slice(b+1,v)}`}}return m}function Br(e,t,s){let n=t,r=t+1,i=e[r];while(i===" "||i==="\t")if(t<r+s)i=e[++t];else{do i=e[++t];while(i&&i!==`
11
+ `);n=t,r=t+1,i=e[r]}return n}kc.FOLD_BLOCK="block";kc.FOLD_FLOW="flow";kc.FOLD_QUOTED="quoted";kc.foldFlowLines=Lc});var Ke=S(function(Uc){var B=k(),te=jr(),Ct=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Nt=(e)=>/^(%|---|\.\.\.)/m.test(e);function qc(e,t,s){if(!t||t<0)return!1;let n=t-s,r=e.length;if(r<=n)return!1;for(let i=0,o=0;i<r;++i)if(e[i]===`
12
12
  `){if(i-o>n)return!0;if(o=i+1,r-o<=n)return!1}return!0}function je(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:n}=t,r=t.options.doubleQuotedMinMultiLineLength,i=t.indent||(Nt(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l]){if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n")o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\";if(c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let p=s.substr(l+2,4);switch(p){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:if(p.substr(0,2)==="00")o+="\\x"+p.substr(2);else o+=s.substr(l,6)}l+=5,a=l+1}break;case"n":if(n||s[l+2]==='"'||s.length<r)l+=1;else{o+=s.slice(a,l)+`
13
13
 
14
14
  `;while(s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"')o+=`
@@ -17,56 +17,56 @@ ${t}${e.slice(b+1,E)}`}}return m}function Ur(e,t,s){let n=t,r=t+1,i=e[r];while(i
17
17
  ${s}`)+"'";return t.implicitKey?n:te.foldFlowLines(n,s,te.FOLD_FLOW,Ct(t,!1))}function Ne(e,t){let{singleQuote:s}=t.options,n;if(s===!1)n=je;else{let r=e.includes('"'),i=e.includes("'");if(r&&!i)n=Is;else if(i&&!r)n=je;else n=s?Is:je}return n(e,t)}var Ps;try{Ps=new RegExp(`(^|(?<!
18
18
  ))
19
19
  +(?!
20
- |$)`,"g")}catch{Ps=/\n+(?!\n|$)/g}function Rt({comment:e,type:t,value:s},n,r,i){let{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(s))return Ne(s,n);let c=n.indent||(n.forceBlockIndent||Nt(s)?" ":""),p=o==="literal"?!0:o==="folded"||t===B.Scalar.BLOCK_FOLDED?!1:t===B.Scalar.BLOCK_LITERAL?!0:!Pc(s,l,c.length);if(!s)return p?`|
20
+ |$)`,"g")}catch{Ps=/\n+(?!\n|$)/g}function Rt({comment:e,type:t,value:s},n,r,i){let{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(s))return Ne(s,n);let c=n.indent||(n.forceBlockIndent||Nt(s)?" ":""),p=o==="literal"?!0:o==="folded"||t===B.Scalar.BLOCK_FOLDED?!1:t===B.Scalar.BLOCK_LITERAL?!0:!qc(s,l,c.length);if(!s)return p?`|
21
21
  `:`>
22
- `;let d,u;for(u=s.length;u>0;--u){let E=s[u-1];if(E!==`
23
- `&&E!=="\t"&&E!==" ")break}let g=s.substring(u),w=g.indexOf(`
22
+ `;let d,u;for(u=s.length;u>0;--u){let v=s[u-1];if(v!==`
23
+ `&&v!=="\t"&&v!==" ")break}let g=s.substring(u),w=g.indexOf(`
24
24
  `);if(w===-1)d="-";else if(s===g||w!==g.length-1){if(d="+",i)i()}else d="";if(g){if(s=s.slice(0,-g.length),g[g.length-1]===`
25
- `)g=g.slice(0,-1);g=g.replace(Ps,`$&${c}`)}let f=!1,y,_=-1;for(y=0;y<s.length;++y){let E=s[y];if(E===" ")f=!0;else if(E===`
26
- `)_=y;else break}let m=s.substring(0,_<y?_+1:y);if(m)s=s.substring(m.length),m=m.replace(/\n+/g,`$&${c}`);let b=(f?c?"2":"1":"")+d;if(e){if(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r)r()}if(!p){let E=s.replace(/\n+/g,`
27
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),T=!1,R=Ct(n,!0);if(o!=="folded"&&t!==B.Scalar.BLOCK_FOLDED)R.onOverflow=()=>{T=!0};let v=te.foldFlowLines(`${m}${E}${g}`,c,te.FOLD_BLOCK,R);if(!T)return`>${b}
28
- ${c}${v}`}return s=s.replace(/\n+/g,`$&${c}`),`|${b}
29
- ${c}${m}${s}${g}`}function Mc(e,t,s,n){let{type:r,value:i}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:p}=t;if(a&&i.includes(`
25
+ `)g=g.slice(0,-1);g=g.replace(Ps,`$&${c}`)}let f=!1,y,_=-1;for(y=0;y<s.length;++y){let v=s[y];if(v===" ")f=!0;else if(v===`
26
+ `)_=y;else break}let m=s.substring(0,_<y?_+1:y);if(m)s=s.substring(m.length),m=m.replace(/\n+/g,`$&${c}`);let b=(f?c?"2":"1":"")+d;if(e){if(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r)r()}if(!p){let v=s.replace(/\n+/g,`
27
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),T=!1,R=Ct(n,!0);if(o!=="folded"&&t!==B.Scalar.BLOCK_FOLDED)R.onOverflow=()=>{T=!0};let E=te.foldFlowLines(`${m}${v}${g}`,c,te.FOLD_BLOCK,R);if(!T)return`>${b}
28
+ ${c}${E}`}return s=s.replace(/\n+/g,`$&${c}`),`|${b}
29
+ ${c}${m}${s}${g}`}function Fc(e,t,s,n){let{type:r,value:i}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:p}=t;if(a&&i.includes(`
30
30
  `)||p&&/[[\]{},]/.test(i))return Ne(i,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||p||!i.includes(`
31
31
  `)?Ne(i,t):Rt(e,t,s,n);if(!a&&!p&&r!==B.Scalar.PLAIN&&i.includes(`
32
32
  `))return Rt(e,t,s,n);if(Nt(i)){if(l==="")return t.forceBlockIndent=!0,Rt(e,t,s,n);else if(a&&l===c)return Ne(i,t)}let d=i.replace(/\n+/g,`$&
33
- ${l}`);if(o){let u=(f)=>f.default&&f.tag!=="tag:yaml.org,2002:str"&&f.test?.test(d),{compat:g,tags:w}=t.doc.schema;if(w.some(u)||g?.some(u))return Ne(i,t)}return a?d:te.foldFlowLines(d,l,te.FOLD_FLOW,Ct(t,!1))}function Dc(e,t,s,n){let{implicitKey:r,inFlow:i}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==B.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=B.Scalar.QUOTE_DOUBLE}let l=(p)=>{switch(p){case B.Scalar.BLOCK_FOLDED:case B.Scalar.BLOCK_LITERAL:return r||i?Ne(o.value,t):Rt(o,t,s,n);case B.Scalar.QUOTE_DOUBLE:return je(o.value,t);case B.Scalar.QUOTE_SINGLE:return Is(o.value,t);case B.Scalar.PLAIN:return Mc(o,t,s,n);default:return null}},c=l(a);if(c===null){let{defaultKeyType:p,defaultStringType:d}=t.options,u=r&&p||d;if(c=l(u),c===null)throw Error(`Unsupported default string type ${u}`)}return c}qc.stringifyString=Dc});var We=S(function(Yc){var $c=Et(),se=C(),Uc=Be(),Bc=Ke();function jc(e,t){let s=Object.assign({blockQuote:!0,commentString:Uc.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},e.schema.toStringOptions,t),n;switch(s.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:typeof s.indent==="number"?" ".repeat(s.indent):" ",inFlow:n,options:s}}function Kc(e,t){if(t.tag){let r=e.filter((i)=>i.tag===t.tag);if(r.length>0)return r.find((i)=>i.format===t.format)??r[0]}let s=void 0,n;if(se.isScalar(t)){n=t.value;let r=e.filter((i)=>i.identify?.(n));if(r.length>1){let i=r.filter((o)=>o.test);if(i.length>0)r=i}s=r.find((i)=>i.format===t.format)??r.find((i)=>!i.format)}else n=t,s=e.find((r)=>r.nodeClass&&n instanceof r.nodeClass);if(!s){let r=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${r} value`)}return s}function Wc(e,t,{anchors:s,doc:n}){if(!n.directives)return"";let r=[],i=(se.isScalar(e)||se.isCollection(e))&&e.anchor;if(i&&$c.anchorIsValid(i))s.add(i),r.push(`&${i}`);let o=e.tag??(t.default?null:t.tag);if(o)r.push(n.directives.tagString(o));return r.join(" ")}function Hc(e,t,s,n){if(se.isPair(e))return e.toString(t,s,n);if(se.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let r=void 0,i=se.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>r=l});r??(r=Kc(t.doc.schema.tags,i));let o=Wc(i,r,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof r.stringify==="function"?r.stringify(i,t,s,n):se.isScalar(i)?Bc.stringifyString(i,t,s,n):i.toString(t,s,n);if(!o)return a;return se.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
34
- ${t.indent}${a}`}Yc.createStringifyContext=jc;Yc.stringify=Hc});var Wr=S(function(Gc){var Q=C(),jr=k(),Kr=We(),He=Be();function Xc({key:e,value:t},s,n,r){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:p,simpleKeys:d}}=s,u=Q.isNode(e)&&e.comment||null;if(d){if(u)throw Error("With simple keys, key nodes cannot have comments");if(Q.isCollection(e)||!Q.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let g=!d&&(!e||u&&t==null&&!s.inFlow||Q.isCollection(e)||(Q.isScalar(e)?e.type===jr.Scalar.BLOCK_FOLDED||e.type===jr.Scalar.BLOCK_LITERAL:typeof e==="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!g&&(d||!i),indent:a+l});let w=!1,f=!1,y=Kr.stringify(e,s,()=>w=!0,()=>f=!0);if(!g&&!s.inFlow&&y.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(s.inFlow){if(i||t==null){if(w&&n)n();return y===""?"?":g?`? ${y}`:y}}else if(i&&!d||t==null&&g){if(y=`? ${y}`,u&&!w)y+=He.lineComment(y,s.indent,c(u));else if(f&&r)r();return y}if(w)u=null;if(g){if(u)y+=He.lineComment(y,s.indent,c(u));y=`? ${y}
35
- ${a}:`}else if(y=`${y}:`,u)y+=He.lineComment(y,s.indent,c(u));let _,m,h;if(Q.isNode(t))_=!!t.spaceBefore,m=t.commentBefore,h=t.comment;else if(_=!1,m=null,h=null,t&&typeof t==="object")t=o.createNode(t);if(s.implicitKey=!1,!g&&!u&&Q.isScalar(t))s.indentAtStart=y.length+1;if(f=!1,!p&&l.length>=2&&!s.inFlow&&!g&&Q.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)s.indent=s.indent.substring(2);let b=!1,E=Kr.stringify(t,s,()=>b=!0,()=>f=!0),T=" ";if(u||_||m){if(T=_?`
33
+ ${l}`);if(o){let u=(f)=>f.default&&f.tag!=="tag:yaml.org,2002:str"&&f.test?.test(d),{compat:g,tags:w}=t.doc.schema;if(w.some(u)||g?.some(u))return Ne(i,t)}return a?d:te.foldFlowLines(d,l,te.FOLD_FLOW,Ct(t,!1))}function $c(e,t,s,n){let{implicitKey:r,inFlow:i}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==B.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=B.Scalar.QUOTE_DOUBLE}let l=(p)=>{switch(p){case B.Scalar.BLOCK_FOLDED:case B.Scalar.BLOCK_LITERAL:return r||i?Ne(o.value,t):Rt(o,t,s,n);case B.Scalar.QUOTE_DOUBLE:return je(o.value,t);case B.Scalar.QUOTE_SINGLE:return Is(o.value,t);case B.Scalar.PLAIN:return Fc(o,t,s,n);default:return null}},c=l(a);if(c===null){let{defaultKeyType:p,defaultStringType:d}=t.options,u=r&&p||d;if(c=l(u),c===null)throw Error(`Unsupported default string type ${u}`)}return c}Uc.stringifyString=$c});var We=S(function(Gc){var jc=vt(),se=C(),Kc=Be(),Wc=Ke();function Hc(e,t){let s=Object.assign({blockQuote:!0,commentString:Kc.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},e.schema.toStringOptions,t),n;switch(s.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:typeof s.indent==="number"?" ".repeat(s.indent):" ",inFlow:n,options:s}}function Yc(e,t){if(t.tag){let r=e.filter((i)=>i.tag===t.tag);if(r.length>0)return r.find((i)=>i.format===t.format)??r[0]}let s=void 0,n;if(se.isScalar(t)){n=t.value;let r=e.filter((i)=>i.identify?.(n));if(r.length>1){let i=r.filter((o)=>o.test);if(i.length>0)r=i}s=r.find((i)=>i.format===t.format)??r.find((i)=>!i.format)}else n=t,s=e.find((r)=>r.nodeClass&&n instanceof r.nodeClass);if(!s){let r=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${r} value`)}return s}function Jc(e,t,{anchors:s,doc:n}){if(!n.directives)return"";let r=[],i=(se.isScalar(e)||se.isCollection(e))&&e.anchor;if(i&&jc.anchorIsValid(i))s.add(i),r.push(`&${i}`);let o=e.tag??(t.default?null:t.tag);if(o)r.push(n.directives.tagString(o));return r.join(" ")}function Vc(e,t,s,n){if(se.isPair(e))return e.toString(t,s,n);if(se.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let r=void 0,i=se.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>r=l});r??(r=Yc(t.doc.schema.tags,i));let o=Jc(i,r,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof r.stringify==="function"?r.stringify(i,t,s,n):se.isScalar(i)?Wc.stringifyString(i,t,s,n):i.toString(t,s,n);if(!o)return a;return se.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
34
+ ${t.indent}${a}`}Gc.createStringifyContext=Hc;Gc.stringify=Vc});var Hr=S(function(Zc){var Q=C(),Kr=k(),Wr=We(),He=Be();function Qc({key:e,value:t},s,n,r){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:p,simpleKeys:d}}=s,u=Q.isNode(e)&&e.comment||null;if(d){if(u)throw Error("With simple keys, key nodes cannot have comments");if(Q.isCollection(e)||!Q.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let g=!d&&(!e||u&&t==null&&!s.inFlow||Q.isCollection(e)||(Q.isScalar(e)?e.type===Kr.Scalar.BLOCK_FOLDED||e.type===Kr.Scalar.BLOCK_LITERAL:typeof e==="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!g&&(d||!i),indent:a+l});let w=!1,f=!1,y=Wr.stringify(e,s,()=>w=!0,()=>f=!0);if(!g&&!s.inFlow&&y.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(s.inFlow){if(i||t==null){if(w&&n)n();return y===""?"?":g?`? ${y}`:y}}else if(i&&!d||t==null&&g){if(y=`? ${y}`,u&&!w)y+=He.lineComment(y,s.indent,c(u));else if(f&&r)r();return y}if(w)u=null;if(g){if(u)y+=He.lineComment(y,s.indent,c(u));y=`? ${y}
35
+ ${a}:`}else if(y=`${y}:`,u)y+=He.lineComment(y,s.indent,c(u));let _,m,h;if(Q.isNode(t))_=!!t.spaceBefore,m=t.commentBefore,h=t.comment;else if(_=!1,m=null,h=null,t&&typeof t==="object")t=o.createNode(t);if(s.implicitKey=!1,!g&&!u&&Q.isScalar(t))s.indentAtStart=y.length+1;if(f=!1,!p&&l.length>=2&&!s.inFlow&&!g&&Q.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)s.indent=s.indent.substring(2);let b=!1,v=Wr.stringify(t,s,()=>b=!0,()=>f=!0),T=" ";if(u||_||m){if(T=_?`
36
36
  `:"",m){let R=c(m);T+=`
37
- ${He.indentComment(R,s.indent)}`}if(E===""&&!s.inFlow){if(T===`
37
+ ${He.indentComment(R,s.indent)}`}if(v===""&&!s.inFlow){if(T===`
38
38
  `&&h)T=`
39
39
 
40
40
  `}else T+=`
41
- ${s.indent}`}else if(!g&&Q.isCollection(t)){let R=E[0],v=E.indexOf(`
42
- `),x=v!==-1,Z=s.inFlow??t.flow??t.items.length===0;if(x||!Z){let _e=!1;if(x&&(R==="&"||R==="!")){let I=E.indexOf(" ");if(R==="&"&&I!==-1&&I<v&&E[I+1]==="!")I=E.indexOf(" ",I+1);if(I===-1||v<I)_e=!0}if(!_e)T=`
43
- ${s.indent}`}}else if(E===""||E[0]===`
44
- `)T="";if(y+=T+E,s.inFlow){if(b&&n)n()}else if(h&&!b)y+=He.lineComment(y,s.indent,c(h));else if(f&&r)r();return y}Gc.stringifyPair=Xc});var Ms=S(function(ed){var Hr=ot("process");function Qc(e,...t){if(e==="debug")console.log(...t)}function Zc(e,t){if(e==="debug"||e==="warn")if(typeof Hr.emitWarning==="function")Hr.emitWarning(t);else console.warn(t)}ed.debug=Qc;ed.warn=Zc});var kt=S(function(rd){var Lt=C(),Yr=k(),xt="<<",Ot={identify:(e)=>e===xt||typeof e==="symbol"&&e.description===xt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Yr.Scalar(Symbol(xt)),{addToJSMap:Jr}),stringify:()=>xt},nd=(e,t)=>(Ot.identify(t)||Lt.isScalar(t)&&(!t.type||t.type===Yr.Scalar.PLAIN)&&Ot.identify(t.value))&&e?.doc.schema.tags.some((s)=>s.tag===Ot.tag&&s.default);function Jr(e,t,s){let n=Vr(e,s);if(Lt.isSeq(n))for(let r of n.items)Ds(e,t,r);else if(Array.isArray(n))for(let r of n)Ds(e,t,r);else Ds(e,t,n)}function Ds(e,t,s){let n=Vr(e,s);if(!Lt.isMap(n))throw Error("Merge sources must be maps or map aliases");let r=n.toJSON(null,e,Map);for(let[i,o]of r)if(t instanceof Map){if(!t.has(i))t.set(i,o)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Vr(e,t){return e&&Lt.isAlias(t)?t.resolve(e.doc,e):t}rd.addMergeToJSMap=Jr;rd.isMergeKey=nd;rd.merge=Ot});var Fs=S(function(fd){var ld=Ms(),Xr=kt(),cd=We(),Gr=C(),qs=ee();function dd(e,t,{key:s,value:n}){if(Gr.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,n);else if(Xr.isMergeKey(e,s))Xr.addMergeToJSMap(e,t,n);else{let r=qs.toJS(s,"",e);if(t instanceof Map)t.set(r,qs.toJS(n,r,e));else if(t instanceof Set)t.add(r);else{let i=ud(s,r,e),o=qs.toJS(n,i,e);if(i in t)Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[i]=o}}return t}function ud(e,t,s){if(t===null)return"";if(typeof t!=="object")return String(t);if(Gr.isNode(e)&&s?.doc){let n=cd.createStringifyContext(s.doc,{});n.anchors=new Set;for(let i of s.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let r=e.toString(n);if(!s.mapKeyWarned){let i=JSON.stringify(r);if(i.length>40)i=i.substring(0,36)+'..."';ld.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return r}return JSON.stringify(t)}fd.addPairToJSMap=dd});var ne=S(function(yd){var zr=Ue(),pd=Wr(),md=Fs(),It=C();function gd(e,t,s){let n=zr.createNode(e,void 0,s),r=zr.createNode(t,void 0,s);return new Pt(n,r)}class Pt{constructor(e,t=null){Object.defineProperty(this,It.NODE_TYPE,{value:It.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;if(It.isNode(t))t=t.clone(e);if(It.isNode(s))s=s.clone(e);return new Pt(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return md.addPairToJSMap(t,s,this)}toString(e,t,s){return e?.doc?pd.stringifyPair(this,e,t,s):JSON.stringify(this)}}yd.Pair=Pt;yd.createPair=gd});var $s=S(function(vd){var me=C(),Qr=We(),Mt=Be();function _d(e,t,s){return(t.inFlow??e.flow?Ed:Sd)(e,t,s)}function Sd({comment:e,items:t},s,{blockItemPrefix:n,flowChars:r,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,p=Object.assign({},s,{indent:i,type:null}),d=!1,u=[];for(let w=0;w<t.length;++w){let f=t[w],y=null;if(me.isNode(f)){if(!d&&f.spaceBefore)u.push("");if(Dt(s,u,f.commentBefore,d),f.comment)y=f.comment}else if(me.isPair(f)){let m=me.isNode(f.key)?f.key:null;if(m){if(!d&&m.spaceBefore)u.push("");Dt(s,u,m.commentBefore,d)}}d=!1;let _=Qr.stringify(f,p,()=>y=null,()=>d=!0);if(y)_+=Mt.lineComment(_,i,c(y));if(d&&y)d=!1;u.push(n+_)}let g;if(u.length===0)g=r.start+r.end;else{g=u[0];for(let w=1;w<u.length;++w){let f=u[w];g+=f?`
41
+ ${s.indent}`}else if(!g&&Q.isCollection(t)){let R=v[0],E=v.indexOf(`
42
+ `),x=E!==-1,Z=s.inFlow??t.flow??t.items.length===0;if(x||!Z){let _e=!1;if(x&&(R==="&"||R==="!")){let I=v.indexOf(" ");if(R==="&"&&I!==-1&&I<E&&v[I+1]==="!")I=v.indexOf(" ",I+1);if(I===-1||E<I)_e=!0}if(!_e)T=`
43
+ ${s.indent}`}}else if(v===""||v[0]===`
44
+ `)T="";if(y+=T+v,s.inFlow){if(b&&n)n()}else if(h&&!b)y+=He.lineComment(y,s.indent,c(h));else if(f&&r)r();return y}Zc.stringifyPair=Qc});var Ms=S(function(nd){var Yr=ot("process");function td(e,...t){if(e==="debug")console.log(...t)}function sd(e,t){if(e==="debug"||e==="warn")if(typeof Yr.emitWarning==="function")Yr.emitWarning(t);else console.warn(t)}nd.debug=td;nd.warn=sd});var kt=S(function(ad){var Lt=C(),Jr=k(),xt="<<",Ot={identify:(e)=>e===xt||typeof e==="symbol"&&e.description===xt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Jr.Scalar(Symbol(xt)),{addToJSMap:Vr}),stringify:()=>xt},od=(e,t)=>(Ot.identify(t)||Lt.isScalar(t)&&(!t.type||t.type===Jr.Scalar.PLAIN)&&Ot.identify(t.value))&&e?.doc.schema.tags.some((s)=>s.tag===Ot.tag&&s.default);function Vr(e,t,s){let n=Gr(e,s);if(Lt.isSeq(n))for(let r of n.items)Ds(e,t,r);else if(Array.isArray(n))for(let r of n)Ds(e,t,r);else Ds(e,t,n)}function Ds(e,t,s){let n=Gr(e,s);if(!Lt.isMap(n))throw Error("Merge sources must be maps or map aliases");let r=n.toJSON(null,e,Map);for(let[i,o]of r)if(t instanceof Map){if(!t.has(i))t.set(i,o)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Gr(e,t){return e&&Lt.isAlias(t)?t.resolve(e.doc,e):t}ad.addMergeToJSMap=Vr;ad.isMergeKey=od;ad.merge=Ot});var Fs=S(function(md){var ud=Ms(),Xr=kt(),fd=We(),zr=C(),qs=ee();function hd(e,t,{key:s,value:n}){if(zr.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,n);else if(Xr.isMergeKey(e,s))Xr.addMergeToJSMap(e,t,n);else{let r=qs.toJS(s,"",e);if(t instanceof Map)t.set(r,qs.toJS(n,r,e));else if(t instanceof Set)t.add(r);else{let i=pd(s,r,e),o=qs.toJS(n,i,e);if(i in t)Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[i]=o}}return t}function pd(e,t,s){if(t===null)return"";if(typeof t!=="object")return String(t);if(zr.isNode(e)&&s?.doc){let n=fd.createStringifyContext(s.doc,{});n.anchors=new Set;for(let i of s.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let r=e.toString(n);if(!s.mapKeyWarned){let i=JSON.stringify(r);if(i.length>40)i=i.substring(0,36)+'..."';ud.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return r}return JSON.stringify(t)}md.addPairToJSMap=hd});var ne=S(function(_d){var Qr=Ue(),yd=Hr(),wd=Fs(),It=C();function bd(e,t,s){let n=Qr.createNode(e,void 0,s),r=Qr.createNode(t,void 0,s);return new Pt(n,r)}class Pt{constructor(e,t=null){Object.defineProperty(this,It.NODE_TYPE,{value:It.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;if(It.isNode(t))t=t.clone(e);if(It.isNode(s))s=s.clone(e);return new Pt(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return wd.addPairToJSMap(t,s,this)}toString(e,t,s){return e?.doc?yd.stringifyPair(this,e,t,s):JSON.stringify(this)}}_d.Pair=Pt;_d.createPair=bd});var $s=S(function(Rd){var me=C(),Zr=We(),Mt=Be();function Ed(e,t,s){return(t.inFlow??e.flow?Ad:Td)(e,t,s)}function Td({comment:e,items:t},s,{blockItemPrefix:n,flowChars:r,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,p=Object.assign({},s,{indent:i,type:null}),d=!1,u=[];for(let w=0;w<t.length;++w){let f=t[w],y=null;if(me.isNode(f)){if(!d&&f.spaceBefore)u.push("");if(Dt(s,u,f.commentBefore,d),f.comment)y=f.comment}else if(me.isPair(f)){let m=me.isNode(f.key)?f.key:null;if(m){if(!d&&m.spaceBefore)u.push("");Dt(s,u,m.commentBefore,d)}}d=!1;let _=Zr.stringify(f,p,()=>y=null,()=>d=!0);if(y)_+=Mt.lineComment(_,i,c(y));if(d&&y)d=!1;u.push(n+_)}let g;if(u.length===0)g=r.start+r.end;else{g=u[0];for(let w=1;w<u.length;++w){let f=u[w];g+=f?`
45
45
  ${l}${f}`:`
46
46
  `}}if(e){if(g+=`
47
- `+Mt.indentComment(c(e),l),a)a()}else if(d&&o)o();return g}function Ed({items:e},t,{flowChars:s,itemIndent:n}){let{indent:r,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=t;n+=i;let l=Object.assign({},t,{indent:n,inFlow:!0,type:null}),c=!1,p=0,d=[];for(let w=0;w<e.length;++w){let f=e[w],y=null;if(me.isNode(f)){if(f.spaceBefore)d.push("");if(Dt(t,d,f.commentBefore,!1),f.comment)y=f.comment}else if(me.isPair(f)){let m=me.isNode(f.key)?f.key:null;if(m){if(m.spaceBefore)d.push("");if(Dt(t,d,m.commentBefore,!1),m.comment)c=!0}let h=me.isNode(f.value)?f.value:null;if(h){if(h.comment)y=h.comment;if(h.commentBefore)c=!0}else if(f.value==null&&m?.comment)y=m.comment}if(y)c=!0;let _=Qr.stringify(f,l,()=>y=null);if(c||(c=d.length>p||_.includes(`
47
+ `+Mt.indentComment(c(e),l),a)a()}else if(d&&o)o();return g}function Ad({items:e},t,{flowChars:s,itemIndent:n}){let{indent:r,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=t;n+=i;let l=Object.assign({},t,{indent:n,inFlow:!0,type:null}),c=!1,p=0,d=[];for(let w=0;w<e.length;++w){let f=e[w],y=null;if(me.isNode(f)){if(f.spaceBefore)d.push("");if(Dt(t,d,f.commentBefore,!1),f.comment)y=f.comment}else if(me.isPair(f)){let m=me.isNode(f.key)?f.key:null;if(m){if(m.spaceBefore)d.push("");if(Dt(t,d,m.commentBefore,!1),m.comment)c=!0}let h=me.isNode(f.value)?f.value:null;if(h){if(h.comment)y=h.comment;if(h.commentBefore)c=!0}else if(f.value==null&&m?.comment)y=m.comment}if(y)c=!0;let _=Zr.stringify(f,l,()=>y=null);if(c||(c=d.length>p||_.includes(`
48
48
  `)),w<e.length-1)_+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=d.reduce((m,h)=>m+h.length+2,2)+(_.length+2)>t.options.lineWidth);if(c)_+=","}if(y)_+=Mt.lineComment(_,n,a(y));d.push(_),p=d.length}let{start:u,end:g}=s;if(d.length===0)return u+g;else{if(!c){let w=d.reduce((f,y)=>f+y.length+2,2);c=t.options.lineWidth>0&&w>t.options.lineWidth}if(c){let w=u;for(let f of d)w+=f?`
49
49
  ${i}${r}${f}`:`
50
50
  `;return`${w}
51
- ${r}${g}`}else return`${u}${o}${d.join(" ")}${o}${g}`}}function Dt({indent:e,options:{commentString:t}},s,n,r){if(n&&r)n=n.replace(/^\n+/,"");if(n){let i=Mt.indentComment(t(n),e);s.push(i.trimStart())}}vd.stringifyCollection=_d});var ie=S(function(xd){var Ad=$s(),Rd=Fs(),Cd=At(),re=C(),qt=ne(),Nd=k();function Ye(e,t){let s=re.isScalar(t)?t.value:t;for(let n of e)if(re.isPair(n)){if(n.key===t||n.key===s)return n;if(re.isScalar(n.key)&&n.key.value===s)return n}return}class Zr extends Cd.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(re.MAP,e);this.items=[]}static from(e,t,s){let{keepUndefined:n,replacer:r}=s,i=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||n)i.items.push(qt.createPair(a,l,s))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let s;if(re.isPair(e))s=e;else if(!e||typeof e!=="object"||!("key"in e))s=new qt.Pair(e,e?.value);else s=new qt.Pair(e.key,e.value);let n=Ye(this.items,s.key),r=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${s.key} already set`);if(re.isScalar(n.value)&&Nd.isScalarValue(s.value))n.value.value=s.value;else n.value=s.value}else if(r){let i=this.items.findIndex((o)=>r(s,o)<0);if(i===-1)this.items.push(s);else this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=Ye(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Ye(this.items,e)?.value;return(!t&&re.isScalar(n)?n.value:n)??void 0}has(e){return!!Ye(this.items,e)}set(e,t){this.add(new qt.Pair(e,t),!0)}toJSON(e,t,s){let n=s?new s:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let r of this.items)Rd.addPairToJSMap(t,n,r);return n}toString(e,t,s){if(!e)return JSON.stringify(this);for(let n of this.items)if(!re.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return Ad.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}xd.YAMLMap=Zr;xd.findPair=Ye});var xe=S(function(Pd){var kd=C(),ei=ie(),Id={collection:"map",default:!0,nodeClass:ei.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!kd.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,s)=>ei.YAMLMap.from(e,t,s)};Pd.map=Id});var oe=S(function(Bd){var Dd=Ue(),qd=$s(),Fd=At(),$t=C(),$d=k(),Ud=ee();class ti extends Fd.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super($t.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Ft(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let s=Ft(e);if(typeof s!=="number")return;let n=this.items[s];return!t&&$t.isScalar(n)?n.value:n}has(e){let t=Ft(e);return typeof t==="number"&&t<this.items.length}set(e,t){let s=Ft(e);if(typeof s!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[s];if($t.isScalar(n)&&$d.isScalarValue(t))n.value=t;else this.items[s]=t}toJSON(e,t){let s=[];if(t?.onCreate)t.onCreate(s);let n=0;for(let r of this.items)s.push(Ud.toJS(r,String(n++),t));return s}toString(e,t,s){if(!e)return JSON.stringify(this);return qd.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t})}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let o of t){if(typeof n==="function"){let a=t instanceof Set?o:String(i++);o=n.call(t,a,o)}r.items.push(Dd.createNode(o,void 0,s))}}return r}}function Ft(e){let t=$t.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Bd.YAMLSeq=ti});var Oe=S(function(Hd){var Kd=C(),si=oe(),Wd={collection:"seq",default:!0,nodeClass:si.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Kd.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,s)=>si.YAMLSeq.from(e,t,s)};Hd.seq=Wd});var Je=S(function(Xd){var Jd=Ke(),Vd={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,s,n){return t=Object.assign({actualString:!0},t),Jd.stringifyString(e,t,s,n)}};Xd.string=Vd});var Ut=S(function(zd){var ni=k(),ri={identify:(e)=>e==null,createNode:()=>new ni.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ni.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&ri.test.test(e)?e:t.options.nullStr};zd.nullTag=ri});var Us=S(function(eu){var Zd=k(),ii={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new Zd.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&ii.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?s.options.trueStr:s.options.falseStr}};eu.boolTag=ii});var Le=S(function(nu){function su({format:e,minFractionDigits:t,tag:s,value:n}){if(typeof n==="bigint")return String(n);let r=typeof n==="number"?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!s||s==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");if(o<0)o=i.length,i+=".";let a=t-(i.length-o-1);while(a-- >0)i+="0"}return i}nu.stringifyNumber=su});var js=S(function(cu){var iu=k(),Bs=Le(),ou={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs.stringifyNumber},au={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bs.stringifyNumber(e)}},lu={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new iu.Scalar(parseFloat(e)),s=e.indexOf(".");if(s!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-s-1;return t},stringify:Bs.stringifyNumber};cu.float=lu;cu.floatExp=au;cu.floatNaN=ou});var Ws=S(function(gu){var oi=Le(),Bt=(e)=>typeof e==="bigint"||Number.isInteger(e),Ks=(e,t,s,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),s);function ai(e,t,s){let{value:n}=e;if(Bt(n)&&n>=0)return s+n.toString(t);return oi.stringifyNumber(e)}var hu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>Ks(e,2,8,s),stringify:(e)=>ai(e,8,"0o")},pu={identify:Bt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>Ks(e,0,10,s),stringify:oi.stringifyNumber},mu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>Ks(e,2,16,s),stringify:(e)=>ai(e,16,"0x")};gu.int=pu;gu.intHex=mu;gu.intOct=hu});var li=S(function(Ru){var _u=xe(),Su=Ut(),Eu=Oe(),vu=Je(),Tu=Us(),Hs=js(),Ys=Ws(),Au=[_u.map,Eu.seq,vu.string,Su.nullTag,Tu.boolTag,Ys.intOct,Ys.int,Ys.intHex,Hs.floatNaN,Hs.floatExp,Hs.float];Ru.schema=Au});var di=S(function(Pu){var Nu=k(),xu=xe(),Ou=Oe();function ci(e){return typeof e==="bigint"||Number.isInteger(e)}var jt=({value:e})=>JSON.stringify(e),Lu=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:jt},{identify:(e)=>e==null,createNode:()=>new Nu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:jt},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:jt},{identify:ci,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:s})=>s?BigInt(e):parseInt(e,10),stringify:({value:e})=>ci(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:jt}],ku={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Iu=[xu.map,Ou.seq].concat(Lu,ku);Pu.schema=Iu});var Vs=S(function(Fu){var Ve=ot("buffer"),Js=k(),Du=Ke(),qu={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Ve.Buffer==="function")return Ve.Buffer.from(e,"base64");else if(typeof atob==="function"){let s=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(s.length);for(let r=0;r<s.length;++r)n[r]=s.charCodeAt(r);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},n,r,i){if(!s)return"";let o=s,a;if(typeof Ve.Buffer==="function")a=o instanceof Ve.Buffer?o.toString("base64"):Ve.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Js.Scalar.BLOCK_LITERAL),t!==Js.Scalar.QUOTE_DOUBLE){let l=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let d=0,u=0;d<c;++d,u+=l)p[d]=a.substr(u,l);a=p.join(t===Js.Scalar.BLOCK_LITERAL?`
52
- `:" ")}return Du.stringifyString({comment:e,type:t,value:a},n,r,i)}};Fu.binary=qu});var Wt=S(function(Ku){var Kt=C(),Xs=ne(),Uu=k(),Bu=oe();function ui(e,t){if(Kt.isSeq(e))for(let s=0;s<e.items.length;++s){let n=e.items[s];if(Kt.isPair(n))continue;else if(Kt.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let r=n.items[0]||new Xs.Pair(new Uu.Scalar(null));if(n.commentBefore)r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
51
+ ${r}${g}`}else return`${u}${o}${d.join(" ")}${o}${g}`}}function Dt({indent:e,options:{commentString:t}},s,n,r){if(n&&r)n=n.replace(/^\n+/,"");if(n){let i=Mt.indentComment(t(n),e);s.push(i.trimStart())}}Rd.stringifyCollection=Ed});var ie=S(function(kd){var Nd=$s(),xd=Fs(),Od=At(),re=C(),qt=ne(),Ld=k();function Ye(e,t){let s=re.isScalar(t)?t.value:t;for(let n of e)if(re.isPair(n)){if(n.key===t||n.key===s)return n;if(re.isScalar(n.key)&&n.key.value===s)return n}return}class ei extends Od.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(re.MAP,e);this.items=[]}static from(e,t,s){let{keepUndefined:n,replacer:r}=s,i=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||n)i.items.push(qt.createPair(a,l,s))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let s;if(re.isPair(e))s=e;else if(!e||typeof e!=="object"||!("key"in e))s=new qt.Pair(e,e?.value);else s=new qt.Pair(e.key,e.value);let n=Ye(this.items,s.key),r=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${s.key} already set`);if(re.isScalar(n.value)&&Ld.isScalarValue(s.value))n.value.value=s.value;else n.value=s.value}else if(r){let i=this.items.findIndex((o)=>r(s,o)<0);if(i===-1)this.items.push(s);else this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=Ye(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Ye(this.items,e)?.value;return(!t&&re.isScalar(n)?n.value:n)??void 0}has(e){return!!Ye(this.items,e)}set(e,t){this.add(new qt.Pair(e,t),!0)}toJSON(e,t,s){let n=s?new s:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let r of this.items)xd.addPairToJSMap(t,n,r);return n}toString(e,t,s){if(!e)return JSON.stringify(this);for(let n of this.items)if(!re.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return Nd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}kd.YAMLMap=ei;kd.findPair=Ye});var xe=S(function(qd){var Md=C(),ti=ie(),Dd={collection:"map",default:!0,nodeClass:ti.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!Md.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,s)=>ti.YAMLMap.from(e,t,s)};qd.map=Dd});var oe=S(function(Wd){var $d=Ue(),Ud=$s(),Bd=At(),$t=C(),jd=k(),Kd=ee();class si extends Bd.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super($t.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Ft(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let s=Ft(e);if(typeof s!=="number")return;let n=this.items[s];return!t&&$t.isScalar(n)?n.value:n}has(e){let t=Ft(e);return typeof t==="number"&&t<this.items.length}set(e,t){let s=Ft(e);if(typeof s!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[s];if($t.isScalar(n)&&jd.isScalarValue(t))n.value=t;else this.items[s]=t}toJSON(e,t){let s=[];if(t?.onCreate)t.onCreate(s);let n=0;for(let r of this.items)s.push(Kd.toJS(r,String(n++),t));return s}toString(e,t,s){if(!e)return JSON.stringify(this);return Ud.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t})}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let o of t){if(typeof n==="function"){let a=t instanceof Set?o:String(i++);o=n.call(t,a,o)}r.items.push($d.createNode(o,void 0,s))}}return r}}function Ft(e){let t=$t.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Wd.YAMLSeq=si});var Oe=S(function(Vd){var Yd=C(),ni=oe(),Jd={collection:"seq",default:!0,nodeClass:ni.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Yd.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,s)=>ni.YAMLSeq.from(e,t,s)};Vd.seq=Jd});var Je=S(function(Qd){var Xd=Ke(),zd={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,s,n){return t=Object.assign({actualString:!0},t),Xd.stringifyString(e,t,s,n)}};Qd.string=zd});var Ut=S(function(eu){var ri=k(),ii={identify:(e)=>e==null,createNode:()=>new ri.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ri.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&ii.test.test(e)?e:t.options.nullStr};eu.nullTag=ii});var Us=S(function(nu){var su=k(),oi={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new su.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&oi.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?s.options.trueStr:s.options.falseStr}};nu.boolTag=oi});var Le=S(function(ou){function iu({format:e,minFractionDigits:t,tag:s,value:n}){if(typeof n==="bigint")return String(n);let r=typeof n==="number"?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!s||s==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");if(o<0)o=i.length,i+=".";let a=t-(i.length-o-1);while(a-- >0)i+="0"}return i}ou.stringifyNumber=iu});var js=S(function(fu){var lu=k(),Bs=Le(),cu={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs.stringifyNumber},du={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bs.stringifyNumber(e)}},uu={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new lu.Scalar(parseFloat(e)),s=e.indexOf(".");if(s!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-s-1;return t},stringify:Bs.stringifyNumber};fu.float=uu;fu.floatExp=du;fu.floatNaN=cu});var Ws=S(function(bu){var ai=Le(),Bt=(e)=>typeof e==="bigint"||Number.isInteger(e),Ks=(e,t,s,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),s);function li(e,t,s){let{value:n}=e;if(Bt(n)&&n>=0)return s+n.toString(t);return ai.stringifyNumber(e)}var gu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>Ks(e,2,8,s),stringify:(e)=>li(e,8,"0o")},yu={identify:Bt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>Ks(e,0,10,s),stringify:ai.stringifyNumber},wu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>Ks(e,2,16,s),stringify:(e)=>li(e,16,"0x")};bu.int=yu;bu.intHex=wu;bu.intOct=gu});var ci=S(function(xu){var Eu=xe(),Tu=Ut(),Au=Oe(),Ru=Je(),Cu=Us(),Hs=js(),Ys=Ws(),Nu=[Eu.map,Au.seq,Ru.string,Tu.nullTag,Cu.boolTag,Ys.intOct,Ys.int,Ys.intHex,Hs.floatNaN,Hs.floatExp,Hs.float];xu.schema=Nu});var ui=S(function(qu){var Lu=k(),ku=xe(),Iu=Oe();function di(e){return typeof e==="bigint"||Number.isInteger(e)}var jt=({value:e})=>JSON.stringify(e),Pu=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:jt},{identify:(e)=>e==null,createNode:()=>new Lu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:jt},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:jt},{identify:di,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:s})=>s?BigInt(e):parseInt(e,10),stringify:({value:e})=>di(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:jt}],Mu={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Du=[ku.map,Iu.seq].concat(Pu,Mu);qu.schema=Du});var Vs=S(function(Bu){var Ve=ot("buffer"),Js=k(),$u=Ke(),Uu={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Ve.Buffer==="function")return Ve.Buffer.from(e,"base64");else if(typeof atob==="function"){let s=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(s.length);for(let r=0;r<s.length;++r)n[r]=s.charCodeAt(r);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},n,r,i){if(!s)return"";let o=s,a;if(typeof Ve.Buffer==="function")a=o instanceof Ve.Buffer?o.toString("base64"):Ve.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Js.Scalar.BLOCK_LITERAL),t!==Js.Scalar.QUOTE_DOUBLE){let l=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let d=0,u=0;d<c;++d,u+=l)p[d]=a.substr(u,l);a=p.join(t===Js.Scalar.BLOCK_LITERAL?`
52
+ `:" ")}return $u.stringifyString({comment:e,type:t,value:a},n,r,i)}};Bu.binary=Uu});var Wt=S(function(Yu){var Kt=C(),Gs=ne(),Ku=k(),Wu=oe();function fi(e,t){if(Kt.isSeq(e))for(let s=0;s<e.items.length;++s){let n=e.items[s];if(Kt.isPair(n))continue;else if(Kt.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let r=n.items[0]||new Gs.Pair(new Ku.Scalar(null));if(n.commentBefore)r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
53
53
  ${r.key.commentBefore}`:n.commentBefore;if(n.comment){let i=r.value??r.key;i.comment=i.comment?`${n.comment}
54
- ${i.comment}`:n.comment}n=r}e.items[s]=Kt.isPair(n)?n:new Xs.Pair(n)}else t("Expected a sequence for this tag");return e}function fi(e,t,s){let{replacer:n}=s,r=new Bu.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,String(i++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Xs.createPair(a,l,s))}return r}var ju={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ui,createNode:fi};Ku.createPairs=fi;Ku.pairs=ju;Ku.resolvePairs=ui});var zs=S(function(Xu){var hi=C(),Gs=ee(),Xe=ie(),Ju=oe(),pi=Wt();class ge extends Ju.YAMLSeq{constructor(){super();this.add=Xe.YAMLMap.prototype.add.bind(this),this.delete=Xe.YAMLMap.prototype.delete.bind(this),this.get=Xe.YAMLMap.prototype.get.bind(this),this.has=Xe.YAMLMap.prototype.has.bind(this),this.set=Xe.YAMLMap.prototype.set.bind(this),this.tag=ge.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;if(t?.onCreate)t.onCreate(s);for(let n of this.items){let r,i;if(hi.isPair(n))r=Gs.toJS(n.key,"",t),i=Gs.toJS(n.value,r,t);else r=Gs.toJS(n,"",t);if(s.has(r))throw Error("Ordered maps must not include duplicate keys");s.set(r,i)}return s}static from(e,t,s){let n=pi.createPairs(e,t,s),r=new this;return r.items=n.items,r}}ge.tag="tag:yaml.org,2002:omap";var Vu={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=pi.resolvePairs(e,t),n=[];for(let{key:r}of s.items)if(hi.isScalar(r))if(n.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else n.push(r.value);return Object.assign(new ge,s)},createNode:(e,t,s)=>ge.from(e,t,s)};Xu.YAMLOMap=ge;Xu.omap=Vu});var bi=S(function(Qu){var mi=k();function gi({value:e,source:t},s){if(t&&(e?yi:wi).test.test(t))return t;return e?s.options.trueStr:s.options.falseStr}var yi={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new mi.Scalar(!0),stringify:gi},wi={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new mi.Scalar(!1),stringify:gi};Qu.falseTag=wi;Qu.trueTag=yi});var _i=S(function(of){var tf=k(),Qs=Le(),sf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Qs.stringifyNumber},nf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Qs.stringifyNumber(e)}},rf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new tf.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let n=e.substring(s+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Qs.stringifyNumber};of.float=rf;of.floatExp=nf;of.floatNaN=sf});var Ei=S(function(pf){var Si=Le(),Ge=(e)=>typeof e==="bigint"||Number.isInteger(e);function Ht(e,t,s,{intAsBigInt:n}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let i=parseInt(e,s);return r==="-"?-1*i:i}function Zs(e,t,s){let{value:n}=e;if(Ge(n)){let r=n.toString(t);return n<0?"-"+s+r.substr(1):s+r}return Si.stringifyNumber(e)}var df={identify:Ge,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Ht(e,2,2,s),stringify:(e)=>Zs(e,2,"0b")},uf={identify:Ge,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Ht(e,1,8,s),stringify:(e)=>Zs(e,8,"0")},ff={identify:Ge,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Ht(e,0,10,s),stringify:Si.stringifyNumber},hf={identify:Ge,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Ht(e,2,16,s),stringify:(e)=>Zs(e,16,"0x")};pf.int=ff;pf.intBin=df;pf.intHex=hf;pf.intOct=uf});var en=S(function(_f){var Vt=C(),Yt=ne(),Jt=ie();class ye extends Jt.YAMLMap{constructor(e){super(e);this.tag=ye.tag}add(e){let t;if(Vt.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Yt.Pair(e.key,null);else t=new Yt.Pair(e,null);if(!Jt.findPair(this.items,t.key))this.items.push(t)}get(e,t){let s=Jt.findPair(this.items,e);return!t&&Vt.isPair(s)?Vt.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=Jt.findPair(this.items,e);if(s&&!t)this.items.splice(this.items.indexOf(s),1);else if(!s&&t)this.items.push(new Yt.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);else throw Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,i,i);r.items.push(Yt.createPair(i,null,s))}return r}}ye.tag="tag:yaml.org,2002:set";var bf={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ye,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>ye.from(e,t,s),resolve(e,t){if(Vt.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ye,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};_f.YAMLSet=ye;_f.set=bf});var sn=S(function(Rf){var vf=Le();function tn(e,t){let s=e[0],n=s==="-"||s==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return s==="-"?r(-1)*i:i}function vi(e){let{value:t}=e,s=(o)=>o;if(typeof t==="bigint")s=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return vf.stringifyNumber(e);let n="";if(t<0)n="-",t*=s(-1);let r=s(60),i=[t%r];if(t<60)i.unshift(0);else if(t=(t-i[0])/r,i.unshift(t%r),t>=60)t=(t-i[0])/r,i.unshift(t);return n+i.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Tf={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>tn(e,s),stringify:vi},Af={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>tn(e,!1),stringify:vi},Ti={identify:(e)=>e 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(e){let t=e.match(Ti.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,n,r,i,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,n-1,r,i||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let d=tn(p,!1);if(Math.abs(d)<30)d*=60;c-=60000*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Rf.floatTime=Af;Rf.intTime=Tf;Rf.timestamp=Ti});var Ri=S(function(Uf){var Of=xe(),Lf=Ut(),kf=Oe(),If=Je(),Pf=Vs(),Ai=bi(),nn=_i(),Xt=Ei(),Mf=kt(),Df=zs(),qf=Wt(),Ff=en(),rn=sn(),$f=[Of.map,kf.seq,If.string,Lf.nullTag,Ai.trueTag,Ai.falseTag,Xt.intBin,Xt.intOct,Xt.int,Xt.intHex,nn.floatNaN,nn.floatExp,nn.float,Pf.binary,Mf.merge,Df.omap,qf.pairs,Ff.set,rn.intTime,rn.floatTime,rn.timestamp];Uf.schema=$f});var Di=S(function(Xf){var Oi=xe(),jf=Ut(),Li=Oe(),Kf=Je(),Wf=Us(),on=js(),an=Ws(),Hf=li(),Yf=di(),ki=Vs(),ze=kt(),Ii=zs(),Pi=Wt(),Ci=Ri(),Mi=en(),Gt=sn(),Ni=new Map([["core",Hf.schema],["failsafe",[Oi.map,Li.seq,Kf.string]],["json",Yf.schema],["yaml11",Ci.schema],["yaml-1.1",Ci.schema]]),xi={binary:ki.binary,bool:Wf.boolTag,float:on.float,floatExp:on.floatExp,floatNaN:on.floatNaN,floatTime:Gt.floatTime,int:an.int,intHex:an.intHex,intOct:an.intOct,intTime:Gt.intTime,map:Oi.map,merge:ze.merge,null:jf.nullTag,omap:Ii.omap,pairs:Pi.pairs,seq:Li.seq,set:Mi.set,timestamp:Gt.timestamp},Jf={"tag:yaml.org,2002:binary":ki.binary,"tag:yaml.org,2002:merge":ze.merge,"tag:yaml.org,2002:omap":Ii.omap,"tag:yaml.org,2002:pairs":Pi.pairs,"tag:yaml.org,2002:set":Mi.set,"tag:yaml.org,2002:timestamp":Gt.timestamp};function Vf(e,t,s){let n=Ni.get(t);if(n&&!e)return s&&!n.includes(ze.merge)?n.concat(ze.merge):n.slice();let r=n;if(!r)if(Array.isArray(e))r=[];else{let i=Array.from(Ni.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)r=r.concat(i);else if(typeof e==="function")r=e(r.slice());if(s)r=r.concat(ze.merge);return r.reduce((i,o)=>{let a=typeof o==="string"?xi[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(xi).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!i.includes(a))i.push(a);return i},[])}Xf.coreKnownTags=Jf;Xf.getTags=Vf});var dn=S(function(sh){var ln=C(),Qf=xe(),Zf=Oe(),eh=Je(),zt=Di(),th=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class cn{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:r,sortMapEntries:i,toStringDefaults:o}){this.compat=Array.isArray(e)?zt.getTags(e,"compat"):e?zt.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=n?zt.coreKnownTags:{},this.tags=zt.getTags(t,this.name,s),this.toStringOptions=o??null,Object.defineProperty(this,ln.MAP,{value:Qf.map}),Object.defineProperty(this,ln.SCALAR,{value:eh.string}),Object.defineProperty(this,ln.SEQ,{value:Zf.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?th:null}clone(){let e=Object.create(cn.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}sh.Schema=cn});var qi=S(function(oh){var rh=C(),un=We(),Qe=Be();function ih(e,t){let s=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)s.push(l),n=!0;else if(e.directives.docStart)n=!0}if(n)s.push("---");let r=un.createStringifyContext(e,t),{commentString:i}=r.options;if(e.commentBefore){if(s.length!==1)s.unshift("");let l=i(e.commentBefore);s.unshift(Qe.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(rh.isNode(e.contents)){if(e.contents.spaceBefore&&n)s.push("");if(e.contents.commentBefore){let p=i(e.contents.commentBefore);s.push(Qe.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=un.stringify(e.contents,r,()=>a=null,l);if(a)c+=Qe.lineComment(c,"",i(a));if((c[0]==="|"||c[0]===">")&&s[s.length-1]==="---")s[s.length-1]=`--- ${c}`;else s.push(c)}else s.push(un.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=i(e.comment);if(l.includes(`
54
+ ${i.comment}`:n.comment}n=r}e.items[s]=Kt.isPair(n)?n:new Gs.Pair(n)}else t("Expected a sequence for this tag");return e}function hi(e,t,s){let{replacer:n}=s,r=new Wu.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,String(i++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Gs.createPair(a,l,s))}return r}var Hu={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:fi,createNode:hi};Yu.createPairs=hi;Yu.pairs=Hu;Yu.resolvePairs=fi});var zs=S(function(Qu){var pi=C(),Xs=ee(),Ge=ie(),Xu=oe(),mi=Wt();class ge extends Xu.YAMLSeq{constructor(){super();this.add=Ge.YAMLMap.prototype.add.bind(this),this.delete=Ge.YAMLMap.prototype.delete.bind(this),this.get=Ge.YAMLMap.prototype.get.bind(this),this.has=Ge.YAMLMap.prototype.has.bind(this),this.set=Ge.YAMLMap.prototype.set.bind(this),this.tag=ge.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;if(t?.onCreate)t.onCreate(s);for(let n of this.items){let r,i;if(pi.isPair(n))r=Xs.toJS(n.key,"",t),i=Xs.toJS(n.value,r,t);else r=Xs.toJS(n,"",t);if(s.has(r))throw Error("Ordered maps must not include duplicate keys");s.set(r,i)}return s}static from(e,t,s){let n=mi.createPairs(e,t,s),r=new this;return r.items=n.items,r}}ge.tag="tag:yaml.org,2002:omap";var zu={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=mi.resolvePairs(e,t),n=[];for(let{key:r}of s.items)if(pi.isScalar(r))if(n.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else n.push(r.value);return Object.assign(new ge,s)},createNode:(e,t,s)=>ge.from(e,t,s)};Qu.YAMLOMap=ge;Qu.omap=zu});var _i=S(function(tf){var gi=k();function yi({value:e,source:t},s){if(t&&(e?wi:bi).test.test(t))return t;return e?s.options.trueStr:s.options.falseStr}var wi={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new gi.Scalar(!0),stringify:yi},bi={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new gi.Scalar(!1),stringify:yi};tf.falseTag=bi;tf.trueTag=wi});var Si=S(function(cf){var rf=k(),Qs=Le(),of={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Qs.stringifyNumber},af={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Qs.stringifyNumber(e)}},lf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new rf.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let n=e.substring(s+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Qs.stringifyNumber};cf.float=lf;cf.floatExp=af;cf.floatNaN=of});var Ei=S(function(yf){var vi=Le(),Xe=(e)=>typeof e==="bigint"||Number.isInteger(e);function Ht(e,t,s,{intAsBigInt:n}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let i=parseInt(e,s);return r==="-"?-1*i:i}function Zs(e,t,s){let{value:n}=e;if(Xe(n)){let r=n.toString(t);return n<0?"-"+s+r.substr(1):s+r}return vi.stringifyNumber(e)}var hf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Ht(e,2,2,s),stringify:(e)=>Zs(e,2,"0b")},pf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Ht(e,1,8,s),stringify:(e)=>Zs(e,8,"0")},mf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Ht(e,0,10,s),stringify:vi.stringifyNumber},gf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Ht(e,2,16,s),stringify:(e)=>Zs(e,16,"0x")};yf.int=mf;yf.intBin=hf;yf.intHex=gf;yf.intOct=pf});var en=S(function(Ef){var Vt=C(),Yt=ne(),Jt=ie();class ye extends Jt.YAMLMap{constructor(e){super(e);this.tag=ye.tag}add(e){let t;if(Vt.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Yt.Pair(e.key,null);else t=new Yt.Pair(e,null);if(!Jt.findPair(this.items,t.key))this.items.push(t)}get(e,t){let s=Jt.findPair(this.items,e);return!t&&Vt.isPair(s)?Vt.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=Jt.findPair(this.items,e);if(s&&!t)this.items.splice(this.items.indexOf(s),1);else if(!s&&t)this.items.push(new Yt.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);else throw Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,i,i);r.items.push(Yt.createPair(i,null,s))}return r}}ye.tag="tag:yaml.org,2002:set";var vf={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ye,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>ye.from(e,t,s),resolve(e,t){if(Vt.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ye,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Ef.YAMLSet=ye;Ef.set=vf});var sn=S(function(xf){var Rf=Le();function tn(e,t){let s=e[0],n=s==="-"||s==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return s==="-"?r(-1)*i:i}function Ti(e){let{value:t}=e,s=(o)=>o;if(typeof t==="bigint")s=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Rf.stringifyNumber(e);let n="";if(t<0)n="-",t*=s(-1);let r=s(60),i=[t%r];if(t<60)i.unshift(0);else if(t=(t-i[0])/r,i.unshift(t%r),t>=60)t=(t-i[0])/r,i.unshift(t);return n+i.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Cf={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>tn(e,s),stringify:Ti},Nf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>tn(e,!1),stringify:Ti},Ai={identify:(e)=>e 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(e){let t=e.match(Ai.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,n,r,i,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,n-1,r,i||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let d=tn(p,!1);if(Math.abs(d)<30)d*=60;c-=60000*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};xf.floatTime=Nf;xf.intTime=Cf;xf.timestamp=Ai});var Ci=S(function(Kf){var If=xe(),Pf=Ut(),Mf=Oe(),Df=Je(),qf=Vs(),Ri=_i(),nn=Si(),Gt=Ei(),Ff=kt(),$f=zs(),Uf=Wt(),Bf=en(),rn=sn(),jf=[If.map,Mf.seq,Df.string,Pf.nullTag,Ri.trueTag,Ri.falseTag,Gt.intBin,Gt.intOct,Gt.int,Gt.intHex,nn.floatNaN,nn.floatExp,nn.float,qf.binary,Ff.merge,$f.omap,Uf.pairs,Bf.set,rn.intTime,rn.floatTime,rn.timestamp];Kf.schema=jf});var qi=S(function(Qf){var Li=xe(),Hf=Ut(),ki=Oe(),Yf=Je(),Jf=Us(),on=js(),an=Ws(),Vf=ci(),Gf=ui(),Ii=Vs(),ze=kt(),Pi=zs(),Mi=Wt(),Ni=Ci(),Di=en(),Xt=sn(),xi=new Map([["core",Vf.schema],["failsafe",[Li.map,ki.seq,Yf.string]],["json",Gf.schema],["yaml11",Ni.schema],["yaml-1.1",Ni.schema]]),Oi={binary:Ii.binary,bool:Jf.boolTag,float:on.float,floatExp:on.floatExp,floatNaN:on.floatNaN,floatTime:Xt.floatTime,int:an.int,intHex:an.intHex,intOct:an.intOct,intTime:Xt.intTime,map:Li.map,merge:ze.merge,null:Hf.nullTag,omap:Pi.omap,pairs:Mi.pairs,seq:ki.seq,set:Di.set,timestamp:Xt.timestamp},Xf={"tag:yaml.org,2002:binary":Ii.binary,"tag:yaml.org,2002:merge":ze.merge,"tag:yaml.org,2002:omap":Pi.omap,"tag:yaml.org,2002:pairs":Mi.pairs,"tag:yaml.org,2002:set":Di.set,"tag:yaml.org,2002:timestamp":Xt.timestamp};function zf(e,t,s){let n=xi.get(t);if(n&&!e)return s&&!n.includes(ze.merge)?n.concat(ze.merge):n.slice();let r=n;if(!r)if(Array.isArray(e))r=[];else{let i=Array.from(xi.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)r=r.concat(i);else if(typeof e==="function")r=e(r.slice());if(s)r=r.concat(ze.merge);return r.reduce((i,o)=>{let a=typeof o==="string"?Oi[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Oi).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!i.includes(a))i.push(a);return i},[])}Qf.coreKnownTags=Xf;Qf.getTags=zf});var dn=S(function(ih){var ln=C(),th=xe(),sh=Oe(),nh=Je(),zt=qi(),rh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class cn{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:r,sortMapEntries:i,toStringDefaults:o}){this.compat=Array.isArray(e)?zt.getTags(e,"compat"):e?zt.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=n?zt.coreKnownTags:{},this.tags=zt.getTags(t,this.name,s),this.toStringOptions=o??null,Object.defineProperty(this,ln.MAP,{value:th.map}),Object.defineProperty(this,ln.SCALAR,{value:nh.string}),Object.defineProperty(this,ln.SEQ,{value:sh.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?rh:null}clone(){let e=Object.create(cn.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}ih.Schema=cn});var Fi=S(function(ch){var ah=C(),un=We(),Qe=Be();function lh(e,t){let s=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)s.push(l),n=!0;else if(e.directives.docStart)n=!0}if(n)s.push("---");let r=un.createStringifyContext(e,t),{commentString:i}=r.options;if(e.commentBefore){if(s.length!==1)s.unshift("");let l=i(e.commentBefore);s.unshift(Qe.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(ah.isNode(e.contents)){if(e.contents.spaceBefore&&n)s.push("");if(e.contents.commentBefore){let p=i(e.contents.commentBefore);s.push(Qe.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=un.stringify(e.contents,r,()=>a=null,l);if(a)c+=Qe.lineComment(c,"",i(a));if((c[0]==="|"||c[0]===">")&&s[s.length-1]==="---")s[s.length-1]=`--- ${c}`;else s.push(c)}else s.push(un.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=i(e.comment);if(l.includes(`
55
55
  `))s.push("..."),s.push(Qe.indentComment(l,""));else s.push(`... ${l}`)}else s.push("...");else{let l=e.comment;if(l&&o)l=l.replace(/^\n+/,"");if(l){if((!o||a)&&s[s.length-1]!=="")s.push("");s.push(Qe.indentComment(i(l),""))}}return s.join(`
56
56
  `)+`
57
- `}oh.stringifyDocument=ih});var Ze=S(function(mh){var lh=$e(),ke=At(),U=C(),ch=ne(),dh=ee(),uh=dn(),fh=qi(),fn=Et(),hh=Os(),ph=Ue(),hn=xs();class pn{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,U.NODE_TYPE,{value:U.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=t,t=void 0;let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:i}=r;if(s?._directives){if(this.directives=s._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new hn.Directives({version:i});this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,n,s)}clone(){let e=Object.create(pn.prototype,{[U.NODE_TYPE]:{value:U.DOC}});if(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();if(e.schema=this.schema.clone(),e.contents=U.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Ie(this.contents))this.contents.add(e)}addIn(e,t){if(Ie(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=fn.anchorNames(this);e.anchor=!t||s.has(t)?fn.findNewAnchor(t||"a",s):t}return new lh.Alias(e.anchor)}createNode(e,t,s){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let f=(_)=>typeof _==="number"||_ instanceof String||_ instanceof Number,y=t.filter(f).map(String);if(y.length>0)t=t.concat(y);n=t}else if(s===void 0&&t)s=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:i,flow:o,keepUndefined:a,onTagObj:l,tag:c}=s??{},{onAnchor:p,setAnchors:d,sourceObjects:u}=fn.createNodeAnchors(this,i||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:u},w=ph.createNode(e,c,g);if(o&&U.isCollection(w))w.flow=!0;return d(),w}createPair(e,t,s={}){let n=this.createNode(e,null,s),r=this.createNode(t,null,s);return new ch.Pair(n,r)}delete(e){return Ie(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(ke.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Ie(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return U.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(ke.isEmptyPath(e))return!t&&U.isScalar(this.contents)?this.contents.value:this.contents;return U.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return U.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(ke.isEmptyPath(e))return this.contents!==void 0;return U.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,[e],t);else if(Ie(this.contents))this.contents.set(e,t)}setIn(e,t){if(ke.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,Array.from(e),t);else if(Ie(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let s;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new hn.Directives({version:"1.1"});s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new hn.Directives({version:e});s={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;s=null;break;default:{let n=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new uh.Schema(Object.assign(s,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:n,onAnchor:r,reviver:i}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},a=dh.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof i==="function"?hh.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return fh.stringifyDocument(this,e)}}function Ie(e){if(U.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}mh.Document=pn});var et=S(function(wh){class Qt extends Error{constructor(e,t,s,n){super();this.name=e,this.code=s,this.message=n,this.pos=t}}class Fi extends Qt{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class $i extends Qt{constructor(e,t,s){super("YAMLWarning",e,t,s)}}var yh=(e,t)=>(s)=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map((a)=>t.linePos(a));let{line:n,col:r}=s.linePos[0];s.message+=` at line ${n}, column ${r}`;let i=r-1,o=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="…"+o.substring(a),i-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(n>1&&/^ *$/.test(o.substring(0,i))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(a.length>80)a=a.substring(0,79)+`…
57
+ `}ch.stringifyDocument=lh});var Ze=S(function(wh){var uh=$e(),ke=At(),U=C(),fh=ne(),hh=ee(),ph=dn(),mh=Fi(),fn=vt(),gh=Os(),yh=Ue(),hn=xs();class pn{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,U.NODE_TYPE,{value:U.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=t,t=void 0;let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:i}=r;if(s?._directives){if(this.directives=s._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new hn.Directives({version:i});this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,n,s)}clone(){let e=Object.create(pn.prototype,{[U.NODE_TYPE]:{value:U.DOC}});if(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();if(e.schema=this.schema.clone(),e.contents=U.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Ie(this.contents))this.contents.add(e)}addIn(e,t){if(Ie(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=fn.anchorNames(this);e.anchor=!t||s.has(t)?fn.findNewAnchor(t||"a",s):t}return new uh.Alias(e.anchor)}createNode(e,t,s){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let f=(_)=>typeof _==="number"||_ instanceof String||_ instanceof Number,y=t.filter(f).map(String);if(y.length>0)t=t.concat(y);n=t}else if(s===void 0&&t)s=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:i,flow:o,keepUndefined:a,onTagObj:l,tag:c}=s??{},{onAnchor:p,setAnchors:d,sourceObjects:u}=fn.createNodeAnchors(this,i||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:u},w=yh.createNode(e,c,g);if(o&&U.isCollection(w))w.flow=!0;return d(),w}createPair(e,t,s={}){let n=this.createNode(e,null,s),r=this.createNode(t,null,s);return new fh.Pair(n,r)}delete(e){return Ie(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(ke.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Ie(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return U.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(ke.isEmptyPath(e))return!t&&U.isScalar(this.contents)?this.contents.value:this.contents;return U.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return U.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(ke.isEmptyPath(e))return this.contents!==void 0;return U.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,[e],t);else if(Ie(this.contents))this.contents.set(e,t)}setIn(e,t){if(ke.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,Array.from(e),t);else if(Ie(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let s;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new hn.Directives({version:"1.1"});s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new hn.Directives({version:e});s={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;s=null;break;default:{let n=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new ph.Schema(Object.assign(s,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:n,onAnchor:r,reviver:i}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},a=hh.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof i==="function"?gh.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return mh.stringifyDocument(this,e)}}function Ie(e){if(U.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}wh.Document=pn});var et=S(function(Sh){class Qt extends Error{constructor(e,t,s,n){super();this.name=e,this.code=s,this.message=n,this.pos=t}}class $i extends Qt{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class Ui extends Qt{constructor(e,t,s){super("YAMLWarning",e,t,s)}}var _h=(e,t)=>(s)=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map((a)=>t.linePos(a));let{line:n,col:r}=s.linePos[0];s.message+=` at line ${n}, column ${r}`;let i=r-1,o=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="…"+o.substring(a),i-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(n>1&&/^ *$/.test(o.substring(0,i))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(a.length>80)a=a.substring(0,79)+`…
58
58
  `;o=a+o}if(/[^ ]/.test(o)){let a=1,l=s.linePos[1];if(l?.line===n&&l.col>r)a=Math.max(1,Math.min(l.col-r,80-i));let c=" ".repeat(i)+"^".repeat(a);s.message+=`:
59
59
 
60
60
  ${o}
61
61
  ${c}
62
- `}};wh.YAMLError=Qt;wh.YAMLParseError=Fi;wh.YAMLWarning=$i;wh.prettifyError=yh});var tt=S(function(Th){function vh(e,{flow:t,indicator:s,next:n,offset:r,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,d="",u="",g=!1,w=!1,f=null,y=null,_=null,m=null,h=null,b=null,E=null;for(let v of e){if(w){if(v.type!=="space"&&v.type!=="newline"&&v.type!=="comma")i(v.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");w=!1}if(f){if(c&&v.type!=="comment"&&v.type!=="newline")i(f,"TAB_AS_INDENT","Tabs are not allowed as indentation");f=null}switch(v.type){case"space":if(!t&&(s!=="doc-start"||n?.type!=="flow-collection")&&v.source.includes("\t"))f=v;p=!0;break;case"comment":{if(!p)i(v,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let x=v.source.substring(1)||" ";if(!d)d=x;else d+=u+x;u="",c=!1;break}case"newline":if(c){if(d)d+=v.source;else if(!b||s!=="seq-item-ind")l=!0}else u+=v.source;if(c=!0,g=!0,y||_)m=v;p=!0;break;case"anchor":if(y)i(v,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(v.source.endsWith(":"))i(v.offset+v.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);y=v,E??(E=v.offset),c=!1,p=!1,w=!0;break;case"tag":{if(_)i(v,"MULTIPLE_TAGS","A node can have at most one tag");_=v,E??(E=v.offset),c=!1,p=!1,w=!0;break}case s:if(y||_)i(v,"BAD_PROP_ORDER",`Anchors and tags must be after the ${v.source} indicator`);if(b)i(v,"UNEXPECTED_TOKEN",`Unexpected ${v.source} in ${t??"collection"}`);b=v,c=s==="seq-item-ind"||s==="explicit-key-ind",p=!1;break;case"comma":if(t){if(h)i(v,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);h=v,c=!1,p=!1;break}default:i(v,"UNEXPECTED_TOKEN",`Unexpected ${v.type} token`),c=!1,p=!1}}let T=e[e.length-1],R=T?T.offset+T.source.length:r;if(w&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(f&&(c&&f.indent<=o||n?.type==="block-map"||n?.type==="block-seq"))i(f,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:h,found:b,spaceBefore:l,comment:d,hasNewline:g,anchor:y,tag:_,newlineAfterProp:m,end:R,start:E??R}}Th.resolveProps=vh});var Zt=S(function(Rh){function mn(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
63
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(mn(t.key)||mn(t.value))return!0}return!1;default:return!0}}Rh.containsNewline=mn});var gn=S(function(Oh){var Nh=Zt();function xh(e,t,s){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&Nh.containsNewline(t))s(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Oh.flowIndentCheck=xh});var yn=S(function(Ih){var Ui=C();function kh(e,t,s){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let r=typeof n==="function"?n:(i,o)=>i===o||Ui.isScalar(i)&&Ui.isScalar(o)&&i.value===o.value;return t.some((i)=>r(i.key,s))}Ih.mapIncludes=kh});var Hi=S(function($h){var Bi=ne(),Mh=ie(),ji=tt(),Dh=Zt(),Ki=gn(),qh=yn(),Wi="All mapping items must start at the same column";function Fh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Mh.YAMLMap)(s.schema);if(s.atRoot)s.atRoot=!1;let l=n.offset,c=null;for(let p of n.items){let{start:d,key:u,sep:g,value:w}=p,f=ji.resolveProps(d,{indicator:"explicit-key-ind",next:u??g?.[0],offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0}),y=!f.found;if(y){if(u){if(u.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in u&&u.indent!==n.indent)r(l,"BAD_INDENT",Wi)}if(!f.anchor&&!f.tag&&!g){if(c=f.end,f.comment)if(a.comment)a.comment+=`
64
- `+f.comment;else a.comment=f.comment;continue}if(f.newlineAfterProp||Dh.containsNewline(u))r(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(f.found?.indent!==n.indent)r(l,"BAD_INDENT",Wi);s.atKey=!0;let _=f.end,m=u?e(s,u,f,r):t(s,_,d,null,f,r);if(s.schema.compat)Ki.flowIndentCheck(n.indent,u,r);if(s.atKey=!1,qh.mapIncludes(s,a.items,m))r(_,"DUPLICATE_KEY","Map keys must be unique");let h=ji.resolveProps(g??[],{indicator:"map-value-ind",next:w,offset:m.range[2],onError:r,parentIndent:n.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=h.end,h.found){if(y){if(w?.type==="block-map"&&!h.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(s.options.strict&&f.start<h.found.offset-1024)r(m.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let b=w?e(s,w,h,r):t(s,l,g,null,h,r);if(s.schema.compat)Ki.flowIndentCheck(n.indent,w,r);l=b.range[2];let E=new Bi.Pair(m,b);if(s.options.keepSourceTokens)E.srcToken=p;a.items.push(E)}else{if(y)r(m.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(h.comment)if(m.comment)m.comment+=`
65
- `+h.comment;else m.comment=h.comment;let b=new Bi.Pair(m);if(s.options.keepSourceTokens)b.srcToken=p;a.items.push(b)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,l,c??l],a}$h.resolveBlockMap=Fh});var Yi=S(function(Hh){var Bh=oe(),jh=tt(),Kh=gn();function Wh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Bh.YAMLSeq)(s.schema);if(s.atRoot)s.atRoot=!1;if(s.atKey)s.atKey=!1;let l=n.offset,c=null;for(let{start:p,value:d}of n.items){let u=jh.resolveProps(p,{indicator:"seq-item-ind",next:d,offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)if(d?.type==="block-seq")r(u.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=u.end,u.comment)a.comment=u.comment;continue}let g=d?e(s,d,u,r):t(s,u.end,p,null,u,r);if(s.schema.compat)Kh.flowIndentCheck(n.indent,d,r);l=g.range[2],a.items.push(g)}return a.range=[n.offset,l,c??l],a}Hh.resolveBlockSeq=Wh});var Pe=S(function(Vh){function Jh(e,t,s,n){let r="";if(e){let i=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{if(s&&!i)n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;o="";break}case"newline":if(r)o+=l;i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}Vh.resolveEnd=Jh});var Xi=S(function(np){var Gh=C(),zh=ne(),Ji=ie(),Qh=oe(),Zh=Pe(),Vi=tt(),ep=Zt(),tp=yn(),wn="Block collections are not allowed within flow collections",bn=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function sp({composeNode:e,composeEmptyNode:t},s,n,r,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",c=new(i?.nodeClass??(o?Ji.YAMLMap:Qh.YAMLSeq))(s.schema);c.flow=!0;let p=s.atRoot;if(p)s.atRoot=!1;if(s.atKey)s.atKey=!1;let d=n.offset+n.start.source.length;for(let y=0;y<n.items.length;++y){let _=n.items[y],{start:m,key:h,sep:b,value:E}=_,T=Vi.resolveProps(m,{flow:a,indicator:"explicit-key-ind",next:h??b?.[0],offset:d,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!T.found){if(!T.anchor&&!T.tag&&!b&&!E){if(y===0&&T.comma)r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(y<n.items.length-1)r(T.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(T.comment)if(c.comment)c.comment+=`
66
- `+T.comment;else c.comment=T.comment;d=T.end;continue}if(!o&&s.options.strict&&ep.containsNewline(h))r(h,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0){if(T.comma)r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!T.comma)r(T.start,"MISSING_CHAR",`Missing , between ${a} items`);if(T.comment){let R="";e:for(let v of m)switch(v.type){case"comma":case"space":break;case"comment":R=v.source.substring(1);break e;default:break e}if(R){let v=c.items[c.items.length-1];if(Gh.isPair(v))v=v.value??v.key;if(v.comment)v.comment+=`
67
- `+R;else v.comment=R;T.comment=T.comment.substring(R.length+1)}}}if(!o&&!b&&!T.found){let R=E?e(s,E,T,r):t(s,T.end,b,null,T,r);if(c.items.push(R),d=R.range[2],bn(E))r(R.range,"BLOCK_IN_FLOW",wn)}else{s.atKey=!0;let R=T.end,v=h?e(s,h,T,r):t(s,R,m,null,T,r);if(bn(h))r(v.range,"BLOCK_IN_FLOW",wn);s.atKey=!1;let x=Vi.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:E,offset:v.range[2],onError:r,parentIndent:n.indent,startOnNewline:!1});if(x.found){if(!o&&!T.found&&s.options.strict){if(b)for(let I of b){if(I===x.found)break;if(I.type==="newline"){r(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(T.start<x.found.offset-1024)r(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(E)if("source"in E&&E.source?.[0]===":")r(E,"MISSING_CHAR",`Missing space after : in ${a}`);else r(x.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let Z=E?e(s,E,x,r):x.found?t(s,x.end,b,null,x,r):null;if(Z){if(bn(E))r(Z.range,"BLOCK_IN_FLOW",wn)}else if(x.comment)if(v.comment)v.comment+=`
68
- `+x.comment;else v.comment=x.comment;let _e=new zh.Pair(v,Z);if(s.options.keepSourceTokens)_e.srcToken=_;if(o){let I=c;if(tp.mapIncludes(s,I.items,v))r(R,"DUPLICATE_KEY","Map keys must be unique");I.items.push(_e)}else{let I=new Ji.YAMLMap(s.schema);I.flow=!0,I.items.push(_e);let Bn=(Z??v).range;I.range=[v.range[0],Bn[1],Bn[2]],c.items.push(I)}d=Z?Z.range[2]:x.end}}let u=o?"}":"]",[g,...w]=n.end,f=d;if(g?.source===u)f=g.offset+g.source.length;else{let y=a[0].toUpperCase()+a.substring(1),_=p?`${y} must end with a ${u}`:`${y} in block collection must be sufficiently indented and end with a ${u}`;if(r(d,p?"MISSING_CHAR":"BAD_INDENT",_),g&&g.source.length!==1)w.unshift(g)}if(w.length>0){let y=Zh.resolveEnd(w,f,s.options.strict,r);if(y.comment)if(c.comment)c.comment+=`
69
- `+y.comment;else c.comment=y.comment;c.range=[n.offset,f,y.offset]}else c.range=[n.offset,f,f];return c}np.resolveFlowCollection=sp});var Gi=S(function(hp){var ip=C(),op=k(),ap=ie(),lp=oe(),cp=Hi(),dp=Yi(),up=Xi();function _n(e,t,s,n,r,i){let o=s.type==="block-map"?cp.resolveBlockMap(e,t,s,n,i):s.type==="block-seq"?dp.resolveBlockSeq(e,t,s,n,i):up.resolveFlowCollection(e,t,s,n,i),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function fp(e,t,s,n,r){let i=n.tag,o=!i?null:t.directives.tagName(i.source,(u)=>r(i,"TAG_RESOLVE_FAILED",u));if(s.type==="block-seq"){let{anchor:u,newlineAfterProp:g}=n,w=u&&i?u.offset>i.offset?u:i:u??i;if(w&&(!g||g.offset<w.offset))r(w,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===ap.YAMLMap.tagName&&a==="map"||o===lp.YAMLSeq.tagName&&a==="seq")return _n(e,t,s,r,o);let l=t.schema.tags.find((u)=>u.tag===o&&u.collection===a);if(!l){let u=t.schema.knownTags[o];if(u?.collection===a)t.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else{if(u)r(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0);else r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return _n(e,t,s,r,o)}}let c=_n(e,t,s,r,o,l),p=l.resolve?.(c,(u)=>r(i,"TAG_RESOLVE_FAILED",u),t.options)??c,d=ip.isNode(p)?p:new op.Scalar(p);if(d.range=c.range,d.tag=o,l?.format)d.format=l.format;return d}hp.composeCollection=fp});var En=S(function(wp){var Sn=k();function mp(e,t,s){let n=t.offset,r=gp(t,e.options.strict,s);if(!r)return{value:"",type:null,comment:"",range:[n,n,n]};let i=r.mode===">"?Sn.Scalar.BLOCK_FOLDED:Sn.Scalar.BLOCK_LITERAL,o=t.source?yp(t.source):[],a=o.length;for(let f=o.length-1;f>=0;--f){let y=o[f][1];if(y===""||y==="\r")a=f;else break}if(a===0){let f=r.chomp==="+"&&o.length>0?`
62
+ `}};Sh.YAMLError=Qt;Sh.YAMLParseError=$i;Sh.YAMLWarning=Ui;Sh.prettifyError=_h});var tt=S(function(Ch){function Rh(e,{flow:t,indicator:s,next:n,offset:r,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,d="",u="",g=!1,w=!1,f=null,y=null,_=null,m=null,h=null,b=null,v=null;for(let E of e){if(w){if(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma")i(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");w=!1}if(f){if(c&&E.type!=="comment"&&E.type!=="newline")i(f,"TAB_AS_INDENT","Tabs are not allowed as indentation");f=null}switch(E.type){case"space":if(!t&&(s!=="doc-start"||n?.type!=="flow-collection")&&E.source.includes("\t"))f=E;p=!0;break;case"comment":{if(!p)i(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let x=E.source.substring(1)||" ";if(!d)d=x;else d+=u+x;u="",c=!1;break}case"newline":if(c){if(d)d+=E.source;else if(!b||s!=="seq-item-ind")l=!0}else u+=E.source;if(c=!0,g=!0,y||_)m=E;p=!0;break;case"anchor":if(y)i(E,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(E.source.endsWith(":"))i(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);y=E,v??(v=E.offset),c=!1,p=!1,w=!0;break;case"tag":{if(_)i(E,"MULTIPLE_TAGS","A node can have at most one tag");_=E,v??(v=E.offset),c=!1,p=!1,w=!0;break}case s:if(y||_)i(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`);if(b)i(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`);b=E,c=s==="seq-item-ind"||s==="explicit-key-ind",p=!1;break;case"comma":if(t){if(h)i(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);h=E,c=!1,p=!1;break}default:i(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),c=!1,p=!1}}let T=e[e.length-1],R=T?T.offset+T.source.length:r;if(w&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(f&&(c&&f.indent<=o||n?.type==="block-map"||n?.type==="block-seq"))i(f,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:h,found:b,spaceBefore:l,comment:d,hasNewline:g,anchor:y,tag:_,newlineAfterProp:m,end:R,start:v??R}}Ch.resolveProps=Rh});var Zt=S(function(xh){function mn(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
63
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(mn(t.key)||mn(t.value))return!0}return!1;default:return!0}}xh.containsNewline=mn});var gn=S(function(Ih){var Lh=Zt();function kh(e,t,s){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&Lh.containsNewline(t))s(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Ih.flowIndentCheck=kh});var yn=S(function(Dh){var Bi=C();function Mh(e,t,s){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let r=typeof n==="function"?n:(i,o)=>i===o||Bi.isScalar(i)&&Bi.isScalar(o)&&i.value===o.value;return t.some((i)=>r(i.key,s))}Dh.mapIncludes=Mh});var Yi=S(function(jh){var ji=ne(),Fh=ie(),Ki=tt(),$h=Zt(),Wi=gn(),Uh=yn(),Hi="All mapping items must start at the same column";function Bh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Fh.YAMLMap)(s.schema);if(s.atRoot)s.atRoot=!1;let l=n.offset,c=null;for(let p of n.items){let{start:d,key:u,sep:g,value:w}=p,f=Ki.resolveProps(d,{indicator:"explicit-key-ind",next:u??g?.[0],offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0}),y=!f.found;if(y){if(u){if(u.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in u&&u.indent!==n.indent)r(l,"BAD_INDENT",Hi)}if(!f.anchor&&!f.tag&&!g){if(c=f.end,f.comment)if(a.comment)a.comment+=`
64
+ `+f.comment;else a.comment=f.comment;continue}if(f.newlineAfterProp||$h.containsNewline(u))r(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(f.found?.indent!==n.indent)r(l,"BAD_INDENT",Hi);s.atKey=!0;let _=f.end,m=u?e(s,u,f,r):t(s,_,d,null,f,r);if(s.schema.compat)Wi.flowIndentCheck(n.indent,u,r);if(s.atKey=!1,Uh.mapIncludes(s,a.items,m))r(_,"DUPLICATE_KEY","Map keys must be unique");let h=Ki.resolveProps(g??[],{indicator:"map-value-ind",next:w,offset:m.range[2],onError:r,parentIndent:n.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=h.end,h.found){if(y){if(w?.type==="block-map"&&!h.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(s.options.strict&&f.start<h.found.offset-1024)r(m.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let b=w?e(s,w,h,r):t(s,l,g,null,h,r);if(s.schema.compat)Wi.flowIndentCheck(n.indent,w,r);l=b.range[2];let v=new ji.Pair(m,b);if(s.options.keepSourceTokens)v.srcToken=p;a.items.push(v)}else{if(y)r(m.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(h.comment)if(m.comment)m.comment+=`
65
+ `+h.comment;else m.comment=h.comment;let b=new ji.Pair(m);if(s.options.keepSourceTokens)b.srcToken=p;a.items.push(b)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,l,c??l],a}jh.resolveBlockMap=Bh});var Ji=S(function(Vh){var Wh=oe(),Hh=tt(),Yh=gn();function Jh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Wh.YAMLSeq)(s.schema);if(s.atRoot)s.atRoot=!1;if(s.atKey)s.atKey=!1;let l=n.offset,c=null;for(let{start:p,value:d}of n.items){let u=Hh.resolveProps(p,{indicator:"seq-item-ind",next:d,offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)if(d?.type==="block-seq")r(u.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=u.end,u.comment)a.comment=u.comment;continue}let g=d?e(s,d,u,r):t(s,u.end,p,null,u,r);if(s.schema.compat)Yh.flowIndentCheck(n.indent,d,r);l=g.range[2],a.items.push(g)}return a.range=[n.offset,l,c??l],a}Vh.resolveBlockSeq=Jh});var Pe=S(function(zh){function Xh(e,t,s,n){let r="";if(e){let i=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{if(s&&!i)n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;o="";break}case"newline":if(r)o+=l;i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}zh.resolveEnd=Xh});var Xi=S(function(op){var Zh=C(),ep=ne(),Vi=ie(),tp=oe(),sp=Pe(),Gi=tt(),np=Zt(),rp=yn(),wn="Block collections are not allowed within flow collections",bn=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function ip({composeNode:e,composeEmptyNode:t},s,n,r,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",c=new(i?.nodeClass??(o?Vi.YAMLMap:tp.YAMLSeq))(s.schema);c.flow=!0;let p=s.atRoot;if(p)s.atRoot=!1;if(s.atKey)s.atKey=!1;let d=n.offset+n.start.source.length;for(let y=0;y<n.items.length;++y){let _=n.items[y],{start:m,key:h,sep:b,value:v}=_,T=Gi.resolveProps(m,{flow:a,indicator:"explicit-key-ind",next:h??b?.[0],offset:d,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!T.found){if(!T.anchor&&!T.tag&&!b&&!v){if(y===0&&T.comma)r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(y<n.items.length-1)r(T.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(T.comment)if(c.comment)c.comment+=`
66
+ `+T.comment;else c.comment=T.comment;d=T.end;continue}if(!o&&s.options.strict&&np.containsNewline(h))r(h,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0){if(T.comma)r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!T.comma)r(T.start,"MISSING_CHAR",`Missing , between ${a} items`);if(T.comment){let R="";e:for(let E of m)switch(E.type){case"comma":case"space":break;case"comment":R=E.source.substring(1);break e;default:break e}if(R){let E=c.items[c.items.length-1];if(Zh.isPair(E))E=E.value??E.key;if(E.comment)E.comment+=`
67
+ `+R;else E.comment=R;T.comment=T.comment.substring(R.length+1)}}}if(!o&&!b&&!T.found){let R=v?e(s,v,T,r):t(s,T.end,b,null,T,r);if(c.items.push(R),d=R.range[2],bn(v))r(R.range,"BLOCK_IN_FLOW",wn)}else{s.atKey=!0;let R=T.end,E=h?e(s,h,T,r):t(s,R,m,null,T,r);if(bn(h))r(E.range,"BLOCK_IN_FLOW",wn);s.atKey=!1;let x=Gi.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:v,offset:E.range[2],onError:r,parentIndent:n.indent,startOnNewline:!1});if(x.found){if(!o&&!T.found&&s.options.strict){if(b)for(let I of b){if(I===x.found)break;if(I.type==="newline"){r(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(T.start<x.found.offset-1024)r(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(v)if("source"in v&&v.source?.[0]===":")r(v,"MISSING_CHAR",`Missing space after : in ${a}`);else r(x.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let Z=v?e(s,v,x,r):x.found?t(s,x.end,b,null,x,r):null;if(Z){if(bn(v))r(Z.range,"BLOCK_IN_FLOW",wn)}else if(x.comment)if(E.comment)E.comment+=`
68
+ `+x.comment;else E.comment=x.comment;let _e=new ep.Pair(E,Z);if(s.options.keepSourceTokens)_e.srcToken=_;if(o){let I=c;if(rp.mapIncludes(s,I.items,E))r(R,"DUPLICATE_KEY","Map keys must be unique");I.items.push(_e)}else{let I=new Vi.YAMLMap(s.schema);I.flow=!0,I.items.push(_e);let Bn=(Z??E).range;I.range=[E.range[0],Bn[1],Bn[2]],c.items.push(I)}d=Z?Z.range[2]:x.end}}let u=o?"}":"]",[g,...w]=n.end,f=d;if(g?.source===u)f=g.offset+g.source.length;else{let y=a[0].toUpperCase()+a.substring(1),_=p?`${y} must end with a ${u}`:`${y} in block collection must be sufficiently indented and end with a ${u}`;if(r(d,p?"MISSING_CHAR":"BAD_INDENT",_),g&&g.source.length!==1)w.unshift(g)}if(w.length>0){let y=sp.resolveEnd(w,f,s.options.strict,r);if(y.comment)if(c.comment)c.comment+=`
69
+ `+y.comment;else c.comment=y.comment;c.range=[n.offset,f,y.offset]}else c.range=[n.offset,f,f];return c}op.resolveFlowCollection=ip});var zi=S(function(gp){var lp=C(),cp=k(),dp=ie(),up=oe(),fp=Yi(),hp=Ji(),pp=Xi();function _n(e,t,s,n,r,i){let o=s.type==="block-map"?fp.resolveBlockMap(e,t,s,n,i):s.type==="block-seq"?hp.resolveBlockSeq(e,t,s,n,i):pp.resolveFlowCollection(e,t,s,n,i),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function mp(e,t,s,n,r){let i=n.tag,o=!i?null:t.directives.tagName(i.source,(u)=>r(i,"TAG_RESOLVE_FAILED",u));if(s.type==="block-seq"){let{anchor:u,newlineAfterProp:g}=n,w=u&&i?u.offset>i.offset?u:i:u??i;if(w&&(!g||g.offset<w.offset))r(w,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===dp.YAMLMap.tagName&&a==="map"||o===up.YAMLSeq.tagName&&a==="seq")return _n(e,t,s,r,o);let l=t.schema.tags.find((u)=>u.tag===o&&u.collection===a);if(!l){let u=t.schema.knownTags[o];if(u?.collection===a)t.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else{if(u)r(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0);else r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return _n(e,t,s,r,o)}}let c=_n(e,t,s,r,o,l),p=l.resolve?.(c,(u)=>r(i,"TAG_RESOLVE_FAILED",u),t.options)??c,d=lp.isNode(p)?p:new cp.Scalar(p);if(d.range=c.range,d.tag=o,l?.format)d.format=l.format;return d}gp.composeCollection=mp});var vn=S(function(Sp){var Sn=k();function wp(e,t,s){let n=t.offset,r=bp(t,e.options.strict,s);if(!r)return{value:"",type:null,comment:"",range:[n,n,n]};let i=r.mode===">"?Sn.Scalar.BLOCK_FOLDED:Sn.Scalar.BLOCK_LITERAL,o=t.source?_p(t.source):[],a=o.length;for(let f=o.length-1;f>=0;--f){let y=o[f][1];if(y===""||y==="\r")a=f;else break}if(a===0){let f=r.chomp==="+"&&o.length>0?`
70
70
  `.repeat(Math.max(1,o.length-1)):"",y=n+r.length;if(t.source)y+=t.source.length;return{value:f,type:i,comment:r.comment,range:[n,y,y]}}let l=t.indent+r.indent,c=t.offset+r.length,p=0;for(let f=0;f<a;++f){let[y,_]=o[f];if(_===""||_==="\r"){if(r.indent===0&&y.length>l)l=y.length}else{if(y.length<l)s(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(r.indent===0)l=y.length;if(p=f,l===0&&!e.atRoot)s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+_.length+1}for(let f=o.length-1;f>=a;--f)if(o[f][0].length>l)a=f+1;let d="",u="",g=!1;for(let f=0;f<p;++f)d+=o[f][0].slice(l)+`
71
71
  `;for(let f=p;f<a;++f){let[y,_]=o[f];c+=y.length+_.length+1;let m=_[_.length-1]==="\r";if(m)_=_.slice(0,-1);if(_&&y.length<l){let b=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;s(c-_.length-(m?2:1),"BAD_INDENT",b),y=""}if(i===Sn.Scalar.BLOCK_LITERAL)d+=u+y.slice(l)+_,u=`
72
72
  `;else if(y.length>l||_[0]==="\t"){if(u===" ")u=`
@@ -81,41 +81,41 @@ ${c}
81
81
  `+o[f][0].slice(l);if(d[d.length-1]!==`
82
82
  `)d+=`
83
83
  `;break;default:d+=`
84
- `}let w=n+r.length+t.source.length;return{value:d,type:i,comment:r.comment,range:[n,w,w]}}function gp({offset:e,props:t},s,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=t[0],i=r[0],o=0,a="",l=-1;for(let u=1;u<r.length;++u){let g=r[u];if(!a&&(g==="-"||g==="+"))a=g;else{let w=Number(g);if(!o&&w)o=w;else if(l===-1)l=e+u}}if(l!==-1)n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,p="",d=r.length;for(let u=1;u<t.length;++u){let g=t[u];switch(g.type){case"space":c=!0;case"newline":d+=g.source.length;break;case"comment":if(s&&!c)n(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=g.source.length,p=g.source.substring(1);break;case"error":n(g,"UNEXPECTED_TOKEN",g.message),d+=g.source.length;break;default:{let w=`Unexpected token in block scalar header: ${g.type}`;n(g,"UNEXPECTED_TOKEN",w);let f=g.source;if(f&&typeof f==="string")d+=f.length}}}return{mode:i,indent:o,chomp:a,comment:p,length:d}}function yp(e){let t=e.split(/\n( *)/),s=t[0],n=s.match(/^( *)/),i=[n?.[1]?[n[1],s.slice(n[1].length)]:["",s]];for(let o=1;o<t.length;o+=2)i.push([t[o],t[o+1]]);return i}wp.resolveBlockScalar=mp});var Tn=S(function(Np){var vn=k(),_p=Pe();function Sp(e,t,s){let{offset:n,type:r,source:i,end:o}=e,a,l,c=(u,g,w)=>s(n+u,g,w);switch(r){case"scalar":a=vn.Scalar.PLAIN,l=Ep(i,c);break;case"single-quoted-scalar":a=vn.Scalar.QUOTE_SINGLE,l=vp(i,c);break;case"double-quoted-scalar":a=vn.Scalar.QUOTE_DOUBLE,l=Tp(i,c);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let p=n+i.length,d=_p.resolveEnd(o,p,t,s);return{value:l,type:a,comment:d.comment,range:[n,p,d.offset]}}function Ep(e,t){let s="";switch(e[0]){case"\t":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":{s=`block scalar indicator ${e[0]}`;break}case"@":case"`":{s=`reserved character ${e[0]}`;break}}if(s)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`);return zi(e)}function vp(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return zi(e.slice(1,-1)).replace(/''/g,"'")}function zi(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
84
+ `}let w=n+r.length+t.source.length;return{value:d,type:i,comment:r.comment,range:[n,w,w]}}function bp({offset:e,props:t},s,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=t[0],i=r[0],o=0,a="",l=-1;for(let u=1;u<r.length;++u){let g=r[u];if(!a&&(g==="-"||g==="+"))a=g;else{let w=Number(g);if(!o&&w)o=w;else if(l===-1)l=e+u}}if(l!==-1)n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,p="",d=r.length;for(let u=1;u<t.length;++u){let g=t[u];switch(g.type){case"space":c=!0;case"newline":d+=g.source.length;break;case"comment":if(s&&!c)n(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=g.source.length,p=g.source.substring(1);break;case"error":n(g,"UNEXPECTED_TOKEN",g.message),d+=g.source.length;break;default:{let w=`Unexpected token in block scalar header: ${g.type}`;n(g,"UNEXPECTED_TOKEN",w);let f=g.source;if(f&&typeof f==="string")d+=f.length}}}return{mode:i,indent:o,chomp:a,comment:p,length:d}}function _p(e){let t=e.split(/\n( *)/),s=t[0],n=s.match(/^( *)/),i=[n?.[1]?[n[1],s.slice(n[1].length)]:["",s]];for(let o=1;o<t.length;o+=2)i.push([t[o],t[o+1]]);return i}Sp.resolveBlockScalar=wp});var Tn=S(function(Lp){var En=k(),Ep=Pe();function Tp(e,t,s){let{offset:n,type:r,source:i,end:o}=e,a,l,c=(u,g,w)=>s(n+u,g,w);switch(r){case"scalar":a=En.Scalar.PLAIN,l=Ap(i,c);break;case"single-quoted-scalar":a=En.Scalar.QUOTE_SINGLE,l=Rp(i,c);break;case"double-quoted-scalar":a=En.Scalar.QUOTE_DOUBLE,l=Cp(i,c);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let p=n+i.length,d=Ep.resolveEnd(o,p,t,s);return{value:l,type:a,comment:d.comment,range:[n,p,d.offset]}}function Ap(e,t){let s="";switch(e[0]){case"\t":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":{s=`block scalar indicator ${e[0]}`;break}case"@":case"`":{s=`reserved character ${e[0]}`;break}}if(s)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`);return Qi(e)}function Rp(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Qi(e.slice(1,-1)).replace(/''/g,"'")}function Qi(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
85
  `,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
86
86
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let r=n[1],i=" ",o=t.lastIndex;s.lastIndex=o;while(n=s.exec(e)){if(n[1]==="")if(i===`
87
87
  `)r+=i;else i=`
88
- `;else r+=i+n[1],i=" ";o=s.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(e),r+i+(n?.[1]??"")}function Tp(e,t){let s="";for(let n=1;n<e.length-1;++n){let r=e[n];if(r==="\r"&&e[n+1]===`
88
+ `;else r+=i+n[1],i=" ";o=s.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=o,n=a.exec(e),r+i+(n?.[1]??"")}function Cp(e,t){let s="";for(let n=1;n<e.length-1;++n){let r=e[n];if(r==="\r"&&e[n+1]===`
89
89
  `)continue;if(r===`
90
- `){let{fold:i,offset:o}=Ap(e,n);s+=i,n=o}else if(r==="\\"){let i=e[++n],o=Rp[i];if(o)s+=o;else if(i===`
90
+ `){let{fold:i,offset:o}=Np(e,n);s+=i,n=o}else if(r==="\\"){let i=e[++n],o=xp[i];if(o)s+=o;else if(i===`
91
91
  `){i=e[n+1];while(i===" "||i==="\t")i=e[++n+1]}else if(i==="\r"&&e[n+1]===`
92
- `){i=e[++n+1];while(i===" "||i==="\t")i=e[++n+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;s+=Cp(e,n+1,a,t),n+=a}else{let a=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),s+=a}}else if(r===" "||r==="\t"){let i=n,o=e[n+1];while(o===" "||o==="\t")o=e[++n+1];if(o!==`
92
+ `){i=e[++n+1];while(i===" "||i==="\t")i=e[++n+1]}else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;s+=Op(e,n+1,a,t),n+=a}else{let a=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),s+=a}}else if(r===" "||r==="\t"){let i=n,o=e[n+1];while(o===" "||o==="\t")o=e[++n+1];if(o!==`
93
93
  `&&!(o==="\r"&&e[n+2]===`
94
- `))s+=n>i?e.slice(i,n+1):r}else s+=r}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return s}function Ap(e,t){let s="",n=e[t+1];while(n===" "||n==="\t"||n===`
94
+ `))s+=n>i?e.slice(i,n+1):r}else s+=r}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return s}function Np(e,t){let s="",n=e[t+1];while(n===" "||n==="\t"||n===`
95
95
  `||n==="\r"){if(n==="\r"&&e[t+2]!==`
96
96
  `)break;if(n===`
97
97
  `)s+=`
98
- `;t+=1,n=e[t+1]}if(!s)s=" ";return{fold:s,offset:t}}var Rp={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
- `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Cp(e,t,s,n){let r=e.substr(t,s),o=r.length===s&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,s+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Np.resolveFlowScalar=Sp});var Zi=S(function(Mp){var we=C(),Qi=k(),Op=En(),Lp=Tn();function kp(e,t,s,n){let{value:r,type:i,comment:o,range:a}=t.type==="block-scalar"?Op.resolveBlockScalar(e,t,n):Lp.resolveFlowScalar(t,e.options.strict,n),l=s?e.directives.tagName(s.source,(d)=>n(s,"TAG_RESOLVE_FAILED",d)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[we.SCALAR];else if(l)c=Ip(e.schema,r,l,s,n);else if(t.type==="scalar")c=Pp(e,r,t,n);else c=e.schema[we.SCALAR];let p;try{let d=c.resolve(r,(u)=>n(s??t,"TAG_RESOLVE_FAILED",u),e.options);p=we.isScalar(d)?d:new Qi.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);n(s??t,"TAG_RESOLVE_FAILED",u),p=new Qi.Scalar(r)}if(p.range=a,p.source=r,i)p.type=i;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function Ip(e,t,s,n,r){if(s==="!")return e[we.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let o=e.knownTags[s];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[we.SCALAR]}function Pp({atKey:e,directives:t,schema:s},n,r,i){let o=s.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||s[we.SCALAR];if(s.compat){let a=s.compat.find((l)=>l.default&&l.test?.test(n))??s[we.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;i(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}Mp.composeScalar=kp});var eo=S(function(Fp){function qp(e,t,s){if(t){s??(s=t.length);for(let n=s-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++n];while(r?.type==="space")e+=r.source.length,r=t[++n];break}}return e}Fp.emptyScalarPosition=qp});var no=S(function(Jp){var Up=$e(),Bp=C(),jp=Gi(),to=Zi(),Kp=Pe(),Wp=eo(),Hp={composeNode:so,composeEmptyNode:An};function so(e,t,s,n){let r=e.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=s,c,p=!0;switch(t.type){case"alias":if(c=Yp(e,t,n),a||l)n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=to.composeScalar(e,t,l,n),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=jp.composeCollection(Hp,e,t,s,n),a)c.anchor=a.source.substring(1)}catch(d){let u=d instanceof Error?d.message:String(d);n(t,"RESOURCE_EXHAUSTION",u)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",d),p=!1}}if(c??(c=An(e,t.offset,void 0,null,s,n)),a&&c.anchor==="")n(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!Bp.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))n(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function An(e,t,s,n,{spaceBefore:r,comment:i,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:Wp.emptyScalarPosition(t,s,n),indent:-1,source:""},d=to.composeScalar(e,p,a,c);if(o){if(d.anchor=o.source.substring(1),d.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)d.spaceBefore=!0;if(i)d.comment=i,d.range[2]=l;return d}function Yp({options:e},{offset:t,source:s,end:n},r){let i=new Up.Alias(s.substring(1));if(i.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))r(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+s.length,a=Kp.resolveEnd(n,o,e.strict,r);if(i.range=[t,o,a.offset],a.comment)i.comment=a.comment;return i}Jp.composeEmptyNode=An;Jp.composeNode=so});var io=S(function(em){var Gp=Ze(),ro=no(),zp=Pe(),Qp=tt();function Zp(e,t,{offset:s,start:n,value:r,end:i},o){let a=Object.assign({_directives:t},e),l=new Gp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=Qp.resolveProps(n,{indicator:"doc-start",next:r??i?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?ro.composeNode(c,r,p,o):ro.composeEmptyNode(c,p.end,n,null,p,o);let d=l.contents.range[2],u=zp.resolveEnd(i,d,!1,o);if(u.comment)l.comment=u.comment;return l.range=[s,d,u.offset],l}em.composeDoc=Zp});var Rn=S(function(am){var sm=ot("process"),nm=xs(),rm=Ze(),st=et(),oo=C(),im=io(),om=Pe();function nt(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s==="string"?s.length:1)]}function ao(e){let t="",s=!1,n=!1;for(let r=0;r<e.length;++r){let i=e[r];switch(i[0]){case"#":t+=(t===""?"":n?`
98
+ `;t+=1,n=e[t+1]}if(!s)s=" ";return{fold:s,offset:t}}var xp={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Op(e,t,s,n){let r=e.substr(t,s),o=r.length===s&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,s+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Lp.resolveFlowScalar=Tp});var eo=S(function(Fp){var we=C(),Zi=k(),Ip=vn(),Pp=Tn();function Mp(e,t,s,n){let{value:r,type:i,comment:o,range:a}=t.type==="block-scalar"?Ip.resolveBlockScalar(e,t,n):Pp.resolveFlowScalar(t,e.options.strict,n),l=s?e.directives.tagName(s.source,(d)=>n(s,"TAG_RESOLVE_FAILED",d)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[we.SCALAR];else if(l)c=Dp(e.schema,r,l,s,n);else if(t.type==="scalar")c=qp(e,r,t,n);else c=e.schema[we.SCALAR];let p;try{let d=c.resolve(r,(u)=>n(s??t,"TAG_RESOLVE_FAILED",u),e.options);p=we.isScalar(d)?d:new Zi.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);n(s??t,"TAG_RESOLVE_FAILED",u),p=new Zi.Scalar(r)}if(p.range=a,p.source=r,i)p.type=i;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function Dp(e,t,s,n,r){if(s==="!")return e[we.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let o=e.knownTags[s];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[we.SCALAR]}function qp({atKey:e,directives:t,schema:s},n,r,i){let o=s.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||s[we.SCALAR];if(s.compat){let a=s.compat.find((l)=>l.default&&l.test?.test(n))??s[we.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;i(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}Fp.composeScalar=Mp});var to=S(function(Bp){function Up(e,t,s){if(t){s??(s=t.length);for(let n=s-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++n];while(r?.type==="space")e+=r.source.length,r=t[++n];break}}return e}Bp.emptyScalarPosition=Up});var ro=S(function(Xp){var Kp=$e(),Wp=C(),Hp=zi(),so=eo(),Yp=Pe(),Jp=to(),Vp={composeNode:no,composeEmptyNode:An};function no(e,t,s,n){let r=e.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=s,c,p=!0;switch(t.type){case"alias":if(c=Gp(e,t,n),a||l)n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=so.composeScalar(e,t,l,n),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=Hp.composeCollection(Vp,e,t,s,n),a)c.anchor=a.source.substring(1)}catch(d){let u=d instanceof Error?d.message:String(d);n(t,"RESOURCE_EXHAUSTION",u)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",d),p=!1}}if(c??(c=An(e,t.offset,void 0,null,s,n)),a&&c.anchor==="")n(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!Wp.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))n(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function An(e,t,s,n,{spaceBefore:r,comment:i,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:Jp.emptyScalarPosition(t,s,n),indent:-1,source:""},d=so.composeScalar(e,p,a,c);if(o){if(d.anchor=o.source.substring(1),d.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)d.spaceBefore=!0;if(i)d.comment=i,d.range[2]=l;return d}function Gp({options:e},{offset:t,source:s,end:n},r){let i=new Kp.Alias(s.substring(1));if(i.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))r(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+s.length,a=Yp.resolveEnd(n,o,e.strict,r);if(i.range=[t,o,a.offset],a.comment)i.comment=a.comment;return i}Xp.composeEmptyNode=An;Xp.composeNode=no});var oo=S(function(nm){var Zp=Ze(),io=ro(),em=Pe(),tm=tt();function sm(e,t,{offset:s,start:n,value:r,end:i},o){let a=Object.assign({_directives:t},e),l=new Zp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=tm.resolveProps(n,{indicator:"doc-start",next:r??i?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?io.composeNode(c,r,p,o):io.composeEmptyNode(c,p.end,n,null,p,o);let d=l.contents.range[2],u=em.resolveEnd(i,d,!1,o);if(u.comment)l.comment=u.comment;return l.range=[s,d,u.offset],l}nm.composeDoc=sm});var Rn=S(function(dm){var im=ot("process"),om=xs(),am=Ze(),st=et(),ao=C(),lm=oo(),cm=Pe();function nt(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s==="string"?s.length:1)]}function lo(e){let t="",s=!1,n=!1;for(let r=0;r<e.length;++r){let i=e[r];switch(i[0]){case"#":t+=(t===""?"":n?`
100
100
 
101
101
  `:`
102
- `)+(i.substring(1)||" "),s=!0,n=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;s=!1;break;default:if(!s)n=!0;s=!1}}return{comment:t,afterEmptyLine:n}}class lo{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,n,r)=>{let i=nt(t);if(r)this.warnings.push(new st.YAMLWarning(i,s,n));else this.errors.push(new st.YAMLParseError(i,s,n))},this.directives=new nm.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:n}=ao(this.prelude);if(s){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
- ${s}`:s;else if(n||e.directives.docStart||!r)e.commentBefore=s;else if(oo.isCollection(r)&&!r.flow&&r.items.length>0){let i=r.items[0];if(oo.isPair(i))i=i.key;let o=i.commentBefore;i.commentBefore=o?`${s}
102
+ `)+(i.substring(1)||" "),s=!0,n=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;s=!1;break;default:if(!s)n=!0;s=!1}}return{comment:t,afterEmptyLine:n}}class co{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,n,r)=>{let i=nt(t);if(r)this.warnings.push(new st.YAMLWarning(i,s,n));else this.errors.push(new st.YAMLParseError(i,s,n))},this.directives=new om.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:n}=lo(this.prelude);if(s){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
+ ${s}`:s;else if(n||e.directives.docStart||!r)e.commentBefore=s;else if(ao.isCollection(r)&&!r.flow&&r.items.length>0){let i=r.items[0];if(ao.isPair(i))i=i.key;let o=i.commentBefore;i.commentBefore=o?`${s}
104
104
  ${o}`:s}else{let i=r.commentBefore;r.commentBefore=i?`${s}
105
- ${i}`:s}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ao(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let n of e)yield*this.next(n);yield*this.end(t,s)}*next(e){if(sm.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,s,n)=>{let r=nt(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=im.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(s);else this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){this.errors.push(new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=om.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
106
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),n=new rm.Document(void 0,s);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}am.Composer=lo});var fo=S(function(gm){var cm=En(),dm=Tn(),um=et(),co=Ke();function fm(e,t=!0,s){if(e){let n=(r,i,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(s)s(a,i,o);else throw new um.YAMLParseError([a,a+1],i,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return dm.resolveFlowScalar(e,t,n);case"block-scalar":return cm.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function hm(e,t){let{implicitKey:s=!1,indent:n,inFlow:r=!1,offset:i=-1,type:o="PLAIN"}=t,a=co.stringifyString({type:o,value:e},{implicitKey:s,indent:n>0?" ".repeat(n):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:n,source:`
105
+ ${i}`:s}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:lo(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let n of e)yield*this.next(n);yield*this.end(t,s)}*next(e){if(im.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,s,n)=>{let r=nt(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=lm.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(s);else this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){this.errors.push(new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=cm.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
106
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),n=new am.Document(void 0,s);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}dm.Composer=co});var ho=S(function(bm){var fm=vn(),hm=Tn(),pm=et(),uo=Ke();function mm(e,t=!0,s){if(e){let n=(r,i,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(s)s(a,i,o);else throw new pm.YAMLParseError([a,a+1],i,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hm.resolveFlowScalar(e,t,n);case"block-scalar":return fm.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function gm(e,t){let{implicitKey:s=!1,indent:n,inFlow:r=!1,offset:i=-1,type:o="PLAIN"}=t,a=uo.stringifyString({type:o,value:e},{implicitKey:s,indent:n>0?" ".repeat(n):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:n,source:`
107
107
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
108
108
  `),p=a.substring(0,c),d=a.substring(c+1)+`
109
- `,u=[{type:"block-scalar-header",offset:i,indent:n,source:p}];if(!uo(u,l))u.push({type:"newline",offset:-1,indent:n,source:`
110
- `});return{type:"block-scalar",offset:i,indent:n,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:l};default:return{type:"scalar",offset:i,indent:n,source:a,end:l}}}function pm(e,t,s={}){let{afterKey:n=!1,implicitKey:r=!1,inFlow:i=!1,type:o}=s,a="indent"in e?e.indent:null;if(n&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=co.stringifyString({type:o,value:t},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":mm(e,l);break;case'"':Cn(e,l,"double-quoted-scalar");break;case"'":Cn(e,l,"single-quoted-scalar");break;default:Cn(e,l,"scalar")}}function mm(e,t){let s=t.indexOf(`
109
+ `,u=[{type:"block-scalar-header",offset:i,indent:n,source:p}];if(!fo(u,l))u.push({type:"newline",offset:-1,indent:n,source:`
110
+ `});return{type:"block-scalar",offset:i,indent:n,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:l};default:return{type:"scalar",offset:i,indent:n,source:a,end:l}}}function ym(e,t,s={}){let{afterKey:n=!1,implicitKey:r=!1,inFlow:i=!1,type:o}=s,a="indent"in e?e.indent:null;if(n&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=uo.stringifyString({type:o,value:t},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":wm(e,l);break;case'"':Cn(e,l,"double-quoted-scalar");break;case"'":Cn(e,l,"single-quoted-scalar");break;default:Cn(e,l,"scalar")}}function wm(e,t){let s=t.indexOf(`
111
111
  `),n=t.substring(0,s),r=t.substring(s+1)+`
112
- `;if(e.type==="block-scalar"){let i=e.props[0];if(i.type!=="block-scalar-header")throw Error("Invalid block scalar header");i.source=n,e.source=r}else{let{offset:i}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];if(!uo(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
113
- `});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function uo(e,t){if(t)for(let s of t)switch(s.type){case"space":case"comment":e.push(s);break;case"newline":return e.push(s),!0}return!1}function Cn(e,t,s){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=s,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),r=t.length;if(e.props[0].type==="block-scalar-header")r-=e.props[0].source.length;for(let i of n)i.offset+=r;delete e.props,Object.assign(e,{type:s,source:t,end:n});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
114
- `};delete e.items,Object.assign(e,{type:s,source:t,end:[r]});break}default:{let n="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:s,indent:n,source:t,end:r})}}}gm.createScalarToken=hm;gm.resolveAsScalar=fm;gm.setScalarValue=pm});var ho=S(function(Sm){var _m=(e)=>("type"in e)?ts(e):es(e);function ts(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ts(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=es(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=es(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=es(e);if(e.end)for(let s of e.end)t+=s.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let s of e.end)t+=s.source;return t}}}function es({start:e,key:t,sep:s,value:n}){let r="";for(let i of e)r+=i.source;if(t)r+=ts(t);if(s)for(let i of s)r+=i.source;if(n)r+=ts(n);return r}Sm.stringify=_m});var go=S(function(Tm){var Nn=Symbol("break visit"),vm=Symbol("skip children"),po=Symbol("remove item");function be(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};mo(Object.freeze([]),e,t)}be.BREAK=Nn;be.SKIP=vm;be.REMOVE=po;be.itemAtPath=(e,t)=>{let s=e;for(let[n,r]of t){let i=s?.[n];if(i&&"items"in i)s=i.items[r];else return}return s};be.parentCollection=(e,t)=>{let s=be.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],r=s?.[n];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function mo(e,t,s){let n=s(t,e);if(typeof n==="symbol")return n;for(let r of["key","value"]){let i=t[r];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=mo(Object.freeze(e.concat([[r,o]])),i.items[o],s);if(typeof a==="number")o=a-1;else if(a===Nn)return Nn;else if(a===po)i.items.splice(o,1),o-=1}if(typeof n==="function"&&r==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}Tm.visit=be});var ss=S(function(km){var xn=fo(),Rm=ho(),Cm=go(),On="\uFEFF",Ln="\x02",kn="\x18",In="\x1F",Nm=(e)=>!!e&&("items"in e),xm=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Om(e){switch(e){case On:return"<BOM>";case Ln:return"<DOC>";case kn:return"<FLOW_END>";case In:return"<SCALAR>";default:return JSON.stringify(e)}}function Lm(e){switch(e){case On:return"byte-order-mark";case Ln:return"doc-mode";case kn:return"flow-error-end";case In:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
112
+ `;if(e.type==="block-scalar"){let i=e.props[0];if(i.type!=="block-scalar-header")throw Error("Invalid block scalar header");i.source=n,e.source=r}else{let{offset:i}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];if(!fo(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
113
+ `});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function fo(e,t){if(t)for(let s of t)switch(s.type){case"space":case"comment":e.push(s);break;case"newline":return e.push(s),!0}return!1}function Cn(e,t,s){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=s,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),r=t.length;if(e.props[0].type==="block-scalar-header")r-=e.props[0].source.length;for(let i of n)i.offset+=r;delete e.props,Object.assign(e,{type:s,source:t,end:n});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
114
+ `};delete e.items,Object.assign(e,{type:s,source:t,end:[r]});break}default:{let n="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:s,indent:n,source:t,end:r})}}}bm.createScalarToken=gm;bm.resolveAsScalar=mm;bm.setScalarValue=ym});var po=S(function(Tm){var Em=(e)=>("type"in e)?ts(e):es(e);function ts(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ts(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=es(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=es(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=es(e);if(e.end)for(let s of e.end)t+=s.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let s of e.end)t+=s.source;return t}}}function es({start:e,key:t,sep:s,value:n}){let r="";for(let i of e)r+=i.source;if(t)r+=ts(t);if(s)for(let i of s)r+=i.source;if(n)r+=ts(n);return r}Tm.stringify=Em});var yo=S(function(Cm){var Nn=Symbol("break visit"),Rm=Symbol("skip children"),mo=Symbol("remove item");function be(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};go(Object.freeze([]),e,t)}be.BREAK=Nn;be.SKIP=Rm;be.REMOVE=mo;be.itemAtPath=(e,t)=>{let s=e;for(let[n,r]of t){let i=s?.[n];if(i&&"items"in i)s=i.items[r];else return}return s};be.parentCollection=(e,t)=>{let s=be.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],r=s?.[n];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function go(e,t,s){let n=s(t,e);if(typeof n==="symbol")return n;for(let r of["key","value"]){let i=t[r];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=go(Object.freeze(e.concat([[r,o]])),i.items[o],s);if(typeof a==="number")o=a-1;else if(a===Nn)return Nn;else if(a===mo)i.items.splice(o,1),o-=1}if(typeof n==="function"&&r==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}Cm.visit=be});var ss=S(function(Mm){var xn=ho(),xm=po(),Om=yo(),On="\uFEFF",Ln="\x02",kn="\x18",In="\x1F",Lm=(e)=>!!e&&("items"in e),km=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Im(e){switch(e){case On:return"<BOM>";case Ln:return"<DOC>";case kn:return"<FLOW_END>";case In:return"<SCALAR>";default:return JSON.stringify(e)}}function Pm(e){switch(e){case On:return"byte-order-mark";case Ln:return"doc-mode";case kn:return"flow-error-end";case In:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
115
115
  `:case`\r
116
- `: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(e[0]){case" ":case"\t":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}km.createScalarToken=xn.createScalarToken;km.resolveAsScalar=xn.resolveAsScalar;km.setScalarValue=xn.setScalarValue;km.stringify=Rm.stringify;km.visit=Cm.visit;km.BOM=On;km.DOCUMENT=Ln;km.FLOW_END=kn;km.SCALAR=In;km.isCollection=Nm;km.isScalar=xm;km.prettyToken=Om;km.tokenType=Lm});var Mn=S(function(Vm){var rt=ss();function j(e){switch(e){case void 0:case" ":case`
117
- `:case"\r":case"\t":return!0;default:return!1}}var yo=new Set("0123456789ABCDEFabcdef"),Ym=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ns=new Set(",[]{}"),Jm=new Set(` ,[]{}
118
- \r `),Pn=(e)=>!e||Jm.has(e);class wo{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,t=!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=!t;let s=this.next??"stream";while(s&&(t||this.hasChars(1)))s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
116
+ `: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(e[0]){case" ":case"\t":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}Mm.createScalarToken=xn.createScalarToken;Mm.resolveAsScalar=xn.resolveAsScalar;Mm.setScalarValue=xn.setScalarValue;Mm.stringify=xm.stringify;Mm.visit=Om.visit;Mm.BOM=On;Mm.DOCUMENT=Ln;Mm.FLOW_END=kn;Mm.SCALAR=In;Mm.isCollection=Lm;Mm.isScalar=km;Mm.prettyToken=Im;Mm.tokenType=Pm});var Mn=S(function(zm){var rt=ss();function j(e){switch(e){case void 0:case" ":case`
117
+ `:case"\r":case"\t":return!0;default:return!1}}var wo=new Set("0123456789ABCDEFabcdef"),Gm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ns=new Set(",[]{}"),Xm=new Set(` ,[]{}
118
+ \r `),Pn=(e)=>!e||Xm.has(e);class bo{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,t=!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=!t;let s=this.next??"stream";while(s&&(t||this.hasChars(1)))s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
119
119
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
120
120
  `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;while(t===" ")t=this.buffer[++s+e];if(t==="\r"){let n=this.buffer[s+e+1];if(n===`
121
121
  `||!n&&!this.atEnd)return e+s+1}return t===`
@@ -130,14 +130,14 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
130
130
  `&&r>=this.pos&&r+1+t>o)e=r;else break}while(!0);return yield rt.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,n;while(n=this.buffer[++s])if(n===":"){let r=this.buffer[s+1];if(j(r)||e&&ns.has(r))break;t=s}else if(j(n)){let r=this.buffer[s+1];if(n==="\r")if(r===`
131
131
  `)s+=1,n=`
132
132
  `,r=this.buffer[s+1];else t=s;if(r==="#"||e&&ns.has(r))break;if(n===`
133
- `){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&ns.has(n))break;t=s}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield rt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);if(s)return yield s,this.pos+=s.length,s.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Pn),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(j(s)||t&&ns.has(s)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!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,t=this.buffer[e];while(!j(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Ym.has(t))t=this.buffer[++e];else if(t==="%"&&yo.has(this.buffer[e+1])&&yo.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
133
+ `){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&ns.has(n))break;t=s}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield rt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);if(s)return yield s,this.pos+=s.length,s.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Pn),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(j(s)||t&&ns.has(s)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!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,t=this.buffer[e];while(!j(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(Gm.has(t))t=this.buffer[++e];else if(t==="%"&&wo.has(this.buffer[e+1])&&wo.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
134
134
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
135
- `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,s=this.buffer[t];while(!e(s))s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}Vm.Lexer=wo});var Dn=S(function(Gm){class bo{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,s=this.lineStarts.length;while(t<s){let r=t+s>>1;if(this.lineStarts[r]<e)t=r+1;else s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}Gm.LineCounter=bo});var qn=S(function(eg){var Qm=ot("process"),_o=ss(),Zm=Mn();function ae(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function So(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function vo(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function rs(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Me(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function is(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let s=0;s<t.length;++s)e.push(t[s])}function Eo(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!ae(t.start,"explicit-key-ind")&&!ae(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,vo(t.value))if(t.value.end)is(t.value.end,t.sep);else t.value.end=t.sep;else is(t.start,t.sep);delete t.sep}}}class To{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 Zm.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);if(!t)yield*this.end()}*next(e){if(this.source=e,Qm.env.LOG_TOKENS)console.log("|",_o.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=_o.tokenType(e);if(!t){let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(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"){while(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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let s=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in s?s.indent:0;else if(t.type==="flow-collection"&&s.type==="document")t.indent=0;if(t.type==="flow-collection")Eo(t);switch(s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let n=s.items[s.items.length-1];if(n.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=s.items[s.items.length-1];if(n.value)s.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=s.items[s.items.length-1];if(!n||n.value)s.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&So(n.start)===-1&&(t.indent===0||n.start.every((r)=>r.type!=="comment"||r.indent<t.indent))){if(s.type==="document")s.end=n.start;else s.items.push({start:n.start});t.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:[]};if(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":{if(So(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else 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 t=rs(this.peek(2)),s=Me(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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 t=this.source.indexOf(`
135
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,s=this.buffer[t];while(!e(s))s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}zm.Lexer=bo});var Dn=S(function(Zm){class _o{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,s=this.lineStarts.length;while(t<s){let r=t+s>>1;if(this.lineStarts[r]<e)t=r+1;else s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}Zm.LineCounter=_o});var qn=S(function(ng){var tg=ot("process"),So=ss(),sg=Mn();function ae(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function vo(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function To(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function rs(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Me(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function is(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let s=0;s<t.length;++s)e.push(t[s])}function Eo(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!ae(t.start,"explicit-key-ind")&&!ae(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,To(t.value))if(t.value.end)is(t.value.end,t.sep);else t.value.end=t.sep;else is(t.start,t.sep);delete t.sep}}}class Ao{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 sg.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);if(!t)yield*this.end()}*next(e){if(this.source=e,tg.env.LOG_TOKENS)console.log("|",So.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=So.tokenType(e);if(!t){let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(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"){while(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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let s=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in s?s.indent:0;else if(t.type==="flow-collection"&&s.type==="document")t.indent=0;if(t.type==="flow-collection")Eo(t);switch(s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let n=s.items[s.items.length-1];if(n.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=s.items[s.items.length-1];if(n.value)s.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=s.items[s.items.length-1];if(!n||n.value)s.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&vo(n.start)===-1&&(t.indent===0||n.start.every((r)=>r.type!=="comment"||r.indent<t.indent))){if(s.type==="document")s.end=n.start;else s.items.push({start:n.start});t.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:[]};if(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":{if(vo(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else 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 t=rs(this.peek(2)),s=Me(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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 t=this.source.indexOf(`
136
136
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
137
- `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let i=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":i.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)r=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0});else 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(t.explicitKey)if(!t.sep)if(ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Me(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(vo(t.key)&&!ae(t.sep,"newline")){let i=Me(t.start),o=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(n||t.value)e.items.push({start:r,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ae(t.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 if(s)e.items.push({start:r});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||ae(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);if(s)this.stack.push(s);else yield*this.pop(),yield*this.step()}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let n=rs(s),r=Me(n);Eo(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
137
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let i=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":i.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)r=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0});else 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(t.explicitKey)if(!t.sep)if(ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Me(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(To(t.key)&&!ae(t.sep,"newline")){let i=Me(t.start),o=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(n||t.value)e.items.push({start:r,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ae(t.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 if(s)e.items.push({start:r});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||ae(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);if(s)this.stack.push(s);else yield*this.pop(),yield*this.step()}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let n=rs(s),r=Me(n);Eo(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
138
138
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
139
- `,t)+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 t=rs(e),s=Me(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=rs(e),s=Me(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((s)=>s.type==="newline"||s.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(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;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}eg.Parser=To});var xo=S(function(cg){var Ao=Rn(),sg=Ze(),it=et(),ng=Ms(),rg=C(),ig=Dn(),Ro=qn();function Co(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ig.LineCounter||null,prettyErrors:t}}function og(e,t={}){let{lineCounter:s,prettyErrors:n}=Co(t),r=new Ro.Parser(s?.addNewLine),i=new Ao.Composer(t),o=Array.from(i.compose(r.parse(e)));if(n&&s)for(let a of o)a.errors.forEach(it.prettifyError(e,s)),a.warnings.forEach(it.prettifyError(e,s));if(o.length>0)return o;return Object.assign([],{empty:!0},i.streamInfo())}function No(e,t={}){let{lineCounter:s,prettyErrors:n}=Co(t),r=new Ro.Parser(s?.addNewLine),i=new Ao.Composer(t),o=null;for(let a of i.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new it.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&s)o.errors.forEach(it.prettifyError(e,s)),o.warnings.forEach(it.prettifyError(e,s));return o}function ag(e,t,s){let n=void 0;if(typeof t==="function")n=t;else if(s===void 0&&t&&typeof t==="object")s=t;let r=No(e,s);if(!r)return null;if(r.warnings.forEach((i)=>ng.warn(r.options.logLevel,i)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:n},s))}function lg(e,t,s){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=t;if(typeof s==="string")s=s.length;if(typeof s==="number"){let r=Math.round(s);s=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=s??t??{};if(!r)return}if(rg.isDocument(e)&&!n)return e.toString(s);return new sg.Document(e,n,s).toString(s)}cg.parse=ag;cg.parseAllDocuments=og;cg.parseDocument=No;cg.stringify=lg});import{spawn as oy}from"node:child_process";import{basename as ta,join as Xn}from"node:path";import{spawn as Gn}from"node:child_process";import{mkdtemp as sa,readFile as na,rm as Ee}from"node:fs/promises";import{tmpdir as ra}from"node:os";import{Readable as ia}from"node:stream";import{spawn as Fo}from"node:child_process";import{realpath as $o}from"node:fs/promises";import{resolve as Uo}from"node:path";class V extends Error{args;exitCode;stderr;constructor(e,t){let s=["git",...e].join(" "),n=t.stderr.trim()||`exited with code ${t.exitCode}`;super(`${s}: ${n}`);this.name="GitCommandError",this.args=e,this.exitCode=t.exitCode,this.stderr=t.stderr}}async function jn(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Bo(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}async function at(e,t){let s;try{s=Fo("git",[...e],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}try{let[n,r,i]=await Promise.all([jn(s.stdout),jn(s.stderr),Bo(s)]);return{stdout:n,stderr:r,exitCode:i}}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}}async function Kn(e=process.cwd(),t=at){let s=Uo(e),n=await t(["-C",s,"rev-parse","--show-toplevel"],s);if(n.exitCode!==0)throw new V(["-C",s,"rev-parse","--show-toplevel"],n);let r=n.stdout.trim();if(!r)throw Error(`${s} is not inside a Git repository`);return $o(r)}async function K(e,t,s=at){let n=await s(t,e);if(n.exitCode!==0)throw new V(t,n);return n.stdout}import{access as jo,constants as Ko,realpath as Wn}from"node:fs/promises";import{dirname as Wo,isAbsolute as Ho,relative as Yo,resolve as ls,sep as cs,win32 as Jo}from"node:path";var Hn=new TextEncoder;class W extends Error{constructor(e="Path must point to a file inside the repository"){super(e);this.name="InvalidRepositoryPathError"}}function Yn(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t="";for(let s of e)t+=String.fromCharCode(s);return btoa(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Vo(e,t){if(!t)return!1;let s=Hn.encode(e),n=Hn.encode(t),r=s.length^n.length,i=Math.max(s.length,n.length);for(let o=0;o<i;o+=1)r|=(s[o]??0)^(n[o]??0);return r===0}function Xo(e){let t=e.headers.get("authorization");if(t){let n=/^Bearer\s+(.+)$/i.exec(t.trim());if(n?.[1])return n[1]}let s=e.headers.get("x-review-token");if(s)return s;return new URL(e.url).searchParams.get("token")}function Jn(e,t){return Vo(t,Xo(e))}function Vn(e,t){let s=e.endsWith(cs)?e:`${e}${cs}`;return t===e||t.startsWith(s)}function Se(e,t){if(typeof t!=="string"||t.length===0)throw new W("A non-empty repository-relative path is required");if(t.includes("\x00")||t.includes("\r")||t.includes(`
140
- `))throw new W("Path contains a forbidden control character");let s=t.replaceAll("\\","/");if(s.startsWith("/")||Ho(t)||Jo.isAbsolute(t)||/^[A-Za-z]:\//.test(s))throw new W("Path must be repository-relative");let n=ls(e),r=ls(n,s);if(!Vn(n,r))throw new W("Path resolves outside the repository");let i=Yo(n,r).split(cs).join("/");if(!i||i==="."||i.startsWith("../")||i==="..")throw new W("Path must identify a file inside the repository");return{relativePath:i,absolutePath:r}}async function ds(e,t){let s=Se(e,t),n=ls(e),r=s.absolutePath;while(r!==n)try{await jo(r,Ko.F_OK);let i=await Wn(r);if(!Vn(await Wn(n),i))throw new W("Path resolves outside the repository");return s}catch(i){if(i instanceof W)throw i;r=Wo(r)}return s}import{existsSync as Go}from"node:fs";import{spawn as zo}from"node:child_process";class lt extends Error{exitCode;constructor(e,t){super(t);this.name="OpenCommandError",this.exitCode=e}}var Qo=process.platform==="darwin"?'open "$VR_FILE"':'xdg-open "$VR_FILE"';async function Zo(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function ea(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function us(e=process.env.REVIEWME_OPEN_COMMAND?.trim()||Qo){if(e.trim()==="")throw Error("Open command cannot be empty");return async(t)=>{let s;try{s=zo("/bin/sh",["-lc",e],{cwd:t.repositoryRoot,env:{...process.env,VR_FILE:t.absolutePath,VR_REL_FILE:t.relativePath,VR_FILE_EXISTS:String(Go(t.absolutePath)),VR_ROOT:t.repositoryRoot,VR_SIDE:t.side??"new",VR_COMMIT:t.commit??t.headSha??"",VR_BASE_SHA:t.baseSha??"",VR_HEAD_SHA:t.headSha??"",VR_LINE:t.line===void 0?"":String(t.line),VR_COLUMN:t.column===void 0?"":String(t.column)},stdio:["ignore","ignore","pipe"]})}catch(i){throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)}let[n,r]=await Promise.all([Zo(s.stderr),ea(s)]).catch((i)=>{throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)});if(r!==0)throw new lt(r,n.trim()||"The open command returned a non-zero exit code")}}var by=us();class ce extends Error{code;constructor(e,t){super(t);this.name="RepositoryServiceError",this.code=e}}class dt extends ce{constructor(e){super("file_not_found",`Changed file not found: ${e}`);this.name="FileNotFoundError"}}function oa(e){if(e==null||e.trim()==="")return null;let t=e.trim().replace(/^git@github\.com:/,"ssh://git@github.com/");try{let s=new URL(t);if(s.hostname.toLowerCase()!=="github.com")return null;let[n,r]=s.pathname.replace(/^\/+/,"").split("/"),i=r?.replace(/\.git$/,"");return n&&i?{owner:n,repository:i}:null}catch{return null}}function zn(e,t,s=[],n=!1){return["diff",...n?["--cached"]:[],"--patch","--binary","--full-index","--no-color","--no-ext-diff","-O","/dev/null","--find-renames","--find-copies",e,...t==null?[]:[t],"--",...s]}async function fs(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Qn(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function De(e,t,s){if(e&&(t||s))throw Error("Use either a range or --from/--to, not both");if(t||s){if(!t||!s)throw Error("--from and --to must be provided together");return ct(t),ct(s),{range:`${t}..${s}`,from:t,to:s,mode:"direct"}}if(!e)return{range:"main...HEAD",from:"main",to:"HEAD",mode:"merge-base"};let n=e.indexOf("..."),r=n<0?e.indexOf(".."):-1,i=n>=0?"...":r>=0?"..":null,o=n>=0?n:r;if(!i||o<0||e.indexOf(i,o+i.length)>=0)throw Error("Range must use exactly one `A...B` or `A..B` separator");let a=e.slice(0,o),l=e.slice(o+i.length);return ct(a),ct(l),{range:e,from:a,to:l,mode:i==="..."?"merge-base":"direct"}}function ct(e){if(!e||/[\0\r\n\t ]/.test(e)||e.startsWith("-")||e.includes(".."))throw Error(`Invalid Git ref: ${e||"(empty)"}`)}function er(e){let t,s,n,r,i,o,a=!0,l=!1,c,p,d=!1,u=(g,w,f)=>{let y=g.indexOf("=");if(y>=0)return[g.slice(y+1),w];let _=e[w+1];if(!_||_.startsWith("-"))throw Error(`${f} requires a value`);return[_,w+1]};for(let g=0;g<e.length;g+=1){let w=e[g];if(w==="--help"||w==="-h"){d=!0;continue}if(w==="--no-open"){a=!1;continue}if(w==="--open"){a=!0;continue}if(w==="--auth"){l=!0;continue}if(w==="--open-command"||w.startsWith("--open-command=")){[c,g]=u(w,g,"--open-command");continue}if(w==="--color-theme"||w.startsWith("--color-theme=")){[p,g]=u(w,g,"--color-theme");continue}if(w==="--from"||w.startsWith("--from=")){[s,g]=u(w,g,"--from");continue}if(w==="--to"||w.startsWith("--to=")){[n,g]=u(w,g,"--to");continue}if(w==="--repo"||w.startsWith("--repo=")){[r,g]=u(w,g,"--repo");continue}if(w==="--port"||w.startsWith("--port=")){let[f,y]=u(w,g,"--port"),_=Number(f);if(!Number.isInteger(_)||_<0||_>65535)throw Error("--port must be an integer between 0 and 65535");i=_,g=y;continue}if(w==="--watch-interval"||w.startsWith("--watch-interval=")){let[f,y]=u(w,g,"--watch-interval"),_=Number(f);if(!Number.isInteger(_)||_<100)throw Error("--watch-interval must be an integer of at least 100ms");o=_,g=y;continue}if(w.startsWith("-"))throw Error(`Unknown option: ${w}`);if(t){if(r)throw Error(`Unexpected argument: ${w}`);r=w}else t=w}return{range:t,from:s,to:n,repoPath:r,port:i,openBrowser:a,auth:l,openCommand:c,colorThemePath:p,watchIntervalMs:o,help:d}}var tr=`Usage: reviewme [RANGE] [REPOSITORY]
139
+ `,t)+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 t=rs(e),s=Me(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=rs(e),s=Me(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((s)=>s.type==="newline"||s.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(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;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}ng.Parser=Ao});var Oo=S(function(fg){var Ro=Rn(),ig=Ze(),it=et(),og=Ms(),ag=C(),lg=Dn(),Co=qn();function No(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new lg.LineCounter||null,prettyErrors:t}}function cg(e,t={}){let{lineCounter:s,prettyErrors:n}=No(t),r=new Co.Parser(s?.addNewLine),i=new Ro.Composer(t),o=Array.from(i.compose(r.parse(e)));if(n&&s)for(let a of o)a.errors.forEach(it.prettifyError(e,s)),a.warnings.forEach(it.prettifyError(e,s));if(o.length>0)return o;return Object.assign([],{empty:!0},i.streamInfo())}function xo(e,t={}){let{lineCounter:s,prettyErrors:n}=No(t),r=new Co.Parser(s?.addNewLine),i=new Ro.Composer(t),o=null;for(let a of i.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new it.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&s)o.errors.forEach(it.prettifyError(e,s)),o.warnings.forEach(it.prettifyError(e,s));return o}function dg(e,t,s){let n=void 0;if(typeof t==="function")n=t;else if(s===void 0&&t&&typeof t==="object")s=t;let r=xo(e,s);if(!r)return null;if(r.warnings.forEach((i)=>og.warn(r.options.logLevel,i)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:n},s))}function ug(e,t,s){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=t;if(typeof s==="string")s=s.length;if(typeof s==="number"){let r=Math.round(s);s=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=s??t??{};if(!r)return}if(ag.isDocument(e)&&!n)return e.toString(s);return new ig.Document(e,n,s).toString(s)}fg.parse=dg;fg.parseAllDocuments=cg;fg.parseDocument=xo;fg.stringify=ug});import{spawn as dy}from"node:child_process";var jn={name:"reviewme",version:"0.0.6",license:"Apache-2.0",description:"A local, browser-based Git branch review tool with inline comments and Codex threads.",type:"module",bin:{reviewme:"bin/reviewme.mjs"},files:["bin","dist/frontend","dist/server","examples/themes","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],engines:{node:">=22.13"},publishConfig:{access:"public"},scripts:{clean:"node scripts/clean-dist.mjs",dev:"npm run build && node ./bin/reviewme.mjs","build:frontend":"bun build ./src/frontend/index.html ./node_modules/@pierre/diffs/dist/worker/worker.js --outdir ./dist/frontend --entry-naming '[name].[ext]' --chunk-naming 'chunks/[name]-[hash].[ext]' --asset-naming 'assets/[name]-[hash].[ext]' --minify","build:server":"bun build ./src/server/main.ts --target=node --outdir=./dist/server --entry-naming=main.js --minify --sourcemap=linked",build:"npm run clean && npm run build:frontend && npm run build:server",prepack:"npm run build",start:"./bin/reviewme.mjs",test:"bun test",typecheck:"tsc --noEmit"},devDependencies:{"@pierre/diffs":"^1.3.6","@pierre/trees":"^1.0.0-beta.6","@types/react":"^19.2.2","@types/react-dom":"^19.2.2","bun-types":"^1.3.14","lucide-react":"^1.35.0",react:"^19.2.8","react-dom":"^19.2.8",typescript:"^5.9.3",yaml:"^2.9.0"}};import{basename as ra,join as Xn}from"node:path";import{spawn as zn}from"node:child_process";import{mkdtemp as ia,readFile as oa,rm as ve}from"node:fs/promises";import{tmpdir as aa}from"node:os";import{Readable as la}from"node:stream";import{spawn as Bo}from"node:child_process";import{realpath as jo}from"node:fs/promises";import{resolve as Ko}from"node:path";class V extends Error{args;exitCode;stderr;constructor(e,t){let s=["git",...e].join(" "),n=t.stderr.trim()||`exited with code ${t.exitCode}`;super(`${s}: ${n}`);this.name="GitCommandError",this.args=e,this.exitCode=t.exitCode,this.stderr=t.stderr}}async function Kn(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Wo(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}async function at(e,t){let s;try{s=Bo("git",[...e],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}try{let[n,r,i]=await Promise.all([Kn(s.stdout),Kn(s.stderr),Wo(s)]);return{stdout:n,stderr:r,exitCode:i}}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}}async function Wn(e=process.cwd(),t=at){let s=Ko(e),n=await t(["-C",s,"rev-parse","--show-toplevel"],s);if(n.exitCode!==0)throw new V(["-C",s,"rev-parse","--show-toplevel"],n);let r=n.stdout.trim();if(!r)throw Error(`${s} is not inside a Git repository`);return jo(r)}async function K(e,t,s=at){let n=await s(t,e);if(n.exitCode!==0)throw new V(t,n);return n.stdout}import{access as Ho,constants as Yo,realpath as Hn}from"node:fs/promises";import{dirname as Jo,isAbsolute as Vo,relative as Go,resolve as ls,sep as cs,win32 as Xo}from"node:path";var Yn=new TextEncoder;class W extends Error{constructor(e="Path must point to a file inside the repository"){super(e);this.name="InvalidRepositoryPathError"}}function Jn(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t="";for(let s of e)t+=String.fromCharCode(s);return btoa(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function zo(e,t){if(!t)return!1;let s=Yn.encode(e),n=Yn.encode(t),r=s.length^n.length,i=Math.max(s.length,n.length);for(let o=0;o<i;o+=1)r|=(s[o]??0)^(n[o]??0);return r===0}function Qo(e){let t=e.headers.get("authorization");if(t){let n=/^Bearer\s+(.+)$/i.exec(t.trim());if(n?.[1])return n[1]}let s=e.headers.get("x-review-token");if(s)return s;return new URL(e.url).searchParams.get("token")}function Vn(e,t){return zo(t,Qo(e))}function Gn(e,t){let s=e.endsWith(cs)?e:`${e}${cs}`;return t===e||t.startsWith(s)}function Se(e,t){if(typeof t!=="string"||t.length===0)throw new W("A non-empty repository-relative path is required");if(t.includes("\x00")||t.includes("\r")||t.includes(`
140
+ `))throw new W("Path contains a forbidden control character");let s=t.replaceAll("\\","/");if(s.startsWith("/")||Vo(t)||Xo.isAbsolute(t)||/^[A-Za-z]:\//.test(s))throw new W("Path must be repository-relative");let n=ls(e),r=ls(n,s);if(!Gn(n,r))throw new W("Path resolves outside the repository");let i=Go(n,r).split(cs).join("/");if(!i||i==="."||i.startsWith("../")||i==="..")throw new W("Path must identify a file inside the repository");return{relativePath:i,absolutePath:r}}async function ds(e,t){let s=Se(e,t),n=ls(e),r=s.absolutePath;while(r!==n)try{await Ho(r,Yo.F_OK);let i=await Hn(r);if(!Gn(await Hn(n),i))throw new W("Path resolves outside the repository");return s}catch(i){if(i instanceof W)throw i;r=Jo(r)}return s}import{existsSync as Zo}from"node:fs";import{spawn as ea}from"node:child_process";class lt extends Error{exitCode;constructor(e,t){super(t);this.name="OpenCommandError",this.exitCode=e}}var ta=process.platform==="darwin"?'open "$VR_FILE"':'xdg-open "$VR_FILE"';async function sa(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function na(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function us(e=process.env.REVIEWME_OPEN_COMMAND?.trim()||ta){if(e.trim()==="")throw Error("Open command cannot be empty");return async(t)=>{let s;try{s=ea("/bin/sh",["-lc",e],{cwd:t.repositoryRoot,env:{...process.env,VR_FILE:t.absolutePath,VR_REL_FILE:t.relativePath,VR_FILE_EXISTS:String(Zo(t.absolutePath)),VR_ROOT:t.repositoryRoot,VR_SIDE:t.side??"new",VR_COMMIT:t.commit??t.headSha??"",VR_BASE_SHA:t.baseSha??"",VR_HEAD_SHA:t.headSha??"",VR_LINE:t.line===void 0?"":String(t.line),VR_COLUMN:t.column===void 0?"":String(t.column)},stdio:["ignore","ignore","pipe"]})}catch(i){throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)}let[n,r]=await Promise.all([sa(s.stderr),na(s)]).catch((i)=>{throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)});if(r!==0)throw new lt(r,n.trim()||"The open command returned a non-zero exit code")}}var Ty=us();class ce extends Error{code;constructor(e,t){super(t);this.name="RepositoryServiceError",this.code=e}}class dt extends ce{constructor(e){super("file_not_found",`Changed file not found: ${e}`);this.name="FileNotFoundError"}}function ca(e){if(e==null||e.trim()==="")return null;let t=e.trim().replace(/^git@github\.com:/,"ssh://git@github.com/");try{let s=new URL(t);if(s.hostname.toLowerCase()!=="github.com")return null;let[n,r]=s.pathname.replace(/^\/+/,"").split("/"),i=r?.replace(/\.git$/,"");return n&&i?{owner:n,repository:i}:null}catch{return null}}function Qn(e,t,s=[],n=!1){return["diff",...n?["--cached"]:[],"--patch","--binary","--full-index","--no-color","--no-ext-diff","-O","/dev/null","--find-renames","--find-copies",e,...t==null?[]:[t],"--",...s]}async function fs(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Zn(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function De(e,t,s){if(e&&(t||s))throw Error("Use either a range or --from/--to, not both");if(t||s){if(!t||!s)throw Error("--from and --to must be provided together");return ct(t),ct(s),{range:`${t}..${s}`,from:t,to:s,mode:"direct"}}if(!e)return{range:"main...HEAD",from:"main",to:"HEAD",mode:"merge-base"};let n=e.indexOf("..."),r=n<0?e.indexOf(".."):-1,i=n>=0?"...":r>=0?"..":null,o=n>=0?n:r;if(!i||o<0||e.indexOf(i,o+i.length)>=0)throw Error("Range must use exactly one `A...B` or `A..B` separator");let a=e.slice(0,o),l=e.slice(o+i.length);return ct(a),ct(l),{range:e,from:a,to:l,mode:i==="..."?"merge-base":"direct"}}function ct(e){if(!e||/[\0\r\n\t ]/.test(e)||e.startsWith("-")||e.includes(".."))throw Error(`Invalid Git ref: ${e||"(empty)"}`)}function tr(e){let t,s,n,r,i,o,a=!0,l=!1,c,p,d=!1,u=(g,w,f)=>{let y=g.indexOf("=");if(y>=0)return[g.slice(y+1),w];let _=e[w+1];if(!_||_.startsWith("-"))throw Error(`${f} requires a value`);return[_,w+1]};for(let g=0;g<e.length;g+=1){let w=e[g];if(w==="--help"||w==="-h"){d=!0;continue}if(w==="--no-open"){a=!1;continue}if(w==="--open"){a=!0;continue}if(w==="--auth"){l=!0;continue}if(w==="--open-command"||w.startsWith("--open-command=")){[c,g]=u(w,g,"--open-command");continue}if(w==="--color-theme"||w.startsWith("--color-theme=")){[p,g]=u(w,g,"--color-theme");continue}if(w==="--from"||w.startsWith("--from=")){[s,g]=u(w,g,"--from");continue}if(w==="--to"||w.startsWith("--to=")){[n,g]=u(w,g,"--to");continue}if(w==="--repo"||w.startsWith("--repo=")){[r,g]=u(w,g,"--repo");continue}if(w==="--port"||w.startsWith("--port=")){let[f,y]=u(w,g,"--port"),_=Number(f);if(!Number.isInteger(_)||_<0||_>65535)throw Error("--port must be an integer between 0 and 65535");i=_,g=y;continue}if(w==="--watch-interval"||w.startsWith("--watch-interval=")){let[f,y]=u(w,g,"--watch-interval"),_=Number(f);if(!Number.isInteger(_)||_<100)throw Error("--watch-interval must be an integer of at least 100ms");o=_,g=y;continue}if(w.startsWith("-"))throw Error(`Unknown option: ${w}`);if(t){if(r)throw Error(`Unexpected argument: ${w}`);r=w}else t=w}return{range:t,from:s,to:n,repoPath:r,port:i,openBrowser:a,auth:l,openCommand:c,colorThemePath:p,watchIntervalMs:o,help:d}}var sr=`Usage: reviewme [RANGE] [REPOSITORY]
141
141
 
142
142
  Compare a branch with a local Git ref and open the review in your browser.
143
143
 
@@ -149,16 +149,16 @@ Compare a branch with a local Git ref and open the review in your browser.
149
149
  --open-command CMD Shell command used to open files/locations
150
150
  --color-theme PATH Load a JSON or YAML color theme
151
151
  --no-open Do not launch the browser
152
- `;function aa(e){switch(e[0]){case"A":return"added";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"M":return"modified";default:return"unknown"}}function la(e){let t=e.split("\x00"),s=[];for(let n=0;n<t.length;){let r=t[n++];if(!r)continue;let i=r.slice(1).trim().split(/\s+/);if(i.length<5)continue;let o=i.at(-1)??"?",a=i[0],l=i[1],c=t[n++]??"",p=o[0];if(p==="R"||p==="C"){let d=t[n++]??"";s.push({statusCode:o,path:d,oldPath:c,oldMode:a,newMode:l})}else s.push({statusCode:o,path:c,oldMode:a,newMode:l})}return s}function ca(e){let t=e.split("\x00"),s=new Map;for(let n=0;n<t.length;){let r=t[n++];if(r===void 0||r==="")continue;let i=/^(\d+|-)[\t ](\d+|-)[\t ](.*)$/.exec(r);if(!i)continue;let o=i[1]==="-"?null:Number(i[1]),a=i[2]==="-"?null:Number(i[2]),l={additions:o,deletions:a,binary:o===null||a===null};if(i[3])s.set(i[3],l);else{let c=t[n++]??"",p=t[n++]??"";if(c)s.set(c,l);if(p)s.set(p,l)}}return s}class sr{ready;options;git;vscode;listeners=new Set;state;root="";parsedRange;refreshInFlight;watchTimer;constructor(e={}){this.options=e,this.git=e.git??at,this.vscode=e.vscode??us(e.openCommand),this.ready=this.initialize()}get repositoryRoot(){return this.root}async initialize(){if(this.root=await Kn(this.options.repoPath??process.cwd(),this.git),this.options.range==null&&this.options.from==null&&this.options.to==null){let e=await this.git(["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"],this.root),t=e.exitCode===0?e.stdout.trim():"";if(!t){for(let s of["main","master"])if((await this.git(["rev-parse","--verify","--quiet","--end-of-options",`refs/heads/${s}^{commit}`],this.root)).exitCode===0){t=s;break}}this.parsedRange=De(`${t||"main"}...HEAD`)}else this.parsedRange=De(this.options.range,this.options.from,this.options.to);await this.updateState(!1)}async resolveRef(e){let t;try{t=await K(this.root,["rev-parse","--verify","--end-of-options",`${e}^{commit}`],this.git)}catch(n){if(n instanceof V)throw new ce("invalid_ref",`Git ref does not exist: ${e}`);throw n}let s=t.trim().split(/\s+/)[0];if(!s||!/^[0-9a-f]{40,64}$/i.test(s))throw new ce("invalid_ref",`Git did not resolve ${e} to a commit`);return s}async resolveComparison(e=this.parsedRange){let[t,s]=await Promise.all([this.resolveRef(e.from),this.resolveRef(e.to)]),n=null,r=await this.git(["merge-base",t,s],this.root);if(r.exitCode===0&&r.stdout.trim())n=r.stdout.trim().split(/\s+/)[0]??null;else if(e.mode==="merge-base")throw new ce("no_merge_base",`No merge base exists between ${e.from} and ${e.to}`);return{fromSha:t,toSha:s,baseSha:e.mode==="merge-base"?n:t,mergeBaseSha:n}}async getBranch(){let e=await this.git(["symbolic-ref","--quiet","--short","HEAD"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getRemoteOrigin(){let e=await this.git(["config","--get","remote.origin.url"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getStatus(){return K(this.root,["status","--porcelain=v1","-z","--untracked-files=all"],this.git)}async getChangedFiles(e,t){let s=["diff","--raw","-z","--abbrev=40","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],[n,r]=await Promise.all([K(this.root,s,this.git),K(this.root,["diff","--numstat","-z","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],this.git)]),i=ca(r);return la(n).map((o)=>{let a=i.get(o.path)??(o.oldPath?i.get(o.oldPath):void 0),l=aa(o.statusCode),c=o.path||o.oldPath||"";return{id:c,path:c,...o.oldPath?{oldPath:o.oldPath}:{},status:l,additions:a?.additions??0,deletions:a?.deletions??0,isBinary:a?.binary??!1,...o.oldMode&&o.oldMode!=="000000"?{oldMode:o.oldMode}:{},...o.newMode&&o.newMode!=="000000"?{newMode:o.newMode}:{}}})}async updateState(e){let t=await this.resolveComparison(),[s,n,r,i]=await Promise.all([this.resolveRef("HEAD"),this.getStatus(),this.getBranch(),this.getRemoteOrigin()]),o=oa(i),a=[t.fromSha,t.toSha,t.baseSha,t.mergeBaseSha??"",n].join("\x00"),l=this.state,c=!l||l.fingerprint!==a,p=c||!l?await this.getChangedFiles(t.baseSha,t.toSha):l.files,d=l?c?l.info.revision+1:l.info.revision:1,u=n.split("\x00"),g=[];for(let y=0;y<u.length;y+=1){let _=u[y];if(_==null||_.length<4)continue;let m=_.slice(0,2);if(g.push(_.slice(3)),m.includes("R")||m.includes("C"))y+=1}let w={root:this.root,name:ta(this.root),remoteOrigin:i,githubOwner:o?.owner??null,githubRepository:o?.repository??null,branch:r,headSha:s,range:this.parsedRange.range,fromRef:this.parsedRange.from,toRef:this.parsedRange.to,baseRef:this.parsedRange.from,headRef:this.parsedRange.to,fromSha:t.fromSha,toSha:t.toSha,baseSha:t.baseSha,targetSha:t.toSha,mergeBaseSha:t.mergeBaseSha,comparisonMode:this.parsedRange.mode,revision:d,dirty:Boolean(n.trim()),uncommittedPaths:g};this.state={info:w,files:p,fingerprint:a};let f={changed:c,revision:d,repository:w,files:[...p]};if(e&&c)for(let y of this.listeners)y(f);return f}async refresh(){if(await this.ready,!this.refreshInFlight)this.refreshInFlight=this.updateState(!0).finally(()=>{this.refreshInFlight=void 0});return this.refreshInFlight}async getRepositoryMetadata(){return await this.ready,{...this.state.info}}async listFiles(){return await this.ready,{revision:this.state.info.revision,files:[...this.state.files]}}async listRefs(){await this.ready;let t=(await K(this.root,["for-each-ref","--format=%(refname)%00%(refname:short)%00%(objectname)%00%(objecttype)%00","refs/heads","refs/remotes","refs/tags"],this.git)).split("\x00"),s=[];for(let n=0;n+3<t.length;n+=4){let r=t[n]?.replace(/^\n+/,""),i=t[n+1],o=t[n+2];if(!r||!i||!o)continue;let a=r.startsWith("refs/heads/")?"branch":r.startsWith("refs/remotes/")?"remote":r.startsWith("refs/tags/")?"tag":"other";s.push({name:i,fullName:r,sha:o,kind:a})}return s}async listCommits(e){await this.ready;let t=e===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(e.mode==="merge-base"?`${e.from}...${e.to}`:`${e.from}..${e.to}`));return(await K(this.root,["log","--topo-order","--numstat","--format=%x1e%H%x1f%P%x1f%an%x1f%aI%x1f%s",`${t.baseSha}..${t.toSha}`],this.git)).split("\x1E").flatMap((n)=>{let r=n.trim().split(`
153
- `),i=r.shift();if(!i)return[];let[o,a="",l="",c="",p=""]=i.split("\x1F");if(!o)return[];return[{sha:o,parents:a===""?[]:a.split(" "),author:l,authoredAt:c,subject:p,changedFiles:r.filter((d)=>d.trim()!=="").length}]})}async streamPatch(e,t,s=!1){await this.ready;let n=t===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(t.mode==="merge-base"?`${t.from}...${t.to}`:`${t.from}..${t.to}`)),r,i;if(s){r=await sa(Xn(ra(),"reviewme-index-")),i={...process.env,GIT_INDEX_FILE:Xn(r,"index")};for(let h of[["read-tree",n.baseSha],["add","-A","--",".",":(exclude).reviewme/**"]]){let b;try{b=Gn("git",h,{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(x){throw await Ee(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}let E=Qn(b),T,R,v;try{[T,R,v]=await Promise.all([fs(b.stdout),fs(b.stderr),E])}catch(x){throw await Ee(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}if(v!==0)throw await Ee(r,{recursive:!0,force:!0}),new V(h,{stdout:T,stderr:R,exitCode:v})}}let o=zn(n.baseSha,s?void 0:n.toSha,[],s),a;try{a=Gn("git",[...o],{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(h){if(r!=null)await Ee(r,{recursive:!0,force:!0});throw Error(`Unable to start git: ${h instanceof Error?h.message:String(h)}`)}let l=Qn(a);if(l.catch(()=>{}),r!=null){let h=r;l.then(()=>Ee(h,{recursive:!0,force:!0}),()=>Ee(h,{recursive:!0,force:!0}))}let c=a.stdout;if(!c)throw a.kill(),Error("Git did not provide a readable stdout stream");let p=a.stderr,d=fs(p).catch(()=>""),u=ia.toWeb(c).getReader(),g=!1,w=!1,f=!1,y=()=>{if(f)return;if(f=!0,a.exitCode===null)a.kill("SIGTERM")},_=()=>{e?.removeEventListener("abort",m)},m=()=>{if(g||w)return;g=!0,y(),u.cancel().catch(()=>{}),_()};if(e?.aborted)m();else e?.addEventListener("abort",m,{once:!0});return new ReadableStream({start(h){if(g)h.close()},async pull(h){if(g||w)return;try{let b=await u.read();if(g||w)return;if(b.done){let E,T;try{[E,T]=await Promise.all([l,d])}catch(R){if(g||w)return;w=!0,_(),y(),h.error(R);return}if(g||w)return;if(w=!0,_(),E!==0)h.error(new V(o,{stdout:"",stderr:T,exitCode:E}));else h.close();return}h.enqueue(b.value)}catch(b){if(g||w)return;w=!0,_(),y(),h.error(b)}},async cancel(h){if(g)return;g=!0,_(),y();try{await u.cancel(h)}catch{}await Promise.allSettled([l,d]),u.releaseLock()}})}async getFileDiff(e){await this.ready;let t=this.state.files.find((r)=>r.id===e||r.path===e||r.oldPath===e);if(!t)throw new dt(e);let s=[t.path,t.oldPath].filter((r)=>Boolean(r)),n=await K(this.root,zn(this.state.info.baseSha,this.state.info.targetSha,s),this.git);return{revision:this.state.info.revision,file:{...t},patch:n}}async getFileContents(e){await this.ready;let t=await this.resolveComparison(De(e.comparison.mode==="merge-base"?`${e.comparison.from}...${e.comparison.to}`:`${e.comparison.from}..${e.comparison.to}`)),s=e.oldPath==null?void 0:Se(this.root,e.oldPath).relativePath,n=e.newPath==null?void 0:Se(this.root,e.newPath).relativePath,r=s==null||e.pureRename?null:{name:s,contents:await K(this.root,["show",`${t.baseSha}:${s}`],this.git)},i=null;if(n!=null){let o=e.includeUnstaged?await na((await ds(this.root,n)).absolutePath,"utf8"):await K(this.root,["show",`${t.toSha}:${n}`],this.git);i={name:n,contents:o}}return{oldFile:r??(e.pureRename?null:{name:s??n,contents:""}),newFile:i??{name:n??s,contents:""}}}async openWorkingFile(e){await this.ready;let t=await ds(this.root,e.path);return Zn(e.line,"line"),Zn(e.column,"column"),await this.vscode({repositoryRoot:this.root,absolutePath:t.absolutePath,relativePath:t.relativePath,line:e.line,column:e.column,side:e.side,commit:e.side==="old"?this.state.info.baseSha:this.state.info.targetSha,baseSha:this.state.info.baseSha,headSha:this.state.info.targetSha}),{path:t.relativePath,absolutePath:t.absolutePath,...e.line===void 0?{}:{line:e.line},...e.column===void 0?{}:{column:e.column}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}startWatching(e=this.options.watchIntervalMs??1000){if(this.watchTimer)return;this.watchTimer=setInterval(()=>{this.refresh().catch(()=>{})},e)}stopWatching(){if(!this.watchTimer)return;clearInterval(this.watchTimer),this.watchTimer=void 0}}function Zn(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<1))throw Error(`${t} must be a positive integer`)}function ut(e={}){return new sr(e)}import{createReadStream as fr,existsSync as hr}from"node:fs";import{stat as pr}from"node:fs/promises";import{createServer as Ba}from"node:http";import{dirname as ja,extname as mr,isAbsolute as Ka,join as As,resolve as Rs}from"node:path";import{Readable as yt}from"node:stream";import{fileURLToPath as Wa}from"node:url";import{randomUUID as da}from"node:crypto";import{mkdirSync as ua,realpathSync as fa}from"node:fs";import{homedir as hs}from"node:os";import{dirname as ha,join as de,resolve as mt}from"node:path";import{DatabaseSync as pa}from"node:sqlite";var ps=3,ma="reviewme";class Te extends Error{constructor(e){super(e);this.name="ReviewStoreError"}}class L extends Te{constructor(e){super(e);this.name="ReviewStoreValidationError"}}class D extends Te{constructor(e,t){super(`${e} not found: ${t}`);this.name="ReviewStoreNotFoundError"}}function ga(){let e=process.env.REVIEWME_DB;if(e)return mt(e);return de(ya(ma),"reviews.sqlite")}function ya(e){let t=process.env.REVIEWME_DATA_HOME;if(t)return de(mt(t),e);if(process.platform==="darwin")return de(hs(),"Library","Application Support",e);else if(process.platform==="win32")return de(process.env.APPDATA||process.env.LOCALAPPDATA||de(hs(),"AppData","Roaming"),e);else return de(process.env.XDG_DATA_HOME||de(hs(),".local","share"),e)}class _s{databasePath;database;statements=new Map;ownsDatabase;clock;idFactory;constructor(e={}){let t=typeof e==="string"?{filename:e}:e;if(this.clock=t.clock??(()=>new Date().toISOString()),this.idFactory=t.idFactory??da,t.database)this.database=t.database,this.databasePath=t.filename??":memory:",this.ownsDatabase=!1;else{let s=t.filename??ga();if(s!==":memory:"&&s!=="")ua(ha(mt(s)),{recursive:!0});this.database=new pa(s),this.databasePath=s,this.ownsDatabase=!0}this.configureAndMigrate()}close(){if(this.statements.clear(),this.ownsDatabase)this.database.close()}getBrowserTabTitleMode(){return this.get("SELECT browser_tab_title FROM app_preferences WHERE id = 1")?.browser_tab_title??"branch"}setBrowserTabTitleMode(e){return this.run(`INSERT INTO app_preferences (id, browser_tab_title) VALUES (1, ?)
154
- ON CONFLICT(id) DO UPDATE SET browser_tab_title = excluded.browser_tab_title`,[e]),e}ensureRepository(e){let t=nr(e.canonicalRoot),s=this.timestamp(),n=this.getRepositoryByRoot(t);if(n){if(e.remoteOrigin!==void 0)this.run(`UPDATE repositories
152
+ `;function da(e){switch(e[0]){case"A":return"added";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"M":return"modified";default:return"unknown"}}function ua(e){let t=e.split("\x00"),s=[];for(let n=0;n<t.length;){let r=t[n++];if(!r)continue;let i=r.slice(1).trim().split(/\s+/);if(i.length<5)continue;let o=i.at(-1)??"?",a=i[0],l=i[1],c=t[n++]??"",p=o[0];if(p==="R"||p==="C"){let d=t[n++]??"";s.push({statusCode:o,path:d,oldPath:c,oldMode:a,newMode:l})}else s.push({statusCode:o,path:c,oldMode:a,newMode:l})}return s}function fa(e){let t=e.split("\x00"),s=new Map;for(let n=0;n<t.length;){let r=t[n++];if(r===void 0||r==="")continue;let i=/^(\d+|-)[\t ](\d+|-)[\t ](.*)$/.exec(r);if(!i)continue;let o=i[1]==="-"?null:Number(i[1]),a=i[2]==="-"?null:Number(i[2]),l={additions:o,deletions:a,binary:o===null||a===null};if(i[3])s.set(i[3],l);else{let c=t[n++]??"",p=t[n++]??"";if(c)s.set(c,l);if(p)s.set(p,l)}}return s}class nr{ready;options;git;vscode;listeners=new Set;state;root="";parsedRange;refreshInFlight;watchTimer;constructor(e={}){this.options=e,this.git=e.git??at,this.vscode=e.vscode??us(e.openCommand),this.ready=this.initialize()}get repositoryRoot(){return this.root}async initialize(){if(this.root=await Wn(this.options.repoPath??process.cwd(),this.git),this.options.range==null&&this.options.from==null&&this.options.to==null){let e=await this.git(["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"],this.root),t=e.exitCode===0?e.stdout.trim():"";if(!t){for(let s of["main","master"])if((await this.git(["rev-parse","--verify","--quiet","--end-of-options",`refs/heads/${s}^{commit}`],this.root)).exitCode===0){t=s;break}}this.parsedRange=De(`${t||"main"}...HEAD`)}else this.parsedRange=De(this.options.range,this.options.from,this.options.to);await this.updateState(!1)}async resolveRef(e){let t;try{t=await K(this.root,["rev-parse","--verify","--end-of-options",`${e}^{commit}`],this.git)}catch(n){if(n instanceof V)throw new ce("invalid_ref",`Git ref does not exist: ${e}`);throw n}let s=t.trim().split(/\s+/)[0];if(!s||!/^[0-9a-f]{40,64}$/i.test(s))throw new ce("invalid_ref",`Git did not resolve ${e} to a commit`);return s}async resolveComparison(e=this.parsedRange){let[t,s]=await Promise.all([this.resolveRef(e.from),this.resolveRef(e.to)]),n=null,r=await this.git(["merge-base",t,s],this.root);if(r.exitCode===0&&r.stdout.trim())n=r.stdout.trim().split(/\s+/)[0]??null;else if(e.mode==="merge-base")throw new ce("no_merge_base",`No merge base exists between ${e.from} and ${e.to}`);return{fromSha:t,toSha:s,baseSha:e.mode==="merge-base"?n:t,mergeBaseSha:n}}async getBranch(){let e=await this.git(["symbolic-ref","--quiet","--short","HEAD"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getRemoteOrigin(){let e=await this.git(["config","--get","remote.origin.url"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getStatus(){return K(this.root,["status","--porcelain=v1","-z","--untracked-files=all"],this.git)}async getChangedFiles(e,t){let s=["diff","--raw","-z","--abbrev=40","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],[n,r]=await Promise.all([K(this.root,s,this.git),K(this.root,["diff","--numstat","-z","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],this.git)]),i=fa(r);return ua(n).map((o)=>{let a=i.get(o.path)??(o.oldPath?i.get(o.oldPath):void 0),l=da(o.statusCode),c=o.path||o.oldPath||"";return{id:c,path:c,...o.oldPath?{oldPath:o.oldPath}:{},status:l,additions:a?.additions??0,deletions:a?.deletions??0,isBinary:a?.binary??!1,...o.oldMode&&o.oldMode!=="000000"?{oldMode:o.oldMode}:{},...o.newMode&&o.newMode!=="000000"?{newMode:o.newMode}:{}}})}async updateState(e){let t=await this.resolveComparison(),[s,n,r,i]=await Promise.all([this.resolveRef("HEAD"),this.getStatus(),this.getBranch(),this.getRemoteOrigin()]),o=ca(i),a=[t.fromSha,t.toSha,t.baseSha,t.mergeBaseSha??"",n].join("\x00"),l=this.state,c=!l||l.fingerprint!==a,p=c||!l?await this.getChangedFiles(t.baseSha,t.toSha):l.files,d=l?c?l.info.revision+1:l.info.revision:1,u=n.split("\x00"),g=[];for(let y=0;y<u.length;y+=1){let _=u[y];if(_==null||_.length<4)continue;let m=_.slice(0,2);if(g.push(_.slice(3)),m.includes("R")||m.includes("C"))y+=1}let w={root:this.root,name:ra(this.root),remoteOrigin:i,githubOwner:o?.owner??null,githubRepository:o?.repository??null,branch:r,headSha:s,range:this.parsedRange.range,fromRef:this.parsedRange.from,toRef:this.parsedRange.to,baseRef:this.parsedRange.from,headRef:this.parsedRange.to,fromSha:t.fromSha,toSha:t.toSha,baseSha:t.baseSha,targetSha:t.toSha,mergeBaseSha:t.mergeBaseSha,comparisonMode:this.parsedRange.mode,revision:d,dirty:Boolean(n.trim()),uncommittedPaths:g};this.state={info:w,files:p,fingerprint:a};let f={changed:c,revision:d,repository:w,files:[...p]};if(e&&c)for(let y of this.listeners)y(f);return f}async refresh(){if(await this.ready,!this.refreshInFlight)this.refreshInFlight=this.updateState(!0).finally(()=>{this.refreshInFlight=void 0});return this.refreshInFlight}async getRepositoryMetadata(){return await this.ready,{...this.state.info}}async listFiles(){return await this.ready,{revision:this.state.info.revision,files:[...this.state.files]}}async listRefs(){await this.ready;let t=(await K(this.root,["for-each-ref","--format=%(refname)%00%(refname:short)%00%(objectname)%00%(objecttype)%00","refs/heads","refs/remotes","refs/tags"],this.git)).split("\x00"),s=[];for(let n=0;n+3<t.length;n+=4){let r=t[n]?.replace(/^\n+/,""),i=t[n+1],o=t[n+2];if(!r||!i||!o)continue;let a=r.startsWith("refs/heads/")?"branch":r.startsWith("refs/remotes/")?"remote":r.startsWith("refs/tags/")?"tag":"other";s.push({name:i,fullName:r,sha:o,kind:a})}return s}async listCommits(e){await this.ready;let t=e===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(e.mode==="merge-base"?`${e.from}...${e.to}`:`${e.from}..${e.to}`));return(await K(this.root,["log","--topo-order","--numstat","--format=%x1e%H%x1f%P%x1f%an%x1f%aI%x1f%s",`${t.baseSha}..${t.toSha}`],this.git)).split("\x1E").flatMap((n)=>{let r=n.trim().split(`
153
+ `),i=r.shift();if(!i)return[];let[o,a="",l="",c="",p=""]=i.split("\x1F");if(!o)return[];return[{sha:o,parents:a===""?[]:a.split(" "),author:l,authoredAt:c,subject:p,changedFiles:r.filter((d)=>d.trim()!=="").length}]})}async streamPatch(e,t,s=!1){await this.ready;let n=t===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(t.mode==="merge-base"?`${t.from}...${t.to}`:`${t.from}..${t.to}`)),r,i;if(s){r=await ia(Xn(aa(),"reviewme-index-")),i={...process.env,GIT_INDEX_FILE:Xn(r,"index")};for(let h of[["read-tree",n.baseSha],["add","-A","--",".",":(exclude).reviewme/**"]]){let b;try{b=zn("git",h,{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(x){throw await ve(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}let v=Zn(b),T,R,E;try{[T,R,E]=await Promise.all([fs(b.stdout),fs(b.stderr),v])}catch(x){throw await ve(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}if(E!==0)throw await ve(r,{recursive:!0,force:!0}),new V(h,{stdout:T,stderr:R,exitCode:E})}}let o=Qn(n.baseSha,s?void 0:n.toSha,[],s),a;try{a=zn("git",[...o],{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(h){if(r!=null)await ve(r,{recursive:!0,force:!0});throw Error(`Unable to start git: ${h instanceof Error?h.message:String(h)}`)}let l=Zn(a);if(l.catch(()=>{}),r!=null){let h=r;l.then(()=>ve(h,{recursive:!0,force:!0}),()=>ve(h,{recursive:!0,force:!0}))}let c=a.stdout;if(!c)throw a.kill(),Error("Git did not provide a readable stdout stream");let p=a.stderr,d=fs(p).catch(()=>""),u=la.toWeb(c).getReader(),g=!1,w=!1,f=!1,y=()=>{if(f)return;if(f=!0,a.exitCode===null)a.kill("SIGTERM")},_=()=>{e?.removeEventListener("abort",m)},m=()=>{if(g||w)return;g=!0,y(),u.cancel().catch(()=>{}),_()};if(e?.aborted)m();else e?.addEventListener("abort",m,{once:!0});return new ReadableStream({start(h){if(g)h.close()},async pull(h){if(g||w)return;try{let b=await u.read();if(g||w)return;if(b.done){let v,T;try{[v,T]=await Promise.all([l,d])}catch(R){if(g||w)return;w=!0,_(),y(),h.error(R);return}if(g||w)return;if(w=!0,_(),v!==0)h.error(new V(o,{stdout:"",stderr:T,exitCode:v}));else h.close();return}h.enqueue(b.value)}catch(b){if(g||w)return;w=!0,_(),y(),h.error(b)}},async cancel(h){if(g)return;g=!0,_(),y();try{await u.cancel(h)}catch{}await Promise.allSettled([l,d]),u.releaseLock()}})}async getFileDiff(e){await this.ready;let t=this.state.files.find((r)=>r.id===e||r.path===e||r.oldPath===e);if(!t)throw new dt(e);let s=[t.path,t.oldPath].filter((r)=>Boolean(r)),n=await K(this.root,Qn(this.state.info.baseSha,this.state.info.targetSha,s),this.git);return{revision:this.state.info.revision,file:{...t},patch:n}}async getFileContents(e){await this.ready;let t=await this.resolveComparison(De(e.comparison.mode==="merge-base"?`${e.comparison.from}...${e.comparison.to}`:`${e.comparison.from}..${e.comparison.to}`)),s=e.oldPath==null?void 0:Se(this.root,e.oldPath).relativePath,n=e.newPath==null?void 0:Se(this.root,e.newPath).relativePath,r=s==null||e.pureRename?null:{name:s,contents:await K(this.root,["show",`${t.baseSha}:${s}`],this.git)},i=null;if(n!=null){let o=e.includeUnstaged?await oa((await ds(this.root,n)).absolutePath,"utf8"):await K(this.root,["show",`${t.toSha}:${n}`],this.git);i={name:n,contents:o}}return{oldFile:r??(e.pureRename?null:{name:s??n,contents:""}),newFile:i??{name:n??s,contents:""}}}async openWorkingFile(e){await this.ready;let t=await ds(this.root,e.path);return er(e.line,"line"),er(e.column,"column"),await this.vscode({repositoryRoot:this.root,absolutePath:t.absolutePath,relativePath:t.relativePath,line:e.line,column:e.column,side:e.side,commit:e.side==="old"?this.state.info.baseSha:this.state.info.targetSha,baseSha:this.state.info.baseSha,headSha:this.state.info.targetSha}),{path:t.relativePath,absolutePath:t.absolutePath,...e.line===void 0?{}:{line:e.line},...e.column===void 0?{}:{column:e.column}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}startWatching(e=this.options.watchIntervalMs??1000){if(this.watchTimer)return;this.watchTimer=setInterval(()=>{this.refresh().catch(()=>{})},e)}stopWatching(){if(!this.watchTimer)return;clearInterval(this.watchTimer),this.watchTimer=void 0}}function er(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<1))throw Error(`${t} must be a positive integer`)}function ut(e={}){return new nr(e)}import{createReadStream as hr,existsSync as pr}from"node:fs";import{stat as mr}from"node:fs/promises";import{createServer as Wa}from"node:http";import{dirname as Ha,extname as gr,isAbsolute as Ya,join as As,resolve as Rs}from"node:path";import{Readable as yt}from"node:stream";import{fileURLToPath as Ja}from"node:url";import{randomUUID as ha}from"node:crypto";import{mkdirSync as pa,realpathSync as ma}from"node:fs";import{homedir as hs}from"node:os";import{dirname as ga,join as de,resolve as mt}from"node:path";import{DatabaseSync as ya}from"node:sqlite";var ps=3,wa="reviewme";class Te extends Error{constructor(e){super(e);this.name="ReviewStoreError"}}class L extends Te{constructor(e){super(e);this.name="ReviewStoreValidationError"}}class D extends Te{constructor(e,t){super(`${e} not found: ${t}`);this.name="ReviewStoreNotFoundError"}}function ba(){let e=process.env.REVIEWME_DB;if(e)return mt(e);return de(_a(wa),"reviews.sqlite")}function _a(e){let t=process.env.REVIEWME_DATA_HOME;if(t)return de(mt(t),e);if(process.platform==="darwin")return de(hs(),"Library","Application Support",e);else if(process.platform==="win32")return de(process.env.APPDATA||process.env.LOCALAPPDATA||de(hs(),"AppData","Roaming"),e);else return de(process.env.XDG_DATA_HOME||de(hs(),".local","share"),e)}class _s{databasePath;database;statements=new Map;ownsDatabase;clock;idFactory;constructor(e={}){let t=typeof e==="string"?{filename:e}:e;if(this.clock=t.clock??(()=>new Date().toISOString()),this.idFactory=t.idFactory??ha,t.database)this.database=t.database,this.databasePath=t.filename??":memory:",this.ownsDatabase=!1;else{let s=t.filename??ba();if(s!==":memory:"&&s!=="")pa(ga(mt(s)),{recursive:!0});this.database=new ya(s),this.databasePath=s,this.ownsDatabase=!0}this.configureAndMigrate()}close(){if(this.statements.clear(),this.ownsDatabase)this.database.close()}getBrowserTabTitleMode(){return this.get("SELECT browser_tab_title FROM app_preferences WHERE id = 1")?.browser_tab_title??"branch"}setBrowserTabTitleMode(e){return this.run(`INSERT INTO app_preferences (id, browser_tab_title) VALUES (1, ?)
154
+ ON CONFLICT(id) DO UPDATE SET browser_tab_title = excluded.browser_tab_title`,[e]),e}ensureRepository(e){let t=rr(e.canonicalRoot),s=this.timestamp(),n=this.getRepositoryByRoot(t);if(n){if(e.remoteOrigin!==void 0)this.run(`UPDATE repositories
155
155
  SET remote_origin = ?, updated_at = ?
156
156
  WHERE id = ?`,[e.remoteOrigin,s,n.id]);else this.run("UPDATE repositories SET updated_at = ? WHERE id = ?",[s,n.id]);return this.getRepository(n.id)}let r=this.newId();return this.run(`INSERT INTO repositories
157
157
  (id, canonical_root, remote_origin, created_at, updated_at)
158
158
  VALUES (?, ?, ?, ?, ?)`,[r,t,e.remoteOrigin??null,s,s]),this.getRepository(r)}getRepository(e){let t=this.get(`SELECT id, canonical_root, remote_origin, created_at, updated_at
159
- FROM repositories WHERE id = ?`,[e]);return t?gs(t):null}getRepositoryByRoot(e){let t=nr(e),s=this.get(`SELECT id, canonical_root, remote_origin, created_at, updated_at
159
+ FROM repositories WHERE id = ?`,[e]);return t?gs(t):null}getRepositoryByRoot(e){let t=rr(e),s=this.get(`SELECT id, canonical_root, remote_origin, created_at, updated_at
160
160
  FROM repositories WHERE canonical_root = ?`,[t]);return s?gs(s):null}listRepositories(){return this.all(`SELECT id, canonical_root, remote_origin, created_at, updated_at
161
- FROM repositories ORDER BY updated_at DESC, canonical_root ASC`).map(gs)}ensureSnapshot(e){let t=this.ensureRepository({canonicalRoot:e.canonicalRoot,remoteOrigin:e.remoteOrigin});Sa(e.comparisonMode);let s=rr(e.baseSha,"base SHA"),n=rr(e.headSha,"head SHA"),r=ve(e.baseRef),i=ve(e.headRef),o=this.timestamp();this.run(`INSERT INTO review_snapshots
161
+ FROM repositories ORDER BY updated_at DESC, canonical_root ASC`).map(gs)}ensureSnapshot(e){let t=this.ensureRepository({canonicalRoot:e.canonicalRoot,remoteOrigin:e.remoteOrigin});Ta(e.comparisonMode);let s=ir(e.baseSha,"base SHA"),n=ir(e.headSha,"head SHA"),r=Ee(e.baseRef),i=Ee(e.headRef),o=this.timestamp();this.run(`INSERT INTO review_snapshots
162
162
  (id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at)
163
163
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
164
164
  ON CONFLICT(repository_id, comparison_mode, base_sha, head_sha)
@@ -179,15 +179,15 @@ Compare a branch with a local Git ref and open the review in your browser.
179
179
  FROM review_snapshots ORDER BY updated_at DESC, created_at DESC`):this.all(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
180
180
  FROM review_snapshots WHERE repository_id = ? ORDER BY updated_at DESC, created_at DESC`,[e])).map(ht)}setFileReviewed(e,t,s=!0){let n=this.normalizeSnapshotPath(e,t);if(!s)return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,n]),null;let r=this.timestamp();return this.run(`INSERT INTO reviewed_files (snapshot_id, path, reviewed_at)
181
181
  VALUES (?, ?, ?)
182
- ON CONFLICT(snapshot_id, path) DO UPDATE SET reviewed_at = excluded.reviewed_at`,[e,n,r]),this.lookupReviewedFile(e,n)}setFilesReviewed(e,t,s=!0){let n=[...new Set(t.map((r)=>this.normalizeSnapshotPath(e,r)))];this.transaction(()=>{for(let r of n)this.setFileReviewed(e,r,s)})}markFileReviewed(e,t){let s=this.setFileReviewed(e,t,!0);if(!s)throw new Te("Unable to mark file reviewed");return s}unmarkFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]).changes>0}toggleFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.transaction(()=>{if(this.lookupReviewedFile(e,s))return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]),null;let r=this.timestamp();return this.run("INSERT INTO reviewed_files (snapshot_id, path, reviewed_at) VALUES (?, ?, ?)",[e,s,r]),this.lookupReviewedFile(e,s)})}isFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.lookupReviewedFile(e,s)!==null}getReviewedFile(e,t){let s=this.normalizeSnapshotPath(e,t),n=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]);return n?ys(n):null}listReviewedFiles(e){return this.requireSnapshotWithRepository(e),this.all("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? ORDER BY path ASC",[e]).map(ys)}createThread(e){let t=this.normalizeAnchor(e.snapshotId,e.anchor),s=e.body===void 0?void 0:ft(e.body),n=ve(e.title),r=this.newId(),i=this.newId(),o=this.timestamp();return this.transaction(()=>{if(this.requireSnapshot(e.snapshotId),this.run("INSERT INTO threads (id, snapshot_id, title, created_at, updated_at) VALUES (?, ?, ?, ?, ?)",[r,e.snapshotId,n,o,o]),this.insertAnchor(r,i,0,t,o),s!==void 0)this.run(`INSERT INTO messages
182
+ ON CONFLICT(snapshot_id, path) DO UPDATE SET reviewed_at = excluded.reviewed_at`,[e,n,r]),this.lookupReviewedFile(e,n)}setFilesReviewed(e,t,s=!0){let n=[...new Set(t.map((r)=>this.normalizeSnapshotPath(e,r)))];this.transaction(()=>{for(let r of n)this.setFileReviewed(e,r,s)})}markFileReviewed(e,t){let s=this.setFileReviewed(e,t,!0);if(!s)throw new Te("Unable to mark file reviewed");return s}unmarkFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]).changes>0}toggleFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.transaction(()=>{if(this.lookupReviewedFile(e,s))return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]),null;let r=this.timestamp();return this.run("INSERT INTO reviewed_files (snapshot_id, path, reviewed_at) VALUES (?, ?, ?)",[e,s,r]),this.lookupReviewedFile(e,s)})}isFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.lookupReviewedFile(e,s)!==null}getReviewedFile(e,t){let s=this.normalizeSnapshotPath(e,t),n=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]);return n?ys(n):null}listReviewedFiles(e){return this.requireSnapshotWithRepository(e),this.all("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? ORDER BY path ASC",[e]).map(ys)}createThread(e){let t=this.normalizeAnchor(e.snapshotId,e.anchor),s=e.body===void 0?void 0:ft(e.body),n=Ee(e.title),r=this.newId(),i=this.newId(),o=this.timestamp();return this.transaction(()=>{if(this.requireSnapshot(e.snapshotId),this.run("INSERT INTO threads (id, snapshot_id, title, created_at, updated_at) VALUES (?, ?, ?, ?, ?)",[r,e.snapshotId,n,o,o]),this.insertAnchor(r,i,0,t,o),s!==void 0)this.run(`INSERT INTO messages
183
183
  (id, thread_id, role, source, body, external_id, created_at, updated_at)
184
184
  VALUES (?, ?, 'user', 'local', ?, NULL, ?, ?)`,[this.newId(),r,s,o,o])}),this.requireThreadDetails(r)}getThread(e){let t=this.get("SELECT id, snapshot_id, title, created_at, updated_at FROM threads WHERE id = ?",[e]);return t?this.composeThreadDetails(t):null}getThreadDetails(e){return this.getThread(e)}listThreads(e){return this.requireSnapshot(e),this.all(`SELECT id, snapshot_id, title, created_at, updated_at
185
- FROM threads WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map((t)=>this.composeThreadDetails(t))}updateThread(e,t){this.requireThread(e);let s=t.title===void 0?void 0:ve(t.title);if(s!==void 0)this.run("UPDATE threads SET title = ?, updated_at = ? WHERE id = ?",[s,this.timestamp(),e]);return this.requireThreadDetails(e)}deleteThread(e){return this.requireThread(e),this.run("DELETE FROM threads WHERE id = ?",[e]).changes>0}addAnchor(e,t){let s=this.requireThread(e),n=this.normalizeAnchor(s.snapshot_id,t),i=this.get("SELECT MAX(anchor_order) + 1 AS next_order FROM anchors WHERE thread_id = ?",[e])?.next_order??0,o=this.newId(),a=this.timestamp();return this.insertAnchor(e,o,i,n,a),this.touchThread(e,a),this.requireAnchor(o)}updateAnchor(e,t){let s=this.getAnchorWithSnapshot(e);if(!s)throw new D("Anchor",e);let n=this.normalizeAnchor(s.snapshot_id,t),r=this.timestamp();return this.run(`UPDATE anchors SET
185
+ FROM threads WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map((t)=>this.composeThreadDetails(t))}updateThread(e,t){this.requireThread(e);let s=t.title===void 0?void 0:Ee(t.title);if(s!==void 0)this.run("UPDATE threads SET title = ?, updated_at = ? WHERE id = ?",[s,this.timestamp(),e]);return this.requireThreadDetails(e)}deleteThread(e){return this.requireThread(e),this.run("DELETE FROM threads WHERE id = ?",[e]).changes>0}addAnchor(e,t){let s=this.requireThread(e),n=this.normalizeAnchor(s.snapshot_id,t),i=this.get("SELECT MAX(anchor_order) + 1 AS next_order FROM anchors WHERE thread_id = ?",[e])?.next_order??0,o=this.newId(),a=this.timestamp();return this.insertAnchor(e,o,i,n,a),this.touchThread(e,a),this.requireAnchor(o)}updateAnchor(e,t){let s=this.getAnchorWithSnapshot(e);if(!s)throw new D("Anchor",e);let n=this.normalizeAnchor(s.snapshot_id,t),r=this.timestamp();return this.run(`UPDATE anchors SET
186
186
  kind = ?, path = ?, side = ?, start_line = ?, end_line = ?,
187
187
  context_text = ?, context_fingerprint = ?, updated_at = ?
188
188
  WHERE id = ?`,[n.kind,n.path,n.side,n.startLine,n.endLine,n.contextText??null,n.contextFingerprint??null,r,e]),this.touchThread(s.thread_id,r),this.requireAnchor(e)}deleteAnchor(e){let t=this.get(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
189
189
  context_text, context_fingerprint, created_at, updated_at
190
- FROM anchors WHERE id = ?`,[e]);if(!t)throw new D("Anchor",e);let s=this.run("DELETE FROM anchors WHERE id = ?",[e]).changes>0;if(s)this.touchThread(t.thread_id,this.timestamp());return s}createMessage(e){this.requireThread(e.threadId);let t=ft(e.body),s=e.role??"user",n=e.source??"local";Ea(s);let r=this.newId(),i=this.timestamp();return this.run(`INSERT INTO messages
190
+ FROM anchors WHERE id = ?`,[e]);if(!t)throw new D("Anchor",e);let s=this.run("DELETE FROM anchors WHERE id = ?",[e]).changes>0;if(s)this.touchThread(t.thread_id,this.timestamp());return s}createMessage(e){this.requireThread(e.threadId);let t=ft(e.body),s=e.role??"user",n=e.source??"local";Aa(s);let r=this.newId(),i=this.timestamp();return this.run(`INSERT INTO messages
191
191
  (id, thread_id, role, source, body, external_id, created_at, updated_at)
192
192
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,[r,e.threadId,s,n,t,e.externalId??null,i,i]),this.touchThread(e.threadId,i),this.requireMessage(r)}updateMessage(e,t){let s=this.get(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
193
193
  FROM messages WHERE id = ?`,[e]);if(!s)throw new D("Message",e);let n=this.timestamp();return this.run("UPDATE messages SET body = ?, updated_at = ? WHERE id = ?",[ft(t),n,e]),this.touchThread(s.thread_id,n),this.requireMessage(e)}deleteMessage(e){let t=this.get("SELECT thread_id FROM messages WHERE id = ?",[e]);if(!t)throw new D("Message",e);let s=this.run("DELETE FROM messages WHERE id = ?",[e]).changes>0;if(s)this.touchThread(t.thread_id,this.timestamp());return s}listMessages(e){return this.requireThread(e),this.all(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
@@ -207,9 +207,9 @@ Compare a branch with a local Git ref and open the review in your browser.
207
207
  body = excluded.body,
208
208
  updated_at = excluded.updated_at`,[n,e.snapshotId,t.kind,t.path,t.side,t.startLine,t.endLine,t.contextText??null,t.contextFingerprint??null,s,o,r]),this.requireDraft(n)}saveDraft(e){return this.upsertDraft(e)}getDraft(e){let t=this.get(`SELECT id, snapshot_id, anchor_kind, path, side, start_line, end_line,
209
209
  context_text, context_fingerprint, body, created_at, updated_at
210
- FROM drafts WHERE id = ?`,[e]);return t?ar(t):null}listDrafts(e){return this.requireSnapshot(e),this.all(`SELECT id, snapshot_id, anchor_kind, path, side, start_line, end_line,
210
+ FROM drafts WHERE id = ?`,[e]);return t?lr(t):null}listDrafts(e){return this.requireSnapshot(e),this.all(`SELECT id, snapshot_id, anchor_kind, path, side, start_line, end_line,
211
211
  context_text, context_fingerprint, body, created_at, updated_at
212
- FROM drafts WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map(ar)}deleteDraft(e){return this.run("DELETE FROM drafts WHERE id = ?",[e]).changes>0}createAgentSession(e={}){let t=this.newId(),s=this.timestamp(),n=e.provider??"codex",r=e.permissionMode??"read-only",i=e.status??"starting";return this.run(`INSERT INTO agent_sessions
212
+ FROM drafts WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map(lr)}deleteDraft(e){return this.run("DELETE FROM drafts WHERE id = ?",[e]).changes>0}createAgentSession(e={}){let t=this.newId(),s=this.timestamp(),n=e.provider??"codex",r=e.permissionMode??"read-only",i=e.status??"starting";return this.run(`INSERT INTO agent_sessions
213
213
  (id, provider, external_thread_id, model, reasoning_effort, permission_mode,
214
214
  status, status_message, last_event_at, created_at, updated_at)
215
215
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?)`,[t,n,e.externalThreadId??null,e.model??null,e.reasoningEffort??null,r,i,e.statusMessage??null,s,s]),this.requireAgentSession(t)}getAgentSession(e){let t=this.get(`SELECT id, provider, external_thread_id, model, reasoning_effort, permission_mode,
@@ -239,8 +239,11 @@ Compare a branch with a local Git ref and open the review in your browser.
239
239
  start_line, end_line, context_text, context_fingerprint, prompt, created_at
240
240
  FROM agent_session_contexts
241
241
  WHERE agent_session_id = ? AND snapshot_id = ?
242
- ORDER BY created_at ASC`,[s.id,e]).map(lr)}))}deleteAgentConversation(e,t){if(this.requireSnapshot(t),!this.get(`SELECT 1 AS found FROM agent_session_contexts
243
- WHERE agent_session_id = ? AND snapshot_id = ? LIMIT 1`,[e,t]))return!1;return this.run("DELETE FROM agent_sessions WHERE id = ?",[e]).changes>0}configureAndMigrate(){if(this.run("PRAGMA foreign_keys = ON"),this.run("PRAGMA busy_timeout = 5000"),this.databasePath!==":memory:")this.run("PRAGMA journal_mode = WAL");let t=this.get("PRAGMA user_version")?.user_version??0;if(t>ps)throw new Te(`Review database version ${t} is newer than supported version ${ps}`);if(t===ps)return;this.transaction(()=>{if(t<1){for(let s of wa)this.run(s);this.run("PRAGMA user_version = 1")}if(t<2){for(let s of ba)this.run(s);this.run(`INSERT OR IGNORE INTO agent_session_contexts
242
+ ORDER BY created_at ASC`,[s.id,e]).map(cr)}))}deleteAgentConversation(e,t){if(this.requireSnapshot(t),!this.get(`SELECT 1 AS found FROM agent_session_contexts
243
+ WHERE agent_session_id = ? AND snapshot_id = ? LIMIT 1`,[e,t]))return!1;return this.run("DELETE FROM agent_sessions WHERE id = ?",[e]).changes>0}configureAndMigrate(){if(this.run("PRAGMA foreign_keys = ON"),this.run("PRAGMA busy_timeout = 5000"),this.databasePath!==":memory:")this.run("PRAGMA journal_mode = WAL");let t=this.get("PRAGMA user_version")?.user_version??0;if(t>ps)throw new Te(`Review database version ${t} is newer than supported version ${ps}.
244
+
245
+ This usually means an older ReviewMe is running. Update and try again:
246
+ npx reviewme@latest`);if(t===ps)return;this.transaction(()=>{if(t<1){for(let s of Sa)this.run(s);this.run("PRAGMA user_version = 1")}if(t<2){for(let s of va)this.run(s);this.run(`INSERT OR IGNORE INTO agent_session_contexts
244
247
  (id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
245
248
  start_line, end_line, context_text, context_fingerprint, prompt, created_at)
246
249
  SELECT lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' ||
@@ -251,30 +254,30 @@ Compare a branch with a local Git ref and open the review in your browser.
251
254
  FROM thread_agent_sessions ts
252
255
  JOIN threads t ON t.id = ts.thread_id
253
256
  JOIN anchors a ON a.thread_id = t.id AND a.anchor_order = 0
254
- LEFT JOIN messages m ON m.thread_id = t.id AND m.source = 'local'`),this.run("PRAGMA user_version = 2")}if(t<3){for(let s of _a)this.run(s);this.run("PRAGMA user_version = 3")}})}timestamp(){let e=this.clock();if(typeof e!=="string"||!e)throw new L("Clock must return a non-empty timestamp");return e}newId(){let e=this.idFactory();if(typeof e!=="string"||!e)throw new L("ID factory must return a non-empty string");return e}transaction(e){this.run("BEGIN IMMEDIATE");try{let t=e();return this.run("COMMIT"),t}catch(t){try{this.run("ROLLBACK")}catch{}throw t}}run(e,t=[]){return this.prepare(e).run(...ms(t))}get(e,t=[]){let s=this.prepare(e).get(...ms(t));return s===void 0?null:s}all(e,t=[]){return this.prepare(e).all(...ms(t))}prepare(e){let t=this.statements.get(e);if(t)return t;let s=this.database.prepare(e);return this.statements.set(e,s),s}requireSnapshot(e){let t=this.getSnapshot(e);if(!t)throw new D("Review snapshot",e);return t}requireSnapshotWithRepository(e){let t=this.getSnapshotWithRepository(e);if(!t)throw new D("Review snapshot",e);return t}findSnapshotByIdentity(e,t,s,n){let r=this.get(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
257
+ LEFT JOIN messages m ON m.thread_id = t.id AND m.source = 'local'`),this.run("PRAGMA user_version = 2")}if(t<3){for(let s of Ea)this.run(s);this.run("PRAGMA user_version = 3")}})}timestamp(){let e=this.clock();if(typeof e!=="string"||!e)throw new L("Clock must return a non-empty timestamp");return e}newId(){let e=this.idFactory();if(typeof e!=="string"||!e)throw new L("ID factory must return a non-empty string");return e}transaction(e){this.run("BEGIN IMMEDIATE");try{let t=e();return this.run("COMMIT"),t}catch(t){try{this.run("ROLLBACK")}catch{}throw t}}run(e,t=[]){return this.prepare(e).run(...ms(t))}get(e,t=[]){let s=this.prepare(e).get(...ms(t));return s===void 0?null:s}all(e,t=[]){return this.prepare(e).all(...ms(t))}prepare(e){let t=this.statements.get(e);if(t)return t;let s=this.database.prepare(e);return this.statements.set(e,s),s}requireSnapshot(e){let t=this.getSnapshot(e);if(!t)throw new D("Review snapshot",e);return t}requireSnapshotWithRepository(e){let t=this.getSnapshotWithRepository(e);if(!t)throw new D("Review snapshot",e);return t}findSnapshotByIdentity(e,t,s,n){let r=this.get(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
255
258
  FROM review_snapshots
256
- WHERE repository_id = ? AND comparison_mode = ? AND base_sha = ? AND head_sha = ?`,[e,t,s,n]);return r?ht(r):null}normalizeSnapshotPath(e,t){let s=this.requireSnapshotWithRepository(e);try{return Se(s.repository.canonicalRoot,t).relativePath}catch(n){throw new L(n instanceof Error?n.message:String(n))}}normalizeAnchor(e,t){let s=this.normalizeSnapshotPath(e,t.path),n=t.kind;if(n!=="file"&&n!=="diff_range")throw new L("Anchor kind must be `file` or `diff_range`");let r=t.side??null,i=t.startLine??null,o=t.endLine??null;if(n==="file"){if(r!==null||i!==null||o!==null)throw new L("File anchors cannot include a diff side or line range")}else{if(r!=="old"&&r!=="new")throw new L("Diff anchors require an `old` or `new` side");if(!ir(i)||!ir(o)||o<i)throw new L("Diff anchors require a valid positive line range")}return{kind:n,path:s,side:r,startLine:i,endLine:o,contextText:ve(t.contextText),contextFingerprint:ve(t.contextFingerprint)}}insertAnchor(e,t,s,n,r){this.run(`INSERT INTO anchors
259
+ WHERE repository_id = ? AND comparison_mode = ? AND base_sha = ? AND head_sha = ?`,[e,t,s,n]);return r?ht(r):null}normalizeSnapshotPath(e,t){let s=this.requireSnapshotWithRepository(e);try{return Se(s.repository.canonicalRoot,t).relativePath}catch(n){throw new L(n instanceof Error?n.message:String(n))}}normalizeAnchor(e,t){let s=this.normalizeSnapshotPath(e,t.path),n=t.kind;if(n!=="file"&&n!=="diff_range")throw new L("Anchor kind must be `file` or `diff_range`");let r=t.side??null,i=t.startLine??null,o=t.endLine??null;if(n==="file"){if(r!==null||i!==null||o!==null)throw new L("File anchors cannot include a diff side or line range")}else{if(r!=="old"&&r!=="new")throw new L("Diff anchors require an `old` or `new` side");if(!or(i)||!or(o)||o<i)throw new L("Diff anchors require a valid positive line range")}return{kind:n,path:s,side:r,startLine:i,endLine:o,contextText:Ee(t.contextText),contextFingerprint:Ee(t.contextFingerprint)}}insertAnchor(e,t,s,n,r){this.run(`INSERT INTO anchors
257
260
  (id, thread_id, anchor_order, kind, path, side, start_line, end_line,
258
261
  context_text, context_fingerprint, created_at, updated_at)
259
262
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[t,e,s,n.kind,n.path,n.side,n.startLine,n.endLine,n.contextText??null,n.contextFingerprint??null,r,r])}requireThread(e){let t=this.get("SELECT id, snapshot_id, title, created_at, updated_at FROM threads WHERE id = ?",[e]);if(!t)throw new D("Review thread",e);return t}requireThreadDetails(e){let t=this.getThread(e);if(!t)throw new D("Review thread",e);return t}requireAgentContext(e){let t=this.get(`SELECT id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
260
263
  start_line, end_line, context_text, context_fingerprint, prompt, created_at
261
- FROM agent_session_contexts WHERE id = ?`,[e]);if(!t)throw new D("Agent context",e);return lr(t)}composeThreadDetails(e){let t=this.all(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
264
+ FROM agent_session_contexts WHERE id = ?`,[e]);if(!t)throw new D("Agent context",e);return cr(t)}composeThreadDetails(e){let t=this.all(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
262
265
  context_text, context_fingerprint, created_at, updated_at
263
- FROM anchors WHERE thread_id = ? ORDER BY anchor_order ASC, created_at ASC`,[e.id]).map(or),s=this.all(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
266
+ FROM anchors WHERE thread_id = ? ORDER BY anchor_order ASC, created_at ASC`,[e.id]).map(ar),s=this.all(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
264
267
  FROM messages WHERE thread_id = ? ORDER BY created_at ASC, id ASC`,[e.id]).map(ws),n=this.all(`SELECT s.id, s.provider, s.external_thread_id, s.model, s.reasoning_effort,
265
268
  s.permission_mode, s.status, s.status_message, s.last_event_at,
266
269
  s.created_at, s.updated_at
267
270
  FROM agent_sessions s
268
271
  JOIN thread_agent_sessions ts ON ts.agent_session_id = s.id
269
272
  WHERE ts.thread_id = ?
270
- ORDER BY ts.session_order ASC, s.created_at ASC`,[e.id]).map(pt);return{...va(e),anchors:t,messages:s,agentSessions:n}}lookupReviewedFile(e,t){let s=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,t]);return s?ys(s):null}requireAnchor(e){let t=this.get(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
273
+ ORDER BY ts.session_order ASC, s.created_at ASC`,[e.id]).map(pt);return{...Ra(e),anchors:t,messages:s,agentSessions:n}}lookupReviewedFile(e,t){let s=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,t]);return s?ys(s):null}requireAnchor(e){let t=this.get(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
271
274
  context_text, context_fingerprint, created_at, updated_at
272
- FROM anchors WHERE id = ?`,[e]);if(!t)throw new D("Anchor",e);return or(t)}getAnchorWithSnapshot(e){return this.get(`SELECT a.id, a.thread_id, a.anchor_order, a.kind, a.path, a.side, a.start_line, a.end_line,
275
+ FROM anchors WHERE id = ?`,[e]);if(!t)throw new D("Anchor",e);return ar(t)}getAnchorWithSnapshot(e){return this.get(`SELECT a.id, a.thread_id, a.anchor_order, a.kind, a.path, a.side, a.start_line, a.end_line,
273
276
  a.context_text, a.context_fingerprint, a.created_at, a.updated_at,
274
277
  t.snapshot_id
275
278
  FROM anchors a JOIN threads t ON t.id = a.thread_id
276
279
  WHERE a.id = ?`,[e])}requireMessage(e){let t=this.get(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
277
- FROM messages WHERE id = ?`,[e]);if(!t)throw new D("Message",e);return ws(t)}requireDraft(e){let t=this.getDraft(e);if(!t)throw new D("Draft",e);return t}requireAgentSession(e){let t=this.getAgentSession(e);if(!t)throw new D("Agent session",e);return t}touchThread(e,t){this.run("UPDATE threads SET updated_at = ? WHERE id = ?",[t,e])}}var wa=[`CREATE TABLE repositories (
280
+ FROM messages WHERE id = ?`,[e]);if(!t)throw new D("Message",e);return ws(t)}requireDraft(e){let t=this.getDraft(e);if(!t)throw new D("Draft",e);return t}requireAgentSession(e){let t=this.getAgentSession(e);if(!t)throw new D("Agent session",e);return t}touchThread(e,t){this.run("UPDATE threads SET updated_at = ? WHERE id = ?",[t,e])}}var Sa=[`CREATE TABLE repositories (
278
281
  id TEXT PRIMARY KEY,
279
282
  canonical_root TEXT NOT NULL UNIQUE,
280
283
  remote_origin TEXT,
@@ -370,7 +373,7 @@ Compare a branch with a local Git ref and open the review in your browser.
370
373
  created_at TEXT NOT NULL,
371
374
  PRIMARY KEY(thread_id, agent_session_id),
372
375
  UNIQUE(thread_id, session_order)
373
- )`,"CREATE INDEX idx_review_snapshots_repository ON review_snapshots(repository_id, updated_at DESC)","CREATE INDEX idx_reviewed_files_snapshot ON reviewed_files(snapshot_id, path)","CREATE INDEX idx_threads_snapshot ON threads(snapshot_id, updated_at DESC)","CREATE INDEX idx_anchors_thread ON anchors(thread_id, anchor_order)","CREATE INDEX idx_messages_thread ON messages(thread_id, created_at)","CREATE INDEX idx_drafts_snapshot ON drafts(snapshot_id, updated_at DESC)","CREATE INDEX idx_thread_agent_sessions_thread ON thread_agent_sessions(thread_id, session_order)"],ba=[`CREATE TABLE IF NOT EXISTS agent_session_contexts (
376
+ )`,"CREATE INDEX idx_review_snapshots_repository ON review_snapshots(repository_id, updated_at DESC)","CREATE INDEX idx_reviewed_files_snapshot ON reviewed_files(snapshot_id, path)","CREATE INDEX idx_threads_snapshot ON threads(snapshot_id, updated_at DESC)","CREATE INDEX idx_anchors_thread ON anchors(thread_id, anchor_order)","CREATE INDEX idx_messages_thread ON messages(thread_id, created_at)","CREATE INDEX idx_drafts_snapshot ON drafts(snapshot_id, updated_at DESC)","CREATE INDEX idx_thread_agent_sessions_thread ON thread_agent_sessions(thread_id, session_order)"],va=[`CREATE TABLE IF NOT EXISTS agent_session_contexts (
374
377
  id TEXT PRIMARY KEY,
375
378
  agent_session_id TEXT NOT NULL REFERENCES agent_sessions(id) ON DELETE CASCADE,
376
379
  snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
@@ -386,23 +389,25 @@ Compare a branch with a local Git ref and open the review in your browser.
386
389
  created_at TEXT NOT NULL,
387
390
  CHECK ((anchor_kind = 'file' AND side IS NULL AND start_line IS NULL AND end_line IS NULL)
388
391
  OR (anchor_kind = 'diff_range' AND side IS NOT NULL AND start_line > 0 AND end_line >= start_line))
389
- )`,"CREATE INDEX IF NOT EXISTS idx_agent_contexts_snapshot ON agent_session_contexts(snapshot_id, created_at DESC)","CREATE INDEX IF NOT EXISTS idx_agent_contexts_session ON agent_session_contexts(agent_session_id, created_at)"],_a=[`CREATE TABLE IF NOT EXISTS app_preferences (
392
+ )`,"CREATE INDEX IF NOT EXISTS idx_agent_contexts_snapshot ON agent_session_contexts(snapshot_id, created_at DESC)","CREATE INDEX IF NOT EXISTS idx_agent_contexts_session ON agent_session_contexts(agent_session_id, created_at)"],Ea=[`CREATE TABLE IF NOT EXISTS app_preferences (
390
393
  id INTEGER PRIMARY KEY CHECK (id = 1),
391
394
  browser_tab_title TEXT NOT NULL DEFAULT 'branch'
392
395
  CHECK (browser_tab_title IN ('repository', 'directory', 'branch', 'diff'))
393
- )`];function nr(e){if(typeof e!=="string"||!e.trim())throw new L("Repository root is required");try{return fa(mt(e))}catch(t){throw new L(`Repository root does not exist: ${e}`)}}function rr(e,t){if(typeof e!=="string"||!e.trim()||/[\0\r\n]/.test(e))throw new L(`${t} is required`);return e}function ve(e){if(e===void 0||e===null)return null;if(typeof e!=="string")throw new L("Text fields must be strings");if(/\0/.test(e))throw new L("Text fields cannot contain NUL bytes");return e}function ms(e){return e.map((t)=>{if(t===void 0)return null;if(typeof t==="boolean")return t?1:0;return t})}function ft(e){if(typeof e!=="string"||!e.trim())throw new L("Comment body cannot be empty");if(/\0/.test(e))throw new L("Comment body cannot contain NUL bytes");return e}function ir(e){return e!==null&&Number.isSafeInteger(e)&&e>0}function Sa(e){if(e!=="merge-base"&&e!=="direct")throw new L("Comparison mode must be `merge-base` or `direct`")}function Ea(e){if(e!=="user"&&e!=="assistant"&&e!=="system")throw new L("Message role is invalid")}function gs(e){return{id:e.id,canonicalRoot:e.canonical_root,remoteOrigin:e.remote_origin,createdAt:e.created_at,updatedAt:e.updated_at}}function ht(e){return{id:e.id,repositoryId:e.repository_id,comparisonMode:e.comparison_mode,baseRef:e.base_ref,headRef:e.head_ref,baseSha:e.base_sha,headSha:e.head_sha,createdAt:e.created_at,updatedAt:e.updated_at}}function ys(e){return{snapshotId:e.snapshot_id,path:e.path,reviewedAt:e.reviewed_at}}function va(e){return{id:e.id,snapshotId:e.snapshot_id,title:e.title,createdAt:e.created_at,updatedAt:e.updated_at}}function or(e){return{id:e.id,threadId:e.thread_id,order:e.anchor_order,kind:e.kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint,createdAt:e.created_at,updatedAt:e.updated_at}}function ws(e){return{id:e.id,threadId:e.thread_id,role:e.role,source:e.source,body:e.body,externalId:e.external_id,createdAt:e.created_at,updatedAt:e.updated_at}}function ar(e){return{id:e.id,snapshotId:e.snapshot_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},body:e.body,createdAt:e.created_at,updatedAt:e.updated_at}}function pt(e){return{id:e.id,provider:e.provider,externalThreadId:e.external_thread_id,model:e.model,reasoningEffort:e.reasoning_effort,permissionMode:e.permission_mode,status:e.status,statusMessage:e.status_message,lastEventAt:e.last_event_at,createdAt:e.created_at,updatedAt:e.updated_at}}function bs(e){return{threadId:e.thread_id,agentSessionId:e.agent_session_id,order:e.session_order,createdAt:e.created_at}}function lr(e){return{id:e.id,agentSessionId:e.agent_session_id,snapshotId:e.snapshot_id,sourceThreadId:e.source_thread_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},prompt:e.prompt,createdAt:e.created_at}}import{spawn as Ta}from"node:child_process";import{Readable as cr}from"node:stream";var Aa="codex",Ra="reviewme",Ca="0.1.0",Na=8388608,xa=8192,Oa=1000;class O extends Error{code;retryable;constructor(e,t,s={}){super(t,s.cause===void 0?void 0:{cause:s.cause});this.name="CodexAgentProviderError",this.code=e,this.retryable=s.retryable??e==="disconnected"}}class ur{values=[];waiters=[];done=!1;failure;push(e){if(this.done)return;let t=this.waiters.shift();if(t)t.resolve({done:!1,value:e});else this.values.push(e)}close(){if(this.done)return;this.done=!0;while(this.waiters.length>0)this.waiters.shift()?.resolve({done:!0,value:void 0})}fail(e){if(this.done)return;this.done=!0,this.failure=e;while(this.waiters.length>0)this.waiters.shift()?.reject(e)}async next(){if(this.values.length>0)return{done:!1,value:this.values.shift()};if(this.done){if(this.failure!==void 0)throw this.failure;return{done:!0,value:void 0}}return new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}async return(){return this.close(),{done:!0,value:void 0}}[Symbol.asyncIterator](){return this}}function La(e,t){return new Promise((s,n)=>{let r=()=>{e.off("drain",i),e.off("error",o),e.off("close",a)},i=()=>{r(),s(t)},o=(l)=>{r(),n(l)},a=()=>{r(),n(Error("Codex stdin closed before the request was flushed"))};e.once("drain",i),e.once("error",o),e.once("close",a)})}function ka(e){return{write(t){let s=typeof t==="string"?Buffer.from(t):Buffer.from(t);return e.write(s)?s.byteLength:La(e,s.byteLength)},end(){e.end()}}}function Ia(e){let[t,...s]=e;if(!t)throw Error("Codex command cannot be empty");let n=Ta(t,s,{stdio:["pipe","pipe","pipe"]});if(!n.stdin||!n.stdout||!n.stderr)throw n.kill(),Error("Codex app-server did not provide piped stdio");let r=new Promise((o,a)=>{let l=()=>{n.off("error",c),o()},c=(p)=>{n.off("spawn",l),a(p)};n.once("spawn",l),n.once("error",c)}),i=new Promise((o)=>{let a=()=>{n.off("close",l),o(-1)},l=(c)=>{n.off("error",a),o(c??1)};n.once("error",a),n.once("close",l)});return{stdin:ka(n.stdin),stdout:cr.toWeb(n.stdout),stderr:cr.toWeb(n.stderr),exited:i,ready:r,kill(o){n.kill(o)}}}function fe(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new O("protocol",`Codex returned an invalid ${t}`);return e}function M(e){return typeof e==="string"&&e.length>0?e:void 0}function Es(e,t){let s=M(e);if(!s)throw new O("protocol",`Codex response is missing ${t}`);return s}function ue(e){if(e instanceof Error)return e.message;return String(e)}function Pa(e){return/auth|login|log in|unauthori[sz]ed|credential|token/i.test(e)}function Ma(e,t){if(Pa(e))return new O("not-authenticated",`Codex is not authenticated. Run codex login, then retry. (${e})`,{retryable:!1,cause:t});return new O("request-failed",e,{retryable:!0,cause:t})}function Ss(e){return!!e&&typeof e==="object"&&"then"in e&&typeof e.then==="function"}function Da(e){if(!Array.isArray(e))return"";return e.map((t)=>{let s=t&&typeof t==="object"?t:void 0;return typeof s?.text==="string"?s.text:""}).filter(Boolean).join(`
394
- `)}function qa(e){let t=Array.isArray(e.turns)?e.turns:[],s=[];for(let n of t){if(!n||typeof n!=="object")continue;let r=n,i=M(r.id)??null;if(!Array.isArray(r.items))continue;for(let o of r.items){if(!o||typeof o!=="object")continue;let a=o,l=M(a.id);if(!l)continue;if(a.type==="userMessage"){let c=Da(a.content);if(c)s.push({id:l,turnId:i,role:"user",text:c})}else if(a.type==="agentMessage"&&typeof a.text==="string")s.push({id:l,turnId:i,role:"assistant",text:a.text})}}return s}function Fa(e){return e??"read-only"}function dr(e){if(Fa(e)!=="read-only")throw new O("unsupported","Codex sessions are read-only in this version of ReviewMe",{retryable:!1})}function $a(e){if(e==="completed"||e==="interrupted"||e==="failed"||e==="inProgress")return e==="inProgress"?"in-progress":e;return typeof e==="string"?e:"completed"}function Ua(e){let t=fe(e,"model"),s=Es(t.id??t.model,"model id"),n=Array.isArray(t.supportedReasoningEfforts)?t.supportedReasoningEfforts.map((r)=>{if(!r||typeof r!=="object")return;let i=r,o=M(i.reasoningEffort??i.reasoning_effort);return o?{value:o,description:typeof i.description==="string"?i.description:""}:void 0}).filter((r)=>r!==void 0):[];return{id:s,displayName:M(t.displayName??t.display_name)??s,description:typeof t.description==="string"?t.description:"",hidden:t.hidden===!0,isDefault:t.isDefault===!0||t.is_default===!0,defaultReasoningEffort:M(t.defaultReasoningEffort??t.default_reasoning_effort)??null,supportedReasoningEfforts:n}}class vs{id="codex";command;clientName;clientVersion;processFactory;connection;starting;everStarted=!1;restartUsed=!1;closed=!1;sessions=new Map;activeTurns=new Map;constructor(e={}){this.command=e.command??Aa,this.clientName=e.clientName??Ra,this.clientVersion=e.clientVersion??Ca,this.processFactory=e.processFactory??Ia}async listModels(){let e,t=[],s=new Set;do{let n={includeHidden:!1,limit:100};if(e)n.cursor=e;let r=fe(await this.request("model/list",n),"model list response");if(!Array.isArray(r.data))throw new O("protocol","Codex model list response is missing data");for(let o of r.data)t.push(Ua(o));let i=M(r.nextCursor??r.next_cursor);if(!i)break;if(s.has(i))throw new O("protocol","Codex model list returned a repeated cursor");s.add(i),e=i}while(!0);return t}async startThread(e){dr(e.permissionMode),this.ensureCwd(e.cwd);let t={cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only"};if(e.model)t.model=e.model;if(e.serviceTier)t.serviceTier=e.serviceTier;let s=fe(await this.request("thread/start",t),"thread start response");return this.threadResult(s,e)}async resumeThread(e){if(dr(e.permissionMode),this.ensureCwd(e.cwd),!e.externalThreadId.trim())throw new O("invalid","A Codex thread id is required to resume a thread",{retryable:!1});let t={threadId:e.externalThreadId,cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only",excludeTurns:!1};if(e.model)t.model=e.model;let s=fe(await this.request("thread/resume",t),"thread resume response");return this.threadResult(s,e)}async sendMessage(e,t){if(!e.trim())throw new O("invalid","A Codex thread id is required to send a message",{retryable:!1});if(!t.text.trim())throw new O("invalid","A Codex message cannot be empty",{retryable:!1});if(this.activeTurns.has(e))throw new O("invalid","This Codex thread already has an active turn",{retryable:!1});let s=await this.ensureConnection(),n=new ur,r={sessionId:e,connection:s,queue:n,turnId:void 0,startedEmitted:!1};this.activeTurns.set(e,r);let i={threadId:e,input:[{type:"text",text:t.text,text_elements:[]}]},o=this.sessions.get(e),a=t.reasoningEffort??o?.reasoningEffort;if(a)i.effort=a;try{let l=fe(await this.requestOnConnection(s,"turn/start",i),"turn start response"),c=fe(l.turn,"turn");if(r.turnId=Es(c.id,"turn id"),!r.startedEmitted)r.startedEmitted=!0,n.push({type:"started",sessionId:e,turnId:r.turnId});let p=this.sessions.get(e);if(p)this.sessions.set(e,{...p,status:"running"});return{turnId:r.turnId,events:n,stop:()=>this.stop(e,r.turnId)}}catch(l){if(this.activeTurns.get(e)===r)this.activeTurns.delete(e);throw n.fail(l),l}}async stop(e,t){let s=this.activeTurns.get(e),n=t??s?.turnId;if(!n)return;let r=s?.connection??await this.ensureConnection();if(await this.requestOnConnection(r,"turn/interrupt",{threadId:e,turnId:n}),s&&s.turnId===n){s.queue.push({type:"stopped",sessionId:e,turnId:n}),s.queue.close(),this.activeTurns.delete(e);let i=this.sessions.get(e);if(i)this.sessions.set(e,{...i,status:"ready"})}}async close(){if(this.closed)return;this.closed=!0;let e=this.connection;if(e){this.handleConnectionClosed(e,"Codex provider closed");try{let t=e.process.stdin.end?.();if(Ss(t))await t}catch{}try{e.process.kill()}catch{}await Promise.race([e.process.exited.catch(()=>-1),new Promise((t)=>setTimeout(()=>t(-1),Oa))])}if(this.starting)try{await this.starting}catch{}}ensureCwd(e){if(!e||typeof e!=="string")throw new O("invalid","A repository working directory is required",{retryable:!1})}threadResult(e,t){let s=fe(e.thread,"thread"),n=Es(s.id,"thread id"),r=M(e.cwd)??t.cwd,i=M(e.model)??t.model??null,o=t.reasoningEffort??M(e.reasoningEffort??e.reasoning_effort)??null,a={id:n,provider:this.id,externalThreadId:n,cwd:r,model:i,reasoningEffort:o,permissionMode:"read-only",status:"ready"};return this.sessions.set(n,a),{session:a,history:qa(s)}}async request(e,t){let s=await this.ensureConnection();return this.requestOnConnection(s,e,t)}async requestOnConnection(e,t,s){if(e.closed)throw new O("disconnected","The Codex app-server connection is closed");let n=String(e.nextRequestId++),r=new Promise((i,o)=>{e.pending.set(n,{method:t,resolve:i,reject:o})});try{await this.writeMessage(e,{id:Number(n),method:t,params:s})}catch(i){e.pending.delete(n);let o=i instanceof O?i:new O("disconnected",`Unable to send ${t} to Codex: ${ue(i)}`,{cause:i});throw this.handleConnectionClosed(e,o.message),o}return r}async writeMessage(e,t){if(e.closed)throw new O("disconnected","The Codex app-server connection is closed");let s=e.process.stdin.write(`${JSON.stringify(t)}
395
- `);if(Ss(s))await s;let n=e.process.stdin.flush?.();if(Ss(n))await n}async sendNotification(e,t,s){await this.writeMessage(e,{method:t,...s===void 0?{}:{params:s}})}async ensureConnection(){if(this.closed)throw new O("disconnected","The Codex provider has been closed",{retryable:!1});if(this.starting)return this.starting;if(this.connection&&!this.connection.closed)return this.connection;if(this.everStarted&&this.restartUsed)throw new O("disconnected","The Codex app-server disconnected and its one automatic restart was already used");if(this.everStarted)this.restartUsed=!0;let e=this.openConnection();this.starting=e;try{return await e}finally{if(this.starting===e)this.starting=void 0}}async openConnection(){let e;try{if(e=this.processFactory([this.command,"app-server","--stdio"]),e.ready)await e.ready}catch(s){let n=ue(s),r=/ENOENT|not found|cannot find/i.test(n)?"missing":"disconnected";throw new O(r,r==="missing"?`Codex CLI was not found at ${this.command}. Install Codex or configure its executable.`:`Unable to start Codex app-server: ${n}`,{cause:s,retryable:r==="disconnected"})}this.everStarted=!0;let t={process:e,pending:new Map,nextRequestId:1,closed:!1,stderrTail:""};if(this.connection=t,this.consumeStdout(t),e.stderr)this.consumeStderr(t);e.exited.then((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited with code ${s}${t.stderrTail?`: ${t.stderrTail}`:""}`)}).catch((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited unexpectedly: ${ue(s)}`)});try{return await this.requestOnConnection(t,"initialize",{clientInfo:{name:this.clientName,title:"ReviewMe",version:this.clientVersion},capabilities:{experimentalApi:!0,requestAttestation:!1}}),await this.sendNotification(t,"initialized"),t}catch(s){if(!t.closed){try{t.process.kill()}catch{}this.handleConnectionClosed(t,ue(s))}throw s instanceof O?s:new O("disconnected",`Codex initialization failed: ${ue(s)}`,{cause:s})}}async consumeStdout(e){let t=e.process.stdout.getReader(),s=new TextDecoder,n="";try{while(!e.closed){let{done:i,value:o}=await t.read();if(i)break;if(n+=s.decode(o,{stream:!0}),new TextEncoder().encode(n).byteLength>Na){this.handleConnectionClosed(e,"Codex protocol line exceeded the maximum size");return}let a=n.indexOf(`
396
+ )`];function rr(e){if(typeof e!=="string"||!e.trim())throw new L("Repository root is required");try{return ma(mt(e))}catch(t){throw new L(`Repository root does not exist: ${e}`)}}function ir(e,t){if(typeof e!=="string"||!e.trim()||/[\0\r\n]/.test(e))throw new L(`${t} is required`);return e}function Ee(e){if(e===void 0||e===null)return null;if(typeof e!=="string")throw new L("Text fields must be strings");if(/\0/.test(e))throw new L("Text fields cannot contain NUL bytes");return e}function ms(e){return e.map((t)=>{if(t===void 0)return null;if(typeof t==="boolean")return t?1:0;return t})}function ft(e){if(typeof e!=="string"||!e.trim())throw new L("Comment body cannot be empty");if(/\0/.test(e))throw new L("Comment body cannot contain NUL bytes");return e}function or(e){return e!==null&&Number.isSafeInteger(e)&&e>0}function Ta(e){if(e!=="merge-base"&&e!=="direct")throw new L("Comparison mode must be `merge-base` or `direct`")}function Aa(e){if(e!=="user"&&e!=="assistant"&&e!=="system")throw new L("Message role is invalid")}function gs(e){return{id:e.id,canonicalRoot:e.canonical_root,remoteOrigin:e.remote_origin,createdAt:e.created_at,updatedAt:e.updated_at}}function ht(e){return{id:e.id,repositoryId:e.repository_id,comparisonMode:e.comparison_mode,baseRef:e.base_ref,headRef:e.head_ref,baseSha:e.base_sha,headSha:e.head_sha,createdAt:e.created_at,updatedAt:e.updated_at}}function ys(e){return{snapshotId:e.snapshot_id,path:e.path,reviewedAt:e.reviewed_at}}function Ra(e){return{id:e.id,snapshotId:e.snapshot_id,title:e.title,createdAt:e.created_at,updatedAt:e.updated_at}}function ar(e){return{id:e.id,threadId:e.thread_id,order:e.anchor_order,kind:e.kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint,createdAt:e.created_at,updatedAt:e.updated_at}}function ws(e){return{id:e.id,threadId:e.thread_id,role:e.role,source:e.source,body:e.body,externalId:e.external_id,createdAt:e.created_at,updatedAt:e.updated_at}}function lr(e){return{id:e.id,snapshotId:e.snapshot_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},body:e.body,createdAt:e.created_at,updatedAt:e.updated_at}}function pt(e){return{id:e.id,provider:e.provider,externalThreadId:e.external_thread_id,model:e.model,reasoningEffort:e.reasoning_effort,permissionMode:e.permission_mode,status:e.status,statusMessage:e.status_message,lastEventAt:e.last_event_at,createdAt:e.created_at,updatedAt:e.updated_at}}function bs(e){return{threadId:e.thread_id,agentSessionId:e.agent_session_id,order:e.session_order,createdAt:e.created_at}}function cr(e){return{id:e.id,agentSessionId:e.agent_session_id,snapshotId:e.snapshot_id,sourceThreadId:e.source_thread_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},prompt:e.prompt,createdAt:e.created_at}}import{spawn as Ca}from"node:child_process";import{Readable as dr}from"node:stream";var Na="codex",xa="reviewme",Oa="0.1.0",La=8388608,ka=8192,Ia=1000;class O extends Error{code;retryable;constructor(e,t,s={}){super(t,s.cause===void 0?void 0:{cause:s.cause});this.name="CodexAgentProviderError",this.code=e,this.retryable=s.retryable??e==="disconnected"}}class fr{values=[];waiters=[];done=!1;failure;push(e){if(this.done)return;let t=this.waiters.shift();if(t)t.resolve({done:!1,value:e});else this.values.push(e)}close(){if(this.done)return;this.done=!0;while(this.waiters.length>0)this.waiters.shift()?.resolve({done:!0,value:void 0})}fail(e){if(this.done)return;this.done=!0,this.failure=e;while(this.waiters.length>0)this.waiters.shift()?.reject(e)}async next(){if(this.values.length>0)return{done:!1,value:this.values.shift()};if(this.done){if(this.failure!==void 0)throw this.failure;return{done:!0,value:void 0}}return new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}async return(){return this.close(),{done:!0,value:void 0}}[Symbol.asyncIterator](){return this}}function Pa(e,t){return new Promise((s,n)=>{let r=()=>{e.off("drain",i),e.off("error",o),e.off("close",a)},i=()=>{r(),s(t)},o=(l)=>{r(),n(l)},a=()=>{r(),n(Error("Codex stdin closed before the request was flushed"))};e.once("drain",i),e.once("error",o),e.once("close",a)})}function Ma(e){return{write(t){let s=typeof t==="string"?Buffer.from(t):Buffer.from(t);return e.write(s)?s.byteLength:Pa(e,s.byteLength)},end(){e.end()}}}function Da(e){let[t,...s]=e;if(!t)throw Error("Codex command cannot be empty");let n=Ca(t,s,{stdio:["pipe","pipe","pipe"]});if(!n.stdin||!n.stdout||!n.stderr)throw n.kill(),Error("Codex app-server did not provide piped stdio");let r=new Promise((o,a)=>{let l=()=>{n.off("error",c),o()},c=(p)=>{n.off("spawn",l),a(p)};n.once("spawn",l),n.once("error",c)}),i=new Promise((o)=>{let a=()=>{n.off("close",l),o(-1)},l=(c)=>{n.off("error",a),o(c??1)};n.once("error",a),n.once("close",l)});return{stdin:Ma(n.stdin),stdout:dr.toWeb(n.stdout),stderr:dr.toWeb(n.stderr),exited:i,ready:r,kill(o){n.kill(o)}}}function fe(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new O("protocol",`Codex returned an invalid ${t}`);return e}function M(e){return typeof e==="string"&&e.length>0?e:void 0}function vs(e,t){let s=M(e);if(!s)throw new O("protocol",`Codex response is missing ${t}`);return s}function ue(e){if(e instanceof Error)return e.message;return String(e)}function qa(e){return/auth|login|log in|unauthori[sz]ed|credential|token/i.test(e)}function Fa(e,t){if(qa(e))return new O("not-authenticated",`Codex is not authenticated. Run codex login, then retry. (${e})`,{retryable:!1,cause:t});return new O("request-failed",e,{retryable:!0,cause:t})}function Ss(e){return!!e&&typeof e==="object"&&"then"in e&&typeof e.then==="function"}function $a(e){if(!Array.isArray(e))return"";return e.map((t)=>{let s=t&&typeof t==="object"?t:void 0;return typeof s?.text==="string"?s.text:""}).filter(Boolean).join(`
397
+ `)}function Ua(e){let t=Array.isArray(e.turns)?e.turns:[],s=[];for(let n of t){if(!n||typeof n!=="object")continue;let r=n,i=M(r.id)??null;if(!Array.isArray(r.items))continue;for(let o of r.items){if(!o||typeof o!=="object")continue;let a=o,l=M(a.id);if(!l)continue;if(a.type==="userMessage"){let c=$a(a.content);if(c)s.push({id:l,turnId:i,role:"user",text:c})}else if(a.type==="agentMessage"&&typeof a.text==="string")s.push({id:l,turnId:i,role:"assistant",text:a.text})}}return s}function Ba(e){return e??"read-only"}function ur(e){if(Ba(e)!=="read-only")throw new O("unsupported","Codex sessions are read-only in this version of ReviewMe",{retryable:!1})}function ja(e){if(e==="completed"||e==="interrupted"||e==="failed"||e==="inProgress")return e==="inProgress"?"in-progress":e;return typeof e==="string"?e:"completed"}function Ka(e){let t=fe(e,"model"),s=vs(t.id??t.model,"model id"),n=Array.isArray(t.supportedReasoningEfforts)?t.supportedReasoningEfforts.map((r)=>{if(!r||typeof r!=="object")return;let i=r,o=M(i.reasoningEffort??i.reasoning_effort);return o?{value:o,description:typeof i.description==="string"?i.description:""}:void 0}).filter((r)=>r!==void 0):[];return{id:s,displayName:M(t.displayName??t.display_name)??s,description:typeof t.description==="string"?t.description:"",hidden:t.hidden===!0,isDefault:t.isDefault===!0||t.is_default===!0,defaultReasoningEffort:M(t.defaultReasoningEffort??t.default_reasoning_effort)??null,supportedReasoningEfforts:n}}class Es{id="codex";command;clientName;clientVersion;processFactory;connection;starting;everStarted=!1;restartUsed=!1;closed=!1;sessions=new Map;activeTurns=new Map;constructor(e={}){this.command=e.command??Na,this.clientName=e.clientName??xa,this.clientVersion=e.clientVersion??Oa,this.processFactory=e.processFactory??Da}async listModels(){let e,t=[],s=new Set;do{let n={includeHidden:!1,limit:100};if(e)n.cursor=e;let r=fe(await this.request("model/list",n),"model list response");if(!Array.isArray(r.data))throw new O("protocol","Codex model list response is missing data");for(let o of r.data)t.push(Ka(o));let i=M(r.nextCursor??r.next_cursor);if(!i)break;if(s.has(i))throw new O("protocol","Codex model list returned a repeated cursor");s.add(i),e=i}while(!0);return t}async startThread(e){ur(e.permissionMode),this.ensureCwd(e.cwd);let t={cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only"};if(e.model)t.model=e.model;if(e.serviceTier)t.serviceTier=e.serviceTier;let s=fe(await this.request("thread/start",t),"thread start response");return this.threadResult(s,e)}async resumeThread(e){if(ur(e.permissionMode),this.ensureCwd(e.cwd),!e.externalThreadId.trim())throw new O("invalid","A Codex thread id is required to resume a thread",{retryable:!1});let t={threadId:e.externalThreadId,cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only",excludeTurns:!1};if(e.model)t.model=e.model;let s=fe(await this.request("thread/resume",t),"thread resume response");return this.threadResult(s,e)}async sendMessage(e,t){if(!e.trim())throw new O("invalid","A Codex thread id is required to send a message",{retryable:!1});if(!t.text.trim())throw new O("invalid","A Codex message cannot be empty",{retryable:!1});if(this.activeTurns.has(e))throw new O("invalid","This Codex thread already has an active turn",{retryable:!1});let s=await this.ensureConnection(),n=new fr,r={sessionId:e,connection:s,queue:n,turnId:void 0,startedEmitted:!1};this.activeTurns.set(e,r);let i={threadId:e,input:[{type:"text",text:t.text,text_elements:[]}]},o=this.sessions.get(e),a=t.reasoningEffort??o?.reasoningEffort;if(a)i.effort=a;try{let l=fe(await this.requestOnConnection(s,"turn/start",i),"turn start response"),c=fe(l.turn,"turn");if(r.turnId=vs(c.id,"turn id"),!r.startedEmitted)r.startedEmitted=!0,n.push({type:"started",sessionId:e,turnId:r.turnId});let p=this.sessions.get(e);if(p)this.sessions.set(e,{...p,status:"running"});return{turnId:r.turnId,events:n,stop:()=>this.stop(e,r.turnId)}}catch(l){if(this.activeTurns.get(e)===r)this.activeTurns.delete(e);throw n.fail(l),l}}async stop(e,t){let s=this.activeTurns.get(e),n=t??s?.turnId;if(!n)return;let r=s?.connection??await this.ensureConnection();if(await this.requestOnConnection(r,"turn/interrupt",{threadId:e,turnId:n}),s&&s.turnId===n){s.queue.push({type:"stopped",sessionId:e,turnId:n}),s.queue.close(),this.activeTurns.delete(e);let i=this.sessions.get(e);if(i)this.sessions.set(e,{...i,status:"ready"})}}async close(){if(this.closed)return;this.closed=!0;let e=this.connection;if(e){this.handleConnectionClosed(e,"Codex provider closed");try{let t=e.process.stdin.end?.();if(Ss(t))await t}catch{}try{e.process.kill()}catch{}await Promise.race([e.process.exited.catch(()=>-1),new Promise((t)=>setTimeout(()=>t(-1),Ia))])}if(this.starting)try{await this.starting}catch{}}ensureCwd(e){if(!e||typeof e!=="string")throw new O("invalid","A repository working directory is required",{retryable:!1})}threadResult(e,t){let s=fe(e.thread,"thread"),n=vs(s.id,"thread id"),r=M(e.cwd)??t.cwd,i=M(e.model)??t.model??null,o=t.reasoningEffort??M(e.reasoningEffort??e.reasoning_effort)??null,a={id:n,provider:this.id,externalThreadId:n,cwd:r,model:i,reasoningEffort:o,permissionMode:"read-only",status:"ready"};return this.sessions.set(n,a),{session:a,history:Ua(s)}}async request(e,t){let s=await this.ensureConnection();return this.requestOnConnection(s,e,t)}async requestOnConnection(e,t,s){if(e.closed)throw new O("disconnected","The Codex app-server connection is closed");let n=String(e.nextRequestId++),r=new Promise((i,o)=>{e.pending.set(n,{method:t,resolve:i,reject:o})});try{await this.writeMessage(e,{id:Number(n),method:t,params:s})}catch(i){e.pending.delete(n);let o=i instanceof O?i:new O("disconnected",`Unable to send ${t} to Codex: ${ue(i)}`,{cause:i});throw this.handleConnectionClosed(e,o.message),o}return r}async writeMessage(e,t){if(e.closed)throw new O("disconnected","The Codex app-server connection is closed");let s=e.process.stdin.write(`${JSON.stringify(t)}
398
+ `);if(Ss(s))await s;let n=e.process.stdin.flush?.();if(Ss(n))await n}async sendNotification(e,t,s){await this.writeMessage(e,{method:t,...s===void 0?{}:{params:s}})}async ensureConnection(){if(this.closed)throw new O("disconnected","The Codex provider has been closed",{retryable:!1});if(this.starting)return this.starting;if(this.connection&&!this.connection.closed)return this.connection;if(this.everStarted&&this.restartUsed)throw new O("disconnected","The Codex app-server disconnected and its one automatic restart was already used");if(this.everStarted)this.restartUsed=!0;let e=this.openConnection();this.starting=e;try{return await e}finally{if(this.starting===e)this.starting=void 0}}async openConnection(){let e;try{if(e=this.processFactory([this.command,"app-server","--stdio"]),e.ready)await e.ready}catch(s){let n=ue(s),r=/ENOENT|not found|cannot find/i.test(n)?"missing":"disconnected";throw new O(r,r==="missing"?`Codex CLI was not found at ${this.command}. Install Codex or configure its executable.`:`Unable to start Codex app-server: ${n}`,{cause:s,retryable:r==="disconnected"})}this.everStarted=!0;let t={process:e,pending:new Map,nextRequestId:1,closed:!1,stderrTail:""};if(this.connection=t,this.consumeStdout(t),e.stderr)this.consumeStderr(t);e.exited.then((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited with code ${s}${t.stderrTail?`: ${t.stderrTail}`:""}`)}).catch((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited unexpectedly: ${ue(s)}`)});try{return await this.requestOnConnection(t,"initialize",{clientInfo:{name:this.clientName,title:"ReviewMe",version:this.clientVersion},capabilities:{experimentalApi:!0,requestAttestation:!1}}),await this.sendNotification(t,"initialized"),t}catch(s){if(!t.closed){try{t.process.kill()}catch{}this.handleConnectionClosed(t,ue(s))}throw s instanceof O?s:new O("disconnected",`Codex initialization failed: ${ue(s)}`,{cause:s})}}async consumeStdout(e){let t=e.process.stdout.getReader(),s=new TextDecoder,n="";try{while(!e.closed){let{done:i,value:o}=await t.read();if(i)break;if(n+=s.decode(o,{stream:!0}),new TextEncoder().encode(n).byteLength>La){this.handleConnectionClosed(e,"Codex protocol line exceeded the maximum size");return}let a=n.indexOf(`
396
399
  `);while(a>=0){let l=n.slice(0,a).replace(/\r$/,"");if(n=n.slice(a+1),l.trim())this.handleProtocolLine(e,l);a=n.indexOf(`
397
- `)}}let r=n+s.decode();if(r.trim()&&!e.closed)this.handleProtocolLine(e,r.trim())}catch(r){if(!e.closed)this.handleConnectionClosed(e,`Codex output could not be read: ${ue(r)}`)}finally{t.releaseLock()}}async consumeStderr(e){if(!e.process.stderr)return;let t=e.process.stderr.getReader(),s=new TextDecoder;try{while(!e.closed){let{done:n,value:r}=await t.read();if(n)break;e.stderrTail=`${e.stderrTail}${s.decode(r,{stream:!0})}`.slice(-xa)}}catch{}finally{t.releaseLock()}}handleProtocolLine(e,t){let s;try{s=JSON.parse(t)}catch(o){this.handleConnectionClosed(e,`Codex returned invalid JSON: ${ue(o)}`);return}if(!s||typeof s!=="object"||Array.isArray(s)){this.handleConnectionClosed(e,"Codex returned a non-object JSON message");return}let n=s,r=n.id;if(typeof n.method==="string"){if(r!==void 0)this.writeMessage(e,{id:typeof r==="number"||typeof r==="string"?r:String(r),error:{code:-32001,message:"ReviewMe does not permit Codex approval or input requests"}}).catch(()=>{if(!e.closed)this.handleConnectionClosed(e,"Unable to reject a Codex server request")});else this.handleNotification(n.method,n.params);return}if(r===void 0)return;let i=e.pending.get(String(r));if(!i)return;if(e.pending.delete(String(r)),Object.prototype.hasOwnProperty.call(n,"error")){let o=n.error&&typeof n.error==="object"?n.error:{},a=M(o.message)??"Codex request failed";i.reject(Ma(`${i.method}: ${a}`,o));return}i.resolve(n.result)}handleNotification(e,t){let s=t&&typeof t==="object"?t:{},n=M(s.threadId),r=n?this.activeTurns.get(n):void 0;if(e==="thread/status/changed"&&n){let o=this.sessions.get(n);if(o){let a=s.status&&typeof s.status==="object"?s.status:{},l=M(a.type);this.sessions.set(n,{...o,status:l==="active"?"running":l==="systemError"?"disconnected":"ready"})}return}if(!r)return;let i=M(s.turnId)??r.turnId;if(i)r.turnId=i;if(e==="turn/started"){if(!r.startedEmitted&&r.turnId)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});return}if(e==="item/agentMessage/delta"){if(typeof s.delta!=="string"||!r.turnId)return;if(!r.startedEmitted)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});r.queue.push({type:"text-delta",sessionId:r.sessionId,turnId:r.turnId,delta:s.delta});return}if(e==="item/started"){let o=s.item&&typeof s.item==="object"?s.item:{},a=M(o.type),l=this.activityForItem(a,o);if(l&&r.turnId)r.queue.push({type:"activity",sessionId:r.sessionId,turnId:r.turnId,kind:l.kind,detail:l.detail});return}if(e==="error"){let o=s.error&&typeof s.error==="object"?s.error:{},a=M(o.message)??"Codex turn failed",l=s.willRetry===!0;if(r.queue.push({type:"error",sessionId:r.sessionId,turnId:r.turnId??null,message:a,code:"turn-failed",retryable:l}),!l)r.queue.close(),this.activeTurns.delete(r.sessionId);return}if(e==="turn/completed"){let o=s.turn&&typeof s.turn==="object"?s.turn:{},a=M(o.id)??r.turnId;if(!a)return;r.turnId=a,r.queue.push({type:"completed",sessionId:r.sessionId,turnId:a,status:$a(o.status)}),r.queue.close(),this.activeTurns.delete(r.sessionId);let l=this.sessions.get(r.sessionId);if(l)this.sessions.set(r.sessionId,{...l,status:"ready"})}}activityForItem(e,t){switch(e){case"commandExecution":return{kind:"command",detail:"Running a command"};case"fileChange":return{kind:"other",detail:"Preparing file changes"};case"mcpToolCall":case"dynamicToolCall":return{kind:"tool",detail:M(t.tool)?`Using ${t.tool}`:"Using a tool"};case"webSearch":return{kind:"searching",detail:"Searching the web"};case"imageView":return{kind:"reading",detail:"Reading an image"};default:return}}handleConnectionClosed(e,t){if(e.closed)return;if(e.closed=!0,this.connection===e)this.connection=void 0;let s=new O("disconnected",t,{retryable:!0});for(let n of e.pending.values())n.reject(s);e.pending.clear();for(let[n,r]of this.activeTurns){if(r.connection!==e)continue;r.queue.fail(s),this.activeTurns.delete(n);let i=this.sessions.get(n);if(i)this.sessions.set(n,{...i,status:"disconnected"})}}}var Ha=`<!doctype html>
400
+ `)}}let r=n+s.decode();if(r.trim()&&!e.closed)this.handleProtocolLine(e,r.trim())}catch(r){if(!e.closed)this.handleConnectionClosed(e,`Codex output could not be read: ${ue(r)}`)}finally{t.releaseLock()}}async consumeStderr(e){if(!e.process.stderr)return;let t=e.process.stderr.getReader(),s=new TextDecoder;try{while(!e.closed){let{done:n,value:r}=await t.read();if(n)break;e.stderrTail=`${e.stderrTail}${s.decode(r,{stream:!0})}`.slice(-ka)}}catch{}finally{t.releaseLock()}}handleProtocolLine(e,t){let s;try{s=JSON.parse(t)}catch(o){this.handleConnectionClosed(e,`Codex returned invalid JSON: ${ue(o)}`);return}if(!s||typeof s!=="object"||Array.isArray(s)){this.handleConnectionClosed(e,"Codex returned a non-object JSON message");return}let n=s,r=n.id;if(typeof n.method==="string"){if(r!==void 0)this.writeMessage(e,{id:typeof r==="number"||typeof r==="string"?r:String(r),error:{code:-32001,message:"ReviewMe does not permit Codex approval or input requests"}}).catch(()=>{if(!e.closed)this.handleConnectionClosed(e,"Unable to reject a Codex server request")});else this.handleNotification(n.method,n.params);return}if(r===void 0)return;let i=e.pending.get(String(r));if(!i)return;if(e.pending.delete(String(r)),Object.prototype.hasOwnProperty.call(n,"error")){let o=n.error&&typeof n.error==="object"?n.error:{},a=M(o.message)??"Codex request failed";i.reject(Fa(`${i.method}: ${a}`,o));return}i.resolve(n.result)}handleNotification(e,t){let s=t&&typeof t==="object"?t:{},n=M(s.threadId),r=n?this.activeTurns.get(n):void 0;if(e==="thread/status/changed"&&n){let o=this.sessions.get(n);if(o){let a=s.status&&typeof s.status==="object"?s.status:{},l=M(a.type);this.sessions.set(n,{...o,status:l==="active"?"running":l==="systemError"?"disconnected":"ready"})}return}if(!r)return;let i=M(s.turnId)??r.turnId;if(i)r.turnId=i;if(e==="turn/started"){if(!r.startedEmitted&&r.turnId)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});return}if(e==="item/agentMessage/delta"){if(typeof s.delta!=="string"||!r.turnId)return;if(!r.startedEmitted)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});r.queue.push({type:"text-delta",sessionId:r.sessionId,turnId:r.turnId,delta:s.delta});return}if(e==="item/started"){let o=s.item&&typeof s.item==="object"?s.item:{},a=M(o.type),l=this.activityForItem(a,o);if(l&&r.turnId)r.queue.push({type:"activity",sessionId:r.sessionId,turnId:r.turnId,kind:l.kind,detail:l.detail});return}if(e==="error"){let o=s.error&&typeof s.error==="object"?s.error:{},a=M(o.message)??"Codex turn failed",l=s.willRetry===!0;if(r.queue.push({type:"error",sessionId:r.sessionId,turnId:r.turnId??null,message:a,code:"turn-failed",retryable:l}),!l)r.queue.close(),this.activeTurns.delete(r.sessionId);return}if(e==="turn/completed"){let o=s.turn&&typeof s.turn==="object"?s.turn:{},a=M(o.id)??r.turnId;if(!a)return;r.turnId=a,r.queue.push({type:"completed",sessionId:r.sessionId,turnId:a,status:ja(o.status)}),r.queue.close(),this.activeTurns.delete(r.sessionId);let l=this.sessions.get(r.sessionId);if(l)this.sessions.set(r.sessionId,{...l,status:"ready"})}}activityForItem(e,t){switch(e){case"commandExecution":return{kind:"command",detail:"Running a command"};case"fileChange":return{kind:"other",detail:"Preparing file changes"};case"mcpToolCall":case"dynamicToolCall":return{kind:"tool",detail:M(t.tool)?`Using ${t.tool}`:"Using a tool"};case"webSearch":return{kind:"searching",detail:"Searching the web"};case"imageView":return{kind:"reading",detail:"Reading an image"};default:return}}handleConnectionClosed(e,t){if(e.closed)return;if(e.closed=!0,this.connection===e)this.connection=void 0;let s=new O("disconnected",t,{retryable:!0});for(let n of e.pending.values())n.reject(s);e.pending.clear();for(let[n,r]of this.activeTurns){if(r.connection!==e)continue;r.queue.fail(s),this.activeTurns.delete(n);let i=this.sessions.get(n);if(i)this.sessions.set(n,{...i,status:"disconnected"})}}}var Va=`<!doctype html>
398
401
  <html lang="en"><head><meta charset="utf-8"><title>ReviewMe</title></head>
399
- <body><main><h1>ReviewMe</h1><p>Frontend assets have not been built yet.</p></main></body></html>`,Ya={".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".png":"image/png",".svg":"image/svg+xml",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};async function wr(e={}){let t=e.service??ut({repoPath:e.repoPath,range:e.range,from:e.from,to:e.to,watchIntervalMs:e.watchIntervalMs});await t.ready;let s=e.reviewStore??new _s,n=e.reviewStore===void 0,r=e.agentProvider??new vs,i=new _r,o=e.auth===!0||e.token!==void 0?e.token??Yn():void 0;if(o!==void 0&&o.length<20)throw Error("Review server token must be at least 20 characters");let a=Za(e.staticDir),l=e.port??0;if(!Number.isInteger(l)||l<0||l>65535)throw Error("Port must be an integer between 0 and 65535");let c=Ba((g,w)=>{Ja(g,w,(f)=>Va(f,t,s,r,i,o,a,e.colorTheme))});if(c.requestTimeout=0,c.headersTimeout=60000,c.keepAliveTimeout=5000,await new Promise((g,w)=>{let f=(y)=>w(y);c.once("error",f),c.listen(l,"127.0.0.1",()=>{c.off("error",f),g()})}),e.watch!==!1)t.startWatching(e.watchIntervalMs);let p=c.address(),d=typeof p==="object"&&p!==null?p.port:l,u=o===void 0?`http://127.0.0.1:${d}/`:`http://127.0.0.1:${d}/?token=${encodeURIComponent(o)}`;return{server:c,service:t,reviewStore:s,agentProvider:r,token:o,port:d,url:u,close:()=>{if(t.stopWatching(),n)s.close();r.close(),c.closeAllConnections(),c.close()}}}async function Ja(e,t,s){let n=new AbortController;e.once("aborted",()=>n.abort()),t.once("close",()=>{if(!t.writableFinished)n.abort()});try{let r=new Headers;for(let[p,d]of Object.entries(e.headers))if(Array.isArray(d))for(let u of d)r.append(p,u);else if(d!==void 0)r.set(p,d);let i=e.method??"GET",o=i==="GET"||i==="HEAD"?void 0:yt.toWeb(e),a=new Request(`http://127.0.0.1${e.url??"/"}`,{method:i,headers:r,body:o,signal:n.signal,...o===void 0?{}:{duplex:"half"}}),l=await s(a);if(t.statusCode=l.status,t.statusMessage=l.statusText,l.headers.forEach((p,d)=>t.setHeader(d,p)),l.headers.get("content-type")?.startsWith("text/event-stream"))t.setTimeout(0);if(i==="HEAD"||l.body===null||l.status===204||l.status===304){l.body?.cancel(),t.end();return}let c=yt.fromWeb(l.body);c.once("error",(p)=>t.destroy(p)),t.once("close",()=>c.destroy()),c.pipe(t)}catch(r){if(!t.headersSent)t.statusCode=500,t.setHeader("content-type","application/json; charset=utf-8"),t.end(JSON.stringify({error:{code:"internal_error",message:r instanceof Error?r.message:String(r)}}));else t.destroy(r instanceof Error?r:void 0)}}async function Va(e,t,s,n,r,i,o,a){let l=new URL(e.url);if(l.pathname.startsWith("/api/")){if(i!==void 0&&!Jn(e,i))return A({error:{code:"unauthorized",message:"A valid review token is required"}},401,{"www-authenticate":"Bearer"});try{return await Xa(e,t,s,n,r,l,a)}catch(c){return tl(c)}}return el(l,o)}async function Xa(e,t,s,n,r,i,o){let a=i.pathname;if(e.method==="GET"&&a==="/api/theme")return A({theme:o??null});if(e.method==="GET"&&a==="/api/settings")return A({browserTabTitle:s.getBrowserTabTitleMode()});if(e.method==="PUT"&&a==="/api/settings/browser-tab-title"){let h=(await H(e))?.mode;if(h!=="repository"&&h!=="directory"&&h!=="branch"&&h!=="diff")throw new N("invalid_settings","Browser tab title mode is invalid",400);return A({browserTabTitle:s.setBrowserTabTitleMode(h)})}if(e.method==="GET"&&(a==="/api/repository"||a==="/api/metadata/repository"))return A({repository:await t.getRepositoryMetadata()});if(e.method==="GET"&&a==="/api/metadata"){let[m,h]=await Promise.all([t.getRepositoryMetadata(),t.listFiles()]);return A({repository:m,files:h.files})}if(e.method==="GET"&&(a==="/api/files"||a==="/api/metadata/files"))return A(await t.listFiles());if(e.method==="GET"&&a==="/api/refs")return A({refs:await t.listRefs()});if(e.method==="GET"&&a==="/api/revision"){let m=await t.getRepositoryMetadata();return A({revision:m.revision,dirty:m.dirty})}if((e.method==="GET"||e.method==="POST")&&a==="/api/refresh")return A(await t.refresh());if(e.method==="GET"&&a==="/api/events")return Qa(t);if(e.method==="GET"&&a==="/api/patch-stream"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return new Response(await t.streamPatch(e.signal,m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"},i.searchParams.get("includeUnstaged")==="true"),{headers:{"cache-control":"no-cache, no-store","content-type":"text/plain; charset=utf-8",vary:"Authorization","x-accel-buffering":"no","x-content-type-options":"nosniff"}})}if(e.method==="GET"&&a==="/api/health")return A({ok:!0,revision:(await t.getRepositoryMetadata()).revision});if(e.method==="GET"&&a==="/api/commits"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return A(await t.listCommits(m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"}))}if(e.method==="GET"&&a==="/api/review"){let m=await X(t,s);return A({snapshotId:m.id,reviewedPaths:s.listReviewedFiles(m.id).map((h)=>h.path),threads:s.listThreads(m.id).map(Ts),drafts:s.listDrafts(m.id).map(gr),agentConversations:s.listAgentConversations(m.id).map(yr)})}if(e.method==="GET"&&a==="/api/agents/codex/models"){let m=await n.listModels(),h=m.find((b)=>b.isDefault)??m[0];return A({models:m,defaultModel:h?.id,defaultEffort:h?.defaultReasoningEffort??void 0,efforts:h?.supportedReasoningEfforts??[]})}let l=G(a,"/api/review/threads/","/agent-sessions");if(e.method==="POST"&&l!==void 0){let m=await X(t,s),h=s.getThread(l);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);let b=await H(e),E=await n.startThread({cwd:t.repositoryRoot,model:typeof b?.model==="string"?b.model:void 0,reasoningEffort:typeof b?.effort==="string"?b.effort:void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:E.session.externalThreadId,model:E.session.model,reasoningEffort:E.session.reasoningEffort,permissionMode:"read-only",status:"ready"});s.linkAgentSession(l,T.id);let R=h.anchors[0],v=h.messages.find((x)=>x.source==="local");if(R!=null)s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,sourceThreadId:h.id,anchor:R,prompt:v?.body??"Review this code"});return r.markProviderReady(E.session.externalThreadId),A(br(T,E.history),201)}if(e.method==="POST"&&a==="/api/agent-conversations"){let m=await X(t,s),h=await H(e);if(!h||typeof h.prompt!=="string"||typeof h.anchor!=="object"||h.anchor==null)throw new N("invalid_request","Agent prompt and anchor are required");let b=gt(h.anchor),E=await n.startThread({cwd:t.repositoryRoot,model:typeof h.model==="string"?h.model:void 0,reasoningEffort:typeof h.effort==="string"?h.effort:void 0,serviceTier:h.fast===!0?"priority":void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:E.session.externalThreadId,model:E.session.model,reasoningEffort:E.session.reasoningEffort,permissionMode:"read-only",status:"ready"}),R=s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,anchor:b,prompt:h.prompt});return r.markProviderReady(E.session.externalThreadId),A(yr({...T,contexts:[R]}),201)}let c=G(a,"/api/agent-conversations/");if(e.method==="DELETE"&&c!==void 0){let m=await X(t,s),h=s.getAgentSession(c);if(!s.deleteAgentConversation(c,m.id))throw new N("not_found","Agent conversation not found",404);if(h?.status==="running"&&h.externalThreadId!=null)try{await n.stop(h.externalThreadId)}catch{}return A({deleted:!0})}let p=G(a,"/api/agent-sessions/","/messages");if(e.method==="POST"&&p!==void 0){let m=await H(e),h=typeof m?.body==="string"?m.body:typeof m?.message==="string"?m.message:"";if(h.trim()==="")throw new N("invalid_request","Agent message is required");let b=s.getAgentSession(p);if(b==null||b.externalThreadId==null)throw new N("not_found","Agent session not found",404);if(!r.isProviderReady(b.externalThreadId)){let T=await n.resumeThread({externalThreadId:b.externalThreadId,cwd:t.repositoryRoot,model:b.model??void 0,reasoningEffort:b.reasoningEffort??void 0,permissionMode:"read-only"});r.markProviderReady(T.session.externalThreadId)}let E=await n.sendMessage(b.externalThreadId,{text:h,reasoningEffort:b.reasoningEffort??void 0});return s.updateAgentSession(b.id,{status:"running",lastEventAt:new Date().toISOString()}),r.pump(b.id,E.events,(T)=>{if(T.type==="completed"||T.type==="stopped")s.updateAgentSession(b.id,{status:"ready",lastEventAt:new Date().toISOString()});else if(T.type==="error")s.updateAgentSession(b.id,{status:"error",statusMessage:T.message,lastEventAt:new Date().toISOString()})}),A({status:"running",turnId:E.turnId})}let d=G(a,"/api/agent-sessions/","/history");if(e.method==="GET"&&d!==void 0){let m=s.getAgentSession(d);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);let h;try{h=await n.resumeThread({externalThreadId:m.externalThreadId,cwd:t.repositoryRoot,model:m.model??void 0,reasoningEffort:m.reasoningEffort??void 0,permissionMode:"read-only"})}catch(b){if(b instanceof Error&&b.message.includes("rollout")&&b.message.includes("is empty"))return A({history:[]});throw b}return r.markProviderReady(h.session.externalThreadId),A({history:h.history})}let u=G(a,"/api/agent-sessions/","/events");if(e.method==="GET"&&u!==void 0){if(s.getAgentSession(u)==null)throw new N("not_found","Agent session not found",404);return r.response(u)}let g=G(a,"/api/agent-sessions/","/stop");if(e.method==="POST"&&g!==void 0){let m=s.getAgentSession(g);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);return await n.stop(m.externalThreadId),s.updateAgentSession(m.id,{status:"stopped",lastEventAt:new Date().toISOString()}),A({stopped:!0})}if(e.method==="PUT"&&a==="/api/review/files/reviewed"){let m=await X(t,s),h=await H(e);if(!Array.isArray(h?.paths)||h.paths.some((E)=>typeof E!=="string"))throw new N("invalid_request","Request body must include an array of file paths");let b=h.reviewed!==!1;return s.setFilesReviewed(m.id,h.paths,b),A({reviewed:b,paths:h.paths})}let w=G(a,"/api/review/files/","/reviewed");if(e.method==="PUT"&&w!==void 0){let m=await X(t,s),h=await H(e),b=typeof h?.path==="string"?h.path:w,E=h?.reviewed!==!1;return A({reviewed:s.setFileReviewed(m.id,b,E)})}if(e.method==="POST"&&a==="/api/review/threads"){let m=await X(t,s),h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Comment body is required");return A(Ts(s.createThread({snapshotId:m.id,anchor:gt(h.anchor),body:h.body})),201)}let f=G(a,"/api/review/threads/");if((e.method==="PATCH"||e.method==="DELETE")&&f!==void 0){let m=await X(t,s),h=s.getThread(f);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);if(e.method==="DELETE")return s.deleteThread(f),A({deleted:!0});let b=await H(e);if(!b||typeof b.body!=="string")throw new N("invalid_request","Comment body is required");let E=h.messages.find((T)=>T.source==="local");if(E==null)s.createMessage({threadId:f,body:b.body});else s.updateMessage(E.id,b.body);if(b.anchor!==void 0&&h.anchors[0]!=null)s.updateAnchor(h.anchors[0].id,gt(b.anchor));return A(Ts(s.getThread(f)))}let y=G(a,"/api/review/drafts/");if((e.method==="PUT"||e.method==="DELETE")&&y!==void 0){let m=await X(t,s);if(e.method==="DELETE"){let b=s.getDraft(y);if(b!=null&&b.snapshotId!==m.id)throw new N("not_found","Review draft not found",404);return s.deleteDraft(y),A({deleted:!0})}let h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Draft body is required");return A(gr(s.upsertDraft({id:y,snapshotId:m.id,anchor:gt(h.anchor),body:h.body})))}let _=za(a);if(e.method==="GET"&&_!==void 0){if(i.searchParams.get("hydrate")==="true"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null||h===null||b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","from, to, and a valid mode are required");return A(await t.getFileContents({comparison:{from:m,to:h,mode:b},includeUnstaged:i.searchParams.get("includeUnstaged")==="true",oldPath:i.searchParams.get("oldPath")??void 0,newPath:i.searchParams.get("newPath")??void 0,pureRename:i.searchParams.get("pureRename")==="true"}))}return A(await t.getFileDiff(_))}if(e.method==="GET"&&(a==="/api/diff"||a==="/api/patch")){let m=i.searchParams.get("fileId")??i.searchParams.get("path");if(!m)throw new N("missing_file","A fileId or path query parameter is required");return A(await t.getFileDiff(m))}if(e.method==="POST"&&(a==="/api/open"||a==="/api/open-working-file")){let m=await H(e);if(!m||typeof m.path!=="string")throw new N("invalid_request","Request body must include a repository-relative path");if(m.line!==void 0&&typeof m.line!=="number"||m.column!==void 0&&typeof m.column!=="number"||m.side!==void 0&&m.side!=="old"&&m.side!=="new")throw new N("invalid_request","line and column must be numbers");let h={path:m.path,...m.line===void 0?{}:{line:m.line},...m.column===void 0?{}:{column:m.column},...m.side===void 0?{}:{side:m.side}};return A(await t.openWorkingFile(h))}throw new N("not_found","API endpoint not found",404)}async function X(e,t){let s=await e.getRepositoryMetadata();return t.ensureSnapshot({canonicalRoot:s.root,remoteOrigin:s.remoteOrigin,comparisonMode:s.comparisonMode,baseRef:s.fromRef,headRef:s.toRef,baseSha:s.baseSha,headSha:s.targetSha})}function gt(e){if(e==null||typeof e!=="object"||Array.isArray(e))throw new N("invalid_anchor","A review anchor is required");let t=e;if(typeof t.path!=="string")throw new N("invalid_anchor","Anchor path is required");let s=t.kind==="diff_range"?"diff_range":t.kind==="file"?"file":null;if(s==null)throw new N("invalid_anchor","Anchor kind is invalid");return{kind:s,path:t.path,side:t.side==="old"||t.side==="new"?t.side:null,startLine:typeof t.startLine==="number"?t.startLine:null,endLine:typeof t.endLine==="number"?t.endLine:null,contextFingerprint:typeof t.contextHash==="string"?t.contextHash:null}}function Ts(e){let t=e.anchors[0],s=e.messages.find((n)=>n.source==="local");return{id:e.id,snapshotId:e.snapshotId,anchor:t==null?null:{id:t.id,kind:t.kind,path:t.path,side:t.side,startLine:t.startLine,endLine:t.endLine,contextHash:t.contextFingerprint},body:s?.body??"",createdAt:e.createdAt,updatedAt:e.updatedAt,agentSession:e.agentSessions[0]??null}}function gr(e){return{id:e.id,snapshotId:e.snapshotId,anchor:{kind:e.anchor.kind,path:e.anchor.path,side:e.anchor.side,startLine:e.anchor.startLine,endLine:e.anchor.endLine,contextHash:e.anchor.contextFingerprint},body:e.body,updatedAt:e.updatedAt}}function G(e,t,s=""){if(!e.startsWith(t)||s!==""&&!e.endsWith(s))return;let n=e.slice(t.length,s===""?void 0:-s.length);if(n===""||n.includes("/"))return;try{return decodeURIComponent(n)}catch{throw new N("invalid_path","Path segment is not valid URL encoding")}}function br(e,t=[]){return{id:e.id,provider:e.provider,externalThreadId:e.externalThreadId,model:e.model,effort:e.reasoningEffort,permissionMode:e.permissionMode,status:e.status,history:t}}function yr(e){return{...br(e),contexts:e.contexts.map((t)=>({id:t.id,sourceThreadId:t.sourceThreadId,anchor:{kind:t.anchor.kind,path:t.anchor.path,side:t.anchor.side,startLine:t.anchor.startLine,endLine:t.anchor.endLine},prompt:t.prompt,createdAt:t.createdAt}))}}class _r{providerReady=new Set;subscribers=new Map;buffered=new Map;encoder=new TextEncoder;markProviderReady(e){this.providerReady.add(e)}isProviderReady(e){return this.providerReady.has(e)}pump(e,t,s){this.buffered.set(e,[]),(async()=>{try{for await(let n of t)s(n),this.publish(e,Ga(n))}catch(n){this.publish(e,{type:"error",message:n instanceof Error?n.message:String(n)})}})()}response(e){let t,s=new ReadableStream({start:(n)=>{t=n;let r=this.subscribers.get(e)??new Set;r.add(n),this.subscribers.set(e,r);for(let i of this.buffered.get(e)??[])this.send(n,i)},cancel:()=>{if(t==null)return;let n=this.subscribers.get(e);if(n?.delete(t),n?.size===0)this.subscribers.delete(e)}});return new Response(s,{headers:{"cache-control":"no-cache, no-store","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}publish(e,t){let s=this.buffered.get(e)??[];if(s.push(t),s.length>2000)s.shift();this.buffered.set(e,s);for(let n of this.subscribers.get(e)??[])this.send(n,t)}send(e,t){try{e.enqueue(this.encoder.encode(`event: message
402
+ <body><main><h1>ReviewMe</h1><p>Frontend assets have not been built yet.</p></main></body></html>`,Ga={".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".png":"image/png",".svg":"image/svg+xml",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};async function br(e={}){let t=e.service??ut({repoPath:e.repoPath,range:e.range,from:e.from,to:e.to,watchIntervalMs:e.watchIntervalMs});await t.ready;let s=e.reviewStore??new _s,n=e.reviewStore===void 0,r=e.agentProvider??new Es,i=new Sr,o=e.auth===!0||e.token!==void 0?e.token??Jn():void 0;if(o!==void 0&&o.length<20)throw Error("Review server token must be at least 20 characters");let a=sl(e.staticDir),l=e.port??0;if(!Number.isInteger(l)||l<0||l>65535)throw Error("Port must be an integer between 0 and 65535");let c=Wa((g,w)=>{Xa(g,w,(f)=>za(f,t,s,r,i,o,a,e.colorTheme))});if(c.requestTimeout=0,c.headersTimeout=60000,c.keepAliveTimeout=5000,await new Promise((g,w)=>{let f=(y)=>w(y);c.once("error",f),c.listen(l,"127.0.0.1",()=>{c.off("error",f),g()})}),e.watch!==!1)t.startWatching(e.watchIntervalMs);let p=c.address(),d=typeof p==="object"&&p!==null?p.port:l,u=o===void 0?`http://127.0.0.1:${d}/`:`http://127.0.0.1:${d}/?token=${encodeURIComponent(o)}`;return{server:c,service:t,reviewStore:s,agentProvider:r,token:o,port:d,url:u,close:()=>{if(t.stopWatching(),n)s.close();r.close(),c.closeAllConnections(),c.close()}}}async function Xa(e,t,s){let n=new AbortController;e.once("aborted",()=>n.abort()),t.once("close",()=>{if(!t.writableFinished)n.abort()});try{let r=new Headers;for(let[p,d]of Object.entries(e.headers))if(Array.isArray(d))for(let u of d)r.append(p,u);else if(d!==void 0)r.set(p,d);let i=e.method??"GET",o=i==="GET"||i==="HEAD"?void 0:yt.toWeb(e),a=new Request(`http://127.0.0.1${e.url??"/"}`,{method:i,headers:r,body:o,signal:n.signal,...o===void 0?{}:{duplex:"half"}}),l=await s(a);if(t.statusCode=l.status,t.statusMessage=l.statusText,l.headers.forEach((p,d)=>t.setHeader(d,p)),l.headers.get("content-type")?.startsWith("text/event-stream"))t.setTimeout(0);if(i==="HEAD"||l.body===null||l.status===204||l.status===304){l.body?.cancel(),t.end();return}let c=yt.fromWeb(l.body);c.once("error",(p)=>t.destroy(p)),t.once("close",()=>c.destroy()),c.pipe(t)}catch(r){if(!t.headersSent)t.statusCode=500,t.setHeader("content-type","application/json; charset=utf-8"),t.end(JSON.stringify({error:{code:"internal_error",message:r instanceof Error?r.message:String(r)}}));else t.destroy(r instanceof Error?r:void 0)}}async function za(e,t,s,n,r,i,o,a){let l=new URL(e.url);if(l.pathname.startsWith("/api/")){if(i!==void 0&&!Vn(e,i))return A({error:{code:"unauthorized",message:"A valid review token is required"}},401,{"www-authenticate":"Bearer"});try{return await Qa(e,t,s,n,r,l,a)}catch(c){return rl(c)}}return nl(l,o)}async function Qa(e,t,s,n,r,i,o){let a=i.pathname;if(e.method==="GET"&&a==="/api/theme")return A({theme:o??null});if(e.method==="GET"&&a==="/api/settings")return A({browserTabTitle:s.getBrowserTabTitleMode()});if(e.method==="PUT"&&a==="/api/settings/browser-tab-title"){let h=(await H(e))?.mode;if(h!=="repository"&&h!=="directory"&&h!=="branch"&&h!=="diff")throw new N("invalid_settings","Browser tab title mode is invalid",400);return A({browserTabTitle:s.setBrowserTabTitleMode(h)})}if(e.method==="GET"&&(a==="/api/repository"||a==="/api/metadata/repository"))return A({repository:await t.getRepositoryMetadata()});if(e.method==="GET"&&a==="/api/metadata"){let[m,h]=await Promise.all([t.getRepositoryMetadata(),t.listFiles()]);return A({repository:m,files:h.files})}if(e.method==="GET"&&(a==="/api/files"||a==="/api/metadata/files"))return A(await t.listFiles());if(e.method==="GET"&&a==="/api/refs")return A({refs:await t.listRefs()});if(e.method==="GET"&&a==="/api/revision"){let m=await t.getRepositoryMetadata();return A({revision:m.revision,dirty:m.dirty})}if((e.method==="GET"||e.method==="POST")&&a==="/api/refresh")return A(await t.refresh());if(e.method==="GET"&&a==="/api/events")return tl(t);if(e.method==="GET"&&a==="/api/patch-stream"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return new Response(await t.streamPatch(e.signal,m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"},i.searchParams.get("includeUnstaged")==="true"),{headers:{"cache-control":"no-cache, no-store","content-type":"text/plain; charset=utf-8",vary:"Authorization","x-accel-buffering":"no","x-content-type-options":"nosniff"}})}if(e.method==="GET"&&a==="/api/health")return A({ok:!0,revision:(await t.getRepositoryMetadata()).revision});if(e.method==="GET"&&a==="/api/commits"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return A(await t.listCommits(m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"}))}if(e.method==="GET"&&a==="/api/review"){let m=await G(t,s);return A({snapshotId:m.id,reviewedPaths:s.listReviewedFiles(m.id).map((h)=>h.path),threads:s.listThreads(m.id).map(Ts),drafts:s.listDrafts(m.id).map(yr),agentConversations:s.listAgentConversations(m.id).map(wr)})}if(e.method==="GET"&&a==="/api/agents/codex/models"){let m=await n.listModels(),h=m.find((b)=>b.isDefault)??m[0];return A({models:m,defaultModel:h?.id,defaultEffort:h?.defaultReasoningEffort??void 0,efforts:h?.supportedReasoningEfforts??[]})}let l=X(a,"/api/review/threads/","/agent-sessions");if(e.method==="POST"&&l!==void 0){let m=await G(t,s),h=s.getThread(l);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);let b=await H(e),v=await n.startThread({cwd:t.repositoryRoot,model:typeof b?.model==="string"?b.model:void 0,reasoningEffort:typeof b?.effort==="string"?b.effort:void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:v.session.externalThreadId,model:v.session.model,reasoningEffort:v.session.reasoningEffort,permissionMode:"read-only",status:"ready"});s.linkAgentSession(l,T.id);let R=h.anchors[0],E=h.messages.find((x)=>x.source==="local");if(R!=null)s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,sourceThreadId:h.id,anchor:R,prompt:E?.body??"Review this code"});return r.markProviderReady(v.session.externalThreadId),A(_r(T,v.history),201)}if(e.method==="POST"&&a==="/api/agent-conversations"){let m=await G(t,s),h=await H(e);if(!h||typeof h.prompt!=="string"||typeof h.anchor!=="object"||h.anchor==null)throw new N("invalid_request","Agent prompt and anchor are required");let b=gt(h.anchor),v=await n.startThread({cwd:t.repositoryRoot,model:typeof h.model==="string"?h.model:void 0,reasoningEffort:typeof h.effort==="string"?h.effort:void 0,serviceTier:h.fast===!0?"priority":void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:v.session.externalThreadId,model:v.session.model,reasoningEffort:v.session.reasoningEffort,permissionMode:"read-only",status:"ready"}),R=s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,anchor:b,prompt:h.prompt});return r.markProviderReady(v.session.externalThreadId),A(wr({...T,contexts:[R]}),201)}let c=X(a,"/api/agent-conversations/");if(e.method==="DELETE"&&c!==void 0){let m=await G(t,s),h=s.getAgentSession(c);if(!s.deleteAgentConversation(c,m.id))throw new N("not_found","Agent conversation not found",404);if(h?.status==="running"&&h.externalThreadId!=null)try{await n.stop(h.externalThreadId)}catch{}return A({deleted:!0})}let p=X(a,"/api/agent-sessions/","/messages");if(e.method==="POST"&&p!==void 0){let m=await H(e),h=typeof m?.body==="string"?m.body:typeof m?.message==="string"?m.message:"";if(h.trim()==="")throw new N("invalid_request","Agent message is required");let b=s.getAgentSession(p);if(b==null||b.externalThreadId==null)throw new N("not_found","Agent session not found",404);if(!r.isProviderReady(b.externalThreadId)){let T=await n.resumeThread({externalThreadId:b.externalThreadId,cwd:t.repositoryRoot,model:b.model??void 0,reasoningEffort:b.reasoningEffort??void 0,permissionMode:"read-only"});r.markProviderReady(T.session.externalThreadId)}let v=await n.sendMessage(b.externalThreadId,{text:h,reasoningEffort:b.reasoningEffort??void 0});return s.updateAgentSession(b.id,{status:"running",lastEventAt:new Date().toISOString()}),r.pump(b.id,v.events,(T)=>{if(T.type==="completed"||T.type==="stopped")s.updateAgentSession(b.id,{status:"ready",lastEventAt:new Date().toISOString()});else if(T.type==="error")s.updateAgentSession(b.id,{status:"error",statusMessage:T.message,lastEventAt:new Date().toISOString()})}),A({status:"running",turnId:v.turnId})}let d=X(a,"/api/agent-sessions/","/history");if(e.method==="GET"&&d!==void 0){let m=s.getAgentSession(d);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);let h;try{h=await n.resumeThread({externalThreadId:m.externalThreadId,cwd:t.repositoryRoot,model:m.model??void 0,reasoningEffort:m.reasoningEffort??void 0,permissionMode:"read-only"})}catch(b){if(b instanceof Error&&b.message.includes("rollout")&&b.message.includes("is empty"))return A({history:[]});throw b}return r.markProviderReady(h.session.externalThreadId),A({history:h.history})}let u=X(a,"/api/agent-sessions/","/events");if(e.method==="GET"&&u!==void 0){if(s.getAgentSession(u)==null)throw new N("not_found","Agent session not found",404);return r.response(u)}let g=X(a,"/api/agent-sessions/","/stop");if(e.method==="POST"&&g!==void 0){let m=s.getAgentSession(g);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);return await n.stop(m.externalThreadId),s.updateAgentSession(m.id,{status:"stopped",lastEventAt:new Date().toISOString()}),A({stopped:!0})}if(e.method==="PUT"&&a==="/api/review/files/reviewed"){let m=await G(t,s),h=await H(e);if(!Array.isArray(h?.paths)||h.paths.some((v)=>typeof v!=="string"))throw new N("invalid_request","Request body must include an array of file paths");let b=h.reviewed!==!1;return s.setFilesReviewed(m.id,h.paths,b),A({reviewed:b,paths:h.paths})}let w=X(a,"/api/review/files/","/reviewed");if(e.method==="PUT"&&w!==void 0){let m=await G(t,s),h=await H(e),b=typeof h?.path==="string"?h.path:w,v=h?.reviewed!==!1;return A({reviewed:s.setFileReviewed(m.id,b,v)})}if(e.method==="POST"&&a==="/api/review/threads"){let m=await G(t,s),h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Comment body is required");return A(Ts(s.createThread({snapshotId:m.id,anchor:gt(h.anchor),body:h.body})),201)}let f=X(a,"/api/review/threads/");if((e.method==="PATCH"||e.method==="DELETE")&&f!==void 0){let m=await G(t,s),h=s.getThread(f);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);if(e.method==="DELETE")return s.deleteThread(f),A({deleted:!0});let b=await H(e);if(!b||typeof b.body!=="string")throw new N("invalid_request","Comment body is required");let v=h.messages.find((T)=>T.source==="local");if(v==null)s.createMessage({threadId:f,body:b.body});else s.updateMessage(v.id,b.body);if(b.anchor!==void 0&&h.anchors[0]!=null)s.updateAnchor(h.anchors[0].id,gt(b.anchor));return A(Ts(s.getThread(f)))}let y=X(a,"/api/review/drafts/");if((e.method==="PUT"||e.method==="DELETE")&&y!==void 0){let m=await G(t,s);if(e.method==="DELETE"){let b=s.getDraft(y);if(b!=null&&b.snapshotId!==m.id)throw new N("not_found","Review draft not found",404);return s.deleteDraft(y),A({deleted:!0})}let h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Draft body is required");return A(yr(s.upsertDraft({id:y,snapshotId:m.id,anchor:gt(h.anchor),body:h.body})))}let _=el(a);if(e.method==="GET"&&_!==void 0){if(i.searchParams.get("hydrate")==="true"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null||h===null||b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","from, to, and a valid mode are required");return A(await t.getFileContents({comparison:{from:m,to:h,mode:b},includeUnstaged:i.searchParams.get("includeUnstaged")==="true",oldPath:i.searchParams.get("oldPath")??void 0,newPath:i.searchParams.get("newPath")??void 0,pureRename:i.searchParams.get("pureRename")==="true"}))}return A(await t.getFileDiff(_))}if(e.method==="GET"&&(a==="/api/diff"||a==="/api/patch")){let m=i.searchParams.get("fileId")??i.searchParams.get("path");if(!m)throw new N("missing_file","A fileId or path query parameter is required");return A(await t.getFileDiff(m))}if(e.method==="POST"&&(a==="/api/open"||a==="/api/open-working-file")){let m=await H(e);if(!m||typeof m.path!=="string")throw new N("invalid_request","Request body must include a repository-relative path");if(m.line!==void 0&&typeof m.line!=="number"||m.column!==void 0&&typeof m.column!=="number"||m.side!==void 0&&m.side!=="old"&&m.side!=="new")throw new N("invalid_request","line and column must be numbers");let h={path:m.path,...m.line===void 0?{}:{line:m.line},...m.column===void 0?{}:{column:m.column},...m.side===void 0?{}:{side:m.side}};return A(await t.openWorkingFile(h))}throw new N("not_found","API endpoint not found",404)}async function G(e,t){let s=await e.getRepositoryMetadata();return t.ensureSnapshot({canonicalRoot:s.root,remoteOrigin:s.remoteOrigin,comparisonMode:s.comparisonMode,baseRef:s.fromRef,headRef:s.toRef,baseSha:s.baseSha,headSha:s.targetSha})}function gt(e){if(e==null||typeof e!=="object"||Array.isArray(e))throw new N("invalid_anchor","A review anchor is required");let t=e;if(typeof t.path!=="string")throw new N("invalid_anchor","Anchor path is required");let s=t.kind==="diff_range"?"diff_range":t.kind==="file"?"file":null;if(s==null)throw new N("invalid_anchor","Anchor kind is invalid");return{kind:s,path:t.path,side:t.side==="old"||t.side==="new"?t.side:null,startLine:typeof t.startLine==="number"?t.startLine:null,endLine:typeof t.endLine==="number"?t.endLine:null,contextFingerprint:typeof t.contextHash==="string"?t.contextHash:null}}function Ts(e){let t=e.anchors[0],s=e.messages.find((n)=>n.source==="local");return{id:e.id,snapshotId:e.snapshotId,anchor:t==null?null:{id:t.id,kind:t.kind,path:t.path,side:t.side,startLine:t.startLine,endLine:t.endLine,contextHash:t.contextFingerprint},body:s?.body??"",createdAt:e.createdAt,updatedAt:e.updatedAt,agentSession:e.agentSessions[0]??null}}function yr(e){return{id:e.id,snapshotId:e.snapshotId,anchor:{kind:e.anchor.kind,path:e.anchor.path,side:e.anchor.side,startLine:e.anchor.startLine,endLine:e.anchor.endLine,contextHash:e.anchor.contextFingerprint},body:e.body,updatedAt:e.updatedAt}}function X(e,t,s=""){if(!e.startsWith(t)||s!==""&&!e.endsWith(s))return;let n=e.slice(t.length,s===""?void 0:-s.length);if(n===""||n.includes("/"))return;try{return decodeURIComponent(n)}catch{throw new N("invalid_path","Path segment is not valid URL encoding")}}function _r(e,t=[]){return{id:e.id,provider:e.provider,externalThreadId:e.externalThreadId,model:e.model,effort:e.reasoningEffort,permissionMode:e.permissionMode,status:e.status,history:t}}function wr(e){return{..._r(e),contexts:e.contexts.map((t)=>({id:t.id,sourceThreadId:t.sourceThreadId,anchor:{kind:t.anchor.kind,path:t.anchor.path,side:t.anchor.side,startLine:t.anchor.startLine,endLine:t.anchor.endLine},prompt:t.prompt,createdAt:t.createdAt}))}}class Sr{providerReady=new Set;subscribers=new Map;buffered=new Map;encoder=new TextEncoder;markProviderReady(e){this.providerReady.add(e)}isProviderReady(e){return this.providerReady.has(e)}pump(e,t,s){this.buffered.set(e,[]),(async()=>{try{for await(let n of t)s(n),this.publish(e,Za(n))}catch(n){this.publish(e,{type:"error",message:n instanceof Error?n.message:String(n)})}})()}response(e){let t,s=new ReadableStream({start:(n)=>{t=n;let r=this.subscribers.get(e)??new Set;r.add(n),this.subscribers.set(e,r);for(let i of this.buffered.get(e)??[])this.send(n,i)},cancel:()=>{if(t==null)return;let n=this.subscribers.get(e);if(n?.delete(t),n?.size===0)this.subscribers.delete(e)}});return new Response(s,{headers:{"cache-control":"no-cache, no-store","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}publish(e,t){let s=this.buffered.get(e)??[];if(s.push(t),s.length>2000)s.shift();this.buffered.set(e,s);for(let n of this.subscribers.get(e)??[])this.send(n,t)}send(e,t){try{e.enqueue(this.encoder.encode(`event: message
400
403
  data: ${JSON.stringify(t)}
401
404
 
402
- `))}catch{}}}function Ga(e){switch(e.type){case"text-delta":return{type:"text_delta",delta:e.delta};case"activity":return{type:"activity",label:e.detail,detail:e.kind};case"completed":return{type:"done",status:e.status};case"stopped":return{type:"done",status:"stopped"};case"error":return{type:"error",message:e.message};default:return e}}function za(e){let t;if(e.startsWith("/api/files/")&&e.endsWith("/diff"))t=e.slice(11,-5);else if(e.startsWith("/api/diff/"))t=e.slice(10);else if(e.startsWith("/api/patch/"))t=e.slice(11);if(t===void 0||!t)return;try{return decodeURIComponent(t)}catch{throw new N("invalid_file","File identifier is not valid URL encoding")}}async function H(e){let t=await e.text();if(t.length>65536)throw new N("request_too_large","Request body is too large",413);try{let s=JSON.parse(t);return s&&typeof s==="object"&&!Array.isArray(s)?s:null}catch{throw new N("invalid_json","Request body must be valid JSON")}}function Qa(e){let t=new TextEncoder,s=!1,n=()=>{},r=new ReadableStream({start(i){let o=(a,l)=>{if(s)return;try{i.enqueue(t.encode(`event: ${a}
405
+ `))}catch{}}}function Za(e){switch(e.type){case"text-delta":return{type:"text_delta",delta:e.delta};case"activity":return{type:"activity",label:e.detail,detail:e.kind};case"completed":return{type:"done",status:e.status};case"stopped":return{type:"done",status:"stopped"};case"error":return{type:"error",message:e.message};default:return e}}function el(e){let t;if(e.startsWith("/api/files/")&&e.endsWith("/diff"))t=e.slice(11,-5);else if(e.startsWith("/api/diff/"))t=e.slice(10);else if(e.startsWith("/api/patch/"))t=e.slice(11);if(t===void 0||!t)return;try{return decodeURIComponent(t)}catch{throw new N("invalid_file","File identifier is not valid URL encoding")}}async function H(e){let t=await e.text();if(t.length>65536)throw new N("request_too_large","Request body is too large",413);try{let s=JSON.parse(t);return s&&typeof s==="object"&&!Array.isArray(s)?s:null}catch{throw new N("invalid_json","Request body must be valid JSON")}}function tl(e){let t=new TextEncoder,s=!1,n=()=>{},r=new ReadableStream({start(i){let o=(a,l)=>{if(s)return;try{i.enqueue(t.encode(`event: ${a}
403
406
  data: ${JSON.stringify(l)}
404
407
 
405
- `))}catch{s=!0,n()}};n=e.subscribe((a)=>o("repository",{changed:a.changed,revision:a.revision})),e.getRepositoryMetadata().then((a)=>{o("ready",{revision:a.revision})}).catch(()=>{})},cancel(){s=!0,n()}});return new Response(r,{headers:{"cache-control":"no-cache, no-store",connection:"keep-alive","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}function Za(e){let t=e??process.env.REVIEWME_STATIC_DIR;if(!t){let n=Rs(ja(Wa(import.meta.url)),"../frontend");return hr(As(n,"index.html"))?n:void 0}let s=Ka(t)?t:Rs(process.cwd(),t);return hr(As(s,"index.html"))?s:void 0}async function el(e,t){if(!t)return new Response(Ha,{headers:{"content-type":"text/html; charset=utf-8"}});let s;try{s=decodeURIComponent(e.pathname)}catch{return new Response("Bad URL",{status:400})}let n=s==="/"?"index.html":s.replace(/^\/+/,""),r=Rs(t,n);if(r!==t&&!r.startsWith(`${t}/`))return new Response("Not found",{status:404});try{let o=await pr(r);if(o.isFile())return new Response(yt.toWeb(fr(r)),{headers:{"cache-control":"no-cache","content-length":String(o.size),"content-type":Ya[mr(r).toLowerCase()]??"application/octet-stream"}})}catch{}let i=As(t,"index.html");if(!mr(r))try{let o=await pr(i);if(o.isFile())return new Response(yt.toWeb(fr(i)),{headers:{"content-length":String(o.size),"content-type":"text/html; charset=utf-8"}})}catch{}return new Response("Not found",{status:404})}class N extends Error{code;status;constructor(e,t,s=400){super(t);this.name="RequestError",this.code=e,this.status=s}}function tl(e){if(e instanceof N)return A({error:{code:e.code,message:e.message}},e.status);if(e instanceof dt)return A({error:{code:e.code,message:e.message}},404);if(e instanceof W)return A({error:{code:"invalid_path",message:e.message}},400);if(e instanceof L)return A({error:{code:"invalid_review",message:e.message}},400);if(e instanceof D)return A({error:{code:"not_found",message:e.message}},404);if(e instanceof ce){let s=e.code==="invalid_ref"||e.code==="no_merge_base"?422:400;return A({error:{code:e.code,message:e.message}},s)}if(e instanceof V)return A({error:{code:"git_error",message:e.message}},500);let t=e instanceof Error?e.message:"Unexpected server error";return A({error:{code:"internal_error",message:t}},500)}function A(e,t=200,s={}){return new Response(JSON.stringify(e),{status:t,headers:{"cache-control":"no-store","content-type":"application/json; charset=utf-8",...s}})}import{readFile as ty,stat as sy}from"node:fs/promises";import{extname as ny,resolve as ry}from"node:path";var pg=Rn(),mg=Ze(),gg=dn(),Fn=et(),yg=$e(),le=C(),wg=ne(),bg=k(),_g=ie(),Sg=oe(),gb=ss(),Eg=Mn(),vg=Dn(),Tg=qn(),os=xo(),Oo=qe();var Ag=pg.Composer,Rg=mg.Document,Cg=gg.Schema,Ng=Fn.YAMLError,xg=Fn.YAMLParseError,Og=Fn.YAMLWarning,Lg=yg.Alias,kg=le.isAlias,Ig=le.isCollection,Pg=le.isDocument,Mg=le.isMap,Dg=le.isNode,qg=le.isPair,Fg=le.isScalar,$g=le.isSeq,Ug=wg.Pair,Bg=bg.Scalar,jg=_g.YAMLMap,Kg=Sg.YAMLSeq;var Wg=Eg.Lexer,Hg=vg.LineCounter,Yg=Tg.Parser,$n=os.parse,Jg=os.parseAllDocuments,Vg=os.parseDocument,Xg=os.stringify,Gg=Oo.visit,zg=Oo.visitAsync;var Lo=["background","sidebar","panel","panelRaised","border","borderStrong","text","muted","subtle","accent","added","deleted","info"],Qg=new Set(["name","version","light","dark","syntax"]),ko=new Set(["github-light","github-dark","github-dark-dimmed","nord","dracula","dracula-soft"]),Zg=[/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,/^rgba?\(\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i,/^hsla?\(\s*-?\d+(?:\.\d+)?(?:deg)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i];function ey(e){if(!Un(e))throw Error("theme must be an object");for(let n of Object.keys(e))if(!Qg.has(n))throw Error(`unknown field: ${n}`);if(typeof e.name!=="string"||e.name.trim()==="")throw Error("name must be a non-empty string");if(e.version!==1)throw Error("version must be 1");let t=(n)=>{let r=e[n];if(!Un(r))throw Error(`${n} must be an object`);for(let i of Object.keys(r))if(!Lo.includes(i))throw Error(`${n}.${i} is not supported`);return Object.fromEntries(Lo.map((i)=>{let o=r[i];if(typeof o!=="string"||!Zg.some((a)=>a.test(o.trim())))throw Error(`${n}.${i} must be a safe CSS color`);return[i,o.trim()]}))},s=e.syntax;if(s!==void 0&&!Un(s))throw Error("syntax must be an object");if(s!=null){for(let n of Object.keys(s))if(n!=="light"&&n!=="dark")throw Error(`syntax.${n} is not supported`);if(s.light!==void 0&&(typeof s.light!=="string"||!ko.has(s.light)))throw Error("syntax.light is not a supported syntax theme");if(s.dark!==void 0&&(typeof s.dark!=="string"||!ko.has(s.dark)))throw Error("syntax.dark is not a supported syntax theme")}return{name:e.name.trim(),version:1,light:t("light"),dark:t("dark"),syntax:{light:s?.light??"github-light",dark:s?.dark??"github-dark"}}}function Io(e,t){let s;try{s=t==="json"?JSON.parse(e):$n(e,{maxAliasCount:50})}catch(n){throw Error(`could not parse ${t.toUpperCase()}: ${n instanceof Error?n.message:String(n)}`)}return ey(s)}var as=(e,t,s,n={light:"github-light",dark:"github-dark"})=>({name:e,version:1,light:t,dark:s,syntax:n}),bb={default:as("Default",{background:"#f5f6f4",sidebar:"#eef0ed",panel:"#ffffff",panelRaised:"#e7eae6",border:"rgba(22,31,28,0.11)",borderStrong:"rgba(22,31,28,0.20)",text:"#202724",muted:"#64706b",subtle:"#89938f",accent:"#303ca9",added:"#16844b",deleted:"#c13e45",info:"#316fc1"},{background:"#0d0f10",sidebar:"#111315",panel:"#151819",panelRaised:"#1b1f20",border:"rgba(255,255,255,0.09)",borderStrong:"rgba(255,255,255,0.15)",text:"#e2e6e5",muted:"#8c9694",subtle:"#5e6967",accent:"#4c67dc",added:"#5bc98a",deleted:"#f07979",info:"#7aa8ff"}),github:as("GitHub",{background:"#ffffff",sidebar:"#f6f8fa",panel:"#ffffff",panelRaised:"#f6f8fa",border:"rgba(31,35,40,0.15)",borderStrong:"rgba(31,35,40,0.25)",text:"#1f2328",muted:"#636c76",subtle:"#8c959f",accent:"#0969da",added:"#1a7f37",deleted:"#cf222e",info:"#0969da"},{background:"#0d1117",sidebar:"#161b22",panel:"#161b22",panelRaised:"#21262d",border:"rgba(240,246,252,0.10)",borderStrong:"rgba(240,246,252,0.20)",text:"#e6edf3",muted:"#8b949e",subtle:"#6e7681",accent:"#58a6ff",added:"#3fb950",deleted:"#f85149",info:"#58a6ff"}),nord:as("Nord",{background:"#eceff4",sidebar:"#e5e9f0",panel:"#ffffff",panelRaised:"#d8dee9",border:"rgba(46,52,64,0.12)",borderStrong:"rgba(46,52,64,0.22)",text:"#2e3440",muted:"#667080",subtle:"#8792a2",accent:"#5e81ac",added:"#3b8c6e",deleted:"#bf616a",info:"#5e81ac"},{background:"#2e3440",sidebar:"#272c36",panel:"#343b49",panelRaised:"#3b4352",border:"rgba(236,239,244,0.10)",borderStrong:"rgba(236,239,244,0.18)",text:"#eceff4",muted:"#aeb8c8",subtle:"#7f8a9a",accent:"#88c0d0",added:"#a3be8c",deleted:"#bf616a",info:"#81a1c1"},{light:"github-light",dark:"nord"}),dracula:as("Dracula",{background:"#f8f8f2",sidebar:"#eeeeea",panel:"#ffffff",panelRaised:"#e5e5df",border:"rgba(40,42,54,0.13)",borderStrong:"rgba(40,42,54,0.23)",text:"#282a36",muted:"#626579",subtle:"#898b99",accent:"#7c3aed",added:"#2d8a54",deleted:"#c43d58",info:"#526ddb"},{background:"#282a36",sidebar:"#21222c",panel:"#30323f",panelRaised:"#3a3c4b",border:"rgba(248,248,242,0.10)",borderStrong:"rgba(248,248,242,0.18)",text:"#f8f8f2",muted:"#b5b6c3",subtle:"#77798a",accent:"#bd93f9",added:"#50fa7b",deleted:"#ff5555",info:"#8be9fd"},{light:"github-light",dark:"dracula"})};function Un(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var iy=262144;async function Po(e){let t=ry(process.cwd(),e);try{let s=await sy(t);if(!s.isFile())throw Error("path is not a file");if(s.size>iy)throw Error("file exceeds the 256 KB limit");let n=ny(t).toLowerCase();if(n!==".json"&&n!==".yaml"&&n!==".yml")throw Error("file extension must be .json, .yaml, or .yml");return Io(await ty(t,"utf8"),n===".json"?"json":"yaml")}catch(s){throw Error(`Color theme ${e}: ${s instanceof Error?s.message:String(s)}`)}}async function Mo(e=process.argv.slice(2),t={}){try{let s=er(e);if(s.help)return console.log(tr),0;let n=ut({repoPath:s.repoPath,range:s.range,from:s.from,to:s.to,openCommand:s.openCommand,watchIntervalMs:s.watchIntervalMs}),r=s.colorThemePath==null?void 0:await Po(s.colorThemePath),i=await wr({...t,service:n,port:s.port,auth:s.auth,watchIntervalMs:s.watchIntervalMs,colorTheme:r});if(console.log(`ReviewMe: ${i.url}`),s.openBrowser)await ay(i.url);let o=()=>i.close();return process.once("SIGINT",o),process.once("SIGTERM",o),0}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}}async function ay(e){let t=process.platform,s=t==="darwin"?["open",e]:t==="win32"?["cmd","/c","start","",e]:["xdg-open",e];try{let[n,...r]=s;if(!n)return;let i=oy(n,r,{stdio:"ignore",detached:!0});i.once("error",()=>{}),i.unref()}catch{}}var Do=await Mo();if(Do!==0)process.exitCode=Do;
408
+ `))}catch{s=!0,n()}};n=e.subscribe((a)=>o("repository",{changed:a.changed,revision:a.revision})),e.getRepositoryMetadata().then((a)=>{o("ready",{revision:a.revision})}).catch(()=>{})},cancel(){s=!0,n()}});return new Response(r,{headers:{"cache-control":"no-cache, no-store",connection:"keep-alive","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}function sl(e){let t=e??process.env.REVIEWME_STATIC_DIR;if(!t){let n=Rs(Ha(Ja(import.meta.url)),"../frontend");return pr(As(n,"index.html"))?n:void 0}let s=Ya(t)?t:Rs(process.cwd(),t);return pr(As(s,"index.html"))?s:void 0}async function nl(e,t){if(!t)return new Response(Va,{headers:{"content-type":"text/html; charset=utf-8"}});let s;try{s=decodeURIComponent(e.pathname)}catch{return new Response("Bad URL",{status:400})}let n=s==="/"?"index.html":s.replace(/^\/+/,""),r=Rs(t,n);if(r!==t&&!r.startsWith(`${t}/`))return new Response("Not found",{status:404});try{let o=await mr(r);if(o.isFile())return new Response(yt.toWeb(hr(r)),{headers:{"cache-control":"no-cache","content-length":String(o.size),"content-type":Ga[gr(r).toLowerCase()]??"application/octet-stream"}})}catch{}let i=As(t,"index.html");if(!gr(r))try{let o=await mr(i);if(o.isFile())return new Response(yt.toWeb(hr(i)),{headers:{"content-length":String(o.size),"content-type":"text/html; charset=utf-8"}})}catch{}return new Response("Not found",{status:404})}class N extends Error{code;status;constructor(e,t,s=400){super(t);this.name="RequestError",this.code=e,this.status=s}}function rl(e){if(e instanceof N)return A({error:{code:e.code,message:e.message}},e.status);if(e instanceof dt)return A({error:{code:e.code,message:e.message}},404);if(e instanceof W)return A({error:{code:"invalid_path",message:e.message}},400);if(e instanceof L)return A({error:{code:"invalid_review",message:e.message}},400);if(e instanceof D)return A({error:{code:"not_found",message:e.message}},404);if(e instanceof ce){let s=e.code==="invalid_ref"||e.code==="no_merge_base"?422:400;return A({error:{code:e.code,message:e.message}},s)}if(e instanceof V)return A({error:{code:"git_error",message:e.message}},500);let t=e instanceof Error?e.message:"Unexpected server error";return A({error:{code:"internal_error",message:t}},500)}function A(e,t=200,s={}){return new Response(JSON.stringify(e),{status:t,headers:{"cache-control":"no-store","content-type":"application/json; charset=utf-8",...s}})}import{readFile as ry,stat as iy}from"node:fs/promises";import{extname as oy,resolve as ay}from"node:path";var yg=Rn(),wg=Ze(),bg=dn(),Fn=et(),_g=$e(),le=C(),Sg=ne(),vg=k(),Eg=ie(),Tg=oe(),Sb=ss(),Ag=Mn(),Rg=Dn(),Cg=qn(),os=Oo(),Lo=qe();var Ng=yg.Composer,xg=wg.Document,Og=bg.Schema,Lg=Fn.YAMLError,kg=Fn.YAMLParseError,Ig=Fn.YAMLWarning,Pg=_g.Alias,Mg=le.isAlias,Dg=le.isCollection,qg=le.isDocument,Fg=le.isMap,$g=le.isNode,Ug=le.isPair,Bg=le.isScalar,jg=le.isSeq,Kg=Sg.Pair,Wg=vg.Scalar,Hg=Eg.YAMLMap,Yg=Tg.YAMLSeq;var Jg=Ag.Lexer,Vg=Rg.LineCounter,Gg=Cg.Parser,$n=os.parse,Xg=os.parseAllDocuments,zg=os.parseDocument,Qg=os.stringify,Zg=Lo.visit,ey=Lo.visitAsync;var ko=["background","sidebar","panel","panelRaised","border","borderStrong","text","muted","subtle","accent","added","deleted","info"],ty=new Set(["name","version","light","dark","syntax"]),Io=new Set(["github-light","github-dark","github-dark-dimmed","nord","dracula","dracula-soft"]),sy=[/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,/^rgba?\(\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i,/^hsla?\(\s*-?\d+(?:\.\d+)?(?:deg)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i];function ny(e){if(!Un(e))throw Error("theme must be an object");for(let n of Object.keys(e))if(!ty.has(n))throw Error(`unknown field: ${n}`);if(typeof e.name!=="string"||e.name.trim()==="")throw Error("name must be a non-empty string");if(e.version!==1)throw Error("version must be 1");let t=(n)=>{let r=e[n];if(!Un(r))throw Error(`${n} must be an object`);for(let i of Object.keys(r))if(!ko.includes(i))throw Error(`${n}.${i} is not supported`);return Object.fromEntries(ko.map((i)=>{let o=r[i];if(typeof o!=="string"||!sy.some((a)=>a.test(o.trim())))throw Error(`${n}.${i} must be a safe CSS color`);return[i,o.trim()]}))},s=e.syntax;if(s!==void 0&&!Un(s))throw Error("syntax must be an object");if(s!=null){for(let n of Object.keys(s))if(n!=="light"&&n!=="dark")throw Error(`syntax.${n} is not supported`);if(s.light!==void 0&&(typeof s.light!=="string"||!Io.has(s.light)))throw Error("syntax.light is not a supported syntax theme");if(s.dark!==void 0&&(typeof s.dark!=="string"||!Io.has(s.dark)))throw Error("syntax.dark is not a supported syntax theme")}return{name:e.name.trim(),version:1,light:t("light"),dark:t("dark"),syntax:{light:s?.light??"github-light",dark:s?.dark??"github-dark"}}}function Po(e,t){let s;try{s=t==="json"?JSON.parse(e):$n(e,{maxAliasCount:50})}catch(n){throw Error(`could not parse ${t.toUpperCase()}: ${n instanceof Error?n.message:String(n)}`)}return ny(s)}var as=(e,t,s,n={light:"github-light",dark:"github-dark"})=>({name:e,version:1,light:t,dark:s,syntax:n}),Tb={default:as("Default",{background:"#f5f6f4",sidebar:"#eef0ed",panel:"#ffffff",panelRaised:"#e7eae6",border:"rgba(22,31,28,0.11)",borderStrong:"rgba(22,31,28,0.20)",text:"#202724",muted:"#64706b",subtle:"#89938f",accent:"#303ca9",added:"#16844b",deleted:"#c13e45",info:"#316fc1"},{background:"#0d0f10",sidebar:"#111315",panel:"#151819",panelRaised:"#1b1f20",border:"rgba(255,255,255,0.09)",borderStrong:"rgba(255,255,255,0.15)",text:"#e2e6e5",muted:"#8c9694",subtle:"#5e6967",accent:"#4c67dc",added:"#5bc98a",deleted:"#f07979",info:"#7aa8ff"}),github:as("GitHub",{background:"#ffffff",sidebar:"#f6f8fa",panel:"#ffffff",panelRaised:"#f6f8fa",border:"rgba(31,35,40,0.15)",borderStrong:"rgba(31,35,40,0.25)",text:"#1f2328",muted:"#636c76",subtle:"#8c959f",accent:"#0969da",added:"#1a7f37",deleted:"#cf222e",info:"#0969da"},{background:"#0d1117",sidebar:"#161b22",panel:"#161b22",panelRaised:"#21262d",border:"rgba(240,246,252,0.10)",borderStrong:"rgba(240,246,252,0.20)",text:"#e6edf3",muted:"#8b949e",subtle:"#6e7681",accent:"#58a6ff",added:"#3fb950",deleted:"#f85149",info:"#58a6ff"}),nord:as("Nord",{background:"#eceff4",sidebar:"#e5e9f0",panel:"#ffffff",panelRaised:"#d8dee9",border:"rgba(46,52,64,0.12)",borderStrong:"rgba(46,52,64,0.22)",text:"#2e3440",muted:"#667080",subtle:"#8792a2",accent:"#5e81ac",added:"#3b8c6e",deleted:"#bf616a",info:"#5e81ac"},{background:"#2e3440",sidebar:"#272c36",panel:"#343b49",panelRaised:"#3b4352",border:"rgba(236,239,244,0.10)",borderStrong:"rgba(236,239,244,0.18)",text:"#eceff4",muted:"#aeb8c8",subtle:"#7f8a9a",accent:"#88c0d0",added:"#a3be8c",deleted:"#bf616a",info:"#81a1c1"},{light:"github-light",dark:"nord"}),dracula:as("Dracula",{background:"#f8f8f2",sidebar:"#eeeeea",panel:"#ffffff",panelRaised:"#e5e5df",border:"rgba(40,42,54,0.13)",borderStrong:"rgba(40,42,54,0.23)",text:"#282a36",muted:"#626579",subtle:"#898b99",accent:"#7c3aed",added:"#2d8a54",deleted:"#c43d58",info:"#526ddb"},{background:"#282a36",sidebar:"#21222c",panel:"#30323f",panelRaised:"#3a3c4b",border:"rgba(248,248,242,0.10)",borderStrong:"rgba(248,248,242,0.18)",text:"#f8f8f2",muted:"#b5b6c3",subtle:"#77798a",accent:"#bd93f9",added:"#50fa7b",deleted:"#ff5555",info:"#8be9fd"},{light:"github-light",dark:"dracula"})};function Un(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ly=262144;async function Mo(e){let t=ay(process.cwd(),e);try{let s=await iy(t);if(!s.isFile())throw Error("path is not a file");if(s.size>ly)throw Error("file exceeds the 256 KB limit");let n=oy(t).toLowerCase();if(n!==".json"&&n!==".yaml"&&n!==".yml")throw Error("file extension must be .json, .yaml, or .yml");return Po(await ry(t,"utf8"),n===".json"?"json":"yaml")}catch(s){throw Error(`Color theme ${e}: ${s instanceof Error?s.message:String(s)}`)}}async function Do(e,t={}){try{let s=await(t.fetchImpl??fetch)("https://registry.npmjs.org/reviewme/latest",{signal:AbortSignal.timeout(t.timeoutMs??2000)});if(!s.ok)return;let n=await s.json(),r=n!=null&&typeof n==="object"&&"version"in n?n.version:void 0;if(typeof r!=="string"||!cy(r,e))return;(t.write??console.log)(`
409
+ Update available: ${e} → ${r}
410
+ Run: npx reviewme@latest`)}catch{}}function cy(e,t){let s=/^(\d+)\.(\d+)\.(\d+)$/.exec(e),n=/^(\d+)\.(\d+)\.(\d+)$/.exec(t);if(s==null||n==null)return!1;for(let r=1;r<=3;r+=1){let i=Number(s[r])-Number(n[r]);if(i!==0)return i>0}return!1}async function qo(e=process.argv.slice(2),t={}){try{let s=tr(e);if(s.help)return console.log(sr),0;let n=ut({repoPath:s.repoPath,range:s.range,from:s.from,to:s.to,openCommand:s.openCommand,watchIntervalMs:s.watchIntervalMs}),r=s.colorThemePath==null?void 0:await Mo(s.colorThemePath),i=await br({...t,service:n,port:s.port,auth:s.auth,watchIntervalMs:s.watchIntervalMs,colorTheme:r});if(console.log(`ReviewMe: ${i.url}`),Do(jn.version),s.openBrowser)await uy(i.url);let o=()=>i.close();return process.once("SIGINT",o),process.once("SIGTERM",o),0}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}}async function uy(e){let t=process.platform,s=t==="darwin"?["open",e]:t==="win32"?["cmd","/c","start","",e]:["xdg-open",e];try{let[n,...r]=s;if(!n)return;let i=dy(n,r,{stdio:"ignore",detached:!0});i.once("error",()=>{}),i.unref()}catch{}}var Fo=await qo();if(Fo!==0)process.exitCode=Fo;
406
411
 
407
- //# debugId=CC9515699E46644564756E2164756E21
412
+ //# debugId=0C3E0DE745A6413D64756E2164756E21
408
413
  //# sourceMappingURL=main.js.map