@decimalturn/toml-patch 3.0.1 → 3.0.3
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 +50 -0
- package/README.md +3 -1
- package/dist/toml-patch.d.ts +1 -0
- package/dist/toml-patch.js +25 -20
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.0.3] - 2026-08-21
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Stringify: Fix extra blank lines when extracting nested inline tables via `inlineTableStart` ([#281])
|
|
15
|
+
- Patching: Fix extra blank lines after tables emptied ([#281])
|
|
16
|
+
- Patching: Fix dotted-key truncation and whitespace bugs ([#282])
|
|
17
|
+
- Patching: Fixing 54+ patching bugs discovered with fuzzing harness (2M seeds) ([#288])
|
|
18
|
+
- Patching: preserve dotted-key formatting when appending array-of-tables entries after nested sub-tables ([#289])
|
|
19
|
+
- Patching: reorder dotted-key members inside array-of-tables entries when `updateOrder` is enabled ([#290])
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Improve stringification performance ([#280])
|
|
23
|
+
|
|
24
|
+
## [3.0.2] - 2026-08-09
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- 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])
|
|
29
|
+
- 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])
|
|
30
|
+
- Patching: match sibling bracket spacing when adding an inline table to an inline array (`{ z = 0 }` beside `{ a = 1 }`). ([#270])
|
|
31
|
+
- 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])
|
|
32
|
+
- 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])
|
|
33
|
+
- 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])
|
|
34
|
+
- 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])
|
|
35
|
+
- Patching: avoid extra blank line when the first array-of-tables entry is converted to a table in-place during implicit parent materialisation. ([#271])
|
|
36
|
+
- 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])
|
|
37
|
+
- 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])
|
|
38
|
+
- Patching: adding a key to a nested table array element (e.g. `[[a.b]]`) no longer throws "Incompatible child type 'InlineItem'". ([#274])
|
|
39
|
+
- Patching: Move entire AOT entry + owned comments as a unit during reorder so comments follow their entries when updateOrder is enabled.
|
|
40
|
+
- Patching: tighten empty single-line inline tables and propagate to parent containers ([#276])
|
|
41
|
+
- Patching: unwrap InlineArrayItem when inserting into nested inline array ([#276])
|
|
42
|
+
- Patching: adjust commented out kv behavior to match expected behavior of comment ownership rules ([#277])
|
|
43
|
+
- Patching: ensure inline container tightening for deletions ([#278])
|
|
44
|
+
|
|
10
45
|
## [3.0.1] - 2026-08-03
|
|
11
46
|
|
|
12
47
|
### Fixed
|
|
@@ -347,4 +382,19 @@ This first forked version from [timhall/toml-patch](https://github.com/timhall/t
|
|
|
347
382
|
[#264]: https://github.com/DecimalTurn/toml-patch/pull/264
|
|
348
383
|
[#265]: https://github.com/DecimalTurn/toml-patch/pull/265
|
|
349
384
|
[#266]: https://github.com/DecimalTurn/toml-patch/pull/266
|
|
385
|
+
[#267]: https://github.com/DecimalTurn/toml-patch/pull/267
|
|
386
|
+
[#269]: https://github.com/DecimalTurn/toml-patch/pull/269
|
|
387
|
+
[#270]: https://github.com/DecimalTurn/toml-patch/pull/270
|
|
388
|
+
[#271]: https://github.com/DecimalTurn/toml-patch/pull/271
|
|
389
|
+
[#273]: https://github.com/DecimalTurn/toml-patch/pull/273
|
|
390
|
+
[#274]: https://github.com/DecimalTurn/toml-patch/pull/274
|
|
391
|
+
[#276]: https://github.com/DecimalTurn/toml-patch/pull/276
|
|
392
|
+
[#277]: https://github.com/DecimalTurn/toml-patch/pull/277
|
|
393
|
+
[#278]: https://github.com/DecimalTurn/toml-patch/pull/278
|
|
394
|
+
[#280]: https://github.com/DecimalTurn/toml-patch/pull/280
|
|
395
|
+
[#281]: https://github.com/DecimalTurn/toml-patch/pull/281
|
|
396
|
+
[#282]: https://github.com/DecimalTurn/toml-patch/pull/282
|
|
397
|
+
[#288]: https://github.com/DecimalTurn/toml-patch/pull/288
|
|
398
|
+
[#289]: https://github.com/DecimalTurn/toml-patch/pull/289
|
|
399
|
+
[#290]: https://github.com/DecimalTurn/toml-patch/pull/290
|
|
350
400
|
[0e66e68]: https://github.com/DecimalTurn/toml-patch/commit/0e66e68cbf42a07bc44445e46c3ea7bea97f95c1
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
<img src="assets/toml-patch-logo.png" alt="toml-patch logo" width="120"/>
|
|
2
|
+
|
|
1
3
|
# toml-patch
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/@decimalturn/toml-patch)
|
|
4
6
|
[](https://jsr.io/@decimalturn/toml-patch)
|
|
5
7
|
[](https://github.com/DecimalTurn/toml-patch/actions/workflows/test-and-build.yml)
|
|
6
|
-
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
package/dist/toml-patch.d.ts
CHANGED
package/dist/toml-patch.js
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.0.
|
|
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-]+$/,
|
|
3
|
-
|
|
1
|
+
//! @decimalturn/toml-patch v3.0.3 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
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-]+$/,E=/[\w,\d,",',+,\-,_]/;function D(){return{reference:null,mixed:!1}}function*O(e,t){let n=e.length,r=0,i=t??D(),a=[],o=(e,t)=>({start:_(a,e),end:_(a,t)});for(;r<n;){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9&&t!==13&&t!==10)throw new C(e,_(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed`);if(t===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new C(e,_(a,r),`Standalone CR; must be CRLF or LF`);if(t!==32&&t!==9&&t!==13)if(t===10)s(r);else if(t===91||t===93)yield{type:`Bracket`,raw:e[r],loc:o(r,r+1)};else if(t===123||t===125)yield{type:`Curly`,raw:e[r],loc:o(r,r+1)};else if(t===61)yield{type:`Equal`,raw:`=`,loc:o(r,r+1)};else if(t===44)yield{type:`Comma`,raw:`,`,loc:o(r,r+1)};else if(t===46)yield{type:`Dot`,raw:`.`,loc:o(r,r+1)};else if(t===35)yield c();else{let t=k(e,r,`'`)||k(e,r,`"`);t?yield l(t):yield u()}r++}function s(t){a.push(t);let n=t>0&&e.charCodeAt(t-1)===13?`\r
|
|
3
|
+
`:`
|
|
4
|
+
`;i.reference===null?i.reference=n:i.reference!==n&&(i.mixed=!0)}function c(){let t=r;for(;r+1<n;){let t=e.charCodeAt(r+1);if(t===10||t===13)break;r++;let n=e.charCodeAt(r);if((n<=31||n===127)&&n!==9)throw new C(e,_(a,r),`Control char 0x${n.toString(16).toUpperCase().padStart(2,`0`)} not allowed`)}return{type:`Comment`,raw:e.slice(t,r+1),loc:o(t,r+1)}}function l(t){let i=r,c=t+t+t;for(r+=3;r<n;){if(k(e,r,t)){let n=3;for(;e[r+n]===t;)n++;if(n>=6)throw new C(e,_(a,r),`Invalid multiline string: ${n} consecutive ${t} characters`);if(n===3){r+=2;break}r+=n-3,r+=2;break}let i=e.charCodeAt(r);if(i===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new C(e,_(a,r),`Standalone CR in multiline string; must be CRLF or LF`);if((i<=31||i===127)&&i!==9&&i!==10&&i!==13){let n=t===`"`?`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 ${n}`:`Control char ${o} not allowed in ${n}`;throw new C(e,_(a,r),c)}i===10&&s(r),r++}if(r>=n){if(t===`"`){let t=0,i=n-1;for(;i>=0&&e[i]===`\\`;)t++,i--;if(t>0&&t%2!=0)throw new C(e,_(a,r),`Unterminated multiline ${c} (possible escape issue)`)}throw new C(e,_(a,r),`Unterminated multiline ${c}`)}return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}function u(){let t=e[r];if(!E.test(t))throw new C(e,_(a,r),`Unexpected char "${t}"`);let i=r,s=t===`"`,c=t===`'`;for(;r<n&&!(r+1>=n);){let t=e.charCodeAt(r+1);if(!(s||c)&&(t===32||t===9||t===10||t===13||t===44||t===46||t===93||t===125||t===61||t===35))break;if(r++,!(s||c)){let t=e.charCodeAt(r);if(t<=31||t===127)throw new C(e,_(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed in unquoted value`)}if(s||c){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9){let n=s?`basic strings`:`literal strings`,i=`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} (${i}) not allowed in ${n}`:`Control char ${i} not allowed in ${n}`;throw new C(e,_(a,r),c)}}let i=e[r];if(i===`"`&&(s=!s),i===`'`&&!s&&(c=!c),r+1>=n)break;if(s&&i===`\\`){let t=e[r+1];(t===`"`||t===`\\`)&&r++}}if(s||c)throw new C(e,_(a,i),`Expected close of string with ${s?`"`:`'`}`);return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}}function k(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 A=new Int8Array(128);A.fill(-1);for(let e=0;e<10;e++)A[48+e]=e;for(let e=0;e<6;e++)A[65+e]=10+e,A[97+e]=10+e;function j(e){let t=e.charCodeAt(0);return t<128&&A[t]!==-1}function M(e,t){return A[e.charCodeAt(t)]<<12|A[e.charCodeAt(t+1)]<<8|A[e.charCodeAt(t+2)]<<4|A[e.charCodeAt(t+3)]}function ee(e){return e.startsWith(`'''`)?ne(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?te(ne(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?te(e.slice(1,e.length-1),!1):e}function te(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(`
|
|
5
|
+
`);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||!j(e[a+1])||!j(e[a+2])||!j(e[a+3])||!j(e[a+4]))throw Error(`Invalid Unicode escape: \\u${e.slice(a+1,a+5)}`);let t=M(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(!j(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||!j(e[a+1])||!j(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=A[e.charCodeAt(a+1)]<<4|A[e.charCodeAt(a+2)];r.push(String.fromCharCode(t)),a+=2;break}default:if(t&&(o===`
|
|
4
6
|
`||o===`\r`||o===` `||o===` `)){let t=o===`
|
|
5
7
|
`||o===`\r`,r=a;for(;r<n&&(e[r]===` `||e[r]===` `||e[r]===`
|
|
6
8
|
`||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
|
|
9
|
+
`||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 ne(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var re=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 ae();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?ae():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const ie=Object.freeze({value:void 0,done:!0});function ae(){return ie}const oe=new WeakMap;function se(e,t){oe.set(e,t)}function ce(e){return oe.get(e)}function le(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 ue(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 de(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 fe=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 ge)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new he(e,!1)}let e=t.toISOString().split(`T`)[0];return new pe(e)}else if(e.IS_TIME_ONLY.test(n)){if(t instanceof me)return t;{let e=le(t),r=ue(e.ms,n);return new me(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}else if(e.IS_LOCAL_DATETIME_T.test(n)){let e=le(t),r=ue(e.ms,n);return new he(`${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=le(t),r=ue(e.ms,n);return new he(`${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=le(new Date(t.getTime()+de(i)*6e4)),s=a?` `:`T`,c=ue(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new ge(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}else return t}},pe=class extends Date{constructor(e){super(e)}toISOString(){let e=le(this);return`${e.year}-${e.month}-${e.day}`}},me=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=le(this);return`${e.hours}:${e.minutes}:${e.seconds}${ue(e.ms,this.originalFormat)}`}},he=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=le(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${ue(e.ms,this.originalFormat)}`}},ge=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=le(new Date(this.getTime()+de(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=ue(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 N=fe,_e=`true`,ve=/e/i,ye=/_/g,be=/^[+-]?inf$/,xe=/^[+-]?nan$/,Se=/^[+-]?0x/i;function Ce(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const we=/^[+-]?0o/i,Te=/^[+-]?0b/i;function Ee(e,t,n){for(let r=0;r<e.length;r++)if(!Ce(e.charCodeAt(r)))throw new C(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function De(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new C(t,n,`Multiline strings cannot be keys`)}function Oe(e,t,n){try{return ee(e)}catch(e){throw new C(t,n,e.message)}}function ke(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 Ae(e,t,n,r){let i=e.replace(ye,``);if(/^[+-]?0\d/.test(i)&&!Se.test(e)&&!we.test(e)&&!Te.test(e))throw new C(t,n,`Leading zeros are not allowed in ${r}`)}function je(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 Me(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 Ne(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 Pe(e,t,n){if(Se.test(e)||we.test(e)||Te.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new C(t,n,`Invalid integer "${e}"`)}function Fe(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*P(e,t){let n=new re(O(e,t));for(;!n.next().done;){let t=Ke(n,e);for(let e of t)yield e}}function*Ie(e,t){for(let t of e)yield t;let n=new re(O(t));for(;!n.next().done;){let e=Ke(n,t);for(let t of e)yield t}}function Le(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function Re(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;De(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||Ee(a,t,e.value.loc.start);let o;for(o=[Oe(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(`'`)||Ee(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(ee(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=Ke(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 ze(e,t){let n=Oe(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function Be(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===_e}}function Ve(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&N.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&N.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(Ue(r,t,n.start),N.IS_FULL_DATE.test(r))i=N.IS_DATE_ONLY.test(r)?new pe(r):N.IS_LOCAL_DATETIME_T.test(r)?new he(r,!1):N.IS_LOCAL_DATETIME_SPACE.test(r)?new he(r,!0):N.IS_OFFSET_DATETIME_T.test(r)?new ge(r,!1):N.IS_OFFSET_DATETIME_SPACE.test(r)?new ge(r,!0):new Date(r.replace(` `,`T`));else if(N.IS_TIME_ONLY.test(r))i=new me(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 He(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 Ue(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;Me(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;Me(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>He(parseInt(r,10),u))throw new C(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Ne(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Ne(r,i,a,e,t,n)}}function We(e,t){let n=e.value.loc,r=e.value.raw,i;if(be.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(xe.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(ve.test(r)&&!Se.test(r))throw new C(t,n.start,`Float "${r}": dot after exponent`);let e=r;Ae(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`);ke(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}"`);ke(n,t,e.value.loc.start,!1),je(n,r,t,e.value.loc.start)}i=Number(r.replace(ye,``))}else{if(ke(r,t,n.start),je(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`);Ae(r,t,n.start,`the integer part of a float`),i=Number(r.replace(ye,``))}if(Number.isNaN(i)&&!xe.test(r))throw new C(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function Ge(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`);Ae(n,t,r.start,`decimal integers`),ke(n,t,r.start),Pe(n,t,r.start);let i=10;Se.test(n)?(i=16,Fe(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):we.test(n)?(i=8,Fe(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):Te.test(n)&&(i=2,Fe(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(ye,``).replace(we,``).replace(Te,``),i);if(Number.isNaN(a))throw new C(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function Ke(e,t){if(e.value.type===`Comment`)return[Le(e)];if(e.value.type===`Bracket`)return[Re(e,t)];if(e.value.type===`Literal`)return qe(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 qe(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 ':'`);De(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ee(n,t,e.value.loc.start);let r;r=[Oe(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;De(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ee(n,t,e.value.loc.start),i.loc.end=e.value.loc.end,i.raw+=`.${e.value.raw}`,i.value.push(Oe(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=Je(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 Je(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[ze(e,t)]:n===_e||n===`false`?[Be(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[Ve(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||be.test(n)||xe.test(n)||ve.test(n)&&!Se.test(n)?[We(e,t)]:[Ge(e,t)]}else if(e.value.type===`Curly`){let[n,r]=Xe(e,t);return[n,...r]}else if(e.value.type===`Bracket`){let[n,r]=Ze(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 Ye(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.loc.end.line===r.loc.start.line){let e=r.loc.start.column-n.loc.end.column;if(e>=1)return e}}}function Xe(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(Le(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=Ke(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 "}"`);n.loc.end=e.value.loc.end;{let e=Ye(n.items);e!==void 0&&se(n,e)}return[n,r]}function Ze(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(Le(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=Je(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 "]"`);n.loc.end=e.value.loc.end;{let e=Ye(n.items);e!==void 0&&se(n,e)}return[n,r]}function F(e){return e[e.length-1]}function Qe(){return Object.create(null)}function $e(e){return typeof e==`string`}function et(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)&&e>=-(2**53-1)&&e<=2**53-1}function tt(e){return typeof e==`bigint`}function nt(e){return typeof e==`number`&&(!et(e)||!isFinite(e)||Object.is(e,-0))}function rt(e){return typeof e==`boolean`}function it(e){return Object.prototype.toString.call(e)===`[object Date]`}const at=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function ot(e){var t;return typeof e==`object`&&!!e&&at.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function st(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 I(e){return e&&typeof e==`object`&&!it(e)&&!ot(e)&&!Array.isArray(e)}function ct(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function lt(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function ut(e){return e.startsWith(`"""`)}function dt(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function ft(e){return e.startsWith(`'''`)}function pt(e,t){return t in e}function L(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 mt(e,t){return ot(e)&&ot(t)?e.toString()===t.toString():it(e)&&it(t)?e.toISOString()===t.toISOString():!1}function ht(e){if(I(e))return`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${ht(e[t])}`).join(`,`)}}`;if(Array.isArray(e))return`[${e.map(ht).join(`,`)}]`;if(ot(e))return JSON.stringify(e.toString());if(it(e))return JSON.stringify(e.toISOString());if(typeof e==`bigint`)return e.toString()+`n`;if(typeof e==`number`&&!Number.isFinite(e)){let t=new Float64Array([e]);return`${new DataView(t.buffer).getUint32(4,!0)&2147483648?`-`:`+`}${String(e)}`}else return JSON.stringify(e)}function gt(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 _t=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function vt(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 yt(e,t){if(_t!==void 0&&_t.call(e))return;let n=vt(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 bt(e,t){ct(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 xt=new WeakSet,St=new WeakSet;function Ct(e){St.add(e)}const wt=new WeakMap,Tt=new WeakSet,Et=new WeakSet;function Dt(e){return Et.has(e)}function Ot(e){Et.delete(e)}function kt(e,t,n){Wt(n,R(e),t)}function At(e){xt.add(e)}const jt=new WeakMap,Mt=e=>(jt.has(e)||jt.set(e,new WeakMap),jt.get(e));function Nt(e){return jt.has(e)||jt.set(e,new WeakMap),jt.get(e)}const Pt=new WeakMap;function R(e){return Pt.has(e)||Pt.set(e,new WeakMap),Pt.get(e)}function z(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`);U(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);Wt({lines:o.lines-i.lines,columns:o.columns-i.columns},R(e),r,n),xt.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}=Rt(n,r,i):a&&e(n)?{shift:c,offset:u}=zt(n,r,i):{shift:c,offset:u}=Ft(t,n,r,i,s),U(r,c);let m=n.items[i-1],h=m&&R(t).get(m);if(h&&(u.lines+=h.lines,u.columns+=h.columns,R(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)}}R(t).set(r,u),xt.add(t)}function Ft(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)if(St.has(n))d=c;else{let e=!1;for(let t=0;t<o;t++)if(f(i.items[t])){e=!0;break}if(!e)d=c;else{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=!St.has(n)&&c===void 0&&(t(i)||r(i)||e(i))&&wt.has(i),S=x&&!Tt.has(i);x&&(wt.delete(i),Tt.delete(i));let C=x&&!S,w=0;if(C){let e=t(i)||r(i)?R(n).get(i.key):Mt(n).get(i);w=e?-e.lines:1}let T=S||C?-y.lines:_-1,E={lines:u?y.lines+1:y.lines+T,columns:y.columns};return{shift:{lines:v.lines+w,columns:v.columns},offset:E}}function It(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 Lt(e){return ce(e)??2}function Rt(e,t,n){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let r=Lt(e),i=n==null?F(e.items):e.items[n-1],a=n==null||n===e.items.length,o=n==null?void 0:e.items[n];e.items.splice(n,0,t);let s=!!i,c=!a;return s&&(i.comma=!0),c&&(t.comma=!0),It(e,t,n,{useNewLine:Ut(e)&&!(i&&o&&o.loc.start.line===i.loc.end.line&&o.loc.start.column>=i.loc.end.column)&&!(!o&&i&&i.loc.end.line===e.loc.end.line),skipCommaSpace:r,hasCommaHandling:!0,isLastElement:a,hasSeparatingCommaBefore:s,hasSeparatingCommaAfter:c,hasTrailingComma:a&&t.comma===!0})}function zt(e,t,n){let r=It(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?R(n).get(c):void 0,b=c&&c.loc.end.line===a.loc.start.line+((y==null?void 0:y.lines)??0),x=h&&h.loc.start.line===a.loc.end.line,S=v&&(b||x),C={lines:-(_.lines-+!!S),columns:S?-_.columns:0};if((e(i)||t(i)||r(i))&&h&&!S&&h.loc.start.line>a.loc.end.line){let e=t(a)||r(a),o=t(h)||r(h),l=-1;for(let e=0;e<s;e++){let t=i.items[e].loc.end.line;t>l&&(l=t)}let u=c?R(n).get(c):void 0,d=R(n).get(a),f=c?e?a.loc.start.line+((u==null?void 0:u.lines)??0)-l-1:0:o?h.loc.start.line+((d==null?void 0:d.lines)??0)-a.loc.end.line-1:0;f>0&&(C.lines-=f)}let w=(d(i)||l(i))&&i.loc.end.line>i.loc.start.line,T=w&&a.loc.start.line===i.loc.start.line;c===void 0&&h===void 0&&(!w||T)&&(C.lines=0,C.columns=0,(d(i)||l(i))&&Et.add(i),(t(i)||r(i)||e(i))&&wt.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&Tt.add(i);let E=l(i)||d(i)?Lt(i):2;if(v&&b&&(C.columns-=E),v&&!c&&h&&(Ut(i)||(C.columns-=E)),v&&c&&!h&&(a.comma?c.comma=!0:c.comma=!1,b)){var D;let e=c?((D=R(n).get(c))==null?void 0:D.columns)??0:0;C.columns=c.loc.end.column-a.loc.end.column-e}let O,k;c?(O=c,k=R(n)):(t(i)||r(i))&&`key`in i?(O=i.key,k=R(n)):(O=i,k=Mt(n));let A=R(n),j=k.get(O);j&&(C.lines+=j.lines,C.columns+=j.columns);let M=A.get(a);if(M&&(C.lines+=M.lines,S&&(C.columns+=M.columns)),k.set(O,C),xt.add(n),w&&(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):C.lines!==0&&o<e&&(a.loc.start.line-=C.lines,a.loc.end.line-=C.lines))}for(let e=r.length-1;e>=0;e--)t.splice(r[e],1)}}function Bt(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 Vt(e,t,n=!0){if(!n||!t.items.length)return;Wt({lines:0,columns:1},Mt(e),t);let r=F(t.items);Wt({lines:0,columns:1},R(e),r),xt.add(e)}function Ht(e,t,n=!1){if(!n||!t.items.length)return;let r=F(t.items);r.comma=!0,Wt({lines:0,columns:1},R(e),r),xt.add(e)}function H(e){if(!xt.has(e))return;let t=Mt(e),n=R(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),Bt(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),Bt(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),Bt(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 r=e;if(!t.get(r)&&!n.get(r)){c(r);for(let e=0;e<r.items.length;e++)a(r.items[e]);l(r);break}o(r);for(let e=0;e<r.items.length;e++)a(r.items[e]);s(r);break}case`InlineTable`:{let r=e;if(!t.get(r)&&!n.get(r)){c(r);for(let e=0;e<r.items.length;e++)a(r.items[e]);l(r);break}o(r);for(let e=0;e<r.items.length;e++)a(r.items[e]);s(r);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)}function c(e){e.loc.start.line+=r,e.loc.start.column+=i[e.loc.start.line]||0}function l(e){e.loc.end.line+=r,e.loc.end.column+=i[e.loc.end.line]||0}a(e),xt.delete(e),jt.delete(e),Pt.delete(e)}function U(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.line===t.loc.start.line&&(t.loc.end.column+=i)),t.loc.start.line+=r,t.loc.end.line+=r,(!a||t.loc.start.line===o)&&(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.line===s.loc.start.line&&(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.line===e.loc.start.line&&(e.loc.end.column+=i)),e.loc.start.line+=r,e.loc.end.line+=r};return bt(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 Ut(e){return e.items.length?g(e.loc).lines>e.items.length:!1}function Wt(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function Gt(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
|
|
8
10
|
`?`\r
|
|
9
11
|
`:`
|
|
10
|
-
`}function
|
|
11
|
-
`).replace(/\n/g,r);let i,a;e.startsWith(`"""\\${r}`)?(i=4+r.length,a=`"""\\${r}`):e.startsWith(`"""${r}`)?(i=3+r.length,a=`"""${r}`):(i=3,a=`"""`);let o=e.length-3,s=e.slice(i,o).split(r),c=s[s.length-1],l=s.length>1&&/^[\t ]*$/.test(c),u=l?c:``,d=(l?s.slice(0,-1):s).map(e=>{var t;if(/^[\t ]*$/.test(e))return{indent:e,content:``,trailingWs:``,hasBackslash:!1,isBlank:!0};let n=e,r=0;for(let e=n.length-1;e>=0&&n[e]===`\\`;e--)r++;let i=r%2==1;i&&(n=n.slice(0,-1));let a=((t=n.match(/^[\t ]*/))==null?void 0:t[0])??``,o=n.slice(a.length),s=o.match(/([\t ]+)$/),c=s?s[1]:``;return{indent:a,content:o.slice(0,o.length-c.length),trailingWs:c,hasBackslash:i,isBlank:!1}}),f=d.filter(e=>!e.isBlank),p=Math.max(...f.map(e=>e.content.length+e.trailingWs.length),1),m=f.filter(e=>e.hasBackslash),h=m[m.length-1]??f[f.length-1]??{indent:``,trailingWs:``,hasBackslash:!1,content:``,isBlank:!1},g=f[f.length-1]??h,_=[];{let e=[],t=0;for(let n of d)n.isBlank?e.push(n.indent):(t>0&&_.push(e),e=[],t++)}let v=f.some((e,t)=>!e.hasBackslash&&t<f.length-1),y=a===`"""${r}`,b=y&&f.length>0?((n=t.match(/^[\t ]*/))==null?void 0:n[0])??``:``,x=e=>{let t=e.match(/\S+| +/g)??[],n=[],r=0;for(;r<t.length;){let e=t[r++];for(;r<t.length&&t[r][0]===` `;){let n=t[r],i=t[r+1];if(!i){r++;break}if(e.length+n.length+i.length<=p)e+=n+i,r+=2;else{e+=n,r++;break}}n.push(e)}return n.length===0&&n.push(``),n},S=[],C=[],w=new Set,T=new Set,
|
|
12
|
+
`}function Kt(e,t){var n;let r=Gt(e);e=e.replace(/\r\n/g,`
|
|
13
|
+
`).replace(/\n/g,r);let i,a;e.startsWith(`"""\\${r}`)?(i=4+r.length,a=`"""\\${r}`):e.startsWith(`"""${r}`)?(i=3+r.length,a=`"""${r}`):(i=3,a=`"""`);let o=e.length-3,s=e.slice(i,o).split(r),c=s[s.length-1],l=s.length>1&&/^[\t ]*$/.test(c),u=l?c:``,d=(l?s.slice(0,-1):s).map(e=>{var t;if(/^[\t ]*$/.test(e))return{indent:e,content:``,trailingWs:``,hasBackslash:!1,isBlank:!0};let n=e,r=0;for(let e=n.length-1;e>=0&&n[e]===`\\`;e--)r++;let i=r%2==1;i&&(n=n.slice(0,-1));let a=((t=n.match(/^[\t ]*/))==null?void 0:t[0])??``,o=n.slice(a.length),s=o.match(/([\t ]+)$/),c=s?s[1]:``;return{indent:a,content:o.slice(0,o.length-c.length),trailingWs:c,hasBackslash:i,isBlank:!1}}),f=d.filter(e=>!e.isBlank),p=Math.max(...f.map(e=>e.content.length+e.trailingWs.length),1),m=f.filter(e=>e.hasBackslash),h=m[m.length-1]??f[f.length-1]??{indent:``,trailingWs:``,hasBackslash:!1,content:``,isBlank:!1},g=f[f.length-1]??h,_=[];{let e=[],t=0;for(let n of d)n.isBlank?e.push(n.indent):(t>0&&_.push(e),e=[],t++)}let v=f.some((e,t)=>!e.hasBackslash&&t<f.length-1),y=a===`"""${r}`,b=y&&f.length>0?((n=t.match(/^[\t ]*/))==null?void 0:n[0])??``:``,x=e=>{let t=e.match(/\S+| +/g)??[],n=[],r=0;for(;r<t.length;){let e=t[r++];for(;r<t.length&&t[r][0]===` `;){let n=t[r],i=t[r+1];if(!i){r++;break}if(e.length+n.length+i.length<=p)e+=n+i,r+=2;else{e+=n,r++;break}}n.push(e)}return n.length===0&&n.push(``),n},S=[],C=[],w=new Set,T=new Set,E=new Map,D=!1;if(v&&t.includes(r)&&(r===`\r
|
|
12
14
|
`||!t.includes(`\r
|
|
13
|
-
`))){
|
|
14
|
-
`;case`f`:return`\f`;case`r`:return`\r`;case`"`:return`"`;case`\\`:return`\\`;default:return null}}function
|
|
15
|
+
`))){D=!0;let e=t.split(r),n=e[0].slice(b.length);if(n.length>0&&n[0]===` `)return null;let i=e[e.length-1];if(i.length>0&&i.length-i.trimEnd().length!==g.trailingWs.length)return null;for(let t=0;t<e.length;t++){var O;let n=e[t],r=t===0?n.slice(b.length):n,i=((O=r.match(/^[\t ]*/))==null?void 0:O[0])??``,a=x(r.slice(i.length)),o=S.length;T.add(o),t>0&&E.set(o,i);for(let e of a)S.push(e);t<e.length-1&&w.add(o+a.length-1)}}else{let e=t.replace(/\r\n/g,`\\r\\n`).replace(/\n/g,`\\n`).slice(b.length);if(e.length>0&&(e[0]===` `||e.length-e.trimEnd().length!==g.trailingWs.length))return null;if(!v){let t=0,n=0;for(let r=0;r<f.length-1;r++){let i=f[r];if(!i.hasBackslash)break;let a=i.content+i.trailingWs;if(e.slice(n,n+a.length)===a)t++,n+=a.length;else break}let i=0,o=0;for(let r=f.length-1;r>=t;r--){let t=f[r],a=t.content+t.trailingWs;if(a.length===0)break;let s=e.length-o-a.length;if(s>=n&&e.slice(s,s+a.length)===a)i++,o+=a.length;else break}if(i>0){let s=e.slice(n,e.length-o);if(s.length===0||s[0]!==` `){for(let e=0;e<t;e++){let n=f[e];if(C.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}if(s.length>0){let e=x(s),n=e.join(``),r=/(?<!\\)\\n/.test(n);if(t>0&&!r){let e=t-1;if(e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}for(let n=0;n<e.length;n++){let i=e[n],a=t+n,o=a<f.length?f[a]:null,c=o?y&&a===0?b:o.indent:h.indent,l=i.length>0&&/\s$/.test(i)?``:s.endsWith(` `)?` `:``;if(C.push(`${c}${i}${l}\\`),n<e.length-1&&!r){let e=t+n;if(e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}}let a=f.length-i-1;if(!r&&a>=0&&a<_.length&&_[a].length>0)for(let e of _[a])C.push(e)}else if(t>0){let e=t-1;if(e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}let e=f.length-i;for(let t=e;t<f.length;t++){let n=f[t],r=t===f.length-1;if(t>e){let e=t-1;if(e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}C.push(r?`${n.indent}${n.content}${n.trailingWs}${n.hasBackslash&&n.content!==``?`\\`:``}`:`${n.indent}${n.content}${n.trailingWs}\\`)}return l&&!(g.hasBackslash&&g.content===``)?`${a}${C.join(r)}${r}${u}"""`:`${a}${C.join(r)}"""`}}let s=e.slice(n);if(t>0&&(n===e.length||s.length>0&&s[0]!==` `)){for(let e=0;e<t;e++){let n=f[e];if(C.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}if(n===e.length){let e=f[t-1],n=g.hasBackslash&&e.content!==``?`\\`:``;C[C.length-1]=`${e.indent}${e.content}${g.trailingWs}${n}`}else{let e=x(s),n=e.join(``),r=/(?<!\\)\\n/.test(n),i=t-1;if(!r&&i<_.length&&_[i].length>0)for(let e of _[i])C.push(e);for(let n=0;n<e.length;n++){let i=n===e.length-1,a=e[n],o=t+n,s=o<f.length?f[o]:null,c=s?y&&o===0?b:s.indent:i?g.indent:h.indent,l,u;if(i?(l=g.trailingWs,u=g.hasBackslash&&g.content!==``?`\\`:``):(l=a.length>0&&/\s$/.test(a)?``:` `,u=`\\`),C.push(`${c}${a}${l}${u}`),!i){let e=t+n;if(!r&&e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}}}return l&&!(g.hasBackslash&&g.content===``)?`${a}${C.join(r)}${r}${u}"""`:`${a}${C.join(r)}"""`}}let n=x(e);for(let e of n)S.push(e)}for(let e=0;e<S.length;e++){let t=e===S.length-1,n=w.has(e),r=t||n,i=e<f.length?f[e]:null,a=D&&T.has(e)&&e>0?E.get(e)??``:i?y&&e===0?b:i.indent:r?g.indent:h.indent,o=S[e],s,c;if(r&&t?(s=g.trailingWs,c=g.hasBackslash&&g.content!==``?`\\`:``):r?(s=g.trailingWs,c=``):(s=o.length>0&&/\s$/.test(o)?``:` `,c=`\\`),C.push(`${a}${o}${s}${c}`),!t&&!n&&!D){let t=S.join(``);if(!/(?<!\\)\\n/.test(t)&&e<_.length&&_[e].length>0)for(let t of _[e])C.push(t)}}return l&&!(g.hasBackslash&&g.content===``)?`${a}${C.join(r)}${r}${u}"""`:`${a}${C.join(r)}"""`}function qt(e){switch(e){case`b`:return`\b`;case`t`:return` `;case`n`:return`
|
|
16
|
+
`;case`f`:return`\f`;case`r`:return`\r`;case`"`:return`"`;case`\\`:return`\\`;default:return null}}function Jt(e,t){return t===`singleline-basic`?e<=31||e===127:e>=0&&e<=7||e===11||e>=14&&e<=31||e===127}function Yt(e,t){switch(e){case`\\`:return`\\\\`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`"`:return t===`singleline-basic`?`\\"`:`"`;case`
|
|
15
17
|
`:return t===`singleline-basic`?`\\n`:`
|
|
16
|
-
`;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return
|
|
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
|
|
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
|
|
18
|
+
`;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return Jt(n,t)?`\\u${n.toString(16).padStart(4,`0`).toUpperCase()}`:e}}}function Xt(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=qt(r);if(i!==null){i!==`
|
|
19
|
+
`&&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+=Yt(i,n)}return r}function Qt(e,t,n){let r=Xt(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 $t(){return{type:`Document`,loc:{start:S(),end:S()},items:[]}}function W(e){let t=en(e);return{type:`Table`,loc:x(t.loc),key:t,items:[]}}function en(e){let t=on(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 tn(e){let t=nn(e);return{type:`TableArray`,loc:x(t.loc),key:t,items:[]}}function nn(e){let t=on(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 rn(e,t){let n=sn(e),{column:r}=n.loc.end,i=r+1;return U(t,{lines:1-t.loc.start.line,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 an(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function on(e){return e.map(e=>(yt(e,`Key ${JSON.stringify(e)}`),T.test(e)?e:an(e))).join(`.`)}function sn(e){let t=on(e);return{type:`Key`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function cn(e,t){return yt(e,`String value`),t?ln(e,t):un(e)}function ln(e,t){if(lt(t))return un(e,t);if(dt(t))return e.includes(`'`)?e.includes(`'''`)?un(e):pn(e,`'''${t.slice(1,-1)}'''`):dn(e);if(ft(t))return e.includes(`'''`)?fn(e,`"""${t.slice(3,-3)}"""`):pn(e,t);if(ut(t))return fn(e,t);throw Error(`Existing raw string value is not valid: ${t}`)}function un(e,t){let n=``;return n=t?`"${Qt(e,t,`singleline-basic`)}"`:an(e),{type:`String`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function dn(e){let t=`'${e}'`,n;if(t.includes(`
|
|
20
|
+
`)){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 fn(e,t){let n=Qt(e,t,`multiline-basic`),r=`"""`+(t.startsWith(`"""\r
|
|
19
21
|
`)?`\r
|
|
20
22
|
`:t.startsWith(`"""
|
|
21
23
|
`)?`
|
|
22
|
-
`:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=
|
|
24
|
+
`:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=Kt(t,n);e!==null&&(r=e)}let a=mn(r);return{type:`String`,loc:{start:S(),end:a},raw:r,value:e}}function pn(e,t){let n=`'''`+(t.startsWith(`'''\r
|
|
23
25
|
`)?`\r
|
|
24
26
|
`:t.startsWith(`'''
|
|
25
27
|
`)?`
|
|
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
|
|
28
|
+
`:``)+e+`'''`,r=mn(n);return{type:`String`,loc:{start:S(),end:r},raw:n,value:e}}function mn(e){if(e.includes(`
|
|
29
|
+
`)){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 hn(e){let t=e.toString();return{type:`Integer`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function gn(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 _n(e){return{type:`Boolean`,loc:{start:S(),end:{line:1,column:e?4:5}},value:e}}function vn(e,t=!1){t&&!(e instanceof me)&&e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0&&(e=new pe(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 yn(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=st(e);else if(a)s=st(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=st(n),{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:n}}s=st(e)}else s=st(e);return{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:e}}function bn(){return{type:`InlineArray`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function xn(e){return{type:`InlineItem`,loc:x(e.loc),item:e,comma:!1}}function Sn(){return{type:`InlineTable`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function Cn(e){return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}function wn(e){return e.charCodeAt(0)===65279}function Tn(e){return wn(e)?e.slice(1):e}function En(e){for(let t of e){let e=An(t);if(e!==null)return e}return!1}function Dn(e,t){for(let n of t){let t=On(n,e);if(t!==null)return t}return!0}function On(e,t){if(!e||typeof e!=`object`)return null;if((e.type===`InlineArray`||e.type===`InlineTable`)&&e.loc){let n=kn(e.loc,t);if(n!==null)return n}if(e.items&&Array.isArray(e.items))for(let n of e.items){let e=On(n,t);if(e!==null)return e;if(n.item){let e=On(n.item,t);if(e!==null)return e}}for(let n of[`value`,`key`,`item`])if(e[n]){let r=On(e[n],t);if(r!==null)return r}return null}function kn(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
30
|
`+(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
|
|
31
|
+
`+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 An(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 jn(e.items);if(e.type===`KeyValue`&&e.value)return An(e.value);if(e.items&&Array.isArray(e.items))for(let t of e.items){let e=An(t);if(e!==null)return e}return null}function jn(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 Mn(e){let t=e.indexOf(`
|
|
30
32
|
`);return t>0&&e[t-1]===`\r`?`\r
|
|
31
33
|
`:`
|
|
32
|
-
`}function
|
|
33
|
-
`;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function
|
|
34
|
+
`}function Nn(e){let t=0,n=e.length;for(;n>0&&e[n-1]===`
|
|
35
|
+
`;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function Pn(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 Fn(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 G(e,t){if(e){if(e instanceof K)return e;{let n=Fn(e);return new K(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 K=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
36
|
`,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=
|
|
37
|
+
`,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=wn(t);let i=Tn(t);r.newLine=Mn(i),r.trailingNewline=Nn(i);try{let e=Array.isArray(n)?n:Array.from(n??P(i));r.trailingComma=En(e),r.bracketSpacing=Dn(i,e)}catch{r.trailingComma=!1,r.bracketSpacing=!0}return r.useTabsForIndentation=Pn(i),r.inlineTableStart=1,r.truncateZeroTimeInDates=!1,r.minimumDecimals=0,r.updateOrder=!1,r}static autoDetectFormatWithAst(t,n){return e.autoDetectFormatWithCst(t,n)}};function In(e){return!l(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function Ln(e){return!d(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function Rn(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=Hn(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,W(t.key.value)):B(e,e,zn(t)):Bn(t).forEach(t=>{B(e,e,t)})}),H(e),e)}function zn(e){let t=W(e.key.value);for(let n of e.value.items)B(t,t,n.item);return H(t),t}function Bn(e){let t=$t();for(let n of e.value.items){let r=tn(e.key.value);B(t,t,r);for(let e of n.item.items)B(t,r,e.item)}return H(t),t.items}function Vn(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 Hn(e){return Math.max(0,e.length-1)}function Un(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(Hn(i.key.value)<t.inlineTableStart){let r=zn(i);V(e,e,i),B(e,e,r),Wn(r,n,t)}}else(i.type===`Table`||r(i))&&Wn(i,n,t);let i=new Map;for(let{table:t,parent:r}of n){let n=e.items.indexOf(r),a=(i.get(r)??0)+1;i.set(r,a),B(e,e,t,n+a)}return H(e),e}function Wn(e,t,n){let r=[];for(let t=0;t<e.items.length;t++){let i=e.items[t];if(a(i)&&d(i.value)){let t=[...e.key.item.value,...i.key.value];Hn(t)<(n.inlineTableStart??1)&&r.push({item:i,nestedTableKey:t})}}for(let{item:i,nestedTableKey:a}of r){let r=W(a),o=i.value;for(let e of o.items)B(r,r,e.item);H(r),V(e,e,i),Vn(e),t.push({table:r,parent:e}),Wn(r,t,n)}r.length>0&&H(e)}function Gn(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)),U(r,{lines:t,columns:0}),n=r.loc.end.line;return e}function q(e,t=K.default()){e=Xn(e);let n=$t();Ct(n);for(let r of Kn(e,t))B(n,n,r);return H(n),Rn(n,t),Un(n,t),Gn(n)}function*Kn(e,t){for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=Xn(r);i!==void 0&&(yield rn([n],qn(i,t)))}}function qn(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 $e(e)?cn(e):tt(e)?hn(e):et(e)?n>0?gn(e,n):hn(e):nt(e)?gn(e,Math.max(n,1)):rt(e)?_n(e):ot(e)?yn(e,t.truncateZeroTimeInDates):it(e)?vn(e,t.truncateZeroTimeInDates):Array.isArray(e)?Jn(e,t):Yn(e,t)}function Jn(e,t){let n=bn();for(let r of e)B(n,n,xn(qn(r,t)));return Vt(n,n,t.bracketSpacing),Ht(n,n,t.trailingComma),H(n),n}function Yn(e,t){if(e=Xn(e),!I(e))return qn(e,t);let n=Sn();for(let r of Kn(e,t))B(n,n,xn(r));return Vt(n,n,t.bracketSpacing),Ht(n,n,t.trailingComma),H(n),n}function Xn(e){return!e||it(e)||ot(e)?e:typeof e.toJSON==`function`?e.toJSON():e}const Zn=/(\r\n|\n)/g;function Qn(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;$n(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;$n(n,t.loc,`[[`+t.item.raw+`]]`);break}case`KeyValue`:{let t=e,i=t.loc.start.line;er(n,i,t.equals,`=`),r(t.key),r(t.value);break}case`Key`:$n(n,e.loc,e.raw);break;case`String`:$n(n,e.loc,e.raw);break;case`Integer`:$n(n,e.loc,e.raw);break;case`Float`:$n(n,e.loc,e.raw);break;case`Boolean`:$n(n,e.loc,e.value.toString());break;case`DateTime`:$n(n,e.loc,e.raw);break;case`InlineArray`:{let t=e,{start:i,end:a}=t.loc;er(n,i.line,i.column,`[`),er(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;er(n,i.line,i.column,`{`),er(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;er(n,e.line,e.column,`,`)}break}case`Comment`:$n(n,e.loc,e.raw);break;default:{let t=e.type;throw Error(`toTOML: Unrecognized node type: ${String(t)}`)}}}if(ct(e))for(let t of e)r(t);else r(e);if(t.useTabsForIndentation){let t=new Set,r=e=>{if(e.type===`String`&&e.loc.end.line>e.loc.start.line)for(let n=e.loc.start.line+1;n<=e.loc.end.line;n++)t.add(n);if(p(e))for(let t of e.items)r(t);a(e)&&r(e.value),u(e)&&r(e.item)};if(ct(e))for(let t of e)r(t);else r(e);for(let e=0;e<n.length;e++){if(t.has(e+1))continue;let r=n[e],i=r.match(/^( +)/);if(i){let t=i[1];n[e]=` `.repeat(t.length)+r.substring(t.length)}}}return n.join(t.newLine)+t.newLine.repeat(t.trailingNewline)}function $n(e,t,n){if(t.start.line===t.end.line){let r=tr(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
38
|
`&&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};
|
|
39
|
+
`),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=tr(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 er(e,t,n,r){let i=tr(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 tr(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function nr(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 rr(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)),rr(e.value,r,n)}}}function ir(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 pe)return s.PlainDate.from(e.toISOString());if(e instanceof me)return s.PlainTime.from(e.toISOString());if(e instanceof he)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof ge){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{or(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=sr(a,n),f=n}function h(e){let n=e.key.item.value;try{or(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=cr(a,n),f=n}function g(e){let n=e.key.value;try{or(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=ar(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)),rr(e.value,t,u)}let o=n.length>1?sr(d,n.slice(0,-1)):d;o[F(n)]=a,c.add(Y(f.concat(n)))}}function ar(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=ar(e.value,{integersAsBigInt:n,temporal:r}),c=dr(o),l=Y(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=dr(o.slice(0,e));if(i.has(Y(o.slice(0,e))))throw Error(`Key "${c}" conflicts with key: "${t}"`)}if(a.has(l)){let e=a.get(l);throw Error(`Key "${c}" conflicts with key: "${e}"`)}i.add(l);for(let e=1;e<o.length;e++){let t=Y(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?sr(t,o.slice(0,-1)):t;u[F(o)]=s}),t;case`InlineArray`:return e.items.map(e=>ar(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 ir(e.value)}return e.value;case`String`:return e.value;case`Integer`:return nr(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function or(e,t,n,r,i){let a=t.length>0?[...t]:[],o=Array(n.length),s=Array(n.length);for(let e=0;e<n.length;e++)a.push(n[e]),o[e]=dr(a),s[e]=Y(a);let c=o[n.length-1],l=s[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(s[e-1]))throw Error(`Cannot extend inline table at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.inline_tables.has(l))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(s[e-1]))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(s[e-1]))throw Error(`Cannot traverse Array of Tables at ${t}`)}if((r===`Table`||r===`TableArray`)&&i.implicit_tables.has(l))throw Error(`Implicit table already defined: ${c}`);if(r===`KeyValue`&&i.implicit_tables.has(l))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(s[e-1]))throw Error(`Cannot extend explicit table ${t} with dotted keys`)}let u=0;for(let t of n){if(!pt(e,t))return;if(ur(e[t]))throw Error(`Value already defined for ${o[u]}`);let r=o[u];if(Array.isArray(e[t])&&!i.table_arrays.has(s[u]))throw Error(`Cannot add to static array at ${r}`);let a=u++<n.length-1;e=Array.isArray(e[t])&&a?F(e[t]):e[t]}let d=c;if(e&&r===`Table`&&i.defined.has(l)||e&&r===`KeyValue`&&n.length===1&&i.defined.has(l)&&!ur(e))throw Error(`Table already defined: ${d}`);if(e&&r===`TableArray`&&!i.table_arrays.has(l))throw Error(`Cannot add Array of Tables to table at ${d}`)}function sr(e,t){let n=lr(e,t.slice(0,-1)),r=F(t);return n[r]||(n[r]=Qe()),n[r]}function cr(e,t){let n=lr(e,t.slice(0,-1)),r=F(t);n[r]||(n[r]=[]);let i=Qe();return n[F(t)].push(i),i}function lr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=Qe()),Array.isArray(e[t])?F(e[t]):e[t]),e)}function ur(e){return typeof e!=`object`&&!it(e)}function dr(e){return e.join(`.`)}function Y(e){return JSON.stringify(e)}function fr(e){return e.type===`Add`}function pr(e){return e.type===`Edit`}function mr(e){return e.type===`Remove`}function hr(e){return e.type===`Move`}function gr(e){return e.type===`Rename`}function _r(e,t,n=[],r={}){if(e===t||mt(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)?yr(e,t,n,r):I(e)&&I(t)?vr(e,t,n,r):[{type:`Edit`,path:n}]}function vr(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>ht(e[t])),s=Object.keys(t),c=s.map(e=>ht(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)?gt(i,_r(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 yr(e,t,n=[],r={}){let i=[],a=e.map(ht),o=t.map(ht),s=e=>{if(typeof e==`string`)return e.includes(`
|
|
40
|
+
`);if(Array.isArray(e))return e.length>0;if(typeof e==`object`&&e&&!(e instanceof Date)){let t=Object.values(e);return t.some(e=>typeof e==`object`&&!!e)||t.some(s)}return!1},c=e.some(s)||t.some(s),l=e.slice(),u=0;for(let e=0;e<o.length;e++){let s=o[e],d=e>=a.length;if(!d&&a[e]===s)continue;let f=d?-1:a.indexOf(s,e+1);if(f>-1){let r=a[e],d=0;for(let t=e;t<a.length;t++)a[t]===r&&d++;let p=0;for(let t=e;t<o.length;t++)o[t]===r&&p++;let m=d>p;if(c&&(o.indexOf(a[e])===-1||m)){i.push({type:`Remove`,path:n.concat(e+u)}),a.splice(e,1),l.splice(e,1),u++,e--;continue}if(u>0&&m){i.push({type:`Remove`,path:n.concat(e+u)}),a.splice(e,1),l.splice(e,1),u++,e--;continue}if(c&&u>0){i.push({type:`Add`,path:n.concat(e)}),a.splice(e,0,s),l.splice(e,0,t[e]),u--;continue}i.push({type:`Move`,path:n,from:f,to:e});let h=a.splice(f,1);a.splice(e,0,...h);let g=l.splice(f,1);l.splice(e,0,...g);continue}let p=!1;if(!d){let t=a[e],n=0;for(let r=e;r<a.length;r++)a[r]===t&&n++;let r=0;for(let n=e;n<o.length;n++)o[n]===t&&r++;p=n>r}if(!d&&p){gt(i,_r(l[e],t[e],n.concat(e),r)),a[e]=s,l[e]=t[e];continue}i.push({type:`Add`,path:n.concat(e)}),a.splice(e,0,s),l.splice(e,0,t[e]),u>0&&u--}for(let e=o.length;e<a.length;e++)i.push({type:`Remove`,path:n.concat(e+u)});return i}function X(n,i){if(!i.length)return u(n)&&a(n.item)?n.item:n;if(a(n))return X(n.value,i);let o={},s,c;if(p(n)&&n.items.some((l,d)=>{try{let f=[];if(a(l))f=l.key.value;else if(t(l))f=l.key.item.value;else if(r(l)){f=l.key.item.value;let e=ht(f);o[e]||(o[e]=0);let t=o[e]++;f=f.concat(t)}else u(l)&&a(l.item)?f=l.item.key.value:u(l)&&(f=[d]);if(f.length&&L(f,i.slice(0,f.length))){let t=i.slice(f.length);if(e(n)&&r(l)&&t.length>0){let e=l.key.item.value,i=n,a=i.items.findIndex((t,n)=>n>d&&r(t)&&L(t.key.item.value,e)),o=a===-1?i.items.length:a;s=br(l,t,e,i.items.slice(d+1,o))}else s=u(l)&&a(l.item)?i.length===f.length?l:X(l.item.value,t):u(l)&&i.length>f.length?X(l.item,t):X(l,t);return!0}else if((a(l)||u(l)&&a(l.item))&&f.length>i.length&&L(f.slice(0,i.length),i))return c||=l,!1;else return!1}catch{return!1}}),!s&&c&&(s=c),!s)throw Error(`Node not found at ${i.join(`.`)}`);return s}function br(e,n,i,a){try{return X(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&&L(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&&L(t.slice(0,i.length),i)){let e=t.slice(i.length),n=ht(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&L(a,n.slice(0,a.length)))try{return X(e,n.slice(a.length))}catch{}}throw Error(`Node not found at (aot scope) ${n.join(`.`)}`)}function Z(e,t){try{return X(e,t)}catch{}}function xr(e,t){let n=t,r;for(;n.length&&!r;)n=n.slice(0,-1),r=Z(e,n);if(!r)throw Error(`Parent not found for ${t.join(`.`)}`);return r}const Sr=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,Cr=new RegExp(String.raw`^#\s*${Sr}(?:\s*\.\s*${Sr})*\s*=`),wr=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,Tr=new RegExp(String.raw`^#\s*${Sr}(?:\s*\.\s*${Sr})*\s*=\s*${wr}\s*$`),Er=new RegExp(String.raw`^#\s*\[\[?\s*${Sr}(?:\s*\.\s*${Sr})*\s*\]\]?\s*$`);function Dr(e){return Tr.test(e.raw)||Er.test(e.raw)}function Or(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 kr(e){return Dr(e)?!0:Cr.test(e.raw)?Or(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function Ar(e){let t=e.raw.match(Cr);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 jr(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function Mr(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 Nr(e,t,n,r=Mr){let i=[],a=t,o,s=[],c=()=>{s.length&&(i.push({kind:`pinned`,items:s,startLine:s[0].loc.start.line,endLine:F(s).loc.end.line}),s=[])};for(let t of e){if(f(t)){if(t.loc.start.line<=a){o?(o.items.push(t),o.endLine=Math.max(o.endLine,t.loc.end.line)):i.push({kind:`pinned`,items:[t],startLine:t.loc.start.line,endLine:t.loc.end.line});continue}let e=s.length?F(s).loc.end.line:void 0;s.length&&t.loc.start.line===e+1||c(),s.push(t);continue}let e=[];if(s.length)if(F(s).loc.end.line+1===t.loc.start.line&&n(t)){let n=r(t);if(n!==void 0){let e=-1;for(let t=s.length-1;t>=0;t--){let r=kr(s[t])?Ar(s[t]):void 0;if(r!==void 0&&r!==n){e=t;break}}if(e>=0){let t=s.splice(0,e+1);i.push({kind:`pinned`,items:t,startLine:t[0].loc.start.line,endLine:F(t).loc.end.line})}}e=s,s=[]}else c();let l=[...e,t],u={kind:`member`,member:t,key:r(t),items:l,startLine:l[0].loc.start.line,endLine:t.loc.end.line};i.push(u),o=u,a=t.loc.end.line}return c(),i}function Pr(t,n=()=>!0,r=Mr){let i=e(t)?0:t.key.loc.end.line;return Nr(t.items,i,n,r)}function Fr(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 Nr([...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 Ir(e,t){function n(e){if(a(e))return n(e.value);if(p(e)){for(let n of e.items)if(u(n)&&n.item===t)return n;for(let t of e.items){let e=n(u(t)?t.item:t);if(e)return e}}}return n(e)}function Lr(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 Rr(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=zr(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),Bt(i),n+=o.length}}function zr(e,t){let n=F(Pr(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 Q(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=zr(o,a);if(e)for(let t of e)V(n,o,t)}}if(e(i)||t(i)||r(i)){let e=Pr(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(jr(i)&&e(n)){let e=Lr(n,i);if(e){let t=Fr(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),V(n,i,a,e.items),H(n);return}}}V(n,i,a)}function Br(t,n,r,i){let s=!1;if(jr(n)&&e(t)){let e=Lr(t,n);if(e){let c=Fr(n,e.items);{let e=n.items,r=1;for(let n=1;n<e.length;n++)if(e[n].loc.start.line===e[n-1].loc.start.line){let i=R(t).get(e[n-1]),a=R(t).get(e[n]);if(i||a)continue;if(r++,r>=3){s=!0;break}}else r=1}let f=[],m,h,g,_=[],v=(e,t)=>{if(!p(e))return;let n=e.items;for(let e=0;e<n.length;e++){let r=n[e],i=r.loc.start.line>t;if(i&&_.push({node:r,start:b(r.loc.start),end:b(r.loc.end)}),r.loc.end.line>t&&r.loc.end.line>r.loc.start.line&&_.push({node:r,start:b(r.loc.start),end:b(r.loc.end),endOnly:!0}),u(r)){let e=r.item;if(i){let t=a(e)?e:void 0;_.push({node:e,start:b(e.loc.start),end:b(e.loc.end),equals:t?t.equals:void 0}),t&&(_.push({node:t.key,start:b(t.key.loc.start),end:b(t.key.loc.end)}),_.push({node:t.value,start:b(t.value.loc.start),end:b(t.value.loc.end)}))}e.loc.end.line>t&&e.loc.end.line>e.loc.start.line&&_.push({node:e,start:b(e.loc.start),end:b(e.loc.end),endOnly:!0}),v(e,t)}else p(r)&&v(r,t)}};for(let t of c){if(t.kind!==`member`||!t.member)continue;let n=t.items.filter(e=>e!==t.member);if(t.member===r&&(m=b(r.loc.start),h=b(r.loc.end),u(r)&&(g=b(r.item.loc.end)),v(u(r)?r.item:r,m.line),n.length&&(r.loc.start=b(t.items[0].loc.start),r.loc.end=b(F(t.items).loc.end))),n.length){f.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)}}}let y=n.items.indexOf(r),x=y===n.items.length-1,S=y>0?n.items[y-1]:void 0,C=i===0&&y>0&&r.loc.end.line>r.loc.start.line&&S!==void 0&&S.loc.start.line===r.loc.start.line;V(t,n,r,e.items);let w=!1;if(x&&S!==void 0&&r.loc.end.line>r.loc.start.line&&!Ut(n)&&R(t).get(S)&&(R(t).delete(S),w=!0),H(t),B(t,n,r,i,void 0,e.items),w){let e=R(t).get(r);e&&(e.lines=0,e.columns=0)}H(t),m&&h&&r.loc.end.line>r.loc.start.line&&(r.loc.end.column=h.column,u(r)&&g&&r.item.loc.end.line>r.item.loc.start.line&&(r.item.loc.end.column=g.column));for(let{node:e,start:t,end:n,endOnly:r,equals:i}of _){if(r){e.loc.end.column=n.column;continue}e.loc.start.column=t.column,e.loc.end.line===e.loc.start.line&&(e.loc.end.column=n.column),i!==void 0&&a(e)&&(e.equals=i)}for(let{owner:t,ownerOriginalStart:n,comments:i}of f){let a;t===r?(a={lines:r.loc.start.line-n.line,columns:r.loc.start.column-n.column},r.loc.start={line:m.line+a.lines,column:m.column+a.columns},r.loc.end={line:h.line+a.lines,column:h.column+a.columns}):a={lines:t.loc.start.line-n.line,columns:t.loc.start.column-n.column};for(let t of i){U(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)}}let T=n;if(s||C){let e=(t,n)=>{let r;for(let n of t.items){if(!r){r={line:n.loc.end.line,column:n.loc.end.column+2};continue}let t={lines:r.line-n.loc.start.line,columns:r.column-n.loc.start.column};if(t.lines!==0||t.columns!==0){U(n,t),n.loc.end.line>n.loc.start.line&&(n.loc.end.column-=t.columns,u(n)&&n.item.loc.end.line>n.item.loc.start.line&&(n.item.loc.end.column-=t.columns));let r=u(n)?a(n.item)?n.item.value:n.item:n;(d(r)||l(r))&&r.loc.end.line>r.loc.start.line&&e(r,n)}r={line:n.loc.end.line,column:n.loc.end.column+2}}r&&(t.loc.end={line:r.line,column:r.column-1},n&&n.loc.end.line===t.loc.end.line&&(n.loc.end.column=t.loc.end.column))},n;for(let t of T.items){if(t===r){n={line:r.loc.end.line,column:r.loc.end.column+2};continue}if(!n)continue;let i={lines:n.line-t.loc.start.line,columns:n.column-t.loc.start.column};if(i.lines!==0||i.columns!==0){U(t,i);let n=u(t)?a(t.item)?t.item.value:t.item:t;(d(n)||l(n))&&n.loc.end.line>n.loc.start.line&&e(n,u(t)?t:void 0)}let s=t.loc.end.line,c=u(t)?t.item:t;o(c)&&c.loc.end.line>c.loc.start.line&&(s=c.loc.start.line+c.raw.split(`
|
|
41
|
+
`).length-1,c.loc.end.line=s,t.loc.end.line=s),n={line:s,column:t.loc.end.column+2}}if(n){let e=b(T.loc.end);T.loc.end={line:n.line,column:n.column-1};let r=Ir(t,T);r&&(r.loc.end={line:T.loc.end.line,column:T.loc.end.column});let i={lines:T.loc.end.line-e.line,columns:T.loc.end.column-e.column};(i.lines!==0||i.columns!==0)&&kt(t,r??T,i)}}return}}let c=n,f=c.items,m=f[0],h=f[f.length-1],g=m.loc.start.column-c.loc.start.column-1,_=c.loc.end.column-1-h.loc.end.column;V(t,n,r),B(t,n,r,i),H(t);let v=c.items,y=v[0],x=y.loc.start.column-c.loc.start.column-1;x!==g&&U(y,{lines:0,columns:g-x});let S=v[v.length-1];c.loc.end.column-1-S.loc.end.column!==_&&(c.loc.end.column=S.loc.end.column+1+_)}function Vr(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`&&i.key!==void 0&&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:i.key!==void 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 Hr(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 Ur(e){return[...e.path,e.key].join(`.`)}function Wr(n,i,o){if(i.length===0)return{container:n};let s;try{s=Z(n,i)}catch{return}if(!s)return;if(a(s)&&(s=s.value),s&&m(s)&&(s=s.item),s&&(e(s)||t(s)||r(s)))return{container:s};if(o===void 0)return;let c=-1;for(let e=i.length-1;e>=0;e--)if(typeof i[e]==`number`){c=e;break}if(c<0)return;let l=i.slice(c+1);if(l.length===0||l.some(e=>typeof e!=`string`))return;let u=Z(n,i.slice(0,c+1));if(!u||!r(u))return;let d=[...l,o];return u.items.some(e=>a(e)&&e.key.value.length===d.length&&e.key.value.every((e,t)=>e===d[t]))?{container:u,dottedPrefix:l}:void 0}function Gr(t,n,r,i,o){let s=Vr(Pr(t,e=>r.has(e),o?e=>{if(!a(e))return;let t=e.key.value;if(t.length===o.length+1){for(let e=0;e<o.length;e++)if(t[e]!==o[e])return;return t[o.length]}}:void 0)),c=new Map;for(let e of s)e.kind===`member`&&e.movable&&e.key!==void 0&&c.set(e.key,e);let l=new Set(s.filter(e=>e.kind===`member`&&e.key!==void 0).map(e=>e.key));for(let e of n)e.key!==void 0&&l.has(e.key)&&!c.has(e.key)&&i.push(`"${Ur(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(c.size===0)return;let u=o?s.filter(e=>e.kind===`member`&&e.movable).map(e=>e.key):s.filter(e=>e.kind===`member`).map((e,t)=>e.movable?e.key:`\u0000anchor:${t}`),d=n.filter(e=>e.key!==void 0&&c.has(e.key));if(d.length===0)return;let f=Hr(u,d).filter(e=>c.has(e)),p=f.filter(e=>!c.get(e).isSection),m=f.filter(e=>c.get(e).isSection),h=!1;for(let e of f)if(c.get(e).isSection)h=!0;else if(h){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 g=0,_=0,v=s.map(e=>{if(e.kind!==`member`||!e.movable)return e;let t=e.isSection?m[_++]:p[g++];return c.get(t)});if(v.every((e,t)=>e===s[t]))return;let y=e(t)?1:t.key.loc.end.line,b=s.map((e,t)=>t===0?e.startLine-y:e.startLine-s[t-1].endLine-1),x=y;for(let e=0;e<v.length;e++){let t=v[e],n=b[e],r=(e===0?x:x+1)+n-t.startLine;if(r!==0)for(let e of t.items)U(e,{lines:r,columns:0});x=t.endLine+r}let S=v.flatMap(e=>e.items),C=t.items;C.splice(0,C.length,...S),Bt(t)}function Kr(e,t,n){if(t.length===0)return;Rr(e);let r=[],i=new Map;for(let n of t){var a;if(n.key===void 0)continue;let t=Wr(e,n.path,n.key);if(!t){r.push(`"${Ur(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 o=((a=t.dottedPrefix)==null?void 0:a.join(`\0`))??``,s=i.get(t.container);s||(s=new Map,i.set(t.container,s));let c=s.get(o);c?c.moves.push(n):s.set(o,{...t,moves:[n]})}for(let e of i.values())for(let t of e.values())Gr(t.container,t.moves,n,r,t.dottedPrefix);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(`
|
|
42
|
+
`))}Bt(e)}const qr=new WeakMap,Jr=new WeakMap;function Yr(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 Xr(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function Zr(e,t,n){Jr.has(e)||Jr.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 Qr(e,t){Jr.set(t,t.loc.start.column),qr.set(t,t.loc.start.column-e.loc.end.column)}function $r(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=Yr(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=[Xr(i,a,-1),Xr(i,a,1)],u;for(let e of l){if(e==null)continue;let t=Yr(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;Zr(o,u,f)}function ei(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Yr(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[Xr(r,i,-1),Xr(r,i,1)];for(let e of c){if(e==null)continue;let t=Yr(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){Zr(a,t.loc.start.column,n);return}}}function ti(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=Yr(r,i);a&&Qr(t,a)}function ni(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 ri(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&ri(i,n)}return n}function ii(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))&&ii(i,n)}return n}function ai(e){for(let n of e.items)(t(n)||r(n))&&ai(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 oi(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=ii(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=ri(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=Jr.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=Jr.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=>qr.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(qr.has(e))return qr.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 ai(e),s.join(r)+a}function si(e,t,n){let r=D(),i=Array.from(P(Tn(e),r)),a=G(n,K.autoDetectFormatWithCst(e,i));if(r.mixed){let e=a.newLine===`\r
|
|
43
|
+
`?`CRLF`:`LF`;console.warn(`toml-patch: Mixed line endings detected. Line endings in the output will be normalized to ${e}`)}let o=pi(i,t,a).tomlString;return a.leadingBom?`${o}`:o}function ci(e,t=new WeakSet){if(typeof e!=`object`||!e)return!1;if(ot(e))return!0;if(t.has(e))return!1;t.add(e);for(let n of Object.values(e))if(ci(n,t))return!0;return!1}function li(e,t,n){let r=e.slice(n),i=0,a=Math.min(r.length,t.length);for(let e=1;e<=a;e++)L(r.slice(r.length-e),t.slice(0,e))&&(i=e);return i}function ui(e){let t=new WeakSet,n=e=>{t.add(e)};return bt(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 di(e,t,n,r){if(!I(t))return t;let i=J(q(e,G({...n,inlineTableStart:0},n)).items,``,{temporal:r});if(!I(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 fi(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(L(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);Bt(i)}}}}}function pi(e,t,n){let r=[...e],i=ci(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=G({...n,inlineTableStart:l},n),d=q(t,u),f=J(d.items,``,{temporal:i}),p=n.updateOrder?di(t,f,u,i):f,m=mi(hi(c,p,_r(s,p,[],{updateOrder:n.updateOrder})));if(m.length===0)return{tomlString:Qn(r,n),document:c};let h=vi(c,d,m,n,i,ui(c),t);return{tomlString:oi(h,Qn(h.items,n),n),document:h}}function mi(e){for(let t=0;t<e.length;t++){let n=e[t];if(mr(n)){let r=F(n.path),i=n.path.slice(0,-1),a=t+1;for(;a<e.length;){let n=e[a];if(fr(n)){if(typeof F(n.path)==`number`&&L(i,n.path.slice(0,-1)))break;a++;continue}if(hr(n)&&n.key===void 0){if(L(i,n.path))break;a++;continue}if(!mr(n)){a++;continue}let o=F(n.path),s=n.path.slice(0,-1);if(typeof r==`number`&&typeof o==`number`&&L(i,s)&&o>r){e.splice(a,1),e.splice(t,0,n),t=-1;break}a++}}}return e}function hi(e,t,n){let i=new Set,a=[],o=new Map;for(let e of n){if(!mr(e)&&!fr(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)),(mr(e)?r.removes:r.adds).push(e)}for(let t of o.values())t.removes.length!==0&&t.adds.length!==0&&(Z(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)||!pr(t)&&!fr(t)&&!mr(t)||typeof F(t.path)!=`number`)continue;let n=t.path.slice(0,-1);if(n.length===0)continue;let a=Z(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=>I(e)))continue;let o=n.filter(t=>!i.has(t)&&(pr(t)||fr(t)||mr(t))&&t.path.length>e.length&&L(t.path.slice(0,e.length),e));if(!(o.length<2)){for(let e of o)i.add(e);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 gi(e,t){return t.map(t=>T.test(t)?t:`"${Qt(t,e,`singleline-basic`)}"`).join(`.`)}function _i(e,t){if(o(e)&&o(t)){let n=cn(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(ot(r)){let e=st(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 if(!(fe.IS_TIME_ONLY.test(n)&&r instanceof Date&&r.getUTCFullYear()>1)){let e=fe.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=In(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma!==n&&(e.comma=n,n&&(t.loc.end.column+=1))}}if(d(e)&&d(t)){let n=Ln(e);if(t.items.length>0){let e=t.items[t.items.length-1];e.comma!==n&&(e.comma=n,n&&(t.loc.end.column+=1))}}}function vi(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 WeakMap;function S(e){let i=x.get(e);if(i!==void 0)return i;let o={};function s(n,i){if(n===e)return i;if(a(n))return s(n.value,i);if(u(n))return s(n.item,i);if(p(n))for(let e=0;e<n.items.length;e++){let c=n.items[e],l=[];if(a(c))l=c.key.value;else if(t(c)||r(c)){if(l=c.key.item.value,r(c)){let e=ht(l);o[e]=(o[e]??-1)+1,l=l.concat(o[e])}}else u(c)&&(l=a(c.item)?c.item.key.value:[e]);let d=s(c,l.length?i.concat(l):i);if(d)return d}}let c=s(n,[]);return c!==void 0&&x.set(e,c),c}function C(e,t){let n=a(e)?e:u(e)&&a(e.item)?e.item:void 0;if(!n)return!1;let r=n.key.value.length;return r>t.length||!L(n.key.value,t.slice(t.length-r))}function w(e,i){let o=e.key.item.value.concat(i);return e.items.some(e=>a(e)&&e.key.value.length>i.length&&L(e.key.value.slice(0,i.length),i))?!0:n.items.some(e=>{if(!t(e)&&!r(e))return!1;let n=e.key.item.value;return n.length>o.length&&L(n.slice(0,o.length),o)})}function E(e,t){let n=[],r=!1;for(let i of e.items){if(!a(i)||!d(i.value)||!w(t,i.key.value)){n.push(i);continue}let e=[];for(let t of i.value.items){if(!u(t)||!a(t.item))continue;let n=J([t.item],``,{temporal:c});for(let e of t.item.key.value)n=n==null?void 0:n[e];let r=Mi(n,s);r!==void 0&&e.push(rn(i.key.value.concat(t.item.key.value),r))}e.length>0?(n.push(...e),r=!0):n.push(i)}if(!r)return e;let i=tn(e.key.item.value);for(let e of n)B(i,i,e);return H(i),i}function D(e,t){function n(e){if(a(e))return n(e.value);if(u(e))return n(e.item);if(!p(e))return;let r=e.items;for(let n of r)if(n===t||u(n)&&n.item===t)return e;for(let e of r){let t=n(u(e)?e.item:e);if(t)return t}}return n(e)}function O(e,t,r,i){let a=t.concat(e.key.value),o=e.key.raw;e.key.value=a,e.key.raw=a.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`);let s=e.key.raw.length-o.length;e.key.loc.end.column=e.key.loc.start.column+e.key.raw.length,e.equals+=s,U(e.value,{lines:0,columns:s},{first_line_only:!0}),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=s),z(n,i,r,e),xi(n,e)}function k(e,t){let n=e.key.item,r=n.raw,i=t.concat(n.value),a=i.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),o=a.length-r.length;n.value=i,n.raw=a,n.loc.end.column=n.loc.start.column+a.length,e.key.loc.end.line===e.key.loc.start.line&&(e.key.loc.end.column+=o)}function A(e,t,r,i){k(e,t),z(n,i,r,e)}function j(e,t,r){let i=Z(n,e);if(i&&!C(i,e))return null;let a=e.length;for(;a>0;){let t=Z(n,e.slice(0,a));if(t&&!C(t,e.slice(0,a)))break;a--}let o=e.slice(a);if(o.length===0||!o.every(e=>typeof e==`string`))return null;if(_!==void 0){let e=_;for(let t of r)e=e==null?void 0:e[t];if(e!==void 0){let n=Mi(e,s);if(n!==void 0)return rn([...o,...t.key.value],n)}}let c=t.key,l=[...o,...c.value].map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),u=l.length-c.raw.length;return c.raw=l,c.value=[...o,...c.value],c.loc.end.column=c.loc.start.column+l.length,t.equals+=u,U(t.value,{lines:0,columns:u},{first_line_only:!0}),t.loc.end.line===t.loc.start.line&&(t.loc.end.column+=u),t}let M=new Set,ee=new Set,te=[];o.forEach(o=>{if(fr(o)){var x;let f=X(i,o.path),m=o.path.slice(0,-1),h=F(o.path),g=r(f);if(et(h)&&!g&&!et(F(m))){let e=Z(n,m.concat(0));e&&r(e)&&(g=!0)}if(g&&et(h)&&!et(F(m))){let e=Z(n,m),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=J(i.items,``,{temporal:c});for(let t of o.path)e=e==null?void 0:e[t];let r=G({...s,inlineTableStart:0},s),l=e===void 0?void 0:q({tmp:e},r),p=l==null?void 0:l.items[0];if(p&&a(p)&&(f=xn(p.value),g=!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&&Vt(n,e,!0)}}}}if(g&&!r(f)){let e=m.filter(e=>typeof e==`string`),n=J(i.items,``,{temporal:c});for(let e of o.path)n=n==null?void 0:n[e];if(n!==void 0){let i=tn(e),a=q(n,s);for(let e of a.items)B(i,i,e,void 0);let o=n=>{if(p(n))for(let i of n.items){if(!t(i)&&!r(i))continue;let n=i.key,a=n.item,s=e.concat(a.value);a.value=s,a.raw=sn(s).raw,a.loc.start.column=n.loc.start.column+1,a.loc.end.column=a.loc.start.column+a.raw.length,n.loc.end.column=a.loc.start.column+a.raw.length+1,o(i)}};o(i),H(i),f=i}}let _;if(t(f))_=n;else if(g){_=n;let e=n,i=Z(e,m.concat(h-1)),a=Z(e,m.concat(h));if(a)h=e.items.indexOf(a);else if(i){if(h=e.items.indexOf(i)+1,r(i)){let n=i.key.item.value,a=h-1;for(let i=h;i<e.items.length;i++){let o=e.items[i],s=t(o)||r(o)?o.key.item.value:void 0;s&&s.length>n.length&&L(s.slice(0,n.length),n)&&(a=i)}h=a+1,r(f)&&(f=E(f,i))}}else h=e.items.length}else{_=n;for(let e=o.path.length-1;e>=0;e--){let t=Z(n,o.path.slice(0,e));if(t&&!C(t,o.path.slice(0,e))){_=t;break}}a(_)?_=_.value:u(_)&&a(_.item)?_=_.item.value:(u(_)&&d(_.item)||u(_)&&l(_.item))&&(_=_.item)}if(l(_)){let e=Z(n,m),t=Z(n,m.slice(0,-1));if(e&&a(e)&&t){let n=ni(_,f,h);n!==0&&ei(t,e,n)}}let v=(l(_)||d(_))&&_.loc.end.line>_.loc.start.line;v&&ee.has(_)&&H(n);let y=l(_)||d(_)?(x=Lr(n,_))==null?void 0:x.items:void 0;if(r(_)||l(_)||e(_)){if(l(_)){let e=In(_);if(u(f)){f.comma=e;let t=f,n=d(t.item)?t.item:void 0,r=n&&n.items.length>0?_.items.map(e=>e.item).find(e=>e!==t.item&&d(e)):void 0;if(n&&r){let e=Ln(r);if(e!==Ln(n)){let n=J(i.items,``,{temporal:c});for(let e of o.path)n=n==null?void 0:n[e];let r=G({...s,inlineTableStart:0,trailingComma:e},s),l=n===void 0?void 0:q({tmp:n},r).items[0];if(l&&a(l)){let e=xn(l.value);e.comma=t.comma,f=e}}}}}if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&e(_)&&t(f)){let e=Ai(f,n,s);B(n,_,f,h);for(let t of e)B(n,n,t,void 0)}else{let i=f;u(f)&&(r(_)||e(_))&&(i=f.item);let s=h;if(e(_)&&a(i)){let e=_.items.findIndex(e=>t(e)||r(e));e!==-1&&(s=e)}let c=!1;if((r(_)||e(_))&&a(i)){let e=j(m,i,o.path);e&&(M.has(_)&&H(n),i=e,c=!0)}l(_)&&_.items.length===0&&H(n),s===0&&l(_)&&Nt(n).has(_)&&H(n),s===0&&(e(_)||t(_)||r(_))&&Nt(n).has(_)&&H(n),B(n,_,i,s,void 0,y),c&&M.add(_)}}else if(d(_)){_.items.length===0&&(H(n),Dt(_)&&_.loc.end.line>_.loc.start.line&&(_.loc.end.line=_.loc.start.line));let e=Ln(_);if(a(f)){let t=xn(f);t.comma=e,B(n,_,t,void 0,void 0,y)}else if(u(f)&&a(f.item)){let t=f.item,r=j(m,t,o.path);r&&(M.has(_)&&H(n),t=r);let i=xn(t);i.comma=e,B(n,_,i,void 0,void 0,y),r&&M.add(_)}else B(n,_,f,void 0,void 0,y)}else if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&a(f)&&d(f.value)&&t(_))Hn([..._.key.item.value,...f.key.value])<s.inlineTableStart?ji(f,_,n,s):B(n,_,f);else if(s.inlineTableStart===0&&a(f)&&d(f.value)&&e(_))B(n,_,f,void 0,!0);else{let i=f;u(f)&&(t(_)||r(_)||e(_))&&(i=f.item);let s=!1;if(t(_)&&a(i)){let e=j(m,i,o.path);e&&(M.has(_)&&H(n),i=e,s=!0)}B(n,_,i),s&&M.add(_)}v&&ee.add(_)}else if(pr(o)){let f=Z(n,o.path),m;try{m=X(i,o.path)}catch{m=void 0}if(!f||!m){Ci(n,i,o,s,c,h,y);return}if(a(f)&&t(m)){let e=m.key.item.value;if($(n,e).some(e=>e!==f)){Ci(n,i,o,s,c,h,y);return}}if(u(f)&&(t(m)||r(m))){let e=Z(n,o.path.slice(0,-1)),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=_;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=G({...s,inlineTableStart:0},s),n=q({tmp:e},t),r=n==null?void 0:n.items[0];r&&a(r)&&(m=xn(r.value))}}}let v,b=Z(n,o.path.slice(0,-1));b&&a(b)&&C(b,o.path.slice(0,-1))&&(b=D(n,b));let x=Ni(n,o.path);if(a(f)&&a(m)){let i=!1;if(f.key.value.length>1){let s=S(f),c=li(o.path,f.key.value,s?s.length-f.key.value.length:0);if(c>0&&c<f.key.value.length){f.key.value=f.key.value.slice(0,c),f.key.raw=sn(f.key.value).raw;let o=f.key.loc.end.column,s=f.key.loc.start.column+f.key.raw.length,l=s-o;f.key.loc.end.column=s,f.equals+=l,f.value.loc.start.column+=l,f.value.loc.end.line===f.value.loc.start.line&&(f.value.loc.end.column+=l),f.loc.end.line===f.loc.start.line&&(f.loc.end.column+=l),i=!0;let u=f.key.value;if(b&&(t(b)||e(b)||r(b))){let e=[...b.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===f)continue;let s=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=u.length&&L(s.slice(0,u.length),u)&&Q(n,b,o)}}}}if(!i&&a(m)&&b&&(t(b)||e(b)||r(b))&&Fi(n,b,f.key.value,f),_i(f.value,m.value),b&&$r(b,f,f.value,m.value),v=f,f=f.value,m=m.value,i&&_!==void 0){let e=_;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Mi(e,s);t!==void 0&&(m=t,_i(f,m))}}}else if(a(f)&&u(m)&&a(m.item)){let i=!1;if(f.key.value.length>1){let s=S(f),c=li(o.path,f.key.value,s?s.length-f.key.value.length:0);if(c>0&&c<f.key.value.length){f.key.value=f.key.value.slice(0,c),f.key.raw=sn(f.key.value).raw;let o=f.key.loc.end.column,s=f.key.loc.start.column+f.key.raw.length,l=s-o;f.key.loc.end.column=s,f.equals+=l,f.value.loc.start.column+=l,f.value.loc.end.line===f.value.loc.start.line&&(f.value.loc.end.column+=l),f.loc.end.line===f.loc.start.line&&(f.loc.end.column+=l),i=!0;let u=f.key.value;if(b&&(t(b)||e(b)||r(b))){let e=[...b.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===f)continue;let s=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=u.length&&L(s.slice(0,u.length),u)&&Q(n,b,o)}}}}if(!i&&a(m.item)&&b&&(t(b)||e(b)||r(b))&&Fi(n,b,f.key.value,f),v=f,f=f.value,m=m.item.value,i&&_!==void 0){let e=_;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Mi(e,s);t!==void 0&&(m=t)}}}else if(u(f)&&a(f.item)&&a(m)){let e=f.item,i=!1;if(e.key.value.length>1){let s=S(e),c=li(o.path,e.key.value,s?s.length-e.key.value.length:0);if(c>0&&c<e.key.value.length){e.key.value=e.key.value.slice(0,c),e.key.raw=sn(e.key.value).raw;let o=e.key.loc.end.column,s=e.key.loc.start.column+e.key.raw.length,l=s-o;e.key.loc.end.column=s,e.equals+=l,e.value.loc.start.column+=l,e.value.loc.end.line===e.value.loc.start.line&&(e.value.loc.end.column+=l),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=l),e.loc.end.line===e.loc.start.line&&kt(n,e,{lines:0,columns:l}),i=!0;let d=e.key.value,m=b;if(m&&u(m)&&(m=m.item),m&&a(m)&&(m=m.value),m&&p(m)){let e=[...m.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===f)continue;let s=a(o)?o.key.value:u(o)&&a(o.item)?o.item.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=d.length&&L(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(_i(e.value,m.value),v=e,f=e.value,m=m.value,i&&_!==void 0){let e=_;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Mi(e,s);t!==void 0&&(m=t,_i(f,m))}}}else if(u(f)&&u(m)&&a(f.item)&&a(m.item)){let e=!1,i=f.item;if(i.key.value.length>1){let s=S(i),c=li(o.path,i.key.value,s?s.length-i.key.value.length:0);if(c>0&&c<i.key.value.length){i.key.value=i.key.value.slice(0,c),i.key.raw=sn(i.key.value).raw;let o=i.key.loc.end.column,s=i.key.loc.start.column+i.key.raw.length,l=s-o;i.key.loc.end.column=s,i.equals+=l,i.value.loc.start.column+=l,i.value.loc.end.line===i.value.loc.start.line&&(i.value.loc.end.column+=l),i.loc.end.line===i.loc.start.line&&(i.loc.end.column+=l),i.loc.end.line===i.loc.start.line&&kt(n,i,{lines:0,columns:l}),e=!0;let d=i.key.value,m=b;if(m&&u(m)&&(m=m.item),m&&a(m)&&(m=m.value),m&&p(m)){let e=[...m.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===f)continue;let s=a(o)?o.key.value:u(o)&&a(o.item)?o.item.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=d.length&&L(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(_i(i.value,m.item.value),v=i,f=i.value,m=m.item.value,e&&_!==void 0){let e=_;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Mi(e,s);t!==void 0&&(m=t,_i(f,m))}}}else if(t(f)){let l=J(i.items,``,{temporal:c});for(let e of o.path)l=l==null?void 0:l[e];if(l!==void 0){let i=f.key.item.value,c=i.slice(-1),u=i.slice(0,-1),d=D(n,f)??xr(n,o.path);if(e(d)){let e=$(n,i).filter(e=>e!==f&&(t(e)||r(e)));for(let t of e)Q(n,d,t)}let p=q({[c[0]]:l},s),m=p.items[0];if(u.length>0)if(t(m)||r(m))A(m,u,f,d),h.add(m);else if($(n,u).some(a))O(m,u,f,d),h.add(m);else{let e=n.items.find(e=>e!==f&&(t(e)||r(e))&&L(e.key.item.value,u));if(e)B(n,e,m,void 0),Q(n,d,f),h.add(m);else{let e=W(u);y.add(e),B(n,e,m,0),z(n,d,f,e),h.add(e)}}else z(n,d,f,m),h.add(m),xi(n,m);if(p.items.length>1)for(let e=1;e<p.items.length;e++){let t=p.items[e];u.length>0&&k(t,u);let r=e===1?m:p.items[e-1];B(n,d,t,d.items.indexOf(r)+1),h.add(t)}return}v=xr(n,o.path)}else if(r(f)){let l=J(i.items,``,{temporal:c}),u=f.key.item.value,d=l,p=typeof o.path[o.path.length-1]==`number`?o.path.slice(0,-1):o.path;for(let e of p)d=d==null?void 0:d[e];if(d!==void 0){let i=u.slice(-1),c=u.slice(0,-1),l=D(n,f)??xr(n,o.path),p=q({[i[0]]:d},s).items[0];if(Array.isArray(d)&&!d.every(e=>I(e))){let e=$(n,u).filter(e=>e!==f&&(t(e)||r(e)));for(let t of e)Q(n,n,t)}if(c.length>0)if(t(p)||r(p))A(p,c,f,l),h.add(p);else{let r=e(l)?l.items.find(e=>t(e)&&L(e.key.item.value,c)):void 0;if(r){let e=r.items.find(e=>a(e)&&L(e.key.value,p.key.value));e?z(n,r,e,p):B(n,r,p,void 0),Q(n,l,f),h.add(r);return}if($(n,c).some(a))O(p,c,f,l),h.add(p);else{let e=W(c);y.add(e),B(n,e,p,0),z(n,l,f,e),h.add(e)}}else z(n,l,f,p),h.add(p),xi(n,p);return}v=xr(n,o.path)}else if(v=xr(n,o.path),a(v)){let e=X(n,o.path.slice(0,-1));a(e)&&l(e.value)&&(v=e.value)}else u(v)&&a(v.item)?v=v.item.value:(u(v)&&d(v.item)||u(v)&&l(v.item))&&(v=v.item);if(u(f)&&u(m)&&(m.comma=f.comma),x){let e=g(f.loc),t=g(m.loc).columns-e.columns;t!==0&&ti(x.container,x.row,t)}z(n,v,f,m),e(v)&&a(f)&&(t(m)||r(m))&&Si(n,m)}else if(mr(o)){let c=Z(n,o.path);if(c){let f=xr(n,o.path);if(f===c&&(f=xr(n,o.path.slice(0,-1))),f===c){let e=Lr(n,c);e&&(f=e)}a(f)&&(f=f.value),u(f)&&a(f.item)&&(f=f.item.value),u(f)&&d(f.item)&&(f=f.item),u(f)&&l(f.item)&&(f=f.item),(!p(f)||!f.items.includes(c))&&(f=D(n,c)??(p(f)?n:Lr(n,c)??n));let h=!1;if(o.path.length>1&&t(c)&&_!==void 0){let e=o.path.slice(0,-1),t=c.key.item.value.slice(0,-1);if($(n,t).filter(e=>e!==c).length===0){let r=_;for(let t of e)r=r==null?void 0:r[t];if(I(r)&&Object.keys(r).length===0){let e=c;for(;e.items.length>0;)V(n,e,F(e.items));H(n);let r=e.key,i=m(r)?r.item:r;i.value=t,i.raw=gi(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,e.loc.end.line=r.loc.end.line,e.loc.end.column=r.loc.end.column,b(e),h=!0}}}let g=e(f)&&p(f)?f.items.indexOf(c):-1,x=p(f)&&!e(f)?f.items.indexOf(c):-1,C=u(c)?c.comma:void 0,w=u(c)&&(l(f)||d(f))&&c.loc.end.line===f.loc.end.line?f.loc.end.column-c.loc.end.column:void 0,E=S(u(c)&&a(c.item)?c.item:c),O=a(c)?c:u(c)&&a(c.item)?c.item:void 0;if(O&&E&&p(f)){let e=E.length-O.key.value.length,i=o.path.slice(e);if(i.length>0&&i.length<O.key.value.length){let e=f.items,o=[];for(let n of e){if(n===c)continue;let e=a(n)?n.key.value:u(n)&&a(n.item)?n.item.key.value:t(n)||r(n)?n.key.item.value:void 0;e&&e.length>i.length&&L(e.slice(0,i.length),i)&&o.push(n)}for(let e of o)Q(n,f,e)}}if(O&&E&&p(f)){let e=O.key.value,i=f.items,o=[];for(let n of i){if(n===c)continue;let i=a(n)?n.key.value:u(n)&&a(n.item)?n.item.key.value:t(n)||r(n)?n.key.item.value:void 0;i&&i.length>e.length&&L(i.slice(0,e.length),e)&&o.push(n)}for(let e of o)Q(n,f,e)}if((t(c)||r(c))&&p(f)){let e=c.key.item.value,i=f.items,o=[];for(let n of i){if(n===c)continue;let i=a(n)?n.key.value:t(n)||r(n)?n.key.item.value:void 0;i&&i.length>e.length&&L(i.slice(0,e.length),e)&&o.push(n)}for(let e of o)Q(n,f,e)}if(h||Q(n,f,c),u(c)&&(l(f)||d(f))&&c.loc.end.line===f.loc.end.line){let e=f.items,t=f.loc.end.line===f.loc.start.line?e.every(e=>e.loc.end.line===f.loc.start.line):e.length>0&&F(e).loc.end.line===f.loc.end.line;if(e.length>0&&x===e.length&&t){let t=w??f.loc.end.column-c.loc.end.column;H(n);let r=F(e).loc.end.column+t;f.loc.end.column!==r&&(f.loc.end.column=r);let i,o=e=>{if(a(e))return e.value===f?e:o(e.value);if(u(e))return o(e.item);if(p(e))for(let t of e.items){let e=o(u(t)?t.item:t);if(e)return e}};if(i=o(n),i&&i.loc.end.line===f.loc.end.line){i.loc.end.column=f.loc.end.column;let e=t=>{if(a(t))return e(t.value);if(u(t))return t.item===i?t:e(t.item);if(p(t))for(let n of t.items){let t=e(n);if(t)return t}},t=e(n);if(t){let e=f.loc.end.column-t.loc.end.column;t.loc.end.column=f.loc.end.column,e!==0&&(kt(n,t,{lines:0,columns:e}),At(n),H(n))}}}}if(!h&&o.path.length>1&&(t(c)||r(c))&&_!==void 0){let e=o.path.slice(0,-1),t=c.key.item.value.slice(0,-1);if($(n,t).length===0){let r=_;for(let t of e)r=r==null?void 0:r[t];if(I(r)&&Object.keys(r).length===0){let e=W(t);y.add(e);let r=g>=0?Math.min(g,n.items.length):n.items.length;H(n),B(n,n,e,r)}}}if(!h&&o.path.length>1&&_!==void 0){let i=a(c)?c:u(c)&&a(c.item)?c.item:void 0;if(i&&i.key.value.length>1){let c=o.path.slice(0,-1),l=e(f)||t(f)||r(f)||d(f)?f:n;if(p(l)){let o;if(t(l)||r(l)){let e=l.key.item.value,t=0,n=0;for(let r=0;r<e.length&&t<c.length;r++){for(;t<c.length&&typeof c[t]==`number`;)t++;if(t>=c.length||c[t]!==e[r])break;n++,t++}for(;t<c.length&&typeof c[t]==`number`;)t++;o=n===e.length?c.slice(t):c.slice(e.length+ +!!r(l))}else if(d(l))if(E){let e=E.slice(0,E.length-i.key.value.length),t=0,n=0;for(;n<e.length&&t<c.length;){for(;t<c.length&&typeof c[t]==`number`;)t++;if(t>=c.length||c[t]!==e[n])break;n++,t++}for(;t<c.length&&typeof c[t]==`number`;)t++;o=n===e.length?c.slice(t):c.slice(e.length)}else o=c.slice(c.length-(i.key.value.length-1));else o=c;o=o.filter(e=>typeof e==`string`);let f=l.items.filter(e=>{let t=a(e)?e.key.value:u(e)&&a(e.item)?e.item.key.value:void 0;return t?L(t.slice(0,o.length),o):!1}),p=r(l),m=[];p&&f.length===0&&(m=$(n,l.key.item.value.concat(o)));let h=o.length===0&&(t(l)||r(l)||d(l));if(f.length===0&&m.length===0&&!h){let r=_;for(let e of c)r=r==null?void 0:r[e];if(I(r)&&Object.keys(r).length===0){if(d(l)){let e=o.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),t=Array.from(P(`${e} = {}`))[0];if(a(t)){let e=xn(t);e.comma=C??!1,H(n),Dt(l)&&l.loc.end.line>l.loc.start.line&&(l.loc.end.line=l.loc.start.line),B(n,l,e,x>=0?x:void 0),s.bracketSpacing&&U(e,{lines:0,columns:1});let r=l.items[x+1],i=R(n).get(e);r&&i&&r.loc.start.line===e.loc.end.line&&(i.columns=e.loc.end.column+2-r.loc.start.column)}return}let r=W(p||t(l)?l.key.item.value.concat(o):o);y.add(r);let i=g>=0?g:n.items.length;if(p){let e=n.items.indexOf(l);i=e>=0?e+1:n.items.length}else if(t(l)){let e=n.items.indexOf(l);i=e>=0?e+1:n.items.length}else if(e(l)){let e=yi(n);i=e>=0?e:n.items.length}H(n),B(n,n,r,i)}}}}}if(r(c)){let e=c.key.item.value,t=o.path.slice(0,-1);!Z(n,t.concat(0))&&Z(i,t)&&v.set(e.join(`.`),e)}}else{let e=()=>Z(n,o.path.concat(0))||$(n,o.path).filter(r)[0],a=e();if(a){let s=n.items.indexOf(a),c=!1;if(o.path.length>1&&_!==void 0){let e=o.path.slice(0,-1);if($(n,e).filter(e=>!(r(e)&&L(e.key.item.value,o.path))).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(I(t)&&Object.keys(t).length===0){let t=a,r=t.key;for(;t.items.length>0;)Q(n,t,F(t.items));H(n),t.type=`Table`,r.type=`TableKey`;let i=m(r)?r.item:r;i.value=e,i.raw=gi(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),c=!0}}}let l;for(;l=e();)Q(n,n,l);for(let e of $(n,o.path).filter(t))Q(n,n,e);if(Z(i,o.path)){let e=o.path;v.set(e.join(`.`),e)}if(!c&&o.path.length>1&&_!==void 0){let e=o.path.slice(0,-1);if($(n,e).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(I(t)&&Object.keys(t).length===0){let t=W(e);y.add(t);let r=s>=0?Math.min(s,n.items.length):n.items.length;H(n),B(n,n,t,r)}}}}else{let e=Pi(n,o.path),t=$(n,e);if(t.length>0){let r=n.items.indexOf(t[0]);for(let e of t)Q(n,n,e);if(e.length>1&&_!==void 0){let t=e.slice(0,-1);if($(n,t).length===0){let e=_;for(let t of o.path.slice(0,-1))e=e==null?void 0:e[t];if(I(e)&&Object.keys(e).length===0){let e=W(t);y.add(e);let i=r>=0?Math.min(r,n.items.length):n.items.length;H(n),B(n,n,e,i)}}}}else X(n,o.path)}}}else if(hr(o)){if(o.key!==void 0){te.push(o);return}let e=Z(n,o.path);if(e){if(m(e)&&(e=e.item),a(e)&&(e=e.value),o.from>=e.items.length)return;let t=e.items[o.from];Br(n,e,t,o.to)}else{fi(n);let e=X(n,o.path.concat(o.from)),i=Pr(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=Z(n,o.path.concat(o.to)),m,h=!1,g=i&&i.items[0]!==e&&f(i.items[0]);if(p){let e=Pr(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){H(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++)U(n.items[e],{lines:i,columns:0})}}}}else if(gr(o)){let e=o.path.concat(o.from),s=Z(n,e);if(!s){let i=$(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=gi(n.raw,n.value),n.loc.end.column=n.loc.start.column+n.raw.length;return}}s||=X(n,e);let c=X(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)&&L(d.value.slice(0,e.length),e)){let t=e.length-1;d.value[t]=o.to,d.raw=gi(d.raw,d.value),d.loc.end.column=d.loc.start.column+d.raw.length;return}if(a(s)&&a(c)&&d.value.length<=e.length&&L(d.value,e.slice(e.length-d.value.length))){let e=d.raw;d.value[d.value.length-1]=o.to,d.raw=gi(d.raw,d.value),d.loc.end.column=d.loc.start.column+d.raw.length;let t=d.raw.length-e.length;t>0&&(s.equals+=t,U(s.value,{lines:0,columns:t},{first_line_only:!0}),kt(n,s.value,{lines:0,columns:t}));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=gi(d.raw,f.value),f.loc.end.column=f.loc.start.column+f.raw.length,z(n,m(l)?l:s,d,f)}}),H(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&&U(i,{lines:-e,columns:0})}}let ne=n.items;for(let e=0;e<ne.length-1;e++){let n=ne[e],i=ne[e+1];if((t(n)||r(n))&&n.items.length===0&&(t(i)||r(i))){let t=i.loc.start.line-n.loc.end.line-1;if(t>1){let n=1-t;for(let t=e+1;t<ne.length;t++)U(ne[t],{lines:n,columns:0})}}}let re=!1;bt(n,{InlineTable:e=>{Dt(e)&&(re=!0)},InlineArray:e=>{Dt(e)&&(re=!0)}}),re&&H(n);let ie=!1,ae=[];if(bt(n,{InlineTable:e=>{Dt(e)&&(ae.push(e),wi(e),Ot(e),Vt(n,e,s.bracketSpacing),ie=!0)},InlineArray:e=>{Dt(e)&&(wi(e),Ot(e),Vt(n,e,s.bracketSpacing),ie=!0)}}),ie){H(n);for(let e of ae)Ti(n,e);Ei(n)}return Oi(n),ki(n,v,s),Kr(n,te,h),n}function yi(e){return e.items.findIndex(e=>t(e)||r(e))}function bi(e){let t=yi(e);return t===-1?void 0:t}function xi(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=yi(e);r===-1||r>n||(V(e,e,t),H(e),B(e,e,t,r))}function Si(e,n){let i=e.items.indexOf(n);if(i<0)return;let o=e.items.findIndex((e,n)=>n>i&&(t(e)||r(e)));if(!e.items.some((e,t)=>t>i&&a(e)&&(o===-1||t<o)))return;let s=o===-1?e.items.length:o;H(e),V(e,e,n),B(e,e,n,s-1)}function Ci(e,n,i,o,s,c,l){let f=J(n.items,``,{temporal:s});for(let e of i.path)f=f==null?void 0:f[e];if(f===void 0)return;{let n=i.path.findIndex(e=>typeof e==`number`);if(n>0&&i.path.slice(n+1).every(e=>typeof e==`string`)){let s=Z(e,i.path.slice(0,n+1));if(s&&r(s)){let r=s.key.item.value,c=i.path.slice(n+1),l=$(e,r.concat(c));for(let t of l)Q(e,e,t);let u=s.items.filter(e=>{let t=a(e)?e.key.value:void 0;return t&&t.length>c.length&&L(t.slice(0,c.length),c)});for(let t of u)Q(e,s,t);let d=f;for(let e=i.path.length-1;e>n;e--)d={[i.path[e]]:d};let p=Qn(q(d,o).items,o),m=Array.from(P(p)),h=t=>{let n=s.items.find(e=>a(e)&&L(e.key.value,t.key.value));n?z(e,s,n,t):B(e,s,t,void 0)};for(let e of m){if(a(e)){h(e);continue}if(t(e)){let t=e.key.item.value;for(let n of e.items){if(!a(n))continue;let e=n.key.raw,r=t.concat(n.key.value);n.key.value=r,n.key.raw=sn(r).raw;let i=n.key.raw.length-e.length;n.key.loc.end.column=n.key.loc.start.column+n.key.raw.length,n.equals+=i,U(n.value,{lines:0,columns:i},{first_line_only:!0}),n.loc.end.line===n.loc.start.line&&(n.loc.end.column+=i),h(n)}}}return}}}let p=f;for(let e=i.path.length-1;e>=0;e--)p={[i.path[e]]:p};let m=$(e,i.path);for(let t of m)V(e,e,t);let h=Qn(q(p,o).items,o),g=Array.from(P(h)),_=bi(e);_!==void 0&&H(e);let v;for(let n=0;n<g.length;n++){let i=g[n],o=t(i)?e.items.find(e=>t(e)&&L(e.key.item.value,i.key.item.value)):void 0;if(o){for(let t of i.items)B(e,o,t,void 0);v||=o;continue}if(a(i)&&d(i.value)){let o=i.key.value,s=e.items.find(e=>t(e)&&L(e.key.item.value,o));if(s){for(let t of i.value.items)B(e,s,u(t)?t.item:t,void 0);v||=s;continue}if($(e,o).filter(e=>a(e)||t(e)||r(e)).length>0){for(let t of i.value.items){let r=u(t)?t.item:t;if(a(r)){let e=r.key.raw,t=o.concat(r.key.value);r.key.value=t,r.key.raw=t.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`);let n=r.key.raw.length-e.length;r.key.loc.end.column=r.key.loc.start.column+r.key.raw.length,r.equals+=n,U(r.value,{lines:0,columns:n},{first_line_only:!0}),r.loc.end.line===r.loc.start.line&&(r.loc.end.column+=n)}B(e,e,r,n===0?_:void 0),v||=r}continue}}if(t(i)){let t=i.key.item.value;if($(e,t).filter(e=>a(e)).length>0){for(let r of i.items){if(a(r)){let e=r.key.raw,n=t.concat(r.key.value);r.key.value=n,r.key.raw=n.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`);let i=r.key.raw.length-e.length;r.key.loc.end.column=r.key.loc.start.column+r.key.raw.length,r.equals+=i,U(r.value,{lines:0,columns:i},{first_line_only:!0}),r.loc.end.line===r.loc.start.line&&(r.loc.end.column+=i)}B(e,e,r,n===0?_:void 0),v||=r}continue}}n>0&&v&&t(v)&&a(i)?B(e,v,i,void 0):B(e,e,i,n===0?_:void 0),v||=i}let y=v;t(y)&&l.add(y),c.add(y)}function wi(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.line=e.loc.start.line,e.loc.end.column=e.loc.start.column+2}function Ti(e,t){let n=[],r=e=>{if(n.push(e),e===t)return!0;if(a(e)){if(r(e.value))return!0}else if(u(e)){if(r(e.item))return!0}else if(p(e)){for(let t of e.items)if(r(t))return!0}return n.pop(),!1};if(!r(e))return;let i=n.findLast(u);if(!i)return;let o=t.loc.end.line-i.loc.end.line;if(o===0)return;let s=n.findLastIndex((e,t)=>t<n.length-1&&(d(e)||l(e)));if(s<0)return;let c=n[s],f=n[s+1],m=c.items.indexOf(f),h=m>=0?c.items[m+1]:void 0;if(m<0||!h)return;let g=h.loc.start.column-f.loc.end.column,_=Di(f)+g-h.loc.start.column;for(let e=m+1;e<c.items.length;e++)U(c.items[e],{lines:o,columns:_});c.loc.end.column+=_;for(let e of n)e!==t&&e.loc.end.line>t.loc.end.line&&(e.loc.end.line+=o);for(let e=n.length-1;e>=0;e--){let r=n[e];a(r)?(r.loc.end={...r.value.loc.end},r.value!==t&&d(r.value)&&(r.loc.end.column+=_)):u(r)&&(r.loc.end={...r.item.loc.end})}}function Ei(e){bt(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=Di(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=Di(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function Di(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 Oi(e){bt(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=xr(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 ki(e,n,i){if(n.size!==0){for(let a of n.values()){if(a.length>1){let n=Z(e,a.slice(0,-1).concat([0]));if(n&&r(n)){let t=a[a.length-1],r=q({[t]:[]},i),o=rn([t],r.items[0].value);H(e),B(e,n,o);continue}let o;for(let n=a.length-1;n>=1;n--){let r=Z(e,a.slice(0,n));if(r&&t(r)){o=r;break}}if(o){let t=a.slice(o.key.item.value.length),n=rn(t,q({[t[t.length-1]]:[]},i).items[0].value);H(e),B(e,o,n);continue}}let n=rn(a,q({[a[a.length-1]]:[]},i).items[0].value);H(e),B(e,e,n,bi(e))}H(e)}}function Ai(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(Hn(c)<(n.inlineTableStart??1)&&n.inlineTableStart!==0){let n=W(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),Vn(e),r.push(n),i(n,r)}}}};return i(e,r),r}function ji(e,t,n,r){let i=W([...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),Vn(t);let o=Ai(i,n,r);for(let e of o)B(n,n,e,void 0)}function Mi(e,n){let r=G({...n,inlineTableStart:0},n),i=Qn(q({__tmp__:e},r).items,r),o=Array.from(P(i))[0];if(a(o))return o.value;if(t(o)&&o.items.length>0&&a(o.items[0]))return o.items[0].value}function Ni(e,t){for(let n=t.length-1;n>0;n--){let r=Z(e,t.slice(0,n));if(!r||!a(r)||!d(r.value))continue;let i=Z(e,t.slice(0,n-1));if(i&&p(i))return{container:i,row:r}}}function $(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&&L(e.slice(0,n.length),n)&&i.push(o)}return i}function Pi(e,t){let n=[];for(let i of t)typeof i==`number`&&$(e,n).some(r)||n.push(i);return n}function Fi(e,n,i,o){let s=[...n.items];for(let c=s.length-1;c>=0;c--){let l=s[c];if(l===o)continue;let u=a(l)?l.key.value:t(l)||r(l)?l.key.item.value:void 0;u&&u.length>i.length&&L(u.slice(0,i.length),i)&&Q(e,n,l)}}function Ii(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=Ii(t.loc.end,r)<0,n=Ii(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 Ri=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:Cn(e),r=Tn(n);this._currentTomlString=r,this._cst=Array.from(P(r)),this._integersAsBigInt=(t==null?void 0:t.integersAsBigInt)??`asNeeded`,this._temporal=(t==null?void 0:t.temporal)??!1,this._format=K.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:zi(e)}get cst(){return this._cst}patch(e,t){let n=G(t,this._format),{tomlString:r,document:i}=pi(this._cst,e,n);this._cst=i.items,this._format=n,this._currentTomlString=r}update(e){let t=Tn(e);if(t===this._currentTomlString){this._format.leadingBom=wn(e);return}let n=this._currentTomlString.split(this._format.newLine),r=Mn(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(Ie(c,p)),this._currentTomlString=t,this._format=K.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=Tn(e);if(t===this._currentTomlString){this._format.leadingBom=wn(e);return}this._cst=Array.from(P(t)),this._currentTomlString=t,this._format=K.autoDetectFormatWithCst(e,this._cst)}};function zi(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(zi);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=zi(r);return t}return e}function Bi(e,t){let n=Tn(typeof e==`string`?e:Cn(e));return J(P(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function Vi(e,t){let n=G(t,K.default()),r=Qn(q(e,n).items,n);return n.leadingBom?`${r}`:r}function Hi(e,t){return new Ri(e,t)}export{pe as LocalDate,he as LocalDateTime,me as LocalTime,ge as OffsetDateTime,Ri as TomlDocument,K as TomlFormat,Bi as parse,Hi as parseDocument,si as patch,Vi as stringify};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decimalturn/toml-patch",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"contributors": [
|
|
5
5
|
"Tim Hall <tim.hall.engr@gmail.com>",
|
|
6
6
|
"Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
|
|
@@ -42,16 +42,17 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@
|
|
45
|
+
"@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@3.0.2",
|
|
46
46
|
"@js-temporal/polyfill": "^0.5.1",
|
|
47
47
|
"@playwright/test": "^1.59.1",
|
|
48
48
|
"@types/dedent": "^0.7.2",
|
|
49
49
|
"@types/js-yaml": "^4.0.0",
|
|
50
50
|
"@types/node": "^24.12.3",
|
|
51
51
|
"benchmark": "^2",
|
|
52
|
+
"cross-env": "^10.1.0",
|
|
52
53
|
"dedent": "^1.5.3",
|
|
53
54
|
"glob": "^13.0.0",
|
|
54
|
-
"js-yaml": "4.3.
|
|
55
|
+
"js-yaml": "4.3.1",
|
|
55
56
|
"jsr": "^0.14.0",
|
|
56
57
|
"mri": "^1",
|
|
57
58
|
"npm-run-all2": "^9.0.0",
|
|
@@ -93,10 +94,12 @@
|
|
|
93
94
|
"bench:stringify": "node benchmark/stringify-benchmark.mjs",
|
|
94
95
|
"profile": "node benchmark/profile.mjs",
|
|
95
96
|
"build": "tsdown",
|
|
97
|
+
"build:profile": "cross-env PROFILE_BUILD=1 tsdown",
|
|
96
98
|
"build:demo": "node scripts/build-demo.mjs",
|
|
97
99
|
"lint": "oxlint",
|
|
98
100
|
"lint:fix": "oxlint --fix",
|
|
99
101
|
"check-overrides": "node scripts/check-overrides.mjs",
|
|
102
|
+
"compare-branch-size": "node scripts/compare-branch-size.mjs",
|
|
100
103
|
"publish:jsr": "jsr publish --allow-dirty"
|
|
101
104
|
}
|
|
102
105
|
}
|