reviewme 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +189 -0
- package/README.md +108 -0
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/bin/reviewme.mjs +23 -0
- package/dist/frontend/index-pnpx6fbm.css +1 -0
- package/dist/frontend/index-y224j9f0.js +3314 -0
- package/dist/frontend/index.html +26 -0
- package/dist/server/main.js +402 -0
- package/dist/server/main.js.map +92 -0
- package/examples/themes/custom.yml +33 -0
- package/package.json +48 -0
|
@@ -0,0 +1,402 @@
|
|
|
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 R=S(function(al){var Cs=Symbol.for("yaml.alias"),Sr=Symbol.for("yaml.document"),wt=Symbol.for("yaml.map"),vr=Symbol.for("yaml.pair"),Ns=Symbol.for("yaml.scalar"),bt=Symbol.for("yaml.seq"),X=Symbol.for("yaml.node.type"),el=(e)=>!!e&&typeof e==="object"&&e[X]===Cs,tl=(e)=>!!e&&typeof e==="object"&&e[X]===Sr,sl=(e)=>!!e&&typeof e==="object"&&e[X]===wt,nl=(e)=>!!e&&typeof e==="object"&&e[X]===vr,Er=(e)=>!!e&&typeof e==="object"&&e[X]===Ns,rl=(e)=>!!e&&typeof e==="object"&&e[X]===bt;function Tr(e){if(e&&typeof e==="object")switch(e[X]){case wt:case bt:return!0}return!1}function il(e){if(e&&typeof e==="object")switch(e[X]){case Cs:case wt:case Ns:case bt:return!0}return!1}var ol=(e)=>(Er(e)||Tr(e))&&!!e.anchor;al.ALIAS=Cs;al.DOC=Sr;al.MAP=wt;al.NODE_TYPE=X;al.PAIR=vr;al.SCALAR=Ns;al.SEQ=bt;al.hasAnchor=ol;al.isAlias=el;al.isCollection=Tr;al.isDocument=tl;al.isMap=sl;al.isNode=il;al.isPair=nl;al.isScalar=Er;al.isSeq=rl});var qe=S(function(Tl){var P=R(),q=Symbol("break visit"),Ar=Symbol("skip children"),H=Symbol("remove node");function _t(e,t){let s=Rr(t);if(P.isDocument(e)){if(Ae(null,e.contents,s,Object.freeze([e]))===H)e.contents=null}else Ae(null,e,s,Object.freeze([]))}_t.BREAK=q;_t.SKIP=Ar;_t.REMOVE=H;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===H)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===H)t.key=null;let o=Ae("value",t.value,s,n);if(o===q)return q;else if(o===H)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]))===H)e.contents=null}else await Re(null,e,s,Object.freeze([]))}St.BREAK=q;St.SKIP=Ar;St.REMOVE=H;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===H)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===H)t.key=null;let o=await Re("value",t.value,s,n);if(o===q)return q;else if(o===H)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`)}}Tl.visit=_t;Tl.visitAsync=St});var xs=S(function(Ol){var xr=R(),Cl=qe(),Nl={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},xl=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Nl[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+xl(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={};Cl.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:"};Ol.Directives=F});var vt=S(function(Ml){var Or=R(),kl=qe();function Il(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 kl.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 Pl(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}}Ml.anchorIsValid=Il;Ml.anchorNames=Lr;Ml.createNodeAnchors=Pl;Ml.findNewAnchor=kr});var Os=S(function(Ul){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)}Ul.applyReviver=Fe});var ee=S(function(Kl){var jl=R();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||!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}Kl.toJS=Ir});var Et=S(function(Jl){var Hl=Os(),Pr=R(),Yl=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=Yl.toJS(this,"",i);if(typeof n==="function")for(let{count:a,res:l}of i.anchors.values())n(l,a);return typeof r==="function"?Hl.applyReviver(r,{"":o},"",o):o}}Jl.NodeBase=Mr});var $e=S(function(Zl){var Xl=vt(),Gl=qe(),Ce=R(),zl=Et(),Ql=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=[],Gl.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)Ql.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(Xl.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}Zl.Alias=Dr});var k=S(function(ic){var tc=R(),sc=Et(),nc=ee(),rc=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class he extends sc.NodeBase{constructor(e){super(tc.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:nc.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";ic.Scalar=he;ic.isScalarValue=rc});var Ue=S(function(fc){var lc=$e(),pe=R(),qr=k(),cc="tag:yaml.org,2002:";function dc(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 uc(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 lc.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=cc+t.slice(2);let c=dc(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}fc.createNode=uc});var At=S(function(gc){var pc=Ue(),Y=R(),mc=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 pc.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 mc.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)=>Y.isNode(s)||Y.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(Y.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(Y.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&&Y.isScalar(r)?r.value:r;else return Y.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Y.isPair(t))return!1;let s=t.value;return s==null||e&&Y.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 Y.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(Y.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}`)}}}gc.Collection=$r;gc.collectionFromPath=Ls;gc.isEmptyPath=Fr});var Be=S(function(vc){var _c=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function ks(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Sc=(e,t,s)=>e.endsWith(`
|
|
3
|
+
`)?ks(s,t):s.includes(`
|
|
4
|
+
`)?`
|
|
5
|
+
`+ks(s,t):(e.endsWith(" ")?"":" ")+s;vc.indentComment=ks;vc.lineComment=Sc;vc.stringifyComment=_c});var Br=S(function(Cc){function Rc(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,m=void 0,g=!1,h=-1,b=-1,f=-1;if(s==="block"){if(h=Ur(e,h,t.length),h!==-1)d=h+l}for(let w;w=e[h+=1];){if(s==="quoted"&&w==="\\"){switch(b=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}f=h}if(w===`
|
|
6
|
+
`){if(s==="block")h=Ur(e,h,t.length);d=h+t.length+l,u=void 0}else{if(w===" "&&m&&m!==" "&&m!==`
|
|
7
|
+
`&&m!=="\t"){let _=e[h+1];if(_&&_!==" "&&_!==`
|
|
8
|
+
`&&_!=="\t")u=h}if(h>=d)if(u)c.push(u),d=u+l,u=void 0;else if(s==="quoted"){while(m===" "||m==="\t")m=w,w=e[h+=1],g=!0;let _=h>f+1?h-2:b-1;if(p[_])return e;c.push(_),p[_]=!0,d=_+l,u=void 0}else g=!0}m=w}if(g&&a)a();if(c.length===0)return e;if(o)o();let y=e.slice(0,c[0]);for(let w=0;w<c.length;++w){let _=c[w],v=c[w+1]||e.length;if(_===0)y=`
|
|
9
|
+
${t}${e.slice(0,v)}`;else{if(s==="quoted"&&p[_])y+=`${e[_]}\\`;y+=`
|
|
10
|
+
${t}${e.slice(_+1,v)}`}}return y}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}Cc.FOLD_BLOCK="block";Cc.FOLD_FLOW="flow";Cc.FOLD_QUOTED="quoted";Cc.foldFlowLines=Rc});var Ke=S(function(Mc){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 kc(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
|
+
`){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
|
+
|
|
14
|
+
`;while(s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"')o+=`
|
|
15
|
+
`,l+=2;if(o+=i,s[l+2]===" ")o+="\\";l+=1,a=l+1}break;default:l+=1}}return o=a?o+s.slice(a):s,n?o:te.foldFlowLines(o,i,te.FOLD_QUOTED,Ct(t,!1))}function Is(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return je(e,t);let s=t.indent||(Nt(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
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
|
+
))
|
|
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:!kc(s,l,c.length);if(!s)return p?`|
|
|
21
|
+
`:`>
|
|
22
|
+
`;let d,u;for(u=s.length;u>0;--u){let v=s[u-1];if(v!==`
|
|
23
|
+
`&&v!=="\t"&&v!==" ")break}let m=s.substring(u),g=m.indexOf(`
|
|
24
|
+
`);if(g===-1)d="-";else if(s===m||g!==m.length-1){if(d="+",i)i()}else d="";if(m){if(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
25
|
+
`)m=m.slice(0,-1);m=m.replace(Ps,`$&${c}`)}let h=!1,b,f=-1;for(b=0;b<s.length;++b){let v=s[b];if(v===" ")h=!0;else if(v===`
|
|
26
|
+
`)f=b;else break}let y=s.substring(0,f<b?f+1:b);if(y)s=s.substring(y.length),y=y.replace(/\n+/g,`$&${c}`);let _=(h?c?"2":"1":"")+d;if(e){if(_+=" "+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,C=Ct(n,!0);if(o!=="folded"&&t!==B.Scalar.BLOCK_FOLDED)C.onOverflow=()=>{T=!0};let E=te.foldFlowLines(`${y}${v}${m}`,c,te.FOLD_BLOCK,C);if(!T)return`>${_}
|
|
28
|
+
${c}${E}`}return s=s.replace(/\n+/g,`$&${c}`),`|${_}
|
|
29
|
+
${c}${y}${s}${m}`}function Ic(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
|
+
`)||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
|
+
`)?Ne(i,t):Rt(e,t,s,n);if(!a&&!p&&r!==B.Scalar.PLAIN&&i.includes(`
|
|
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=(h)=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:g}=t.doc.schema;if(g.some(u)||m?.some(u))return Ne(i,t)}return a?d:te.foldFlowLines(d,l,te.FOLD_FLOW,Ct(t,!1))}function Pc(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 Ic(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}Mc.stringifyString=Pc});var We=S(function(Wc){var qc=vt(),se=R(),Fc=Be(),$c=Ke();function Uc(e,t){let s=Object.assign({blockQuote:!0,commentString:Fc.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 Bc(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&&qc.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 Kc(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=Bc(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)?$c.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}`}Wc.createStringifyContext=Uc;Wc.stringify=Kc});var Wr=S(function(Vc){var G=R(),jr=k(),Kr=We(),He=Be();function Jc({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=G.isNode(e)&&e.comment||null;if(d){if(u)throw Error("With simple keys, key nodes cannot have comments");if(G.isCollection(e)||!G.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let m=!d&&(!e||u&&t==null&&!s.inFlow||G.isCollection(e)||(G.isScalar(e)?e.type===jr.Scalar.BLOCK_FOLDED||e.type===jr.Scalar.BLOCK_LITERAL:typeof e==="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!m&&(d||!i),indent:a+l});let g=!1,h=!1,b=Kr.stringify(e,s,()=>g=!0,()=>h=!0);if(!m&&!s.inFlow&&b.length>1024){if(d)throw Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(i||t==null){if(g&&n)n();return b===""?"?":m?`? ${b}`:b}}else if(i&&!d||t==null&&m){if(b=`? ${b}`,u&&!g)b+=He.lineComment(b,s.indent,c(u));else if(h&&r)r();return b}if(g)u=null;if(m){if(u)b+=He.lineComment(b,s.indent,c(u));b=`? ${b}
|
|
35
|
+
${a}:`}else if(b=`${b}:`,u)b+=He.lineComment(b,s.indent,c(u));let f,y,w;if(G.isNode(t))f=!!t.spaceBefore,y=t.commentBefore,w=t.comment;else if(f=!1,y=null,w=null,t&&typeof t==="object")t=o.createNode(t);if(s.implicitKey=!1,!m&&!u&&G.isScalar(t))s.indentAtStart=b.length+1;if(h=!1,!p&&l.length>=2&&!s.inFlow&&!m&&G.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)s.indent=s.indent.substring(2);let _=!1,v=Kr.stringify(t,s,()=>_=!0,()=>h=!0),T=" ";if(u||f||y){if(T=f?`
|
|
36
|
+
`:"",y){let C=c(y);T+=`
|
|
37
|
+
${He.indentComment(C,s.indent)}`}if(v===""&&!s.inFlow){if(T===`
|
|
38
|
+
`&&w)T=`
|
|
39
|
+
|
|
40
|
+
`}else T+=`
|
|
41
|
+
${s.indent}`}else if(!m&&G.isCollection(t)){let C=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&&(C==="&"||C==="!")){let I=v.indexOf(" ");if(C==="&"&&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(b+=T+v,s.inFlow){if(_&&n)n()}else if(w&&!_)b+=He.lineComment(b,s.indent,c(w));else if(h&&r)r();return b}Vc.stringifyPair=Jc});var Ms=S(function(Qc){var Hr=ot("process");function Gc(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)}Qc.debug=Gc;Qc.warn=zc});var kt=S(function(sd){var Lt=R(),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},td=(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}sd.addMergeToJSMap=Jr;sd.isMergeKey=td;sd.merge=Ot});var Fs=S(function(dd){var od=Ms(),Xr=kt(),ad=We(),Gr=R(),qs=ee();function ld(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=cd(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 cd(e,t,s){if(t===null)return"";if(typeof t!=="object")return String(t);if(Gr.isNode(e)&&s?.doc){let n=ad.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)+'..."';od.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)}dd.addPairToJSMap=ld});var ne=S(function(md){var zr=Ue(),fd=Wr(),hd=Fs(),It=R();function pd(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 hd.addPairToJSMap(t,s,this)}toString(e,t,s){return e?.doc?fd.stringifyPair(this,e,t,s):JSON.stringify(this)}}md.Pair=Pt;md.createPair=pd});var $s=S(function(Sd){var me=R(),Qr=We(),Mt=Be();function wd(e,t,s){return(t.inFlow??e.flow?_d:bd)(e,t,s)}function bd({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 g=0;g<t.length;++g){let h=t[g],b=null;if(me.isNode(h)){if(!d&&h.spaceBefore)u.push("");if(Dt(s,u,h.commentBefore,d),h.comment)b=h.comment}else if(me.isPair(h)){let y=me.isNode(h.key)?h.key:null;if(y){if(!d&&y.spaceBefore)u.push("");Dt(s,u,y.commentBefore,d)}}d=!1;let f=Qr.stringify(h,p,()=>b=null,()=>d=!0);if(b)f+=Mt.lineComment(f,i,c(b));if(d&&b)d=!1;u.push(n+f)}let m;if(u.length===0)m=r.start+r.end;else{m=u[0];for(let g=1;g<u.length;++g){let h=u[g];m+=h?`
|
|
45
|
+
${l}${h}`:`
|
|
46
|
+
`}}if(e){if(m+=`
|
|
47
|
+
`+Mt.indentComment(c(e),l),a)a()}else if(d&&o)o();return m}function _d({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 g=0;g<e.length;++g){let h=e[g],b=null;if(me.isNode(h)){if(h.spaceBefore)d.push("");if(Dt(t,d,h.commentBefore,!1),h.comment)b=h.comment}else if(me.isPair(h)){let y=me.isNode(h.key)?h.key:null;if(y){if(y.spaceBefore)d.push("");if(Dt(t,d,y.commentBefore,!1),y.comment)c=!0}let w=me.isNode(h.value)?h.value:null;if(w){if(w.comment)b=w.comment;if(w.commentBefore)c=!0}else if(h.value==null&&y?.comment)b=y.comment}if(b)c=!0;let f=Qr.stringify(h,l,()=>b=null);if(c||(c=d.length>p||f.includes(`
|
|
48
|
+
`)),g<e.length-1)f+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=d.reduce((y,w)=>y+w.length+2,2)+(f.length+2)>t.options.lineWidth);if(c)f+=","}if(b)f+=Mt.lineComment(f,n,a(b));d.push(f),p=d.length}let{start:u,end:m}=s;if(d.length===0)return u+m;else{if(!c){let g=d.reduce((h,b)=>h+b.length+2,2);c=t.options.lineWidth>0&&g>t.options.lineWidth}if(c){let g=u;for(let h of d)g+=h?`
|
|
49
|
+
${i}${r}${h}`:`
|
|
50
|
+
`;return`${g}
|
|
51
|
+
${r}${m}`}else return`${u}${o}${d.join(" ")}${o}${m}`}}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())}}Sd.stringifyCollection=wd});var ie=S(function(Cd){var Ed=$s(),Td=Fs(),Ad=At(),re=R(),qt=ne(),Rd=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 Ad.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)&&Rd.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)Td.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 Ed.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}Cd.YAMLMap=Zr;Cd.findPair=Ye});var xe=S(function(kd){var Od=R(),ei=ie(),Ld={collection:"map",default:!0,nodeClass:ei.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!Od.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,s)=>ei.YAMLMap.from(e,t,s)};kd.map=Ld});var oe=S(function($d){var Pd=Ue(),Md=$s(),Dd=At(),$t=R(),qd=k(),Fd=ee();class ti extends Dd.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)&&qd.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(Fd.toJS(r,String(n++),t));return s}toString(e,t,s){if(!e)return JSON.stringify(this);return Md.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(Pd.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}$d.YAMLSeq=ti});var Oe=S(function(Kd){var Bd=R(),si=oe(),jd={collection:"seq",default:!0,nodeClass:si.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Bd.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,s)=>si.YAMLSeq.from(e,t,s)};Kd.seq=jd});var Je=S(function(Jd){var Hd=Ke(),Yd={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),Hd.stringifyString(e,t,s,n)}};Jd.string=Yd});var Ut=S(function(Xd){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};Xd.nullTag=ri});var Us=S(function(Qd){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}};Qd.boolTag=ii});var Le=S(function(tu){function eu({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}tu.stringifyNumber=eu});var js=S(function(au){var nu=k(),Bs=Le(),ru={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},iu={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)}},ou={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 nu.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};au.float=ou;au.floatExp=iu;au.floatNaN=ru});var Ws=S(function(pu){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 uu={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")},fu={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},hu={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")};pu.int=fu;pu.intHex=hu;pu.intOct=uu});var li=S(function(Tu){var wu=xe(),bu=Ut(),_u=Oe(),Su=Je(),vu=Us(),Hs=js(),Ys=Ws(),Eu=[wu.map,_u.seq,Su.string,bu.nullTag,vu.boolTag,Ys.intOct,Ys.int,Ys.intHex,Hs.floatNaN,Hs.floatExp,Hs.float];Tu.schema=Eu});var di=S(function(ku){var Ru=k(),Cu=xe(),Nu=Oe();function ci(e){return typeof e==="bigint"||Number.isInteger(e)}var jt=({value:e})=>JSON.stringify(e),xu=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:jt},{identify:(e)=>e==null,createNode:()=>new Ru.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}],Ou={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Lu=[Cu.map,Nu.seq].concat(xu,Ou);ku.schema=Lu});var Vs=S(function(Du){var Ve=ot("buffer"),Js=k(),Pu=Ke(),Mu={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 Pu.stringifyString({comment:e,type:t,value:a},n,r,i)}};Du.binary=Mu});var Wt=S(function(Bu){var Kt=R(),Xs=ne(),Fu=k(),$u=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 Fu.Scalar(null));if(n.commentBefore)r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
|
|
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 $u.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 Uu={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ui,createNode:fi};Bu.createPairs=fi;Bu.pairs=Uu;Bu.resolvePairs=ui});var zs=S(function(Ju){var hi=R(),Gs=ee(),Xe=ie(),Hu=oe(),pi=Wt();class ge extends Hu.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 Yu={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)};Ju.YAMLOMap=ge;Ju.omap=Yu});var bi=S(function(Gu){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};Gu.falseTag=wi;Gu.trueTag=yi});var _i=S(function(nf){var Zu=k(),Qs=Le(),ef={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},tf={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)}},sf={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 Zu.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};nf.float=sf;nf.floatExp=tf;nf.floatNaN=ef});var vi=S(function(ff){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 lf={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")},cf={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")},df={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},uf={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")};ff.int=df;ff.intBin=lf;ff.intHex=uf;ff.intOct=cf});var en=S(function(wf){var Vt=R(),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 yf={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}};wf.YAMLSet=ye;wf.set=yf});var sn=S(function(Tf){var Sf=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 Ei(e){let{value:t}=e,s=(o)=>o;if(typeof t==="bigint")s=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Sf.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 vf={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:Ei},Ef={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:Ei},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$/,"")??""};Tf.floatTime=Ef;Tf.intTime=vf;Tf.timestamp=Ti});var Ri=S(function(Ff){var Nf=xe(),xf=Ut(),Of=Oe(),Lf=Je(),kf=Vs(),Ai=bi(),nn=_i(),Xt=vi(),If=kt(),Pf=zs(),Mf=Wt(),Df=en(),rn=sn(),qf=[Nf.map,Of.seq,Lf.string,xf.nullTag,Ai.trueTag,Ai.falseTag,Xt.intBin,Xt.intOct,Xt.int,Xt.intHex,nn.floatNaN,nn.floatExp,nn.float,kf.binary,If.merge,Pf.omap,Mf.pairs,Df.set,rn.intTime,rn.floatTime,rn.timestamp];Ff.schema=qf});var Di=S(function(Jf){var Oi=xe(),Uf=Ut(),Li=Oe(),Bf=Je(),jf=Us(),on=js(),an=Ws(),Kf=li(),Wf=di(),ki=Vs(),ze=kt(),Ii=zs(),Pi=Wt(),Ci=Ri(),Mi=en(),Gt=sn(),Ni=new Map([["core",Kf.schema],["failsafe",[Oi.map,Li.seq,Bf.string]],["json",Wf.schema],["yaml11",Ci.schema],["yaml-1.1",Ci.schema]]),xi={binary:ki.binary,bool:jf.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:Uf.nullTag,omap:Ii.omap,pairs:Pi.pairs,seq:Li.seq,set:Mi.set,timestamp:Gt.timestamp},Hf={"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 Yf(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},[])}Jf.coreKnownTags=Hf;Jf.getTags=Yf});var dn=S(function(eh){var ln=R(),Gf=xe(),zf=Oe(),Qf=Je(),zt=Di(),Zf=(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:Gf.map}),Object.defineProperty(this,ln.SCALAR,{value:Qf.string}),Object.defineProperty(this,ln.SEQ,{value:zf.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?Zf:null}clone(){let e=Object.create(cn.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}eh.Schema=cn});var qi=S(function(rh){var sh=R(),un=We(),Qe=Be();function nh(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(sh.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
|
+
`))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
|
+
`)+`
|
|
57
|
+
`}rh.stringifyDocument=nh});var Ze=S(function(hh){var oh=$e(),ke=At(),U=R(),ah=ne(),lh=ee(),ch=dn(),dh=qi(),fn=vt(),uh=Os(),fh=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 oh.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 h=(f)=>typeof f==="number"||f instanceof String||f instanceof Number,b=t.filter(h).map(String);if(b.length>0)t=t.concat(b);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"),m={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:u},g=fh.createNode(e,c,m);if(o&&U.isCollection(g))g.flow=!0;return d(),g}createPair(e,t,s={}){let n=this.createNode(e,null,s),r=this.createNode(t,null,s);return new ah.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 ch.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=lh.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"?uh.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 dh.stringifyDocument(this,e)}}function Ie(e){if(U.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}hh.Document=pn});var et=S(function(gh){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 mh=(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
|
+
`;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
|
+
|
|
60
|
+
${o}
|
|
61
|
+
${c}
|
|
62
|
+
`}};gh.YAMLError=Qt;gh.YAMLParseError=Fi;gh.YAMLWarning=$i;gh.prettifyError=mh});var tt=S(function(vh){function Sh(e,{flow:t,indicator:s,next:n,offset:r,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,d="",u="",m=!1,g=!1,h=null,b=null,f=null,y=null,w=null,_=null,v=null;for(let E of e){if(g){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");g=!1}if(h){if(c&&E.type!=="comment"&&E.type!=="newline")i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation");h=null}switch(E.type){case"space":if(!t&&(s!=="doc-start"||n?.type!=="flow-collection")&&E.source.includes("\t"))h=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(!_||s!=="seq-item-ind")l=!0}else u+=E.source;if(c=!0,m=!0,b||f)y=E;p=!0;break;case"anchor":if(b)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);b=E,v??(v=E.offset),c=!1,p=!1,g=!0;break;case"tag":{if(f)i(E,"MULTIPLE_TAGS","A node can have at most one tag");f=E,v??(v=E.offset),c=!1,p=!1,g=!0;break}case s:if(b||f)i(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`);if(_)i(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`);_=E,c=s==="seq-item-ind"||s==="explicit-key-ind",p=!1;break;case"comma":if(t){if(w)i(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);w=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],C=T?T.offset+T.source.length:r;if(g&&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(h&&(c&&h.indent<=o||n?.type==="block-map"||n?.type==="block-seq"))i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:w,found:_,spaceBefore:l,comment:d,hasNewline:m,anchor:b,tag:f,newlineAfterProp:y,end:C,start:v??C}}vh.resolveProps=Sh});var Zt=S(function(Th){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}}Th.containsNewline=mn});var gn=S(function(Nh){var Rh=Zt();function Ch(e,t,s){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&Rh.containsNewline(t))s(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Nh.flowIndentCheck=Ch});var yn=S(function(Lh){var Ui=R();function Oh(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))}Lh.mapIncludes=Oh});var Hi=S(function(qh){var Bi=ne(),Ih=ie(),ji=tt(),Ph=Zt(),Ki=gn(),Mh=yn(),Wi="All mapping items must start at the same column";function Dh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Ih.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:m,value:g}=p,h=ji.resolveProps(d,{indicator:"explicit-key-ind",next:u??m?.[0],offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0}),b=!h.found;if(b){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(!h.anchor&&!h.tag&&!m){if(c=h.end,h.comment)if(a.comment)a.comment+=`
|
|
64
|
+
`+h.comment;else a.comment=h.comment;continue}if(h.newlineAfterProp||Ph.containsNewline(u))r(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(h.found?.indent!==n.indent)r(l,"BAD_INDENT",Wi);s.atKey=!0;let f=h.end,y=u?e(s,u,h,r):t(s,f,d,null,h,r);if(s.schema.compat)Ki.flowIndentCheck(n.indent,u,r);if(s.atKey=!1,Mh.mapIncludes(s,a.items,y))r(f,"DUPLICATE_KEY","Map keys must be unique");let w=ji.resolveProps(m??[],{indicator:"map-value-ind",next:g,offset:y.range[2],onError:r,parentIndent:n.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=w.end,w.found){if(b){if(g?.type==="block-map"&&!w.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(s.options.strict&&h.start<w.found.offset-1024)r(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let _=g?e(s,g,w,r):t(s,l,m,null,w,r);if(s.schema.compat)Ki.flowIndentCheck(n.indent,g,r);l=_.range[2];let v=new Bi.Pair(y,_);if(s.options.keepSourceTokens)v.srcToken=p;a.items.push(v)}else{if(b)r(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(w.comment)if(y.comment)y.comment+=`
|
|
65
|
+
`+w.comment;else y.comment=w.comment;let _=new Bi.Pair(y);if(s.options.keepSourceTokens)_.srcToken=p;a.items.push(_)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,l,c??l],a}qh.resolveBlockMap=Dh});var Yi=S(function(Kh){var $h=oe(),Uh=tt(),Bh=gn();function jh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??$h.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=Uh.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 m=d?e(s,d,u,r):t(s,u.end,p,null,u,r);if(s.schema.compat)Bh.flowIndentCheck(n.indent,d,r);l=m.range[2],a.items.push(m)}return a.range=[n.offset,l,c??l],a}Kh.resolveBlockSeq=jh});var Pe=S(function(Yh){function Hh(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}}Yh.resolveEnd=Hh});var Xi=S(function(tp){var Vh=R(),Xh=ne(),Ji=ie(),Gh=oe(),zh=Pe(),Vi=tt(),Qh=Zt(),Zh=yn(),wn="Block collections are not allowed within flow collections",bn=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function ep({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:Gh.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 b=0;b<n.items.length;++b){let f=n.items[b],{start:y,key:w,sep:_,value:v}=f,T=Vi.resolveProps(y,{flow:a,indicator:"explicit-key-ind",next:w??_?.[0],offset:d,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!T.found){if(!T.anchor&&!T.tag&&!_&&!v){if(b===0&&T.comma)r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(b<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&&Qh.containsNewline(w))r(w,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===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 C="";e:for(let E of y)switch(E.type){case"comma":case"space":break;case"comment":C=E.source.substring(1);break e;default:break e}if(C){let E=c.items[c.items.length-1];if(Vh.isPair(E))E=E.value??E.key;if(E.comment)E.comment+=`
|
|
67
|
+
`+C;else E.comment=C;T.comment=T.comment.substring(C.length+1)}}}if(!o&&!_&&!T.found){let C=v?e(s,v,T,r):t(s,T.end,_,null,T,r);if(c.items.push(C),d=C.range[2],bn(v))r(C.range,"BLOCK_IN_FLOW",wn)}else{s.atKey=!0;let C=T.end,E=w?e(s,w,T,r):t(s,C,y,null,T,r);if(bn(w))r(E.range,"BLOCK_IN_FLOW",wn);s.atKey=!1;let x=Vi.resolveProps(_??[],{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(_)for(let I of _){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,_,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 Xh.Pair(E,z);if(s.options.keepSourceTokens)_e.srcToken=f;if(o){let I=c;if(Zh.mapIncludes(s,I.items,E))r(C,"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??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?"}":"]",[m,...g]=n.end,h=d;if(m?.source===u)h=m.offset+m.source.length;else{let b=a[0].toUpperCase()+a.substring(1),f=p?`${b} must end with a ${u}`:`${b} in block collection must be sufficiently indented and end with a ${u}`;if(r(d,p?"MISSING_CHAR":"BAD_INDENT",f),m&&m.source.length!==1)g.unshift(m)}if(g.length>0){let b=zh.resolveEnd(g,h,s.options.strict,r);if(b.comment)if(c.comment)c.comment+=`
|
|
69
|
+
`+b.comment;else c.comment=b.comment;c.range=[n.offset,h,b.offset]}else c.range=[n.offset,h,h];return c}tp.resolveFlowCollection=ep});var Gi=S(function(up){var np=R(),rp=k(),ip=ie(),op=oe(),ap=Hi(),lp=Yi(),cp=Xi();function _n(e,t,s,n,r,i){let o=s.type==="block-map"?ap.resolveBlockMap(e,t,s,n,i):s.type==="block-seq"?lp.resolveBlockSeq(e,t,s,n,i):cp.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 dp(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:m}=n,g=u&&i?u.offset>i.offset?u:i:u??i;if(g&&(!m||m.offset<g.offset))r(g,"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===ip.YAMLMap.tagName&&a==="map"||o===op.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=np.isNode(p)?p:new rp.Scalar(p);if(d.range=c.range,d.tag=o,l?.format)d.format=l.format;return d}up.composeCollection=dp});var vn=S(function(gp){var Sn=k();function hp(e,t,s){let n=t.offset,r=pp(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?mp(t.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let b=o[h][1];if(b===""||b==="\r")a=h;else break}if(a===0){let h=r.chomp==="+"&&o.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,o.length-1)):"",b=n+r.length;if(t.source)b+=t.source.length;return{value:h,type:i,comment:r.comment,range:[n,b,b]}}let l=t.indent+r.indent,c=t.offset+r.length,p=0;for(let h=0;h<a;++h){let[b,f]=o[h];if(f===""||f==="\r"){if(r.indent===0&&b.length>l)l=b.length}else{if(b.length<l)s(c+b.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(r.indent===0)l=b.length;if(p=h,l===0&&!e.atRoot)s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=b.length+f.length+1}for(let h=o.length-1;h>=a;--h)if(o[h][0].length>l)a=h+1;let d="",u="",m=!1;for(let h=0;h<p;++h)d+=o[h][0].slice(l)+`
|
|
71
|
+
`;for(let h=p;h<a;++h){let[b,f]=o[h];c+=b.length+f.length+1;let y=f[f.length-1]==="\r";if(y)f=f.slice(0,-1);if(f&&b.length<l){let _=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;s(c-f.length-(y?2:1),"BAD_INDENT",_),b=""}if(i===Sn.Scalar.BLOCK_LITERAL)d+=u+b.slice(l)+f,u=`
|
|
72
|
+
`;else if(b.length>l||f[0]==="\t"){if(u===" ")u=`
|
|
73
|
+
`;else if(!m&&u===`
|
|
74
|
+
`)u=`
|
|
75
|
+
|
|
76
|
+
`;d+=u+b.slice(l)+f,u=`
|
|
77
|
+
`,m=!0}else if(f==="")if(u===`
|
|
78
|
+
`)d+=`
|
|
79
|
+
`;else u=`
|
|
80
|
+
`;else d+=u+f,u=" ",m=!1}switch(r.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
|
|
81
|
+
`+o[h][0].slice(l);if(d[d.length-1]!==`
|
|
82
|
+
`)d+=`
|
|
83
|
+
`;break;default:d+=`
|
|
84
|
+
`}let g=n+r.length+t.source.length;return{value:d,type:i,comment:r.comment,range:[n,g,g]}}function pp({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 m=r[u];if(!a&&(m==="-"||m==="+"))a=m;else{let g=Number(m);if(!o&&g)o=g;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 m=t[u];switch(m.type){case"space":c=!0;case"newline":d+=m.source.length;break;case"comment":if(s&&!c)n(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");d+=m.source.length,p=m.source.substring(1);break;case"error":n(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let g=`Unexpected token in block scalar header: ${m.type}`;n(m,"UNEXPECTED_TOKEN",g);let h=m.source;if(h&&typeof h==="string")d+=h.length}}}return{mode:i,indent:o,chomp:a,comment:p,length:d}}function mp(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}gp.resolveBlockScalar=hp});var Tn=S(function(Rp){var En=k(),wp=Pe();function bp(e,t,s){let{offset:n,type:r,source:i,end:o}=e,a,l,c=(u,m,g)=>s(n+u,m,g);switch(r){case"scalar":a=En.Scalar.PLAIN,l=_p(i,c);break;case"single-quoted-scalar":a=En.Scalar.QUOTE_SINGLE,l=Sp(i,c);break;case"double-quoted-scalar":a=En.Scalar.QUOTE_DOUBLE,l=vp(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=wp.resolveEnd(o,p,t,s);return{value:l,type:a,comment:d.comment,range:[n,p,d.offset]}}function _p(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 Sp(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?
|
|
85
|
+
`,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
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
|
+
`)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 vp(e,t){let s="";for(let n=1;n<e.length-1;++n){let r=e[n];if(r==="\r"&&e[n+1]===`
|
|
89
|
+
`)continue;if(r===`
|
|
90
|
+
`){let{fold:i,offset:o}=Ep(e,n);s+=i,n=o}else if(r==="\\"){let i=e[++n],o=Tp[i];if(o)s+=o;else if(i===`
|
|
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+=Ap(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
|
+
`&&!(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 Ep(e,t){let s="",n=e[t+1];while(n===" "||n==="\t"||n===`
|
|
95
|
+
`||n==="\r"){if(n==="\r"&&e[t+2]!==`
|
|
96
|
+
`)break;if(n===`
|
|
97
|
+
`)s+=`
|
|
98
|
+
`;t+=1,n=e[t+1]}if(!s)s=" ";return{fold:s,offset:t}}var Tp={"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 Ap(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}}Rp.resolveFlowScalar=bp});var Zi=S(function(Ip){var we=R(),Qi=k(),Np=vn(),xp=Tn();function Op(e,t,s,n){let{value:r,type:i,comment:o,range:a}=t.type==="block-scalar"?Np.resolveBlockScalar(e,t,n):xp.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=Lp(e.schema,r,l,s,n);else if(t.type==="scalar")c=kp(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 Lp(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 kp({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}Ip.composeScalar=Op});var eo=S(function(Dp){function Mp(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}Dp.emptyScalarPosition=Mp});var no=S(function(Hp){var Fp=$e(),$p=R(),Up=Gi(),to=Zi(),Bp=Pe(),jp=eo(),Kp={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=Wp(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=Up.composeCollection(Kp,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&&(!$p.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=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 Wp({options:e},{offset:t,source:s,end:n},r){let i=new Fp.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=Bp.resolveEnd(n,o,e.strict,r);if(i.range=[t,o,a.offset],a.comment)i.comment=a.comment;return i}Hp.composeEmptyNode=An;Hp.composeNode=so});var io=S(function(Qp){var Vp=Ze(),ro=no(),Xp=Pe(),Gp=tt();function zp(e,t,{offset:s,start:n,value:r,end:i},o){let a=Object.assign({_directives:t},e),l=new Vp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=Gp.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=Xp.resolveEnd(i,d,!1,o);if(u.comment)l.comment=u.comment;return l.range=[s,d,u.offset],l}Qp.composeDoc=zp});var Rn=S(function(im){var em=ot("process"),tm=xs(),sm=Ze(),st=et(),oo=R(),nm=io(),rm=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?`
|
|
100
|
+
|
|
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 tm.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}
|
|
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(em.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=nm.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=rm.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 sm.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}}}im.Composer=lo});var fo=S(function(pm){var am=vn(),lm=Tn(),cm=et(),co=Ke();function dm(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 cm.YAMLParseError([a,a+1],i,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return lm.resolveFlowScalar(e,t,n);case"block-scalar":return am.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function um(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:`
|
|
107
|
+
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
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 fm(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">":hm(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 hm(e,t){let s=t.indexOf(`
|
|
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})}}}pm.createScalarToken=um;pm.resolveAsScalar=dm;pm.setScalarValue=fm});var ho=S(function(bm){var wm=(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}bm.stringify=wm});var go=S(function(vm){var Nn=Symbol("break visit"),Sm=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=Sm;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}vm.visit=be});var ss=S(function(Om){var xn=fo(),Tm=ho(),Am=go(),On="\uFEFF",Ln="\x02",kn="\x18",In="\x1F",Rm=(e)=>!!e&&("items"in e),Cm=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Nm(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 xm(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
|
+
`: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}Om.createScalarToken=xn.createScalarToken;Om.resolveAsScalar=xn.resolveAsScalar;Om.setScalarValue=xn.setScalarValue;Om.stringify=Tm.stringify;Om.visit=Am.visit;Om.BOM=On;Om.DOCUMENT=Ln;Om.FLOW_END=kn;Om.SCALAR=In;Om.isCollection=Rm;Om.isScalar=Cm;Om.prettyToken=Nm;Om.tokenType=xm});var Mn=S(function(Ym){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"),Wm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ns=new Set(",[]{}"),Hm=new Set(` ,[]{}
|
|
118
|
+
\r `),Pn=(e)=>!e||Hm.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===`
|
|
119
|
+
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
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
|
+
`||!n&&!this.atEnd)return e+s+1}return t===`
|
|
122
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&j(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
|
|
123
|
+
`,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===rt.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,s=e.indexOf("#");while(s!==-1){let r=e[s-1];if(r===" "||r==="\t"){t=s-1;break}else s=e.indexOf("#",s+1)}while(!0){let r=e[t-1];if(r===" "||r==="\t")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield rt.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&j(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!j(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&j(t)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Pn),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=s=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if(s!==-1&&s<this.indentNext&&n[0]!=="#"||s===0&&(n.startsWith("---")||n.startsWith("..."))&&j(n[3])){if(!(s===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield rt.FLOW_END,yield*this.parseLineStart()}let r=0;while(n[r]===",")r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),n[r]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Pn),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||j(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let r=0;while(this.buffer[t-1-r]==="\\")r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}let s=this.buffer.substring(0,t),n=s.indexOf(`
|
|
124
|
+
`,this.pos);if(n!==-1){while(n!==-1){let r=this.continueScalar(n+1);if(r===-1)break;n=s.indexOf(`
|
|
125
|
+
`,r)}if(n!==-1)t=n-(s[n-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>j(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let r=this.pos;s=this.buffer[r];++r)switch(s){case" ":t+=1;break;case`
|
|
126
|
+
`:e=r,t=0;break;case"\r":{let i=this.buffer[r+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
127
|
+
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(`
|
|
128
|
+
`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;s=this.buffer[n];while(s===" ")s=this.buffer[++n];if(s==="\t"){while(s==="\t"||s===" "||s==="\r"||s===`
|
|
129
|
+
`)s=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let r=e-1,i=this.buffer[r];if(i==="\r")i=this.buffer[--r];let o=r;while(i===" ")i=this.buffer[--r];if(i===`
|
|
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
|
+
`)s+=1,n=`
|
|
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(Wm.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===`
|
|
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)}}Ym.Lexer=wo});var Dn=S(function(Vm){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}}}}Vm.LineCounter=bo});var qn=S(function(Qm){var Gm=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 Eo(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 vo(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,Eo(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,Gm.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")vo(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(`
|
|
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(Eo(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);vo(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
|
+
`)+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()}}}Qm.Parser=To});var xo=S(function(ag){var Ao=Rn(),eg=Ze(),it=et(),tg=Ms(),sg=R(),ng=Dn(),Ro=qn();function Co(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new ng.LineCounter||null,prettyErrors:t}}function rg(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 ig(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)=>tg.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 og(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(sg.isDocument(e)&&!n)return e.toString(s);return new eg.Document(e,n,s).toString(s)}ag.parse=ig;ag.parseAllDocuments=rg;ag.parseDocument=No;ag.stringify=og});import{spawn as ry}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 ve}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 J 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 J(["-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 J(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 yy=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 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=(m,g,h)=>{let b=m.indexOf("=");if(b>=0)return[m.slice(b+1),g];let f=e[g+1];if(!f||f.startsWith("-"))throw Error(`${h} requires a value`);return[f,g+1]};for(let m=0;m<e.length;m+=1){let g=e[m];if(g==="--help"||g==="-h"){d=!0;continue}if(g==="--no-open"){a=!1;continue}if(g==="--open"){a=!0;continue}if(g==="--auth"){l=!0;continue}if(g==="--open-command"||g.startsWith("--open-command=")){[c,m]=u(g,m,"--open-command");continue}if(g==="--color-theme"||g.startsWith("--color-theme=")){[p,m]=u(g,m,"--color-theme");continue}if(g==="--from"||g.startsWith("--from=")){[s,m]=u(g,m,"--from");continue}if(g==="--to"||g.startsWith("--to=")){[n,m]=u(g,m,"--to");continue}if(g==="--repo"||g.startsWith("--repo=")){[r,m]=u(g,m,"--repo");continue}if(g==="--port"||g.startsWith("--port=")){let[h,b]=u(g,m,"--port"),f=Number(h);if(!Number.isInteger(f)||f<0||f>65535)throw Error("--port must be an integer between 0 and 65535");i=f,m=b;continue}if(g==="--watch-interval"||g.startsWith("--watch-interval=")){let[h,b]=u(g,m,"--watch-interval"),f=Number(h);if(!Number.isInteger(f)||f<100)throw Error("--watch-interval must be an integer of at least 100ms");o=f,m=b;continue}if(g.startsWith("-"))throw Error(`Unknown option: ${g}`);if(t){if(r)throw Error(`Unexpected argument: ${g}`);r=g}else t=g}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]
|
|
141
|
+
|
|
142
|
+
Compare a branch with a local Git ref and open the review in your browser.
|
|
143
|
+
|
|
144
|
+
RANGE main...HEAD (merge-base) or main..HEAD (direct)
|
|
145
|
+
--from REF --to REF Explicit direct comparison
|
|
146
|
+
--repo PATH Repository to review (defaults to the current directory)
|
|
147
|
+
--port PORT Port to use (0 asks the OS for a free port)
|
|
148
|
+
--auth Require a per-launch token for local API requests
|
|
149
|
+
--open-command CMD Shell command used to open files/locations
|
|
150
|
+
--color-theme PATH Load a JSON or YAML color theme
|
|
151
|
+
--no-open Do not launch the browser
|
|
152
|
+
`;function oa(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 aa(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 la(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 J)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 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=la(r);return aa(n).map((o)=>{let a=i.get(o.path)??(o.oldPath?i.get(o.oldPath):void 0),l=oa(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]=await Promise.all([this.resolveRef("HEAD"),this.getStatus(),this.getBranch()]),i=[t.fromSha,t.toSha,t.baseSha,t.mergeBaseSha??"",n].join("\x00"),o=this.state,a=!o||o.fingerprint!==i,l=a||!o?await this.getChangedFiles(t.baseSha,t.toSha):o.files,c=o?a?o.info.revision+1:o.info.revision:1,p=n.split("\x00"),d=[];for(let g=0;g<p.length;g+=1){let h=p[g];if(h==null||h.length<4)continue;let b=h.slice(0,2);if(d.push(h.slice(3)),b.includes("R")||b.includes("C"))g+=1}let u={root:this.root,name:ta(this.root),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:c,dirty:Boolean(n.trim()),uncommittedPaths:d};this.state={info:u,files:l,fingerprint:i};let m={changed:a,revision:c,repository:u,files:[...l]};if(e&&a)for(let g of this.listeners)g(m);return m}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 w of[["read-tree",n.baseSha],["add","-A","--",".",":(exclude).reviewme/**"]]){let _;try{_=Gn("git",w,{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=Qn(_),T,C,E;try{[T,C,E]=await Promise.all([fs(_.stdout),fs(_.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 J(w,{stdout:T,stderr:C,exitCode:E})}}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(w){if(r!=null)await ve(r,{recursive:!0,force:!0});throw Error(`Unable to start git: ${w instanceof Error?w.message:String(w)}`)}let l=Qn(a);if(l.catch(()=>{}),r!=null){let w=r;l.then(()=>ve(w,{recursive:!0,force:!0}),()=>ve(w,{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(),m=!1,g=!1,h=!1,b=()=>{if(h)return;if(h=!0,a.exitCode===null)a.kill("SIGTERM")},f=()=>{e?.removeEventListener("abort",y)},y=()=>{if(m||g)return;m=!0,b(),u.cancel().catch(()=>{}),f()};if(e?.aborted)y();else e?.addEventListener("abort",y,{once:!0});return new ReadableStream({start(w){if(m)w.close()},async pull(w){if(m||g)return;try{let _=await u.read();if(m||g)return;if(_.done){let v,T;try{[v,T]=await Promise.all([l,d])}catch(C){if(m||g)return;g=!0,f(),b(),w.error(C);return}if(m||g)return;if(g=!0,f(),v!==0)w.error(new J(o,{stdout:"",stderr:T,exitCode:v}));else w.close();return}w.enqueue(_.value)}catch(_){if(m||g)return;g=!0,f(),b(),w.error(_)}},async cancel(w){if(m)return;m=!0,f(),b();try{await u.cancel(w)}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 $a}from"node:http";import{dirname as Ua,extname as mr,isAbsolute as Ba,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 ca}from"node:crypto";import{mkdirSync as da,realpathSync as ua}from"node:fs";import{homedir as hs}from"node:os";import{dirname as fa,join as de,resolve as mt}from"node:path";import{DatabaseSync as ha}from"node:sqlite";var ps=2,pa="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 ma(){let e=process.env.REVIEWME_DB;if(e)return mt(e);return de(ga(pa),"reviews.sqlite")}function ga(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??ca,t.database)this.database=t.database,this.databasePath=t.filename??":memory:",this.ownsDatabase=!1;else{let s=t.filename??ma();if(s!==":memory:"&&s!=="")da(fa(mt(s)),{recursive:!0});this.database=new ha(s),this.databasePath=s,this.ownsDatabase=!0}this.configureAndMigrate()}close(){if(this.statements.clear(),this.ownsDatabase)this.database.close()}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
|
|
154
|
+
SET remote_origin = ?, updated_at = ?
|
|
155
|
+
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
|
|
156
|
+
(id, canonical_root, remote_origin, created_at, updated_at)
|
|
157
|
+
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
|
|
158
|
+
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 canonical_root = ?`,[t]);return s?gs(s):null}listRepositories(){return this.all(`SELECT id, canonical_root, remote_origin, created_at, updated_at
|
|
160
|
+
FROM repositories ORDER BY updated_at DESC, canonical_root ASC`).map(gs)}ensureSnapshot(e){let t=this.ensureRepository({canonicalRoot:e.canonicalRoot,remoteOrigin:e.remoteOrigin});ba(e.comparisonMode);let s=rr(e.baseSha,"base SHA"),n=rr(e.headSha,"head SHA"),r=Ee(e.baseRef),i=Ee(e.headRef),o=this.timestamp();this.run(`INSERT INTO review_snapshots
|
|
161
|
+
(id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at)
|
|
162
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
163
|
+
ON CONFLICT(repository_id, comparison_mode, base_sha, head_sha)
|
|
164
|
+
DO UPDATE SET
|
|
165
|
+
base_ref = excluded.base_ref,
|
|
166
|
+
head_ref = excluded.head_ref,
|
|
167
|
+
updated_at = excluded.updated_at`,[this.newId(),t.id,e.comparisonMode,r,i,s,n,o,o]);let a=this.findSnapshotByIdentity(t.id,e.comparisonMode,s,n);if(!a)throw new Te("Unable to create review snapshot");return a}upsertSnapshot(e){return this.ensureSnapshot(e)}getSnapshot(e){let t=this.get(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
|
|
168
|
+
FROM review_snapshots WHERE id = ?`,[e]);return t?ht(t):null}getSnapshotWithRepository(e){let t=this.get(`SELECT
|
|
169
|
+
s.id, s.repository_id, s.comparison_mode, s.base_ref, s.head_ref,
|
|
170
|
+
s.base_sha, s.head_sha, s.created_at, s.updated_at,
|
|
171
|
+
r.canonical_root AS repository_canonical_root,
|
|
172
|
+
r.remote_origin AS repository_remote_origin,
|
|
173
|
+
r.created_at AS repository_created_at,
|
|
174
|
+
r.updated_at AS repository_updated_at
|
|
175
|
+
FROM review_snapshots s
|
|
176
|
+
JOIN repositories r ON r.id = s.repository_id
|
|
177
|
+
WHERE s.id = ?`,[e]);if(!t)return null;return{...ht(t),repository:{id:t.repository_id,canonicalRoot:t.repository_canonical_root,remoteOrigin:t.repository_remote_origin,createdAt:t.repository_created_at,updatedAt:t.repository_updated_at}}}listSnapshots(e){return(e===void 0?this.all(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
|
|
178
|
+
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
|
|
179
|
+
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)
|
|
180
|
+
VALUES (?, ?, ?)
|
|
181
|
+
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
|
|
182
|
+
(id, thread_id, role, source, body, external_id, created_at, updated_at)
|
|
183
|
+
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
|
|
184
|
+
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
|
|
185
|
+
kind = ?, path = ?, side = ?, start_line = ?, end_line = ?,
|
|
186
|
+
context_text = ?, context_fingerprint = ?, updated_at = ?
|
|
187
|
+
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,
|
|
188
|
+
context_text, context_fingerprint, created_at, updated_at
|
|
189
|
+
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";_a(s);let r=this.newId(),i=this.timestamp();return this.run(`INSERT INTO messages
|
|
190
|
+
(id, thread_id, role, source, body, external_id, created_at, updated_at)
|
|
191
|
+
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
|
|
192
|
+
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
|
|
193
|
+
FROM messages WHERE thread_id = ? ORDER BY created_at ASC, id ASC`,[e]).map(ws)}upsertDraft(e){let t=this.normalizeAnchor(e.snapshotId,e.anchor),s=String(e.body??""),n=e.id??this.newId(),r=this.timestamp(),o=this.getDraft(n)?.createdAt??r;return this.run(`INSERT INTO drafts
|
|
194
|
+
(id, snapshot_id, anchor_kind, path, side, start_line, end_line,
|
|
195
|
+
context_text, context_fingerprint, body, created_at, updated_at)
|
|
196
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
197
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
198
|
+
snapshot_id = excluded.snapshot_id,
|
|
199
|
+
anchor_kind = excluded.anchor_kind,
|
|
200
|
+
path = excluded.path,
|
|
201
|
+
side = excluded.side,
|
|
202
|
+
start_line = excluded.start_line,
|
|
203
|
+
end_line = excluded.end_line,
|
|
204
|
+
context_text = excluded.context_text,
|
|
205
|
+
context_fingerprint = excluded.context_fingerprint,
|
|
206
|
+
body = excluded.body,
|
|
207
|
+
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,
|
|
208
|
+
context_text, context_fingerprint, body, created_at, updated_at
|
|
209
|
+
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
|
+
context_text, context_fingerprint, body, created_at, updated_at
|
|
211
|
+
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
|
+
(id, provider, external_thread_id, model, reasoning_effort, permission_mode,
|
|
213
|
+
status, status_message, last_event_at, created_at, updated_at)
|
|
214
|
+
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,
|
|
215
|
+
status, status_message, last_event_at, created_at, updated_at
|
|
216
|
+
FROM agent_sessions WHERE id = ?`,[e]);return t?pt(t):null}updateAgentSession(e,t){let s=this.getAgentSession(e);if(!s)throw new D("Agent session",e);let n=this.timestamp();return this.run(`UPDATE agent_sessions SET
|
|
217
|
+
external_thread_id = ?, model = ?, reasoning_effort = ?, permission_mode = ?,
|
|
218
|
+
status = ?, status_message = ?, last_event_at = ?, updated_at = ?
|
|
219
|
+
WHERE id = ?`,[t.externalThreadId===void 0?s.externalThreadId:t.externalThreadId,t.model===void 0?s.model:t.model,t.reasoningEffort===void 0?s.reasoningEffort:t.reasoningEffort,t.permissionMode===void 0?s.permissionMode:t.permissionMode,t.status===void 0?s.status:t.status,t.statusMessage===void 0?s.statusMessage:t.statusMessage,t.lastEventAt===void 0?s.lastEventAt:t.lastEventAt,n,e]),this.requireAgentSession(e)}linkAgentSession(e,t,s){this.requireThread(e),this.requireAgentSession(t);let n=this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
220
|
+
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]);if(n){if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new L("Agent-session order must be a non-negative integer");if(s!==void 0&&s!==n.session_order)this.run("UPDATE thread_agent_sessions SET session_order = ? WHERE thread_id = ? AND agent_session_id = ?",[s,e,t]);return bs(this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
221
|
+
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]))}let r=s??(this.get("SELECT MAX(session_order) + 1 AS next_order FROM thread_agent_sessions WHERE thread_id = ?",[e])?.next_order??0);if(!Number.isInteger(r)||r<0)throw new L("Agent-session order must be a non-negative integer");let i=this.timestamp();return this.run(`INSERT INTO thread_agent_sessions (thread_id, agent_session_id, session_order, created_at)
|
|
222
|
+
VALUES (?, ?, ?, ?)`,[e,t,r,i]),bs(this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
223
|
+
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]))}unlinkAgentSession(e,t){return this.requireThread(e),this.run("DELETE FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?",[e,t]).changes>0}listAgentSessionsForThread(e){return this.requireThread(e),this.all(`SELECT s.id, s.provider, s.external_thread_id, s.model, s.reasoning_effort,
|
|
224
|
+
s.permission_mode, s.status, s.status_message, s.last_event_at,
|
|
225
|
+
s.created_at, s.updated_at
|
|
226
|
+
FROM agent_sessions s
|
|
227
|
+
JOIN thread_agent_sessions ts ON ts.agent_session_id = s.id
|
|
228
|
+
WHERE ts.thread_id = ?
|
|
229
|
+
ORDER BY ts.session_order ASC, s.created_at ASC`,[e]).map(pt)}listThreadAgentLinks(e){return this.requireThread(e),this.all(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
230
|
+
FROM thread_agent_sessions WHERE thread_id = ? ORDER BY session_order ASC`,[e]).map(bs)}addAgentContext(e){this.requireAgentSession(e.agentSessionId);let t=this.normalizeAnchor(e.snapshotId,e.anchor);if(e.sourceThreadId!=null){if(this.requireThread(e.sourceThreadId).snapshot_id!==e.snapshotId)throw new L("Agent context and source thread must belong to the same snapshot")}let s=this.newId(),n=this.timestamp();return this.run(`INSERT INTO agent_session_contexts
|
|
231
|
+
(id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
232
|
+
start_line, end_line, context_text, context_fingerprint, prompt, created_at)
|
|
233
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[s,e.agentSessionId,e.snapshotId,e.sourceThreadId??null,t.kind,t.path,t.side,t.startLine,t.endLine,t.contextText??null,t.contextFingerprint??null,ft(e.prompt),n]),this.requireAgentContext(s)}listAgentConversations(e){return this.requireSnapshot(e),this.all(`SELECT DISTINCT s.id, s.provider, s.external_thread_id, s.model, s.reasoning_effort,
|
|
234
|
+
s.permission_mode, s.status, s.status_message, s.last_event_at, s.created_at, s.updated_at
|
|
235
|
+
FROM agent_sessions s
|
|
236
|
+
JOIN agent_session_contexts c ON c.agent_session_id = s.id
|
|
237
|
+
WHERE c.snapshot_id = ? ORDER BY s.updated_at DESC`,[e]).map(pt).map((s)=>({...s,contexts:this.all(`SELECT id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
238
|
+
start_line, end_line, context_text, context_fingerprint, prompt, created_at
|
|
239
|
+
FROM agent_session_contexts
|
|
240
|
+
WHERE agent_session_id = ? AND snapshot_id = ?
|
|
241
|
+
ORDER BY created_at ASC`,[s.id,e]).map(lr)}))}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 ya)this.run(s);this.run("PRAGMA user_version = 1")}if(t<2){for(let s of wa)this.run(s);this.run(`INSERT OR IGNORE INTO agent_session_contexts
|
|
242
|
+
(id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
243
|
+
start_line, end_line, context_text, context_fingerprint, prompt, created_at)
|
|
244
|
+
SELECT lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' ||
|
|
245
|
+
substr(lower(hex(randomblob(2))), 2) || '-a' || substr(lower(hex(randomblob(2))), 2) || '-' ||
|
|
246
|
+
lower(hex(randomblob(6))), ts.agent_session_id, t.snapshot_id, t.id, a.kind, a.path,
|
|
247
|
+
a.side, a.start_line, a.end_line, a.context_text, a.context_fingerprint,
|
|
248
|
+
COALESCE(m.body, 'Review this code'), ts.created_at
|
|
249
|
+
FROM thread_agent_sessions ts
|
|
250
|
+
JOIN threads t ON t.id = ts.thread_id
|
|
251
|
+
JOIN anchors a ON a.thread_id = t.id AND a.anchor_order = 0
|
|
252
|
+
LEFT JOIN messages m ON m.thread_id = t.id AND m.source = 'local'`),this.run("PRAGMA user_version = 2")}})}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
|
|
253
|
+
FROM review_snapshots
|
|
254
|
+
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:Ee(t.contextText),contextFingerprint:Ee(t.contextFingerprint)}}insertAnchor(e,t,s,n,r){this.run(`INSERT INTO anchors
|
|
255
|
+
(id, thread_id, anchor_order, kind, path, side, start_line, end_line,
|
|
256
|
+
context_text, context_fingerprint, created_at, updated_at)
|
|
257
|
+
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,
|
|
258
|
+
start_line, end_line, context_text, context_fingerprint, prompt, created_at
|
|
259
|
+
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,
|
|
260
|
+
context_text, context_fingerprint, created_at, updated_at
|
|
261
|
+
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
|
|
262
|
+
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,
|
|
263
|
+
s.permission_mode, s.status, s.status_message, s.last_event_at,
|
|
264
|
+
s.created_at, s.updated_at
|
|
265
|
+
FROM agent_sessions s
|
|
266
|
+
JOIN thread_agent_sessions ts ON ts.agent_session_id = s.id
|
|
267
|
+
WHERE ts.thread_id = ?
|
|
268
|
+
ORDER BY ts.session_order ASC, s.created_at ASC`,[e.id]).map(pt);return{...Sa(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,
|
|
269
|
+
context_text, context_fingerprint, created_at, updated_at
|
|
270
|
+
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,
|
|
271
|
+
a.context_text, a.context_fingerprint, a.created_at, a.updated_at,
|
|
272
|
+
t.snapshot_id
|
|
273
|
+
FROM anchors a JOIN threads t ON t.id = a.thread_id
|
|
274
|
+
WHERE a.id = ?`,[e])}requireMessage(e){let t=this.get(`SELECT id, thread_id, role, source, body, external_id, created_at, updated_at
|
|
275
|
+
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 ya=[`CREATE TABLE repositories (
|
|
276
|
+
id TEXT PRIMARY KEY,
|
|
277
|
+
canonical_root TEXT NOT NULL UNIQUE,
|
|
278
|
+
remote_origin TEXT,
|
|
279
|
+
created_at TEXT NOT NULL,
|
|
280
|
+
updated_at TEXT NOT NULL
|
|
281
|
+
)`,`CREATE TABLE review_snapshots (
|
|
282
|
+
id TEXT PRIMARY KEY,
|
|
283
|
+
repository_id TEXT NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
|
|
284
|
+
comparison_mode TEXT NOT NULL CHECK (comparison_mode IN ('merge-base', 'direct')),
|
|
285
|
+
base_ref TEXT,
|
|
286
|
+
head_ref TEXT,
|
|
287
|
+
base_sha TEXT NOT NULL,
|
|
288
|
+
head_sha TEXT NOT NULL,
|
|
289
|
+
created_at TEXT NOT NULL,
|
|
290
|
+
updated_at TEXT NOT NULL,
|
|
291
|
+
UNIQUE(repository_id, comparison_mode, base_sha, head_sha)
|
|
292
|
+
)`,`CREATE TABLE reviewed_files (
|
|
293
|
+
snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
|
|
294
|
+
path TEXT NOT NULL,
|
|
295
|
+
reviewed_at TEXT NOT NULL,
|
|
296
|
+
PRIMARY KEY(snapshot_id, path)
|
|
297
|
+
)`,`CREATE TABLE threads (
|
|
298
|
+
id TEXT PRIMARY KEY,
|
|
299
|
+
snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
|
|
300
|
+
title TEXT,
|
|
301
|
+
created_at TEXT NOT NULL,
|
|
302
|
+
updated_at TEXT NOT NULL
|
|
303
|
+
)`,`CREATE TABLE anchors (
|
|
304
|
+
id TEXT PRIMARY KEY,
|
|
305
|
+
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
306
|
+
anchor_order INTEGER NOT NULL CHECK (anchor_order >= 0),
|
|
307
|
+
kind TEXT NOT NULL CHECK (kind IN ('file', 'diff_range')),
|
|
308
|
+
path TEXT NOT NULL,
|
|
309
|
+
side TEXT CHECK (side IN ('old', 'new') OR side IS NULL),
|
|
310
|
+
start_line INTEGER,
|
|
311
|
+
end_line INTEGER,
|
|
312
|
+
context_text TEXT,
|
|
313
|
+
context_fingerprint TEXT,
|
|
314
|
+
created_at TEXT NOT NULL,
|
|
315
|
+
updated_at TEXT NOT NULL,
|
|
316
|
+
UNIQUE(thread_id, anchor_order),
|
|
317
|
+
CHECK (
|
|
318
|
+
(kind = 'file' AND side IS NULL AND start_line IS NULL AND end_line IS NULL)
|
|
319
|
+
OR
|
|
320
|
+
(kind = 'diff_range' AND side IS NOT NULL AND start_line IS NOT NULL AND end_line IS NOT NULL
|
|
321
|
+
AND start_line > 0 AND end_line >= start_line)
|
|
322
|
+
)
|
|
323
|
+
)`,`CREATE TABLE messages (
|
|
324
|
+
id TEXT PRIMARY KEY,
|
|
325
|
+
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
326
|
+
role TEXT NOT NULL CHECK (role IN ('user', 'assistant', 'system')),
|
|
327
|
+
source TEXT NOT NULL,
|
|
328
|
+
body TEXT NOT NULL,
|
|
329
|
+
external_id TEXT,
|
|
330
|
+
created_at TEXT NOT NULL,
|
|
331
|
+
updated_at TEXT NOT NULL
|
|
332
|
+
)`,`CREATE TABLE drafts (
|
|
333
|
+
id TEXT PRIMARY KEY,
|
|
334
|
+
snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
|
|
335
|
+
anchor_kind TEXT NOT NULL CHECK (anchor_kind IN ('file', 'diff_range')),
|
|
336
|
+
path TEXT NOT NULL,
|
|
337
|
+
side TEXT CHECK (side IN ('old', 'new') OR side IS NULL),
|
|
338
|
+
start_line INTEGER,
|
|
339
|
+
end_line INTEGER,
|
|
340
|
+
context_text TEXT,
|
|
341
|
+
context_fingerprint TEXT,
|
|
342
|
+
body TEXT NOT NULL,
|
|
343
|
+
created_at TEXT NOT NULL,
|
|
344
|
+
updated_at TEXT NOT NULL,
|
|
345
|
+
CHECK (
|
|
346
|
+
(anchor_kind = 'file' AND side IS NULL AND start_line IS NULL AND end_line IS NULL)
|
|
347
|
+
OR
|
|
348
|
+
(anchor_kind = 'diff_range' AND side IS NOT NULL AND start_line IS NOT NULL AND end_line IS NOT NULL
|
|
349
|
+
AND start_line > 0 AND end_line >= start_line)
|
|
350
|
+
)
|
|
351
|
+
)`,`CREATE TABLE agent_sessions (
|
|
352
|
+
id TEXT PRIMARY KEY,
|
|
353
|
+
provider TEXT NOT NULL,
|
|
354
|
+
external_thread_id TEXT,
|
|
355
|
+
model TEXT,
|
|
356
|
+
reasoning_effort TEXT,
|
|
357
|
+
permission_mode TEXT NOT NULL DEFAULT 'read-only',
|
|
358
|
+
status TEXT NOT NULL DEFAULT 'starting',
|
|
359
|
+
status_message TEXT,
|
|
360
|
+
last_event_at TEXT,
|
|
361
|
+
created_at TEXT NOT NULL,
|
|
362
|
+
updated_at TEXT NOT NULL,
|
|
363
|
+
UNIQUE(provider, external_thread_id)
|
|
364
|
+
)`,`CREATE TABLE thread_agent_sessions (
|
|
365
|
+
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
|
|
366
|
+
agent_session_id TEXT NOT NULL REFERENCES agent_sessions(id) ON DELETE CASCADE,
|
|
367
|
+
session_order INTEGER NOT NULL CHECK (session_order >= 0),
|
|
368
|
+
created_at TEXT NOT NULL,
|
|
369
|
+
PRIMARY KEY(thread_id, agent_session_id),
|
|
370
|
+
UNIQUE(thread_id, session_order)
|
|
371
|
+
)`,"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)"],wa=[`CREATE TABLE IF NOT EXISTS agent_session_contexts (
|
|
372
|
+
id TEXT PRIMARY KEY,
|
|
373
|
+
agent_session_id TEXT NOT NULL REFERENCES agent_sessions(id) ON DELETE CASCADE,
|
|
374
|
+
snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
|
|
375
|
+
source_thread_id TEXT REFERENCES threads(id) ON DELETE SET NULL,
|
|
376
|
+
anchor_kind TEXT NOT NULL CHECK (anchor_kind IN ('file', 'diff_range')),
|
|
377
|
+
path TEXT NOT NULL,
|
|
378
|
+
side TEXT CHECK (side IN ('old', 'new') OR side IS NULL),
|
|
379
|
+
start_line INTEGER,
|
|
380
|
+
end_line INTEGER,
|
|
381
|
+
context_text TEXT,
|
|
382
|
+
context_fingerprint TEXT,
|
|
383
|
+
prompt TEXT NOT NULL,
|
|
384
|
+
created_at TEXT NOT NULL,
|
|
385
|
+
CHECK ((anchor_kind = 'file' AND side IS NULL AND start_line IS NULL AND end_line IS NULL)
|
|
386
|
+
OR (anchor_kind = 'diff_range' AND side IS NOT NULL AND start_line > 0 AND end_line >= start_line))
|
|
387
|
+
)`,"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)"];function nr(e){if(typeof e!=="string"||!e.trim())throw new L("Repository root is required");try{return ua(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 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 ir(e){return e!==null&&Number.isSafeInteger(e)&&e>0}function ba(e){if(e!=="merge-base"&&e!=="direct")throw new L("Comparison mode must be `merge-base` or `direct`")}function _a(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 Sa(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 va}from"node:child_process";import{Readable as cr}from"node:stream";var Ea="codex",Ta="reviewme",Aa="0.1.0",Ra=8388608,Ca=8192,Na=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 xa(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 Oa(e){return{write(t){let s=typeof t==="string"?Buffer.from(t):Buffer.from(t);return e.write(s)?s.byteLength:xa(e,s.byteLength)},end(){e.end()}}}function La(e){let[t,...s]=e;if(!t)throw Error("Codex command cannot be empty");let n=va(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:Oa(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 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 ka(e){return/auth|login|log in|unauthori[sz]ed|credential|token/i.test(e)}function Ia(e,t){if(ka(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 Pa(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(`
|
|
388
|
+
`)}function Ma(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=Pa(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 Da(e){return e??"read-only"}function dr(e){if(Da(e)!=="read-only")throw new O("unsupported","Codex sessions are read-only in this version of ReviewMe",{retryable:!1})}function qa(e){if(e==="completed"||e==="interrupted"||e==="failed"||e==="inProgress")return e==="inProgress"?"in-progress":e;return typeof e==="string"?e:"completed"}function Fa(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??Ea,this.clientName=e.clientName??Ta,this.clientVersion=e.clientVersion??Aa,this.processFactory=e.processFactory??La}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(Fa(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;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=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),Na))])}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:Ma(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)}
|
|
389
|
+
`);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>Ra){this.handleConnectionClosed(e,"Codex protocol line exceeded the maximum size");return}let a=n.indexOf(`
|
|
390
|
+
`);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(`
|
|
391
|
+
`)}}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(-Ca)}}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(Ia(`${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:qa(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 Ka=`<!doctype html>
|
|
392
|
+
<html lang="en"><head><meta charset="utf-8"><title>ReviewMe</title></head>
|
|
393
|
+
<body><main><h1>ReviewMe</h1><p>Frontend assets have not been built yet.</p></main></body></html>`,Wa={".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 Es,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=$a((m,g)=>{Ha(m,g,(h)=>Ya(h,t,s,r,i,o,a,e.colorTheme))});if(c.requestTimeout=0,c.headersTimeout=60000,c.keepAliveTimeout=5000,await new Promise((m,g)=>{let h=(b)=>g(b);c.once("error",h),c.listen(l,"127.0.0.1",()=>{c.off("error",h),m()})}),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 Ha(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 Ya(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 Ja(e,t,s,n,r,l,a)}catch(c){return Za(c)}}return Qa(l,o)}async function Ja(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/repository"||a==="/api/metadata/repository"))return A({repository:await t.getRepositoryMetadata()});if(e.method==="GET"&&a==="/api/metadata"){let[f,y]=await Promise.all([t.getRepositoryMetadata(),t.listFiles()]);return A({repository:f,files:y.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 f=await t.getRepositoryMetadata();return A({revision:f.revision,dirty:f.dirty})}if((e.method==="GET"||e.method==="POST")&&a==="/api/refresh")return A(await t.refresh());if(e.method==="GET"&&a==="/api/events")return Ga(t);if(e.method==="GET"&&a==="/api/patch-stream"){let f=i.searchParams.get("from"),y=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null!==(y===null))throw new N("invalid_comparison","from and to must be provided together");if(w!==null&&w!=="merge-base"&&w!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return new Response(await t.streamPatch(e.signal,f===null||y===null?void 0:{from:f,to:y,mode:w==="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 f=i.searchParams.get("from"),y=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null!==(y===null))throw new N("invalid_comparison","from and to must be provided together");if(w!==null&&w!=="merge-base"&&w!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return A(await t.listCommits(f===null||y===null?void 0:{from:f,to:y,mode:w==="direct"?"direct":"merge-base"}))}if(e.method==="GET"&&a==="/api/review"){let f=await Q(t,s);return A({snapshotId:f.id,reviewedPaths:s.listReviewedFiles(f.id).map((y)=>y.path),threads:s.listThreads(f.id).map(Ts),drafts:s.listDrafts(f.id).map(gr),agentConversations:s.listAgentConversations(f.id).map(yr)})}if(e.method==="GET"&&a==="/api/agents/codex/models"){let f=await n.listModels(),y=f.find((w)=>w.isDefault)??f[0];return A({models:f,defaultModel:y?.id,defaultEffort:y?.defaultReasoningEffort??void 0,efforts:y?.supportedReasoningEfforts??[]})}let l=Z(a,"/api/review/threads/","/agent-sessions");if(e.method==="POST"&&l!==void 0){let f=await Q(t,s),y=s.getThread(l);if(y==null||y.snapshotId!==f.id)throw new N("not_found","Review thread not found",404);let w=await V(e),_=await n.startThread({cwd:t.repositoryRoot,model:typeof w?.model==="string"?w.model:void 0,reasoningEffort:typeof w?.effort==="string"?w.effort:void 0,permissionMode:"read-only"}),v=s.createAgentSession({provider:"codex",externalThreadId:_.session.externalThreadId,model:_.session.model,reasoningEffort:_.session.reasoningEffort,permissionMode:"read-only",status:"ready"});s.linkAgentSession(l,v.id);let T=y.anchors[0],C=y.messages.find((E)=>E.source==="local");if(T!=null)s.addAgentContext({agentSessionId:v.id,snapshotId:f.id,sourceThreadId:y.id,anchor:T,prompt:C?.body??"Review this code"});return r.markProviderReady(_.session.externalThreadId),A(br(v,_.history),201)}if(e.method==="POST"&&a==="/api/agent-conversations"){let f=await Q(t,s),y=await V(e);if(!y||typeof y.prompt!=="string"||typeof y.anchor!=="object"||y.anchor==null)throw new N("invalid_request","Agent prompt and anchor are required");let w=gt(y.anchor),_=await n.startThread({cwd:t.repositoryRoot,model:typeof y.model==="string"?y.model:void 0,reasoningEffort:typeof y.effort==="string"?y.effort:void 0,permissionMode:"read-only"}),v=s.createAgentSession({provider:"codex",externalThreadId:_.session.externalThreadId,model:_.session.model,reasoningEffort:_.session.reasoningEffort,permissionMode:"read-only",status:"ready"}),T=s.addAgentContext({agentSessionId:v.id,snapshotId:f.id,anchor:w,prompt:y.prompt});return r.markProviderReady(_.session.externalThreadId),A(yr({...v,contexts:[T]}),201)}let c=Z(a,"/api/agent-sessions/","/messages");if(e.method==="POST"&&c!==void 0){let f=await V(e),y=typeof f?.body==="string"?f.body:typeof f?.message==="string"?f.message:"";if(y.trim()==="")throw new N("invalid_request","Agent message is required");let w=s.getAgentSession(c);if(w==null||w.externalThreadId==null)throw new N("not_found","Agent session not found",404);if(!r.isProviderReady(w.externalThreadId)){let v=await n.resumeThread({externalThreadId:w.externalThreadId,cwd:t.repositoryRoot,model:w.model??void 0,reasoningEffort:w.reasoningEffort??void 0,permissionMode:"read-only"});r.markProviderReady(v.session.externalThreadId)}let _=await n.sendMessage(w.externalThreadId,{text:y,reasoningEffort:w.reasoningEffort??void 0});return s.updateAgentSession(w.id,{status:"running",lastEventAt:new Date().toISOString()}),r.pump(w.id,_.events,(v)=>{if(v.type==="completed"||v.type==="stopped")s.updateAgentSession(w.id,{status:"ready",lastEventAt:new Date().toISOString()});else if(v.type==="error")s.updateAgentSession(w.id,{status:"error",statusMessage:v.message,lastEventAt:new Date().toISOString()})}),A({status:"running",turnId:_.turnId})}let p=Z(a,"/api/agent-sessions/","/history");if(e.method==="GET"&&p!==void 0){let f=s.getAgentSession(p);if(f==null||f.externalThreadId==null)throw new N("not_found","Agent session not found",404);let y;try{y=await n.resumeThread({externalThreadId:f.externalThreadId,cwd:t.repositoryRoot,model:f.model??void 0,reasoningEffort:f.reasoningEffort??void 0,permissionMode:"read-only"})}catch(w){if(w instanceof Error&&w.message.includes("rollout")&&w.message.includes("is empty"))return A({history:[]});throw w}return r.markProviderReady(y.session.externalThreadId),A({history:y.history})}let d=Z(a,"/api/agent-sessions/","/events");if(e.method==="GET"&&d!==void 0){if(s.getAgentSession(d)==null)throw new N("not_found","Agent session not found",404);return r.response(d)}let u=Z(a,"/api/agent-sessions/","/stop");if(e.method==="POST"&&u!==void 0){let f=s.getAgentSession(u);if(f==null||f.externalThreadId==null)throw new N("not_found","Agent session not found",404);return await n.stop(f.externalThreadId),s.updateAgentSession(f.id,{status:"stopped",lastEventAt:new Date().toISOString()}),A({stopped:!0})}if(e.method==="PUT"&&a==="/api/review/files/reviewed"){let f=await Q(t,s),y=await V(e);if(!Array.isArray(y?.paths)||y.paths.some((_)=>typeof _!=="string"))throw new N("invalid_request","Request body must include an array of file paths");let w=y.reviewed!==!1;return s.setFilesReviewed(f.id,y.paths,w),A({reviewed:w,paths:y.paths})}let m=Z(a,"/api/review/files/","/reviewed");if(e.method==="PUT"&&m!==void 0){let f=await Q(t,s),y=await V(e),w=typeof y?.path==="string"?y.path:m,_=y?.reviewed!==!1;return A({reviewed:s.setFileReviewed(f.id,w,_)})}if(e.method==="POST"&&a==="/api/review/threads"){let f=await Q(t,s),y=await V(e);if(!y||typeof y.body!=="string")throw new N("invalid_request","Comment body is required");return A(Ts(s.createThread({snapshotId:f.id,anchor:gt(y.anchor),body:y.body})),201)}let g=Z(a,"/api/review/threads/");if((e.method==="PATCH"||e.method==="DELETE")&&g!==void 0){let f=await Q(t,s),y=s.getThread(g);if(y==null||y.snapshotId!==f.id)throw new N("not_found","Review thread not found",404);if(e.method==="DELETE")return s.deleteThread(g),A({deleted:!0});let w=await V(e);if(!w||typeof w.body!=="string")throw new N("invalid_request","Comment body is required");let _=y.messages.find((v)=>v.source==="local");if(_==null)s.createMessage({threadId:g,body:w.body});else s.updateMessage(_.id,w.body);if(w.anchor!==void 0&&y.anchors[0]!=null)s.updateAnchor(y.anchors[0].id,gt(w.anchor));return A(Ts(s.getThread(g)))}let h=Z(a,"/api/review/drafts/");if((e.method==="PUT"||e.method==="DELETE")&&h!==void 0){let f=await Q(t,s);if(e.method==="DELETE"){let w=s.getDraft(h);if(w!=null&&w.snapshotId!==f.id)throw new N("not_found","Review draft not found",404);return s.deleteDraft(h),A({deleted:!0})}let y=await V(e);if(!y||typeof y.body!=="string")throw new N("invalid_request","Draft body is required");return A(gr(s.upsertDraft({id:h,snapshotId:f.id,anchor:gt(y.anchor),body:y.body})))}let b=Xa(a);if(e.method==="GET"&&b!==void 0){if(i.searchParams.get("hydrate")==="true"){let f=i.searchParams.get("from"),y=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null||y===null||w!=="merge-base"&&w!=="direct")throw new N("invalid_comparison","from, to, and a valid mode are required");return A(await t.getFileContents({comparison:{from:f,to:y,mode:w},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(b))}if(e.method==="GET"&&(a==="/api/diff"||a==="/api/patch")){let f=i.searchParams.get("fileId")??i.searchParams.get("path");if(!f)throw new N("missing_file","A fileId or path query parameter is required");return A(await t.getFileDiff(f))}if(e.method==="POST"&&(a==="/api/open"||a==="/api/open-working-file")){let f=await V(e);if(!f||typeof f.path!=="string")throw new N("invalid_request","Request body must include a repository-relative path");if(f.line!==void 0&&typeof f.line!=="number"||f.column!==void 0&&typeof f.column!=="number"||f.side!==void 0&&f.side!=="old"&&f.side!=="new")throw new N("invalid_request","line and column must be numbers");let y={path:f.path,...f.line===void 0?{}:{line:f.line},...f.column===void 0?{}:{column:f.column},...f.side===void 0?{}:{side:f.side}};return A(await t.openWorkingFile(y))}throw new N("not_found","API endpoint not found",404)}async function Q(e,t){let s=await e.getRepositoryMetadata();return t.ensureSnapshot({canonicalRoot:s.root,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 Z(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,Va(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
|
|
394
|
+
data: ${JSON.stringify(t)}
|
|
395
|
+
|
|
396
|
+
`))}catch{}}}function Va(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 Xa(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 V(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 Ga(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}
|
|
397
|
+
data: ${JSON.stringify(l)}
|
|
398
|
+
|
|
399
|
+
`))}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(Ua(ja(import.meta.url)),"../frontend");return hr(As(n,"index.html"))?n:void 0}let s=Ba(t)?t:Rs(process.cwd(),t);return hr(As(s,"index.html"))?s:void 0}async function Qa(e,t){if(!t)return new Response(Ka,{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":Wa[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 Za(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 J)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 Zg,stat as ey}from"node:fs/promises";import{extname as ty,resolve as sy}from"node:path";var fg=Rn(),hg=Ze(),pg=dn(),Fn=et(),mg=$e(),le=R(),gg=ne(),yg=k(),wg=ie(),bg=oe(),pb=ss(),_g=Mn(),Sg=Dn(),vg=qn(),os=xo(),Oo=qe();var Eg=fg.Composer,Tg=hg.Document,Ag=pg.Schema,Rg=Fn.YAMLError,Cg=Fn.YAMLParseError,Ng=Fn.YAMLWarning,xg=mg.Alias,Og=le.isAlias,Lg=le.isCollection,kg=le.isDocument,Ig=le.isMap,Pg=le.isNode,Mg=le.isPair,Dg=le.isScalar,qg=le.isSeq,Fg=gg.Pair,$g=yg.Scalar,Ug=wg.YAMLMap,Bg=bg.YAMLSeq;var jg=_g.Lexer,Kg=Sg.LineCounter,Wg=vg.Parser,$n=os.parse,Hg=os.parseAllDocuments,Yg=os.parseDocument,Jg=os.stringify,Vg=Oo.visit,Xg=Oo.visitAsync;var Lo=["background","sidebar","panel","panelRaised","border","borderStrong","text","muted","subtle","accent","added","deleted","info"],Gg=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 Qg(e){if(!Un(e))throw Error("theme must be an object");for(let n of Object.keys(e))if(!Gg.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 Qg(s)}var as=(e,t,s,n={light:"github-light",dark:"github-dark"})=>({name:e,version:1,light:t,dark:s,syntax:n}),yb={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 ny=262144;async function Po(e){let t=sy(process.cwd(),e);try{let s=await ey(t);if(!s.isFile())throw Error("path is not a file");if(s.size>ny)throw Error("file exceeds the 256 KB limit");let n=ty(t).toLowerCase();if(n!==".json"&&n!==".yaml"&&n!==".yml")throw Error("file extension must be .json, .yaml, or .yml");return Io(await Zg(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 iy(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 iy(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=ry(n,r,{stdio:"ignore",detached:!0});i.once("error",()=>{}),i.unref()}catch{}}var Do=await Mo();if(Do!==0)process.exitCode=Do;
|
|
400
|
+
|
|
401
|
+
//# debugId=F1098CB2E9C0B35F64756E2164756E21
|
|
402
|
+
//# sourceMappingURL=main.js.map
|