-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcli.js
More file actions
167 lines (162 loc) · 207 KB
/
cli.js
File metadata and controls
167 lines (162 loc) · 207 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env node
var Nc=Object.create;var Fr=Object.defineProperty;var Cc=Object.getOwnPropertyDescriptor;var Ic=Object.getOwnPropertyNames;var Oc=Object.getPrototypeOf,kc=Object.prototype.hasOwnProperty;var A=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var xc=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ic(e))!kc.call(s,n)&&n!==t&&Fr(s,n,{get:()=>e[n],enumerable:!(i=Cc(e,n))||i.enumerable});return s};var pe=(s,e,t)=>(t=s!=null?Nc(Oc(s)):{},xc(e||!s||!s.__esModule?Fr(t,"default",{value:s,enumerable:!0}):t,s));var L=A(q=>{"use strict";var Cs=Symbol.for("yaml.alias"),uo=Symbol.for("yaml.document"),Wt=Symbol.for("yaml.map"),fo=Symbol.for("yaml.pair"),Is=Symbol.for("yaml.scalar"),Ht=Symbol.for("yaml.seq"),z=Symbol.for("yaml.node.type"),Kc=s=>!!s&&typeof s=="object"&&s[z]===Cs,Vc=s=>!!s&&typeof s=="object"&&s[z]===uo,Wc=s=>!!s&&typeof s=="object"&&s[z]===Wt,Hc=s=>!!s&&typeof s=="object"&&s[z]===fo,ho=s=>!!s&&typeof s=="object"&&s[z]===Is,Yc=s=>!!s&&typeof s=="object"&&s[z]===Ht;function po(s){if(s&&typeof s=="object")switch(s[z]){case Wt:case Ht:return!0}return!1}function Gc(s){if(s&&typeof s=="object")switch(s[z]){case Cs:case Wt:case Is:case Ht:return!0}return!1}var Jc=s=>(ho(s)||po(s))&&!!s.anchor;q.ALIAS=Cs;q.DOC=uo;q.MAP=Wt;q.NODE_TYPE=z;q.PAIR=fo;q.SCALAR=Is;q.SEQ=Ht;q.hasAnchor=Jc;q.isAlias=Kc;q.isCollection=po;q.isDocument=Vc;q.isMap=Wc;q.isNode=Gc;q.isPair=Hc;q.isScalar=ho;q.isSeq=Yc});var Je=A(Os=>{"use strict";var k=L(),R=Symbol("break visit"),go=Symbol("skip children"),G=Symbol("remove node");function Yt(s,e){let t=mo(e);k.isDocument(s)?Ce(null,s.contents,t,Object.freeze([s]))===G&&(s.contents=null):Ce(null,s,t,Object.freeze([]))}Yt.BREAK=R;Yt.SKIP=go;Yt.REMOVE=G;function Ce(s,e,t,i){let n=yo(s,e,t,i);if(k.isNode(n)||k.isPair(n))return bo(s,i,n),Ce(s,n,t,i);if(typeof n!="symbol"){if(k.isCollection(e)){i=Object.freeze(i.concat(e));for(let r=0;r<e.items.length;++r){let o=Ce(r,e.items[r],t,i);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===G&&(e.items.splice(r,1),r-=1)}}}else if(k.isPair(e)){i=Object.freeze(i.concat(e));let r=Ce("key",e.key,t,i);if(r===R)return R;r===G&&(e.key=null);let o=Ce("value",e.value,t,i);if(o===R)return R;o===G&&(e.value=null)}}return n}async function Gt(s,e){let t=mo(e);k.isDocument(s)?await Ie(null,s.contents,t,Object.freeze([s]))===G&&(s.contents=null):await Ie(null,s,t,Object.freeze([]))}Gt.BREAK=R;Gt.SKIP=go;Gt.REMOVE=G;async function Ie(s,e,t,i){let n=await yo(s,e,t,i);if(k.isNode(n)||k.isPair(n))return bo(s,i,n),Ie(s,n,t,i);if(typeof n!="symbol"){if(k.isCollection(e)){i=Object.freeze(i.concat(e));for(let r=0;r<e.items.length;++r){let o=await Ie(r,e.items[r],t,i);if(typeof o=="number")r=o-1;else{if(o===R)return R;o===G&&(e.items.splice(r,1),r-=1)}}}else if(k.isPair(e)){i=Object.freeze(i.concat(e));let r=await Ie("key",e.key,t,i);if(r===R)return R;r===G&&(e.key=null);let o=await Ie("value",e.value,t,i);if(o===R)return R;o===G&&(e.value=null)}}return n}function mo(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function yo(s,e,t,i){if(typeof t=="function")return t(s,e,i);if(k.isMap(e))return t.Map?.(s,e,i);if(k.isSeq(e))return t.Seq?.(s,e,i);if(k.isPair(e))return t.Pair?.(s,e,i);if(k.isScalar(e))return t.Scalar?.(s,e,i);if(k.isAlias(e))return t.Alias?.(s,e,i)}function bo(s,e,t){let i=e[e.length-1];if(k.isCollection(i))i.items[s]=t;else if(k.isPair(i))s==="key"?i.key=t:i.value=t;else if(k.isDocument(i))i.contents=t;else{let n=k.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}Os.visit=Yt;Os.visitAsync=Gt});var ks=A(So=>{"use strict";var wo=L(),Qc=Je(),Xc={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},zc=s=>s.replace(/[!,[\]{}]/g,e=>Xc[e]),Qe=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!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 o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return t(String(o)),null}return i==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,i]of Object.entries(this.tags))if(e.startsWith(i))return t+zc(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&wo.isNode(e.contents)){let r={};Qc.visit(e.contents,(o,a)=>{wo.isNode(a)&&a.tag&&(r[a.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
`)}};Qe.defaultYaml={explicit:!1,version:"1.2"};Qe.defaultTags={"!!":"tag:yaml.org,2002:"};So.Directives=Qe});var Jt=A(Xe=>{"use strict";var vo=L(),Zc=Je();function eu(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function Eo(s){let e=new Set;return Zc.visit(s,{Value(t,i){i.anchor&&e.add(i.anchor)}}),e}function Fo(s,e){for(let t=1;;++t){let i=`${s}${t}`;if(!e.has(i))return i}}function tu(s,e){let t=[],i=new Map,n=null;return{onAnchor:r=>{t.push(r),n||(n=Eo(s));let o=Fo(e,n);return n.add(o),o},setAnchors:()=>{for(let r of t){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(vo.isScalar(o.node)||vo.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:i}}Xe.anchorIsValid=eu;Xe.anchorNames=Eo;Xe.createNodeAnchors=tu;Xe.findNewAnchor=Fo});var xs=A(Ao=>{"use strict";function ze(s,e,t,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let o=i[n],a=ze(s,i,String(n),o);a===void 0?delete i[n]:a!==o&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),o=ze(s,i,n,r);o===void 0?i.delete(n):o!==r&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let r=ze(s,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let o=ze(s,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return s.call(e,t,i)}Ao.applyReviver=ze});var se=A(Do=>{"use strict";var iu=L();function Po(s,e,t){if(Array.isArray(s))return s.map((i,n)=>Po(i,String(n),t));if(s&&typeof s.toJSON=="function"){if(!t||!iu.hasAnchor(s))return s.toJSON(e,t);let i={aliasCount:0,count:1,res:void 0};t.anchors.set(s,i),t.onCreate=r=>{i.res=r,delete t.onCreate};let n=s.toJSON(e,t);return t.onCreate&&t.onCreate(n),n}return typeof s=="bigint"&&!t?.keep?Number(s):s}Do.toJS=Po});var Qt=A(Lo=>{"use strict";var su=xs(),To=L(),nu=se(),qs=class{constructor(e){Object.defineProperty(this,To.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:i,onAnchor:n,reviver:r}={}){if(!To.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=nu.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?su.applyReviver(r,{"":a},"",a):a}};Lo.NodeBase=qs});var Ze=A(No=>{"use strict";var ru=Jt(),_o=Je(),Xt=L(),ou=Qt(),au=se(),Ms=class extends ou.NodeBase{constructor(e){super(Xt.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return _o.visit(e,{Node:(i,n)=>{if(n===this)return _o.visit.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=t,o=this.resolve(n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(o);if(a||(au.toJS(o,null,t),a=i.get(o)),!a||a.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=zt(n,o,i)),a.count*a.aliasCount>r)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,i){let n=`*${this.source}`;if(e){if(ru.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 new Error(r)}if(e.implicitKey)return`${n} `}return n}};function zt(s,e,t){if(Xt.isAlias(e)){let i=e.resolve(s),n=t&&i&&t.get(i);return n?n.count*n.aliasCount:0}else if(Xt.isCollection(e)){let i=0;for(let n of e.items){let r=zt(s,n,t);r>i&&(i=r)}return i}else if(Xt.isPair(e)){let i=zt(s,e.key,t),n=zt(s,e.value,t);return Math.max(i,n)}return 1}No.Alias=Ms});var O=A(Rs=>{"use strict";var lu=L(),cu=Qt(),uu=se(),fu=s=>!s||typeof s!="function"&&typeof s!="object",ne=class extends cu.NodeBase{constructor(e){super(lu.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:uu.toJS(this.value,e,t)}toString(){return String(this.value)}};ne.BLOCK_FOLDED="BLOCK_FOLDED";ne.BLOCK_LITERAL="BLOCK_LITERAL";ne.PLAIN="PLAIN";ne.QUOTE_DOUBLE="QUOTE_DOUBLE";ne.QUOTE_SINGLE="QUOTE_SINGLE";Rs.Scalar=ne;Rs.isScalarValue=fu});var et=A(Io=>{"use strict";var hu=Ze(),be=L(),Co=O(),pu="tag:yaml.org,2002:";function du(s,e,t){if(e){let i=t.filter(r=>r.tag===e),n=i.find(r=>!r.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return t.find(i=>i.identify?.(s)&&!i.format)}function gu(s,e,t){if(be.isDocument(s)&&(s=s.contents),be.isNode(s))return s;if(be.isPair(s)){let u=t.schema[be.MAP].createNode?.(t.schema,null,t);return u.items.push(s),u}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:a}=t,l;if(i&&s&&typeof s=="object"){if(l=a.get(s),l)return l.anchor||(l.anchor=n(s)),new hu.Alias(l.anchor);l={anchor:null,node:null},a.set(s,l)}e?.startsWith("!!")&&(e=pu+e.slice(2));let c=du(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let u=new Co.Scalar(s);return l&&(l.node=u),u}c=s instanceof Map?o[be.MAP]:Symbol.iterator in Object(s)?o[be.SEQ]:o[be.MAP]}r&&(r(c),delete t.onTagObj);let f=c?.createNode?c.createNode(t.schema,s,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,s,t):new Co.Scalar(s);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}Io.createNode=gu});var ei=A(Zt=>{"use strict";var mu=et(),J=L(),yu=Qt();function Bs(s,e,t){let i=t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return mu.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var Oo=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,$s=class extends yu.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));return e&&(t.schema=e),t.items=t.items.map(i=>J.isNode(i)||J.isPair(i)?i.clone(e):i),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Oo(e))this.add(t);else{let[i,...n]=e,r=this.get(i,!0);if(J.isCollection(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(i,Bs(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[t,...i]=e;if(i.length===0)return this.delete(t);let n=this.get(t,!0);if(J.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${i}`)}getIn(e,t){let[i,...n]=e,r=this.get(i,!0);return n.length===0?!t&&J.isScalar(r)?r.value:r:J.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!J.isPair(t))return!1;let i=t.value;return i==null||e&&J.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[t,...i]=e;if(i.length===0)return this.has(t);let n=this.get(t,!0);return J.isCollection(n)?n.hasIn(i):!1}setIn(e,t){let[i,...n]=e;if(n.length===0)this.set(i,t);else{let r=this.get(i,!0);if(J.isCollection(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(i,Bs(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Zt.Collection=$s;Zt.collectionFromPath=Bs;Zt.isEmptyPath=Oo});var tt=A(ti=>{"use strict";var bu=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function js(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var wu=(s,e,t)=>s.endsWith(`
`)?js(t,e):t.includes(`
`)?`
`+js(t,e):(s.endsWith(" ")?"":" ")+t;ti.indentComment=js;ti.lineComment=wu;ti.stringifyComment=bu});var xo=A(it=>{"use strict";var Su="flow",Us="block",ii="quoted";function vu(s,e,t="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return s;n<r&&(r=0);let l=Math.max(1+r,1+n-e.length);if(s.length<=l)return s;let c=[],f={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,r)?c.push(0):u=n-i);let h,y,S=!1,d=-1,p=-1,m=-1;t===Us&&(d=ko(s,d,e.length),d!==-1&&(u=d+l));for(let E;E=s[d+=1];){if(t===ii&&E==="\\"){switch(p=d,s[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}m=d}if(E===`
`)t===Us&&(d=ko(s,d,e.length)),u=d+e.length+l,h=void 0;else{if(E===" "&&y&&y!==" "&&y!==`
`&&y!==" "){let b=s[d+1];b&&b!==" "&&b!==`
`&&b!==" "&&(h=d)}if(d>=u)if(h)c.push(h),u=h+l,h=void 0;else if(t===ii){for(;y===" "||y===" ";)y=E,E=s[d+=1],S=!0;let b=d>m+1?d-2:p-1;if(f[b])return s;c.push(b),f[b]=!0,u=b+l,h=void 0}else S=!0}y=E}if(S&&a&&a(),c.length===0)return s;o&&o();let g=s.slice(0,c[0]);for(let E=0;E<c.length;++E){let b=c[E],w=c[E+1]||s.length;b===0?g=`
${e}${s.slice(0,w)}`:(t===ii&&f[b]&&(g+=`${s[b]}\\`),g+=`
${e}${s.slice(b+1,w)}`)}return g}function ko(s,e,t){let i=e,n=e+1,r=s[n];for(;r===" "||r===" ";)if(e<n+t)r=s[++e];else{do r=s[++e];while(r&&r!==`
`);i=e,n=e+1,r=s[n]}return i}it.FOLD_BLOCK=Us;it.FOLD_FLOW=Su;it.FOLD_QUOTED=ii;it.foldFlowLines=vu});var nt=A(qo=>{"use strict";var W=O(),re=xo(),ni=(s,e)=>({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),ri=s=>/^(%|---|\.\.\.)/m.test(s);function Eu(s,e,t){if(!e||e<0)return!1;let i=e-t,n=s.length;if(n<=i)return!1;for(let r=0,o=0;r<n;++r)if(s[r]===`
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function st(s,e){let t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(ri(s)?" ":""),o="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(o+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{o+=t.slice(a,l);let f=t.substr(l+2,4);switch(f){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:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||t[l+2]==='"'||t.length<n)l+=1;else{for(o+=t.slice(a,l)+`
`;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)o+=`
`,l+=2;o+=r,t[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+t.slice(a):t,i?o:re.foldFlowLines(o,r,re.FOLD_QUOTED,ni(e,!1))}function Ks(s,e){if(e.options.singleQuote===!1||e.implicitKey&&s.includes(`
`)||/[ \t]\n|\n[ \t]/.test(s))return st(s,e);let t=e.indent||(ri(s)?" ":""),i="'"+s.replace(/'/g,"''").replace(/\n+/g,`$&
${t}`)+"'";return e.implicitKey?i:re.foldFlowLines(i,t,re.FOLD_FLOW,ni(e,!1))}function Oe(s,e){let{singleQuote:t}=e.options,i;if(t===!1)i=st;else{let n=s.includes('"'),r=s.includes("'");n&&!r?i=Ks:r&&!n?i=st:i=t?Ks:st}return i(s,e)}var Vs;try{Vs=new RegExp(`(^|(?<!
))
+(?!
|$)`,"g")}catch{Vs=/\n+(?!\n|$)/g}function si({comment:s,type:e,value:t},i,n,r){let{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(t)||/^\s*$/.test(t))return Oe(t,i);let c=i.indent||(i.forceBlockIndent||ri(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===W.Scalar.BLOCK_FOLDED?!1:e===W.Scalar.BLOCK_LITERAL?!0:!Eu(t,l,c.length);if(!t)return f?`|
`:`>
`;let u,h;for(h=t.length;h>0;--h){let w=t[h-1];if(w!==`
`&&w!==" "&&w!==" ")break}let y=t.substring(h),S=y.indexOf(`
`);S===-1?u="-":t===y||S!==y.length-1?(u="+",r&&r()):u="",y&&(t=t.slice(0,-y.length),y[y.length-1]===`
`&&(y=y.slice(0,-1)),y=y.replace(Vs,`$&${c}`));let d=!1,p,m=-1;for(p=0;p<t.length;++p){let w=t[p];if(w===" ")d=!0;else if(w===`
`)m=p;else break}let g=t.substring(0,m<p?m+1:p);g&&(t=t.substring(g.length),g=g.replace(/\n+/g,`$&${c}`));let b=(d?c?"2":"1":"")+u;if(s&&(b+=" "+a(s.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let w=t.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),v=!1,P=ni(i,!0);o!=="folded"&&e!==W.Scalar.BLOCK_FOLDED&&(P.onOverflow=()=>{v=!0});let F=re.foldFlowLines(`${g}${w}${y}`,c,re.FOLD_BLOCK,P);if(!v)return`>${b}
${c}${F}`}return t=t.replace(/\n+/g,`$&${c}`),`|${b}
${c}${g}${t}${y}`}function Fu(s,e,t,i){let{type:n,value:r}=s,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&r.includes(`
`)||f&&/[[\]{},]/.test(r))return Oe(r,e);if(!r||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
`)?Oe(r,e):si(s,e,t,i);if(!a&&!f&&n!==W.Scalar.PLAIN&&r.includes(`
`))return si(s,e,t,i);if(ri(r)){if(l==="")return e.forceBlockIndent=!0,si(s,e,t,i);if(a&&l===c)return Oe(r,e)}let u=r.replace(/\n+/g,`$&
${l}`);if(o){let h=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:y,tags:S}=e.doc.schema;if(S.some(h)||y?.some(h))return Oe(r,e)}return a?u:re.foldFlowLines(u,l,re.FOLD_FLOW,ni(e,!1))}function Au(s,e,t,i){let{implicitKey:n,inFlow:r}=e,o=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)}),{type:a}=s;a!==W.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=W.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case W.Scalar.BLOCK_FOLDED:case W.Scalar.BLOCK_LITERAL:return n||r?Oe(o.value,e):si(o,e,t,i);case W.Scalar.QUOTE_DOUBLE:return st(o.value,e);case W.Scalar.QUOTE_SINGLE:return Ks(o.value,e);case W.Scalar.PLAIN:return Fu(o,e,t,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,h=n&&f||u;if(c=l(h),c===null)throw new Error(`Unsupported default string type ${h}`)}return c}qo.stringifyString=Au});var rt=A(Ws=>{"use strict";var Pu=Jt(),oe=L(),Du=tt(),Tu=nt();function Lu(s,e){let t=Object.assign({blockQuote:!0,commentString:Du.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,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e),i;switch(t.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:i,options:t}}function _u(s,e){if(e.tag){let n=s.filter(r=>r.tag===e.tag);if(n.length>0)return n.find(r=>r.format===e.format)??n[0]}let t,i;if(oe.isScalar(e)){i=e.value;let n=s.filter(r=>r.identify?.(i));if(n.length>1){let r=n.filter(o=>o.test);r.length>0&&(n=r)}t=n.find(r=>r.format===e.format)??n.find(r=>!r.format)}else i=e,t=s.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!t){let n=i?.constructor?.name??typeof i;throw new Error(`Tag not resolved for ${n} value`)}return t}function Nu(s,e,{anchors:t,doc:i}){if(!i.directives)return"";let n=[],r=(oe.isScalar(s)||oe.isCollection(s))&&s.anchor;r&&Pu.anchorIsValid(r)&&(t.add(r),n.push(`&${r}`));let o=s.tag?s.tag:e.default?null:e.tag;return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Cu(s,e,t,i){if(oe.isPair(s))return s.toString(e,t,i);if(oe.isAlias(s)){if(e.doc.directives)return s.toString(e);if(e.resolvedAliases?.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let n,r=oe.isNode(s)?s:e.doc.createNode(s,{onTagObj:l=>n=l});n||(n=_u(e.doc.schema.tags,r));let o=Nu(r,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(r,e,t,i):oe.isScalar(r)?Tu.stringifyString(r,e,t,i):r.toString(e,t,i);return o?oe.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
${e.indent}${a}`:a}Ws.createStringifyContext=Lu;Ws.stringify=Cu});var $o=A(Bo=>{"use strict";var Z=L(),Mo=O(),Ro=rt(),ot=tt();function Iu({key:s,value:e},t,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,h=Z.isNode(s)&&s.comment||null;if(u){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(Z.isCollection(s)||!Z.isNode(s)&&typeof s=="object"){let P="With simple keys, collection cannot be used as a key value";throw new Error(P)}}let y=!u&&(!s||h&&e==null&&!t.inFlow||Z.isCollection(s)||(Z.isScalar(s)?s.type===Mo.Scalar.BLOCK_FOLDED||s.type===Mo.Scalar.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!y&&(u||!r),indent:a+l});let S=!1,d=!1,p=Ro.stringify(s,t,()=>S=!0,()=>d=!0);if(!y&&!t.inFlow&&p.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");y=!0}if(t.inFlow){if(r||e==null)return S&&i&&i(),p===""?"?":y?`? ${p}`:p}else if(r&&!u||e==null&&y)return p=`? ${p}`,h&&!S?p+=ot.lineComment(p,t.indent,c(h)):d&&n&&n(),p;S&&(h=null),y?(h&&(p+=ot.lineComment(p,t.indent,c(h))),p=`? ${p}
${a}:`):(p=`${p}:`,h&&(p+=ot.lineComment(p,t.indent,c(h))));let m,g,E;Z.isNode(e)?(m=!!e.spaceBefore,g=e.commentBefore,E=e.comment):(m=!1,g=null,E=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!y&&!h&&Z.isScalar(e)&&(t.indentAtStart=p.length+1),d=!1,!f&&l.length>=2&&!t.inFlow&&!y&&Z.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let b=!1,w=Ro.stringify(e,t,()=>b=!0,()=>d=!0),v=" ";if(h||m||g){if(v=m?`
`:"",g){let P=c(g);v+=`
${ot.indentComment(P,t.indent)}`}w===""&&!t.inFlow?v===`
`&&(v=`
`):v+=`
${t.indent}`}else if(!y&&Z.isCollection(e)){let P=w[0],F=w.indexOf(`
`),N=F!==-1,M=t.inFlow??e.flow??e.items.length===0;if(N||!M){let ee=!1;if(N&&(P==="&"||P==="!")){let I=w.indexOf(" ");P==="&"&&I!==-1&&I<F&&w[I+1]==="!"&&(I=w.indexOf(" ",I+1)),(I===-1||F<I)&&(ee=!0)}ee||(v=`
${t.indent}`)}}else(w===""||w[0]===`
`)&&(v="");return p+=v+w,t.inFlow?b&&i&&i():E&&!b?p+=ot.lineComment(p,t.indent,c(E)):d&&n&&n(),p}Bo.stringifyPair=Iu});var Ys=A(Hs=>{"use strict";var jo=require("node:process");function Ou(s,...e){s==="debug"&&console.log(...e)}function ku(s,e){(s==="debug"||s==="warn")&&(typeof jo.emitWarning=="function"?jo.emitWarning(e):console.warn(e))}Hs.debug=Ou;Hs.warn=ku});var ci=A(li=>{"use strict";var at=L(),Uo=O(),oi="<<",ai={identify:s=>s===oi||typeof s=="symbol"&&s.description===oi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Uo.Scalar(Symbol(oi)),{addToJSMap:Ko}),stringify:()=>oi},xu=(s,e)=>(ai.identify(e)||at.isScalar(e)&&(!e.type||e.type===Uo.Scalar.PLAIN)&&ai.identify(e.value))&&s?.doc.schema.tags.some(t=>t.tag===ai.tag&&t.default);function Ko(s,e,t){if(t=s&&at.isAlias(t)?t.resolve(s.doc):t,at.isSeq(t))for(let i of t.items)Gs(s,e,i);else if(Array.isArray(t))for(let i of t)Gs(s,e,i);else Gs(s,e,t)}function Gs(s,e,t){let i=s&&at.isAlias(t)?t.resolve(s.doc):t;if(!at.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,s,Map);for(let[r,o]of n)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}li.addMergeToJSMap=Ko;li.isMergeKey=xu;li.merge=ai});var Qs=A(Ho=>{"use strict";var qu=Ys(),Vo=ci(),Mu=rt(),Wo=L(),Js=se();function Ru(s,e,{key:t,value:i}){if(Wo.isNode(t)&&t.addToJSMap)t.addToJSMap(s,e,i);else if(Vo.isMergeKey(s,t))Vo.addMergeToJSMap(s,e,i);else{let n=Js.toJS(t,"",s);if(e instanceof Map)e.set(n,Js.toJS(i,n,s));else if(e instanceof Set)e.add(n);else{let r=Bu(t,n,s),o=Js.toJS(i,r,s);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}function Bu(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Wo.isNode(s)&&t?.doc){let i=Mu.createStringifyContext(t.doc,{});i.anchors=new Set;for(let r of t.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=s.toString(i);if(!t.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+'..."'),qu.warn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return n}return JSON.stringify(e)}Ho.addPairToJSMap=Ru});var ae=A(Xs=>{"use strict";var Yo=et(),$u=$o(),ju=Qs(),ui=L();function Uu(s,e,t){let i=Yo.createNode(s,void 0,t),n=Yo.createNode(e,void 0,t);return new fi(i,n)}var fi=class s{constructor(e,t=null){Object.defineProperty(this,ui.NODE_TYPE,{value:ui.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:i}=this;return ui.isNode(t)&&(t=t.clone(e)),ui.isNode(i)&&(i=i.clone(e)),new s(t,i)}toJSON(e,t){let i=t?.mapAsMap?new Map:{};return ju.addPairToJSMap(t,i,this)}toString(e,t,i){return e?.doc?$u.stringifyPair(this,e,t,i):JSON.stringify(this)}};Xs.Pair=fi;Xs.createPair=Uu});var zs=A(Jo=>{"use strict";var we=L(),Go=rt(),hi=tt();function Ku(s,e,t){return(e.inFlow??s.flow?Wu:Vu)(s,e,t)}function Vu({comment:s,items:e},t,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=t,f=Object.assign({},t,{indent:r,type:null}),u=!1,h=[];for(let S=0;S<e.length;++S){let d=e[S],p=null;if(we.isNode(d))!u&&d.spaceBefore&&h.push(""),pi(t,h,d.commentBefore,u),d.comment&&(p=d.comment);else if(we.isPair(d)){let g=we.isNode(d.key)?d.key:null;g&&(!u&&g.spaceBefore&&h.push(""),pi(t,h,g.commentBefore,u))}u=!1;let m=Go.stringify(d,f,()=>p=null,()=>u=!0);p&&(m+=hi.lineComment(m,r,c(p))),u&&p&&(u=!1),h.push(i+m)}let y;if(h.length===0)y=n.start+n.end;else{y=h[0];for(let S=1;S<h.length;++S){let d=h[S];y+=d?`
${l}${d}`:`
`}}return s?(y+=`
`+hi.indentComment(c(s),l),a&&a()):u&&o&&o(),y}function Wu({items:s},e,{flowChars:t,itemIndent:i}){let{indent:n,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=e;i+=r;let l=Object.assign({},e,{indent:i,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let S=0;S<s.length;++S){let d=s[S],p=null;if(we.isNode(d))d.spaceBefore&&u.push(""),pi(e,u,d.commentBefore,!1),d.comment&&(p=d.comment);else if(we.isPair(d)){let g=we.isNode(d.key)?d.key:null;g&&(g.spaceBefore&&u.push(""),pi(e,u,g.commentBefore,!1),g.comment&&(c=!0));let E=we.isNode(d.value)?d.value:null;E?(E.comment&&(p=E.comment),E.commentBefore&&(c=!0)):d.value==null&&g?.comment&&(p=g.comment)}p&&(c=!0);let m=Go.stringify(d,l,()=>p=null);S<s.length-1&&(m+=","),p&&(m+=hi.lineComment(m,i,a(p))),!c&&(u.length>f||m.includes(`
`))&&(c=!0),u.push(m),f=u.length}let{start:h,end:y}=t;if(u.length===0)return h+y;if(!c){let S=u.reduce((d,p)=>d+p.length+2,2);c=e.options.lineWidth>0&&S>e.options.lineWidth}if(c){let S=h;for(let d of u)S+=d?`
${r}${n}${d}`:`
`;return`${S}
${n}${y}`}else return`${h}${o}${u.join(" ")}${o}${y}`}function pi({indent:s,options:{commentString:e}},t,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=hi.indentComment(e(i),s);t.push(r.trimStart())}}Jo.stringifyCollection=Ku});var ce=A(en=>{"use strict";var Hu=zs(),Yu=Qs(),Gu=ei(),le=L(),di=ae(),Ju=O();function lt(s,e){let t=le.isScalar(e)?e.value:e;for(let i of s)if(le.isPair(i)&&(i.key===e||i.key===t||le.isScalar(i.key)&&i.key.value===t))return i}var Zs=class extends Gu.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(le.MAP,e),this.items=[]}static from(e,t,i){let{keepUndefined:n,replacer:r}=i,o=new this(e),a=(l,c)=>{if(typeof r=="function")c=r.call(t,l,c);else if(Array.isArray(r)&&!r.includes(l))return;(c!==void 0||n)&&o.items.push(di.createPair(l,c,i))};if(t instanceof Map)for(let[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(let l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let i;le.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new di.Pair(e,e?.value):i=new di.Pair(e.key,e.value);let n=lt(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!t)throw new Error(`Key ${i.key} already set`);le.isScalar(n.value)&&Ju.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let o=this.items.findIndex(a=>r(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let t=lt(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=lt(this.items,e)?.value;return(!t&&le.isScalar(n)?n.value:n)??void 0}has(e){return!!lt(this.items,e)}set(e,t){this.add(new di.Pair(e,t),!0)}toJSON(e,t,i){let n=i?new i:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(n);for(let r of this.items)Yu.addPairToJSMap(t,n,r);return n}toString(e,t,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!le.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Hu.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:t})}};en.YAMLMap=Zs;en.findPair=lt});var ke=A(Xo=>{"use strict";var Qu=L(),Qo=ce(),Xu={collection:"map",default:!0,nodeClass:Qo.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(s,e){return Qu.isMap(s)||e("Expected a mapping for this tag"),s},createNode:(s,e,t)=>Qo.YAMLMap.from(s,e,t)};Xo.map=Xu});var ue=A(zo=>{"use strict";var zu=et(),Zu=zs(),ef=ei(),mi=L(),tf=O(),sf=se(),tn=class extends ef.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(mi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=gi(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let i=gi(e);if(typeof i!="number")return;let n=this.items[i];return!t&&mi.isScalar(n)?n.value:n}has(e){let t=gi(e);return typeof t=="number"&&t<this.items.length}set(e,t){let i=gi(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];mi.isScalar(n)&&tf.isScalarValue(t)?n.value=t:this.items[i]=t}toJSON(e,t){let i=[];t?.onCreate&&t.onCreate(i);let n=0;for(let r of this.items)i.push(sf.toJS(r,String(n++),t));return i}toString(e,t,i){return e?Zu.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:t}):JSON.stringify(this)}static from(e,t,i){let{replacer:n}=i,r=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof n=="function"){let l=t instanceof Set?a:String(o++);a=n.call(t,l,a)}r.items.push(zu.createNode(a,void 0,i))}}return r}};function gi(s){let e=mi.isScalar(s)?s.value:s;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}zo.YAMLSeq=tn});var xe=A(ea=>{"use strict";var nf=L(),Zo=ue(),rf={collection:"seq",default:!0,nodeClass:Zo.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(s,e){return nf.isSeq(s)||e("Expected a sequence for this tag"),s},createNode:(s,e,t)=>Zo.YAMLSeq.from(s,e,t)};ea.seq=rf});var ct=A(ta=>{"use strict";var of=nt(),af={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,i){return e=Object.assign({actualString:!0},e),of.stringifyString(s,e,t,i)}};ta.string=af});var yi=A(na=>{"use strict";var ia=O(),sa={identify:s=>s==null,createNode:()=>new ia.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ia.Scalar(null),stringify:({source:s},e)=>typeof s=="string"&&sa.test.test(s)?s:e.options.nullStr};na.nullTag=sa});var sn=A(oa=>{"use strict";var lf=O(),ra={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new lf.Scalar(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&ra.test.test(s)){let i=s[0]==="t"||s[0]==="T";if(e===i)return s}return e?t.options.trueStr:t.options.falseStr}};oa.boolTag=ra});var qe=A(aa=>{"use strict";function cf({format:s,minFractionDigits:e,tag:t,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let r=JSON.stringify(i);if(!s&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let a=e-(r.length-o-1);for(;a-- >0;)r+="0"}return r}aa.stringifyNumber=cf});var rn=A(bi=>{"use strict";var uf=O(),nn=qe(),ff={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:nn.stringifyNumber},hf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){let e=Number(s.value);return isFinite(e)?e.toExponential():nn.stringifyNumber(s)}},pf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(s){let e=new uf.Scalar(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:nn.stringifyNumber};bi.float=pf;bi.floatExp=hf;bi.floatNaN=ff});var an=A(Si=>{"use strict";var la=qe(),wi=s=>typeof s=="bigint"||Number.isInteger(s),on=(s,e,t,{intAsBigInt:i})=>i?BigInt(s):parseInt(s.substring(e),t);function ca(s,e,t){let{value:i}=s;return wi(i)&&i>=0?t+i.toString(e):la.stringifyNumber(s)}var df={identify:s=>wi(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>on(s,2,8,t),stringify:s=>ca(s,8,"0o")},gf={identify:wi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>on(s,0,10,t),stringify:la.stringifyNumber},mf={identify:s=>wi(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>on(s,2,16,t),stringify:s=>ca(s,16,"0x")};Si.int=gf;Si.intHex=mf;Si.intOct=df});var fa=A(ua=>{"use strict";var yf=ke(),bf=yi(),wf=xe(),Sf=ct(),vf=sn(),ln=rn(),cn=an(),Ef=[yf.map,wf.seq,Sf.string,bf.nullTag,vf.boolTag,cn.intOct,cn.int,cn.intHex,ln.floatNaN,ln.floatExp,ln.float];ua.schema=Ef});var da=A(pa=>{"use strict";var Ff=O(),Af=ke(),Pf=xe();function ha(s){return typeof s=="bigint"||Number.isInteger(s)}var vi=({value:s})=>JSON.stringify(s),Df=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:vi},{identify:s=>s==null,createNode:()=>new Ff.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:vi},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:s=>s==="true",stringify:vi},{identify:ha,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>ha(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:vi}],Tf={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},Lf=[Af.map,Pf.seq].concat(Df,Tf);pa.schema=Lf});var fn=A(ga=>{"use strict";var ut=require("node:buffer"),un=O(),_f=nt(),Nf={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof ut.Buffer=="function")return ut.Buffer.from(s,"base64");if(typeof atob=="function"){let t=atob(s.replace(/[\n\r]/g,"")),i=new Uint8Array(t.length);for(let n=0;n<t.length;++n)i[n]=t.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:e,value:t},i,n,r){let o=t,a;if(typeof ut.Buffer=="function")a=o instanceof ut.Buffer?o.toString("base64"):ut.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 new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e||(e=un.Scalar.BLOCK_LITERAL),e!==un.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,h=0;u<c;++u,h+=l)f[u]=a.substr(h,l);a=f.join(e===un.Scalar.BLOCK_LITERAL?`
`:" ")}return _f.stringifyString({comment:s,type:e,value:a},i,n,r)}};ga.binary=Nf});var Ai=A(Fi=>{"use strict";var Ei=L(),hn=ae(),Cf=O(),If=ue();function ma(s,e){if(Ei.isSeq(s))for(let t=0;t<s.items.length;++t){let i=s.items[t];if(!Ei.isPair(i)){if(Ei.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new hn.Pair(new Cf.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
${n.key.commentBefore}`:i.commentBefore),i.comment){let r=n.value??n.key;r.comment=r.comment?`${i.comment}
${r.comment}`:i.comment}i=n}s.items[t]=Ei.isPair(i)?i:new hn.Pair(i)}}else e("Expected a sequence for this tag");return s}function ya(s,e,t){let{replacer:i}=t,n=new If.YAMLSeq(s);n.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new 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 new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(hn.createPair(a,l,t))}return n}var Of={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ma,createNode:ya};Fi.createPairs=ya;Fi.pairs=Of;Fi.resolvePairs=ma});var gn=A(dn=>{"use strict";var ba=L(),pn=se(),ft=ce(),kf=ue(),wa=Ai(),Se=class s extends kf.YAMLSeq{constructor(){super(),this.add=ft.YAMLMap.prototype.add.bind(this),this.delete=ft.YAMLMap.prototype.delete.bind(this),this.get=ft.YAMLMap.prototype.get.bind(this),this.has=ft.YAMLMap.prototype.has.bind(this),this.set=ft.YAMLMap.prototype.set.bind(this),this.tag=s.tag}toJSON(e,t){if(!t)return super.toJSON(e);let i=new Map;t?.onCreate&&t.onCreate(i);for(let n of this.items){let r,o;if(ba.isPair(n)?(r=pn.toJS(n.key,"",t),o=pn.toJS(n.value,r,t)):r=pn.toJS(n,"",t),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(e,t,i){let n=wa.createPairs(e,t,i),r=new this;return r.items=n.items,r}};Se.tag="tag:yaml.org,2002:omap";var xf={collection:"seq",identify:s=>s instanceof Map,nodeClass:Se,default:!1,tag:"tag:yaml.org,2002:omap",resolve(s,e){let t=wa.resolvePairs(s,e),i=[];for(let{key:n}of t.items)ba.isScalar(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Se,t)},createNode:(s,e,t)=>Se.from(s,e,t)};dn.YAMLOMap=Se;dn.omap=xf});var Aa=A(mn=>{"use strict";var Sa=O();function va({value:s,source:e},t){return e&&(s?Ea:Fa).test.test(e)?e:s?t.options.trueStr:t.options.falseStr}var Ea={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Sa.Scalar(!0),stringify:va},Fa={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Sa.Scalar(!1),stringify:va};mn.falseTag=Fa;mn.trueTag=Ea});var Pa=A(Pi=>{"use strict";var qf=O(),yn=qe(),Mf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:yn.stringifyNumber},Rf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s.replace(/_/g,"")),stringify(s){let e=Number(s.value);return isFinite(e)?e.toExponential():yn.stringifyNumber(s)}},Bf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(s){let e=new qf.Scalar(parseFloat(s.replace(/_/g,""))),t=s.indexOf(".");if(t!==-1){let i=s.substring(t+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:yn.stringifyNumber};Pi.float=Bf;Pi.floatExp=Rf;Pi.floatNaN=Mf});var Ta=A(pt=>{"use strict";var Da=qe(),ht=s=>typeof s=="bigint"||Number.isInteger(s);function Di(s,e,t,{intAsBigInt:i}){let n=s[0];if((n==="-"||n==="+")&&(e+=1),s=s.substring(e).replace(/_/g,""),i){switch(t){case 2:s=`0b${s}`;break;case 8:s=`0o${s}`;break;case 16:s=`0x${s}`;break}let o=BigInt(s);return n==="-"?BigInt(-1)*o:o}let r=parseInt(s,t);return n==="-"?-1*r:r}function bn(s,e,t){let{value:i}=s;if(ht(i)){let n=i.toString(e);return i<0?"-"+t+n.substr(1):t+n}return Da.stringifyNumber(s)}var $f={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(s,e,t)=>Di(s,2,2,t),stringify:s=>bn(s,2,"0b")},jf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(s,e,t)=>Di(s,1,8,t),stringify:s=>bn(s,8,"0")},Uf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(s,e,t)=>Di(s,0,10,t),stringify:Da.stringifyNumber},Kf={identify:ht,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(s,e,t)=>Di(s,2,16,t),stringify:s=>bn(s,16,"0x")};pt.int=Uf;pt.intBin=$f;pt.intHex=Kf;pt.intOct=jf});var Sn=A(wn=>{"use strict";var _i=L(),Ti=ae(),Li=ce(),ve=class s extends Li.YAMLMap{constructor(e){super(e),this.tag=s.tag}add(e){let t;_i.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Ti.Pair(e.key,null):t=new Ti.Pair(e,null),Li.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let i=Li.findPair(this.items,e);return!t&&_i.isPair(i)?_i.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=Li.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new Ti.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,i);throw new Error("Set items must all have null values")}static from(e,t,i){let{replacer:n}=i,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof n=="function"&&(o=n.call(t,o,o)),r.items.push(Ti.createPair(o,null,i));return r}};ve.tag="tag:yaml.org,2002:set";var Vf={collection:"map",identify:s=>s instanceof Set,nodeClass:ve,default:!1,tag:"tag:yaml.org,2002:set",createNode:(s,e,t)=>ve.from(s,e,t),resolve(s,e){if(_i.isMap(s)){if(s.hasAllNullValues(!0))return Object.assign(new ve,s);e("Set items must all have null values")}else e("Expected a mapping for this tag");return s}};wn.YAMLSet=ve;wn.set=Vf});var En=A(Ni=>{"use strict";var Wf=qe();function vn(s,e){let t=s[0],i=t==="-"||t==="+"?s.substring(1):s,n=o=>e?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return t==="-"?n(-1)*r:r}function La(s){let{value:e}=s,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Wf.stringifyNumber(s);let i="";e<0&&(i="-",e*=t(-1));let n=t(60),r=[e%n];return e<60?r.unshift(0):(e=(e-r[0])/n,r.unshift(e%n),e>=60&&(e=(e-r[0])/n,r.unshift(e))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Hf={identify:s=>typeof s=="bigint"||Number.isInteger(s),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(s,e,{intAsBigInt:t})=>vn(s,t),stringify:La},Yf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:s=>vn(s,!1),stringify:La},_a={identify:s=>s 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(s){let e=s.match(_a.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,i,n,r,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(t,i-1,n,r||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let u=vn(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:s})=>s.toISOString().replace(/(T00:00:00)?\.000Z$/,"")};Ni.floatTime=Yf;Ni.intTime=Hf;Ni.timestamp=_a});var Ia=A(Ca=>{"use strict";var Gf=ke(),Jf=yi(),Qf=xe(),Xf=ct(),zf=fn(),Na=Aa(),Fn=Pa(),Ci=Ta(),Zf=ci(),eh=gn(),th=Ai(),ih=Sn(),An=En(),sh=[Gf.map,Qf.seq,Xf.string,Jf.nullTag,Na.trueTag,Na.falseTag,Ci.intBin,Ci.intOct,Ci.int,Ci.intHex,Fn.floatNaN,Fn.floatExp,Fn.float,zf.binary,Zf.merge,eh.omap,th.pairs,ih.set,An.intTime,An.floatTime,An.timestamp];Ca.schema=sh});var Ua=A(Tn=>{"use strict";var qa=ke(),nh=yi(),Ma=xe(),rh=ct(),oh=sn(),Pn=rn(),Dn=an(),ah=fa(),lh=da(),Ra=fn(),dt=ci(),Ba=gn(),$a=Ai(),Oa=Ia(),ja=Sn(),Ii=En(),ka=new Map([["core",ah.schema],["failsafe",[qa.map,Ma.seq,rh.string]],["json",lh.schema],["yaml11",Oa.schema],["yaml-1.1",Oa.schema]]),xa={binary:Ra.binary,bool:oh.boolTag,float:Pn.float,floatExp:Pn.floatExp,floatNaN:Pn.floatNaN,floatTime:Ii.floatTime,int:Dn.int,intHex:Dn.intHex,intOct:Dn.intOct,intTime:Ii.intTime,map:qa.map,merge:dt.merge,null:nh.nullTag,omap:Ba.omap,pairs:$a.pairs,seq:Ma.seq,set:ja.set,timestamp:Ii.timestamp},ch={"tag:yaml.org,2002:binary":Ra.binary,"tag:yaml.org,2002:merge":dt.merge,"tag:yaml.org,2002:omap":Ba.omap,"tag:yaml.org,2002:pairs":$a.pairs,"tag:yaml.org,2002:set":ja.set,"tag:yaml.org,2002:timestamp":Ii.timestamp};function uh(s,e,t){let i=ka.get(e);if(i&&!s)return t&&!i.includes(dt.merge)?i.concat(dt.merge):i.slice();let n=i;if(!n)if(Array.isArray(s))n=[];else{let r=Array.from(ka.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`)}if(Array.isArray(s))for(let r of s)n=n.concat(r);else typeof s=="function"&&(n=s(n.slice()));return t&&(n=n.concat(dt.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?xa[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(xa).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Tn.coreKnownTags=ch;Tn.getTags=uh});var Nn=A(Ka=>{"use strict";var Ln=L(),fh=ke(),hh=xe(),ph=ct(),Oi=Ua(),dh=(s,e)=>s.key<e.key?-1:s.key>e.key?1:0,_n=class s{constructor({compat:e,customTags:t,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Oi.getTags(e,"compat"):e?Oi.getTags(null,e):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?Oi.coreKnownTags:{},this.tags=Oi.getTags(t,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Ln.MAP,{value:fh.map}),Object.defineProperty(this,Ln.SCALAR,{value:ph.string}),Object.defineProperty(this,Ln.SEQ,{value:hh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?dh:null}clone(){let e=Object.create(s.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Ka.Schema=_n});var Wa=A(Va=>{"use strict";var gh=L(),Cn=rt(),gt=tt();function mh(s,e){let t=[],i=e.directives===!0;if(e.directives!==!1&&s.directives){let l=s.directives.toString(s);l?(t.push(l),i=!0):s.directives.docStart&&(i=!0)}i&&t.push("---");let n=Cn.createStringifyContext(s,e),{commentString:r}=n.options;if(s.commentBefore){t.length!==1&&t.unshift("");let l=r(s.commentBefore);t.unshift(gt.indentComment(l,""))}let o=!1,a=null;if(s.contents){if(gh.isNode(s.contents)){if(s.contents.spaceBefore&&i&&t.push(""),s.contents.commentBefore){let f=r(s.contents.commentBefore);t.push(gt.indentComment(f,""))}n.forceBlockIndent=!!s.comment,a=s.contents.comment}let l=a?void 0:()=>o=!0,c=Cn.stringify(s.contents,n,()=>a=null,l);a&&(c+=gt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Cn.stringify(s.contents,n));if(s.directives?.docEnd)if(s.comment){let l=r(s.comment);l.includes(`
`)?(t.push("..."),t.push(gt.indentComment(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=s.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(gt.indentComment(r(l),"")))}return t.join(`
`)+`
`}Va.stringifyDocument=mh});var mt=A(Ha=>{"use strict";var yh=Ze(),Me=ei(),K=L(),bh=ae(),wh=se(),Sh=Nn(),vh=Wa(),In=Jt(),Eh=xs(),Fh=et(),On=ks(),kn=class s{constructor(e,t,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,K.NODE_TYPE,{value:K.DOC});let n=null;typeof t=="function"||Array.isArray(t)?n=t:i===void 0&&t&&(i=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"},i);this.options=r;let{version:o}=r;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new On.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(s.prototype,{[K.NODE_TYPE]:{value:K.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=K.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Re(this.contents)&&this.contents.add(e)}addIn(e,t){Re(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let i=In.anchorNames(this);e.anchor=!t||i.has(t)?In.findNewAnchor(t||"a",i):t}return new yh.Alias(e.anchor)}createNode(e,t,i){let n;if(typeof t=="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let p=g=>typeof g=="number"||g instanceof String||g instanceof Number,m=t.filter(p).map(String);m.length>0&&(t=t.concat(m)),n=t}else i===void 0&&t&&(i=t,t=void 0);let{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=i??{},{onAnchor:u,setAnchors:h,sourceObjects:y}=In.createNodeAnchors(this,o||"a"),S={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:y},d=Fh.createNode(e,f,S);return a&&K.isCollection(d)&&(d.flow=!0),h(),d}createPair(e,t,i={}){let n=this.createNode(e,null,i),r=this.createNode(t,null,i);return new bh.Pair(n,r)}delete(e){return Re(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Me.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Re(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return K.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Me.isEmptyPath(e)?!t&&K.isScalar(this.contents)?this.contents.value:this.contents:K.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return K.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Me.isEmptyPath(e)?this.contents!==void 0:K.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Me.collectionFromPath(this.schema,[e],t):Re(this.contents)&&this.contents.set(e,t)}setIn(e,t){Me.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Me.collectionFromPath(this.schema,Array.from(e),t):Re(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new On.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new On.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(i)this.schema=new Sh.Schema(Object.assign(i,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:i,maxAliasCount:n,onAnchor:r,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=wh.toJS(this.contents,t??"",a);if(typeof r=="function")for(let{count:c,res:f}of a.anchors.values())r(f,c);return typeof o=="function"?Eh.applyReviver(o,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return vh.stringifyDocument(this,e)}};function Re(s){if(K.isCollection(s))return!0;throw new Error("Expected a YAML collection as document contents")}Ha.Document=kn});var wt=A(bt=>{"use strict";var yt=class extends Error{constructor(e,t,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=t}},xn=class extends yt{constructor(e,t,i){super("YAMLParseError",e,t,i)}},qn=class extends yt{constructor(e,t,i){super("YAMLWarning",e,t,i)}},Ah=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:i,col:n}=t.linePos[0];t.message+=` at line ${i}, column ${n}`;let r=n-1,o=s.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){let a=Math.min(r-39,o.length-79);o="\u2026"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),i>1&&/^ *$/.test(o.substring(0,r))){let a=s.substring(e.lineStarts[i-2],e.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
`),o=a+o}if(/[^ ]/.test(o)){let a=1,l=t.linePos[1];l&&l.line===i&&l.col>n&&(a=Math.max(1,Math.min(l.col-n,80-r)));let c=" ".repeat(r)+"^".repeat(a);t.message+=`:
${o}
${c}
`}};bt.YAMLError=yt;bt.YAMLParseError=xn;bt.YAMLWarning=qn;bt.prettifyError=Ah});var St=A(Ya=>{"use strict";function Ph(s,{flow:e,indicator:t,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",h="",y=!1,S=!1,d=null,p=null,m=null,g=null,E=null,b=null,w=null;for(let F of s)switch(S&&(F.type!=="space"&&F.type!=="newline"&&F.type!=="comma"&&r(F.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),S=!1),d&&(c&&F.type!=="comment"&&F.type!=="newline"&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),F.type){case"space":!e&&(t!=="doc-start"||i?.type!=="flow-collection")&&F.source.includes(" ")&&(d=F),f=!0;break;case"comment":{f||r(F,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=F.source.substring(1)||" ";u?u+=h+N:u=N,h="",c=!1;break}case"newline":c?u?u+=F.source:(!b||t!=="seq-item-ind")&&(l=!0):h+=F.source,c=!0,y=!0,(p||m)&&(g=F),f=!0;break;case"anchor":p&&r(F,"MULTIPLE_ANCHORS","A node can have at most one anchor"),F.source.endsWith(":")&&r(F.offset+F.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=F,w===null&&(w=F.offset),c=!1,f=!1,S=!0;break;case"tag":{m&&r(F,"MULTIPLE_TAGS","A node can have at most one tag"),m=F,w===null&&(w=F.offset),c=!1,f=!1,S=!0;break}case t:(p||m)&&r(F,"BAD_PROP_ORDER",`Anchors and tags must be after the ${F.source} indicator`),b&&r(F,"UNEXPECTED_TOKEN",`Unexpected ${F.source} in ${e??"collection"}`),b=F,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){E&&r(F,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),E=F,c=!1,f=!1;break}default:r(F,"UNEXPECTED_TOKEN",`Unexpected ${F.type} token`),c=!1,f=!1}let v=s[s.length-1],P=v?v.offset+v.source.length:n;return S&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(c&&d.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:E,found:b,spaceBefore:l,comment:u,hasNewline:y,anchor:p,tag:m,newlineAfterProp:g,end:P,start:w??P}}Ya.resolveProps=Ph});var ki=A(Ga=>{"use strict";function Mn(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(`
`))return!0;if(s.end){for(let e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of s.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(Mn(e.key)||Mn(e.value))return!0}return!1;default:return!0}}Ga.containsNewline=Mn});var Rn=A(Ja=>{"use strict";var Dh=ki();function Th(s,e,t){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===s&&(i.source==="]"||i.source==="}")&&Dh.containsNewline(e)&&t(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Ja.flowIndentCheck=Th});var Bn=A(Xa=>{"use strict";var Qa=L();function Lh(s,e,t){let{uniqueKeys:i}=s.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||Qa.isScalar(r)&&Qa.isScalar(o)&&r.value===o.value;return e.some(r=>n(r.key,t))}Xa.mapIncludes=Lh});var sl=A(il=>{"use strict";var za=ae(),_h=ce(),Za=St(),Nh=ki(),el=Rn(),Ch=Bn(),tl="All mapping items must start at the same column";function Ih({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=r?.nodeClass??_h.YAMLMap,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let l=i.offset,c=null;for(let f of i.items){let{start:u,key:h,sep:y,value:S}=f,d=Za.resolveProps(u,{indicator:"explicit-key-ind",next:h??y?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),p=!d.found;if(p){if(h&&(h.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==i.indent&&n(l,"BAD_INDENT",tl)),!d.anchor&&!d.tag&&!y){c=d.end,d.comment&&(a.comment?a.comment+=`
`+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||Nh.containsNewline(h))&&n(h??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==i.indent&&n(l,"BAD_INDENT",tl);t.atKey=!0;let m=d.end,g=h?s(t,h,d,n):e(t,m,u,null,d,n);t.schema.compat&&el.flowIndentCheck(i.indent,h,n),t.atKey=!1,Ch.mapIncludes(t,a.items,g)&&n(m,"DUPLICATE_KEY","Map keys must be unique");let E=Za.resolveProps(y??[],{indicator:"map-value-ind",next:S,offset:g.range[2],onError:n,parentIndent:i.indent,startOnNewline:!h||h.type==="block-scalar"});if(l=E.end,E.found){p&&(S?.type==="block-map"&&!E.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<E.found.offset-1024&&n(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let b=S?s(t,S,E,n):e(t,l,y,null,E,n);t.schema.compat&&el.flowIndentCheck(i.indent,S,n),l=b.range[2];let w=new za.Pair(g,b);t.options.keepSourceTokens&&(w.srcToken=f),a.items.push(w)}else{p&&n(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),E.comment&&(g.comment?g.comment+=`
`+E.comment:g.comment=E.comment);let b=new za.Pair(g);t.options.keepSourceTokens&&(b.srcToken=f),a.items.push(b)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,l,c??l],a}il.resolveBlockMap=Ih});var rl=A(nl=>{"use strict";var Oh=ue(),kh=St(),xh=Rn();function qh({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=r?.nodeClass??Oh.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=i.offset,c=null;for(let{start:f,value:u}of i.items){let h=kh.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!h.found)if(h.anchor||h.tag||u)u&&u.type==="block-seq"?n(h.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=h.end,h.comment&&(a.comment=h.comment);continue}let y=u?s(t,u,h,n):e(t,h.end,f,null,h,n);t.schema.compat&&xh.flowIndentCheck(i.indent,u,n),l=y.range[2],a.items.push(y)}return a.range=[i.offset,l,c??l],a}nl.resolveBlockSeq=qh});var Be=A(ol=>{"use strict";function Mh(s,e,t,i){let n="";if(s){let r=!1,o="";for(let a of s){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:n,offset:e}}ol.resolveEnd=Mh});var ul=A(cl=>{"use strict";var Rh=L(),Bh=ae(),al=ce(),$h=ue(),jh=Be(),ll=St(),Uh=ki(),Kh=Bn(),$n="Block collections are not allowed within flow collections",jn=s=>s&&(s.type==="block-map"||s.type==="block-seq");function Vh({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?al.YAMLMap:$h.YAMLSeq),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=i.offset+i.start.source.length;for(let p=0;p<i.items.length;++p){let m=i.items[p],{start:g,key:E,sep:b,value:w}=m,v=ll.resolveProps(g,{flow:a,indicator:"explicit-key-ind",next:E??b?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!b&&!w){p===0&&v.comma?n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<i.items.length-1&&n(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),v.comment&&(c.comment?c.comment+=`
`+v.comment:c.comment=v.comment),u=v.end;continue}!o&&t.options.strict&&Uh.containsNewline(E)&&n(E,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)v.comma&&n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(v.comma||n(v.start,"MISSING_CHAR",`Missing , between ${a} items`),v.comment){let P="";e:for(let F of g)switch(F.type){case"comma":case"space":break;case"comment":P=F.source.substring(1);break e;default:break e}if(P){let F=c.items[c.items.length-1];Rh.isPair(F)&&(F=F.value??F.key),F.comment?F.comment+=`
`+P:F.comment=P,v.comment=v.comment.substring(P.length+1)}}if(!o&&!b&&!v.found){let P=w?s(t,w,v,n):e(t,v.end,b,null,v,n);c.items.push(P),u=P.range[2],jn(w)&&n(P.range,"BLOCK_IN_FLOW",$n)}else{t.atKey=!0;let P=v.end,F=E?s(t,E,v,n):e(t,P,g,null,v,n);jn(E)&&n(F.range,"BLOCK_IN_FLOW",$n),t.atKey=!1;let N=ll.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:w,offset:F.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(N.found){if(!o&&!v.found&&t.options.strict){if(b)for(let I of b){if(I===N.found)break;if(I.type==="newline"){n(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.start<N.found.offset-1024&&n(N.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else w&&("source"in w&&w.source&&w.source[0]===":"?n(w,"MISSING_CHAR",`Missing space after : in ${a}`):n(N.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let M=w?s(t,w,N,n):N.found?e(t,N.end,b,null,N,n):null;M?jn(w)&&n(M.range,"BLOCK_IN_FLOW",$n):N.comment&&(F.comment?F.comment+=`
`+N.comment:F.comment=N.comment);let ee=new Bh.Pair(F,M);if(t.options.keepSourceTokens&&(ee.srcToken=m),o){let I=c;Kh.mapIncludes(t,I.items,F)&&n(P,"DUPLICATE_KEY","Map keys must be unique"),I.items.push(ee)}else{let I=new al.YAMLMap(t.schema);I.flow=!0,I.items.push(ee);let Ot=(M??F).range;I.range=[F.range[0],Ot[1],Ot[2]],c.items.push(I)}u=M?M.range[2]:N.end}}let h=o?"}":"]",[y,...S]=i.end,d=u;if(y&&y.source===h)d=y.offset+y.source.length;else{let p=a[0].toUpperCase()+a.substring(1),m=f?`${p} must end with a ${h}`:`${p} in block collection must be sufficiently indented and end with a ${h}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",m),y&&y.source.length!==1&&S.unshift(y)}if(S.length>0){let p=jh.resolveEnd(S,d,t.options.strict,n);p.comment&&(c.comment?c.comment+=`
`+p.comment:c.comment=p.comment),c.range=[i.offset,d,p.offset]}else c.range=[i.offset,d,d];return c}cl.resolveFlowCollection=Vh});var hl=A(fl=>{"use strict";var Wh=L(),Hh=O(),Yh=ce(),Gh=ue(),Jh=sl(),Qh=rl(),Xh=ul();function Un(s,e,t,i,n,r){let o=t.type==="block-map"?Jh.resolveBlockMap(s,e,t,i,r):t.type==="block-seq"?Qh.resolveBlockSeq(s,e,t,i,r):Xh.resolveFlowCollection(s,e,t,i,r),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function zh(s,e,t,i,n){let r=i.tag,o=r?e.directives.tagName(r.source,h=>n(r,"TAG_RESOLVE_FAILED",h)):null;if(t.type==="block-seq"){let{anchor:h,newlineAfterProp:y}=i,S=h&&r?h.offset>r.offset?h:r:h??r;S&&(!y||y.offset<S.offset)&&n(S,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===Yh.YAMLMap.tagName&&a==="map"||o===Gh.YAMLSeq.tagName&&a==="seq")return Un(s,e,t,n,o);let l=e.schema.tags.find(h=>h.tag===o&&h.collection===a);if(!l){let h=e.schema.knownTags[o];if(h&&h.collection===a)e.schema.tags.push(Object.assign({},h,{default:!1})),l=h;else return h?.collection?n(r,"BAD_COLLECTION_TYPE",`${h.tag} used for ${a} collection, but expects ${h.collection}`,!0):n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Un(s,e,t,n,o)}let c=Un(s,e,t,n,o,l),f=l.resolve?.(c,h=>n(r,"TAG_RESOLVE_FAILED",h),e.options)??c,u=Wh.isNode(f)?f:new Hh.Scalar(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}fl.composeCollection=zh});var Vn=A(pl=>{"use strict";var Kn=O();function Zh(s,e,t){let i=e.offset,n=ep(e,s.options.strict,t);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?Kn.Scalar.BLOCK_FOLDED:Kn.Scalar.BLOCK_LITERAL,o=e.source?tp(e.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let p=o[d][1];if(p===""||p==="\r")a=d;else break}if(a===0){let d=n.chomp==="+"&&o.length>0?`
`.repeat(Math.max(1,o.length-1)):"",p=i+n.length;return e.source&&(p+=e.source.length),{value:d,type:r,comment:n.comment,range:[i,p,p]}}let l=e.indent+n.indent,c=e.offset+n.length,f=0;for(let d=0;d<a;++d){let[p,m]=o[d];if(m===""||m==="\r")n.indent===0&&p.length>l&&(l=p.length);else{p.length<l&&t(c+p.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=p.length),f=d,l===0&&!s.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=p.length+m.length+1}for(let d=o.length-1;d>=a;--d)o[d][0].length>l&&(a=d+1);let u="",h="",y=!1;for(let d=0;d<f;++d)u+=o[d][0].slice(l)+`
`;for(let d=f;d<a;++d){let[p,m]=o[d];c+=p.length+m.length+1;let g=m[m.length-1]==="\r";if(g&&(m=m.slice(0,-1)),m&&p.length<l){let b=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;t(c-m.length-(g?2:1),"BAD_INDENT",b),p=""}r===Kn.Scalar.BLOCK_LITERAL?(u+=h+p.slice(l)+m,h=`
`):p.length>l||m[0]===" "?(h===" "?h=`
`:!y&&h===`
`&&(h=`
`),u+=h+p.slice(l)+m,h=`
`,y=!0):m===""?h===`
`?u+=`
`:h=`
`:(u+=h+m,h=" ",y=!1)}switch(n.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)u+=`
`+o[d][0].slice(l);u[u.length-1]!==`
`&&(u+=`
`);break;default:u+=`
`}let S=i+n.length+e.source.length;return{value:u,type:r,comment:n.comment,range:[i,S,S]}}function ep({offset:s,props:e},t,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],r=n[0],o=0,a="",l=-1;for(let h=1;h<n.length;++h){let y=n[h];if(!a&&(y==="-"||y==="+"))a=y;else{let S=Number(y);!o&&S?o=S:l===-1&&(l=s+h)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,f="",u=n.length;for(let h=1;h<e.length;++h){let y=e[h];switch(y.type){case"space":c=!0;case"newline":u+=y.source.length;break;case"comment":t&&!c&&i(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=y.source.length,f=y.source.substring(1);break;case"error":i(y,"UNEXPECTED_TOKEN",y.message),u+=y.source.length;break;default:{let S=`Unexpected token in block scalar header: ${y.type}`;i(y,"UNEXPECTED_TOKEN",S);let d=y.source;d&&typeof d=="string"&&(u+=d.length)}}}return{mode:r,indent:o,chomp:a,comment:f,length:u}}function tp(s){let e=s.split(/\n( *)/),t=e[0],i=t.match(/^( *)/),r=[i?.[1]?[i[1],t.slice(i[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}pl.resolveBlockScalar=Zh});var Hn=A(gl=>{"use strict";var Wn=O(),ip=Be();function sp(s,e,t){let{offset:i,type:n,source:r,end:o}=s,a,l,c=(h,y,S)=>t(i+h,y,S);switch(n){case"scalar":a=Wn.Scalar.PLAIN,l=np(r,c);break;case"single-quoted-scalar":a=Wn.Scalar.QUOTE_SINGLE,l=rp(r,c);break;case"double-quoted-scalar":a=Wn.Scalar.QUOTE_DOUBLE,l=op(r,c);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}let f=i+r.length,u=ip.resolveEnd(o,f,e,t);return{value:l,type:a,comment:u.comment,range:[i,f,u.offset]}}function np(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),dl(s)}function rp(s,e){return(s[s.length-1]!=="'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing 'quote"),dl(s.slice(1,-1)).replace(/''/g,"'")}function dl(s){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(s);if(!i)return s;let n=i[1],r=" ",o=e.lastIndex;for(t.lastIndex=o;i=t.exec(s);)i[1]===""?r===`
`?n+=r:r=`
`:(n+=r+i[1],r=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(s),n+r+(i?.[1]??"")}function op(s,e){let t="";for(let i=1;i<s.length-1;++i){let n=s[i];if(!(n==="\r"&&s[i+1]===`
`))if(n===`
`){let{fold:r,offset:o}=ap(s,i);t+=r,i=o}else if(n==="\\"){let r=s[++i],o=lp[r];if(o)t+=o;else if(r===`
`)for(r=s[i+1];r===" "||r===" ";)r=s[++i+1];else if(r==="\r"&&s[i+1]===`
`)for(r=s[++i+1];r===" "||r===" ";)r=s[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];t+=cp(s,i+1,a,e),i+=a}else{let a=s.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(n===" "||n===" "){let r=i,o=s[i+1];for(;o===" "||o===" ";)o=s[++i+1];o!==`
`&&!(o==="\r"&&s[i+2]===`
`)&&(t+=i>r?s.slice(r,i+1):n)}else t+=n}return(s[s.length-1]!=='"'||s.length===1)&&e(s.length,"MISSING_CHAR",'Missing closing "quote'),t}function ap(s,e){let t="",i=s[e+1];for(;(i===" "||i===" "||i===`
`||i==="\r")&&!(i==="\r"&&s[e+2]!==`
`);)i===`
`&&(t+=`
`),e+=1,i=s[e+1];return t||(t=" "),{fold:t,offset:e}}var lp={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function cp(s,e,t,i){let n=s.substr(e,t),o=n.length===t&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;if(isNaN(o)){let a=s.substr(e-2,t+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}gl.resolveFlowScalar=sp});var bl=A(yl=>{"use strict";var Ee=L(),ml=O(),up=Vn(),fp=Hn();function hp(s,e,t,i){let{value:n,type:r,comment:o,range:a}=e.type==="block-scalar"?up.resolveBlockScalar(s,e,i):fp.resolveFlowScalar(e,s.options.strict,i),l=t?s.directives.tagName(t.source,u=>i(t,"TAG_RESOLVE_FAILED",u)):null,c;s.options.stringKeys&&s.atKey?c=s.schema[Ee.SCALAR]:l?c=pp(s.schema,n,l,t,i):e.type==="scalar"?c=dp(s,n,e,i):c=s.schema[Ee.SCALAR];let f;try{let u=c.resolve(n,h=>i(t??e,"TAG_RESOLVE_FAILED",h),s.options);f=Ee.isScalar(u)?u:new ml.Scalar(u)}catch(u){let h=u instanceof Error?u.message:String(u);i(t??e,"TAG_RESOLVE_FAILED",h),f=new ml.Scalar(n)}return f.range=a,f.source=n,r&&(f.type=r),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function pp(s,e,t,i,n){if(t==="!")return s[Ee.SCALAR];let r=[];for(let a of s.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(let a of r)if(a.test?.test(e))return a;let o=s.knownTags[t];return o&&!o.collection?(s.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[Ee.SCALAR])}function dp({atKey:s,directives:e,schema:t},i,n,r){let o=t.tags.find(a=>(a.default===!0||s&&a.default==="key")&&a.test?.test(i))||t[Ee.SCALAR];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(i))??t[Ee.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}yl.composeScalar=hp});var Sl=A(wl=>{"use strict";function gp(s,e,t){if(e){t===null&&(t=e.length);for(let i=t-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":s-=n.source.length;continue}for(n=e[++i];n?.type==="space";)s+=n.source.length,n=e[++i];break}}return s}wl.emptyScalarPosition=gp});var Fl=A(Gn=>{"use strict";var mp=Ze(),yp=L(),bp=hl(),vl=bl(),wp=Be(),Sp=Sl(),vp={composeNode:El,composeEmptyNode:Yn};function El(s,e,t,i){let n=s.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=t,c,f=!0;switch(e.type){case"alias":c=Ep(s,e,i),(a||l)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=vl.composeScalar(s,e,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=bp.composeCollection(vp,s,e,t,i),a&&(c.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),c=Yn(s,e.offset,void 0,null,t,i),f=!1}}return a&&c.anchor===""&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&s.options.stringKeys&&(!yp.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),s.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Yn(s,e,t,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:Sp.emptyScalarPosition(e,t,i),indent:-1,source:""},u=vl.composeScalar(s,f,a,c);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),r&&(u.comment=r,u.range[2]=l),u}function Ep({options:s},{offset:e,source:t,end:i},n){let r=new mp.Alias(t.substring(1));r.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&n(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+t.length,a=wp.resolveEnd(i,o,s.strict,n);return r.range=[e,o,a.offset],a.comment&&(r.comment=a.comment),r}Gn.composeEmptyNode=Yn;Gn.composeNode=El});var Dl=A(Pl=>{"use strict";var Fp=mt(),Al=Fl(),Ap=Be(),Pp=St();function Dp(s,e,{offset:t,start:i,value:n,end:r},o){let a=Object.assign({_directives:e},s),l=new Fp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=Pp.resolveProps(i,{indicator:"doc-start",next:n??r?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?Al.composeNode(c,n,f,o):Al.composeEmptyNode(c,f.end,i,null,f,o);let u=l.contents.range[2],h=Ap.resolveEnd(r,u,!1,o);return h.comment&&(l.comment=h.comment),l.range=[t,u,h.offset],l}Pl.composeDoc=Dp});var Qn=A(_l=>{"use strict";var Tp=require("node:process"),Lp=ks(),_p=mt(),vt=wt(),Tl=L(),Np=Dl(),Cp=Be();function Et(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];let{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function Ll(s){let e="",t=!1,i=!1;for(let n=0;n<s.length;++n){let r=s[n];switch(r[0]){case"#":e+=(e===""?"":i?`
`:`
`)+(r.substring(1)||" "),t=!0,i=!1;break;case"%":s[n+1]?.[0]!=="#"&&(n+=1),t=!1;break;default:t||(i=!0),t=!1}}return{comment:e,afterEmptyLine:i}}var Jn=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,i,n,r)=>{let o=Et(t);r?this.warnings.push(new vt.YAMLWarning(o,i,n)):this.errors.push(new vt.YAMLParseError(o,i,n))},this.directives=new Lp.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:i,afterEmptyLine:n}=Ll(this.prelude);if(i){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
${i}`:i;else if(n||e.directives.docStart||!r)e.commentBefore=i;else if(Tl.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];Tl.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${i}
${a}`:i}else{let o=r.commentBefore;r.commentBefore=o?`${i}
${o}`:i}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ll(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(t,i)}*next(e){switch(Tp.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,i,n)=>{let r=Et(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Np.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),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,i=new vt.YAMLParseError(Et(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new vt.YAMLParseError(Et(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let t=Cp.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new vt.YAMLParseError(Et(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 i=Object.assign({_directives:this.directives},this.options),n=new _p.Document(void 0,i);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}};_l.Composer=Jn});var Il=A(xi=>{"use strict";var Ip=Vn(),Op=Hn(),kp=wt(),Nl=nt();function xp(s,e=!0,t){if(s){let i=(n,r,o)=>{let a=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(t)t(a,r,o);else throw new kp.YAMLParseError([a,a+1],r,o)};switch(s.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Op.resolveFlowScalar(s,e,i);case"block-scalar":return Ip.resolveBlockScalar({options:{strict:e}},s,i)}}return null}function qp(s,e){let{implicitKey:t=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=e,a=Nl.stringifyString({type:o,value:s},{implicitKey:t,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:i,source:`
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
`),f=a.substring(0,c),u=a.substring(c+1)+`
`,h=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return Cl(h,l)||h.push({type:"newline",offset:-1,indent:i,source:`
`}),{type:"block-scalar",offset:r,indent:i,props:h,source:u}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function Mp(s,e,t={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:r=!1,type:o}=t,a="indent"in s?s.indent:null;if(i&&typeof a=="number"&&(a+=2),!o)switch(s.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=s.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Nl.stringifyString({type:o,value:e},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Rp(s,l);break;case'"':Xn(s,l,"double-quoted-scalar");break;case"'":Xn(s,l,"single-quoted-scalar");break;default:Xn(s,l,"scalar")}}function Rp(s,e){let t=e.indexOf(`
`),i=e.substring(0,t),n=e.substring(t+1)+`
`;if(s.type==="block-scalar"){let r=s.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=i,s.source=n}else{let{offset:r}=s,o="indent"in s?s.indent:-1,a=[{type:"block-scalar-header",offset:r,indent:o,source:i}];Cl(a,"end"in s?s.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
`});for(let l of Object.keys(s))l!=="type"&&l!=="offset"&&delete s[l];Object.assign(s,{type:"block-scalar",indent:o,props:a,source:n})}}function Cl(s,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":s.push(t);break;case"newline":return s.push(t),!0}return!1}function Xn(s,e,t){switch(s.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":s.type=t,s.source=e;break;case"block-scalar":{let i=s.props.slice(1),n=e.length;s.props[0].type==="block-scalar-header"&&(n-=s.props[0].source.length);for(let r of i)r.offset+=n;delete s.props,Object.assign(s,{type:t,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:s.offset+e.length,indent:s.indent,source:`
`};delete s.items,Object.assign(s,{type:t,source:e,end:[n]});break}default:{let i="indent"in s?s.indent:-1,n="end"in s&&Array.isArray(s.end)?s.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(s))r!=="type"&&r!=="offset"&&delete s[r];Object.assign(s,{type:t,indent:i,source:e,end:n})}}}xi.createScalarToken=qp;xi.resolveAsScalar=xp;xi.setScalarValue=Mp});var kl=A(Ol=>{"use strict";var Bp=s=>"type"in s?Mi(s):qi(s);function Mi(s){switch(s.type){case"block-scalar":{let e="";for(let t of s.props)e+=Mi(t);return e+s.source}case"block-map":case"block-seq":{let e="";for(let t of s.items)e+=qi(t);return e}case"flow-collection":{let e=s.start.source;for(let t of s.items)e+=qi(t);for(let t of s.end)e+=t.source;return e}case"document":{let e=qi(s);if(s.end)for(let t of s.end)e+=t.source;return e}default:{let e=s.source;if("end"in s&&s.end)for(let t of s.end)e+=t.source;return e}}}function qi({start:s,key:e,sep:t,value:i}){let n="";for(let r of s)n+=r.source;if(e&&(n+=Mi(e)),t)for(let r of t)n+=r.source;return i&&(n+=Mi(i)),n}Ol.stringify=Bp});var Rl=A(Ml=>{"use strict";var zn=Symbol("break visit"),$p=Symbol("skip children"),xl=Symbol("remove item");function Fe(s,e){"type"in s&&s.type==="document"&&(s={start:s.start,value:s.value}),ql(Object.freeze([]),s,e)}Fe.BREAK=zn;Fe.SKIP=$p;Fe.REMOVE=xl;Fe.itemAtPath=(s,e)=>{let t=s;for(let[i,n]of e){let r=t?.[i];if(r&&"items"in r)t=r.items[n];else return}return t};Fe.parentCollection=(s,e)=>{let t=Fe.itemAtPath(s,e.slice(0,-1)),i=e[e.length-1][0],n=t?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function ql(s,e,t){let i=t(e,s);if(typeof i=="symbol")return i;for(let n of["key","value"]){let r=e[n];if(r&&"items"in r){for(let o=0;o<r.items.length;++o){let a=ql(Object.freeze(s.concat([[n,o]])),r.items[o],t);if(typeof a=="number")o=a-1;else{if(a===zn)return zn;a===xl&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,s))}}return typeof i=="function"?i(e,s):i}Ml.visit=Fe});var Ri=A(B=>{"use strict";var Zn=Il(),jp=kl(),Up=Rl(),er="\uFEFF",tr="",ir="",sr="",Kp=s=>!!s&&"items"in s,Vp=s=>!!s&&(s.type==="scalar"||s.type==="single-quoted-scalar"||s.type==="double-quoted-scalar"||s.type==="block-scalar");function Wp(s){switch(s){case er:return"<BOM>";case tr:return"<DOC>";case ir:return"<FLOW_END>";case sr:return"<SCALAR>";default:return JSON.stringify(s)}}function Hp(s){switch(s){case er:return"byte-order-mark";case tr:return"doc-mode";case ir:return"flow-error-end";case sr:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
`:case`\r
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(s[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}B.createScalarToken=Zn.createScalarToken;B.resolveAsScalar=Zn.resolveAsScalar;B.setScalarValue=Zn.setScalarValue;B.stringify=jp.stringify;B.visit=Up.visit;B.BOM=er;B.DOCUMENT=tr;B.FLOW_END=ir;B.SCALAR=sr;B.isCollection=Kp;B.isScalar=Vp;B.prettyToken=Wp;B.tokenType=Hp});var or=A($l=>{"use strict";var Ft=Ri();function H(s){switch(s){case void 0:case" ":case`
`:case"\r":case" ":return!0;default:return!1}}var Bl=new Set("0123456789ABCDEFabcdef"),Yp=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Bi=new Set(",[]{}"),Gp=new Set(` ,[]{}
\r `),nr=s=>!s||Gp.has(s),rr=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,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 i=this.next??"stream";for(;i&&(t||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
`?!0:t==="\r"?this.buffer[e+1]===`
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let i=0;for(;t===" ";)t=this.buffer[++i+e];if(t==="\r"){let n=this.buffer[i+e+1];if(n===`
`||!n&&!this.atEnd)return e+i+1}return t===`
`||i>=this.indentNext||!t&&!this.atEnd?e+i:-1}if(t==="-"||t==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&H(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ft.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,i=e.indexOf("#");for(;i!==-1;){let r=e[i-1];if(r===" "||r===" "){t=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let r=e[t-1];if(r===" "||r===" ")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 Ft.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==="...")&&H(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!H(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&H(t)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*this.parseBlockStart()}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(nr),"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,i=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=i=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&H(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ft.FLOW_END,yield*this.parseLineStart();let r=0;for(;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(nr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||H(o)||o===",")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==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let r=0;for(;this.buffer[t-1-r]==="\\";)r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}let i=this.buffer.substring(0,t),n=i.indexOf(`
`,this.pos);if(n!==-1){for(;n!==-1;){let r=this.continueScalar(n+1);if(r===-1)break;n=i.indexOf(`
`,r)}n!==-1&&(t=n-(i[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;for(;;){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=>H(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,i;e:for(let r=this.pos;i=this.buffer[r];++r)switch(i){case" ":t+=1;break;case`
`:e=r,t=0;break;case"\r":{let o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t: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(`
`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
`;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let r=e-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);let a=r;for(;o===" ";)o=this.buffer[--r];if(o===`
`&&r>=this.pos&&r+1+t>a)e=r;else break}while(!0);return yield Ft.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(H(r)||e&&Bi.has(r))break;t=i}else if(H(n)){let r=this.buffer[i+1];if(n==="\r"&&(r===`
`?(i+=1,n=`
`,r=this.buffer[i+1]):t=i),r==="#"||e&&Bi.has(r))break;if(n===`
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Bi.has(n))break;t=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ft.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(nr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(H(t)||e&&Bi.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!H(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];for(;t;)if(Yp.has(t))t=this.buffer[++e];else if(t==="%"&&Bl.has(this.buffer[e+1])&&Bl.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];return e===`
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,i;do i=this.buffer[++t];while(i===" "||e&&i===" ");let n=t-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=t),n}*pushUntil(e){let t=this.pos,i=this.buffer[t];for(;!e(i);)i=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};$l.Lexer=rr});var lr=A(jl=>{"use strict";var ar=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,i=this.lineStarts.length;for(;t<i;){let r=t+i>>1;this.lineStarts[r]<e?t=r+1:i=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}}}};jl.LineCounter=ar});var ur=A(Hl=>{"use strict";var Jp=require("node:process"),Ul=Ri(),Qp=or();function Ae(s,e){for(let t=0;t<s.length;++t)if(s[t].type===e)return!0;return!1}function Kl(s){for(let e=0;e<s.length;++e)switch(s[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Wl(s){switch(s?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function $i(s){switch(s.type){case"document":return s.start;case"block-map":{let e=s.items[s.items.length-1];return e.sep??e.start}case"block-seq":return s.items[s.items.length-1].start;default:return[]}}function $e(s){if(s.length===0)return[];let e=s.length;e:for(;--e>=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;s[++e]?.type==="space";);return s.splice(e,s.length)}function Vl(s){if(s.start.type==="flow-seq-start")for(let e of s.items)e.sep&&!e.value&&!Ae(e.start,"explicit-key-ind")&&!Ae(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Wl(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var cr=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Qp.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,t))yield*this.next(i);t||(yield*this.end())}*next(e){if(this.source=e,Jp.env.LOG_TOKENS&&console.log("|",Ul.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Ul.tokenType(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&(!e||e.type!=="doc-end")){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let 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 i=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in i?i.indent:0:t.type==="flow-collection"&&i.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Vl(t),i.type){case"document":i.value=t;break;case"block-scalar":i.props.push(t);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.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=i.items[i.items.length-1];n.value?i.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Kl(n.start)===-1&&(t.indent===0||n.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(i.type==="document"?i.end=n.start:i.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:[]};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":{Kl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):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=$i(this.peek(2)),i=$e(t),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,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(`
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
`,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 i="end"in t.value?t.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):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)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let o=[];for(let a=0;a<t.sep.length;++a){let l=t.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):n||t.value?(r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)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(Wl(t.key)&&!Ae(t.sep,"newline")){let o=$e(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(Ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=$e(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:r,key:null,sep:[this.sourceToken]}):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]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||t.value?(e.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){i&&o.type!=="block-seq"&&e.items.push({start:r}),this.stack.push(o);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 i="end"in t.value?t.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):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)){Array.prototype.push.apply(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;t.value||Ae(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i&&i.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=$i(i),r=$e(n);Vl(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
`,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=$i(e),i=$e(t);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=$i(e),i=$e(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Hl.Parser=cr});var Xl=A(Pt=>{"use strict";var Yl=Qn(),Xp=mt(),At=wt(),zp=Ys(),Zp=L(),ed=lr(),Gl=ur();function Jl(s){let e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new ed.LineCounter||null,prettyErrors:e}}function td(s,e={}){let{lineCounter:t,prettyErrors:i}=Jl(e),n=new Gl.Parser(t?.addNewLine),r=new Yl.Composer(e),o=Array.from(r.compose(n.parse(s)));if(i&&t)for(let a of o)a.errors.forEach(At.prettifyError(s,t)),a.warnings.forEach(At.prettifyError(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function Ql(s,e={}){let{lineCounter:t,prettyErrors:i}=Jl(e),n=new Gl.Parser(t?.addNewLine),r=new Yl.Composer(e),o=null;for(let a of r.compose(n.parse(s),!0,s.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new At.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&t&&(o.errors.forEach(At.prettifyError(s,t)),o.warnings.forEach(At.prettifyError(s,t))),o}function id(s,e,t){let i;typeof e=="function"?i=e:t===void 0&&e&&typeof e=="object"&&(t=e);let n=Ql(s,t);if(!n)return null;if(n.warnings.forEach(r=>zp.warn(n.options.logLevel,r)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},t))}function sd(s,e,t){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let n=Math.round(t);t=n<1?void 0:n>8?{indent:8}:{indent:n}}if(s===void 0){let{keepUndefined:n}=t??e??{};if(!n)return}return Zp.isDocument(s)&&!i?s.toString(t):new Xp.Document(s,i,t).toString(t)}Pt.parse=id;Pt.parseAllDocuments=td;Pt.parseDocument=Ql;Pt.stringify=sd});var Zl=A(_=>{"use strict";var nd=Qn(),rd=mt(),od=Nn(),fr=wt(),ad=Ze(),fe=L(),ld=ae(),cd=O(),ud=ce(),fd=ue(),hd=Ri(),pd=or(),dd=lr(),gd=ur(),ji=Xl(),zl=Je();_.Composer=nd.Composer;_.Document=rd.Document;_.Schema=od.Schema;_.YAMLError=fr.YAMLError;_.YAMLParseError=fr.YAMLParseError;_.YAMLWarning=fr.YAMLWarning;_.Alias=ad.Alias;_.isAlias=fe.isAlias;_.isCollection=fe.isCollection;_.isDocument=fe.isDocument;_.isMap=fe.isMap;_.isNode=fe.isNode;_.isPair=fe.isPair;_.isScalar=fe.isScalar;_.isSeq=fe.isSeq;_.Pair=ld.Pair;_.Scalar=cd.Scalar;_.YAMLMap=ud.YAMLMap;_.YAMLSeq=fd.YAMLSeq;_.CST=hd;_.Lexer=pd.Lexer;_.LineCounter=dd.LineCounter;_.Parser=gd.Parser;_.parse=ji.parse;_.parseAllDocuments=ji.parseAllDocuments;_.parseDocument=ji.parseDocument;_.stringify=ji.stringify;_.visit=zl.visit;_.visitAsync=zl.visitAsync});var Dc=require("commander");var Ar=pe(require("node:crypto")),D=pe(require("node:fs")),de=pe(require("node:os")),T=pe(require("node:path")),ns=pe(require("node:url"));global.nodeCrypto=Ar.default;var kt=null;try{let s=T.default.join(__dirname,"btime",process.platform+"-"+process.arch);kt=require(T.default.join(s,"btime.node")).btime}catch{}function Pr(){return kt!==null}function Dr(s,e){if(!kt)return;let t=Buffer.alloc(Buffer.byteLength(s,"utf-8")+1);t.write(s,0,t.length-1,"utf-8"),t[t.length-1]=0,kt(t,e)}var rs=["image","audio","video","pdf","unsupported"],Le=["image","audio","pdf","video"],os=["app","appearance","appearance-data","hotkey","core-plugin","core-plugin-data","community-plugin","community-plugin-data"],as=["app","appearance","appearance-data","hotkey","core-plugin","core-plugin-data"];var Tr="obsidian-headless",ge=de.default.platform()==="linux"?T.default.join(process.env.XDG_CONFIG_HOME||T.default.join(de.default.homedir(),".config"),Tr):T.default.join(de.default.homedir(),"."+Tr),Lr="OBSIDIAN_AUTH_TOKEN",ls=T.default.join(ge,"auth_token");function Ke(){if(process.env[Lr])return process.env[Lr];try{return D.default.readFileSync(ls,"utf8")}catch{return null}}function _r(s){D.default.existsSync(ge)||D.default.mkdirSync(ge,{recursive:!0,mode:448}),D.default.writeFileSync(ls,s,{mode:384})}function cs(){D.default.rmSync(ls,{force:!0})}function Ve(s){return T.default.join(ge,"sync",s)}function Nr(s){return T.default.join(Ve(s),"state.db")}function Cr(s){return T.default.join(Ve(s),"sync.log")}function Ir(s){return T.default.join(Ve(s),"config.json")}function us(s){let e=Ve(s);return D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0,mode:448}),e}function fs(s){let e=Ir(s);if(!D.default.existsSync(e))return null;try{let t=D.default.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return null}}function hs(s,e){us(s);let t=Ir(s);D.default.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function Or(s,e){return T.default.join(s,e,".sync.lock")}function kr(s){let e=Ve(s);D.default.existsSync(e)&&D.default.rmSync(e,{recursive:!0,force:!0})}function ps(){let s=T.default.join(ge,"sync");if(!D.default.existsSync(s))return[];let e=D.default.readdirSync(s,{withFileTypes:!0}),t=[];for(let i of e)if(i.isDirectory()){let n=T.default.join(s,i.name,"config.json");D.default.existsSync(n)&&t.push(i.name)}return t}function We(s){let e=T.default.resolve(s),t=ps();for(let i of t){let n=fs(i);if(n&&T.default.resolve(n.vaultPath)===e)return n}return null}function xr(s){let e=s.split(",").map(t=>t.trim().toLowerCase());for(let t of e)if(!rs.includes(t))throw new Error(`Invalid file type: "${t}". Valid values: ${rs.join(", ")}`);return e}function qr(s){let e=s.split(",").map(t=>t.trim().toLowerCase());for(let t of e)if(!os.includes(t))throw new Error(`Invalid config: "${t}". Valid values: ${os.join(", ")}`);return e}function ds(s){if(s){if(!s.startsWith(".")||s.includes("/")||s.includes("\\"))throw new Error(`Invalid config directory: "${s}". Must be a dotfolder name (e.g. .obsidian).`);return s}}function xt(s){return T.default.join(ge,"publish",s)}function Mr(s){return T.default.join(xt(s),"config.json")}function gs(s){return T.default.join(xt(s),"cache.json")}function ms(s){let e=xt(s);return D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0,mode:448}),e}function qc(s){let e=Mr(s);if(!D.default.existsSync(e))return null;try{let t=D.default.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return null}}function ys(s,e){ms(s);let t=Mr(s);D.default.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function Rr(s){let e=xt(s);D.default.existsSync(e)&&D.default.rmSync(e,{recursive:!0,force:!0})}function Mc(){let s=T.default.join(ge,"publish");if(!D.default.existsSync(s))return[];let e=D.default.readdirSync(s,{withFileTypes:!0}),t=[];for(let i of e)if(i.isDirectory()){let n=T.default.join(s,i.name,"config.json");D.default.existsSync(n)&&t.push(i.name)}return t}function qt(s){let e=T.default.resolve(s),t=Mc();for(let i of t){let n=qc(i);if(n&&T.default.resolve(n.vaultPath)===e)return n}return null}function bs(){let s=de.default.hostname(),e=de.default.platform();return`${s} (${e==="darwin"?"macOS":e==="win32"?"Windows":e==="linux"?"Linux":e})`}function Br(s){let e=T.default.dirname(s);D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0});let t=D.default.createWriteStream(s,{flags:"a"}),i=console.log,n=console.warn,r=console.error,o=console.debug;function a(...l){let c=new Date().toISOString(),f=l.map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(" ");t.write(`[${c}] ${f}
`)}return console.log=(...l)=>{i(...l),a(...l)},console.warn=(...l)=>{n(...l),a(...l)},console.error=(...l)=>{r(...l),a(...l)},console.debug=(...l)=>{o(...l),a(...l)},()=>{console.log=i,console.warn=n,console.error=r,console.debug=o,t.end()}}var Mt=fetch,$r="https://"+["api","obsidian","md"].join("."),Rc="https://publish.obsidian.md",He=class s extends Error{constructor(e){super(e.error),this.response=e,this.error=e.error,Object.setPrototypeOf(this,s.prototype)}};async function X(s,e,t){let{preflight:i,headers:n}=t||{};i&&await Mt($r+s,{method:"OPTIONS"}),n||(n={}),n["Content-Type"]="application/json";let r=await(await Mt($r+s,{method:"POST",body:JSON.stringify(e),headers:n})).json();if("error"in r)throw new He(r);return r}async function ws(s,e,t){return X("/user/signin",{email:s,password:e,mfa:t},{preflight:!0,headers:{Origin:"https://obsidian.md"}})}function Ss(s){return X("/user/signout",{token:s})}function jr(s){return X("/user/info",{token:s})}function Ur(s,e){return X("/vault/regions",{token:s,host:e})}function vs(s,e){return X("/vault/list",{token:s,supported_encryption_version:e})}function Kr(s,e,t,i,n,r){return X("/vault/create",{token:s,name:e,keyhash:t,salt:i,region:n,encryption_version:r})}function Vr(s,e,t,i,n){return X("/vault/access",{token:s,vault_uid:e,keyhash:t,host:i,encryption_version:n})}function Es(s){return X("/publish/list",{token:s})}function Wr(s){return X("/publish/create",{token:s})}var Rt=class s extends Error{constructor(e,t){super(t),this.name="RequestError",this.code=e,Object.setPrototypeOf(this,s.prototype)}};async function Hr(s,e,t){let i=await(await Mt(s+e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json();if(i.code&&i.message)throw new Rt(i.code,i.message);return i}function Yr(s){return s.startsWith("127.0.0.1")||s.startsWith("localhost")?"http://"+s:"https://"+s}function Gr(s,e){return Hr(Rc,s,e)}function Jr(s,e,t,i){return Gr("/api/slug",{token:s,id:e,host:t,slug:i})}function Fs(s,e){return Gr("/api/slugs",{token:s,ids:e})}function Qr(s,e,t){return Hr(Yr(s),e,t)}function Xr(s,e,t){return Qr(e,"/api/list",{token:s,id:t,version:2})}function zr(s,e,t,i){return Qr(e,"/api/remove",{token:s,id:t,path:i})}async function Zr(s,e,t,i,n,r){let o=Yr(e)+"/api/upload",a=await(await Mt(o,{method:"POST",headers:{"obs-token":s,"obs-id":t,"obs-path":encodeURIComponent(i),"obs-hash":n,"Content-Type":"application/octet-stream"},body:r})).json();if(a.code&&a.message)throw new Rt(a.code,a.message);return a}var eo=["obsidian.css","publish.css","favicon.ico","publish.js"];var to=crypto,$=to.subtle,As="AES-GCM";function io(s){return $.importKey("raw",s,As,!1,["encrypt","decrypt"])}async function Bt(s,e,t){t||(t=to.getRandomValues(new Uint8Array(12)));let i=await $.encrypt({name:As,iv:t},e,s),n=new ArrayBuffer(t.byteLength+i.byteLength),r=new Uint8Array(n);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(i),t.byteLength),n}async function $t(s,e){if(s.byteLength<12)throw new Error("Encrypted data is bad");if(s.byteLength===12)return new ArrayBuffer(0);let t=new Uint8Array(s,0,12),i=new Uint8Array(s,12);return await $.decrypt({name:As,iv:t},e,i)}function Ye(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function U(s){return Ye(new TextEncoder().encode(s))}function me(s){return new TextDecoder().decode(new Uint8Array(s))}function so(s){let e=atob(s),t=e.length,i=new Uint8Array(t);for(let n=0;n<t;n++)i[n]=e.charCodeAt(n);return i.buffer}function no(s){return Bc(new Uint8Array(s))}function Bc(s){let e=[],t=s.byteLength;for(let i=0;i<t;i++)e.push(String.fromCharCode(s[i]));return btoa(e.join(""))}async function te(s){return Y(await Ge(s))}async function Ge(s){return $.digest("SHA-256",new Uint8Array(s))}function Ps(s){let e=s.length/2,t=new ArrayBuffer(e),i=new Uint8Array(t);for(let n=0;n<e;n++)i[n]=parseInt(s.substr(n*2,2),16);return t}function Y(s){let e=new Uint8Array(s),t=[];for(let i=0;i<e.length;i++){let n=e[i];t.push((n>>>4).toString(16)),t.push((n&15).toString(16))}return t.join("")}function Ds(s){if(s<=0)return"0 B";let e=["B","KB","MB","GB","TB","PB"],t=e.length-1,i=1024;for(let r=0;r<e.length;r++)if(s<Math.pow(i,r+1)){t=r;break}let n=s/Math.pow(i,t);return`${$c(n,t===0?0:2)} ${e[t]}`}function $c(s,e=2,t=".",i=","){let n=s<0?"-":"";s=Math.abs(s);let r=parseInt(s.toFixed(e),10)+"",o=r.length>3?r.length%3:0;return n+(o?r.substr(0,o)+i:"")+r.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+i)+(e?t+Math.abs(s-Math.floor(s)).toFixed(e).slice(2):"")}var jc=/\u00A0|\u202F/g;function Ts(s){return s.replace(jc," ")}function V(s){let e=s.lastIndexOf("/");return e===-1?s:s.slice(e+1)}function ye(s){let e=s.lastIndexOf("/");return e===-1?"":s.slice(0,e)}function Ls(s){for(;s;){if(V(s).startsWith("."))return!0;s=ye(s)}return!1}function ro(s){let e=V(s),t=e.lastIndexOf(".");return t===-1||t===e.length-1||t===0?e:e.substr(0,t)}function oo(s){let e=s.lastIndexOf(".");return e===-1||e===s.length-1||e===0?s:s.substr(0,e)}function j(s){let e=s.lastIndexOf(".");return e===-1||e===s.length-1||e===0?"":s.substr(e+1).toLowerCase()}function _e(s){return Ts(Ne(s)).normalize("NFC")}function Ne(s){return s=s.replace(/([\\/])+/g,"/").replace(/(^\/+|\/+$)/g,""),s===""&&(s="/"),s}var jt=["bmp","png","jpg","jpeg","gif","svg","webp","avif"],Ut=["mp3","wav","m4a","3gp","flac","ogg","oga","opus"],Kt=["mp4","webm","ogv","mov","mkv"],Vt=["pdf"],ao=["md"],_s=["canvas"],lo=["base"];var rg=ao.concat(_s,lo),Uc=[].concat(jt,Ut,Kt,Vt,ao,_s);function co(s){return Uc.includes(s)}var og=[...jt,...Ut,...Kt,...Vt,...lo,..._s];function ie(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function Ns(s){return Buffer.from(s)}var ec=pe(Zl()),Ui=class{constructor(e,t){this.cache={};this.token=e,this.config=t,this.loadCache()}async scanForChanges(e){let{config:t,token:i,cache:n}=this,r=[],o=await Xr(i,t.host,t.siteId),a={};for(let c of o.files)a[c.path]=c;let l=this.walkLocalFiles();for(let c of l){let f=n[c.path],u,h;if(f&&f.mtime===c.mtime&&f.size===c.size)u=f.publish,h=f.hash;else{let S=T.default.join(t.vaultPath,c.path),d;try{d=D.default.readFileSync(S)}catch{continue}u=T.default.extname(c.path).toLowerCase()===".md"?this.parseFrontmatterPublishFlag(d.toString("utf-8")):null,h=await te(ie(d)),n[c.path]={mtime:c.mtime,size:c.size,hash:h,publish:u}}if(u===null&&(u=this.getFolderPublishFlag(c.path)),u===!1)continue;u===null&&e&&(u=!0);let y=a[c.path];y?(h!==y.hash&&r.push({path:c.path,type:"changed"}),delete a[c.path]):u===!0&&r.push({path:c.path,type:"new"})}for(let c in a)r.push({path:c,type:"deleted"});return this.saveCache(),r}async uploadFile(e){let{config:t,token:i}=this,n=T.default.join(t.vaultPath,e),r=D.default.readFileSync(n);if(r.byteLength>52428800)throw new Error(`File exceeds 50MB upload limit: ${e}`);let o=ie(r),a=await te(o);await Zr(i,t.host,t.siteId,e,a,o)}async removeFile(e){let{config:t,token:i}=this;await zr(i,t.host,t.siteId,e)}async publish(e,t){let i=e.length,n=0;for(let r of e)r.type==="new"||r.type==="changed"?await this.uploadFile(r.path):r.type==="deleted"&&await this.removeFile(r.path),n++,t?.(n,i);this.saveCache()}walkLocalFiles(){let{config:e}=this,t=e.vaultPath,i=[],n=r=>{let o;try{o=D.default.readdirSync(T.default.join(t,r),{withFileTypes:!0})}catch{return}for(let a of o){let l=a.name;if(l.startsWith("."))continue;let c=r?r+"/"+l:l;if(a.isDirectory())n(c);else if(a.isFile()&&this.isFileSupported(l,c)){let f;try{f=D.default.statSync(T.default.join(t,c))}catch{continue}i.push({path:c,mtime:f.mtimeMs,size:f.size})}}};return n(""),i}isFileSupported(e,t){if(eo.includes(e))return!0;let i=T.default.extname(t);return i.startsWith(".")&&(i=i.slice(1)),co(i)}getFolderPublishFlag(e){let{config:t}=this;if(t.excludes){for(let i of t.excludes)if(e.startsWith(i+"/"))return!1}if(t.includes){for(let i of t.includes)if(e.startsWith(i+"/"))return!0}return null}parseFrontmatterPublishFlag(e){if(!e.startsWith("---"))return null;let t=e.indexOf(`
---`,3);if(t===-1)return null;let i=e.slice(4,t),n;try{n=(0,ec.parse)(i)}catch{return null}if(!n||typeof n!="object")return null;let r=n.publish;if(r==null)return null;if(typeof r=="string"){let o=r.toLowerCase();if(o==="false"||o==="no")return!1;if(o==="true"||o==="yes")return!0}return!!r}loadCache(){try{let e=D.default.readFileSync(gs(this.config.siteId),"utf-8");this.cache=JSON.parse(e)}catch{this.cache={}}}saveCache(){ms(this.config.siteId),D.default.writeFileSync(gs(this.config.siteId),JSON.stringify(this.cache))}};var Dt=()=>typeof activeWindow<"u"?activeWindow:global;function tc(s,e=0,t=!1){let i=null,n=null,r=null,o=0,a=0,l=Dt(),c=function(){let h=n,y=r;return n=null,r=null,s.apply(h,y)},f=function(){if(o){let h=Date.now();if(h<o){l=Dt(),i=l.setTimeout(f,o-h),o=0;return}}a=0,i=null,c()},u=function(...h){n=this,r=h;let y=Date.now();return i?t?o=a=y+e:l!==Dt()&&a<=y&&(l.clearTimeout(i),l=Dt(),i=l.setTimeout(f,0)):(l=Dt(),a=y+e,i=l.setTimeout(f,e)),u};return u.cancel=function(){return i&&(l.clearTimeout(i),i=null),u},u.run=function(){if(i)return l.clearTimeout(i),i=null,c()},u}var yd=5;function bd(s,e){if(e.isFile())return{type:"file",realpath:s,ctime:Math.round(e.birthtimeMs),mtime:Math.round(e.mtimeMs),size:e.size};if(e.isDirectory())return{type:"folder",realpath:s}}function hr(s){return{ctime:Math.round(s.birthtimeMs),mtime:Math.round(s.mtimeMs),size:s.size}}var ic=typeof process<"u"?process:null,sc=ic?ic.platform:"",nc=sc==="darwin",rc=sc==="win32",Ki=nc||rc,Vi=class{constructor(e,t,i,n,r,o,a){this.thingsHappening=tc(this.kill.bind(this),60*1e3,!0);this.resourcePathPrefix=o,this.basePath=a,this.fs=e,this.fsPromises=e.promises,this.path=t,this.url=i,this.trash=n,this.files={},this.promise=Promise.resolve(),this.watchers={},this.handler=null,this.btime=r,this.insensitive=nc||rc;try{this.testInsensitive()}catch(l){console.error(l)}}testInsensitive(){let{fs:e,path:t,basePath:i}=this,n=t.join(i,".OBSIDIANTEST"),r=t.join(i,".OBSIDIANTEST".toLowerCase());e.existsSync(n)&&e.unlinkSync(n),e.writeFileSync(n,"","utf8"),this.insensitive=e.existsSync(r),e.unlinkSync(n)}getName(){return this.path.basename(this.basePath)}getBasePath(){return this.basePath}async listAll(){this.files={},this.files["/"]={type:"folder",realpath:"/"},await this.listRecursive("")}async listRecursive(e){let t=this.getFullRealPath(e),i=await this.fsPromises.readdir(t);this.thingsHappening();let n=[];for(let r of i)n.push(this.listRecursiveChild(e,r));await Promise.all(n)}async listRecursiveChild(e,t){let i=Ne(e===""?t:e+"/"+t),n=_e(i);if(this.trigger("raw",n),Ls(n))return await this.reconcileDeletion(i,n);try{await this.reconcileFileInternal(i,n)}catch(r){if(r.code==="ENOENT")await this.reconcileDeletion(i,n,!0);else throw r}}mkdir(e){return this.queue(async()=>{let t=this.getFullPath(e);await this.fsPromises.mkdir(t,{recursive:!0}),await this.reconcileInternalFile(e)})}trashSystem(e){return this.queue(async()=>{let t=this.getFullPath(e);return this.trash(t)?(await this.reconcileInternalFile(e),!0):!1})}trashLocal(e){return this.queue(async()=>{let t=this.getFullPath(e),i=this.getFullPath(".trash");await this.fsPromises.mkdir(i,{recursive:!0});let n=this.path.extname(t),r=this.path.basename(t,n),o=this.path.join(i,r+n),a=1;for(;await this._exists(o);)a++,o=this.path.join(i,r+" "+a+n);await this.fsPromises.rename(t,o),await this.reconcileInternalFile(e)})}rmdir(e,t){return this.queue(async()=>{let i=this.getFullPath(e);await this.fsPromises.rm(i,{maxRetries:yd,recursive:t}),await this.reconcileInternalFile(e)})}read(e){return this.queue(async()=>{let t=this.getFullPath(e);try{return this.fsPromises.readFile(t,"utf8")}catch(i){throw this.queue(()=>this.reconcileInternalFile(e)),i}})}readBinary(e){return this.queue(async()=>{let t=this.getFullPath(e);try{let i=await this.fsPromises.readFile(t);return ie(i)}catch(i){throw this.queue(()=>this.reconcileInternalFile(e)),i}})}write(e,t,i){return this.queue(async()=>{let n=this.getFullPath(e);try{await this.fsPromises.writeFile(n,t,"utf8"),await this.applyWriteOptions(n,i)}finally{await this.reconcileInternalFile(e)}})}writeBinary(e,t,i){return this.queue(async()=>{let n=this.getFullPath(e),r=Ns(t);try{await this.fsPromises.writeFile(n,r),await this.applyWriteOptions(n,i)}finally{await this.reconcileInternalFile(e)}})}append(e,t,i){return this.queue(async()=>{let n=this.getFullPath(e);try{await this.fsPromises.appendFile(n,t,"utf8"),await this.applyWriteOptions(n,i)}finally{await this.reconcileInternalFile(e)}})}appendBinary(e,t,i){return this.queue(async()=>{let n=this.getFullPath(e),r=Ns(t);try{await this.fsPromises.appendFile(n,r),await this.applyWriteOptions(n,i)}finally{await this.reconcileInternalFile(e)}})}process(e,t,i){return this.queue(async()=>{let n=this.getFullPath(e),r=await this.fsPromises.readFile(n,"utf8"),o=t(r);if(o===r)return r;try{await this.fsPromises.writeFile(n,o,"utf8"),await this.applyWriteOptions(n,i)}finally{await this.reconcileInternalFile(e)}return o})}async applyWriteOptions(e,t){if(!t)return;let{ctime:i,mtime:n,immediate:r}=t;i&&this.btime(e,i),n&&await this.fsPromises.utimes(e,n/1e3,n/1e3),r&&r()}getResourcePath(e){let t=this.getFullPath(e),i=0,n=this.files[e];n&&n.type==="file"&&(i=n.mtime),i||(i=Date.now());let r=this.url.pathToFileURL(t).href;return r.startsWith("file:///")?r=r.substring(8):r.startsWith("file://")&&(r="%5C%5C"+r.substring(7)),this.resourcePathPrefix+r+"?"+i}getFilePath(e){let t=this.getFullPath(e);return this.url.pathToFileURL(t).toString()}remove(e){return this.queue(async()=>{let t=this.getFullPath(e);await this.fsPromises.unlink(t),await this.reconcileInternalFile(e)})}update(e){return this.queue(async()=>{await this.reconcileInternalFile(e)})}async rename(e,t){e!==t&&await this.queue(async()=>{let i=this.getFullPath(e),n=this.getFullPath(t);if(await this._exists(n,!1)&&!(this.insensitive&&e.toLowerCase()===t.toLowerCase()))throw new Error("Destination file already exists!");let r=this.files[e],o=r?r.realpath:null;if(await this.fsPromises.rename(i,n),!r)return;delete this.files[e];let a=this.getRealPath(t);if(r.realpath=a,this.files[t]=r,this.trigger("renamed",t,e),r.type==="folder"&&this.watchers.hasOwnProperty(e)&&(this.stopWatchPath(e),await this.startWatchPath(t)),r.type==="folder"){for(let c in this.files)if(this.files.hasOwnProperty(c)&&c.startsWith(e+"/")){let f=c.slice(e.length),u=t+f,h=this.files[c];delete this.files[c];let y=h.realpath.slice(o.length);h.realpath=a+y,this.files[u]=h,this.trigger("renamed",u,c)}}})}async copyRecursive(e,t){let i=await this.fsPromises.stat(e);if(i.isFile()&&await this.fsPromises.copyFile(e,t,this.fs.constants.COPYFILE_EXCL),i.isDirectory()){await this.fsPromises.mkdir(t,{recursive:!0});let n=await this.fsPromises.readdir(e);for(let r of n){let o=this.path.join(e,r),a=this.path.join(t,r);await this.copyRecursive(o,a)}}}async copy(e,t){await this.queue(async()=>{let i=this.getFullPath(e),n=this.getFullPath(t);await this.copyRecursive(i,n),await this.reconcileInternalFile(t)})}async exists(e,t){return this.queue(()=>{let i=this.getFullPath(e);return this._exists(i,t)})}async _exists(e,t){try{await this.fsPromises.access(e)}catch{return!1}if(t&&this.insensitive){let i=this.path.dirname(e),n=this.path.basename(e);if((await this.fsPromises.readdir(i)).indexOf(n)===-1)return!1}return!0}async stat(e){return this.queue(async()=>{let t=this.getFullPath(e);try{let i=await this.fsPromises.stat(t);if(i.isFile())return{type:"file",...hr(i)};if(i.isDirectory())return{type:"folder",...hr(i)}}catch(i){if(i.code!=="ENOENT")throw i}return null})}async list(e){return this.queue(async()=>{let t=this.getFullPath(e),i=await this.fsPromises.readdir(t),n={folders:[],files:[]};for(let r of i){let o=Ne(e===""?r:e+"/"+r),a=_e(o),l=await this.fsPromises.stat(this.getFullRealPath(o));l.isFile()&&n.files.push(a),l.isDirectory()&&n.folders.push(a)}return n})}async watch(e){return this.stopWatch(),this.handler=e,await this.startWatchPath("/"),this.queue(()=>this.listAll())}async watchHiddenRecursive(e){if(!Ki)try{let t=this.getFullRealPath(e),i=await this.fsPromises.readdir(t);await this.startWatchPath(e);for(let n of i)try{let r=Ne(e===""?n:e+"/"+n),o=this.getFullRealPath(r);(await this.fsPromises.lstat(o)).isDirectory()&&await this.watchHiddenRecursive(r)}catch{}}catch{}}stopWatch(){for(let e in this.watchers)this.watchers.hasOwnProperty(e)&&this.stopWatchPath(e);this.handler=null}async startWatchPath(e){let t=this.getRealPath(e);if(this.watchers[e])return;let i=this.getFullPath(e),n=i;try{n=await this.fsPromises.realpath(i)}catch(o){o.code!=="ENOENT"&&console.error(o)}let r=this.fs.watch(i,{persistent:!1,encoding:"utf8",recursive:Ki});r.on("change",(o,a)=>{let l=t==="/"?a:t+"/"+a;this.onFileChange(l)}),r.on("error",()=>{this.onFileChange(t)}),this.watchers[e]={watcher:r,resolvedPath:n}}stopWatchPath(e){let t=this.watchers[e];t&&(t.watcher.close(),delete this.watchers[e])}onFileChange(e){e&&(e=Ne(e),setTimeout(()=>{let t=_e(e);this.queue(()=>this.reconcileFile(e,t,!1))},0))}async reconcileInternalFile(e){return this.reconcileFile(this.getRealPath(e),e)}async reconcileFile(e,t,i=!0){if(this.trigger("raw",t),Ls(t))return await this.reconcileDeletion(e,t,i);let n=ye(t);n&&n!=="/"&&(this.files[t]||await this.reconcileFile(ye(e),n,i));try{let r=this.getFullRealPath(e);if(this.insensitive){let o=this.path.dirname(r),a=this.path.basename(t),l=await this.fsPromises.readdir(o);if(l=l.map(c=>Ts(c).normalize("NFC")),l.indexOf(a)===-1)return await this.reconcileDeletion(e,t,i)}await this.reconcileFileInternal(e,t)}catch(r){r.code==="ENOENT"?await this.reconcileDeletion(e,t,i):console.error(r)}}async reconcileFileInternal(e,t){let i=this.getFullRealPath(e),n=await this.fsPromises.lstat(i);n.isFile()?await this.reconcileFileCreation(e,t,n):n.isDirectory()?await this.reconcileFolderCreation(e,t):n.isSymbolicLink()&&await this.reconcileSymbolicLinkCreation(e,t)}async reconcileFileCreation(e,t,i){let n=hr(i),r=this.files[t];if(r)if(r.realpath=e,r.type==="file"){(r.mtime!==Math.round(i.mtimeMs)||r.size!==i.size)&&(r.mtime=Math.round(i.mtimeMs),r.size=i.size,this.trigger("raw",t,t,n),this.trigger("modified",t,t,n));return}else this.removeFile(t);this.files[t]=bd(e,i),this.trigger("file-created",t,t,n)}async reconcileFolderCreation(e,t){this.files.hasOwnProperty(t)?this.files[t].realpath=e:(this.files[t]={type:"folder",realpath:e},this.trigger("folder-created",t),Ki||await this.startWatchPath(t),await this.listRecursive(e))}async reconcileSymbolicLinkCreation(e,t){let i=this.getFullRealPath(e),n;try{n=await this.fsPromises.realpath(i)}catch{return}let r=this.path.sep,o=this.watchers;if(o.hasOwnProperty(t))o[t].resolvedPath=n;else for(let l in o)if(o.hasOwnProperty(l)&&l!==t){let c=o[l].resolvedPath;if(n===c||c.startsWith(n+r)||n.startsWith(c+r))return}let a=await this.fsPromises.stat(i);a.isFile()?await this.reconcileFileCreation(e,t,a):a.isDirectory()&&(Ki&&await this.startWatchPath(t),await this.reconcileFolderCreation(e,t))}async reconcileDeletion(e,t,i=!0){if(t==="/"){this.trigger("closed",t);return}this.stopWatchPath(t);let n=this.files[t];if(n){if(!i){setTimeout(()=>{this.queue(()=>this.reconcileFile(e,t))},100);return}if(n.type==="folder")for(let r in this.files)this.files.hasOwnProperty(r)&&r.startsWith(t+"/")&&this.removeFile(r);this.removeFile(t)}}trigger(e,t,i,n){this.handler&&this.handler(e,t,i,n)}getRealPath(e){let t=e;for(;t;){if(this.files.hasOwnProperty(t)){let i=e.substr(t.length);return this.files[t].realpath+i}t=ye(t)}return e}getFullPath(e){let t=this.getRealPath(e);return this.getFullRealPath(t)}getFullRealPath(e){return this.path.join(this.basePath,e)}kill(){this.killLastAction&&(this.killLastAction(new Error("File system operation timed out.")),this.killLastAction=null)}queue(e){let t=()=>{let n=new Promise((r,o)=>this.killLastAction=o);return this.thingsHappening(),Promise.race([n,e()])},i=this.promise.then(t,t);return this.promise=i,i}removeFile(e){let t=this.files[e];delete this.files[e],t&&(t.type==="file"?this.trigger("file-removed",e):t.type==="folder"&&this.trigger("folder-removed",e))}static async readLocalFile(e){let t=require;if(t){let i=t("fs");return ie(await i.promises.readFile(e))}return null}static async mkdir(e){let t=require;return t?await t("fs").promises.mkdir(e,{recursive:!0}):null}};var oc=pe(require("better-sqlite3"));var wd=1,Wi=class{constructor(e){let t=T.default.dirname(e);D.default.existsSync(t)||D.default.mkdirSync(t,{recursive:!0}),this.db=new oc.default(e),this.db.pragma("journal_mode = WAL"),this.db.exec("CREATE TABLE IF NOT EXISTS meta (key TEXT PRIMARY KEY, value TEXT );"),this.db.exec("CREATE TABLE IF NOT EXISTS local_files (path TEXT PRIMARY KEY, data TEXT NOT NULL);"),this.db.exec("CREATE TABLE IF NOT EXISTS server_files (path TEXT PRIMARY KEY, data TEXT NOT NULL);"),this.db.exec("CREATE TABLE IF NOT EXISTS pending_files (uid INTEGER PRIMARY KEY, path TEXT, data TEXT NOT NULL)"),this.stmts={getMeta:this.db.prepare("SELECT value FROM meta WHERE key = ?"),setMeta:this.db.prepare("INSERT OR REPLACE INTO meta (key, value) VALUES (?, ?)"),getLocalFile:this.db.prepare("SELECT data FROM local_files WHERE path = ?"),setLocalFile:this.db.prepare("INSERT OR REPLACE INTO local_files (path, data) VALUES (?, ?)"),deleteLocalFile:this.db.prepare("DELETE FROM local_files WHERE path = ?"),getAllLocalFiles:this.db.prepare("SELECT path, data FROM local_files"),getServerFile:this.db.prepare("SELECT data FROM server_files WHERE path = ?"),setServerFile:this.db.prepare("INSERT OR REPLACE INTO server_files (path, data) VALUES (?, ?)"),deleteServerFile:this.db.prepare("DELETE FROM server_files WHERE path = ?"),getAllServerFiles:this.db.prepare("SELECT path, data FROM server_files"),addPendingFile:this.db.prepare("INSERT OR REPLACE INTO pending_files (uid, path, data) VALUES (?, ?, ?)"),deletePendingFile:this.db.prepare("DELETE FROM pending_files WHERE path = ?"),getPendingFiles:this.db.prepare("SELECT data FROM pending_files ORDER BY uid")},this.getMetaValue("schema_version")===null&&this.setMetaValue("schema_version",String(wd))}getMetaValue(e){let t=this.stmts.getMeta.get(e);return t?t.value:null}setMetaValue(e,t){this.stmts.setMeta.run(e,t)}getVersion(){let e=this.getMetaValue("version"),t=e?parseInt(e,10):0;return isNaN(t)&&(t=0),t}setVersion(e){this.setMetaValue("version",String(e))}isInitial(){return this.getMetaValue("initial")!=="false"}setInitial(e){this.setMetaValue("initial",e?"true":"false")}getLocalFile(e){let t=this.stmts.getLocalFile.get(e);if(!t)return null;try{return JSON.parse(t.data)}catch{return null}}setLocalFile(e){this.stmts.setLocalFile.run(e.path,JSON.stringify(e))}deleteLocalFile(e){this.stmts.deleteLocalFile.run(e)}getAllLocalFiles(){let e=this.stmts.getAllLocalFiles.all(),t={};for(let i of e)try{t[i.path]=JSON.parse(i.data)}catch{}return t}getServerFile(e){let t=this.stmts.getServerFile.get(e);if(!t)return null;try{return JSON.parse(t.data)}catch{return null}}setServerFile(e){this.stmts.setServerFile.run(e.path,JSON.stringify(e))}deleteServerFile(e){this.stmts.deleteServerFile.run(e)}getAllServerFiles(){let e=this.stmts.getAllServerFiles.all(),t={};for(let i of e)try{t[i.path]=JSON.parse(i.data)}catch{}return t}addPendingFile(e){this.stmts.addPendingFile.run(e.uid,e.path,JSON.stringify(e))}deletePendingFile(e){this.stmts.deletePendingFile.run(e)}getPendingFiles(){let e=this.stmts.getPendingFiles.all(),t=[];for(let i of e)try{t.push(JSON.parse(i.data))}catch{}return t}close(){this.db.open&&this.db.close()}};var ac=/[^a-zA-Z0-9]/,lc=/\s/,cc=/[\r\n]/,Sd=/\n\r?\n$/,vd=/^\r?\n\r?\n/;function Pe(s,e){return s<e?s:e}function De(s,e){return s>e?s:e}var Ed=/\W/;function Fd(s,e){let t=s.length;for(let i=e;i<t;i+=1)if(Ed.test(s[i]))return i;return-1}function Ad(s,e){let t=0,i=-1;for(;i<s.length-1;)if(i=Fd(s,t),i!==-1){if(t!==i){let r=s.substring(t,i);e(r)}let n=s[i];e(n),t=i+1}else{let n=s.substring(t,s.length);e(n),i=s.length;break}}var Hi=class{constructor(){this.diffTimeout=1;this.diffEditCost=4;this.matchThreshold=.5;this.matchDistance=1e3;this.patchDeleteThreshold=.5;this.patchMargin=4;this.matchMaxBits=32}diff_main(e,t,i,n){typeof n>"u"&&(this.diffTimeout<=0?n=Number.MAX_VALUE:n=Date.now()+this.diffTimeout*1e3);let r=n;if(e==null||t==null)throw new Error("Null input. (diff_main)");if(e===t)return e?[[0,e]]:[];typeof i>"u"&&(i=!0);let o=i,a=this.diff_commonPrefix(e,t),l=e.substring(0,a);e=e.substring(a),t=t.substring(a),a=this.diff_commonSuffix(e,t);let c=e.substring(e.length-a);e=e.substring(0,e.length-a),t=t.substring(0,t.length-a);let f=this.diff_compute_(e,t,o,r);return l&&f.unshift([0,l]),c&&f.push([0,c]),this.diff_cleanupMerge(f),f}diff_lineMode(e,t){let{chars1:i,chars2:n,lineArray:r}=this.diff_linesToChars_(e,t),o=this.diff_main(i,n,!1);return this.diff_charsToLines_(o,r),o}diff_wordMode(e,t){let{chars1:i,chars2:n,lineArray:r}=this.diff_wordsToChars_(e,t),o=this.diff_main(i,n,!1);return this.diff_charsToLines_(o,r),o}diff_wordsToChars_(e,t){let i=[],n={};i[0]="";let r=l=>{let c="",f=i.length;return Ad(l,u=>{(n.hasOwnProperty?n.hasOwnProperty(u):n[u]!==void 0)?c+=String.fromCharCode(n[u]):(c+=String.fromCharCode(f),n[u]=f,i[f++]=u)}),c},o=r(e),a=r(t);return{chars1:o,chars2:a,lineArray:i}}diff_commonPrefix(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;let i=0,n=Pe(e.length,t.length),r=n,o=0;for(;i<r;)e.substring(o,r)===t.substring(o,r)?(i=r,o=i):n=r,r=Math.floor((n-i)/2+i);return r}diff_commonSuffix(e,t){if(!e||!t||e.charAt(e.length-1)!==t.charAt(t.length-1))return 0;let i=0,n=Pe(e.length,t.length),r=n,o=0;for(;i<r;)e.substring(e.length-r,e.length-o)===t.substring(t.length-r,t.length-o)?(i=r,o=i):n=r,r=Math.floor((n-i)/2+i);return r}diff_cleanupSemantic(e){let t=!1,i=[],n=0,r=null,o=0,a=0,l=0,c=0,f=0;for(;o<e.length;)e[o][0]===0?(i[n++]=o,a=c,l=f,c=0,f=0,r=e[o][1]):(e[o][0]===1?c+=e[o][1].length:f+=e[o][1].length,r&&r.length<=De(a,l)&&r.length<=De(c,f)&&(e.splice(i[n-1],0,[-1,r]),e[i[n-1]+1][0]=1,n--,n--,o=n>0?i[n-1]:-1,a=0,l=0,c=0,f=0,r=null,t=!0)),o++;for(t&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),o=1;o<e.length;){if(e[o-1][0]===-1&&e[o][0]===1){let u=e[o-1][1],h=e[o][1],y=this.diff_commonOverlap_(u,h),S=this.diff_commonOverlap_(h,u);y>=S?(y>=u.length/2||y>=h.length/2)&&(e.splice(o,0,[0,h.substring(0,y)]),e[o-1][1]=u.substring(0,u.length-y),e[o+1][1]=h.substring(y),o++):(S>=u.length/2||S>=h.length/2)&&(e.splice(o,0,[0,u.substring(0,S)]),e[o-1][0]=1,e[o-1][1]=h.substring(0,h.length-S),e[o+1][0]=-1,e[o+1][1]=u.substring(S),o++),o++}o++}}diff_cleanupSemanticLossless(e){let t=1;for(;t<e.length-1;){if(e[t-1][0]===0&&e[t+1][0]===0){let i=e[t-1][1],n=e[t][1],r=e[t+1][1],o=this.diff_commonSuffix(i,n);if(o){let u=n.substring(n.length-o);i=i.substring(0,i.length-o),n=u+n.substring(0,n.length-o),r=u+r}let a=i,l=n,c=r,f=this.diff_cleanupSemanticScore_(i,n)+this.diff_cleanupSemanticScore_(n,r);for(;n.charAt(0)===r.charAt(0);){i+=n.charAt(0),n=n.substring(1)+r.charAt(0),r=r.substring(1);let u=this.diff_cleanupSemanticScore_(i,n)+this.diff_cleanupSemanticScore_(n,r);u>=f&&(f=u,a=i,l=n,c=r)}e[t-1][1]!==a&&(a?e[t-1][1]=a:(e.splice(t-1,1),t--),e[t][1]=l,c?e[t+1][1]=c:(e.splice(t+1,1),t--))}t++}}diff_cleanupEfficiency(e){let t=!1,i=[],n=0,r=null,o=0,a=!1,l=!1,c=!1,f=!1;for(;o<e.length;)e[o][0]===0?(e[o][1].length<this.diffEditCost&&(c||f)?(i[n++]=o,a=c,l=f,r=e[o][1]):(n=0,r=null),c=f=!1):(e[o][0]===-1?f=!0:c=!0,r&&(a&&l&&c&&f||r.length<this.diffEditCost/2&&Number(a)+Number(l)+Number(c)+Number(f)===3)&&(e.splice(i[n-1],0,[-1,r]),e[i[n-1]+1][0]=1,n--,r=null,a&&l?(c=f=!0,n=0):(n--,o=n>0?i[n-1]:-1,c=f=!1),t=!0)),o++;t&&this.diff_cleanupMerge(e)}diff_cleanupMerge(e){e.push([0,""]);let t=0,i=0,n=0,r="",o="",a;for(;t<e.length;)switch(e[t][0]){case 1:n++,o+=e[t][1],t++;break;case-1:i++,r+=e[t][1],t++;break;case 0:i+n>1?(i!==0&&n!==0&&(a=this.diff_commonPrefix(o,r),a!==0&&(t-i-n>0&&e[t-i-n-1][0]===0?e[t-i-n-1][1]+=o.substring(0,a):(e.splice(0,0,[0,o.substring(0,a)]),t++),o=o.substring(a),r=r.substring(a)),a=this.diff_commonSuffix(o,r),a!==0&&(e[t][1]=o.substring(o.length-a)+e[t][1],o=o.substring(0,o.length-a),r=r.substring(0,r.length-a))),t-=i+n,e.splice(t,i+n),r.length&&(e.splice(t,0,[-1,r]),t++),o.length&&(e.splice(t,0,[1,o]),t++),t++):t!==0&&e[t-1][0]===0?(e[t-1][1]+=e[t][1],e.splice(t,1)):t++,n=0,i=0,r="",o="";break}e[e.length-1][1]===""&&e.pop();let l=!1;for(t=1;t<e.length-1;)e[t-1][0]===0&&e[t+1][0]===0&&(e[t][1].substring(e[t][1].length-e[t-1][1].length)===e[t-1][1]?(e[t][1]=e[t-1][1]+e[t][1].substring(0,e[t][1].length-e[t-1][1].length),e[t+1][1]=e[t-1][1]+e[t+1][1],e.splice(t-1,1),l=!0):e[t][1].substring(0,e[t+1][1].length)===e[t+1][1]&&(e[t-1][1]+=e[t+1][1],e[t][1]=e[t][1].substring(e[t+1][1].length)+e[t+1][1],e.splice(t+1,1),l=!0)),t++;l&&this.diff_cleanupMerge(e)}diff_xIndex(e,t){let i=0,n=0,r=0,o=0,a;for(a=0;a<e.length&&(e[a][0]!==1&&(i+=e[a][1].length),e[a][0]!==-1&&(n+=e[a][1].length),!(i>t));a++)r=i,o=n;return e.length!==a&&e[a][0]===-1?o:o+(t-r)}diff_prettyHtml(e){let t=[],i=/&/g,n=/</g,r=/>/g,o=/\n/g;for(let a=0;a<e.length;a++){let l=e[a][0],f=e[a][1].replace(i,"&").replace(n,"<").replace(r,">").replace(o,"¶<br>");switch(l){case 1:t[a]='<ins style="background:#e6ffe6;">'+f+"</ins>";break;case-1:t[a]='<del style="background:#ffe6e6;">'+f+"</del>";break;case 0:t[a]="<span>"+f+"</span>";break}}return t.join("")}diff_text1(e){let t=[];for(let i=0;i<e.length;i++)e[i][0]!==1&&(t[i]=e[i][1]);return t.join("")}diff_text2(e){let t=[];for(let i=0;i<e.length;i++)e[i][0]!==-1&&(t[i]=e[i][1]);return t.join("")}diff_levenshtein(e){let t=0,i=0,n=0;for(let r=0;r<e.length;r++){let o=e[r][0],a=e[r][1];switch(o){case 1:i+=a.length;break;case-1:n+=a.length;break;case 0:t+=De(i,n),i=0,n=0;break}}return t+=De(i,n),t}diff_toDelta(e){let t=[];for(let i=0;i<e.length;i++)switch(e[i][0]){case 1:t[i]="+"+encodeURI(e[i][1]);break;case-1:t[i]="-"+e[i][1].length;break;case 0:t[i]="="+e[i][1].length;break}return t.join(" ").replace(/%20/g," ")}diff_fromDelta(e,t){let i=[],n=0,r=0,o=t.split(/\t/g);for(let a=0;a<o.length;a++){let l=o[a].substring(1);switch(o[a].charAt(0)){case"+":try{i[n++]=[1,decodeURI(l)]}catch{throw new Error("Illegal escape in diff_fromDelta: "+l)}break;case"-":case"=":let c=parseInt(l,10);if(isNaN(c)||c<0)throw new Error("Invalid number in diff_fromDelta: "+l);let f=e.substring(r,r+=c);o[a].charAt(0)==="="?i[n++]=[0,f]:i[n++]=[-1,f];break;default:if(o[a])throw new Error("Invalid diff operation in diff_fromDelta: "+o[a])}}if(r!==e.length)throw new Error("Delta length ("+r+") does not equal source text length ("+e.length+")");return i}match_main(e,t,i){if(e==null||t==null||i==null)throw new Error("Null input. (match_main)");return i=De(0,Pe(i,e.length)),e===t?0:e.length?e.substring(i,i+t.length)===t?i:this.match_bitap_(e,t,i):-1}patch_make(e,t,i){let n,r;if(typeof e=="string"&&typeof t=="string"&&typeof i>"u")n=e,r=this.diff_main(n,t,!0),r.length>2&&(this.diff_cleanupSemantic(r),this.diff_cleanupEfficiency(r));else if(e&&typeof e=="object"&&typeof t>"u"&&typeof i>"u")r=e,n=this.diff_text1(r);else if(typeof e=="string"&&t&&typeof t=="object"&&typeof i>"u")n=e,r=t;else if(typeof e=="string"&&typeof t=="string"&&i&&typeof i=="object")n=e,r=i;else throw new Error("Unknown call format to patch_make");if(r.length===0)return[];let o=[],a=new Te,l=0,c=0,f=0,u=n,h=n;for(let y=0;y<r.length;y++){let S=r[y][0],d=r[y][1];switch(!l&&S!==0&&(a.start1=c,a.start2=f),S){case 1:a.diffs[l++]=r[y],a.length2+=d.length,h=h.substring(0,f)+d+h.substring(f);break;case-1:a.length1+=d.length,a.diffs[l++]=r[y],h=h.substring(0,f)+h.substring(f+d.length);break;case 0:d.length<=2*this.patchMargin&&l&&r.length!==y+1?(a.diffs[l++]=r[y],a.length1+=d.length,a.length2+=d.length):d.length>=2*this.patchMargin&&l&&(this.patch_addContext_(a,u),o.push(a),a=new Te,l=0,u=h,c=f);break}S!==1&&(c+=d.length),S!==-1&&(f+=d.length)}return l&&(this.patch_addContext_(a,u),o.push(a)),o}patch_deepCopy(e){let t=[];for(let i=0;i<e.length;i++){let n=e[i],r=new Te;for(let o=0;o<n.diffs.length;o++)r.diffs[o]=[n.diffs[o][0],n.diffs[o][1]];r.start1=n.start1,r.start2=n.start2,r.length1=n.length1,r.length2=n.length2,t[i]=r}return t}patch_apply(e,t){if(e.length===0)return[t,[]];e=this.patch_deepCopy(e);let i=this.patch_addPadding(e);t=i+t+i,this.patch_splitMax(e);let n=0,r=[];for(let o=0;o<e.length;o++){let a=e[o].start2+n,l=this.diff_text1(e[o].diffs),c,f=-1;if(l.length>this.matchMaxBits?(c=this.match_main(t,l.substring(0,this.matchMaxBits),a),c!==-1&&(f=this.match_main(t,l.substring(l.length-this.matchMaxBits),a+l.length-this.matchMaxBits),(f===-1||c>=f)&&(c=-1))):c=this.match_main(t,l,a),c===-1)r[o]=!1,n-=e[o].length2-e[o].length1;else{r[o]=!0,n=c-a;let u;if(f===-1?u=t.substring(c,c+l.length):u=t.substring(c,f+this.matchMaxBits),l===u)t=t.substring(0,c)+this.diff_text2(e[o].diffs)+t.substring(c+l.length);else{let h=this.diff_main(l,u,!1);if(l.length>this.matchMaxBits&&this.diff_levenshtein(h)/l.length>this.patchDeleteThreshold)r[o]=!1;else{this.diff_cleanupSemanticLossless(h);let y=0,S=0;for(let d=0;d<e[o].diffs.length;d++){let p=e[o].diffs[d];p[0]!==0&&(S=this.diff_xIndex(h,y)),p[0]===1?t=t.substring(0,c+S)+p[1]+t.substring(c+S):p[0]===-1&&(t=t.substring(0,c+S)+t.substring(c+this.diff_xIndex(h,y+p[1].length))),p[0]!==-1&&(y+=p[1].length)}}}}}return t=t.substring(i.length,t.length-i.length),[t,r]}patch_addPadding(e){let t=this.patchMargin,i="";for(let o=1;o<=t;o++)i+=String.fromCharCode(o);for(let o=0;o<e.length;o++)e[o].start1+=t,e[o].start2+=t;let n=e[0],r=n.diffs;if(r.length===0||r[0][0]!==0)r.unshift([0,i]),n.start1-=t,n.start2-=t,n.length1+=t,n.length2+=t;else if(t>r[0][1].length){let o=t-r[0][1].length;r[0][1]=i.substring(r[0][1].length)+r[0][1],n.start1-=o,n.start2-=o,n.length1+=o,n.length2+=o}if(n=e[e.length-1],r=n.diffs,r.length===0||r[r.length-1][0]!==0)r.push([0,i]),n.length1+=t,n.length2+=t;else if(t>r[r.length-1][1].length){let o=t-r[r.length-1][1].length;r[r.length-1][1]+=i.substring(0,o),n.length1+=o,n.length2+=o}return i}patch_splitMax(e){let t=this.matchMaxBits;for(let i=0;i<e.length;i++){if(e[i].length1<=t)continue;let n=e[i];e.splice(i--,1);let r=n.start1,o=n.start2,a="";for(;n.diffs.length!==0;){let l=new Te,c=!0;for(l.start1=r-a.length,l.start2=o-a.length,a!==""&&(l.length1=l.length2=a.length,l.diffs.push([0,a]));n.diffs.length!==0&&l.length1<t-this.patchMargin;){let u=n.diffs[0][0],h=n.diffs[0][1];u===1?(l.length2+=h.length,o+=h.length,l.diffs.push(n.diffs.shift()),c=!1):u===-1&&l.diffs.length===1&&l.diffs[0][0]===0&&h.length>2*t?(l.length1+=h.length,r+=h.length,c=!1,l.diffs.push([u,h]),n.diffs.shift()):(h=h.substring(0,t-l.length1-this.patchMargin),l.length1+=h.length,r+=h.length,u===0?(l.length2+=h.length,o+=h.length):c=!1,l.diffs.push([u,h]),h===n.diffs[0][1]?n.diffs.shift():n.diffs[0][1]=n.diffs[0][1].substring(h.length))}a=this.diff_text2(l.diffs),a=a.substring(a.length-this.patchMargin);let f=this.diff_text1(n.diffs).substring(0,this.patchMargin);f!==""&&(l.length1+=f.length,l.length2+=f.length,l.diffs.length!==0&&l.diffs[l.diffs.length-1][0]===0?l.diffs[l.diffs.length-1][1]+=f:l.diffs.push([0,f])),c||e.splice(++i,0,l)}}}patch_toText(e){let t=[];for(let i=0;i<e.length;i++)t[i]=e[i];return t.join("")}patch_fromText(e){let t=[];if(!e)return t;let i=e.split(`
`),n=0,r=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;for(;n<i.length;){let o=i[n].match(r);if(!o)throw new Error("Invalid patch string: "+i[n]);let a=new Te;t.push(a),a.start1=parseInt(o[1],10),o[2]===""?(a.start1--,a.length1=1):o[2]==="0"?a.length1=0:(a.start1--,a.length1=parseInt(o[2],10)),a.start2=parseInt(o[3],10),o[4]===""?(a.start2--,a.length2=1):o[4]==="0"?a.length2=0:(a.start2--,a.length2=parseInt(o[4],10)),n++;let l,c,f;for(;n<i.length;){l=i[n].charAt(0),f=i[n].substring(1);try{c=decodeURI(f)}catch{throw new Error("Illegal escape in patch_fromText: "+f)}if(l==="-")a.diffs.push([-1,c]);else if(l==="+")a.diffs.push([1,c]);else if(l===" ")a.diffs.push([0,c]);else{if(l==="@")break;if(l!=="")throw new Error('Invalid patch mode "'+l+'" in: '+c)}n++}}return t}diff_compute_(e,t,i,n){let r;if(!e)return[[1,t]];if(!t)return[[-1,e]];let o=e.length>t.length?e:t,a=e.length>t.length?t:e,l=o.indexOf(a);if(l!==-1)return r=[[1,o.substring(0,l)],[0,a],[1,o.substring(l+a.length)]],e.length>t.length&&(r[0][0]=-1,r[2][0]=-1),r;if(a.length===1)return[[-1,e],[1,t]];let c=this.diff_halfMatch_(e,t);if(c){let f=c[0],u=c[1],h=c[2],y=c[3],S=c[4],d=this.diff_main(f,h,i,n),p=this.diff_main(u,y,i,n);return d.concat([[0,S]],p)}return i&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,n):this.diff_bisect_(e,t,n)}diff_lineMode_(e,t,i){let n=this.diff_linesToChars_(e,t);e=n.chars1,t=n.chars2;let r=n.lineArray,o=this.diff_main(e,t,!1,i);this.diff_charsToLines_(o,r),this.diff_cleanupSemantic(o),o.push([0,""]);let a=0,l=0,c=0,f="",u="";for(;a<o.length;){switch(o[a][0]){case 1:c++,u+=o[a][1];break;case-1:l++,f+=o[a][1];break;case 0:if(l>=1&&c>=1){o.splice(a-l-c,l+c),a=a-l-c;let h=this.diff_main(f,u,!1,i);for(let y=h.length-1;y>=0;y--)o.splice(a,0,h[y]);a=a+h.length}c=0,l=0,f="",u="";break}a++}return o.pop(),o}diff_bisect_(e,t,i){let n=e.length,r=t.length,o=Math.ceil((n+r)/2),a=o,l=2*o,c=new Array(l),f=new Array(l);for(let m=0;m<l;m++)c[m]=-1,f[m]=-1;c[a+1]=0,f[a+1]=0;let u=n-r,h=u%2!==0,y=0,S=0,d=0,p=0;for(let m=0;m<o&&!(Date.now()>i);m++){for(let g=-m+y;g<=m-S;g+=2){let E=a+g,b;g===-m||g!==m&&c[E-1]<c[E+1]?b=c[E+1]:b=c[E-1]+1;let w=b-g;for(;b<n&&w<r&&e.charAt(b)===t.charAt(w);)b++,w++;if(c[E]=b,b>n)S+=2;else if(w>r)y+=2;else if(h){let v=a+u-g;if(v>=0&&v<l&&f[v]!==-1){let P=n-f[v];if(b>=P)return this.diff_bisectSplit_(e,t,b,w,i)}}}for(let g=-m+d;g<=m-p;g+=2){let E=a+g,b;g===-m||g!==m&&f[E-1]<f[E+1]?b=f[E+1]:b=f[E-1]+1;let w=b-g;for(;b<n&&w<r&&e.charAt(n-b-1)===t.charAt(r-w-1);)b++,w++;if(f[E]=b,b>n)p+=2;else if(w>r)d+=2;else if(!h){let v=a+u-g;if(v>=0&&v<l&&c[v]!==-1){let P=c[v],F=a+P-v;if(b=n-b,P>=b)return this.diff_bisectSplit_(e,t,P,F,i)}}}}return[[-1,e],[1,t]]}diff_bisectSplit_(e,t,i,n,r){let o=e.substring(0,i),a=t.substring(0,n),l=e.substring(i),c=t.substring(n),f=this.diff_main(o,a,!1,r),u=this.diff_main(l,c,!1,r);return f.concat(u)}diff_linesToChars_(e,t){let i=[],n={};i[0]="";let r=this.diff_linesToCharsMunge_(e,i,n,4e4),o=this.diff_linesToCharsMunge_(t,i,n,65535);return{chars1:r,chars2:o,lineArray:i}}diff_linesToCharsMunge_(e,t,i,n){let r="",o=0,a=-1,l=t.length;for(;a<e.length-1;){a=e.indexOf(`
`,o),a===-1&&(a=e.length-1);let c=e.substring(o,a+1);(i.hasOwnProperty?i.hasOwnProperty(c):i[c]!==void 0)?r+=String.fromCharCode(i[c]):(l===n&&(c=e.substring(o),a=e.length),r+=String.fromCharCode(l),i[c]=l,t[l++]=c),o=a+1}return r}diff_charsToLines_(e,t){for(let i=0;i<e.length;i++){let n=e[i][1],r=[];for(let o=0;o<n.length;o++)r[o]=t[n.charCodeAt(o)];e[i][1]=r.join("")}}diff_commonOverlap_(e,t){let i=e.length,n=t.length;if(i===0||n===0)return 0;i>n?e=e.substring(i-n):i<n&&(t=t.substring(0,i));let r=Pe(i,n);if(e===t)return r;let o=0,a=1;for(;;){let l=e.substring(r-a),c=t.indexOf(l);if(c===-1)return o;a+=c,(c===0||e.substring(r-a)===t.substring(0,a))&&(o=a,a++)}}diff_halfMatch_(e,t){if(this.diffTimeout<=0)return null;let i=e.length>t.length?e:t,n=e.length>t.length?t:e;if(i.length<4||n.length*2<i.length)return null;let r=this.diff_halfMatchI_(i,n,Math.ceil(i.length/4)),o=this.diff_halfMatchI_(i,n,Math.ceil(i.length/2)),a;if(!r&&!o)return null;o?r?a=r[4].length>o[4].length?r:o:a=o:a=r;let l,c,f,u,h=a[4];return e.length>t.length?(l=a[0],c=a[1],f=a[2],u=a[3]):(f=a[0],u=a[1],l=a[2],c=a[3]),[l,c,f,u,h]}diff_halfMatchI_(e,t,i){let n=e.substring(i,i+Math.floor(e.length/4)),r="",o,a,l,c,f=t.indexOf(n,0);for(;f!==-1;){let u=this.diff_commonPrefix(e.substring(i),t.substring(f)),h=this.diff_commonSuffix(e.substring(0,i),t.substring(0,f));r.length<h+u&&(r=t.substring(f-h,f)+t.substring(f,f+u),o=e.substring(0,i-h),a=e.substring(i+u),l=t.substring(0,f-h),c=t.substring(f+u)),f=t.indexOf(n,f+1)}return r.length*2>=e.length?[o,a,l,c,r]:null}diff_cleanupSemanticScore_(e,t){if(!e||!t)return 6;let i=e.charAt(e.length-1),n=t.charAt(0),r=i.match(ac),o=n.match(ac),a=r&&i.match(lc),l=o&&n.match(lc),c=a&&i.match(cc),f=l&&n.match(cc),u=c&&e.match(Sd),h=f&&t.match(vd);return u||h?5:c||f?4:r&&!a&&l?3:a||l?2:r||o?1:0}match_bitap_(e,t,i){if(t.length>this.matchMaxBits)throw new Error("Pattern too long for this browser");let n=this.match_alphabet_(t),r=this.matchThreshold,o=e.indexOf(t,i);o!==-1&&(r=Pe(this.match_bitapScore_(0,o,t,i),r),o=e.lastIndexOf(t,i+t.length),o!==-1&&(r=Pe(this.match_bitapScore_(0,o,t,i),r)));let a=1<<t.length-1;o=-1;let l,c,f=t.length+e.length,u;for(let h=0;h<t.length;h++){for(l=0,c=f;l<c;)this.match_bitapScore_(h,i+c,t,i)<=r?l=c:f=c,c=Math.floor((f-l)/2+l);f=c;let y=De(1,i-c+1),S=Pe(i+c,e.length)+t.length,d=Array(S+2);d[S+1]=(1<<h)-1;for(let p=S;p>=y;p--){let m=n[e.charAt(p-1)];if(h===0?d[p]=(d[p+1]<<1|1)&m:d[p]=(d[p+1]<<1|1)&m|((u[p+1]|u[p])<<1|1)|u[p+1],d[p]&a){let g=this.match_bitapScore_(h,p-1,t,i);if(g<=r)if(r=g,o=p-1,o>i)y=De(1,2*i-o);else break}}if(this.match_bitapScore_(h+1,i,t,i)>r)break;u=d}return o}match_bitapScore_(e,t,i,n){let r=e/i.length,o=Math.abs(n-t);return this.matchDistance?r+o/this.matchDistance:o?1:r}match_alphabet_(e){let t={};for(let i=0;i<e.length;i++)t[e.charAt(i)]=0;for(let i=0;i<e.length;i++)t[e.charAt(i)]|=1<<e.length-i-1;return t}patch_addContext_(e,t){if(t.length===0)return;if(e.start2==null)throw Error("patch not initialized");let i=t.substring(e.start2,e.start2+e.length1),n=0;for(;t.indexOf(i)!==t.lastIndexOf(i)&&i.length<this.matchMaxBits-this.patchMargin-this.patchMargin;)n+=this.patchMargin,i=t.substring(e.start2-n,e.start2+e.length1+n);n+=this.patchMargin;let r=t.substring(e.start2-n,e.start2);r&&e.diffs.unshift([0,r]);let o=t.substring(e.start2+e.length1,e.start2+e.length1+n);o&&e.diffs.push([0,o]),e.start1-=r.length,e.start2-=r.length,e.length1+=r.length+o.length,e.length2+=r.length+o.length}},Te=class{constructor(){this.diffs=[];this.start1=0;this.start2=0;this.length1=0;this.length2=0}toString(){let e,t;this.length1===0?e=this.start1+",0":this.length1===1?e=this.start1+1:e=this.start1+1+","+this.length1,this.length2===0?t=this.start2+",0":this.length2===1?t=this.start2+1:t=this.start2+1+","+this.length2;let i=["@@ -"+e+" +"+t+` @@
`],n;for(let r=0;r<this.diffs.length;r++){switch(this.diffs[r][0]){case 1:n="+";break;case-1:n="-";break;case 0:n=" ";break}i[r+1]=n+encodeURI(this.diffs[r][1])+`
`}return i.join("").replace(/%20/g," ")}};function uc(s,e,t){let i=new Hi,n=i.diff_main(s,e,!0,0);n.length>2&&(i.diff_cleanupSemantic(n),i.diff_cleanupEfficiency(n));let r=i.patch_make(s,n);return i.patch_apply(r,t)[0]}var Yi=class{constructor(e){this.allowTypes=new Set(Le);this.allowSpecialFiles=new Set(as);this.ignoreFolders=[];this.filterCache={};this.configDir=e}init(e,t,i){this.filterCache={},this.allowTypes=new Set(e||Le),this.allowSpecialFiles=new Set(t||[]),this.ignoreFolders=i||[]}clear(){this.filterCache={},this.allowTypes=new Set(Le),this.allowSpecialFiles=new Set(as),this.ignoreFolders=[]}clearCache(){this.filterCache={}}allowSyncFile(e,t){let{filterCache:i}=this;return Object.hasOwn(i,e)?i[e]:i[e]=this._allowSyncFile(e,t)}_allowSyncFile(e,t){for(let r of this.ignoreFolders)if(t&&e===r||e.startsWith(r+"/"))return!1;if(!t&&e.startsWith(this.configDir+"/")){let r=e.substring((this.configDir+"/").length),o=r.split("/");if(o.some(f=>f==="node_modules"||f.startsWith(".")))return!1;let a=V(r),l=j(a),c=null;return r==="workspace.json"||r==="workspace-mobile.json"?!1:(r==="app.json"||r==="types.json"?c="app":r==="appearance.json"?c="appearance":r==="hotkeys.json"?c="hotkey":r==="core-plugins.json"||r==="core-plugins-migration.json"?c="core-plugin":r==="community-plugins.json"?c="community-plugin":o[0]==="themes"&&o.length===3&&(a==="theme.css"||a==="manifest.json")||o[0]==="snippets"&&o.length===2&&l==="css"?c="appearance-data":o.length===1&&l==="json"?c="core-plugin-data":o[0]==="plugins"&&o.length===3&&this.isPluginFile(a)&&(c="community-plugin-data"),c&&this.allowSpecialFiles.has(c))}if(e.startsWith("."))return!1;if(t)return!0;if(e.startsWith("."))return!1;let i=j(V(e));if(i==="md"||i==="canvas"||i==="base")return!0;let{allowTypes:n}=this;return jt.includes(i)?n.has("image"):i==="webm"?n.has("audio")||n.has("video"):Ut.includes(i)?n.has("audio"):Kt.includes(i)?n.has("video"):Vt.includes(i)?n.has("pdf"):!!n.has("unsupported")}isPluginFile(e){return e==="manifest.json"||e==="main.js"||e==="styles.css"||e==="data.json"}};var Tt=class{constructor(){this.promise=Promise.resolve()}queue(e){let t=this.promise.then(e,e);return this.promise=t,t}};function Gi(){let s={promise:null,resolve:null,reject:null};return s.promise=new Promise((e,t)=>{s.resolve=e,s.reject=t}),s}var pr=WebSocket,hc=URL,Pd=Object.getOwnPropertyDescriptor(hc.prototype,"hostname").get,Dd=String.prototype.endsWith,fc={1e3:"Disconnected",1001:"Going Away",1002:"Protocol Error",1003:"Unsupported Data",1004:"(For future)",1005:"No Status Received",1006:"Disconnected",1007:"Invalid frame payload data",1008:"Policy Violation",1009:"Message too big",1010:"Missing Extension",1011:"Internal Error",1012:"Service Restart",1013:"Try Again Later",1014:"Bad Gateway",1015:"TLS Handshake"};function Td(s){if(s>=0&&s<=999)return"(Unused)";if(s>=1016){if(s<=1999)return"(For WebSocket standard)";if(s<=2999)return"(For WebSocket extensions)";if(s<=3999)return"(For libraries and frameworks)";if(s<=4999)return"(For applications)"}return fc.hasOwnProperty(s)?fc[s]:"(Unknown)"}var Ld=20*1e3,_d=10*1e3,Nd=2*60*1e3,Ji=class{constructor(e){this.socket=null;this.queue=new Tt;this.notifyQueue=new Tt;this.dataQueue=[];this.onDisconnect=null;this.perFileMax=199*1024*1024;this.userId=-1;this.justPushed=null;this.encryptionProvider=e}isConnecting(){let{socket:e}=this;return e&&e.readyState===pr.CONNECTING}isConnected(){let{socket:e}=this;return e&&e.readyState===pr.OPEN}hasConnection(){let{socket:e}=this;return!!e}async connect(e,t,i,n,r,o,a,l){if(this.hasConnection())return;this.onReady=a,this.onPush=l;let c=this.encryptionProvider.keyHash;return new Promise((f,u)=>{let h=new hc(e),y=Pd.call(h);if(!Dd.call(y,".obsidian.md")&&y!=="127.0.0.1")return u(new Error("Unable to connect to server."));let S=!1,d=m=>{S||(S=!0,this.disconnect(),u(m))},p=this.socket=new pr(h);p.binaryType="arraybuffer",p.onclose=m=>{m.code===1006?d(new Error("Unable to connect to server.")):d(new Error("Disconnected. Code: "+m.code+" "+Td(m.code)))},p.onopen=()=>{this.lastMessageTs=Date.now(),this.heartbeat=setInterval(()=>{let m=Date.now()-this.lastMessageTs;if(m>Nd){this.disconnect();return}m>_d&&this.send({op:"ping"})},Ld),this.send({op:"init",token:t,id:i,keyhash:c,version:n,initial:r,device:o,encryption_version:this.encryptionProvider.encryptionVersion})},p.onmessage=m=>{let g=m.data;if(typeof g!="string")return d(new Error("Server returned binary"));let E;try{E=JSON.parse(g)}catch(b){return console.error(b),d(new Error("Server JSON failed to parse: "+g))}if(E.op!=="pong"){if(E.status==="err"||E.res==="err")return d(new Error("Failed to authenticate: "+E.msg));if(E.res!=="ok")return d(new Error("Did not respond to login request: "+g));if(E.hasOwnProperty("perFileMax")){let b=E.perFileMax;if(!Number.isInteger(b)||isNaN(b)||b<0)return d(new Error("Unexpected value from server for max file size"));this.perFileMax=b}E.userId&&(this.userId=E.userId),f(),S=!0,p.onmessage=this.onMessage.bind(this),p.onclose=this.disconnect.bind(this),p.onerror=this.disconnect.bind(this)}}})}disconnect(){let e=!1;this.socket&&(this.socket.close(),this.socket=null,e=!0),this.heartbeat&&(clearInterval(this.heartbeat),this.heartbeat=null),this.responsePromise&&(this.responsePromise.reject(new Error("Disconnected")),this.responsePromise=null),this.dataPromise&&(this.dataPromise.reject(new Error("Disconnected")),this.dataPromise=null),e&&this.onDisconnect&&this.onDisconnect()}async pull(e){return this.queue.queue(async()=>{this.lastNetworkRequestTs=Date.now(),this.dataQueue.length=0;let t=await this.request({op:"pull",uid:e});if(!t.deleted){let i=t.size,n=t.pieces,r=new ArrayBuffer(i),o=0;for(let a=0;a<n;a++){let l=await this.dataResponse();new Uint8Array(r,o,l.byteLength).set(new Uint8Array(l)),o+=l.byteLength}return r.byteLength>0&&(r=await this.encryptionProvider.decrypt(r)),r}return null})}async push(e,t,i,n,r,o,a,l){return this.queue.queue(async()=>{this.lastNetworkRequestTs=Date.now();let c=await this.encryptionProvider.deterministicEncodeStr(e),f=t?await this.encryptionProvider.deterministicEncodeStr(t):null,u=i?"":j(V(e));if(i||n){this.justPushed={path:c,folder:i,deleted:n,mtime:0,hash:""},await this.request({op:"push",path:c,relatedpath:f,extension:u,hash:"",ctime:0,mtime:0,folder:i,deleted:n});return}l.byteLength>0&&(l=await this.encryptionProvider.encrypt(l)),a&&(a=await this.encryptionProvider.deterministicEncodeStr(a));let h=l.byteLength,y=2*1024*1024,S=Math.ceil(h/y);if(this.justPushed={path:c,folder:i,deleted:n,mtime:o,hash:a},(await this.request({op:"push",path:c,relatedpath:f,extension:u,hash:a,ctime:r,mtime:o,folder:i,deleted:n,size:h,pieces:S})).res==="ok"){this.justPushed=null;return}for(let p=0;p<S;p++){let m=p*y,g=Math.min(y,h-m);this.sendBinary(new Uint8Array(l,m,g)),await this.response()}this.justPushed=null})}async listDeleted(){return this.queue.queue(async()=>{let t=(await this.request({op:"deleted",suppressrenames:!0})).items;for(let i of t)i.path=await this.encryptionProvider.deterministicDecodeStr(i.path);return t})}async listHistory(e,t){return this.queue.queue(async()=>{let i=await this.encryptionProvider.deterministicEncodeStr(e),n=await this.request({op:"history",path:i,last:t}),r=n.items;for(let o of r)o.path=await this.encryptionProvider.deterministicDecodeStr(o.path),o.relatedpath=o.relatedpath&&await this.encryptionProvider.deterministicDecodeStr(o.relatedpath);return n})}async restore(e){return this.queue.queue(async()=>this.request({op:"restore",uid:e}))}async getUsernames(){return this.queue.queue(()=>this.request({op:"usernames"}))}async purge(){return this.queue.queue(()=>this.request({op:"purge"}))}async size(){return this.queue.queue(()=>this.request({op:"size"}))}onServerPush(e){let{justPushed:t}=this;t&&t.path===e.path&&t.folder===e.folder&&t.deleted===e.deleted&&t.mtime===e.mtime&&t.hash===e.hash&&(this.justPushed=null,e.wasJustPushed=!0),this.notifyQueue.queue(async()=>{e.path=await this.encryptionProvider.deterministicDecodeStr(e.path),e.hash&&(e.hash=await this.encryptionProvider.deterministicDecodeStr(e.hash)),this.onPush(e)})}response(){return(this.responsePromise=Gi()).promise}dataResponse(){return this.dataQueue.length>0?Promise.resolve(this.dataQueue.shift()):(this.dataPromise=Gi()).promise}async request(e,t=6e4){let i=this.responsePromise=Gi();this.send(e);let n=new Error("Timeout"),r=setTimeout(()=>i.reject(n),t),o;try{o=await i.promise,clearTimeout(r)}catch(a){throw a===n&&this.disconnect(),a}if(o.err)throw new Error(o.err);return o}onMessage(e){if(this.lastMessageTs=Date.now(),typeof e.data=="string"){let t;try{t=JSON.parse(e.data)}catch{console.log(e.data),this.disconnect();return}let i=t.op;if(i==="pong")return;if(i==="ready"){this.notifyQueue.queue(async()=>{this.onReady(t.version)});return}if(i==="push"){this.onServerPush(t);return}let n=this.responsePromise;n&&(this.responsePromise=null,n.resolve(t))}else{let t=this.dataPromise;t?(this.dataPromise=null,t.resolve(e.data)):this.dataQueue.push(e.data)}}send(e){this.socket.send(JSON.stringify(e))}sendBinary(e){this.socket.send(e)}};var Qi=class{constructor(e,t,i,n){this.min=e||0,this.max=t||Number.MAX_VALUE,this.base=i||1e3,this.jitter=n||!0,this.count=0,this.nextTs=Date.now()}success(){this.count=0,this.nextTs=Date.now()+this.getTimeout()}fail(){this.count++,this.nextTs=Date.now()+this.getTimeout()}getTimeout(){if(this.count===0)return this.min;let e=this.count-1,t=this.base*Math.pow(2,e);if(this.jitter){let i=.5;t=t*(1-i+i*Math.random())}return t=Math.floor(Math.min(this.max,this.min+t)),t}getNextTs(){return this.nextTs}isReady(){return Date.now()>this.nextTs}};var Cd=function(){let s=typeof process<"u"?process.platform:"";if(s==="win32")return"win";if(s==="darwin")return"mac";if(s==="linux")return"linux";if(s)return"unknown";let e=navigator.userAgent;return e.indexOf("Win")!==-1?"win":e.indexOf("Mac")!==-1?"mac":e.indexOf("X11")!==-1||e.indexOf("Linux")!==-1?"linux":"unknown"}(),pc=navigator.userAgent.toLowerCase();var dr=Cd==="win";var ly=/^((?!chrome|android).)*safari/i.test(pc),dc=/android/i.test(pc);var Id=/[.?*+^$[\]\\(){}|-]/g;function Xi(s){return s.replace(Id,"\\$&")}var Od="\\/:"+(dc?'*?<>"':""),kd='*"\\/<>:|?',gc="#^[]|",mc=dr?kd:Od,xd=mc.split("").join("\xA0"),dy=gc.split("").join("\xA0"),yc=new RegExp("["+Xi(mc)+"]"),gy=new RegExp("["+Xi(gc)+"]"),qd=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;function bc(s){try{return Md(s),!0}catch{return!1}}function Md(s){if(dr){let e=s.charAt(s.length-1);if(e==="."||e===" ")throw new Error("File names cannot end with a dot or a space.");let t=ro(s);if(qd.test(t))throw new Error("File name is forbidden: "+t)}if(s.split("/").some(e=>yc.test(e)))throw new Error("File name cannot contain any of the following characters: "+xd)}function wc(s,e="_"){let t=s.trim();if(t&&(t=s.replace(yc,e),e.length===1)){let i=Xi(e),n=new RegExp(`${i}{2,}`,"g");t=t.replace(n,e)}return t}function Rd(s){return new Promise(e=>setTimeout(e,s))}var zi=class{constructor(e){this.server=null;this.localFiles={};this.serverFiles={};this.newServerFiles=[];this.version=0;this.initial=!0;this.ready=!1;this.syncing=!1;this.loaded=!1;this.backoff=new Qi(0,5*60*1e3,5e3,!0);this.fileRetry={};this.skippedFiles={};this.syncingPath="";this.scanSpecialFiles=!1;this.scanSpecialFileQueue=[];this.resolveStop=null;let{config:t}=e;this.host=t.host,this.token=e.token,this.vaultId=t.vaultId,this.continuous=e.continuous||!1,this.encryption=e.encryption;let i=Nr(t.vaultId);this.stateStore=new Wi(i),this.conflictStrategy=t.conflictStrategy||"merge",this.syncMode=t.syncMode||"",this.deviceName=t.deviceName||"Sync Client",this.adapter=new Vi(D.default,T.default,ns.default,()=>!1,Dr,"file:///",t.vaultPath),this.filter=new Yi(t.configDir),this.filter.init(t.allowTypes,t.allowSpecialFiles,t.ignoreFolders),this.loadState()}loadState(){this.version=this.stateStore.getVersion(),this.initial=this.stateStore.isInitial(),this.localFiles=this.stateStore.getAllLocalFiles(),this.serverFiles=this.stateStore.getAllServerFiles(),this.newServerFiles=this.stateStore.getPendingFiles()}handlePush(e){if(this.version=e.uid,this.initial&&e.deleted){this.stateStore.setVersion(this.version);return}let t=e.path,i={path:t,size:e.size,hash:e.hash,ctime:e.ctime,mtime:e.mtime,folder:e.folder,deleted:e.deleted,uid:e.uid,device:e.device,user:e.user};this.initial&&(i.initial=!0);let{newServerFiles:n}=this;if(e.wasJustPushed){for(let r=0;r<n.length;r++)n[r].path===t&&(n.splice(r,1),r-=1);this.stateStore.deletePendingFile(t),this.serverFiles[t]=i,this.stateStore.setServerFile(i),this.stateStore.setVersion(this.version);return}n.push(i),this.stateStore.addPendingFile(i),this.stateStore.setVersion(this.version),this.initial||console.debug(`Push: ${i.path} (${i.deleted?"deleted":"updated"})`),this.requestSync()}async sync(){let e=new Promise(i=>this.resolveStop=i),t;try{if(!this.loaded){await this.adapter.watch(this.onChange.bind(this));for(let i in this.localFiles)Object.hasOwn(this.adapter.files,i)||(delete this.localFiles[i],this.stateStore.deleteLocalFile(i));this.scanSpecialFiles=!0,this.loaded=!0}t=setInterval(this.requestSync.bind(this),30*1e3),await this.requestSync(),await e}finally{clearInterval(t)}}stop(){this.server&&(this.server.disconnect(),this.server=null),this.ready=!1,this.continuous=!1,this.stateStore.close(),this.adapter.stopWatch(),this.adapter.thingsHappening.cancel(),this.resolveStop&&(this.resolveStop(),this.resolveStop=null)}async requestSync(){if(!this.syncing){this.syncing=!0;try{let e=!0;for(;e;){try{this.syncingPath="",e=await this._sync();let i=this.syncingPath;i&&delete this.fileRetry[i]}catch(i){if(console.error("Sync error:",i),this.failedSync(this.syncingPath),e=!1,!this.continuous)throw this.syncing=!1,i}if(!e)return;let t=0;if(this.server){let i=Date.now()-this.server.lastNetworkRequestTs;t=Math.max(0,50-i)}await Rd(t)}}finally{this.syncing=!1}}}canSyncPath(e,t){let{fileRetry:i}=this;for(let n in i)if(i.hasOwnProperty(n)&&i[n].ts>e&&t.startsWith(n))return!1;return!0}canSyncLocalFile(e,t){if(!t.synctime)return!0;let i=t.size,n=i>10*1024,r=i>100*1024,o=n?r?30:20:10;return e-t.synctime>o*1e3}failedSync(e){if(!e)return;let t=Date.now(),i=this.fileRetry[e];i||(i=this.fileRetry[e]={count:0,ts:0});let n=i.count=i.count+1,r=Math.pow(2,n)*5*1e3;r=Math.min(r,5*60*1e3),i.ts=t+r}async getServer(){let{server:e}=this;if(e&&!e.isConnected()&&!e.isConnecting()&&(e.disconnect(),e=this.server=null,this.backoff.fail()),!e){if(!this.backoff.isReady())return this.log("Waiting to connect to server"),null;e=this.server=new Ji(this.encryption)}if(!e.hasConnection()){this.log("Connecting..."),this.ready=!1;try{let t=this.host.startsWith("127.0.0.1")||this.host.startsWith("localhost")?"ws://":"wss://";e.onDisconnect=()=>{this.ready=!1,this.log("Disconnected from server"),this.continuous&&this.requestSync()},await e.connect(t+this.host,this.token,this.vaultId,this.version,this.initial,this.deviceName,i=>{this.ready=!0,this.initial=!1,this.stateStore.setInitial(!1),this.version<i&&(this.version=i,this.stateStore.setVersion(this.version)),this.requestSync()},i=>this.handlePush(i)),this.log("Connection successful. Detecting changes..."),this.backoff.success()}catch(t){if(t.message&&t.message.includes("Your subscription to Obsidian Sync has expired"))throw console.error(t.message),this.stop(),t;if(t.message&&t.message.includes("Vault not found"))throw console.error("The connected remote vault no longer exists."),this.stop(),t;return console.error(t),e.disconnect(),e=this.server=null,this.backoff.fail(),null}}return e}async _sync(){let e=await this.getServer();if(!e)return!1;let t=Date.now(),i=0,n=this.filter.configDir,r=n+"/",{localFiles:o,serverFiles:a,newServerFiles:l,stateStore:c,filter:f,adapter:u}=this;try{let p={},m=this.scanSpecialFileQueue;if(this.scanSpecialFiles){this.scanSpecialFiles=!1,m=this.scanSpecialFileQueue=[];for(let g in o)Object.hasOwn(o,g)&&g.startsWith(".")&&(p[g]=o[g],delete o[g],c.deleteLocalFile(g));if(f.allowSpecialFiles.size>0&&await u.exists(n)){m.push(r+"config");let g=await u.list(n);for(let E of g.files)j(E)==="json"&&m.push(E);if(await u.exists(r+"themes")){let E=await u.list(r+"themes");for(let b of E.folders){let w=await u.list(b);for(let v of w.files){let P=V(v);(P==="manifest.json"||P==="theme.css")&&m.push(v)}}}if(await u.exists(r+"snippets")){let E=await u.list(r+"snippets");for(let b of E.files)j(b)==="css"&&m.push(b)}if(await u.exists(r+"plugins")){let E=await u.list(r+"plugins");for(let b of E.folders){let w=await u.list(b);for(let v of w.files){let P=V(v);f.isPluginFile(P)&&m.push(v)}}}}}for(;m.length>0;){let g=m.pop();if(!await u.exists(g)){delete o[g],c.deleteLocalFile(g);continue}let E=await u.stat(g);if(!E||E.type!=="file"){delete o[g],c.deleteLocalFile(g);continue}let b=o[g];b||(Object.hasOwn(p,g)?b=o[g]=p[g]:b=o[g]={path:g,previouspath:"",ctime:0,mtime:0,size:0,folder:!1,hash:"",synchash:"",synctime:0});let w=Math.ceil(E.mtime),v=Math.ceil(E.ctime),P=E.size;(!b.mtime||b.mtime!==w||b.size!==E.size)&&(b.hash=""),b.mtime=w,b.ctime=v,b.size=P,c.setLocalFile(b)}}catch(p){console.error("Failed to scan config files",p)}if(l.length>0)for(let p=0;p<l.length;p++){let m=l[p],g=m.path,E=a[g],b=o[g],w=(v,P)=>(v||this.log("Accepted",g),b&&(b.synctime=Date.now(),c.setLocalFile(b)),P||(a[g]=m,c.setServerFile(m)),l.splice(p,1),c.deletePendingFile(g),!0);if(!f.allowSyncFile(g,m.folder))return w(!0);if(!bc(g))return this.log("Ignoring remote file name with illegal characters",g,!0),w(!0,!0);if(_e(g).split("/").includes(".."))return w(!0);if(!this.canSyncPath(t,g)){i++;continue}if(this.syncingPath=g,b&&!b.folder&&!b.hash){this.log("Checking",g);let v=await u.readBinary(g);b.hash=await te(v),c.setLocalFile(b)}if(b&&!b.folder&&!m.folder&&b.hash===m.hash)return w(!0);for(let v=p+1;v<l.length;v++)if(l[v].path===g)return this.log("Skipped",g),w(!0,!0);if(!b)return m.deleted?w(!0):(await this.syncFileDown(e,m),w());if(b.folder&&m.folder){if(m.deleted){try{let v=await u.list(g);if(v.files.length>0||v.folders.length>0)return w(!0)}catch{}this.log("Deleting",g);try{await u.rmdir(g,!0)}catch(v){let P=(v?v.message:"")||"Failed to delete folder";this.log(P,g,!0)}}return w(!0)}if(this.syncMode==="pull-only"||this.syncMode==="mirror-remote"||E&&(b.folder&&E.folder||b.hash===E.hash))return m.deleted?(this.log("Deleting",g),b.folder?await this.adapter.rmdir(g,!0):await this.adapter.remove(g),delete o[g],this.stateStore.deleteLocalFile(g),w()):(await this.syncFileDown(e,m),w());if(!b.folder&&m.folder)try{let v=await u.stat(g);if(v&&v.type==="file"){let P=j(V(g)),F=P?g.substr(g.length-P.length-1):"",M=g.substr(0,g.length-F.length)+" (Conflicted copy)"+F;return this.log("Renaming conflicted file",g),await u.rename(g,M),!0}}catch{}if(m.initial&&m.mtime>b.mtime)return await this.syncFileDown(e,m),w();if(!m.initial&&!b.folder&&!m.folder&&!m.deleted&&j(g)==="md"&&m.hash!==b.synchash){this.logMerge("Merging conflicted file",g);let v=await this.adapter.read(g);if(!v)return await this.syncFileDown(e,m),w();let P="";if(E&&!E.deleted)try{P=me(await e.pull(E.uid))}catch(M){return this.logMerge("Merge failed. "+M.toString(),g,!0),w(!0)}let F;try{F=me(await e.pull(m.uid))}catch(M){return this.logMerge("Merge failed. "+M.toString(),g,!0),w(!0)}if(P===F||v===F||!F)return w();if(this.conflictStrategy==="conflict"){let M=new Date().toLocaleString("sv").replace(/[:\- ]/g,"").substring(0,12),ee=j(g),I=oo(g),Ot=wc(this.deviceName),_c=`${I} (Conflicted copy ${Ot} ${M}).${ee}`;try{await u.write(_c,v,{ctime:b.ctime,mtime:b.mtime}),await u.write(g,F,{ctime:m.ctime,mtime:m.mtime}),this.logMerge("Conflicted copy stored",g)}catch{return w()}return w()}if(!P)return Math.abs(Date.now()-b.ctime)<3*60*1e3?(this.log("Downloading "+g),await u.write(g,F,{ctime:m.ctime,mtime:m.mtime}),w()):(m.mtime>b.mtime&&(this.log("Downloading "+g),await u.write(g,F,{ctime:m.ctime,mtime:m.mtime})),w());let N=uc(P,v,F);return await u.write(g,N),this.logMerge("Merge successful",g),w()}if(!m.folder&&!m.deleted&&m.size>0&&g.startsWith(r)){if(j(g)==="json")try{this.log("Merging conflicted file",g);let v=JSON.parse(await u.read(g));if(v&&!Array.isArray(v)&&typeof v=="object"){let P=JSON.parse(me(await e.pull(m.uid)));if(P&&!Array.isArray(P)&&typeof P=="object"){for(let N in P)Object.hasOwn(P,N)&&(v[N]=P[N]);let F=U(JSON.stringify(v,void 0,2));return await u.writeBinary(g,F),this.log("Merge successful",g),w(!0)}}}catch(v){this.log("Merge failed. "+v.toString(),g,!0)}return await this.syncFileDown(e,m),w()}return this.log("Rejected server change",g),w(!0)}if(!this.ready)return!1;if(this.syncMode==="mirror-remote"){let p=null,m=null;for(let w in a){if(!Object.hasOwn(a,w))continue;let v=a[w];if(!v.deleted&&!Object.hasOwn(o,w)&&f.allowSyncFile(w,v.folder)){if(!this.canSyncPath(t,w)){i++;continue}v.folder?(!p||w.length<p.path.length)&&(p=v):(!m||v.size<m.size)&&(m=v)}}if(p)return this.syncingPath=p.path,this.log("Restoring",p.path),await this.syncFileDown(e,p),!0;if(m)return this.syncingPath=m.path,this.log("Restoring",m.path),await this.syncFileDown(e,m),!0;let g=null,E=null,b=null;for(let w in o){if(!Object.hasOwn(o,w))continue;let v=o[w],P=a[w];if(f.allowSyncFile(w,v.folder)){if(!this.canSyncPath(t,w)){i++;continue}if(!P||P.deleted){v.folder?(!E||w.length>E.path.length)&&(E=v):(!g||w.length>g.path.length)&&(g=v);continue}if(!v.folder&&!P.folder){if(v.hash&&v.hash===P.hash)continue;(!b||v.size<b.size)&&(b=v)}}}if(g){let w=g.path;return this.syncingPath=w,this.log("Removing local-only file",w),await u.remove(w),delete o[w],c.deleteLocalFile(w),!0}if(E){let w=E.path;return this.syncingPath=w,this.log("Removing local-only folder",w),await u.rmdir(w,!0),delete o[w],c.deleteLocalFile(w),!0}if(b){let w=b.path,v=a[w];if(this.syncingPath=w,!b.hash){let P=await u.readBinary(w);if(b.hash=await te(P),c.setLocalFile(b),b.hash===v.hash)return!0}return this.log("Reverting",w),await this.syncFileDown(e,v),!0}}if(this.syncMode==="mirror-remote"||this.syncMode==="pull-only")return i===0?(this.log("Fully synced"),this.fileRetry={},this.continuous||this.stop(),!1):!0;let h=null,y=null;for(let p in a){if(!Object.hasOwn(a,p))continue;let m=a[p];if(!Object.hasOwn(o,p)){if(m.deleted){delete a[p],c.deleteServerFile(p);continue}if(!f.allowSyncFile(p,m.folder))continue;m.folder?(!y||m.path.length>y.path.length)&&(y=m):(!h||m.path.length>h.path.length)&&(h=m)}}if(h){let p=h.path;return this.log("Deleting remote file",p),this.syncingPath=p,await e.push(p,null,!1,!0,0,0,"",null),h.deleted=!0,c.setServerFile(h),!0}if(y){let p=y.path;return this.log("Deleting remote folder",p),this.syncingPath=p,await e.push(p,null,!0,!0,0,0,"",null),y.deleted=!0,c.setServerFile(y),!0}let S=null,d=null;for(let p in o){if(!Object.hasOwn(o,p))continue;let m=o[p],g=a[p];if(!(g&&!g.deleted&&m.folder===g.folder&&m.ctime===g.ctime&&m.mtime===g.mtime&&m.size===g.size&&m.hash&&m.hash===g.hash)&&f.allowSyncFile(p,m.folder)){if(!this.canSyncPath(t,p)){i++;continue}if(process.platform==="linux"&&!m.folder&&g&&g.ctime&&(m.ctime===0||m.ctime>g.ctime)&&!g.folder&&!g.deleted&&(m.ctime=g.ctime),!m.folder&&m.size>e.perFileMax){this.logSkip(`File too large to sync (${Ds(m.size)}, max ${Ds(e.perFileMax)})`,p);continue}if(!g||g.deleted){if(!this.canSyncLocalFile(t,m)){i++;continue}m.folder?(!S||m.path.length<S.path.length)&&(S=m):(!d||m.size<d.size)&&(d=m);continue}if(!S){if(m.folder){if(!this.canSyncLocalFile(t,m)){i++;continue}g.folder||(!S||m.path.length<S.path.length)&&(S=m);continue}if(g.folder){if(!this.canSyncLocalFile(t,m)){i++;continue}y=g;continue}if(!m.hash||m.hash!==g.hash){if(!this.canSyncLocalFile(t,m)){i++;continue}(!d||m.size<d.size)&&(d=m)}}}}if(S){let p=S.path;return this.syncingPath=p,this.log("Uploading",p),await e.push(p,S.previouspath,!0,!1,0,0,"",null),Object.hasOwn(a,p)?a[p].deleted&&(a[p].deleted=!1):a[p]={uid:0,path:p,size:0,hash:"",ctime:0,mtime:0,folder:!0,deleted:!1,device:this.deviceName},c.setServerFile(a[p]),S.previouspath="",S.synctime=Date.now(),c.setLocalFile(S),!0}if(d){let p=d.path;this.log("New file",p),this.syncingPath=p;let m=a[p],{ctime:g,mtime:E}=d,b=await u.readBinary(p),w=d.hash=await te(b);return c.setLocalFile(d),m&&!m.deleted&&m.hash===d.hash||(this.log("Uploading file",p),await e.push(p,d.previouspath,!1,!1,g,E,w,b),d.synchash=w,this.log("Upload complete",p),d.previouspath="",d.synctime=Date.now(),c.setLocalFile(d)),!0}return i===0?(this.log("Fully synced"),this.fileRetry={},this.continuous||this.stop(),!1):!0}onChange(e,t,i,n){if(e==="file-created"){let r=this.localFiles[t];r||(r=this.localFiles[t]={path:t,previouspath:"",folder:!1,ctime:0,mtime:0,size:0,hash:"",synctime:0,synchash:""}),n&&((r.mtime!==n.mtime||r.size!==n.size)&&(r.hash=""),r.ctime=n.ctime,r.mtime=n.mtime,r.size=n.size),this.stateStore.setLocalFile(r)}else if(e==="folder-created")this.localFiles[t]||(this.localFiles[t]={path:t,previouspath:"",folder:!0,ctime:0,mtime:0,size:0,hash:"",synctime:0,synchash:""},this.stateStore.setLocalFile(this.localFiles[t]));else if(e==="modified"){let r=this.localFiles[t];r&&n&&((r.mtime!==n.mtime||r.size!==n.size)&&(r.hash=""),r.ctime=n.ctime,r.mtime=n.mtime,r.size=n.size,this.stateStore.setLocalFile(r))}else if(e==="file-removed"||e==="folder-removed")delete this.localFiles[t],this.stateStore.deleteLocalFile(t);else if(e==="renamed"){let r=this.localFiles[i];r&&(delete this.localFiles[i],this.stateStore.deleteLocalFile(i),r.path=t,r.previouspath=i,this.localFiles[t]=r,this.stateStore.setLocalFile(r))}if(e==="raw"&&t.startsWith(this.filter.configDir+"/")&&!t.endsWith(".sync.lock")){let r=this.scanSpecialFileQueue;if(r.includes(t))return;r.push(t),this.requestSync()}this.loaded&&e!=="raw"&&this.requestSync()}async syncFileDown(e,t){let i=t.path;if(this.log("Downloading",i),t.folder){await this.adapter.mkdir(i),this.log("Downloaded",i);return}let n=await e.pull(t.uid);if(!n)throw new Error("Failed to download file, no data.");let r=ye(i);r&&await this.adapter.mkdir(r);let o=await te(n);await this.adapter.writeBinary(i,n,{ctime:t.ctime,mtime:t.mtime});let a=this.localFiles[i];a&&(a.hash=o,a.synchash=o,this.stateStore.setLocalFile(a)),this.log("Downloaded",i)}log(e,t,i=!1){i?t?console.error(e,t):console.error(e):t?console.log(e,t):console.log(e)}logMerge(e,t,i=!1){this.log(e,t,i)}logSkip(e,t){let{skippedFiles:i}=this;(!Object.hasOwn(i,t)||i[t]!==e)&&(i[t]=e,this.log(e,t,!0))}};var Lt=class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,s.prototype)}};function Sc(s,e,t){return~(s-1)&e|s-1&t}function Bd(s,e){if(s.length!==e.length)return 0;let t=0;for(let i=0;i<s.length;i++)t|=s[i]^e[i];return 1&t-1>>>8}function vc(s,e){return s.length===0||e.length===0?!1:Bd(s,e)!==0}function Zi(s){for(let e=0;e<s.length;e++)s[e]=0;return s}function es(s,e){for(let t=0;t<e.length;t++)s[t]^=e[t]}var C=class s{static{this.SIZE=16}static{this.R=135}constructor(){this.data=new Uint8Array(s.SIZE)}clear(){Zi(this.data)}clone(){let e=new s;return e.copy(this),e}copy(e){this.data.set(e.data)}dbl(){let e=0;for(let t=s.SIZE-1;t>=0;t--){let i=this.data[t]>>>7&255;this.data[t]=this.data[t]<<1|e,e=i}this.data[s.SIZE-1]^=Sc(e,s.R,0),e=0}};var je=crypto.subtle;var _t=class s{constructor(e){this.key=e}static async importKey(e,t){let i=await je.deriveKey({name:"HKDF",salt:t,info:new TextEncoder().encode("ObsidianAesSivEnc"),hash:"SHA-256"},e,{name:"AES-CTR",length:256},!1,["encrypt"]);return new s(i)}async encryptCtr(e,t){let i=await je.encrypt({name:"AES-CTR",counter:e,length:16},this.key,t);return new Uint8Array(i)}};var Nt=class s{constructor(e){this._key=e;this._iv=new C;this._emptyPromise=Promise.resolve(this)}static async importKey(e,t){let i=await je.deriveKey({name:"HKDF",salt:t,info:new TextEncoder().encode("ObsidianAesSivMac"),hash:"SHA-256"},e,{name:"AES-CBC",length:256},!1,["encrypt"]);return new s(i)}clear(){return this}async encryptBlock(e){let t={name:"AES-CBC",iv:this._iv.data},i=await je.encrypt(t,this._key,e.data);return e.data.set(new Uint8Array(i,0,C.SIZE)),this._emptyPromise}};var Ct=class s{constructor(e,t,i){this._cipher=e;this._subkey1=t;this._subkey2=i;this._bufferPos=0;this._finished=!1;this._buffer=new C}static async importKey(e,t){let i=await Nt.importKey(e,t),n=new C;await i.encryptBlock(n),n.dbl();let r=n.clone();return r.dbl(),()=>new s(i,n,r)}async update(e){if(this._finished)throw new Error("Cannot update finished CMAC");let t=C.SIZE-this._bufferPos,i=0,n=e.length;if(n>t){for(let r=0;r<t;r++)this._buffer.data[this._bufferPos+r]^=e[r];n-=t,i+=t,await this._cipher.encryptBlock(this._buffer),this._bufferPos=0}for(;n>C.SIZE;){for(let r=0;r<C.SIZE;r++)this._buffer.data[r]^=e[i+r];n-=C.SIZE,i+=C.SIZE,await this._cipher.encryptBlock(this._buffer)}for(let r=0;r<n;r++)this._buffer.data[this._bufferPos++]^=e[i+r];return this}async finish(){if(!this._finished){let e=this._bufferPos<C.SIZE?this._subkey2:this._subkey1;es(this._buffer.data,e.data),this._bufferPos<C.SIZE&&(this._buffer.data[this._bufferPos]^=128),await this._cipher.encryptBlock(this._buffer),this._finished=!0}return this._buffer.data}};var It=class s{static async importKey(e,t){let i=await Ct.importKey(e,t),n=await _t.importKey(e,t);return new s(i,n)}constructor(e,t){this.cmacFactory=e,this._ctr=t}async seal(e){let t=C.SIZE+e.length,i=new Uint8Array(t),n=await this._s2v(e);return i.set(n),Ec(n),i.set(await this._ctr.encryptCtr(n,e),n.length),i}async open(e){if(e.length<C.SIZE)throw new Lt("AES-SIV: ciphertext is truncated");let t=e.subarray(0,C.SIZE),i=new Uint8Array(C.SIZE);i.set(t),Ec(i);let n=await this._ctr.encryptCtr(i,e.subarray(C.SIZE)),r=await this._s2v(n);if(!vc(r,t))throw Zi(n),new Lt("AES-SIV: ciphertext verification failure!");return n}async _s2v(e){let t=this.cmacFactory(),i=new C,n=new C;if(await t.update(i.data),n.data.set(await t.finish()),t=this.cmacFactory(),i.clear(),e.length>=C.SIZE){let r=e.length-C.SIZE;i.data.set(e.subarray(r)),await t.update(e.subarray(0,r))}else i.data.set(e),i.data[e.length]=128,n.dbl();return es(i.data,n.data),await t.update(i.data),t.finish()}};function Ec(s){s[s.length-8]&=127,s[s.length-4]&=127}var wr=3,Sr=3,Fc=32,gr=32768,mr=8,Ac=1,$d={N:gr,r:mr,p:Ac,maxmem:128*gr*mr*2};async function vr(s,e){s=s.normalize("NFKC"),e=e.normalize("NFKC");let t=require&&require("crypto");if(t){let n=await new Promise((r,o)=>{t.scrypt(Buffer.from(s,"utf8"),Buffer.from(e,"utf8"),Fc,$d,(a,l)=>{a?o(a):r(l)})});return ie(n)}let i=await window.scrypt.scrypt(new Uint8Array(U(s)),new Uint8Array(U(e)),gr,mr,Ac,Fc);return Ye(i)}async function Pc(s,e,t){switch(s){case 0:return yr.init(e);case 2:case 3:return br.init(e,t,s);default:throw new Error("Encryption version not supported")}}async function Er(s,e,t){switch(t){case 0:return Y(await Ge(s));case 2:case 3:let i=await $.importKey("raw",s,"HKDF",!1,["deriveKey"]),n=await $.deriveKey({name:"HKDF",salt:U(e),info:U("ObsidianKeyHash"),hash:"SHA-256"},i,{name:"AES-CBC",length:256},!0,["encrypt"]);return Y(await $.exportKey("raw",n));default:throw new Error("Encryption version not supported")}}var yr=class s{constructor(e,t){this.encryptionVersion=0;this.keyHash=e,this.cryptoKey=t}static async init(e){if(e.byteLength!==32)throw new Error("Invalid encryption key");let t=Y(await Ge(e)),i=await io(e);return new s(t,i)}async deterministicEncodeStr(e){let t=U(e),i=await Ge(t),n=new Uint8Array(i,0,12);return Y(await Bt(t,this.cryptoKey,n))}async deterministicDecodeStr(e){let t=Ps(e);return me(await $t(t,this.cryptoKey))}async encrypt(e){return Bt(e,this.cryptoKey)}async decrypt(e){return $t(e,this.cryptoKey)}},br=class s{constructor(e,t,i,n){if(this.keyHash=e,this.cryptoKey=t,this.siv=i,n!==2&&n!==3)throw new Error("Invalid encryption version");this.encryptionVersion=n}static async init(e,t,i){if(e.byteLength!==32)throw new Error("Invalid encryption key");let n=await $.importKey("raw",e,"HKDF",!1,["deriveKey"]),r=U(t),o=await $.deriveKey({name:"HKDF",salt:r,info:U("ObsidianKeyHash"),hash:"SHA-256"},n,{name:"AES-CBC",length:256},!0,["encrypt"]),a=Y(await $.exportKey("raw",o)),l=await It.importKey(n,r),c=await $.deriveKey({name:"HKDF",salt:new Uint8Array,info:U("ObsidianAesGcm"),hash:"SHA-256"},n,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return new s(a,c,l,i)}async deterministicEncodeStr(e){let t=U(e),i=await this.siv.seal(new Uint8Array(t));return Y(Ye(i))}async deterministicDecodeStr(e){let t=Ps(e),i=await this.siv.open(new Uint8Array(t));return me(Ye(i))}async encrypt(e){return Bt(e,this.cryptoKey)}async decrypt(e){return $t(e,this.cryptoKey)}};var ts=class{constructor(e,t,i){this.refreshTimer=null;this.lockTime=0;this.isMs=!0;this.fs=e,this.path=t,this.lockPath=i}acquire(){let{fs:e,lockPath:t}=this,i=this.path.dirname(t);e.mkdirSync(i,{recursive:!0});try{e.mkdirSync(t)}catch(o){if(o.code!=="EEXIST")throw o;let a;try{a=Math.round(e.statSync(t).mtimeMs)}catch(l){if(l.code==="ENOENT")return this.acquire();throw l}if(Date.now()-a<5e3)throw new is}let n=Date.now();if(n%1e3===0&&(n+=1),this.lockTime=n,this.touch(),this.get()%1e3===0&&(this.isMs=!1),this.set(),!this.verify())throw new is;this.refreshTimer=setInterval(()=>this.set(),1e3)}release(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=null);try{this.verify()&&this.fs.rmdirSync(this.lockPath)}catch{}}set(){let e=Date.now();this.isMs||(e=Math.ceil(e/1e3)*1e3),this.lockTime=e,this.touch()}touch(){try{let e=this.lockTime/1e3;this.fs.utimesSync(this.lockPath,e,e)}catch{}}get(){try{return Math.round(this.fs.statSync(this.lockPath).mtimeMs)}catch{return 0}}verify(){return this.lockTime===this.get()}},is=class extends Error{constructor(){super("Failed to acquire lock.")}};var x=new Dc.Command,Q="ob",{version:jd}=JSON.parse(D.default.readFileSync(T.default.join(__dirname,"package.json"),"utf-8"));x.name(Q).description("Headless client for Obsidian services").version(jd);x.command("login").description("Login to Obsidian account or display login status").option("--email <email>","Email address (prompted if omitted)").option("--password <password>","Password (prompted if omitted)").option("--mfa <code>","MFA code (prompted if omitted)").action(async s=>{try{let e=Ke();if(e&&!s.email&&!s.password){let r=await jr(e);if(r){console.log(`Logged in as ${r.name} (${r.email})`);return}}if(e){try{await Ss(e)}catch{}cs()}let t=s.email||await Ue("Email: ",!0),i=s.password||await Ue("Password: "),n;try{n=await ws(t,i,s.mfa||"")}catch(r){if(r instanceof He&&r.error.includes("2FA code")){if(r.error.includes("2FA code is incorrect"))throw r;let o=await Ue("2FA code: ");n=await ws(t,i,o)}else throw r}_r(n.token),console.log(`Logged in as ${n.name} (${n.email})`)}catch(e){console.error("Login failed:",e),process.exit(2)}});x.command("logout").description("Logout from Obsidian account").action(async()=>{try{let s=Ke();if(!s){console.log("No account logged in.");return}try{await Ss(s)}catch{}cs(),console.log("Logged out.")}catch(s){console.error("Logout failed:",s),process.exit(1)}});x.command("sync-list-remote").description("List available remote vaults").action(async()=>{try{let s=he();console.log("Fetching vaults...");let e=await vs(s,Sr);if(e.vaults.length===0&&e.shared.length===0){console.log("No vaults found.");return}console.log(`
Vaults:`);let t=i=>console.log(` ${i.id} "${i.name}" (${i.region})`);for(let i of e.vaults)t(i);if(e.shared.length>0){console.log(`
Shared vaults:`);for(let i of e.shared)t(i)}}catch(s){console.error("Failed to list vaults:",s),process.exit(1)}});x.command("sync-list-local").description("List locally configured vaults").action(()=>{try{let s=ps();if(s.length===0){console.log("No vaults configured.");return}console.log("Configured vaults:");for(let e of s){let t=fs(e);t&&(console.log(` ${e}`),console.log(` Path: ${t.vaultPath}`),console.log(` Host: ${t.host}`))}}catch(s){console.error("Failed to list vaults:",s),process.exit(1)}});x.command("sync-create-remote").description("Create a new remote vault").requiredOption("--name <name>","Vault name").option("--encryption <standard|e2ee>","Encryption").option("--password <encryption-password>","End-to-end encryption password (prompt if omitted)").option("--region <region>","Vault region (leave empty for automatic)").action(async s=>{try{let e=he(),t=s.name,i=s.password;!i&&s.encryption!=="standard"&&(i=await Ue("End-to-end encryption password (leave empty for standard encryption): "));let n=s.region||"";if(n){let c=(await Ur(e)).regions;if(!c.some(f=>f.value===n)){console.error(`Invalid region: "${n}". Available regions:`);for(let f of c)console.error(` ${f.value} (${f.name})`);process.exit(1)}}console.log("Creating vault...");let r,o=null;if(i){r=Y(crypto.getRandomValues(new Uint8Array(16)));let l=await vr(i,r);o=await Er(l,r,wr)}let a=await Kr(e,t,o,r,n,wr);console.log(`
Vault created successfully!`),console.log(` Vault ID: ${a.id}`),console.log(` Vault name: ${a.name}`),console.log(` Region: ${a.region}`),console.log(` Encryption: ${i?"end-to-end":"managed"}`),console.log(`
Run '${Q} sync-setup --vault "${a.id}"' to configure sync.`)}catch(e){console.error("Failed to create vault:",e),process.exit(1)}});x.command("sync-setup").description("Setup sync from a local path to a remote vault").requiredOption("--vault <vault>","Remote vault ID or name").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--password <encryption-password>","End-to-end encryption password (prompted if omitted)").option("--device-name <name>","Device name to identify this client in the sync version history").option("--config-dir <name>","Config directory name (default: .obsidian)").action(async s=>{try{let e=he(),t=s.vault,i=T.default.resolve(s.path||"."),n=s.password,r=s.deviceName||"",o=ds(s.configDir);console.log("Fetching vault info...");let a=await vs(e,Sr),l=[...a.vaults,...a.shared],c=l.find(S=>S.id===t);if(!c){let S=l.filter(d=>d.name===t);if(S.length===1)c=S[0];else if(S.length>1){console.error(`Multiple vaults named "${t}". Use the vault ID instead:`);for(let d of S)console.error(` ${d.id} "${d.name}"`);process.exit(1)}}c||(console.error(`Vault "${t}" not found.`),process.exit(3));let f=c.id;c.password?n=c.password:n||(n=await Ue("End-to-end encryption password: ")),n||(console.error("Failed to validate password."),process.exit(2)),console.log("Setting up...");let u=await vr(n,c.salt),h=await Er(u,c.salt,c.encryption_version);try{await Vr(e,f,h,c.host,c.encryption_version)}catch{console.error("Failed to validate password."),process.exit(2)}let y={vaultId:f,vaultName:c.name,vaultPath:i,host:c.host,encryptionVersion:c.encryption_version,encryptionKey:no(u),encryptionSalt:c.salt,conflictStrategy:"merge",deviceName:r,configDir:o};us(f),hs(f,y),console.log(`
Vault configured successfully!`),ss(y),D.default.existsSync(i)?D.default.readdirSync(i).filter(p=>!p.startsWith(".")).length>0&&(console.log(`
Warning: Your local vault already contains some notes.`),console.log("If you start syncing, notes in your local vault will be merged with notes from your remote vault."),console.log("In case of conflicts, the most recent version of the note will be preserved.")):D.default.mkdirSync(i,{recursive:!0}),Lc(),console.log(`
Run '${Q} sync' to start syncing.`)}catch(e){console.error("Setup failed:",e),process.exit(1)}});x.command("sync-config").description("Change sync configuration for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--conflict-strategy <strategy>","Conflict resolution strategy (merge or conflict)").option("--excluded-folders <folders>","Folders to exclude, comma-separated (empty string to clear)").option("--file-types <types>","Attachment types to sync, comma-separated: image, audio, video, pdf, unsupported (empty to clear)").option("--configs <settings>","Config categories to sync, comma-separated: app, appearance, appearance-data, hotkey, core-plugin, core-plugin-data, community-plugin, community-plugin-data (empty to clear)").option("--device-name <name>","Device name to identify this client in the sync version history").option("--mode <mode>","Sync mode: bidirectional (default), pull-only (only download, ignore local changes), or mirror-remote (only download, revert local changes)").option("--config-dir <name>","Config directory name (default: .obsidian)").action(s=>{try{let e=T.default.resolve(s.path||"."),t=We(e);t||(console.error(`No sync configuration found for ${e}`),console.error(`Run '${Q} sync-setup' first.`),process.exit(3));let i=!1;s.mode!==void 0&&(s.mode!=="bidirectional"&&s.mode!=="pull-only"&&s.mode!=="mirror-remote"&&(console.error(`Invalid sync mode: "${s.mode}". Must be "bidirectional", "pull-only", or "mirror-remote".`),process.exit(1)),s.mode==="bidirectional"?delete t.syncMode:t.syncMode=s.mode,i=!0),s.conflictStrategy!==void 0&&(s.conflictStrategy!=="merge"&&s.conflictStrategy!=="conflict"&&(console.error(`Invalid conflict strategy: "${s.conflictStrategy}". Must be "merge" or "conflict".`),process.exit(1)),t.conflictStrategy=s.conflictStrategy,i=!0),s.excludedFolders!==void 0&&(s.excludedFolders===""?delete t.ignoreFolders:t.ignoreFolders=s.excludedFolders.split(",").map(n=>n.trim()),i=!0),s.fileTypes!==void 0&&(s.fileTypes===""?delete t.allowTypes:t.allowTypes=xr(s.fileTypes),i=!0),s.configs!==void 0&&(s.configs===""?delete t.allowSpecialFiles:t.allowSpecialFiles=qr(s.configs),i=!0),s.deviceName!==void 0&&(t.deviceName=s.deviceName,i=!0),s.configDir!==void 0&&(t.configDir=ds(s.configDir),i=!0),i?(hs(t.vaultId,t),console.log("Configuration updated:")):console.log("No options provided. Current configuration:"),ss(t)}catch(e){console.error("Config update failed:",e),process.exit(1)}});x.command("sync-status").description("Show sync status for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=We(e);t||(console.error(`No sync configuration found for ${e}`),process.exit(3)),Ke()||console.log("Not logged in."),t.encryptionKey||console.log("End-to-end encryption key missing. Run setup again."),console.log("Sync Configuration:"),ss(t)}catch(e){console.error("Status check failed:",e),process.exit(1)}});x.command("sync-unlink").description("Disconnect a vault from sync and remove stored credentials").option("--path <local-path>","Local vault path (use current directory if omitted)").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=We(e);t||(console.error(`No sync configuration found for ${e}`),process.exit(3)),kr(t.vaultId),console.log(`Sync configuration removed for ${e}`)}catch(e){console.error("Unlink failed:",e),process.exit(1)}});x.command("sync").description("Sync a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--continuous","Run in continuous sync mode").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=We(e);t||(console.error(`No sync configuration found for ${e}`),console.error(`Run '${Q} sync-setup' first.`),process.exit(3));let i=he();(!t.encryptionKey||!t.encryptionSalt||t.encryptionVersion==null)&&(console.error("Encryption key not found. Run setup again."),process.exit(2));let n=await Pc(t.encryptionVersion,so(t.encryptionKey),t.encryptionSalt),r=Br(Cr(t.vaultId));t.deviceName||(t.deviceName=bs()),(!t.configDir||!t.configDir.startsWith("."))&&(t.configDir=".obsidian"),Lc();let o=new ts(D.default,T.default,Or(t.vaultPath,t.configDir));try{o.acquire()}catch{console.error("Another sync instance is already running for this vault."),r(),process.exit(1)}let a;try{a=new zi({config:t,token:i,encryption:n,continuous:s.continuous});let l=()=>{console.log(`
Received signal to shut down...`),a.stop()};process.on("SIGINT",l),process.on("SIGTERM",l),console.log("Starting sync:"),ss(t),await a.sync()}finally{o.release(),r(),a?.stop()}process.exit(0)}catch(e){console.error("Sync failed:",e),process.exit(1)}});function ss(s){console.log(` Vault: ${s.vaultName} (${s.vaultId})`),console.log(` Location: ${s.vaultPath}`),console.log(` Sync mode: ${s.syncMode||"bidirectional"}`),console.log(` Conflict strategy: ${s.conflictStrategy}`),console.log(` Device name: ${s.deviceName||bs()}`),s.configDir&&console.log(` Config directory: ${s.configDir}`);let{allowTypes:e,allowSpecialFiles:t,ignoreFolders:i}=s;console.log(` File types: ${(e||Le).join(", ")}`),console.log(` Configs: ${t?.length?(t||[]).join(", "):"none (config syncing disabled)"}`),i&&i.length>0&&console.log(` Excluded folders: ${i.join(", ")}`)}x.command("publish-list-sites").description("List publish sites").action(async()=>{try{let s=he();console.log("Fetching sites...");let e=await Es(s);if(e.sites.length===0&&e.shared.length===0){console.log("No publish sites found.");return}let t=[...e.sites,...e.shared],i={};try{i=await Fs(s,t.map(r=>r.id))}catch{}console.log(`
Sites:`);let n=r=>{let o=i[r.id]||"";console.log(` ${r.id} ${o?'"'+o+'"':"(no slug)"}`)};for(let r of e.sites)n(r);if(e.shared.length>0){console.log("Shared sites:");for(let r of e.shared)n(r)}}catch(s){console.error("Failed to list sites:",s),process.exit(1)}});x.command("publish-create-site").description("Create a new publish site").requiredOption("--slug <slug>","Site slug (URL identifier)").action(async s=>{try{let e=he();console.log("Creating site...");let t=await Wr(e);await Jr(e,t.id,t.host,s.slug),console.log(`
Site created successfully!`),console.log(` Site ID: ${t.id}`),console.log(` Slug: ${s.slug}`),console.log(` Host: ${t.host}`),console.log(`
Run '${Q} publish-setup --site "${t.id}"' to connect a vault.`)}catch(e){console.error("Failed to create site:",e),process.exit(1)}});x.command("publish-setup").description("Connect a local vault to a publish site").requiredOption("--site <id-or-slug>","Site ID or slug").option("--path <local-path>","Local vault path (use current directory if omitted)").action(async s=>{try{let e=he(),t=T.default.resolve(s.path||"."),i=s.site;console.log("Fetching sites...");let n=await Es(e),r=[...n.sites,...n.shared],o=r.find(l=>l.id===i);if(!o){let l={};try{l=await Fs(e,r.map(f=>f.id))}catch{}let c=Object.entries(l).find(([,f])=>f===i)?.[0];c&&(o=r.find(f=>f.id===c))}o||(console.error(`Site "${i}" not found.`),process.exit(1));let a={siteId:o.id,host:o.host,vaultPath:t};ys(o.id,a),console.log(`
Site connected successfully!`),Tc(a),D.default.existsSync(t)||D.default.mkdirSync(t,{recursive:!0}),console.log(`
Run '${Q} publish --dry-run' to preview changes.`)}catch(e){console.error("Setup failed:",e),process.exit(1)}});x.command("publish").description("Publish vault changes to site").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--dry-run","Show changes without publishing").option("--yes","Publish without prompting for confirmation").option("--all","Include files without a publish flag").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=qt(e);t||(console.error(`No publish configuration found for ${e}`),console.error(`Run '${Q} publish-setup' first.`),process.exit(1));let i=he(),n=new Ui(i,t);console.log("Scanning for changes...");let r=await n.scanForChanges(s.all);r.length===0&&(console.log("No changes to publish."),process.exit(0));let o=r.filter(u=>u.type==="new"),a=r.filter(u=>u.type==="changed"),l=r.filter(u=>u.type==="deleted");if(o.length>0){console.log(`
New (${o.length}):`);for(let u of o)console.log(` + ${u.path}`)}if(a.length>0){console.log(`
Changed (${a.length}):`);for(let u of a)console.log(` ~ ${u.path}`)}if(l.length>0){console.log(`
Deleted (${l.length}):`);for(let u of l)console.log(` - ${u.path}`)}console.log(`
Total: ${r.length} changes`),s.dryRun&&process.exit(0),s.yes||(await Ue("Publish these changes? (y/N) ",!0)).toLowerCase()!=="y"&&(console.log("Cancelled."),process.exit(1)),console.log(`
Publishing...`);let c=r.length,f=0;for(let u of r)u.type==="new"||u.type==="changed"?(console.log(`Uploading (${f}/${c}) ${u.path}`),await n.uploadFile(u.path)):u.type==="deleted"&&(console.log(`Deleting (${f}/${c}) ${u.path}`),await n.removeFile(u.path)),f++;console.log(`
Done.`),process.exit(0)}catch(e){console.error("Publish failed:",e),process.exit(1)}});x.command("publish-config").description("Configure publish settings for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--includes <folders>","Folders to include, comma-separated (empty string to clear)").option("--excludes <folders>","Folders to exclude, comma-separated (empty string to clear)").action(s=>{try{let e=T.default.resolve(s.path||"."),t=qt(e);t||(console.error(`No publish configuration found for ${e}`),console.error(`Run '${Q} publish-setup' first.`),process.exit(1));let i=!1;s.includes!==void 0&&(s.includes===""?delete t.includes:t.includes=s.includes.split(",").map(n=>n.trim()),i=!0),s.excludes!==void 0&&(s.excludes===""?delete t.excludes:t.excludes=s.excludes.split(",").map(n=>n.trim()),i=!0),i?(ys(t.siteId,t),console.log("Configuration updated:")):console.log("No options provided. Current configuration:"),Tc(t)}catch(e){console.error("Config update failed:",e),process.exit(1)}});x.command("publish-unlink").description("Disconnect a vault from a publish site").option("--path <local-path>","Local vault path (use current directory if omitted)").action(s=>{try{let e=T.default.resolve(s.path||"."),t=qt(e);t||(console.error(`No publish configuration found for ${e}`),process.exit(1)),Rr(t.siteId),console.log(`Publish configuration removed for ${e}`)}catch(e){console.error("Unlink failed:",e),process.exit(1)}});function Tc(s){console.log(` Site: ${s.siteId}`),console.log(` Host: ${s.host}`),console.log(` Location: ${s.vaultPath}`),s.includes?.length&&console.log(` Includes: ${s.includes.join(", ")}`),s.excludes?.length&&console.log(` Excludes: ${s.excludes.join(", ")}`)}function Ue(s,e){return new Promise(t=>{if(process.stdin.isTTY){process.stdout.write(s),process.stdin.setRawMode(!0),process.stdin.resume();let i="",n=()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(s+(e?i:"*".repeat(i.length)))},r=o=>{let a=o.toString();a===`
`||a==="\r"?(process.stdin.setRawMode(!1),process.stdin.pause(),process.stdin.removeListener("data",r),process.stdout.write(`
`),t(i)):a===""?(process.stdin.setRawMode(!1),process.exit(1)):a==="\x7F"||a==="\b"?(i=i.slice(0,-1),n()):(i+=a,process.stdout.write(e?a:"*".repeat(a.length)))};process.stdin.on("data",r)}else{let i="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",n=>{i+=n}),process.stdin.on("end",()=>{t(i.trimEnd())}),process.stdin.resume()}})}function Lc(){(process.platform==="win32"||process.platform==="darwin")&&!Pr()&&console.warn("Warning: btime native module failed to load. File creation times will not be preserved.")}function he(){let s=Ke();return s||(console.error(`No account logged in. Run "${Q} login" first.`),process.exit(2)),s}x.parse();