@decimalturn/toml-patch 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/toml-patch.d.ts +1 -0
- package/dist/toml-patch.js +13 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.0.2] - 2026-08-09
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Patching: add an element to an inline array of tables (`xs = [{ ... }]`) as an inline element rather than emitting a `[[xs]]` section alongside it, which defined the key twice. ([#267])
|
|
15
|
+
- Patching: match a sibling's inner trailing comma when adding an inline table to an array, instead of taking it from the array's own separator (`{ z = 0, }` beside `{ a = 1 }`). ([#267])
|
|
16
|
+
- Patching: match sibling bracket spacing when adding an inline table to an inline array (`{ z = 0 }` beside `{ a = 1 }`). ([#270])
|
|
17
|
+
- Patching: keep an implicit parent table as an empty header when its last child is removed (`[a.b]` → `{ a: {} }` now produces `[a]` instead of an empty document). Covers both table (`[a.b]`) and array-of-tables (`[[a.b]]`) cases. ([#270])
|
|
18
|
+
- Patching: pair renames one target each, so collapsing several equal-valued keys onto one no longer emits a key with an empty name. Keys sharing a value are matched in order, keeping their comments, and only the leftovers become removes or adds. ([#269])
|
|
19
|
+
- Patching: rename a `[table]` section key instead of throwing. The rename path read the key node directly, which only works for a key-value — a section wraps it in a `TableKey`. ([#269])
|
|
20
|
+
- Patching: rename a segment of a dotted section key (e.g. `[a.b]` → `[x.b]`, `[a.b]` → `[a.y]`, `[a.b.c]` → `[a.x.c]`) instead of throwing. The Rename handler now falls back to key-prefix search and handles segment-count mismatches when the target is rendered as a plain nested key. ([#269])
|
|
21
|
+
- Patching: avoid extra blank line when the first array-of-tables entry is converted to a table in-place during implicit parent materialisation. ([#271])
|
|
22
|
+
- Stringify: prevent float-to-bigint type change on round-trip. Whole-number values exceeding `Number.MAX_SAFE_INTEGER` (e.g. `743000000000000000` from TOML `743e+15`) are now always emitted with a decimal point so they stay as `number` on re-parse instead of being promoted to `bigint`. ([#273])
|
|
23
|
+
- Patching: modifying nested dotted-key values that change from a table to a scalar (e.g. `a.b.c = 1` → `a.b = 42` under `[a.b]`) no longer emits conflicting inline tables or misplaces the value. ([#274])
|
|
24
|
+
- Patching: adding a key to a nested table array element (e.g. `[[a.b]]`) no longer throws "Incompatible child type 'InlineItem'". ([#274])
|
|
25
|
+
- Patching: Move entire AOT entry + owned comments as a unit during reorder so comments follow their entries when updateOrder is enabled.
|
|
26
|
+
- Patching: tighten empty single-line inline tables and propagate to parent containers ([#276])
|
|
27
|
+
- Patching: unwrap InlineArrayItem when inserting into nested inline array ([#276])
|
|
28
|
+
- Patching: adjust commented out kv behavior to match expected behavior of comment ownership rules ([#277])
|
|
29
|
+
- Patching: ensure inline container tightening for deletions ([#278])
|
|
30
|
+
|
|
10
31
|
## [3.0.1] - 2026-08-03
|
|
11
32
|
|
|
12
33
|
### Fixed
|
|
@@ -347,4 +368,13 @@ This first forked version from [timhall/toml-patch](https://github.com/timhall/t
|
|
|
347
368
|
[#264]: https://github.com/DecimalTurn/toml-patch/pull/264
|
|
348
369
|
[#265]: https://github.com/DecimalTurn/toml-patch/pull/265
|
|
349
370
|
[#266]: https://github.com/DecimalTurn/toml-patch/pull/266
|
|
371
|
+
[#267]: https://github.com/DecimalTurn/toml-patch/pull/267
|
|
372
|
+
[#269]: https://github.com/DecimalTurn/toml-patch/pull/269
|
|
373
|
+
[#270]: https://github.com/DecimalTurn/toml-patch/pull/270
|
|
374
|
+
[#271]: https://github.com/DecimalTurn/toml-patch/pull/271
|
|
375
|
+
[#273]: https://github.com/DecimalTurn/toml-patch/pull/273
|
|
376
|
+
[#274]: https://github.com/DecimalTurn/toml-patch/pull/274
|
|
377
|
+
[#276]: https://github.com/DecimalTurn/toml-patch/pull/276
|
|
378
|
+
[#277]: https://github.com/DecimalTurn/toml-patch/pull/277
|
|
379
|
+
[#278]: https://github.com/DecimalTurn/toml-patch/pull/278
|
|
350
380
|
[0e66e68]: https://github.com/DecimalTurn/toml-patch/commit/0e66e68cbf42a07bc44445e46c3ea7bea97f95c1
|
package/dist/toml-patch.d.ts
CHANGED
package/dist/toml-patch.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.0.
|
|
1
|
+
//! @decimalturn/toml-patch v3.0.2 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableKey`}function r(e){return e.type===`TableArray`}function i(e){return e.type===`TableArrayKey`}function a(e){return e.type===`KeyValue`}function o(e){return e.type===`String`}function s(e){return e.type===`Float`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(e){return e.type===`Comment`}function p(n){return e(n)||t(n)||r(n)||d(n)||l(n)}function m(e){return n(e)||i(e)||u(e)}function h(e){return a(e)||t(e)||r(e)||f(e)}function g(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function _(e,t){let n=Array.isArray(e)?e:y(e);if(n.length===0)return{line:1,column:t};let r=0,i=n.length-1;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}n[r]<t&&r++;let a=r+1;return{line:a,column:t-(n[a-2]+1||0)}}function v(e,t){let n=y(e),r=n[t.line-2]===void 0?0:n[t.line-2]+1,i=n[t.line-1]||e.length;return e.substring(r,i)}function y(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===10?t.push(n):r===13&&(e.charCodeAt(n+1)===10?(t.push(n+1),n++):t.push(n))}return t.push(e.length),t}function b(e){return{line:e.line,column:e.column}}function x(e){return{start:b(e.start),end:b(e.end)}}function S(){return{line:1,column:0}}var C=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=v(e,t),i=`${w(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function w(e,t=` `){return t.repeat(e)}const T=/^[\w-]+$/,ee=/[\w,\d,",',+,\-,_]/;function*E(e){let t=e.length,n=0,r=[],i=(e,t)=>({start:_(r,e),end:_(r,t)});for(;n<t;){let c=e.charCodeAt(n);if((c<=31||c===127)&&c!==9&&c!==13&&c!==10)throw new C(e,_(r,n),`Control char 0x${c.toString(16).toUpperCase().padStart(2,`0`)} not allowed`);if(c===13&&(n+1>=t||e.charCodeAt(n+1)!==10))throw new C(e,_(r,n),`Standalone CR; must be CRLF or LF`);if(c!==32&&c!==9&&c!==13)if(c===10)r.push(n);else if(c===91||c===93)yield{type:`Bracket`,raw:e[n],loc:i(n,n+1)};else if(c===123||c===125)yield{type:`Curly`,raw:e[n],loc:i(n,n+1)};else if(c===61)yield{type:`Equal`,raw:`=`,loc:i(n,n+1)};else if(c===44)yield{type:`Comma`,raw:`,`,loc:i(n,n+1)};else if(c===46)yield{type:`Dot`,raw:`.`,loc:i(n,n+1)};else if(c===35)yield a();else{let t=D(e,n,`'`)||D(e,n,`"`);t?yield o(t):yield s()}n++}function a(){let a=n;for(;n+1<t;){let t=e.charCodeAt(n+1);if(t===10||t===13)break;n++;let i=e.charCodeAt(n);if((i<=31||i===127)&&i!==9)throw new C(e,_(r,n),`Control char 0x${i.toString(16).toUpperCase().padStart(2,`0`)} not allowed`)}return{type:`Comment`,raw:e.slice(a,n+1),loc:i(a,n+1)}}function o(a){let o=n,s=a+a+a;for(n+=3;n<t;){if(D(e,n,a)){let t=3;for(;e[n+t]===a;)t++;if(t>=6)throw new C(e,_(r,n),`Invalid multiline string: ${t} consecutive ${a} characters`);if(t===3){n+=2;break}n+=t-3,n+=2;break}let i=e.charCodeAt(n);if(i===13&&(n+1>=t||e.charCodeAt(n+1)!==10))throw new C(e,_(r,n),`Standalone CR in multiline string; must be CRLF or LF`);if((i<=31||i===127)&&i!==9&&i!==10&&i!==13){let t=a===`"`?`multiline basic strings`:`multiline literal strings`,o=`0x${i.toString(16).toUpperCase().padStart(2,`0`)}`,s=``;i===0?s=`Null`:i===127&&(s=`DEL`);let c=s?`${s} (${o}) not allowed in ${t}`:`Control char ${o} not allowed in ${t}`;throw new C(e,_(r,n),c)}i===10&&r.push(n),n++}if(n>=t){if(a===`"`){let i=0,a=t-1;for(;a>=0&&e[a]===`\\`;)i++,a--;if(i>0&&i%2!=0)throw new C(e,_(r,n),`Unterminated multiline ${s} (possible escape issue)`)}throw new C(e,_(r,n),`Unterminated multiline ${s}`)}return{type:`Literal`,raw:e.slice(o,n+1),loc:i(o,n+1)}}function s(){let a=e[n];if(!ee.test(a))throw new C(e,_(r,n),`Unexpected char "${a}"`);let o=n,s=a===`"`,c=a===`'`;for(;n<t&&!(n+1>=t);){let i=e.charCodeAt(n+1);if(!(s||c)&&(i===32||i===9||i===10||i===13||i===44||i===46||i===93||i===125||i===61||i===35))break;if(n++,!(s||c)){let t=e.charCodeAt(n);if(t<=31||t===127)throw new C(e,_(r,n),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed in unquoted value`)}if(s||c){let t=e.charCodeAt(n);if((t<=31||t===127)&&t!==9){let i=s?`basic strings`:`literal strings`,a=`0x${t.toString(16).toUpperCase().padStart(2,`0`)}`,o=``;t===10?o=`Newline`:t===13?o=`Carriage return`:t===0?o=`Null`:t===127&&(o=`DEL`);let c=o?`${o} (${a}) not allowed in ${i}`:`Control char ${a} not allowed in ${i}`;throw new C(e,_(r,n),c)}}let a=e[n];if(a===`"`&&(s=!s),a===`'`&&!s&&(c=!c),n+1>=t)break;if(s&&a===`\\`){let t=e[n+1];(t===`"`||t===`\\`)&&n++}}if(s||c)throw new C(e,_(r,o),`Expected close of string with ${s?`"`:`'`}`);return{type:`Literal`,raw:e.slice(o,n+1),loc:i(o,n+1)}}}function D(e,t,n){if(!n||e[t]!==n||e[t+1]!==n||e[t+2]!==n)return!1;if(n===`'`)return n;let r=0,i=t-1;for(;i>=0&&e[i]===`\\`;)r++,i--;return(r===0||r%2==0)&&n}const O=new Int8Array(128);O.fill(-1);for(let e=0;e<10;e++)O[48+e]=e;for(let e=0;e<6;e++)O[65+e]=10+e,O[97+e]=10+e;function k(e){let t=e.charCodeAt(0);return t<128&&O[t]!==-1}function te(e,t){return O[e.charCodeAt(t)]<<12|O[e.charCodeAt(t+1)]<<8|O[e.charCodeAt(t+2)]<<4|O[e.charCodeAt(t+3)]}function ne(e){return e.startsWith(`'''`)?ie(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?re(ie(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?re(e.slice(1,e.length-1),!1):e}function re(e,t){let n=e.length;if(!t&&e.indexOf(`\\`)===-1)return e;let r=[],i=0;for(let a=0;a<n;a++){if(e[a]!==`\\`)continue;if(a>i&&r.push(e.slice(i,a)),a++,a>=n)throw Error(`Trailing backslash`);let o=e[a];switch(o){case`b`:r.push(`\b`);break;case`t`:r.push(` `);break;case`n`:r.push(`
|
|
3
3
|
`);break;case`f`:r.push(`\f`);break;case`r`:r.push(`\r`);break;case`"`:r.push(`"`);break;case`\\`:r.push(`\\`);break;case`e`:r.push(`\x1B`);break;case`u`:{if(a+4>n||!k(e[a+1])||!k(e[a+2])||!k(e[a+3])||!k(e[a+4]))throw Error(`Invalid Unicode escape: \\u${e.slice(a+1,a+5)}`);let t=te(e,a+1);if(t>=55296&&t<=57343)throw Error(`Invalid \\u${e.slice(a+1,a+5)}: surrogates not allowed`);r.push(String.fromCharCode(t)),a+=4;break}case`U`:{if(a+8>n)throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);for(let t=1;t<=8;t++)if(!k(e[a+t]))throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);let t=parseInt(e.slice(a+1,a+9),16);if(t>=55296&&t<=57343)throw Error(`Invalid \\U${e.slice(a+1,a+9)}: surrogates not allowed`);r.push(String.fromCodePoint(t)),a+=8;break}case`x`:{if(a+2>n||!k(e[a+1])||!k(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=O[e.charCodeAt(a+1)]<<4|O[e.charCodeAt(a+2)];r.push(String.fromCharCode(t)),a+=2;break}default:if(t&&(o===`
|
|
4
4
|
`||o===`\r`||o===` `||o===` `)){let t=o===`
|
|
5
5
|
`||o===`\r`,r=a;for(;r<n&&(e[r]===` `||e[r]===` `||e[r]===`
|
|
6
6
|
`||e[r]===`\r`);)(e[r]===`
|
|
7
|
-
`||e[r]===`\r`)&&(t=!0),r++;if(!t)throw Error(`Invalid escape sequence: \\${o}`);a=r-1;break}throw Error(`Invalid escape sequence: \\${o}`)}i=a+1}return i===0?e:(i<n&&r.push(e.slice(i)),r.join(``))}function ie(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var ae=class{iterator;index;value;done;peeked;constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){if(this.done)return se();let e=this.peeked||this.iterator.next();return this.index+=1,this.value=e.value,this.done=e.done??!1,this.peeked=null,e}peek(){return this.done?se():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const oe=Object.freeze({value:void 0,done:!0});function se(){return oe}function A(e){return{year:String(e.getUTCFullYear()).padStart(4,`0`),month:String(e.getUTCMonth()+1).padStart(2,`0`),day:String(e.getUTCDate()).padStart(2,`0`),hours:String(e.getUTCHours()).padStart(2,`0`),minutes:String(e.getUTCMinutes()).padStart(2,`0`),seconds:String(e.getUTCSeconds()).padStart(2,`0`),ms:e.getUTCMilliseconds()}}function j(e,t,n=/\.(\d+)\s*$/){if(t&&t.includes(`.`)){let r=t.match(n),i=r?r[1].length:3;return`.`+String(e).padStart(3,`0`).slice(0,i)}return e>0?`.`+String(e).padStart(3,`0`).replace(/0+$/,``):``}function ce(e){if(e===`Z`)return 0;let t=e[0]===`+`?1:-1,[n,r]=e.slice(1).split(`:`);return t*(parseInt(n)*60+parseInt(r))}var le=class e{static IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/;static IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/;static IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;static createDateWithOriginalFormat(t,n){if(e.IS_DATE_ONLY.test(n)){if(t.getUTCHours()!==0||t.getUTCMinutes()!==0||t.getUTCSeconds()!==0||t.getUTCMilliseconds()!==0){if(t instanceof N)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new M(e,!1)}let e=t.toISOString().split(`T`)[0];return new ue(e)}else if(e.IS_TIME_ONLY.test(n)){if(t instanceof de)return t;{let e=A(t),r=j(e.ms,n);return new de(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}else if(e.IS_LOCAL_DATETIME_T.test(n)){let e=A(t),r=j(e.ms,n);return new M(`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`,!1,n)}else if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=A(t),r=j(e.ms,n);return new M(`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`,!0,n)}else if(e.IS_OFFSET_DATETIME_T.test(n)||e.IS_OFFSET_DATETIME_SPACE.test(n)){let r=n.match(/([+-]\d{2}:\d{2}|[Zz])$/),i=r?r[1]===`z`?`Z`:r[1]:`Z`,a=e.IS_OFFSET_DATETIME_SPACE.test(n),o=A(new Date(t.getTime()+ce(i)*6e4)),s=a?` `:`T`,c=j(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new N(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}else return t}},ue=class extends Date{constructor(e){super(e)}toISOString(){let e=A(this);return`${e.year}-${e.month}-${e.day}`}},de=class extends Date{originalFormat;constructor(e,t){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+`:00`),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){let e=A(this);return`${e.hours}:${e.minutes}:${e.seconds}${j(e.ms,this.originalFormat)}`}},M=class extends Date{useSpaceSeparator=!1;originalFormat;constructor(e,t=!1,n){let r=e;/\d{2}:\d{2}:\d{2}/.test(e)||(r=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(r.replace(` `,`T`)+`Z`),this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){let e=A(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${j(e.ms,this.originalFormat)}`}},N=class extends Date{useSpaceSeparator=!1;originalOffset;originalFormat;constructor(e,t=!1){let n=e;/\d{2}:\d{2}:\d{2}/.test(e)||(n=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(n.replace(` `,`T`)),this.useSpaceSeparator=t,this.originalFormat=e;let r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset=r[1]===`z`?`Z`:r[1])}toISOString(){if(this.originalOffset){let e=A(new Date(this.getTime()+ce(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=j(e.ms,this.originalFormat,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${n}${this.originalOffset}`}let e=super.toISOString();return this.useSpaceSeparator?e.replace(`T`,` `):e}};const P=le,fe=`true`,pe=/e/i,me=/_/g,he=/^[+-]?inf$/,ge=/^[+-]?nan$/,_e=/^[+-]?0x/i;function ve(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const ye=/^[+-]?0o/i,be=/^[+-]?0b/i;function xe(e,t,n){for(let r=0;r<e.length;r++)if(!ve(e.charCodeAt(r)))throw new C(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function Se(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new C(t,n,`Multiline strings cannot be keys`)}function Ce(e,t,n){try{return ne(e)}catch(e){throw new C(t,n,e.message)}}function we(e,t,n,r=!0){if(e.endsWith(`_`)||(r?/^[+-]?_/.test(e):e.startsWith(`_`)))throw new C(t,n,`Underscore must be between digits`);if(/__/.test(e))throw new C(t,n,`Consecutive underscores not allowed`)}function Te(e,t,n,r){let i=e.replace(me,``);if(/^[+-]?0\d/.test(i)&&!_e.test(e)&&!ye.test(e)&&!be.test(e))throw new C(t,n,`Leading zeros are not allowed in ${r}`)}function Ee(e,t,n,r){if(/_[eE]/.test(e))throw new C(n,r,`Underscore before exponent is not allowed`);if(/[eE][+-]?_/.test(e))throw new C(n,r,`Underscore at start of exponent is not allowed`);if(/[eE][+-]?$/.test(e))throw new C(n,r,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new C(n,r,`Invalid float "${t}": decimal point not allowed in exponent`)}function De(e,t,n,r,i,a){if(e.length!==2)throw new C(i,a,`"${r}": hour must be 2 digits`);if(t.length!==2)throw new C(i,a,`"${r}": minute must be 2 digits`);if(n&&n.length!==2)throw new C(i,a,`"${r}": second must be 2 digits`)}function Oe(e,t,n,r,i,a){if(e!==void 0){let t=parseInt(e,10);if(t<0||t>23)throw new C(i,a,`"${r}": hour must be 00-23`)}if(t!==void 0){let e=parseInt(t,10);if(e<0||e>59)throw new C(i,a,`"${r}": minute must be 00-59`)}if(n!==void 0){let e=parseInt(n,10);if(e<0||e>60)throw new C(i,a,`"${r}": second must be 00-60`)}}function ke(e,t,n){if(_e.test(e)||ye.test(e)||be.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new C(t,n,`Invalid integer "${e}"`)}function Ae(e,t,n,r,i,a,o){let s=r[0]+r[1].toUpperCase();if(RegExp(`^[+\\-]?`+s.replace(/([[\]])/g,`\\$1`)).test(e))throw new C(t,n,`${a} prefix must be lowercase "${r}"`);if(RegExp(`^[+\\-]?`+r+`_`,`i`).test(e))throw new C(t,n,`Underscore must be between digits`);let c=RegExp(`^[+\\-]?`+r,`i`),l=e.replace(c,``);if(!l||l===`_`||l.startsWith(`_`))throw new C(t,n,`Incomplete ${a.toLowerCase()} number`);let u=l.replace(/_/g,``);if(!i.test(u))throw new C(t,n,o??`Invalid ${a.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new C(t,n,`${a} numbers cannot have a sign prefix`)}function*je(e){let t=new ae(E(e));for(;!t.next().done;){let n=He(t,e);for(let e of n)yield e}}function*Me(e,t){for(let t of e)yield t;let n=new ae(E(t));for(;!n.next().done;){let e=He(n,t);for(let t of e)yield t}}function Ne(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function Pe(e,t){let n=!e.peek().done&&e.peek().value.type===`Bracket`?`TableArray`:`Table`,r=n===`Table`;if(r&&e.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected table opening "[", found ${e.value.raw}`);if(!r){let n=e.peek();if(n.done)throw new C(t,e.value.loc.start,`Expected "[[" for Array of Tables, found end of input`);if(e.value.raw!==`[`||n.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected "[[", found ${e.value.raw+n.value.raw}`);let r=e.value,i=n.value;if(r.loc.end.line!==i.loc.start.line||r.loc.end.column!==i.loc.start.column)throw new C(t,r.loc.start,`"[[" brackets must be adjacent (no whitespace)`)}let i=r?{type:`TableKey`,loc:e.value.loc}:{type:`TableArrayKey`,loc:e.value.loc};if(e.next(),n===`TableArray`&&e.next(),e.done)throw new C(t,i.loc.start,`Expected table key, reached end of file`);if(e.value.type===`Bracket`&&e.value.raw===`]`)throw new C(t,e.value.loc.start,n===`TableArray`?`Array of Tables header [[]] requires a table name`:`Table header [] requires a table name`);let a=e.value.raw;Se(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||xe(a,t,e.value.loc.start);let o;for(o=[Ce(e.value.raw,t,e.value.loc.start)],i.item={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:o};!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;r.startsWith(`"`)||r.startsWith(`'`)||xe(r,t,e.value.loc.start);let a=` `.repeat(n.loc.start.column-i.item.loc.end.column),o=` `.repeat(e.value.loc.start.column-n.loc.end.column);i.item.loc.end=e.value.loc.end,i.item.raw+=`${a}.${o}${e.value.raw}`;try{i.item.value.push(ne(e.value.raw))}catch(n){let r=n;throw new C(t,e.value.loc.start,r.message)}}if(e.next(),!e.done){let n=i.loc.start.line;if(e.value.loc.start.line!==n)throw new C(t,e.value.loc.start,r?`Table header must be single-line`:`Array of Tables header must be single-line`)}if(r&&(e.done||e.value.raw!==`]`))throw new C(t,e.done?i.item.loc.end:e.value.loc.start,`Expected table closing "]", found ${e.done?`end of file`:e.value.raw}`);if(!r&&(e.done||e.peek().done||e.value.raw!==`]`||e.peek().value.raw!==`]`))throw new C(t,e.done||e.peek().done?i.item.loc.end:e.value.loc.start,`Expected "]]" closing, found ${e.done||e.peek().done?`end of file`:e.value.raw+e.peek().value.raw}`);if(!r){let n=e.value,r=e.peek().value;if(n.loc.end.line!==r.loc.start.line||n.loc.end.column!==r.loc.start.column)throw new C(t,n.loc.start,`"]]" brackets must be adjacent (no whitespace)`)}if(r||e.next(),i.loc.end=e.value.loc.end,!e.peek().done){let n=e.peek().value;if(n.loc.start.line===i.loc.end.line&&n.type!==`Comment`)throw new C(t,n.loc.start,`Extra content after ${r?`table`:`Array of Tables`} header`)}let s=[];for(;!e.peek().done&&e.peek().value.type!==`Bracket`;){e.next();let n=He(e,t);for(let e=0;e<n.length;e++)s.push(n[e])}return{type:r?`Table`:`TableArray`,loc:{start:b(i.loc.start),end:s.length?b(s[s.length-1].loc.end):b(i.loc.end)},key:i,items:s}}function Fe(e,t){let n=Ce(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function Ie(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===fe}}function Le(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&P.IS_FULL_DATE.test(r)&&P.IS_FULL_TIME.test(e.peek().value.raw)){let t=n.start;e.next(),n={start:t,end:e.value.loc.end},r+=` ${e.value.raw}`}if(!e.peek().done&&e.peek().value.type===`Dot`){let i=n.start;if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new C(t,e.value.loc.end,`Expected fractional value for DateTime`);e.next(),n={start:i,end:e.value.loc.end},r+=`.${e.value.raw}`}if(ze(r,t,n.start),P.IS_FULL_DATE.test(r))i=P.IS_DATE_ONLY.test(r)?new ue(r):P.IS_LOCAL_DATETIME_T.test(r)?new M(r,!1):P.IS_LOCAL_DATETIME_SPACE.test(r)?new M(r,!0):P.IS_OFFSET_DATETIME_T.test(r)?new N(r,!1):P.IS_OFFSET_DATETIME_SPACE.test(r)?new N(r,!0):new Date(r.replace(` `,`T`));else if(P.IS_TIME_ONLY.test(r))i=new de(r,r);else{let[e]=new Date().toISOString().split(`T`);i=new Date(`${e}T${r}`)}return{type:`DateTime`,loc:n,raw:r,value:i}}function Re(e,t){return t===2?e%4==0&&e%100!=0||e%400==0?29:28:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}function ze(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new C(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new C(t,n,`"${e}": offset needs HH:MM`);let r=/\d{2}:\d{2}/.test(e)?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(r){let e=r[0],i=r[2],a=r[3],o=r[4];if(a!==`:`)throw new C(t,n,`Offset "${e}": missing colon separator`);if(i.length!==2)throw new C(t,n,`Offset "${e}": hour must be 2 digits`);if(!o||o.length===0)throw new C(t,n,`Offset "${e}": minute required`);if(o.length!==2)throw new C(t,n,`Offset "${e}": minute must be 2 digits`);let s=parseInt(i,10);if(s<0||s>23)throw new C(t,n,`Offset "${e}": hour must be 00-23`);let c=parseInt(o,10);if(c<0||c>59)throw new C(t,n,`Offset "${e}": minute must be 00-59`)}if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/.test(e))throw/^\d{4}-\d{2}-\d{2}T$/.test(e)?new C(t,n,`"${e}": 'T' requires time component`):/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e)?new C(t,n,`Invalid date "${e}": unexpected character after date`):/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e)?new C(t,n,`"${e}": missing 'T' or space separator`):new C(t,n,`Invalid datetime "${e}"`);let i=e.match(/^(\d+)-/);if(i&&i[1].length!==4)throw new C(t,n,`"${e}": year must be 4 digits`);let a=e.match(/^(\d+)-(\d+)-(\d+)/);if(a){let[,,r,i]=a;if(r.length!==2)throw new C(t,n,`"${e}": month must be 2 digits`);if(i.length!==2)throw new C(t,n,`"${e}": day must be 2 digits`)}let o=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(o){let[,r,i,a]=o;De(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;De(r,i,a,e,t,n)}let c=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),l=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(c){let[,r,i,a,o,s,l]=c,u=parseInt(i,10);if(u<1||u>12)throw new C(t,n,`"${e}": month must be 01-12`);let d=parseInt(a,10);if(d<1||d>31)throw new C(t,n,`"${e}": day must be 01-31`);if(d>Re(parseInt(r,10),u))throw new C(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Oe(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Oe(r,i,a,e,t,n)}}function Be(e,t){let n=e.value.loc,r=e.value.raw,i;if(he.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(ge.test(r)){let e=new Float64Array(1),t=new DataView(e.buffer);r.startsWith(`-`)?(t.setUint32(0,0,!0),t.setUint32(4,4294443008,!0)):(t.setUint32(0,0,!0),t.setUint32(4,2146959360,!0)),i=e[0];let a=r.startsWith(`+`)?`+`:r.startsWith(`-`)?`-`:void 0;return{type:`Float`,loc:n,raw:r,value:i,nanSign:a}}else if(!e.peek().done&&e.peek().value.type===`Dot`){let a=n.start;{if(pe.test(r)&&!_e.test(r))throw new C(t,n.start,`Float "${r}": dot after exponent`);let e=r;Te(e,t,n.start,`the integer part of a float`);let i=e.replace(/^[+-]/,``);if(i===``||i===`_`)throw new C(t,n.start,`Float: digit required before dot`);we(e,t,n.start)}if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new C(t,e.value.loc.end,`Expected fraction value for Float`);e.next(),r+=`.${e.value.raw}`,n={start:a,end:e.value.loc.end};{let n=e.value.raw;if(!/^\d/.test(n))throw new C(t,e.value.loc.start,`Float: fraction must start with digit, found "${n}"`);we(n,t,e.value.loc.start,!1),Ee(n,r,t,e.value.loc.start)}i=Number(r.replace(me,``))}else{if(we(r,t,n.start),Ee(r,r,t,n.start),!e.peek().done&&e.peek().value.type===`Dot`)throw new C(t,e.peek().value.loc.start,`Float "${r}.": dot after exponent`);Te(r,t,n.start,`the integer part of a float`),i=Number(r.replace(me,``))}if(Number.isNaN(i)&&!ge.test(r))throw new C(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function Ve(e,t){let n=e.value.raw,r=e.value.loc;if(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n)||/^\d{6}-\d{2}$/.test(n))throw new C(t,r.start,`Invalid integer "${n}"`);if(n===`-0`||n===`+0`)return{type:`Integer`,loc:r,raw:n,value:0};if(/^[+-]{2,}/.test(n))throw new C(t,r.start,`Double sign is not allowed in integers`);Te(n,t,r.start,`decimal integers`),we(n,t,r.start),ke(n,t,r.start);let i=10;_e.test(n)?(i=16,Ae(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):ye.test(n)?(i=8,Ae(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):be.test(n)&&(i=2,Ae(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(me,``).replace(ye,``).replace(be,``),i);if(Number.isNaN(a))throw new C(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function He(e,t){if(e.value.type===`Comment`)return[Ne(e)];if(e.value.type===`Bracket`)return[Pe(e,t)];if(e.value.type===`Literal`)return Ue(e,t);throw e.value.type===`Equal`?new C(t,e.value.loc.start,`Missing key before '='`):new C(t,e.value.loc.start,`Unexpected token "${e.value.type}"`)}function Ue(e,t){let n=e.value.raw;if(n.endsWith(`:`))throw new C(t,{line:e.value.loc.start.line,column:e.value.loc.start.column+[...n].length-1},`Use '=' to separate keys and values, not ':'`);Se(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||xe(n,t,e.value.loc.start);let r;r=[Ce(e.value.raw,t,e.value.loc.start)];let i={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:r};for(;!e.peek().done&&e.peek().value.type===`Dot`;){e.next(),e.next();let n=e.value.raw;Se(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||xe(n,t,e.value.loc.start),i.loc.end=e.value.loc.end,i.raw+=`.${e.value.raw}`,i.value.push(Ce(e.value.raw,t,e.value.loc.start))}if(e.next(),!e.done&&e.value.loc.start.line!==i.loc.end.line)throw new C(t,e.value.loc.start,`"=" must be on same line as key`);if(e.done||e.value.type!==`Equal`)throw!e.done&&e.value.raw===`:`?new C(t,e.value.loc.start,`Use '=' to separate keys and values, not ':'`):new C(t,e.done?i.loc.end:e.value.loc.start,`Expected "=" for key-value`);let a=e.value.loc.start.column,o=e.value.loc.start.line;if(e.next(),e.done)throw new C(t,i.loc.start,`Expected value, reached EOF`);if(e.value.loc.start.line!==o)throw new C(t,e.value.loc.start,`Value must be on same line as '='`);if(e.done)throw new C(t,i.loc.start,`Expected value for key-value`);let s=We(e,t),c=s[0];if(!e.peek().done){let n=e.peek().value;if(n.type===`Dot`&&n.loc.start.line===c.loc.end.line&&(c.type===`Float`||c.type===`Integer`))throw new C(t,n.loc.start,`Invalid number: multiple decimal points not allowed`);if((n.type===`Literal`||n.type===`Bracket`)&&n.loc.start.line===c.loc.end.line)throw new C(t,n.loc.start,`Key/value pairs must be separated by a newline`)}return s[0]={type:`KeyValue`,key:i,value:c,loc:{start:b(i.loc.start),end:b(c.loc.end)},equals:a},s}function We(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[Fe(e,t)]:n===fe||n===`false`?[Ie(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[Le(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||he.test(n)||ge.test(n)||pe.test(n)&&!_e.test(n)?[Be(e,t)]:[Ve(e,t)]}else if(e.value.type===`Curly`){let[n,r]=Ge(e,t);return[n,...r]}else if(e.value.type===`Bracket`){let[n,r]=Ke(e,t);return[n,...r]}else if(e.value.type===`Dot`)throw new C(t,e.value.loc.start,`Number cannot start with a dot`);else throw new C(t,e.value.loc.start,`Unrecognized token type`)}function Ge(e,t){if(e.value.raw!==`{`)throw new C(t,e.value.loc.start,`Expected "{" for inline table`);let n={type:`InlineTable`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Curly`||e.value.raw!==`}`);){if(e.value.type===`Comment`){r.push(Ne(e)),e.next();continue}if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new C(t,e.value.loc.start,`Leading comma in inline table`);if(r.comma)throw new C(t,e.value.loc.start,`Consecutive commas in inline table`);r.comma=!0,r.loc.end=e.value.loc.start,e.next();continue}let i=n.items[n.items.length-1];if(i&&!i.comma)throw new C(t,e.value.loc.start,`Missing comma between inline table items`);let a=He(e,t),o=a[0];if(o.type===`KeyValue`){n.items.push({type:`InlineItem`,loc:x(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Curly`||e.value.raw!==`}`)throw new C(t,e.done?n.loc.start:e.value.loc.start,`Expected "}"`);return n.loc.end=e.value.loc.end,[n,r]}function Ke(e,t){if(e.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected "[" for inline array`);let n={type:`InlineArray`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Bracket`||e.value.raw!==`]`);){if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new C(t,e.value.loc.start,`Leading comma in array`);if(r.comma)throw new C(t,e.value.loc.start,`Consecutive commas in array`);r.comma=!0,r.loc.end=e.value.loc.start}else if(e.value.type===`Comment`)r.push(Ne(e));else{let i=n.items[n.items.length-1];if(i&&!i.comma)throw new C(t,e.value.loc.start,`Missing comma between array elements`);let a=We(e,t),o=a[0];n.items.push({type:`InlineItem`,loc:x(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Bracket`||e.value.raw!==`]`)throw new C(t,e.done?n.loc.start:e.value.loc.start,`Expected "]"`);return n.loc.end=e.value.loc.end,[n,r]}function F(e){return e[e.length-1]}function qe(){return Object.create(null)}function Je(e){return typeof e==`string`}function Ye(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function Xe(e){return typeof e==`bigint`}function Ze(e){return typeof e==`number`&&(!Ye(e)||!isFinite(e)||Object.is(e,-0))}function Qe(e){return typeof e==`boolean`}function I(e){return Object.prototype.toString.call(e)===`[object Date]`}const $e=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function L(e){var t;return typeof e==`object`&&!!e&&$e.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function et(e){var t;let n=((t=e.constructor)==null?void 0:t.name)??``;if(n===`Temporal.ZonedDateTime`||n===`ZonedDateTime`){let t=e.toString(),n=t.match(/\[(.+)\]$/);if(n&&!/^[+-]\d{2}:\d{2}$/.test(n[1]))throw Error(`ZonedDateTime with IANA timezone "${t}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);return t.replace(/\[.*\]$/,``).replace(/(\+00:00)$/,`Z`)}let r=e.toString();if(/\[.*\]/.test(r))throw Error(`Temporal value contains unsupported annotation: "${r}". TOML only supports ISO 8601 calendar.`);return r}function tt(e){return e&&typeof e==`object`&&!I(e)&&!L(e)&&!Array.isArray(e)}function nt(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function rt(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function it(e){return e.startsWith(`"""`)}function at(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function ot(e){return e.startsWith(`'''`)}function st(e,t){return t in e}function R(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ct(e,t){return L(e)&&L(t)?e.toString()===t.toString():I(e)&&I(t)?e.toISOString()===t.toISOString():!1}function z(e){return tt(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${z(e[t])}`).join(`,`)}}`:Array.isArray(e)?`[${e.map(z).join(`,`)}]`:L(e)?JSON.stringify(e.toString()):I(e)?JSON.stringify(e.toISOString()):typeof e==`bigint`?e.toString()+`n`:JSON.stringify(e)}function lt(e,t){let n=e.length,r=t.length;e.length=n+r;for(let i=0;i<r;i++)e[n+i]=t[i]}const ut=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function dt(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n<55296||n>57343)){if(n<=56319){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){t++;continue}}return{index:t,code:n}}}}function ft(e,t){if(ut!==void 0&&ut.call(e))return;let n=dt(e);if(!n)return;let r=n.code.toString(16).toUpperCase().padStart(4,`0`);throw Error(`${t} contains a lone surrogate (U+${r}) at index ${n.index}. Unpaired surrogates are not Unicode scalar values and cannot be encoded as TOML.`)}function pt(e,t){nt(e)?n(e,null):r(e,null);function n(e,t){for(let n of e)r(n,t)}function r(e,i){let a=t[e.type];switch(a&&typeof a==`function`&&a(e,i),a&&a.enter&&a.enter(e,i),e.type){case`Document`:n(e.items,e);break;case`Table`:r(e.key,e),n(e.items,e);break;case`TableKey`:r(e.item,e);break;case`TableArray`:r(e.key,e),n(e.items,e);break;case`TableArrayKey`:r(e.item,e);break;case`KeyValue`:r(e.key,e),r(e.value,e);break;case`InlineArray`:n(e.items,e);break;case`InlineItem`:r(e.item,e);break;case`InlineTable`:n(e.items,e);break;case`Key`:case`String`:case`Integer`:case`Float`:case`Boolean`:case`DateTime`:case`Comment`:break;default:throw Error(`Unrecognized node type "${e.type}"`)}a&&a.exit&&a.exit(e,i)}}const B=new WeakSet,mt=new WeakMap,ht=new WeakSet,gt=new Set;function _t(e){return gt.has(e)}function vt(e){gt.delete(e)}const yt=new WeakMap,bt=e=>(yt.has(e)||yt.set(e,new WeakMap),yt.get(e)),xt=new WeakMap,V=e=>(xt.has(e)||xt.set(e,new WeakMap),xt.get(e));function St(e,t,n,r){if(p(t)){let e=t.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.items.splice(e,1,r)}else if(a(t)&&d(t.value)&&!d(n)){let e=t.value.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.value.items.splice(e,1,r)}else if(m(t))t.item=r;else if(a(t))t.key===n?t.key=r:t.value=r;else throw Error(`Unsupported parent type "${t.type}" for replace`);At(r,{lines:n.loc.start.line-r.loc.start.line,columns:n.loc.start.column-r.loc.start.column});let i=g(n.loc),o=g(r.loc);Mt({lines:o.lines-i.lines,columns:o.columns-i.columns},V(e),r,n),B.add(e)}function H(t,n,r,i,a,o){if(!p(n))throw Error(`Unsupported parent type "${n.type}" for insert`);i=i!=null&&typeof i==`number`?i:n.items.length;let s,c;l(n)||d(n)?{shift:s,offset:c}=Tt(n,r,i):a&&e(n)?{shift:s,offset:c}=Et(n,r,i):{shift:s,offset:c}=Ct(t,n,r,i),At(r,s);let u=n.items[i-1],m=u&&V(t).get(u);if(m&&(c.lines+=m.lines,c.columns+=m.columns,V(t).delete(u)),(d(n)||l(n))&&c.lines!==0&&(o||p(t))&&t!==n){let e=r.loc.start.line,i=o??t.items;for(let t=0;t<i.length;t++){let r=i[t];if(!f(r))continue;let a=r.loc.start.line;a<n.loc.start.line||a>n.loc.end.line||a<e&&(r.loc.start.line-=c.lines,r.loc.end.line-=c.lines)}}V(t).set(r,c),B.add(t)}function Ct(n,i,a,o){if(!h(a))throw Error(`Incompatible child type "${a.type}"`);let s=i.items[o-1],c=e(i)&&!i.items.length,l=e(i)&&!c&&s===void 0;i.items.splice(o,0,a);let u;if(s!==void 0){let e=-1,t=-1;for(let n=0;n<o;n++){let r=i.items[n],a=r.loc.end;(a.line>e||a.line===e&&a.column>t)&&(e=a.line,t=a.column,u=r)}}let d=u?{line:u.loc.end.line,column:f(u)?i.loc.start.column:u.loc.start.column}:b(i.loc.start),p=t(a)||r(a),m=0;c||l||(m=p?2:1),d.line+=m;let _={lines:d.line-a.loc.start.line,columns:d.column-a.loc.start.column},v=g(a.loc),y=s===void 0&&(t(i)||r(i)||e(i))&&mt.has(i),x=y&&!ht.has(i);y&&(mt.delete(i),ht.delete(i));let S=y&&!x,C=0;if(S){let e=t(i)||r(i)?V(n).get(i.key):bt(n).get(i);C=e?-e.lines:1}let w=x||S?-v.lines:m-1,T={lines:l?v.lines+1:v.lines+w,columns:v.columns};return{shift:{lines:_.lines+C,columns:_.columns},offset:T}}function wt(e,t,n,r={}){let{useNewLine:i=!1,skipCommaSpace:a=2,skipBracketSpace:o=1,hasCommaHandling:s=!1,isLastElement:c=!1,hasSeparatingCommaBefore:l=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:d=!1}=r,p=n>0?e.items[n-1]:void 0,m=p?{line:p.loc.end.line,column:i?f(p)?e.loc.start.column:p.loc.start.column:p.loc.end.column}:b(e.loc.start);if(!p&&i){let t=e.items.find((e,t)=>t>n&&!f(e));t&&(m.column=t.loc.start.column)}let h=0;if(i)h=1;else{let e=l||!s&&!!p;e&&s?m.column+=a:(e||s&&!p)&&(m.column+=o)}m.line+=h;let _={lines:m.line-t.loc.start.line,columns:m.column-t.loc.start.column},v=g(t.loc);if(!s)return{shift:_,offset:{lines:v.lines+(h-1),columns:v.columns}};let y=l&&d&&!u&&c,x=0;return y&&(x=-1),{shift:_,offset:{lines:v.lines+(h-1),columns:v.columns+(l||u?a:0)+(d?1+x:0)}}}function Tt(e,t,n){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let r=n==null?F(e.items):e.items[n-1],i=n==null||n===e.items.length;e.items.splice(n,0,t);let a=!!r,o=!i;return a&&(r.comma=!0),o&&(t.comma=!0),wt(e,t,n,{useNewLine:jt(e),hasCommaHandling:!0,isLastElement:i,hasSeparatingCommaBefore:a,hasSeparatingCommaAfter:o,hasTrailingComma:i&&t.comma===!0})}function Et(e,t,n){let r=wt(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),r}function U(n,i,a,o){if(!p(i))throw Error(`Unsupported parent type "${i.type}" for remove`);let s=i.items.indexOf(a);if(s<0){if(s=i.items.findIndex(e=>m(e)&&e.item===a),s<0)throw Error(`Node not found in parent for removal`);a=i.items[s]}let c=i.items[s-1],h=i.items[s+1];i.items.splice(s,1);let _=g(a.loc);h&&f(h)&&h.loc.start.line===a.loc.end.line&&(_=g({start:a.loc.start,end:h.loc.end}),h=i.items[s+1],i.items.splice(s,1));let v=c&&u(c)||h&&u(h),y=c&&c.loc.end.line===a.loc.start.line,b=h&&h.loc.start.line===a.loc.end.line,x=v&&(y||b),S={lines:-(_.lines-+!!x),columns:x?-_.columns:0};if((e(i)||t(i)||r(i))&&h&&!x&&h.loc.start.line>a.loc.end.line){let e=t(a)||r(a),n=t(h)||r(h),o=-1;for(let e=0;e<s;e++){let t=i.items[e].loc.end.line;t>o&&(o=t)}let l=c?e?a.loc.start.line-o-1:0:n?h.loc.start.line-a.loc.end.line-1:0;l>0&&(S.lines-=l)}let C=(d(i)||l(i))&&i.loc.end.line>i.loc.start.line;c===void 0&&h===void 0&&!C&&(S.lines=0,S.columns=0,d(i)&&i.loc.end.line===i.loc.start.line&>.add(i),(t(i)||r(i)||e(i))&&mt.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&ht.add(i),v&&y&&(S.columns-=2),v&&!c&&h&&(jt(i)||(S.columns-=2)),v&&c&&!h&&(a.comma?c.comma=!0:c.comma=!1);let w,T;c?(w=c,T=V(n)):(t(i)||r(i))&&`key`in i?(w=i.key,T=V(n)):(w=i,T=bt(n));let ee=V(n),E=T.get(w);E&&(S.lines+=E.lines,S.columns+=E.columns);let D=ee.get(a);if(D&&(S.lines+=D.lines,S.columns+=D.columns),T.set(w,S),B.add(n),C&&(o||p(n))&&n!==i){let e=a.loc.start.line,t=o??n.items,r=[];for(let n=0;n<t.length;n++){let a=t[n];if(!f(a))continue;let o=a.loc.start.line;o<i.loc.start.line||o>i.loc.end.line||(o===e?r.push(n):S.lines!==0&&o<e&&(a.loc.start.line-=S.lines,a.loc.end.line-=S.lines))}for(let e=r.length-1;e>=0;e--)t.splice(r[e],1)}}function Dt(e){let t=e.loc.start.line,n=e.loc.start.column;if(`key`in e){let r=e.key.loc.end;(r.line>t||r.line===t&&r.column>n)&&(t=r.line,n=r.column)}for(let r=0;r<e.items.length;r++){let i=e.items[r].loc.end;(i.line>t||i.line===t&&i.column>n)&&(t=i.line,n=i.column)}e.loc.end={line:t,column:n}}function Ot(e,t,n=!0){if(!n||!t.items.length)return;Mt({lines:0,columns:1},bt(e),t);let r=F(t.items);Mt({lines:0,columns:1},V(e),r),B.add(e)}function kt(e,t,n=!1){if(!n||!t.items.length)return;let r=F(t.items);r.comma=!0,Mt({lines:0,columns:1},V(e),r),B.add(e)}function W(e){if(!B.has(e))return;let t=bt(e),n=V(e),r=0,i={};function a(e){switch(e.type){case`Document`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),Dt(t);break}case`Table`:{let t=e;o(t),a(t.key);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),Dt(t);break}case`TableArray`:{let t=e;o(t),a(t.key);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),Dt(t);break}case`TableKey`:{let t=e;o(t),a(t.item),s(t);break}case`TableArrayKey`:{let t=e;o(t),a(t.item),s(t);break}case`KeyValue`:{let t=e,c=t.loc.start.line+r,l=n.get(t.key);t.equals+=(i[c]||0)+(l?l.columns:0),o(t),a(t.key),a(t.value),s(t);break}case`InlineArray`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t);break}case`InlineTable`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t);break}case`InlineItem`:{let t=e;o(t),a(t.item),s(t);break}case`Key`:case`String`:case`Integer`:case`Float`:case`Boolean`:case`DateTime`:case`Comment`:o(e),s(e);break;default:throw Error(`Unrecognized node type "${e.type}"`)}}function o(e){e.loc.start.line+=r;let n=i[e.loc.start.line]||0;e.loc.start.column+=n;let a=t.get(e);a&&(r+=a.lines,i[e.loc.start.line]=(i[e.loc.start.line]||0)+a.columns)}function s(e){e.loc.end.line+=r;let t=i[e.loc.end.line]||0;e.loc.end.column+=t;let a=n.get(e);a&&(r+=a.lines,i[e.loc.end.line]=(i[e.loc.end.line]||0)+a.columns)}a(e),B.delete(e),yt.delete(e),xt.delete(e)}function At(e,t,n={}){let{lines:r,columns:i}=t;if(r===0&&i===0)return e;let{first_line_only:a=!1}=n,o=e.loc.start.line,s=e.type;if(s===`Key`||s===`String`||s===`Integer`||s===`Float`||s===`Boolean`||s===`DateTime`||s===`Comment`)return(!a||e.loc.start.line===o)&&(e.loc.start.column+=i,e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=i)),e.loc.start.line+=r,e.loc.end.line+=r,e;if(s===`KeyValue`){let t=e,n=t.value.type;if(n===`String`||n===`Integer`||n===`Float`||n===`Boolean`||n===`DateTime`){(!a||t.loc.start.line===o)&&(t.loc.start.column+=i,t.loc.end.column+=i),t.loc.start.line+=r,t.loc.end.line+=r,t.equals+=i;let n=t.key;(!a||n.loc.start.line===o)&&(n.loc.start.column+=i,n.loc.end.column+=i),n.loc.start.line+=r,n.loc.end.line+=r;let s=t.value;return(!a||s.loc.start.line===o)&&(s.loc.start.column+=i,s.loc.end.column+=i),s.loc.start.line+=r,s.loc.end.line+=r,e}}let c=e=>{(!a||e.loc.start.line===o)&&(e.loc.start.column+=i,e.loc.end.column+=i),e.loc.start.line+=r,e.loc.end.line+=r};return pt(e,{Table:c,TableKey:c,TableArray:c,TableArrayKey:c,KeyValue(e){c(e),e.equals+=i},Key:c,String:c,Integer:c,Float:c,Boolean:c,DateTime:c,InlineArray:c,InlineItem:c,InlineTable:c,Comment:c}),e}function jt(e){return e.items.length?g(e.loc).lines>e.items.length:!1}function Mt(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function Nt(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
|
|
7
|
+
`||e[r]===`\r`)&&(t=!0),r++;if(!t)throw Error(`Invalid escape sequence: \\${o}`);a=r-1;break}throw Error(`Invalid escape sequence: \\${o}`)}i=a+1}return i===0?e:(i<n&&r.push(e.slice(i)),r.join(``))}function ie(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var ae=class{iterator;index;value;done;peeked;constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){if(this.done)return se();let e=this.peeked||this.iterator.next();return this.index+=1,this.value=e.value,this.done=e.done??!1,this.peeked=null,e}peek(){return this.done?se():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const oe=Object.freeze({value:void 0,done:!0});function se(){return oe}function A(e){return{year:String(e.getUTCFullYear()).padStart(4,`0`),month:String(e.getUTCMonth()+1).padStart(2,`0`),day:String(e.getUTCDate()).padStart(2,`0`),hours:String(e.getUTCHours()).padStart(2,`0`),minutes:String(e.getUTCMinutes()).padStart(2,`0`),seconds:String(e.getUTCSeconds()).padStart(2,`0`),ms:e.getUTCMilliseconds()}}function ce(e,t,n=/\.(\d+)\s*$/){if(t&&t.includes(`.`)){let r=t.match(n),i=r?r[1].length:3;return`.`+String(e).padStart(3,`0`).slice(0,i)}return e>0?`.`+String(e).padStart(3,`0`).replace(/0+$/,``):``}function le(e){if(e===`Z`)return 0;let t=e[0]===`+`?1:-1,[n,r]=e.slice(1).split(`:`);return t*(parseInt(n)*60+parseInt(r))}var ue=class e{static IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/;static IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/;static IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;static createDateWithOriginalFormat(t,n){if(e.IS_DATE_ONLY.test(n)){if(t.getUTCHours()!==0||t.getUTCMinutes()!==0||t.getUTCSeconds()!==0||t.getUTCMilliseconds()!==0){if(t instanceof pe)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new j(e,!1)}let e=t.toISOString().split(`T`)[0];return new de(e)}else if(e.IS_TIME_ONLY.test(n)){if(t instanceof fe)return t;{let e=A(t),r=ce(e.ms,n);return new fe(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}else if(e.IS_LOCAL_DATETIME_T.test(n)){let e=A(t),r=ce(e.ms,n);return new j(`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`,!1,n)}else if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=A(t),r=ce(e.ms,n);return new j(`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`,!0,n)}else if(e.IS_OFFSET_DATETIME_T.test(n)||e.IS_OFFSET_DATETIME_SPACE.test(n)){let r=n.match(/([+-]\d{2}:\d{2}|[Zz])$/),i=r?r[1]===`z`?`Z`:r[1]:`Z`,a=e.IS_OFFSET_DATETIME_SPACE.test(n),o=A(new Date(t.getTime()+le(i)*6e4)),s=a?` `:`T`,c=ce(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new pe(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}else return t}},de=class extends Date{constructor(e){super(e)}toISOString(){let e=A(this);return`${e.year}-${e.month}-${e.day}`}},fe=class extends Date{originalFormat;constructor(e,t){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+`:00`),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){let e=A(this);return`${e.hours}:${e.minutes}:${e.seconds}${ce(e.ms,this.originalFormat)}`}},j=class extends Date{useSpaceSeparator=!1;originalFormat;constructor(e,t=!1,n){let r=e;/\d{2}:\d{2}:\d{2}/.test(e)||(r=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(r.replace(` `,`T`)+`Z`),this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){let e=A(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${ce(e.ms,this.originalFormat)}`}},pe=class extends Date{useSpaceSeparator=!1;originalOffset;originalFormat;constructor(e,t=!1){let n=e;/\d{2}:\d{2}:\d{2}/.test(e)||(n=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(n.replace(` `,`T`)),this.useSpaceSeparator=t,this.originalFormat=e;let r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset=r[1]===`z`?`Z`:r[1])}toISOString(){if(this.originalOffset){let e=A(new Date(this.getTime()+le(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=ce(e.ms,this.originalFormat,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${n}${this.originalOffset}`}let e=super.toISOString();return this.useSpaceSeparator?e.replace(`T`,` `):e}};const M=ue,me=`true`,he=/e/i,ge=/_/g,_e=/^[+-]?inf$/,ve=/^[+-]?nan$/,ye=/^[+-]?0x/i;function be(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const xe=/^[+-]?0o/i,Se=/^[+-]?0b/i;function Ce(e,t,n){for(let r=0;r<e.length;r++)if(!be(e.charCodeAt(r)))throw new C(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function we(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new C(t,n,`Multiline strings cannot be keys`)}function Te(e,t,n){try{return ne(e)}catch(e){throw new C(t,n,e.message)}}function Ee(e,t,n,r=!0){if(e.endsWith(`_`)||(r?/^[+-]?_/.test(e):e.startsWith(`_`)))throw new C(t,n,`Underscore must be between digits`);if(/__/.test(e))throw new C(t,n,`Consecutive underscores not allowed`)}function De(e,t,n,r){let i=e.replace(ge,``);if(/^[+-]?0\d/.test(i)&&!ye.test(e)&&!xe.test(e)&&!Se.test(e))throw new C(t,n,`Leading zeros are not allowed in ${r}`)}function Oe(e,t,n,r){if(/_[eE]/.test(e))throw new C(n,r,`Underscore before exponent is not allowed`);if(/[eE][+-]?_/.test(e))throw new C(n,r,`Underscore at start of exponent is not allowed`);if(/[eE][+-]?$/.test(e))throw new C(n,r,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new C(n,r,`Invalid float "${t}": decimal point not allowed in exponent`)}function ke(e,t,n,r,i,a){if(e.length!==2)throw new C(i,a,`"${r}": hour must be 2 digits`);if(t.length!==2)throw new C(i,a,`"${r}": minute must be 2 digits`);if(n&&n.length!==2)throw new C(i,a,`"${r}": second must be 2 digits`)}function Ae(e,t,n,r,i,a){if(e!==void 0){let t=parseInt(e,10);if(t<0||t>23)throw new C(i,a,`"${r}": hour must be 00-23`)}if(t!==void 0){let e=parseInt(t,10);if(e<0||e>59)throw new C(i,a,`"${r}": minute must be 00-59`)}if(n!==void 0){let e=parseInt(n,10);if(e<0||e>60)throw new C(i,a,`"${r}": second must be 00-60`)}}function je(e,t,n){if(ye.test(e)||xe.test(e)||Se.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new C(t,n,`Invalid integer "${e}"`)}function Me(e,t,n,r,i,a,o){let s=r[0]+r[1].toUpperCase();if(RegExp(`^[+\\-]?`+s.replace(/([[\]])/g,`\\$1`)).test(e))throw new C(t,n,`${a} prefix must be lowercase "${r}"`);if(RegExp(`^[+\\-]?`+r+`_`,`i`).test(e))throw new C(t,n,`Underscore must be between digits`);let c=RegExp(`^[+\\-]?`+r,`i`),l=e.replace(c,``);if(!l||l===`_`||l.startsWith(`_`))throw new C(t,n,`Incomplete ${a.toLowerCase()} number`);let u=l.replace(/_/g,``);if(!i.test(u))throw new C(t,n,o??`Invalid ${a.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new C(t,n,`${a} numbers cannot have a sign prefix`)}function*Ne(e){let t=new ae(E(e));for(;!t.next().done;){let n=We(t,e);for(let e of n)yield e}}function*Pe(e,t){for(let t of e)yield t;let n=new ae(E(t));for(;!n.next().done;){let e=We(n,t);for(let t of e)yield t}}function Fe(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function Ie(e,t){let n=!e.peek().done&&e.peek().value.type===`Bracket`?`TableArray`:`Table`,r=n===`Table`;if(r&&e.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected table opening "[", found ${e.value.raw}`);if(!r){let n=e.peek();if(n.done)throw new C(t,e.value.loc.start,`Expected "[[" for Array of Tables, found end of input`);if(e.value.raw!==`[`||n.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected "[[", found ${e.value.raw+n.value.raw}`);let r=e.value,i=n.value;if(r.loc.end.line!==i.loc.start.line||r.loc.end.column!==i.loc.start.column)throw new C(t,r.loc.start,`"[[" brackets must be adjacent (no whitespace)`)}let i=r?{type:`TableKey`,loc:e.value.loc}:{type:`TableArrayKey`,loc:e.value.loc};if(e.next(),n===`TableArray`&&e.next(),e.done)throw new C(t,i.loc.start,`Expected table key, reached end of file`);if(e.value.type===`Bracket`&&e.value.raw===`]`)throw new C(t,e.value.loc.start,n===`TableArray`?`Array of Tables header [[]] requires a table name`:`Table header [] requires a table name`);let a=e.value.raw;we(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||Ce(a,t,e.value.loc.start);let o;for(o=[Te(e.value.raw,t,e.value.loc.start)],i.item={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:o};!e.peek().done&&e.peek().value.type===`Dot`;){e.next();let n=e.value;e.next();let r=e.value.raw;r.startsWith(`"`)||r.startsWith(`'`)||Ce(r,t,e.value.loc.start);let a=` `.repeat(n.loc.start.column-i.item.loc.end.column),o=` `.repeat(e.value.loc.start.column-n.loc.end.column);i.item.loc.end=e.value.loc.end,i.item.raw+=`${a}.${o}${e.value.raw}`;try{i.item.value.push(ne(e.value.raw))}catch(n){let r=n;throw new C(t,e.value.loc.start,r.message)}}if(e.next(),!e.done){let n=i.loc.start.line;if(e.value.loc.start.line!==n)throw new C(t,e.value.loc.start,r?`Table header must be single-line`:`Array of Tables header must be single-line`)}if(r&&(e.done||e.value.raw!==`]`))throw new C(t,e.done?i.item.loc.end:e.value.loc.start,`Expected table closing "]", found ${e.done?`end of file`:e.value.raw}`);if(!r&&(e.done||e.peek().done||e.value.raw!==`]`||e.peek().value.raw!==`]`))throw new C(t,e.done||e.peek().done?i.item.loc.end:e.value.loc.start,`Expected "]]" closing, found ${e.done||e.peek().done?`end of file`:e.value.raw+e.peek().value.raw}`);if(!r){let n=e.value,r=e.peek().value;if(n.loc.end.line!==r.loc.start.line||n.loc.end.column!==r.loc.start.column)throw new C(t,n.loc.start,`"]]" brackets must be adjacent (no whitespace)`)}if(r||e.next(),i.loc.end=e.value.loc.end,!e.peek().done){let n=e.peek().value;if(n.loc.start.line===i.loc.end.line&&n.type!==`Comment`)throw new C(t,n.loc.start,`Extra content after ${r?`table`:`Array of Tables`} header`)}let s=[];for(;!e.peek().done&&e.peek().value.type!==`Bracket`;){e.next();let n=We(e,t);for(let e=0;e<n.length;e++)s.push(n[e])}return{type:r?`Table`:`TableArray`,loc:{start:b(i.loc.start),end:s.length?b(s[s.length-1].loc.end):b(i.loc.end)},key:i,items:s}}function Le(e,t){let n=Te(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function Re(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===me}}function ze(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&M.IS_FULL_DATE.test(r)&&M.IS_FULL_TIME.test(e.peek().value.raw)){let t=n.start;e.next(),n={start:t,end:e.value.loc.end},r+=` ${e.value.raw}`}if(!e.peek().done&&e.peek().value.type===`Dot`){let i=n.start;if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new C(t,e.value.loc.end,`Expected fractional value for DateTime`);e.next(),n={start:i,end:e.value.loc.end},r+=`.${e.value.raw}`}if(Ve(r,t,n.start),M.IS_FULL_DATE.test(r))i=M.IS_DATE_ONLY.test(r)?new de(r):M.IS_LOCAL_DATETIME_T.test(r)?new j(r,!1):M.IS_LOCAL_DATETIME_SPACE.test(r)?new j(r,!0):M.IS_OFFSET_DATETIME_T.test(r)?new pe(r,!1):M.IS_OFFSET_DATETIME_SPACE.test(r)?new pe(r,!0):new Date(r.replace(` `,`T`));else if(M.IS_TIME_ONLY.test(r))i=new fe(r,r);else{let[e]=new Date().toISOString().split(`T`);i=new Date(`${e}T${r}`)}return{type:`DateTime`,loc:n,raw:r,value:i}}function Be(e,t){return t===2?e%4==0&&e%100!=0||e%400==0?29:28:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}function Ve(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new C(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new C(t,n,`"${e}": offset needs HH:MM`);let r=/\d{2}:\d{2}/.test(e)?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(r){let e=r[0],i=r[2],a=r[3],o=r[4];if(a!==`:`)throw new C(t,n,`Offset "${e}": missing colon separator`);if(i.length!==2)throw new C(t,n,`Offset "${e}": hour must be 2 digits`);if(!o||o.length===0)throw new C(t,n,`Offset "${e}": minute required`);if(o.length!==2)throw new C(t,n,`Offset "${e}": minute must be 2 digits`);let s=parseInt(i,10);if(s<0||s>23)throw new C(t,n,`Offset "${e}": hour must be 00-23`);let c=parseInt(o,10);if(c<0||c>59)throw new C(t,n,`Offset "${e}": minute must be 00-59`)}if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/.test(e))throw/^\d{4}-\d{2}-\d{2}T$/.test(e)?new C(t,n,`"${e}": 'T' requires time component`):/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e)?new C(t,n,`Invalid date "${e}": unexpected character after date`):/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e)?new C(t,n,`"${e}": missing 'T' or space separator`):new C(t,n,`Invalid datetime "${e}"`);let i=e.match(/^(\d+)-/);if(i&&i[1].length!==4)throw new C(t,n,`"${e}": year must be 4 digits`);let a=e.match(/^(\d+)-(\d+)-(\d+)/);if(a){let[,,r,i]=a;if(r.length!==2)throw new C(t,n,`"${e}": month must be 2 digits`);if(i.length!==2)throw new C(t,n,`"${e}": day must be 2 digits`)}let o=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(o){let[,r,i,a]=o;ke(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;ke(r,i,a,e,t,n)}let c=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),l=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(c){let[,r,i,a,o,s,l]=c,u=parseInt(i,10);if(u<1||u>12)throw new C(t,n,`"${e}": month must be 01-12`);let d=parseInt(a,10);if(d<1||d>31)throw new C(t,n,`"${e}": day must be 01-31`);if(d>Be(parseInt(r,10),u))throw new C(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Ae(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Ae(r,i,a,e,t,n)}}function He(e,t){let n=e.value.loc,r=e.value.raw,i;if(_e.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(ve.test(r)){let e=new Float64Array(1),t=new DataView(e.buffer);r.startsWith(`-`)?(t.setUint32(0,0,!0),t.setUint32(4,4294443008,!0)):(t.setUint32(0,0,!0),t.setUint32(4,2146959360,!0)),i=e[0];let a=r.startsWith(`+`)?`+`:r.startsWith(`-`)?`-`:void 0;return{type:`Float`,loc:n,raw:r,value:i,nanSign:a}}else if(!e.peek().done&&e.peek().value.type===`Dot`){let a=n.start;{if(he.test(r)&&!ye.test(r))throw new C(t,n.start,`Float "${r}": dot after exponent`);let e=r;De(e,t,n.start,`the integer part of a float`);let i=e.replace(/^[+-]/,``);if(i===``||i===`_`)throw new C(t,n.start,`Float: digit required before dot`);Ee(e,t,n.start)}if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new C(t,e.value.loc.end,`Expected fraction value for Float`);e.next(),r+=`.${e.value.raw}`,n={start:a,end:e.value.loc.end};{let n=e.value.raw;if(!/^\d/.test(n))throw new C(t,e.value.loc.start,`Float: fraction must start with digit, found "${n}"`);Ee(n,t,e.value.loc.start,!1),Oe(n,r,t,e.value.loc.start)}i=Number(r.replace(ge,``))}else{if(Ee(r,t,n.start),Oe(r,r,t,n.start),!e.peek().done&&e.peek().value.type===`Dot`)throw new C(t,e.peek().value.loc.start,`Float "${r}.": dot after exponent`);De(r,t,n.start,`the integer part of a float`),i=Number(r.replace(ge,``))}if(Number.isNaN(i)&&!ve.test(r))throw new C(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function Ue(e,t){let n=e.value.raw,r=e.value.loc;if(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n)||/^\d{6}-\d{2}$/.test(n))throw new C(t,r.start,`Invalid integer "${n}"`);if(n===`-0`||n===`+0`)return{type:`Integer`,loc:r,raw:n,value:0};if(/^[+-]{2,}/.test(n))throw new C(t,r.start,`Double sign is not allowed in integers`);De(n,t,r.start,`decimal integers`),Ee(n,t,r.start),je(n,t,r.start);let i=10;ye.test(n)?(i=16,Me(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):xe.test(n)?(i=8,Me(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):Se.test(n)&&(i=2,Me(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(ge,``).replace(xe,``).replace(Se,``),i);if(Number.isNaN(a))throw new C(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function We(e,t){if(e.value.type===`Comment`)return[Fe(e)];if(e.value.type===`Bracket`)return[Ie(e,t)];if(e.value.type===`Literal`)return Ge(e,t);throw e.value.type===`Equal`?new C(t,e.value.loc.start,`Missing key before '='`):new C(t,e.value.loc.start,`Unexpected token "${e.value.type}"`)}function Ge(e,t){let n=e.value.raw;if(n.endsWith(`:`))throw new C(t,{line:e.value.loc.start.line,column:e.value.loc.start.column+[...n].length-1},`Use '=' to separate keys and values, not ':'`);we(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ce(n,t,e.value.loc.start);let r;r=[Te(e.value.raw,t,e.value.loc.start)];let i={type:`Key`,loc:e.value.loc,raw:e.value.raw,value:r};for(;!e.peek().done&&e.peek().value.type===`Dot`;){e.next(),e.next();let n=e.value.raw;we(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ce(n,t,e.value.loc.start),i.loc.end=e.value.loc.end,i.raw+=`.${e.value.raw}`,i.value.push(Te(e.value.raw,t,e.value.loc.start))}if(e.next(),!e.done&&e.value.loc.start.line!==i.loc.end.line)throw new C(t,e.value.loc.start,`"=" must be on same line as key`);if(e.done||e.value.type!==`Equal`)throw!e.done&&e.value.raw===`:`?new C(t,e.value.loc.start,`Use '=' to separate keys and values, not ':'`):new C(t,e.done?i.loc.end:e.value.loc.start,`Expected "=" for key-value`);let a=e.value.loc.start.column,o=e.value.loc.start.line;if(e.next(),e.done)throw new C(t,i.loc.start,`Expected value, reached EOF`);if(e.value.loc.start.line!==o)throw new C(t,e.value.loc.start,`Value must be on same line as '='`);if(e.done)throw new C(t,i.loc.start,`Expected value for key-value`);let s=Ke(e,t),c=s[0];if(!e.peek().done){let n=e.peek().value;if(n.type===`Dot`&&n.loc.start.line===c.loc.end.line&&(c.type===`Float`||c.type===`Integer`))throw new C(t,n.loc.start,`Invalid number: multiple decimal points not allowed`);if((n.type===`Literal`||n.type===`Bracket`)&&n.loc.start.line===c.loc.end.line)throw new C(t,n.loc.start,`Key/value pairs must be separated by a newline`)}return s[0]={type:`KeyValue`,key:i,value:c,loc:{start:b(i.loc.start),end:b(c.loc.end)},equals:a},s}function Ke(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[Le(e,t)]:n===me||n===`false`?[Re(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[ze(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||_e.test(n)||ve.test(n)||he.test(n)&&!ye.test(n)?[He(e,t)]:[Ue(e,t)]}else if(e.value.type===`Curly`){let[n,r]=qe(e,t);return[n,...r]}else if(e.value.type===`Bracket`){let[n,r]=Je(e,t);return[n,...r]}else if(e.value.type===`Dot`)throw new C(t,e.value.loc.start,`Number cannot start with a dot`);else throw new C(t,e.value.loc.start,`Unrecognized token type`)}function qe(e,t){if(e.value.raw!==`{`)throw new C(t,e.value.loc.start,`Expected "{" for inline table`);let n={type:`InlineTable`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Curly`||e.value.raw!==`}`);){if(e.value.type===`Comment`){r.push(Fe(e)),e.next();continue}if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new C(t,e.value.loc.start,`Leading comma in inline table`);if(r.comma)throw new C(t,e.value.loc.start,`Consecutive commas in inline table`);r.comma=!0,r.loc.end=e.value.loc.start,e.next();continue}let i=n.items[n.items.length-1];if(i&&!i.comma)throw new C(t,e.value.loc.start,`Missing comma between inline table items`);let a=We(e,t),o=a[0];if(o.type===`KeyValue`){n.items.push({type:`InlineItem`,loc:x(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Curly`||e.value.raw!==`}`)throw new C(t,e.done?n.loc.start:e.value.loc.start,`Expected "}"`);return n.loc.end=e.value.loc.end,[n,r]}function Je(e,t){if(e.value.raw!==`[`)throw new C(t,e.value.loc.start,`Expected "[" for inline array`);let n={type:`InlineArray`,loc:e.value.loc,items:[]},r=[];for(e.next();!e.done&&(e.value.type!==`Bracket`||e.value.raw!==`]`);){if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new C(t,e.value.loc.start,`Leading comma in array`);if(r.comma)throw new C(t,e.value.loc.start,`Consecutive commas in array`);r.comma=!0,r.loc.end=e.value.loc.start}else if(e.value.type===`Comment`)r.push(Fe(e));else{let i=n.items[n.items.length-1];if(i&&!i.comma)throw new C(t,e.value.loc.start,`Missing comma between array elements`);let a=Ke(e,t),o=a[0];n.items.push({type:`InlineItem`,loc:x(o.loc),item:o,comma:!1});for(let e=1;e<a.length;e++)r.push(a[e])}e.next()}if(e.done||e.value.type!==`Bracket`||e.value.raw!==`]`)throw new C(t,e.done?n.loc.start:e.value.loc.start,`Expected "]"`);return n.loc.end=e.value.loc.end,[n,r]}function N(e){return e[e.length-1]}function Ye(){return Object.create(null)}function Xe(e){return typeof e==`string`}function Ze(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)&&e>=-(2**53-1)&&e<=2**53-1}function Qe(e){return typeof e==`bigint`}function $e(e){return typeof e==`number`&&(!Ze(e)||!isFinite(e)||Object.is(e,-0))}function et(e){return typeof e==`boolean`}function tt(e){return Object.prototype.toString.call(e)===`[object Date]`}const nt=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function P(e){var t;return typeof e==`object`&&!!e&&nt.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function rt(e){var t;let n=((t=e.constructor)==null?void 0:t.name)??``;if(n===`Temporal.ZonedDateTime`||n===`ZonedDateTime`){let t=e.toString(),n=t.match(/\[(.+)\]$/);if(n&&!/^[+-]\d{2}:\d{2}$/.test(n[1]))throw Error(`ZonedDateTime with IANA timezone "${t}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);return t.replace(/\[.*\]$/,``).replace(/(\+00:00)$/,`Z`)}let r=e.toString();if(/\[.*\]/.test(r))throw Error(`Temporal value contains unsupported annotation: "${r}". TOML only supports ISO 8601 calendar.`);return r}function F(e){return e&&typeof e==`object`&&!tt(e)&&!P(e)&&!Array.isArray(e)}function it(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function at(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function ot(e){return e.startsWith(`"""`)}function st(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function ct(e){return e.startsWith(`'''`)}function lt(e,t){return t in e}function I(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ut(e,t){return P(e)&&P(t)?e.toString()===t.toString():tt(e)&&tt(t)?e.toISOString()===t.toISOString():!1}function L(e){return F(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${L(e[t])}`).join(`,`)}}`:Array.isArray(e)?`[${e.map(L).join(`,`)}]`:P(e)?JSON.stringify(e.toString()):tt(e)?JSON.stringify(e.toISOString()):typeof e==`bigint`?e.toString()+`n`:JSON.stringify(e)}function dt(e,t){let n=e.length,r=t.length;e.length=n+r;for(let i=0;i<r;i++)e[n+i]=t[i]}const ft=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function pt(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(!(n<55296||n>57343)){if(n<=56319){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){t++;continue}}return{index:t,code:n}}}}function mt(e,t){if(ft!==void 0&&ft.call(e))return;let n=pt(e);if(!n)return;let r=n.code.toString(16).toUpperCase().padStart(4,`0`);throw Error(`${t} contains a lone surrogate (U+${r}) at index ${n.index}. Unpaired surrogates are not Unicode scalar values and cannot be encoded as TOML.`)}function ht(e,t){it(e)?n(e,null):r(e,null);function n(e,t){for(let n of e)r(n,t)}function r(e,i){let a=t[e.type];switch(a&&typeof a==`function`&&a(e,i),a&&a.enter&&a.enter(e,i),e.type){case`Document`:n(e.items,e);break;case`Table`:r(e.key,e),n(e.items,e);break;case`TableKey`:r(e.item,e);break;case`TableArray`:r(e.key,e),n(e.items,e);break;case`TableArrayKey`:r(e.item,e);break;case`KeyValue`:r(e.key,e),r(e.value,e);break;case`InlineArray`:n(e.items,e);break;case`InlineItem`:r(e.item,e);break;case`InlineTable`:n(e.items,e);break;case`Key`:case`String`:case`Integer`:case`Float`:case`Boolean`:case`DateTime`:case`Comment`:break;default:throw Error(`Unrecognized node type "${e.type}"`)}a&&a.exit&&a.exit(e,i)}}const R=new WeakSet,gt=new WeakMap,_t=new WeakSet,vt=new WeakSet;function yt(e){return vt.has(e)}function bt(e){vt.delete(e)}const xt=new WeakMap,St=e=>(xt.has(e)||xt.set(e,new WeakMap),xt.get(e)),Ct=new WeakMap,z=e=>(Ct.has(e)||Ct.set(e,new WeakMap),Ct.get(e));function wt(e,t,n,r){if(p(t)){let e=t.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.items.splice(e,1,r)}else if(a(t)&&d(t.value)&&!d(n)){let e=t.value.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.value.items.splice(e,1,r)}else if(m(t))t.item=r;else if(a(t))t.key===n?t.key=r:t.value=r;else throw Error(`Unsupported parent type "${t.type}" for replace`);W(r,{lines:n.loc.start.line-r.loc.start.line,columns:n.loc.start.column-r.loc.start.column});let i=g(n.loc),o=g(r.loc);Mt({lines:o.lines-i.lines,columns:o.columns-i.columns},z(e),r,n),R.add(e)}function B(t,n,r,i,a,o,s){if(!p(n))throw Error(`Unsupported parent type "${n.type}" for insert`);i=i!=null&&typeof i==`number`?i:n.items.length;let c,u;l(n)||d(n)?{shift:c,offset:u}=Dt(n,r,i):a&&e(n)?{shift:c,offset:u}=Ot(n,r,i):{shift:c,offset:u}=Tt(t,n,r,i,s),W(r,c);let m=n.items[i-1],h=m&&z(t).get(m);if(h&&(u.lines+=h.lines,u.columns+=h.columns,z(t).delete(m)),(d(n)||l(n))&&u.lines!==0&&(o||p(t))&&t!==n){let e=r.loc.start.line,i=o??t.items;for(let t=0;t<i.length;t++){let r=i[t];if(!f(r))continue;let a=r.loc.start.line;a<n.loc.start.line||a>n.loc.end.line||a<e&&(r.loc.start.line-=u.lines,r.loc.end.line-=u.lines)}}z(t).set(r,u),R.add(t)}function Tt(n,i,a,o,s){if(!h(a))throw Error(`Incompatible child type "${a.type}"`);let c=i.items[o-1],l=e(i)&&!i.items.length,u=e(i)&&!l&&c===void 0;i.items.splice(o,0,a);let d;if(c!==void 0){let e=-1,t=-1;for(let n=0;n<o;n++){let r=i.items[n],a=r.loc.end;(a.line>e||a.line===e&&a.column>t)&&(e=a.line,t=a.column,d=r)}}let p=d?{line:d.loc.end.line,column:f(d)?i.loc.start.column:d.loc.start.column}:b(i.loc.start),m=t(a)||r(a),_=0;s===void 0?l||u||(_=m?2:1):_=s,p.line+=_;let v={lines:p.line-a.loc.start.line,columns:p.column-a.loc.start.column},y=g(a.loc),x=c===void 0&&(t(i)||r(i)||e(i))&>.has(i),S=x&&!_t.has(i);x&&(gt.delete(i),_t.delete(i));let C=x&&!S,w=0;if(C){let e=t(i)||r(i)?z(n).get(i.key):St(n).get(i);w=e?-e.lines:1}let T=S||C?-y.lines:_-1,ee={lines:u?y.lines+1:y.lines+T,columns:y.columns};return{shift:{lines:v.lines+w,columns:v.columns},offset:ee}}function Et(e,t,n,r={}){let{useNewLine:i=!1,skipCommaSpace:a=2,skipBracketSpace:o=1,hasCommaHandling:s=!1,isLastElement:c=!1,hasSeparatingCommaBefore:l=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:d=!1}=r,p=n>0?e.items[n-1]:void 0,m=p?{line:p.loc.end.line,column:i?f(p)?e.loc.start.column:p.loc.start.column:p.loc.end.column}:b(e.loc.start);if(!p&&i){let t=e.items.find((e,t)=>t>n&&!f(e));t&&(m.column=t.loc.start.column)}let h=0;if(i)h=1;else{let e=l||!s&&!!p;e&&s?m.column+=a:(e||s&&!p)&&(m.column+=o)}m.line+=h;let _={lines:m.line-t.loc.start.line,columns:m.column-t.loc.start.column},v=g(t.loc);if(!s)return{shift:_,offset:{lines:v.lines+(h-1),columns:v.columns}};let y=l&&d&&!u&&c,x=0;return y&&(x=-1),{shift:_,offset:{lines:v.lines+(h-1),columns:v.columns+(l||u?a:0)+(d?1+x:0)}}}function Dt(e,t,n){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let r=n==null?N(e.items):e.items[n-1],i=n==null||n===e.items.length;e.items.splice(n,0,t);let a=!!r,o=!i;return a&&(r.comma=!0),o&&(t.comma=!0),Et(e,t,n,{useNewLine:jt(e),hasCommaHandling:!0,isLastElement:i,hasSeparatingCommaBefore:a,hasSeparatingCommaAfter:o,hasTrailingComma:i&&t.comma===!0})}function Ot(e,t,n){let r=Et(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),r}function V(n,i,a,o){if(!p(i))throw Error(`Unsupported parent type "${i.type}" for remove`);let s=i.items.indexOf(a);if(s<0){if(s=i.items.findIndex(e=>m(e)&&e.item===a),s<0)throw Error(`Node not found in parent for removal`);a=i.items[s]}let c=i.items[s-1],h=i.items[s+1];i.items.splice(s,1);let _=g(a.loc);h&&f(h)&&h.loc.start.line===a.loc.end.line&&(_=g({start:a.loc.start,end:h.loc.end}),h=i.items[s+1],i.items.splice(s,1));let v=c&&u(c)||h&&u(h),y=c&&c.loc.end.line===a.loc.start.line,b=h&&h.loc.start.line===a.loc.end.line,x=v&&(y||b),S={lines:-(_.lines-+!!x),columns:x?-_.columns:0};if((e(i)||t(i)||r(i))&&h&&!x&&h.loc.start.line>a.loc.end.line){let e=t(a)||r(a),n=t(h)||r(h),o=-1;for(let e=0;e<s;e++){let t=i.items[e].loc.end.line;t>o&&(o=t)}let l=c?e?a.loc.start.line-o-1:0:n?h.loc.start.line-a.loc.end.line-1:0;l>0&&(S.lines-=l)}let C=(d(i)||l(i))&&i.loc.end.line>i.loc.start.line;c===void 0&&h===void 0&&!C&&(S.lines=0,S.columns=0,(d(i)||l(i))&&i.loc.end.line===i.loc.start.line&&vt.add(i),(t(i)||r(i)||e(i))&>.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&_t.add(i),v&&y&&(S.columns-=2),v&&!c&&h&&(jt(i)||(S.columns-=2)),v&&c&&!h&&(a.comma?c.comma=!0:c.comma=!1);let w,T;c?(w=c,T=z(n)):(t(i)||r(i))&&`key`in i?(w=i.key,T=z(n)):(w=i,T=St(n));let ee=z(n),E=T.get(w);E&&(S.lines+=E.lines,S.columns+=E.columns);let D=ee.get(a);if(D&&(S.lines+=D.lines,S.columns+=D.columns),T.set(w,S),R.add(n),C&&(o||p(n))&&n!==i){let e=a.loc.start.line,t=o??n.items,r=[];for(let n=0;n<t.length;n++){let a=t[n];if(!f(a))continue;let o=a.loc.start.line;o<i.loc.start.line||o>i.loc.end.line||(o===e?r.push(n):S.lines!==0&&o<e&&(a.loc.start.line-=S.lines,a.loc.end.line-=S.lines))}for(let e=r.length-1;e>=0;e--)t.splice(r[e],1)}}function H(e){let t=e.loc.start.line,n=e.loc.start.column;if(`key`in e){let r=e.key.loc.end;(r.line>t||r.line===t&&r.column>n)&&(t=r.line,n=r.column)}for(let r=0;r<e.items.length;r++){let i=e.items[r].loc.end;(i.line>t||i.line===t&&i.column>n)&&(t=i.line,n=i.column)}e.loc.end={line:t,column:n}}function kt(e,t,n=!0){if(!n||!t.items.length)return;Mt({lines:0,columns:1},St(e),t);let r=N(t.items);Mt({lines:0,columns:1},z(e),r),R.add(e)}function At(e,t,n=!1){if(!n||!t.items.length)return;let r=N(t.items);r.comma=!0,Mt({lines:0,columns:1},z(e),r),R.add(e)}function U(e){if(!R.has(e))return;let t=St(e),n=z(e),r=0,i={};function a(e){switch(e.type){case`Document`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),H(t);break}case`Table`:{let t=e;o(t),a(t.key);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),H(t);break}case`TableArray`:{let t=e;o(t),a(t.key);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),H(t);break}case`TableKey`:{let t=e;o(t),a(t.item),s(t);break}case`TableArrayKey`:{let t=e;o(t),a(t.item),s(t);break}case`KeyValue`:{let t=e,c=t.loc.start.line+r,l=n.get(t.key);t.equals+=(i[c]||0)+(l?l.columns:0),o(t),a(t.key),a(t.value),s(t);break}case`InlineArray`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t);break}case`InlineTable`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t);break}case`InlineItem`:{let t=e;o(t),a(t.item),s(t);break}case`Key`:case`String`:case`Integer`:case`Float`:case`Boolean`:case`DateTime`:case`Comment`:o(e),s(e);break;default:throw Error(`Unrecognized node type "${e.type}"`)}}function o(e){e.loc.start.line+=r;let n=i[e.loc.start.line]||0;e.loc.start.column+=n;let a=t.get(e);a&&(r+=a.lines,i[e.loc.start.line]=(i[e.loc.start.line]||0)+a.columns)}function s(e){e.loc.end.line+=r;let t=i[e.loc.end.line]||0;e.loc.end.column+=t;let a=n.get(e);a&&(r+=a.lines,i[e.loc.end.line]=(i[e.loc.end.line]||0)+a.columns)}a(e),R.delete(e),xt.delete(e),Ct.delete(e)}function W(e,t,n={}){let{lines:r,columns:i}=t;if(r===0&&i===0)return e;let{first_line_only:a=!1}=n,o=e.loc.start.line,s=e.type;if(s===`Key`||s===`String`||s===`Integer`||s===`Float`||s===`Boolean`||s===`DateTime`||s===`Comment`)return(!a||e.loc.start.line===o)&&(e.loc.start.column+=i,e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=i)),e.loc.start.line+=r,e.loc.end.line+=r,e;if(s===`KeyValue`){let t=e,n=t.value.type;if(n===`String`||n===`Integer`||n===`Float`||n===`Boolean`||n===`DateTime`){(!a||t.loc.start.line===o)&&(t.loc.start.column+=i,t.loc.end.column+=i),t.loc.start.line+=r,t.loc.end.line+=r,t.equals+=i;let n=t.key;(!a||n.loc.start.line===o)&&(n.loc.start.column+=i,n.loc.end.column+=i),n.loc.start.line+=r,n.loc.end.line+=r;let s=t.value;return(!a||s.loc.start.line===o)&&(s.loc.start.column+=i,s.loc.end.column+=i),s.loc.start.line+=r,s.loc.end.line+=r,e}}let c=e=>{(!a||e.loc.start.line===o)&&(e.loc.start.column+=i,e.loc.end.column+=i),e.loc.start.line+=r,e.loc.end.line+=r};return ht(e,{Table:c,TableKey:c,TableArray:c,TableArrayKey:c,KeyValue(e){c(e),e.equals+=i},Key:c,String:c,Integer:c,Float:c,Boolean:c,DateTime:c,InlineArray:c,InlineItem:c,InlineTable:c,Comment:c}),e}function jt(e){return e.items.length?g(e.loc).lines>e.items.length:!1}function Mt(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function Nt(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
|
|
8
8
|
`?`\r
|
|
9
9
|
`:`
|
|
10
10
|
`}function Pt(e,t){var n;let r=Nt(e);e=e.replace(/\r\n/g,`
|
|
@@ -14,25 +14,25 @@ function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}f
|
|
|
14
14
|
`;case`f`:return`\f`;case`r`:return`\r`;case`"`:return`"`;case`\\`:return`\\`;default:return null}}function It(e,t){return t===`singleline-basic`?e<=31||e===127:e>=0&&e<=7||e===11||e>=14&&e<=31||e===127}function Lt(e,t){switch(e){case`\\`:return`\\\\`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`"`:return t===`singleline-basic`?`\\"`:`"`;case`
|
|
15
15
|
`:return t===`singleline-basic`?`\\n`:`
|
|
16
16
|
`;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return It(n,t)?`\\u${n.toString(16).padStart(4,`0`).toUpperCase()}`:e}}}function Rt(e){let t=new Map;for(let n=0;n<e.length;n++){if(e[n]!==`\\`)continue;let r=e[n+1];if(!r)continue;let i=Ft(r);if(i!==null){i!==`
|
|
17
|
-
`&&i!==`\r`&&!t.has(i)&&t.set(i,`\\`+r),n+=1;continue}if(r===`x`&&/^[0-9A-Fa-f]{2}$/.test(e.slice(n+2,n+4))){let r=e.slice(n,n+4),i=Number.parseInt(e.slice(n+2,n+4),16),a=String.fromCharCode(i);t.has(a)||t.set(a,r),n+=3;continue}if(r===`u`&&/^[0-9A-Fa-f]{4}$/.test(e.slice(n+2,n+6))){let r=e.slice(n,n+6),i=Number.parseInt(e.slice(n+2,n+6),16),a=String.fromCodePoint(i);t.has(a)||t.set(a,r),n+=5;continue}if(r===`U`&&/^[0-9A-Fa-f]{8}$/.test(e.slice(n+2,n+10))){let r=e.slice(n,n+10),i=Number.parseInt(e.slice(n+2,n+10),16),a=String.fromCodePoint(i);t.has(a)||t.set(a,r),n+=9;continue}}return t}function zt(e,t,n){let r=``;for(let i of e){let e=t.get(i);if(e){r+=e;continue}r+=Lt(i,n)}return r}function Bt(e,t,n){let r=Rt(t);if(r.size===0&&n===`singleline-basic`)return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,`\\u007F`);let i=zt(e,r,n);return n===`multiline-basic`?i.replace(/"""/g,`""\\"`):i}function Vt(){return{type:`Document`,loc:{start:S(),end:S()},items:[]}}function
|
|
18
|
-
`)){let e=t.split(/\r\n|\n/),r=e[e.length-1];n={line:e.length,column:r.length}}else n={line:1,column:t.length};return{type:`String`,loc:{start:S(),end:n},raw:t,value:e}}function
|
|
17
|
+
`&&i!==`\r`&&!t.has(i)&&t.set(i,`\\`+r),n+=1;continue}if(r===`x`&&/^[0-9A-Fa-f]{2}$/.test(e.slice(n+2,n+4))){let r=e.slice(n,n+4),i=Number.parseInt(e.slice(n+2,n+4),16),a=String.fromCharCode(i);t.has(a)||t.set(a,r),n+=3;continue}if(r===`u`&&/^[0-9A-Fa-f]{4}$/.test(e.slice(n+2,n+6))){let r=e.slice(n,n+6),i=Number.parseInt(e.slice(n+2,n+6),16),a=String.fromCodePoint(i);t.has(a)||t.set(a,r),n+=5;continue}if(r===`U`&&/^[0-9A-Fa-f]{8}$/.test(e.slice(n+2,n+10))){let r=e.slice(n,n+10),i=Number.parseInt(e.slice(n+2,n+10),16),a=String.fromCodePoint(i);t.has(a)||t.set(a,r),n+=9;continue}}return t}function zt(e,t,n){let r=``;for(let i of e){let e=t.get(i);if(e){r+=e;continue}r+=Lt(i,n)}return r}function Bt(e,t,n){let r=Rt(t);if(r.size===0&&n===`singleline-basic`)return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,`\\u007F`);let i=zt(e,r,n);return n===`multiline-basic`?i.replace(/"""/g,`""\\"`):i}function Vt(){return{type:`Document`,loc:{start:S(),end:S()},items:[]}}function G(e){let t=Ht(e);return{type:`Table`,loc:x(t.loc),key:t,items:[]}}function Ht(e){let t=qt(e);return{type:`TableKey`,loc:{start:S(),end:{line:1,column:t.length+2}},item:{type:`Key`,loc:{start:{line:1,column:1},end:{line:1,column:t.length+1}},value:e,raw:t}}}function Ut(e){let t=Wt(e);return{type:`TableArray`,loc:x(t.loc),key:t,items:[]}}function Wt(e){let t=qt(e);return{type:`TableArrayKey`,loc:{start:S(),end:{line:1,column:t.length+4}},item:{type:`Key`,loc:{start:{line:1,column:2},end:{line:1,column:t.length+2}},value:e,raw:t}}}function Gt(e,t){let n=Jt(e),{column:r}=n.loc.end,i=r+1;return W(t,{lines:0,columns:r+3-t.loc.start.column},{first_line_only:!0}),{type:`KeyValue`,loc:{start:b(n.loc.start),end:b(t.loc.end)},key:n,equals:i,value:t}}function Kt(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function qt(e){return e.map(e=>(mt(e,`Key ${JSON.stringify(e)}`),T.test(e)?e:Kt(e))).join(`.`)}function Jt(e){let t=qt(e);return{type:`Key`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function Yt(e,t){return mt(e,`String value`),t?Xt(e,t):Zt(e)}function Xt(e,t){if(at(t))return Zt(e,t);if(st(t))return e.includes(`'`)?e.includes(`'''`)?Zt(e):en(e,`'''${t.slice(1,-1)}'''`):Qt(e);if(ct(t))return e.includes(`'''`)?$t(e,`"""${t.slice(3,-3)}"""`):en(e,t);if(ot(t))return $t(e,t);throw Error(`Existing raw string value is not valid: ${t}`)}function Zt(e,t){let n=``;return n=t?`"${Bt(e,t,`singleline-basic`)}"`:Kt(e),{type:`String`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function Qt(e){let t=`'${e}'`,n;if(t.includes(`
|
|
18
|
+
`)){let e=t.split(/\r\n|\n/),r=e[e.length-1];n={line:e.length,column:r.length}}else n={line:1,column:t.length};return{type:`String`,loc:{start:S(),end:n},raw:t,value:e}}function $t(e,t){let n=Bt(e,t,`multiline-basic`),r=`"""`+(t.startsWith(`"""\r
|
|
19
19
|
`)?`\r
|
|
20
20
|
`:t.startsWith(`"""
|
|
21
21
|
`)?`
|
|
22
|
-
`:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=Pt(t,n);e!==null&&(r=e)}let a=
|
|
22
|
+
`:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=Pt(t,n);e!==null&&(r=e)}let a=tn(r);return{type:`String`,loc:{start:S(),end:a},raw:r,value:e}}function en(e,t){let n=`'''`+(t.startsWith(`'''\r
|
|
23
23
|
`)?`\r
|
|
24
24
|
`:t.startsWith(`'''
|
|
25
25
|
`)?`
|
|
26
|
-
`:``)+e+`'''`,r=
|
|
27
|
-
`)){let t=e.split(/\r\n|\n/),n=t[t.length-1];return{line:t.length,column:n.length}}else return{line:1,column:e.length}}function
|
|
26
|
+
`:``)+e+`'''`,r=tn(n);return{type:`String`,loc:{start:S(),end:r},raw:n,value:e}}function tn(e){if(e.includes(`
|
|
27
|
+
`)){let t=e.split(/\r\n|\n/),n=t[t.length-1];return{line:t.length,column:n.length}}else return{line:1,column:e.length}}function nn(e){let t=e.toString();return{type:`Integer`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function rn(e,t=1){let n,r;if(e===1/0)n=`inf`;else if(e===-1/0)n=`-inf`;else if(Number.isNaN(e)){let t=new Float64Array([e]),i=(new DataView(t.buffer).getUint32(4,!0)&2147483648)!=0;r=i?`-`:void 0,n=i?`-nan`:`nan`}else if(Object.is(e,-0))n=`-0.`+`0`.repeat(Math.max(t,1));else{n=e.toString();let r=n.search(/[eE]/);if(r!==-1){let e=n.slice(0,r),i=n.slice(r),a=e.indexOf(`.`);if(a===-1)n=`${e}.${`0`.repeat(Math.max(t,1))}${i}`;else{let r=e.length-a-1;n=r<t?`${e}${`0`.repeat(t-r)}${i}`:`${e}${i}`}}else{let e=n.indexOf(`.`);if(e===-1)n+=`.`+`0`.repeat(Math.max(t,1));else{let r=n.length-e-1;r<t&&(n+=`0`.repeat(t-r))}}}return{type:`Float`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e,...r===void 0?{}:{nanSign:r}}}function an(e){return{type:`Boolean`,loc:{start:S(),end:{line:1,column:e?4:5}},value:e}}function on(e,t=!1){t&&e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0&&(e=new de(e.toISOString().split(`T`)[0]));let n=e.toISOString();return{type:`DateTime`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function sn(e,t=!1){var n;let r=((n=e.constructor)==null?void 0:n.name)??``,i=r===`Temporal.PlainDate`||r===`PlainDate`,a=r===`Temporal.PlainTime`||r===`PlainTime`,o=r===`Temporal.PlainDateTime`||r===`PlainDateTime`,s;if(i)s=rt(e);else if(a)s=rt(e);else if(o){if(t){let t=globalThis.Temporal;if(!t)throw Error(`Temporal API is not available in this runtime. Set temporal: false or use a runtime with Temporal support.`);let n=t.PlainDate.from(e.toString().split(`T`)[0]);if(n.toString()+`T00:00:00`===e.toString().slice(0,19))return s=rt(n),{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:n}}s=rt(e)}else s=rt(e);return{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:e}}function cn(){return{type:`InlineArray`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function ln(e){return{type:`InlineItem`,loc:x(e.loc),item:e,comma:!1}}function un(){return{type:`InlineTable`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function dn(e){return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}function fn(e){return e.charCodeAt(0)===65279}function pn(e){return fn(e)?e.slice(1):e}function mn(e){for(let t of e){let e=vn(t);if(e!==null)return e}return!1}function hn(e,t){for(let n of t){let t=gn(n,e);if(t!==null)return t}return!0}function gn(e,t){if(!e||typeof e!=`object`)return null;if((e.type===`InlineArray`||e.type===`InlineTable`)&&e.loc){let n=_n(e.loc,t);if(n!==null)return n}if(e.items&&Array.isArray(e.items))for(let n of e.items){let e=gn(n,t);if(e!==null)return e;if(n.item){let e=gn(n.item,t);if(e!==null)return e}}for(let n of[`value`,`key`,`item`])if(e[n]){let r=gn(e[n],t);if(r!==null)return r}return null}function _n(e,t){if(!e||!e.start||!e.end)return null;let n=t.split(/\r?\n/),r=e.start.line-1,i=e.end.line-1,a=e.start.column,o=e.end.column,s=``;if(r===i){var c;s=((c=n[r])==null?void 0:c.substring(a,o+1))||``}else{n[r]&&(s+=n[r].substring(a));for(let e=r+1;e<i;e++)s+=`
|
|
28
28
|
`+(n[e]||``);n[i]&&(s+=`
|
|
29
|
-
`+n[i].substring(0,o+1))}let l=s.match(/^\[(\s*)/),u=s.match(/^\{(\s*)/);return l?l[1].length>0:u?u[1].length>0:null}function
|
|
29
|
+
`+n[i].substring(0,o+1))}let l=s.match(/^\[(\s*)/),u=s.match(/^\{(\s*)/);return l?l[1].length>0:u?u[1].length>0:null}function vn(e){if(!e||typeof e!=`object`)return null;if(e.type===`InlineArray`&&e.items&&Array.isArray(e.items)||e.type===`InlineTable`&&e.items&&Array.isArray(e.items))return yn(e.items);if(e.type===`KeyValue`&&e.value)return vn(e.value);if(e.items&&Array.isArray(e.items))for(let t of e.items){let e=vn(t);if(e!==null)return e}return null}function yn(e){if(e.length===0)return null;let t=e[e.length-1];return t&&typeof t==`object`&&`comma`in t?t.comma===!0:!1}function bn(e){let t=e.indexOf(`
|
|
30
30
|
`);return t>0&&e[t-1]===`\r`?`\r
|
|
31
31
|
`:`
|
|
32
|
-
`}function
|
|
33
|
-
`;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function
|
|
32
|
+
`}function xn(e){let t=0,n=e.length;for(;n>0&&e[n-1]===`
|
|
33
|
+
`;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function Sn(e){let t=e.split(/\r?\n/),n=0,r=0;for(let e of t)if(e.length!==0&&(e[0]===` `?n++:e[0]===` `&&r++,n+r>=5))break;return n>r}function Cn(e){if(!e||typeof e!=`object`)return{};let t=e=>typeof e==`boolean`?null:`expected boolean, got ${typeof e}`,n={newLine:e=>typeof e==`string`?null:`expected string, got ${typeof e}`,trailingNewline:e=>typeof e==`boolean`||typeof e==`number`?null:`expected boolean or number, got ${typeof e}`,trailingComma:t,bracketSpacing:t,leadingBom:t,inlineTableStart:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected non-negative integer or undefined, got ${typeof e}`,truncateZeroTimeInDates:t,useTabsForIndentation:t,minimumDecimals:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected non-negative integer or undefined, got ${typeof e}`,updateOrder:t},r={},i=[],a=[];for(let t in e){let o=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(o){let n=e[t],i=o(n);i?a.push(`${t} (${i})`):r[t]=n}else Object.prototype.hasOwnProperty.call(e,t)&&i.push(t)}if(i.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${i.join(`, `)}. Supported properties are: ${Object.keys(n).join(`, `)}`),a.length>0)throw TypeError(`Invalid types for format properties: ${a.join(`, `)}`);return r}function K(e,t){if(e){if(e instanceof q)return e;{let n=Cn(e);return new q(n.newLine??t.newLine,n.trailingNewline??t.trailingNewline,n.trailingComma??t.trailingComma,n.bracketSpacing??t.bracketSpacing,`inlineTableStart`in n?n.inlineTableStart:t.inlineTableStart,n.truncateZeroTimeInDates??t.truncateZeroTimeInDates,n.useTabsForIndentation??t.useTabsForIndentation,n.minimumDecimals??t.minimumDecimals,n.leadingBom??t.leadingBom,n.updateOrder??t.updateOrder)}}else return t}var q=class e{newLine;trailingNewline;trailingComma;bracketSpacing;leadingBom;inlineTableStart;truncateZeroTimeInDates;useTabsForIndentation;minimumDecimals;updateOrder;constructor(e,t,n,r,i,a,o,s,c,l){this.newLine=e??`
|
|
34
34
|
`,this.trailingNewline=t??1,this.trailingComma=n??!1,this.bracketSpacing=r??!0,this.inlineTableStart=i??1,this.truncateZeroTimeInDates=a??!1,this.useTabsForIndentation=o??!1,this.minimumDecimals=s??0,this.leadingBom=c??!1,this.updateOrder=l??!1}static default(){return new e(`
|
|
35
|
-
`,1,!1,!0,1,!1,!1,0,!1,!1)}static autoDetectFormat(t){return e.autoDetectFormatWithCst(t)}static autoDetectFormatWithCst(t,n){let r=e.default();r.leadingBom=
|
|
35
|
+
`,1,!1,!0,1,!1,!1,0,!1,!1)}static autoDetectFormat(t){return e.autoDetectFormatWithCst(t)}static autoDetectFormatWithCst(t,n){let r=e.default();r.leadingBom=fn(t);let i=pn(t);r.newLine=bn(i),r.trailingNewline=xn(i);try{let e=Array.isArray(n)?n:Array.from(n??Ne(i));r.trailingComma=mn(e),r.bracketSpacing=hn(i,e)}catch{r.trailingComma=!1,r.bracketSpacing=!0}return r.useTabsForIndentation=Sn(i),r.inlineTableStart=1,r.truncateZeroTimeInDates=!1,r.minimumDecimals=0,r.updateOrder=!1,r}static autoDetectFormatWithAst(t,n){return e.autoDetectFormatWithCst(t,n)}};function wn(e){return!l(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function Tn(e){return!d(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function En(e,t){return t.inlineTableStart===0?e:(e.items.filter(e=>{if(!a(e))return!1;let n=d(e.value),r=l(e.value)&&e.value.items.length>0&&e.value.items.every(e=>d(e.item));if(n||r){let n=An(e.key.value);return t.inlineTableStart===void 0||n<t.inlineTableStart}return!1}).forEach(t=>{V(e,e,t),d(t.value)?t.value.items.length===0?B(e,e,G(t.key.value)):B(e,e,Dn(t)):On(t).forEach(t=>{B(e,e,t)})}),U(e),e)}function Dn(e){let t=G(e.key.value);for(let n of e.value.items)B(t,t,n.item);return U(t),t}function On(e){let t=Vt();for(let n of e.value.items){let r=Ut(e.key.value);B(t,t,r);for(let e of n.item.items)B(t,r,e.item)}return U(t),t.items}function kn(e){if(e.items.length>0){let t=e.items[e.items.length-1];e.loc.end.line=t.loc.end.line,e.loc.end.column=t.loc.end.column}else e.loc.end.line=e.key.loc.end.line,e.loc.end.column=e.key.loc.end.column}function An(e){return Math.max(0,e.length-1)}function jn(e,t){if(t.inlineTableStart===void 0||t.inlineTableStart===0)return e;let n=[];for(let i of e.items)if(a(i)&&d(i.value)){if(An(i.key.value)<t.inlineTableStart){let r=Dn(i);V(e,e,i),B(e,e,r),Mn(r,n,t)}}else(i.type===`Table`||r(i))&&Mn(i,n,t);for(let t of n)B(e,e,t);return U(e),e}function Mn(e,t,n){for(let r=e.items.length-1;r>=0;r--){let i=e.items[r];if(a(i)&&d(i.value)){let r=[...e.key.item.value,...i.key.value];if(An(r)<(n.inlineTableStart??1)){let a=G(r);for(let e of i.value.items)B(a,a,e.item);V(e,e,i),kn(e),t.push(a),Mn(a,t,n)}}}}function Nn(e){let t=0,n=0;for(let r of e.items)n===0&&r.loc.start.line>1?t=1-r.loc.start.line:r.loc.start.line+t>n+2&&(t+=n+2-(r.loc.start.line+t)),W(r,{lines:t,columns:0}),n=r.loc.end.line;return e}function J(e,t=q.default()){e=Rn(e);let n=Vt();for(let r of Pn(e,t))B(n,n,r);return U(n),En(n,t),jn(n,t),Nn(n)}function*Pn(e,t){for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=Rn(r);i!==void 0&&(yield Gt([n],Fn(i,t)))}}function Fn(e,t){let n=t.minimumDecimals??0;if(e===null)throw Error(`"null" values are not supported`);if(e===void 0)throw Error(`"undefined" values are not supported inside arrays`);return Xe(e)?Yt(e):Qe(e)?nn(e):Ze(e)?n>0?rn(e,n):nn(e):$e(e)?rn(e,Math.max(n,1)):et(e)?an(e):P(e)?sn(e,t.truncateZeroTimeInDates):tt(e)?on(e,t.truncateZeroTimeInDates):Array.isArray(e)?In(e,t):Ln(e,t)}function In(e,t){let n=cn();for(let r of e)B(n,n,ln(Fn(r,t)));return kt(n,n,t.bracketSpacing),At(n,n,t.trailingComma),U(n),n}function Ln(e,t){if(e=Rn(e),!F(e))return Fn(e,t);let n=un();for(let r of Pn(e,t))B(n,n,ln(r));return kt(n,n,t.bracketSpacing),At(n,n,t.trailingComma),U(n),n}function Rn(e){return!e||tt(e)||P(e)?e:typeof e.toJSON==`function`?e.toJSON():e}const zn=/(\r\n|\n)/g;function Bn(e,t){let n=[];function r(e){switch(e.type){case`Document`:for(let t=0;t<e.items.length;t++)r(e.items[t]);break;case`Table`:{let t=e;r(t.key);for(let e=0;e<t.items.length;e++)r(t.items[e]);break}case`TableKey`:{let t=e;Y(n,t.loc,`[`+t.item.raw+`]`);break}case`TableArray`:{let t=e;r(t.key);for(let e=0;e<t.items.length;e++)r(t.items[e]);break}case`TableArrayKey`:{let t=e;Y(n,t.loc,`[[`+t.item.raw+`]]`);break}case`KeyValue`:{let t=e,i=t.loc.start.line;Vn(n,i,t.equals,`=`),r(t.key),r(t.value);break}case`Key`:Y(n,e.loc,e.raw);break;case`String`:Y(n,e.loc,e.raw);break;case`Integer`:Y(n,e.loc,e.raw);break;case`Float`:Y(n,e.loc,e.raw);break;case`Boolean`:Y(n,e.loc,e.value.toString());break;case`DateTime`:Y(n,e.loc,e.raw);break;case`InlineArray`:{let t=e,{start:i,end:a}=t.loc;Vn(n,i.line,i.column,`[`),Vn(n,a.line,a.column-1,`]`);for(let e=0;e<t.items.length;e++)r(t.items[e]);break}case`InlineTable`:{let t=e,{start:i,end:a}=t.loc;Vn(n,i.line,i.column,`{`),Vn(n,a.line,a.column-1,`}`);for(let e=0;e<t.items.length;e++)r(t.items[e]);break}case`InlineItem`:{let t=e;if(r(t.item),t.comma){let e=t.loc.end;Vn(n,e.line,e.column,`,`)}break}case`Comment`:Y(n,e.loc,e.raw);break;default:{let t=e.type;throw Error(`toTOML: Unrecognized node type: ${String(t)}`)}}}if(it(e))for(let t of e)r(t);else r(e);if(t.useTabsForIndentation)for(let e=0;e<n.length;e++){let t=n[e],r=t.match(/^( +)/);if(r){let i=r[1];n[e]=` `.repeat(i.length)+t.substring(i.length)}}return n.join(t.newLine)+t.newLine.repeat(t.trailingNewline)}function Y(e,t,n){if(t.start.line===t.end.line){let r=Hn(e,t.start.line),i=r.substring(0,t.start.column),a=i.length<t.start.column?i.padEnd(t.start.column,` `):i,o=r.substring(t.end.column);e[t.start.line-1]=a+n+o;return}let r=n.split(zn).filter(e=>e!==`
|
|
36
36
|
`&&e!==`\r
|
|
37
|
-
`),i=t.end.line-t.start.line+1;if(r.length!==i)throw Error(`Mismatch between location and raw string, expected ${i} lines for "${n}"`);for(let n=t.start.line;n<=t.end.line;n++){let i=Wn(e,n),a=n===t.start.line,o=n===t.end.line,s=``;if(a){let e=i.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column,` `):e}let c=o?i.substring(t.end.column):``;e[n-1]=s+r[n-t.start.line]+c}}function Un(e,t,n,r){let i=Wn(e,t),a=i.length<n?i.padEnd(n,` `):i.substring(0,n),o=i.substring(n+1);e[t-1]=a+r+o}function Wn(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function Gn(e,t=`asNeeded`){let n=e.replace(/_/g,``),r=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){let e=n[0]===`+`||n[0]===`-`?n[0]:``;r=e+n.slice(+!!e).toLowerCase()}let i;try{i=BigInt(r)}catch{return Number(n)}return t===!0?i:t===!1||i>=BigInt(-(2**53-1))&&i<=BigInt(2**53-1)?Number(i):i}function Kn(e,t,n){for(let r of e.items){let e=r.item;if(e.value.type===`InlineTable`){let r=t.concat(e.key.value);n.add(Y(r)),Kn(e.value,r,n)}}}function qn(e){var t,n,r,i,a,o;if((t=e.constructor)!=null&&(t=t.name)!=null&&(n=t.startsWith)!=null&&n.call(t,`Temporal.`)||((r=e.constructor)==null?void 0:r.name)===`PlainDate`||((i=e.constructor)==null?void 0:i.name)===`PlainTime`||((a=e.constructor)==null?void 0:a.name)===`PlainDateTime`||((o=e.constructor)==null?void 0:o.name)===`ZonedDateTime`)return e;let s=globalThis.Temporal;if(e instanceof ue)return s.PlainDate.from(e.toISOString());if(e instanceof de)return s.PlainTime.from(e.toISOString());if(e instanceof M)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof N){let t=e.toISOString().replace(` `,`T`),n=t.match(/([+-]\d{2}:\d{2}|Z)$/),r=n?n[1]:`Z`,i=t.replace(/([+-]\d{2}:\d{2}|Z)$/,``),a=r===`Z`?`+00:00`:r;return s.ZonedDateTime.from(`${i}${r}[${a}]`)}return s.PlainDateTime.from(e.toISOString().replace(`Z`,``))}function J(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=qe(),o=new Set,s=new Set,c=new Set,l=new Set,u=new Set,d=a,f=[],p={tables:o,table_arrays:s,defined:c,implicit_tables:l,inline_tables:u};for(let t of e)switch(t.type){case`Table`:m(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`TableArray`:h(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`KeyValue`:g(t);break}return a;function m(e){let n=e.key.item.value;try{Yn(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=Y(n);o.add(r),c.add(r),d=Xn(a,n),f=n}function h(e){let n=e.key.item.value;try{Yn(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=Y(n);s.add(r),c.add(r),d=Zn(a,n),f=n}function g(e){let n=e.key.value;try{Yn(d,f,n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}if(n.length>1)for(let e=1;e<n.length;e++){let t=Y(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=Jn(e.value,{integersAsBigInt:r,temporal:i})}catch(n){let r=n;throw new C(t,e.value.loc.start,r.message)}if(e.value.type===`InlineTable`){let t=f.concat(n);u.add(Y(t)),Kn(e.value,t,u)}let o=n.length>1?Xn(d,n.slice(0,-1)):d;o[F(n)]=a,c.add(Y(f.concat(n)))}}function Jn(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=qe(),i=new Set,a=new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=Jn(e.value,{integersAsBigInt:n,temporal:r}),c=Y(o);if(i.has(c))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=Y(o.slice(0,e));if(i.has(t))throw Error(`Key "${c}" conflicts with key: "${t}"`)}if(a.has(c)){let e=a.get(c);throw Error(`Key "${c}" conflicts with key: "${e}"`)}i.add(c);for(let e=1;e<o.length;e++){let t=Y(o.slice(0,e));a.has(t)||a.set(t,c)}let l=o.length>1?Xn(t,o.slice(0,-1)):t;l[F(o)]=s}),t;case`InlineArray`:return e.items.map(e=>Jn(e.item,{integersAsBigInt:n,temporal:r}));case`DateTime`:if(r){if(globalThis.Temporal===void 0)throw Error(`Temporal API is not available in this runtime. Set temporal: false or use a runtime with Temporal support.`);return qn(e.value)}return e.value;case`String`:return e.value;case`Integer`:return Gn(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function Yn(e,t,n,r,i){let a=t.length>0?Y(t):``,o=Array(n.length),s=a;for(let e=0;e<n.length;e++)s=s?s+`.`+n[e]:n[e],o[e]=s;let c=o[n.length-1];if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(t))throw Error(`Cannot extend inline table at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.inline_tables.has(c))throw Error(`Cannot extend inline table at ${c}`);if(r===`Table`||r===`TableArray`)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(t))throw Error(`Cannot extend inline table at ${t}`)}if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.table_arrays.has(t))throw Error(`Cannot traverse Array of Tables at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.implicit_tables.has(c))throw Error(`Implicit table already defined: ${c}`);if(r===`KeyValue`&&i.implicit_tables.has(c))throw Error(`Table already defined: ${c}`);if(r===`KeyValue`&&n.length>1)for(let e=1;e<=n.length;e++){let t=o[e-1];if(i.tables.has(t))throw Error(`Cannot extend explicit table ${t} with dotted keys`)}let l=0;for(let t of n){if(!st(e,t))return;if($n(e[t]))throw Error(`Value already defined for ${o[l]}`);let r=o[l];if(Array.isArray(e[t])&&!i.table_arrays.has(r))throw Error(`Cannot add to static array at ${r}`);let a=l++<n.length-1;e=Array.isArray(e[t])&&a?F(e[t]):e[t]}let u=c;if(e&&r===`Table`&&i.defined.has(u)||e&&r===`KeyValue`&&n.length===1&&i.defined.has(u)&&!$n(e))throw Error(`Table already defined: ${u}`);if(e&&r===`TableArray`&&!i.table_arrays.has(u))throw Error(`Cannot add Array of Tables to table at ${u}`)}function Xn(e,t){let n=Qn(e,t.slice(0,-1)),r=F(t);return n[r]||(n[r]=qe()),n[r]}function Zn(e,t){let n=Qn(e,t.slice(0,-1)),r=F(t);n[r]||(n[r]=[]);let i=qe();return n[F(t)].push(i),i}function Qn(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=qe()),Array.isArray(e[t])?F(e[t]):e[t]),e)}function $n(e){return typeof e!=`object`&&!I(e)}function Y(e){return e.join(`.`)}function er(e){return e.type===`Add`}function tr(e){return e.type===`Edit`}function X(e){return e.type===`Remove`}function nr(e){return e.type===`Move`}function rr(e){return e.type===`Rename`}function ir(e,t,n=[],r={}){if(e===t||ct(e,t))return[];if(typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t)){let n=new Float64Array([e]),r=new Float64Array([t]),i=new DataView(n.buffer),a=new DataView(r.buffer);if((i.getUint32(4,!0)&2147483648)==(a.getUint32(4,!0)&2147483648))return[]}return Array.isArray(e)&&Array.isArray(t)?or(e,t,n,r):tt(e)&&tt(t)?ar(e,t,n,r):[{type:`Edit`,path:n}]}function ar(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>z(e[t])),s=Object.keys(t),c=s.map(e=>z(t[e])),l=(e,t)=>{if(t.indexOf(e)<0)return!1;let n=a[o.indexOf(e)];if(s.includes(n))return!1;let r=s[c.indexOf(e)];return r!==void 0&&!a.includes(r)},u=new Map;if(a.forEach((a,d)=>{let f=n.concat(a);if(s.includes(a))lt(i,ir(e[a],t[a],f,r));else if(l(o[d],c)){let e=s[c.indexOf(o[d])];i.push({type:`Rename`,path:n,from:a,to:e}),u.set(a,e)}else i.push({type:`Remove`,path:f})}),s.forEach((e,t)=>{!a.includes(e)&&!l(c[t],o)&&i.push({type:`Add`,path:n.concat(e)})}),r.updateOrder){let e=[];for(let t of a)if(s.includes(t))e.includes(t)||e.push(t);else if(u.has(t)){let n=u.get(t);e.includes(n)||e.push(n)}for(let t of s)e.includes(t)||e.push(t);s.forEach((t,r)=>{if(e[r]===t)return;let a=e.indexOf(t);i.push({type:`Move`,path:n,from:a,to:r,key:t}),e.splice(a,1),e.splice(r,0,t)})}return i}function or(e,t,n=[],r={}){let i=[],a=e.map(z),o=t.map(z);o.forEach((s,c)=>{let l=c>=a.length;if(!l&&a[c]===s)return;let u=a.indexOf(s,c+1);if(!l&&u>-1){i.push({type:`Move`,path:n,from:u,to:c});let e=a.splice(u,1);a.splice(c,0,...e);return}let d=!o.includes(a[c]);if(!l&&d){lt(i,ir(e[c],t[c],n.concat(c),r)),a[c]=s;return}i.push({type:`Add`,path:n.concat(c)}),a.splice(c,0,s)});for(let e=o.length;e<a.length;e++)i.push({type:`Remove`,path:n.concat(e)});return i}function Z(n,i){if(!i.length)return u(n)&&a(n.item)?n.item:n;if(a(n))return Z(n.value,i);let o={},s;if(p(n)&&n.items.some((c,l)=>{try{let d=[];if(a(c))d=c.key.value;else if(t(c))d=c.key.item.value;else if(r(c)){d=c.key.item.value;let e=z(d);o[e]||(o[e]=0);let t=o[e]++;d=d.concat(t)}else u(c)&&a(c.item)?d=c.item.key.value:u(c)&&(d=[l]);if(d.length&&R(d,i.slice(0,d.length))){let t=i.slice(d.length);if(e(n)&&r(c)&&t.length>0){let e=c.key.item.value,i=n,a=i.items.findIndex((t,n)=>n>l&&r(t)&&R(t.key.item.value,e)),o=a===-1?i.items.length:a;s=sr(c,t,e,i.items.slice(l+1,o))}else s=u(c)&&a(c.item)?i.length===d.length?c:Z(c.item.value,t):u(c)&&i.length>d.length?Z(c.item,t):Z(c,t);return!0}else return!1}catch{return!1}}),!s)throw Error(`Node not found at ${i.join(`.`)}`);return s}function sr(e,n,i,a){try{return Z(e,n)}catch{}let o={};for(let e of a){let a=[];if(t(e)){let t=e.key.item.value;t.length>i.length&&R(t.slice(0,i.length),i)&&(a=t.slice(i.length))}else if(r(e)){let t=e.key.item.value;if(t.length>i.length&&R(t.slice(0,i.length),i)){let e=t.slice(i.length),n=z(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&R(a,n.slice(0,a.length)))try{return Z(e,n.slice(a.length))}catch{}}throw Error(`Node not found at (aot scope) ${n.join(`.`)}`)}function Q(e,t){try{return Z(e,t)}catch{}}function $(e,t){let n=t,r;for(;n.length&&!r;)n=n.slice(0,-1),r=Q(e,n);if(!r)throw Error(`Parent not found for ${t.join(`.`)}`);return r}const cr=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,lr=new RegExp(String.raw`^#\s*${cr}(?:\s*\.\s*${cr})*\s*=`),ur=new RegExp(String.raw`^#\s*\[\[?\s*${cr}(?:\s*\.\s*${cr})*\s*\]\]?\s*$`);function dr(e){return lr.test(e.raw)||ur.test(e.raw)}function fr(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function pr(e){if(a(e))return e.key.value[0];if(t(e)||r(e))return e.key.item.value[0];if(u(e)&&a(e.item))return e.item.key.value[0]}function mr(e,t,n){let r=[],i=t,a,o=[],s=()=>{o.length&&(r.push({kind:`pinned`,items:o,startLine:o[0].loc.start.line,endLine:F(o).loc.end.line}),o=[])};for(let t of e){if(f(t)){if(t.loc.start.line<=i){a?(a.items.push(t),a.endLine=Math.max(a.endLine,t.loc.end.line)):r.push({kind:`pinned`,items:[t],startLine:t.loc.start.line,endLine:t.loc.end.line});continue}let e=o.length?F(o).loc.end.line:void 0;o.length&&t.loc.start.line===e+1||s(),o.push(t);continue}let e=[];if(o.length){let r=F(o).loc.end.line+1===t.loc.start.line,i=o.every(dr);r&&n(t)&&!i?(e=o,o=[]):s()}let c=[...e,t],l={kind:`member`,member:t,key:pr(t),items:c,startLine:c[0].loc.start.line,endLine:t.loc.end.line};r.push(l),a=l,i=t.loc.end.line}return s(),r}function hr(t,n=()=>!0){let r=e(t)?0:t.key.loc.end.line;return mr(t.items,r,n)}function gr(e,t){let n=t.filter(t=>f(t)&&t.loc.start.line>=e.loc.start.line&&t.loc.start.line<=e.loc.end.line);return mr([...e.items,...n].sort((e,t)=>e.loc.start.line-t.loc.start.line||e.loc.start.column-t.loc.start.column),e.loc.start.line,()=>!0)}function _r(e,n){function i(e,t){if(e===n)return t;if(a(e))return i(e.value,t);if(d(e)||l(e))for(let r of e.items){if(r===n)return t;let e=i(r.item,t);if(e)return e}}function o(e){for(let s of e.items){if(s===n)return e;if(a(s)){let t=i(s.value,e);if(t)return t}else if(t(s)||r(s)){let e=o(s);if(e)return e}}}return o(e)}function vr(e){for(let n=0;n<e.items.length;n++){let i=e.items[n];if(!t(i)&&!r(i))continue;let a=e.items[n+1];if(!a)continue;let o=yr(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),Dt(i),n+=o.length}}function yr(e,t){let n=F(hr(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(dr);if(!(!i||a))return r}function br(n,i,a){if(e(i)&&(t(a)||r(a))){let e=i.items.indexOf(a),o=e>0?i.items[e-1]:void 0;if(o&&(t(o)||r(o))){let e=yr(o,a);if(e)for(let t of e)U(n,o,t)}}if(e(i)||t(i)||r(i)){let e=hr(i).find(e=>e.member===a);if(e){let t=e.items.indexOf(a);for(let r=0;r<=t;r++){let t=e.items[r];i.items.includes(t)&&U(n,i,t)}for(let n=t+1;n<e.items.length;n++){let t=e.items[n],r=i.items.indexOf(t);r<0||i.items.splice(r,1)}return}}if(fr(i)&&e(n)){let e=_r(n,i);if(e){let t=gr(i,e.items).find(e=>e.member===a);if(t){let r=t.items.filter(e=>e!==a);for(let t of r){let n=e.items.indexOf(t);n<0||e.items.splice(n,1)}r.length&&(a.loc.start=t.items[0].loc.start,a.loc.end=F(t.items).loc.end),U(n,i,a,e.items),W(n);return}}}U(n,i,a)}function xr(t,n,r,i){if(fr(n)&&e(t)){let e=_r(t,n);if(e){let a=gr(n,e.items),o=[],s,c;for(let t of a){if(t.kind!==`member`||!t.member)continue;let n=t.items.filter(e=>e!==t.member);if(t.member===r&&(s=b(r.loc.start),c=b(r.loc.end),n.length&&(r.loc.start=b(t.items[0].loc.start),r.loc.end=b(F(t.items).loc.end))),n.length){o.push({owner:t.member,ownerOriginalStart:b(t.member.loc.start),comments:n});for(let t of n){let n=e.items.indexOf(t);n>=0&&e.items.splice(n,1)}}}U(t,n,r,e.items),H(t,n,r,i,void 0,e.items),W(t);for(let{owner:t,ownerOriginalStart:n,comments:i}of o){let a;t===r?(a={lines:r.loc.start.line-n.line,columns:r.loc.start.column-n.column},r.loc.start={line:s.line+a.lines,column:s.column+a.columns},r.loc.end={line:c.line+a.lines,column:c.column+a.columns}):a={lines:t.loc.start.line-n.line,columns:t.loc.start.column-n.column};for(let t of i){At(t,a);let n=e.items.findIndex(e=>e.loc.start.line>t.loc.start.line);n===-1?e.items.push(t):e.items.splice(n,0,t)}}return}}U(t,n,r),H(t,n,r,i)}function Sr(e){let n=[];for(let i of e){if(i.kind===`pinned`){n.push({kind:`pinned`,isSection:!1,movable:!1,slots:[i],startLine:i.startLine,endLine:i.endLine,items:i.items});continue}let e=t(i.member)||r(i.member),a=n[n.length-1];if(a&&a.kind===`member`&&a.key===i.key){a.slots.push(i),a.endLine=i.endLine,a.items=a.items.concat(i.items);continue}n.push({kind:`member`,key:i.key,isSection:e,movable:!0,slots:[i],startLine:i.startLine,endLine:i.endLine,items:[...i.items]})}let i=new Map;for(let e of n)e.kind===`member`&&e.key!==void 0&&i.set(e.key,(i.get(e.key)??0)+1);for(let e of n)e.kind===`member`&&e.key!==void 0&&i.get(e.key)>1&&(e.movable=!1);return n}function Cr(e,t){let n=[...e];for(let e of t){if(e.key===void 0)continue;let t=n.indexOf(e.key);if(t===-1)continue;let r=Math.max(0,Math.min(e.to,n.length-1));t!==r&&(n.splice(t,1),n.splice(r,0,e.key))}return n}function wr(e){return[...e.path,e.key].join(`.`)}function Tr(n,i){if(i.length===0)return n;let o;try{o=Q(n,i)}catch{return}if(o&&(a(o)&&(o=o.value),o&&m(o)&&(o=o.item),o&&(e(o)||t(o)||r(o))))return o}function Er(t,n,r,i){let a=Sr(hr(t,e=>r.has(e))),o=new Map;for(let e of a)e.kind===`member`&&e.movable&&e.key!==void 0&&o.set(e.key,e);let s=new Set(a.filter(e=>e.kind===`member`&&e.key!==void 0).map(e=>e.key));for(let e of n)e.key!==void 0&&s.has(e.key)&&!o.has(e.key)&&i.push(`"${wr(e)}" -- its entries are not contiguous in the document (e.g. the TOML spec's own "valid but discouraged" out-of-order table pattern), so reordering was skipped for it`);if(o.size===0)return;let c=0,l=a.filter(e=>e.kind===`member`).map(e=>e.movable?e.key:`\u0000anchor:${c++}`),u=n.filter(e=>e.key!==void 0&&o.has(e.key));if(u.length===0)return;let d=Cr(l,u).filter(e=>o.has(e)),f=d.filter(e=>!o.get(e).isSection),p=d.filter(e=>o.get(e).isSection),m=!1;for(let e of d)if(o.get(e).isSection)m=!0;else if(m){i.push(`the requested order asked for a root key-value to be positioned after a section header, which TOML cannot represent -- each group (root key-values, section blocks) was reordered to match its own requested relative order instead`);break}let h=0,g=0,_=a.map(e=>{if(e.kind!==`member`||!e.movable)return e;let t=e.isSection?p[g++]:f[h++];return o.get(t)});if(_.every((e,t)=>e===a[t]))return;let v=e(t)?1:t.key.loc.end.line,y=a.map((e,t)=>t===0?e.startLine-v:e.startLine-a[t-1].endLine-1),b=v;for(let e=0;e<_.length;e++){let t=_[e],n=y[e],r=(e===0?b:b+1)+n-t.startLine;if(r!==0)for(let e of t.items)At(e,{lines:r,columns:0});b=t.endLine+r}let x=_.flatMap(e=>e.items),S=t.items;S.splice(0,S.length,...x),Dt(t)}function Dr(e,t,n){if(t.length===0)return;vr(e);let r=[],i=new Map;for(let n of t){if(n.key===void 0)continue;let t=Tr(e,n.path);if(!t){r.push(`"${wr(n)}" -- unsupported location for reordering (e.g. a dotted-key implicit table, or an interior of an inline table/array-of-tables entry)`);continue}let a=i.get(t);a?a.push(n):i.set(t,[n])}for(let[e,t]of i)Er(e,t,n,r);if(r.length>0){let e=[...new Set(r)];console.warn(`toml-patch: updateOrder could not honor the requested position for ${e.length===1?`1 entry`:`${e.length} entries`}, left unchanged:\n`+e.map(e=>` - ${e}`).join(`
|
|
38
|
-
`))}Dt(e)}const Or=new WeakMap,kr=new WeakMap;function Ar(e,t){let n=e[t].loc.end.line;for(let r=t+1;r<e.length;r++){let t=e[r];if(f(t)&&t.loc.start.line===n)return t;if(!f(t)&&t.loc.start.line>n)return}}function jr(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function Mr(e,t,n){kr.has(e)||kr.set(e,e.loc.start.column);let r=e.loc.start.column+n,i=Math.max(t,r)-r;i!==0&&(e.loc.start.column+=i,e.loc.end.column+=i)}function Nr(e,t){kr.set(t,t.loc.start.column),Or.set(t,t.loc.start.column-e.loc.end.column)}function Pr(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=Ar(i,a);if(!o||n.loc.start.line!==n.loc.end.line||r.loc.start.line!==r.loc.end.line)return;let s=o.loc.start.column,c=o.loc.start.line,l=[jr(i,a,-1),jr(i,a,1)],u;for(let e of l){if(e==null)continue;let t=Ar(i,e);if(t&&Math.abs(t.loc.start.line-c)===1&&t.loc.start.column===s){u=t.loc.start.column;break}}if(u==null)return;let d=g(n.loc),f=g(r.loc).columns-d.columns;Mr(o,u,f)}function Fr(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Ar(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[jr(r,i,-1),jr(r,i,1)];for(let e of c){if(e==null)continue;let t=Ar(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){Mr(a,t.loc.start.column,n);return}}}function Ir(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Ar(r,i);a&&Nr(t,a)}function Lr(e,t,n){if(!l(e)&&!d(e))return 0;let r=g(t.loc),i=n>0,a=n<e.items.length,o=n===e.items.length,s=u(t)?t.comma:!1,c=i&&s&&!a&&o;return r.columns+(i||a?2:0)+(s?1+(c?-1:0):0)}function Rr(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&Rr(i,n)}return n}function zr(e,n=new Set){for(let i of e.items){if(a(i)&&d(i.value)&&i.loc.start.line===i.loc.end.line){n.add(i.loc.end.line);continue}(t(i)||r(i))&&zr(i,n)}return n}function Br(e){for(let n of e.items)(t(n)||r(n))&&Br(n);let n=e.loc.end.line,i=e.loc.end.column,a=(e,t)=>{(e>n||e===n&&t>i)&&(n=e,i=t)};(t(e)||r(e))&&a(e.key.loc.end.line,e.key.loc.end.column);for(let t of e.items)a(t.loc.end.line,t.loc.end.column);e.loc.end.line=n,e.loc.end.column=i}function Vr(e,t,n){let r=n.newLine,i=t.match(/(?:\r\n|\n)+$/u),a=i?i[0]:``,o=a?t.slice(0,-a.length):t,s=o.length?o.split(r):[],c=zr(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=Rr(e).filter(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n);return r.trim().length>0&&/\s{2,}$/u.test(r)}).sort((e,t)=>e.loc.start.line-t.loc.start.line),d=[],f=[];for(let e of u){let t=f[f.length-1];!t||e.loc.start.line===t.loc.start.line+1?f.push(e):(f.length>0&&d.push(f),f=[e])}f.length>0&&d.push(f);for(let e of d){if(e.length<2)continue;let t=kr.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=kr.get(t)??t.loc.start.column;n.set(e,(n.get(e)||0)+1)}let r=1;for(let[e,i]of n)i>r&&(r=i,t=e);let i=Math.max(...e.map(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e);return t.slice(0,n).trimEnd().length})),a=Math.min(...e.map(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n).trimEnd();return Math.max(1,n-r.length)})),o=e.filter(e=>Or.has(e)),u=e.some(e=>!c.has(e.loc.start.line));if(o.length>0&&u){let t=Math.min(...e.map(e=>{if(Or.has(e))return Or.get(e)||1;let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n).trimEnd();return Math.max(1,n-r.length)}));a=Math.min(a,t)}if(t<i+1){let e=i+a;t=Math.max(t,e)}for(let n of e){let e=n.loc.start.line-1,r=s[e]||``,i=l(r,n),a=r.slice(0,i).trimEnd(),o=Math.max(t,a.length+1);i!==o&&(s[e]=a+` `.repeat(o-a.length)+n.raw),n.loc.start.column!==o&&(n.loc.start.column=o,n.loc.end.column=o+n.raw.length)}}return Br(e),s.join(r)+a}function Hr(e,t,n){let r=Array.from(je(mn(e))),i=Tn(n,G.autoDetectFormatWithCst(e,r)),a=Kr(r,t,i).tomlString;return i.leadingBom?`${a}`:a}function Ur(e,t=new WeakSet){if(typeof e!=`object`||!e)return!1;if(L(e))return!0;if(t.has(e))return!1;t.add(e);for(let n of Object.values(e))if(Ur(n,t))return!0;return!1}function Wr(e){let t=new WeakSet,n=e=>{t.add(e)};return pt(e,{Document:n,Table:n,TableKey:n,TableArray:n,TableArrayKey:n,KeyValue:n,Key:n,String:n,Integer:n,Float:n,Boolean:n,DateTime:n,InlineArray:n,InlineItem:n,InlineTable:n,Comment:n}),t}function Gr(e,t,n,r){if(!tt(t))return t;let i=J(K(e,Tn({...n,inlineTableStart:0},n)).items,``,{temporal:r});if(!tt(i))return t;let a={};for(let e of Object.keys(i))Object.prototype.hasOwnProperty.call(t,e)&&(a[e]=t[e]);for(let e of Object.keys(t))Object.prototype.hasOwnProperty.call(a,e)||(a[e]=t[e]);return a}function Kr(e,t,n){let r=[...e],i=Ur(t),a=1,o=0;for(let e of r){let t=e.loc.end;(t.line>a||t.line===a&&t.column>o)&&(a=t.line,o=t.column)}let s=J(r,``,{temporal:i}),c={type:`Document`,loc:{start:{line:1,column:0},end:{line:a,column:o}},items:r},l=n.inlineTableStart!=null&&n.inlineTableStart>1?1:n.inlineTableStart,u=Tn({...n,inlineTableStart:l},n),d=K(t,u),f=J(d.items,``,{temporal:i}),p=n.updateOrder?Gr(t,f,u,i):f,m=qr(Jr(c,p,ir(s,p,[],{updateOrder:n.updateOrder})));if(m.length===0)return{tomlString:Hn(r,n),document:c};let h=Zr(c,d,m,n,i,Wr(c));return{tomlString:Vr(h,Hn(h.items,n),n),document:h}}function qr(e){for(let t=0;t<e.length;t++){let n=e[t];if(X(n)){let r=t+1;for(;r<e.length;){let i=e[r];if(!X(i)){r++;continue}let a=F(n.path),o=F(i.path),s=n.path.slice(0,-1),c=i.path.slice(0,-1);if(typeof a==`number`&&typeof o==`number`&&R(s,c)&&o>a){e.splice(r,1),e.splice(t,0,i),t=-1;break}r++}}}return e}function Jr(e,t,n){let i=new Set,a=[],o=new Map;for(let e of n){if(!X(e)&&!er(e))continue;let t=e.path.slice(0,-1);if(t.length===0)continue;let n=JSON.stringify(t),r=o.get(n);r||(r={path:t,removes:[],adds:[]},o.set(n,r)),(X(e)?r.removes:r.adds).push(e)}for(let t of o.values())t.removes.length!==0&&t.adds.length!==0&&(Q(e,t.path)||(t.removes.forEach(e=>i.add(e)),t.adds.forEach(e=>i.add(e)),a.push({type:`Edit`,path:t.path})));let s=new Map;for(let t of n){if(i.has(t)||!tr(t)&&!er(t)&&!X(t)||typeof F(t.path)!=`number`)continue;let n=t.path.slice(0,-1);if(n.length===0)continue;let a=Q(e,n.concat(0));!a||!r(a)||s.set(JSON.stringify(n),n)}for(let e of s.values()){let r=t;for(let t of e)r=r==null?void 0:r[t];if(Array.isArray(r)&&!r.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e))){for(let t of n)i.has(t)||!tr(t)&&!er(t)&&!X(t)||t.path.length===e.length+1&&R(t.path.slice(0,-1),e)&&i.add(t);a.push({type:`Edit`,path:e})}}if(i.size===0)return n;let c=n.filter(e=>!i.has(e));return c.push(...a),c}function Yr(e,t){return t.map(t=>T.test(t)?t:`"${Bt(t,e,`singleline-basic`)}"`).join(`.`)}function Xr(e,t){if(o(e)&&o(t)){let n=Xt(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(c(e)&&c(t)){let n=e.raw,r=t.value;if(L(r)){let e=et(r);if(n.includes(` `)&&e.includes(`T`)&&(e=e.replace(`T`,` `)),/(?:\+00:00|-00:00)/.test(n)&&e.endsWith(`Z`)){let t=n.match(/([+-]00:00)/)[1];e=e.replace(/Z$/,t)}t.raw=e,t.loc.end.column=t.loc.start.column+t.raw.length}else{let e=le.createDateWithOriginalFormat(r,n);t.value=e,t.raw=e.toISOString(),t.loc.end.column=t.loc.start.column+t.raw.length}}if(s(e)&&s(t)&&Number.isNaN(e.value)&&Number.isNaN(t.value)){let n=e,r=t;n.nanSign&&(r.nanSign=`+`,r.raw=`+nan`)}if(l(e)&&l(t)){let n=En(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma=n}}if(d(e)&&d(t)){let n=Dn(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma=n}}}function Zr(n,i,o,s,c=!1,f=new WeakSet){let h=new Map,_=new Set,v=[];o.forEach(o=>{if(er(o)){var y;let f=Z(i,o.path),p=o.path.slice(0,-1),m=F(o.path),h=r(f);if(Ye(m)&&!h&&!Ye(F(p))){let e=Q(n,p.concat(0));e&&r(e)&&(h=!0)}if(h&&!r(f)){let e=p.filter(e=>typeof e==`string`),t=J(i.items,``,{temporal:c});for(let e of o.path)t=t==null?void 0:t[e];if(t!==void 0){let n=Wt(e),r=K(t,s);for(let e of r.items)H(n,n,e,void 0);W(n),f=n}}let g;if(t(f))g=n;else if(h){g=n;let e=n,t=Q(e,p.concat(m-1)),r=Q(e,p.concat(m));m=r?e.items.indexOf(r):t?e.items.indexOf(t)+1:e.items.length}else g=$(n,o.path),a(g)?g=g.value:u(g)&&a(g.item)?g=g.item.value:u(g)&&d(g.item)&&(g=g.item);if(l(g)){let e=Q(n,p),t=Q(n,p.slice(0,-1));if(e&&a(e)&&t){let n=Lr(g,f,m);n!==0&&Fr(t,e,n)}}let v=(l(g)||d(g))&&g.loc.end.line>g.loc.start.line;v&&_.has(g)&&W(n);let b=l(g)||d(g)?(y=_r(n,g))==null?void 0:y.items:void 0;if(r(g)||l(g)||e(g)){if(l(g)){let e=En(g);u(f)&&(f.comma=e)}if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&e(g)&&t(f)){let e=ii(f,n,s);H(n,g,f,m);for(let t of e)H(n,n,t,void 0)}else{let i=m;if(e(g)&&a(f)){let e=g.items.findIndex(e=>t(e)||r(e));e!==-1&&(i=e)}H(n,g,f,i,void 0,b)}}else if(d(g)){let e=Dn(g);if(a(f)){let t=un(f);t.comma=e,H(n,g,t,void 0,void 0,b)}else H(n,g,f,void 0,void 0,b)}else if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&a(f)&&d(f.value)&&t(g))Mn([...g.key.item.value,...f.key.value])<s.inlineTableStart?ai(f,g,n,s):H(n,g,f);else if(s.inlineTableStart===0&&a(f)&&d(f.value)&&e(g))H(n,g,f,void 0,!0);else{let r=f;u(f)&&(t(g)||e(g))&&(r=f.item),H(n,g,r)}v&&_.add(g)}else if(tr(o)){let e=Q(n,o.path),r=Z(i,o.path);if(!e){ti(n,i,o,s,c,f);return}let d,p=Q(n,o.path.slice(0,-1)),m=oi(n,o.path);if(a(e)&&a(r))Xr(e.value,r.value),p&&Pr(p,e,e.value,r.value),d=e,e=e.value,r=r.value;else if(a(e)&&u(r)&&a(r.item))d=e,e=e.value,r=r.item.value;else if(u(e)&&a(e.item)&&a(r)){let t=e.item;Xr(t.value,r.value),d=t,e=t.value,r=r.value}else if(u(e)&&u(r)&&a(e.item)&&a(r.item))Xr(e.item.value,r.item.value),d=e.item,e=e.item.value,r=r.item.value;else if(t(e)){let t=J(i.items,``,{temporal:c});for(let e of o.path)t=t==null?void 0:t[e];if(t!==void 0){let r=e.key.item.value,i=r.slice(-1),a=r.slice(0,-1),c=$(n,o.path),l=K({[i[0]]:t},s).items[0];if(a.length>0){let t=Ht(a);H(n,t,l,0),St(n,c,e,t),f.add(t)}else St(n,c,e,l),f.add(l),ei(n,l);return}d=$(n,o.path)}else if(d=$(n,o.path),a(d)){let e=Z(n,o.path.slice(0,-1));a(e)&&l(e.value)&&(d=e.value)}if(m){let t=g(e.loc),n=g(r.loc).columns-t.columns;n!==0&&Ir(m.container,m.row,n)}St(n,d,e,r)}else if(X(o)){let e=Q(n,o.path);if(e){let t=$(n,o.path);if(a(t)&&(t=t.value),u(t)&&a(t.item)&&(t=t.item.value),u(t)&&d(t.item)&&(t=t.item),p(t)&&!t.items.includes(e)&&(t=n),br(n,t,e),r(e)){let t=e.key.item.value,r=o.path.slice(0,-1);!Q(n,r.concat(0))&&Q(i,r)&&h.set(t.join(`.`),t)}}else if(Q(n,o.path.concat(0))){let e;for(;e=Q(n,o.path.concat(0));)br(n,n,e);if(Q(i,o.path)){let e=o.path;h.set(e.join(`.`),e)}}else{let e=si(n,o.path);if(e.length>0)for(let t of e)br(n,n,t);else Z(n,o.path)}}else if(nr(o)){if(o.key!==void 0){v.push(o);return}let e=Q(n,o.path);if(e){m(e)&&(e=e.item),a(e)&&(e=e.value);let t=e.items[o.from];xr(n,e,t,o.to)}else{let e=Z(n,o.path.concat(o.from));U(n,n,e);let t=Q(n,o.path.concat(o.to));H(n,n,e,t?n.items.indexOf(t):n.items.length)}}else if(rr(o)){let e=Z(n,o.path.concat(o.from)),t=Z(i,o.path.concat(o.to));m(e)&&(e=e.item),m(t)&&(t=t.item),t.key.raw=Yr(e.key.raw,t.key.value),t.key.loc.end.column=t.key.loc.start.column+t.key.raw.length,St(n,e,e.key,t.key)}}),W(n);let y=!1;return pt(n,{InlineTable:e=>{if(_t(e)&&e.items.length>0){let t=e.items[e.items.length-1];e.loc.end.column=t.loc.end.column+1,vt(e),Ot(n,e,s.bracketSpacing),y=!0}}}),y&&W(n),ni(n),ri(n,h,s),Dr(n,v,f),n}function Qr(e){return e.items.findIndex(e=>t(e)||r(e))}function $r(e){let t=Qr(e);return t===-1?void 0:t}function ei(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=Qr(e);r===-1||r>n||(U(e,e,t),H(e,e,t,r))}function ti(e,t,n,r,i,a){let o=J(t.items,``,{temporal:i});for(let e of n.path)o=o==null?void 0:o[e];if(o===void 0)return;let s=o;for(let e=n.path.length-1;e>=0;e--)s={[n.path[e]]:s};let c=si(e,n.path);for(let t of c)U(e,e,t);let l=Hn(K(s,r).items,r),u=Array.from(je(l))[0],d=$r(e);d!==void 0&&W(e),H(e,e,u,d),a.add(u)}function ni(e){pt(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=$(e,[t.key.value[0]]);if(!r||!p(r))return;let i=t.loc.start.line,a=t.loc.end.line,o=r.items;for(let e=o.length-1;e>=0;e--){let t=o[e];if(!f(t))continue;let n=t.loc.start.line;n>=i&&n<=a&&o.splice(e,1)}}})}function ri(e,t,n){if(t.size!==0){for(let r of t.values())H(e,e,Kt(r,K({[r[r.length-1]]:[]},n).items[0].value),$r(e));W(e)}}function ii(e,t,n){let r=[],i=(e,r)=>{for(let o=e.items.length-1;o>=0;o--){let s=e.items[o];if(a(s)&&d(s.value)){let c=[...e.key.item.value,...s.key.value];if(Mn(c)<(n.inlineTableStart??1)&&n.inlineTableStart!==0){let n=Ht(c);for(let e of s.value.items)u(e)&&a(e.item)&&H(t,n,e.item,void 0);e.items.splice(o,1),jn(e),r.push(n),i(n,r)}}}};return i(e,r),r}function ai(e,t,n,r){let i=Ht([...t.key.item.value,...e.key.value]);if(d(e.value))for(let t of e.value.items)u(t)&&a(t.item)&&H(n,i,t.item,void 0);H(n,n,i,void 0),jn(t);let o=ii(i,n,r);for(let e of o)H(n,n,e,void 0)}function oi(e,t){for(let n=t.length-1;n>0;n--){let r=Q(e,t.slice(0,n));if(!r||!a(r)||!d(r.value))continue;let i=Q(e,t.slice(0,n-1));if(i&&p(i))return{container:i,row:r}}}function si(e,n){let i=[];for(let o of e.items){let e;a(o)?e=o.key.value:(t(o)||r(o))&&(e=o.key.item.value),e&&R(e.slice(0,n.length),n)&&i.push(o)}return i}function ci(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function li(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=ci(t.loc.end,r)<0,n=ci(t.loc.start,r)<0;if(e)i.push(t),a=t.loc.end;else if(n&&!e)break;else break}return{truncatedCst:i,lastEndPosition:a}}var ui=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:fn(e),r=mn(n);this._currentTomlString=r,this._cst=Array.from(je(r)),this._integersAsBigInt=(t==null?void 0:t.integersAsBigInt)??`asNeeded`,this._temporal=(t==null?void 0:t.temporal)??!1,this._format=G.autoDetectFormatWithCst(n,this._cst)}get toTomlString(){return this._format.leadingBom?`${this._currentTomlString}`:this._currentTomlString}get toJsObject(){let e=J(this._cst,this._currentTomlString,{integersAsBigInt:this._integersAsBigInt,temporal:this._temporal});return this._temporal?e:di(e)}get cst(){return this._cst}patch(e,t){let n=Tn(t,this._format),{tomlString:r,document:i}=Kr(this._cst,e,n);this._cst=i.items,this._format=n,this._currentTomlString=r}update(e){let t=mn(e);if(t===this._currentTomlString){this._format.leadingBom=pn(e);return}let n=this._currentTomlString.split(this._format.newLine),r=xn(t),i=t.split(r),a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;let o=0;if(a<n.length&&a<i.length){let e=n[a],t=i[a];for(let n=0;n<Math.max(e.length,t.length);n++)if(e[n]!==t[n]){o=n;break}}let s=a+1,{truncatedCst:c,lastEndPosition:l}=li(this._cst,s,o),u=l?l.line:1,d=l?l.column+1:0,f=i.slice(u-1);f.length>0&&d>0&&(f[0]=f[0].substring(d));let p=f.join(this._format.newLine);this._cst=Array.from(Me(c,p)),this._currentTomlString=t,this._format=G.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=mn(e);if(t===this._currentTomlString){this._format.leadingBom=pn(e);return}this._cst=Array.from(je(t)),this._currentTomlString=t,this._format=G.autoDetectFormatWithCst(e,this._cst)}};function di(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(di);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=di(r);return t}return e}function fi(e,t){let n=mn(typeof e==`string`?e:fn(e));return J(je(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function pi(e,t){let n=Tn(t,G.default()),r=Hn(K(e,n).items,n);return n.leadingBom?`${r}`:r}function mi(e,t){return new ui(e,t)}export{ue as LocalDate,M as LocalDateTime,de as LocalTime,N as OffsetDateTime,ui as TomlDocument,G as TomlFormat,fi as parse,mi as parseDocument,Hr as patch,pi as stringify};
|
|
37
|
+
`),i=t.end.line-t.start.line+1;if(r.length!==i)throw Error(`Mismatch between location and raw string, expected ${i} lines for "${n}"`);for(let n=t.start.line;n<=t.end.line;n++){let i=Hn(e,n),a=n===t.start.line,o=n===t.end.line,s=``;if(a){let e=i.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column,` `):e}let c=o?i.substring(t.end.column):``;e[n-1]=s+r[n-t.start.line]+c}}function Vn(e,t,n,r){let i=Hn(e,t),a=i.length<n?i.padEnd(n,` `):i.substring(0,n),o=i.substring(n+1);e[t-1]=a+r+o}function Hn(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function Un(e,t=`asNeeded`){let n=e.replace(/_/g,``),r=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){let e=n[0]===`+`||n[0]===`-`?n[0]:``;r=e+n.slice(+!!e).toLowerCase()}let i;try{i=BigInt(r)}catch{return Number(n)}return t===!0?i:t===!1||i>=BigInt(-(2**53-1))&&i<=BigInt(2**53-1)?Number(i):i}function Wn(e,t,n){for(let r of e.items){let e=r.item;if(e.value.type===`InlineTable`){let r=t.concat(e.key.value);n.add(Z(r)),Wn(e.value,r,n)}}}function Gn(e){var t,n,r,i,a,o;if((t=e.constructor)!=null&&(t=t.name)!=null&&(n=t.startsWith)!=null&&n.call(t,`Temporal.`)||((r=e.constructor)==null?void 0:r.name)===`PlainDate`||((i=e.constructor)==null?void 0:i.name)===`PlainTime`||((a=e.constructor)==null?void 0:a.name)===`PlainDateTime`||((o=e.constructor)==null?void 0:o.name)===`ZonedDateTime`)return e;let s=globalThis.Temporal;if(e instanceof de)return s.PlainDate.from(e.toISOString());if(e instanceof fe)return s.PlainTime.from(e.toISOString());if(e instanceof j)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof pe){let t=e.toISOString().replace(` `,`T`),n=t.match(/([+-]\d{2}:\d{2}|Z)$/),r=n?n[1]:`Z`,i=t.replace(/([+-]\d{2}:\d{2}|Z)$/,``),a=r===`Z`?`+00:00`:r;return s.ZonedDateTime.from(`${i}${r}[${a}]`)}return s.PlainDateTime.from(e.toISOString().replace(`Z`,``))}function X(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=Ye(),o=new Set,s=new Set,c=new Set,l=new Set,u=new Set,d=a,f=[],p={tables:o,table_arrays:s,defined:c,implicit_tables:l,inline_tables:u};for(let t of e)switch(t.type){case`Table`:m(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`TableArray`:h(t);for(let e of t.items)e.type===`KeyValue`&&g(e);break;case`KeyValue`:g(t);break}return a;function m(e){let n=e.key.item.value;try{qn(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=Z(n);o.add(r),c.add(r),d=Jn(a,n),f=n}function h(e){let n=e.key.item.value;try{qn(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=Z(n);s.add(r),c.add(r),d=Yn(a,n),f=n}function g(e){let n=e.key.value;try{qn(d,f,n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}if(n.length>1)for(let e=1;e<n.length;e++){let t=Z(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=Kn(e.value,{integersAsBigInt:r,temporal:i})}catch(n){let r=n;throw new C(t,e.value.loc.start,r.message)}if(e.value.type===`InlineTable`){let t=f.concat(n);u.add(Z(t)),Wn(e.value,t,u)}let o=n.length>1?Jn(d,n.slice(0,-1)):d;o[N(n)]=a,c.add(Z(f.concat(n)))}}function Kn(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=Ye(),i=new Set,a=new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=Kn(e.value,{integersAsBigInt:n,temporal:r}),c=Z(o);if(i.has(c))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=Z(o.slice(0,e));if(i.has(t))throw Error(`Key "${c}" conflicts with key: "${t}"`)}if(a.has(c)){let e=a.get(c);throw Error(`Key "${c}" conflicts with key: "${e}"`)}i.add(c);for(let e=1;e<o.length;e++){let t=Z(o.slice(0,e));a.has(t)||a.set(t,c)}let l=o.length>1?Jn(t,o.slice(0,-1)):t;l[N(o)]=s}),t;case`InlineArray`:return e.items.map(e=>Kn(e.item,{integersAsBigInt:n,temporal:r}));case`DateTime`:if(r){if(globalThis.Temporal===void 0)throw Error(`Temporal API is not available in this runtime. Set temporal: false or use a runtime with Temporal support.`);return Gn(e.value)}return e.value;case`String`:return e.value;case`Integer`:return Un(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function qn(e,t,n,r,i){let a=t.length>0?Z(t):``,o=Array(n.length),s=a;for(let e=0;e<n.length;e++)s=s?s+`.`+n[e]:n[e],o[e]=s;let c=o[n.length-1];if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(t))throw Error(`Cannot extend inline table at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.inline_tables.has(c))throw Error(`Cannot extend inline table at ${c}`);if(r===`Table`||r===`TableArray`)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.inline_tables.has(t))throw Error(`Cannot extend inline table at ${t}`)}if(r===`KeyValue`&&n.length>1)for(let e=1;e<n.length;e++){let t=o[e-1];if(i.table_arrays.has(t))throw Error(`Cannot traverse Array of Tables at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.implicit_tables.has(c))throw Error(`Implicit table already defined: ${c}`);if(r===`KeyValue`&&i.implicit_tables.has(c))throw Error(`Table already defined: ${c}`);if(r===`KeyValue`&&n.length>1)for(let e=1;e<=n.length;e++){let t=o[e-1];if(i.tables.has(t))throw Error(`Cannot extend explicit table ${t} with dotted keys`)}let l=0;for(let t of n){if(!lt(e,t))return;if(Zn(e[t]))throw Error(`Value already defined for ${o[l]}`);let r=o[l];if(Array.isArray(e[t])&&!i.table_arrays.has(r))throw Error(`Cannot add to static array at ${r}`);let a=l++<n.length-1;e=Array.isArray(e[t])&&a?N(e[t]):e[t]}let u=c;if(e&&r===`Table`&&i.defined.has(u)||e&&r===`KeyValue`&&n.length===1&&i.defined.has(u)&&!Zn(e))throw Error(`Table already defined: ${u}`);if(e&&r===`TableArray`&&!i.table_arrays.has(u))throw Error(`Cannot add Array of Tables to table at ${u}`)}function Jn(e,t){let n=Xn(e,t.slice(0,-1)),r=N(t);return n[r]||(n[r]=Ye()),n[r]}function Yn(e,t){let n=Xn(e,t.slice(0,-1)),r=N(t);n[r]||(n[r]=[]);let i=Ye();return n[N(t)].push(i),i}function Xn(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=Ye()),Array.isArray(e[t])?N(e[t]):e[t]),e)}function Zn(e){return typeof e!=`object`&&!tt(e)}function Z(e){return e.join(`.`)}function Qn(e){return e.type===`Add`}function $n(e){return e.type===`Edit`}function er(e){return e.type===`Remove`}function tr(e){return e.type===`Move`}function nr(e){return e.type===`Rename`}function rr(e,t,n=[],r={}){if(e===t||ut(e,t))return[];if(typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t)){let n=new Float64Array([e]),r=new Float64Array([t]),i=new DataView(n.buffer),a=new DataView(r.buffer);if((i.getUint32(4,!0)&2147483648)==(a.getUint32(4,!0)&2147483648))return[]}return Array.isArray(e)&&Array.isArray(t)?ar(e,t,n,r):F(e)&&F(t)?ir(e,t,n,r):[{type:`Edit`,path:n}]}function ir(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>L(e[t])),s=Object.keys(t),c=s.map(e=>L(t[e])),l=new Set(a),u=new Set(s),d=(e,t,n)=>{let r=new Map;return e.forEach((e,i)=>{if(n.has(e))return;let a=r.get(t[i]);a?a.push(e):r.set(t[i],[e])}),r},f=d(a,o,u),p=d(s,c,l),m=new Map,h=new Set;for(let[e,t]of f){let n=p.get(e);if(!n)continue;let r=Math.min(t.length,n.length);for(let e=0;e<r;e++)m.set(t[e],n[e]),h.add(n[e])}if(a.forEach(a=>{let o=n.concat(a);u.has(a)?dt(i,rr(e[a],t[a],o,r)):m.has(a)?i.push({type:`Rename`,path:n,from:a,to:m.get(a)}):i.push({type:`Remove`,path:o})}),s.forEach(e=>{!l.has(e)&&!h.has(e)&&i.push({type:`Add`,path:n.concat(e)})}),r.updateOrder){let e=[];for(let t of a)if(u.has(t))e.includes(t)||e.push(t);else if(m.has(t)){let n=m.get(t);e.includes(n)||e.push(n)}for(let t of s)e.includes(t)||e.push(t);s.forEach((t,r)=>{if(e[r]===t)return;let a=e.indexOf(t);i.push({type:`Move`,path:n,from:a,to:r,key:t}),e.splice(a,1),e.splice(r,0,t)})}return i}function ar(e,t,n=[],r={}){let i=[],a=e.map(L),o=t.map(L);o.forEach((s,c)=>{let l=c>=a.length;if(!l&&a[c]===s)return;let u=a.indexOf(s,c+1);if(!l&&u>-1){i.push({type:`Move`,path:n,from:u,to:c});let e=a.splice(u,1);a.splice(c,0,...e);return}let d=!o.includes(a[c]);if(!l&&d){dt(i,rr(e[c],t[c],n.concat(c),r)),a[c]=s;return}i.push({type:`Add`,path:n.concat(c)}),a.splice(c,0,s)});for(let e=o.length;e<a.length;e++)i.push({type:`Remove`,path:n.concat(e)});return i}function Q(n,i){if(!i.length)return u(n)&&a(n.item)?n.item:n;if(a(n))return Q(n.value,i);let o={},s;if(p(n)&&n.items.some((c,l)=>{try{let d=[];if(a(c))d=c.key.value;else if(t(c))d=c.key.item.value;else if(r(c)){d=c.key.item.value;let e=L(d);o[e]||(o[e]=0);let t=o[e]++;d=d.concat(t)}else u(c)&&a(c.item)?d=c.item.key.value:u(c)&&(d=[l]);if(d.length&&I(d,i.slice(0,d.length))){let t=i.slice(d.length);if(e(n)&&r(c)&&t.length>0){let e=c.key.item.value,i=n,a=i.items.findIndex((t,n)=>n>l&&r(t)&&I(t.key.item.value,e)),o=a===-1?i.items.length:a;s=or(c,t,e,i.items.slice(l+1,o))}else s=u(c)&&a(c.item)?i.length===d.length?c:Q(c.item.value,t):u(c)&&i.length>d.length?Q(c.item,t):Q(c,t);return!0}else if(a(c)&&d.length>i.length&&I(d.slice(0,i.length),i))return s=c,!0;else return!1}catch{return!1}}),!s)throw Error(`Node not found at ${i.join(`.`)}`);return s}function or(e,n,i,a){try{return Q(e,n)}catch{}let o={};for(let e of a){let a=[];if(t(e)){let t=e.key.item.value;t.length>i.length&&I(t.slice(0,i.length),i)&&(a=t.slice(i.length))}else if(r(e)){let t=e.key.item.value;if(t.length>i.length&&I(t.slice(0,i.length),i)){let e=t.slice(i.length),n=L(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&I(a,n.slice(0,a.length)))try{return Q(e,n.slice(a.length))}catch{}}throw Error(`Node not found at (aot scope) ${n.join(`.`)}`)}function $(e,t){try{return Q(e,t)}catch{}}function sr(e,t){let n=t,r;for(;n.length&&!r;)n=n.slice(0,-1),r=$(e,n);if(!r)throw Error(`Parent not found for ${t.join(`.`)}`);return r}const cr=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,lr=new RegExp(String.raw`^#\s*${cr}(?:\s*\.\s*${cr})*\s*=`),ur=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,dr=new RegExp(String.raw`^#\s*${cr}(?:\s*\.\s*${cr})*\s*=\s*${ur}\s*$`),fr=new RegExp(String.raw`^#\s*\[\[?\s*${cr}(?:\s*\.\s*${cr})*\s*\]\]?\s*$`);function pr(e){return dr.test(e.raw)||fr.test(e.raw)}function mr(e){let t=e.raw.indexOf(`=`);if(t<0)return!1;let n=!1,r=!1;for(let i=t+1;i<e.raw.length;i++){let t=e.raw[i];if(t===`\\`){i++;continue}if(!r&&t===`"`){n=!n;continue}if(!n&&t===`'`){r=!r;continue}if(!n&&!r&&t===`#`)return!0}return!1}function hr(e){return pr(e)?!0:lr.test(e.raw)?mr(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function gr(e){let t=e.raw.match(lr);if(!t)return;let n=t[0].replace(/^#\s*/,``).replace(/\s*=.*$/,``).trim(),r=n.indexOf(`.`);return r>=0&&(n=n.substring(0,r)),(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))&&(n=n.slice(1,-1)),n||void 0}function _r(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function vr(e){if(a(e))return e.key.value[0];if(t(e)||r(e))return e.key.item.value[0];if(u(e)&&a(e.item))return e.item.key.value[0]}function yr(e,t,n){let r=[],i=t,a,o=[],s=()=>{o.length&&(r.push({kind:`pinned`,items:o,startLine:o[0].loc.start.line,endLine:N(o).loc.end.line}),o=[])};for(let t of e){if(f(t)){if(t.loc.start.line<=i){a?(a.items.push(t),a.endLine=Math.max(a.endLine,t.loc.end.line)):r.push({kind:`pinned`,items:[t],startLine:t.loc.start.line,endLine:t.loc.end.line});continue}let e=o.length?N(o).loc.end.line:void 0;o.length&&t.loc.start.line===e+1||s(),o.push(t);continue}let e=[];if(o.length)if(N(o).loc.end.line+1===t.loc.start.line&&n(t)){let n=vr(t);if(n!==void 0){let e=-1;for(let t=o.length-1;t>=0;t--){let r=hr(o[t])?gr(o[t]):void 0;if(r!==void 0&&r!==n){e=t;break}}if(e>=0){let t=o.splice(0,e+1);r.push({kind:`pinned`,items:t,startLine:t[0].loc.start.line,endLine:N(t).loc.end.line})}}e=o,o=[]}else s();let c=[...e,t],l={kind:`member`,member:t,key:vr(t),items:c,startLine:c[0].loc.start.line,endLine:t.loc.end.line};r.push(l),a=l,i=t.loc.end.line}return s(),r}function br(t,n=()=>!0){let r=e(t)?0:t.key.loc.end.line;return yr(t.items,r,n)}function xr(e,t){let n=t.filter(t=>f(t)&&t.loc.start.line>=e.loc.start.line&&t.loc.start.line<=e.loc.end.line);return yr([...e.items,...n].sort((e,t)=>e.loc.start.line-t.loc.start.line||e.loc.start.column-t.loc.start.column),e.loc.start.line,()=>!0)}function Sr(e,n){function i(e,t){if(e===n)return t;if(a(e))return i(e.value,t);if(d(e)||l(e))for(let r of e.items){if(r===n)return t;let e=i(r.item,t);if(e)return e}}function o(e){for(let s of e.items){if(s===n)return e;if(a(s)){let t=i(s.value,e);if(t)return t}else if(t(s)||r(s)){let e=o(s);if(e)return e}}}return o(e)}function Cr(e){for(let n=0;n<e.items.length;n++){let i=e.items[n];if(!t(i)&&!r(i))continue;let a=e.items[n+1];if(!a)continue;let o=wr(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),H(i),n+=o.length}}function wr(e,t){let n=N(br(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(pr);if(!(!i||a))return r}function Tr(n,i,a){if(e(i)&&(t(a)||r(a))){let e=i.items.indexOf(a),o=e>0?i.items[e-1]:void 0;if(o&&(t(o)||r(o))){let e=wr(o,a);if(e)for(let t of e)V(n,o,t)}}if(e(i)||t(i)||r(i)){let e=br(i).find(e=>e.member===a);if(e){let t=e.items.indexOf(a);for(let r=0;r<=t;r++){let t=e.items[r];i.items.includes(t)&&V(n,i,t)}for(let n=t+1;n<e.items.length;n++){let t=e.items[n],r=i.items.indexOf(t);r<0||i.items.splice(r,1)}return}}if(_r(i)&&e(n)){let e=Sr(n,i);if(e){let t=xr(i,e.items).find(e=>e.member===a);if(t){let r=t.items.filter(e=>e!==a);for(let t of r){let n=e.items.indexOf(t);n<0||e.items.splice(n,1)}r.length&&(a.loc.start=t.items[0].loc.start,a.loc.end=N(t.items).loc.end),V(n,i,a,e.items),U(n);return}}}V(n,i,a)}function Er(t,n,r,i){if(_r(n)&&e(t)){let e=Sr(t,n);if(e){let a=xr(n,e.items),o=[],s,c;for(let t of a){if(t.kind!==`member`||!t.member)continue;let n=t.items.filter(e=>e!==t.member);if(t.member===r&&(s=b(r.loc.start),c=b(r.loc.end),n.length&&(r.loc.start=b(t.items[0].loc.start),r.loc.end=b(N(t.items).loc.end))),n.length){o.push({owner:t.member,ownerOriginalStart:b(t.member.loc.start),comments:n});for(let t of n){let n=e.items.indexOf(t);n>=0&&e.items.splice(n,1)}}}V(t,n,r,e.items),B(t,n,r,i,void 0,e.items),U(t);for(let{owner:t,ownerOriginalStart:n,comments:i}of o){let a;t===r?(a={lines:r.loc.start.line-n.line,columns:r.loc.start.column-n.column},r.loc.start={line:s.line+a.lines,column:s.column+a.columns},r.loc.end={line:c.line+a.lines,column:c.column+a.columns}):a={lines:t.loc.start.line-n.line,columns:t.loc.start.column-n.column};for(let t of i){W(t,a);let n=e.items.findIndex(e=>e.loc.start.line>t.loc.start.line);n===-1?e.items.push(t):e.items.splice(n,0,t)}}return}}V(t,n,r),B(t,n,r,i)}function Dr(e){let n=[];for(let i of e){if(i.kind===`pinned`){n.push({kind:`pinned`,isSection:!1,movable:!1,slots:[i],startLine:i.startLine,endLine:i.endLine,items:i.items});continue}let e=t(i.member)||r(i.member),a=n[n.length-1];if(a&&a.kind===`member`&&a.key===i.key){a.slots.push(i),a.endLine=i.endLine,a.items=a.items.concat(i.items);continue}n.push({kind:`member`,key:i.key,isSection:e,movable:!0,slots:[i],startLine:i.startLine,endLine:i.endLine,items:[...i.items]})}let i=new Map;for(let e of n)e.kind===`member`&&e.key!==void 0&&i.set(e.key,(i.get(e.key)??0)+1);for(let e of n)e.kind===`member`&&e.key!==void 0&&i.get(e.key)>1&&(e.movable=!1);return n}function Or(e,t){let n=[...e];for(let e of t){if(e.key===void 0)continue;let t=n.indexOf(e.key);if(t===-1)continue;let r=Math.max(0,Math.min(e.to,n.length-1));t!==r&&(n.splice(t,1),n.splice(r,0,e.key))}return n}function kr(e){return[...e.path,e.key].join(`.`)}function Ar(n,i){if(i.length===0)return n;let o;try{o=$(n,i)}catch{return}if(o&&(a(o)&&(o=o.value),o&&m(o)&&(o=o.item),o&&(e(o)||t(o)||r(o))))return o}function jr(t,n,r,i){let a=Dr(br(t,e=>r.has(e))),o=new Map;for(let e of a)e.kind===`member`&&e.movable&&e.key!==void 0&&o.set(e.key,e);let s=new Set(a.filter(e=>e.kind===`member`&&e.key!==void 0).map(e=>e.key));for(let e of n)e.key!==void 0&&s.has(e.key)&&!o.has(e.key)&&i.push(`"${kr(e)}" -- its entries are not contiguous in the document (e.g. the TOML spec's own "valid but discouraged" out-of-order table pattern), so reordering was skipped for it`);if(o.size===0)return;let c=0,l=a.filter(e=>e.kind===`member`).map(e=>e.movable?e.key:`\u0000anchor:${c++}`),u=n.filter(e=>e.key!==void 0&&o.has(e.key));if(u.length===0)return;let d=Or(l,u).filter(e=>o.has(e)),f=d.filter(e=>!o.get(e).isSection),p=d.filter(e=>o.get(e).isSection),m=!1;for(let e of d)if(o.get(e).isSection)m=!0;else if(m){i.push(`the requested order asked for a root key-value to be positioned after a section header, which TOML cannot represent -- each group (root key-values, section blocks) was reordered to match its own requested relative order instead`);break}let h=0,g=0,_=a.map(e=>{if(e.kind!==`member`||!e.movable)return e;let t=e.isSection?p[g++]:f[h++];return o.get(t)});if(_.every((e,t)=>e===a[t]))return;let v=e(t)?1:t.key.loc.end.line,y=a.map((e,t)=>t===0?e.startLine-v:e.startLine-a[t-1].endLine-1),b=v;for(let e=0;e<_.length;e++){let t=_[e],n=y[e],r=(e===0?b:b+1)+n-t.startLine;if(r!==0)for(let e of t.items)W(e,{lines:r,columns:0});b=t.endLine+r}let x=_.flatMap(e=>e.items),S=t.items;S.splice(0,S.length,...x),H(t)}function Mr(e,t,n){if(t.length===0)return;Cr(e);let r=[],i=new Map;for(let n of t){if(n.key===void 0)continue;let t=Ar(e,n.path);if(!t){r.push(`"${kr(n)}" -- unsupported location for reordering (e.g. a dotted-key implicit table, or an interior of an inline table/array-of-tables entry)`);continue}let a=i.get(t);a?a.push(n):i.set(t,[n])}for(let[e,t]of i)jr(e,t,n,r);if(r.length>0){let e=[...new Set(r)];console.warn(`toml-patch: updateOrder could not honor the requested position for ${e.length===1?`1 entry`:`${e.length} entries`}, left unchanged:\n`+e.map(e=>` - ${e}`).join(`
|
|
38
|
+
`))}H(e)}const Nr=new WeakMap,Pr=new WeakMap;function Fr(e,t){let n=e[t].loc.end.line;for(let r=t+1;r<e.length;r++){let t=e[r];if(f(t)&&t.loc.start.line===n)return t;if(!f(t)&&t.loc.start.line>n)return}}function Ir(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function Lr(e,t,n){Pr.has(e)||Pr.set(e,e.loc.start.column);let r=e.loc.start.column+n,i=Math.max(t,r)-r;i!==0&&(e.loc.start.column+=i,e.loc.end.column+=i)}function Rr(e,t){Pr.set(t,t.loc.start.column),Nr.set(t,t.loc.start.column-e.loc.end.column)}function zr(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=Fr(i,a);if(!o||n.loc.start.line!==n.loc.end.line||r.loc.start.line!==r.loc.end.line)return;let s=o.loc.start.column,c=o.loc.start.line,l=[Ir(i,a,-1),Ir(i,a,1)],u;for(let e of l){if(e==null)continue;let t=Fr(i,e);if(t&&Math.abs(t.loc.start.line-c)===1&&t.loc.start.column===s){u=t.loc.start.column;break}}if(u==null)return;let d=g(n.loc),f=g(r.loc).columns-d.columns;Lr(o,u,f)}function Br(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Fr(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[Ir(r,i,-1),Ir(r,i,1)];for(let e of c){if(e==null)continue;let t=Fr(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){Lr(a,t.loc.start.column,n);return}}}function Vr(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Fr(r,i);a&&Rr(t,a)}function Hr(e,t,n){if(!l(e)&&!d(e))return 0;let r=g(t.loc),i=n>0,a=n<e.items.length,o=n===e.items.length,s=u(t)?t.comma:!1,c=i&&s&&!a&&o;return r.columns+(i||a?2:0)+(s?1+(c?-1:0):0)}function Ur(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&Ur(i,n)}return n}function Wr(e,n=new Set){for(let i of e.items){if(a(i)&&d(i.value)&&i.loc.start.line===i.loc.end.line){n.add(i.loc.end.line);continue}(t(i)||r(i))&&Wr(i,n)}return n}function Gr(e){for(let n of e.items)(t(n)||r(n))&&Gr(n);let n=e.loc.end.line,i=e.loc.end.column,a=(e,t)=>{(e>n||e===n&&t>i)&&(n=e,i=t)};(t(e)||r(e))&&a(e.key.loc.end.line,e.key.loc.end.column);for(let t of e.items)a(t.loc.end.line,t.loc.end.column);e.loc.end.line=n,e.loc.end.column=i}function Kr(e,t,n){let r=n.newLine,i=t.match(/(?:\r\n|\n)+$/u),a=i?i[0]:``,o=a?t.slice(0,-a.length):t,s=o.length?o.split(r):[],c=Wr(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=Ur(e).filter(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n);return r.trim().length>0&&/\s{2,}$/u.test(r)}).sort((e,t)=>e.loc.start.line-t.loc.start.line),d=[],f=[];for(let e of u){let t=f[f.length-1];!t||e.loc.start.line===t.loc.start.line+1?f.push(e):(f.length>0&&d.push(f),f=[e])}f.length>0&&d.push(f);for(let e of d){if(e.length<2)continue;let t=Pr.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=Pr.get(t)??t.loc.start.column;n.set(e,(n.get(e)||0)+1)}let r=1;for(let[e,i]of n)i>r&&(r=i,t=e);let i=Math.max(...e.map(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e);return t.slice(0,n).trimEnd().length})),a=Math.min(...e.map(e=>{let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n).trimEnd();return Math.max(1,n-r.length)})),o=e.filter(e=>Nr.has(e)),u=e.some(e=>!c.has(e.loc.start.line));if(o.length>0&&u){let t=Math.min(...e.map(e=>{if(Nr.has(e))return Nr.get(e)||1;let t=s[e.loc.start.line-1]||``,n=l(t,e),r=t.slice(0,n).trimEnd();return Math.max(1,n-r.length)}));a=Math.min(a,t)}if(t<i+1){let e=i+a;t=Math.max(t,e)}for(let n of e){let e=n.loc.start.line-1,r=s[e]||``,i=l(r,n),a=r.slice(0,i).trimEnd(),o=Math.max(t,a.length+1);i!==o&&(s[e]=a+` `.repeat(o-a.length)+n.raw),n.loc.start.column!==o&&(n.loc.start.column=o,n.loc.end.column=o+n.raw.length)}}return Gr(e),s.join(r)+a}function qr(e,t,n){let r=Array.from(Ne(pn(e))),i=K(n,q.autoDetectFormatWithCst(e,r)),a=Qr(r,t,i).tomlString;return i.leadingBom?`${a}`:a}function Jr(e,t=new WeakSet){if(typeof e!=`object`||!e)return!1;if(P(e))return!0;if(t.has(e))return!1;t.add(e);for(let n of Object.values(e))if(Jr(n,t))return!0;return!1}function Yr(e){let t=new WeakSet,n=e=>{t.add(e)};return ht(e,{Document:n,Table:n,TableKey:n,TableArray:n,TableArrayKey:n,KeyValue:n,Key:n,String:n,Integer:n,Float:n,Boolean:n,DateTime:n,InlineArray:n,InlineItem:n,InlineTable:n,Comment:n}),t}function Xr(e,t,n,r){if(!F(t))return t;let i=X(J(e,K({...n,inlineTableStart:0},n)).items,``,{temporal:r});if(!F(i))return t;let a={};for(let e of Object.keys(i))Object.prototype.hasOwnProperty.call(t,e)&&(a[e]=t[e]);for(let e of Object.keys(t))Object.prototype.hasOwnProperty.call(a,e)||(a[e]=t[e]);return a}function Zr(e){let n=e.items;for(let e=0;e<n.length;e++){let i=n[e];if(!((t(i)||r(i))&&p(i)))continue;let a=i.items,o=a.length;for(;o>0&&f(a[o-1]);)o--;if(o<a.length){let t=n[e+1];if(t&&r(t)){let e=i.key.item.value,r=t.key.item.value;if(I(e,r.slice(0,e.length))){let e=a.splice(o),r=n.indexOf(t);for(let t of[...e].reverse())n.splice(r,0,t);H(i)}}}}}function Qr(e,t,n){let r=[...e],i=Jr(t),a=1,o=0;for(let e of r){let t=e.loc.end;(t.line>a||t.line===a&&t.column>o)&&(a=t.line,o=t.column)}let s=X(r,``,{temporal:i}),c={type:`Document`,loc:{start:{line:1,column:0},end:{line:a,column:o}},items:r},l=n.inlineTableStart!=null&&n.inlineTableStart>1?1:n.inlineTableStart,u=K({...n,inlineTableStart:l},n),d=J(t,u),f=X(d.items,``,{temporal:i}),p=n.updateOrder?Xr(t,f,u,i):f,m=$r(ei(c,p,rr(s,p,[],{updateOrder:n.updateOrder})));if(m.length===0)return{tomlString:Bn(r,n),document:c};let h=ri(c,d,m,n,i,Yr(c),t);return{tomlString:Kr(h,Bn(h.items,n),n),document:h}}function $r(e){for(let t=0;t<e.length;t++){let n=e[t];if(er(n)){let r=t+1;for(;r<e.length;){let i=e[r];if(!er(i)){r++;continue}let a=N(n.path),o=N(i.path),s=n.path.slice(0,-1),c=i.path.slice(0,-1);if(typeof a==`number`&&typeof o==`number`&&I(s,c)&&o>a){e.splice(r,1),e.splice(t,0,i),t=-1;break}r++}}}return e}function ei(e,t,n){let i=new Set,a=[],o=new Map;for(let e of n){if(!er(e)&&!Qn(e))continue;let t=e.path.slice(0,-1);if(t.length===0)continue;let n=JSON.stringify(t),r=o.get(n);r||(r={path:t,removes:[],adds:[]},o.set(n,r)),(er(e)?r.removes:r.adds).push(e)}for(let t of o.values())t.removes.length!==0&&t.adds.length!==0&&($(e,t.path)||(t.removes.forEach(e=>i.add(e)),t.adds.forEach(e=>i.add(e)),a.push({type:`Edit`,path:t.path})));let s=new Map;for(let t of n){if(i.has(t)||!$n(t)&&!Qn(t)&&!er(t)||typeof N(t.path)!=`number`)continue;let n=t.path.slice(0,-1);if(n.length===0)continue;let a=$(e,n.concat(0));!a||!r(a)||s.set(JSON.stringify(n),n)}for(let e of s.values()){let r=t;for(let t of e)r=r==null?void 0:r[t];if(Array.isArray(r)&&!r.every(e=>typeof e==`object`&&!!e&&!Array.isArray(e))){for(let t of n)i.has(t)||!$n(t)&&!Qn(t)&&!er(t)||t.path.length===e.length+1&&I(t.path.slice(0,-1),e)&&i.add(t);a.push({type:`Edit`,path:e})}}if(i.size===0)return n;let c=n.filter(e=>!i.has(e));return c.push(...a),c}function ti(e,t){return t.map(t=>T.test(t)?t:`"${Bt(t,e,`singleline-basic`)}"`).join(`.`)}function ni(e,t){if(o(e)&&o(t)){let n=Yt(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(c(e)&&c(t)){let n=e.raw,r=t.value;if(P(r)){let e=rt(r);if(n.includes(` `)&&e.includes(`T`)&&(e=e.replace(`T`,` `)),/(?:\+00:00|-00:00)/.test(n)&&e.endsWith(`Z`)){let t=n.match(/([+-]00:00)/)[1];e=e.replace(/Z$/,t)}t.raw=e,t.loc.end.column=t.loc.start.column+t.raw.length}else{let e=ue.createDateWithOriginalFormat(r,n);t.value=e,t.raw=e.toISOString(),t.loc.end.column=t.loc.start.column+t.raw.length}}if(s(e)&&s(t)&&Number.isNaN(e.value)&&Number.isNaN(t.value)){let n=e,r=t;n.nanSign&&(r.nanSign=`+`,r.raw=`+nan`)}if(l(e)&&l(t)){let n=wn(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma=n}}if(d(e)&&d(t)){let n=Tn(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma=n}}}function ri(n,i,o,s,c=!1,h=new WeakSet,_=void 0){let v=new Map,y=new Set;function b(e){let t=n.items,r=t.indexOf(e);if(r>0){let n=t[r-1];f(n)&&n.loc.end.line+1===e.loc.start.line&&y.add(e)}}let x=new Set,S=[];o.forEach(o=>{if(Qn(o)){var C;let f=Q(i,o.path),p=o.path.slice(0,-1),m=N(o.path),h=r(f);if(Ze(m)&&!h&&!Ze(N(p))){let e=$(n,p.concat(0));e&&r(e)&&(h=!0)}if(h&&Ze(m)&&!Ze(N(p))){let e=$(n,p),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=X(i.items,``,{temporal:c});for(let t of o.path)e=e==null?void 0:e[t];let r=K({...s,inlineTableStart:0},s),l=e===void 0?void 0:J({tmp:e},r),p=l==null?void 0:l.items[0];if(p&&a(p)&&(f=ln(p.value),h=!1,u(f)&&d(f.item)&&f.item.items.length>0)){let e=f.item;if(!(e.items[0].loc.start.column-e.loc.start.column>1)){let r=t.items.map(e=>e.item).find(e=>d(e)&&e.items.length>0);r&&r.items[0].loc.start.column-r.loc.start.column>1&&kt(n,e,!0)}}}}if(h&&!r(f)){let e=p.filter(e=>typeof e==`string`),t=X(i.items,``,{temporal:c});for(let e of o.path)t=t==null?void 0:t[e];if(t!==void 0){let n=Ut(e),r=J(t,s);for(let e of r.items)B(n,n,e,void 0);U(n),f=n}}let g;if(t(f))g=n;else if(h){g=n;let e=n,t=$(e,p.concat(m-1)),r=$(e,p.concat(m));m=r?e.items.indexOf(r):t?e.items.indexOf(t)+1:e.items.length}else g=sr(n,o.path),a(g)?g=g.value:u(g)&&a(g.item)?g=g.item.value:(u(g)&&d(g.item)||u(g)&&l(g.item))&&(g=g.item);if(l(g)){let e=$(n,p),t=$(n,p.slice(0,-1));if(e&&a(e)&&t){let n=Hr(g,f,m);n!==0&&Br(t,e,n)}}let _=(l(g)||d(g))&&g.loc.end.line>g.loc.start.line;_&&x.has(g)&&U(n);let v=l(g)||d(g)?(C=Sr(n,g))==null?void 0:C.items:void 0;if(r(g)||l(g)||e(g)){if(l(g)){let e=wn(g);if(u(f)){f.comma=e;let t=f,n=d(t.item)?t.item:void 0,r=n&&n.items.length>0?g.items.map(e=>e.item).find(e=>e!==t.item&&d(e)):void 0;if(n&&r){let e=Tn(r);if(e!==Tn(n)){let n=X(i.items,``,{temporal:c});for(let e of o.path)n=n==null?void 0:n[e];let r=K({...s,inlineTableStart:0,trailingComma:e},s),l=n===void 0?void 0:J({tmp:n},r).items[0];if(l&&a(l)){let e=ln(l.value);e.comma=t.comma,f=e}}}}}if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&e(g)&&t(f)){let e=pi(f,n,s);B(n,g,f,m);for(let t of e)B(n,n,t,void 0)}else{let i=m;if(e(g)&&a(f)){let e=g.items.findIndex(e=>t(e)||r(e));e!==-1&&(i=e)}let o=f;u(f)&&(r(g)||e(g))&&(o=f.item),B(n,g,o,i,void 0,v)}}else if(d(g)){let e=Tn(g);if(a(f)){let t=ln(f);t.comma=e,B(n,g,t,void 0,void 0,v)}else B(n,g,f,void 0,void 0,v)}else if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&a(f)&&d(f.value)&&t(g))An([...g.key.item.value,...f.key.value])<s.inlineTableStart?mi(f,g,n,s):B(n,g,f);else if(s.inlineTableStart===0&&a(f)&&d(f.value)&&e(g))B(n,g,f,void 0,!0);else{let i=f;u(f)&&(t(g)||r(g)||e(g))&&(i=f.item),B(n,g,i)}_&&x.add(g)}else if($n(o)){let e=$(n,o.path),r=Q(i,o.path);if(!e){si(n,i,o,s,c,h,y);return}let d,f=$(n,o.path.slice(0,-1)),p=hi(n,o.path);if(a(e)&&a(r)){if(e.key.value.length>1){let t=0,n=Math.min(o.path.length,e.key.value.length);for(let r=1;r<=n;r++)I(o.path.slice(o.path.length-r),e.key.value.slice(0,r))&&(t=r);if(t>0&&t<e.key.value.length){e.key.value=e.key.value.slice(0,t),e.key.raw=Jt(e.key.value).raw;let n=e.key.loc.end.column,r=e.key.loc.start.column+e.key.raw.length,i=r-n;e.key.loc.end.column=r,e.equals+=i,e.value.loc.start.column+=i,e.value.loc.end.line===e.value.loc.start.line&&(e.value.loc.end.column+=i),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=i)}}ni(e.value,r.value),f&&zr(f,e,e.value,r.value),d=e,e=e.value,r=r.value}else if(a(e)&&u(r)&&a(r.item)){if(e.key.value.length>1){let t=0,n=Math.min(o.path.length,e.key.value.length);for(let r=1;r<=n;r++)I(o.path.slice(o.path.length-r),e.key.value.slice(0,r))&&(t=r);if(t>0&&t<e.key.value.length){e.key.value=e.key.value.slice(0,t),e.key.raw=Jt(e.key.value).raw;let n=e.key.loc.end.column,r=e.key.loc.start.column+e.key.raw.length,i=r-n;e.key.loc.end.column=r,e.equals+=i,e.value.loc.start.column+=i,e.value.loc.end.line===e.value.loc.start.line&&(e.value.loc.end.column+=i),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=i)}}d=e,e=e.value,r=r.item.value}else if(u(e)&&a(e.item)&&a(r)){let t=e.item;ni(t.value,r.value),d=t,e=t.value,r=r.value}else if(u(e)&&u(r)&&a(e.item)&&a(r.item))ni(e.item.value,r.item.value),d=e.item,e=e.item.value,r=r.item.value;else if(t(e)){let t=X(i.items,``,{temporal:c});for(let e of o.path)t=t==null?void 0:t[e];if(t!==void 0){let r=e.key.item.value,i=r.slice(-1),a=r.slice(0,-1),c=sr(n,o.path),l=J({[i[0]]:t},s).items[0];if(a.length>0){let t=G(a);y.add(t),B(n,t,l,0),wt(n,c,e,t),h.add(t)}else wt(n,c,e,l),h.add(l),oi(n,l);return}d=sr(n,o.path)}else if(d=sr(n,o.path),a(d)){let e=Q(n,o.path.slice(0,-1));a(e)&&l(e.value)&&(d=e.value)}if(p){let t=g(e.loc),n=g(r.loc).columns-t.columns;n!==0&&Vr(p.container,p.row,n)}wt(n,d,e,r)}else if(er(o)){let s=$(n,o.path);if(s){let c=sr(n,o.path);a(c)&&(c=c.value),u(c)&&a(c.item)&&(c=c.item.value),u(c)&&d(c.item)&&(c=c.item),p(c)&&!c.items.includes(s)&&(c=n);let l=!1;if(o.path.length>1&&t(s)&&_!==void 0){let e=o.path.slice(0,-1);if(gi(n,e).filter(e=>e!==s).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(F(t)&&Object.keys(t).length===0){let t=s;for(;t.items.length>0;)V(n,t,N(t.items));let r=t.key,i=m(r)?r.item:r;i.value=e,i.raw=ti(i.raw,i.value),i.loc.end.column=i.loc.start.column+i.raw.length,r.loc.end.column=r.loc.start.column+i.raw.length+2,t.loc.end.line=r.loc.end.line,t.loc.end.column=r.loc.end.column,b(t),l=!0}}}let f=e(c)&&p(c)?c.items.indexOf(s):-1;if(l||Tr(n,c,s),!l&&o.path.length>1&&(t(s)||r(s))&&_!==void 0){let e=o.path.slice(0,-1);if(gi(n,e).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(F(t)&&Object.keys(t).length===0){let t=G(e);y.add(t),B(n,n,t,f>=0?f:n.items.length)}}}if(r(s)){let e=s.key.item.value,t=o.path.slice(0,-1);!$(n,t.concat(0))&&$(i,t)&&v.set(e.join(`.`),e)}}else{let e=$(n,o.path.concat(0));if(e){let t=n.items.indexOf(e),a=!1;if(o.path.length>1&&_!==void 0){let t=o.path.slice(0,-1);if(gi(n,t).filter(e=>!(r(e)&&I(e.key.item.value,o.path))).length===0){let r=_;for(let e of t)r=r==null?void 0:r[e];if(F(r)&&Object.keys(r).length===0){let r=e,i=r.key;for(;r.items.length>0;)Tr(n,r,N(r.items));r.type=`Table`,i.type=`TableKey`;let o=m(i)?i.item:i;o.value=t,o.raw=ti(o.raw,o.value),o.loc.end.column=o.loc.start.column+o.raw.length,i.loc.end.column=i.loc.start.column+o.raw.length+2,r.loc.end.line=i.loc.end.line,r.loc.end.column=i.loc.end.column,b(r),a=!0}}}let s;for(;s=$(n,o.path.concat(0));)Tr(n,n,s);if($(i,o.path)){let e=o.path;v.set(e.join(`.`),e)}if(!a&&o.path.length>1&&_!==void 0){let e=o.path.slice(0,-1);if(gi(n,e).length===0){let r=_;for(let t of e)r=r==null?void 0:r[t];if(F(r)&&Object.keys(r).length===0){let r=G(e);y.add(r),B(n,n,r,t>=0?t:n.items.length)}}}}else{let e=gi(n,o.path);if(e.length>0)for(let t of e)Tr(n,n,t);else Q(n,o.path)}}}else if(tr(o)){if(o.key!==void 0){S.push(o);return}let e=$(n,o.path);if(e){m(e)&&(e=e.item),a(e)&&(e=e.value);let t=e.items[o.from];Er(n,e,t,o.to)}else{Zr(n);let e=Q(n,o.path.concat(o.from)),i=br(n).find(t=>t.member===e),a=i?[...i.items]:[e],s=a.map(e=>({startLine:e.loc.start.line,endLine:e.loc.end.line})),c=n.items.indexOf(i?i.items[0]:e),l=s[s.length-1].endLine,u;for(let e=0;e<n.items.length;e++){let t=n.items[e];if(t.loc.start.line>l){u=t.loc.start.line-l;break}}if(u===void 0&&c>0){let e=n.items[c-1];u=s[0].startLine-e.loc.end.line}let d=i?i.items.indexOf(e):0;for(let e=0;e<=d;e++)n.items.includes(a[e])&&V(n,n,a[e]);for(let e=d+1;e<a.length;e++){let t=n.items.indexOf(a[e]);t>=0&&n.items.splice(t,1)}let p=$(n,o.path.concat(o.to)),m,h=!1,g=i&&i.items[0]!==e&&f(i.items[0]);if(p){let e=br(n).find(e=>e.member===p);h=!!(e&&e.items[0]!==p&&f(e.items[0])),m=h&&g?n.items.indexOf(e.items[0]):n.items.indexOf(p)}else m=n.items.length;let _=m>0?n.items[m-1].loc.end.line:0,v=m<n.items.length?n.items[m].loc.start.line:void 0,y=h&&g,b=m;for(let e=0;e<a.length;e++){let i=a[e],o;if((y||g&&m>0&&m<n.items.length)&&b>0){let n=e===0?_:s[e-1].endLine,a=e===0&&v!==void 0?v-_:s[e].startLine-n;a!==(t(i)||r(i)?2:1)&&(o=a)}B(n,n,i,b,void 0,void 0,o),b++}if(u!==void 0){U(n);let e=a[a.length-1],t=n.items.indexOf(e)+1;if(t<n.items.length){let r=n.items[t].loc.start.line-e.loc.end.line,i=u-r;if(i!==0)for(let e=t;e<n.items.length;e++)W(n.items[e],{lines:i,columns:0})}}}}else if(nr(o)){let e=o.path.concat(o.from),s=$(n,e);if(!s){let i=gi(n,e);if(i.length===1&&(t(i[0])||r(i[0]))){let t=i[0].key,n=m(t)?t.item:t,r=e.length-1;n.value[r]=o.to,n.raw=ti(n.raw,n.value),n.loc.end.column=n.loc.start.column+n.raw.length;return}}s||=Q(n,e);let c=Q(i,o.path.concat(o.to));m(s)&&(s=s.item),m(c)&&(c=c.item);let l=s.key,u=c.key,d=m(l)?l.item:l,f=m(u)?u.item:u;if(d.value.length!==f.value.length){let e=o.path.concat(o.from);if((t(s)||r(s))&&a(c)&&I(d.value.slice(0,e.length),e)){let t=e.length-1;d.value[t]=o.to,d.raw=ti(d.raw,d.value),d.loc.end.column=d.loc.start.column+d.raw.length;return}throw Error(`Cannot rename "${d.raw}" to "${f.raw}": the replacement key has ${f.value.length} segment(s) where the existing key has ${d.value.length}, so one cannot be substituted for the other.`)}f.raw=ti(d.raw,f.value),f.loc.end.column=f.loc.start.column+f.raw.length,wt(n,m(l)?l:s,d,f)}}),U(n);for(let e=1;e<n.items.length;e++){let r=n.items[e-1],i=n.items[e];if(f(r)&&t(i)&&y.has(i)){let e=i.loc.start.line-r.loc.end.line-1;e>0&&W(i,{lines:-e,columns:0})}}let C=!1;return ht(n,{InlineTable:e=>{yt(e)&&(ci(e),bt(e),kt(n,e,s.bracketSpacing),C=!0)},InlineArray:e=>{yt(e)&&(ci(e),bt(e),kt(n,e,s.bracketSpacing),C=!0)}}),C&&(U(n),li(n)),di(n),fi(n,v,s),Mr(n,S,h),n}function ii(e){return e.items.findIndex(e=>t(e)||r(e))}function ai(e){let t=ii(e);return t===-1?void 0:t}function oi(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=ii(e);r===-1||r>n||(V(e,e,t),B(e,e,t,r))}function si(e,n,r,i,a,o,s){let c=X(n.items,``,{temporal:a});for(let e of r.path)c=c==null?void 0:c[e];if(c===void 0)return;let l=c;for(let e=r.path.length-1;e>=0;e--)l={[r.path[e]]:l};let u=gi(e,r.path);for(let t of u)V(e,e,t);let d=Bn(J(l,i).items,i),f=Array.from(Ne(d))[0],p=ai(e);p!==void 0&&U(e),B(e,e,f,p),t(f)&&s.add(f),o.add(f)}function ci(e){if(e.items.length>0){let t=e.items[e.items.length-1];e.loc.end.column=t.loc.end.column+1}else e.loc.end.column=e.loc.start.column+2}function li(e){ht(e,{InlineTable:{exit:e=>{if(e.items.length===0||e.loc.end.line!==e.loc.start.line)return;let t=e.items[e.items.length-1],n=ui(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}},InlineArray:{exit:e=>{if(e.items.length===0||e.loc.end.line!==e.loc.start.line)return;let t=e.items[e.items.length-1],n=ui(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function ui(e){if(!u(e))return e.loc.end.column;if(a(e.item)){let t=e.item.value;if(d(t)||l(t))return t.loc.end.column}return d(e.item)||l(e.item)?e.item.loc.end.column:e.loc.end.column}function di(e){ht(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=sr(e,[t.key.value[0]]);if(!r||!p(r))return;let i=t.loc.start.line,a=t.loc.end.line,o=r.items;for(let e=o.length-1;e>=0;e--){let t=o[e];if(!f(t))continue;let n=t.loc.start.line;n>=i&&n<=a&&o.splice(e,1)}}})}function fi(e,t,n){if(t.size!==0){for(let r of t.values())B(e,e,Gt(r,J({[r[r.length-1]]:[]},n).items[0].value),ai(e));U(e)}}function pi(e,t,n){let r=[],i=(e,r)=>{for(let o=e.items.length-1;o>=0;o--){let s=e.items[o];if(a(s)&&d(s.value)){let c=[...e.key.item.value,...s.key.value];if(An(c)<(n.inlineTableStart??1)&&n.inlineTableStart!==0){let n=G(c);for(let e of s.value.items)u(e)&&a(e.item)&&B(t,n,e.item,void 0);e.items.splice(o,1),kn(e),r.push(n),i(n,r)}}}};return i(e,r),r}function mi(e,t,n,r){let i=G([...t.key.item.value,...e.key.value]);if(d(e.value))for(let t of e.value.items)u(t)&&a(t.item)&&B(n,i,t.item,void 0);B(n,n,i,void 0),kn(t);let o=pi(i,n,r);for(let e of o)B(n,n,e,void 0)}function hi(e,t){for(let n=t.length-1;n>0;n--){let r=$(e,t.slice(0,n));if(!r||!a(r)||!d(r.value))continue;let i=$(e,t.slice(0,n-1));if(i&&p(i))return{container:i,row:r}}}function gi(e,n){let i=[];for(let o of e.items){let e;a(o)?e=o.key.value:(t(o)||r(o))&&(e=o.key.item.value),e&&I(e.slice(0,n.length),n)&&i.push(o)}return i}function _i(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function vi(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=_i(t.loc.end,r)<0,n=_i(t.loc.start,r)<0;if(e)i.push(t),a=t.loc.end;else if(n&&!e)break;else break}return{truncatedCst:i,lastEndPosition:a}}var yi=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:dn(e),r=pn(n);this._currentTomlString=r,this._cst=Array.from(Ne(r)),this._integersAsBigInt=(t==null?void 0:t.integersAsBigInt)??`asNeeded`,this._temporal=(t==null?void 0:t.temporal)??!1,this._format=q.autoDetectFormatWithCst(n,this._cst)}get toTomlString(){return this._format.leadingBom?`${this._currentTomlString}`:this._currentTomlString}get toJsObject(){let e=X(this._cst,this._currentTomlString,{integersAsBigInt:this._integersAsBigInt,temporal:this._temporal});return this._temporal?e:bi(e)}get cst(){return this._cst}patch(e,t){let n=K(t,this._format),{tomlString:r,document:i}=Qr(this._cst,e,n);this._cst=i.items,this._format=n,this._currentTomlString=r}update(e){let t=pn(e);if(t===this._currentTomlString){this._format.leadingBom=fn(e);return}let n=this._currentTomlString.split(this._format.newLine),r=bn(t),i=t.split(r),a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;let o=0;if(a<n.length&&a<i.length){let e=n[a],t=i[a];for(let n=0;n<Math.max(e.length,t.length);n++)if(e[n]!==t[n]){o=n;break}}let s=a+1,{truncatedCst:c,lastEndPosition:l}=vi(this._cst,s,o),u=l?l.line:1,d=l?l.column+1:0,f=i.slice(u-1);f.length>0&&d>0&&(f[0]=f[0].substring(d));let p=f.join(this._format.newLine);this._cst=Array.from(Pe(c,p)),this._currentTomlString=t,this._format=q.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=pn(e);if(t===this._currentTomlString){this._format.leadingBom=fn(e);return}this._cst=Array.from(Ne(t)),this._currentTomlString=t,this._format=q.autoDetectFormatWithCst(e,this._cst)}};function bi(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(bi);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=bi(r);return t}return e}function xi(e,t){let n=pn(typeof e==`string`?e:dn(e));return X(Ne(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function Si(e,t){let n=K(t,q.default()),r=Bn(J(e,n).items,n);return n.leadingBom?`${r}`:r}function Ci(e,t){return new yi(e,t)}export{de as LocalDate,j as LocalDateTime,fe as LocalTime,pe as OffsetDateTime,yi as TomlDocument,q as TomlFormat,xi as parse,Ci as parseDocument,qr as patch,Si as stringify};
|