@decimalturn/toml-patch 3.0.4 → 3.0.5
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/README.md +10 -8
- package/dist/toml-patch.d.ts +4 -11
- package/dist/toml-patch.js +25 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ We hope that these improvements can be incorporated upstream one day if the orig
|
|
|
19
19
|
- [Comment ownership](#comment-ownership)
|
|
20
20
|
- [Date/time handling and Temporal](#datetime-handling--temporal)
|
|
21
21
|
- [Formatting](#formatting)
|
|
22
|
-
- [Changelog](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
23
|
-
- [Contributing](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
22
|
+
- [Changelog](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/CHANGELOG.md)
|
|
23
|
+
- [Contributing](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/CONTRIBUTING.md)
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
@@ -35,7 +35,9 @@ $ npm install --save @decimalturn/toml-patch
|
|
|
35
35
|
For browser usage, you can use unpkg:
|
|
36
36
|
|
|
37
37
|
```html
|
|
38
|
-
<script
|
|
38
|
+
<script type="module">
|
|
39
|
+
import * as TOML from 'https://unpkg.com/@decimalturn/toml-patch@v3.0.5/dist/toml-patch.js';
|
|
40
|
+
</script>
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
## API
|
|
@@ -43,7 +45,7 @@ For browser usage, you can use unpkg:
|
|
|
43
45
|
overwrite(tomlString: string): void
|
|
44
46
|
toml-patch provides a functional API for one-time operations and a document-oriented API for workflows that need multiple operations on the same TOML document.
|
|
45
47
|
|
|
46
|
-
See the [API reference](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
48
|
+
See the [API reference](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/docs/API.md) for `patch`, `parse`, `stringify` and the `TomlDocument` class.
|
|
47
49
|
|
|
48
50
|
For a quick start, patch an existing TOML string like this:
|
|
49
51
|
|
|
@@ -81,10 +83,10 @@ y = 2
|
|
|
81
83
|
`);
|
|
82
84
|
```
|
|
83
85
|
|
|
84
|
-
See the [comment ownership guide](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
86
|
+
See the [comment ownership guide](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/docs/Comment-Ownership.md) for the full behavior, including how a blank line opts a comment out of ownership and current scope limitations.
|
|
85
87
|
|
|
86
88
|
Note that `patch()` does not reorder entries by default.
|
|
87
|
-
To have it match the key order of the object you pass in, enable `updateOrder` in the [formatting options](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
89
|
+
To have it match the key order of the object you pass in, enable `updateOrder` in the [formatting options](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/docs/Formatting.md#updateorder).
|
|
88
90
|
|
|
89
91
|
## Date/Time Handling & Temporal
|
|
90
92
|
|
|
@@ -116,7 +118,7 @@ const obj2 = TOML.parse('d = 2024-01-15\n', { temporal: true });
|
|
|
116
118
|
|
|
117
119
|
> **Note:** Only offset-based timezones (`+05:30`, `Z`) are supported in TOML. IANA timezone annotations (e.g., `[Asia/Kolkata]`) will throw an error.
|
|
118
120
|
|
|
119
|
-
See the [date/time guide](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
121
|
+
See the [date/time guide](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/docs/Dates.md) for details and examples.
|
|
120
122
|
|
|
121
123
|
## Formatting
|
|
122
124
|
|
|
@@ -158,4 +160,4 @@ const toml = stringify({
|
|
|
158
160
|
|
|
159
161
|
```
|
|
160
162
|
|
|
161
|
-
See the [formatting reference](https://github.com/DecimalTurn/toml-patch/blob/v3.0.
|
|
163
|
+
See the [formatting reference](https://github.com/DecimalTurn/toml-patch/blob/v3.0.5/docs/Formatting.md) for the complete list of options, auto-detection behavior, `updateOrder` and more examples.
|
package/dist/toml-patch.d.ts
CHANGED
|
@@ -344,6 +344,10 @@ type Value<TInlineArrayItem = TreeNode> = String | Integer | Float | Boolean | D
|
|
|
344
344
|
interface TreeNode {
|
|
345
345
|
type: NodeType;
|
|
346
346
|
loc: Location;
|
|
347
|
+
/** Absolute UTF-16 offsets into the source that produced this node. */
|
|
348
|
+
readonly range?: readonly [number, number];
|
|
349
|
+
/** Set on generated or mutated nodes and propagated to their ancestors. */
|
|
350
|
+
dirty?: boolean;
|
|
347
351
|
}
|
|
348
352
|
//#endregion
|
|
349
353
|
//#region src/toml-document.d.ts
|
|
@@ -382,11 +386,6 @@ declare class TomlDocument {
|
|
|
382
386
|
* Applies a patch to the current CST using a modified JS object.
|
|
383
387
|
* Updates the internal CST. Use toTomlString getter to retrieve the updated TOML string.
|
|
384
388
|
*
|
|
385
|
-
* The result is verified internally: the produced TOML is re-parsed and checked
|
|
386
|
-
* against `updatedObject`, retrying with a coarser writer if it does not match.
|
|
387
|
-
* A patch that neither attempt can satisfy commits the fine-grained result, with
|
|
388
|
-
* the CST re-derived from it so the document and its TOML string stay in step.
|
|
389
|
-
*
|
|
390
389
|
* @param updatedObject - The modified JS object to patch with
|
|
391
390
|
* @param format - Optional formatting options
|
|
392
391
|
*/
|
|
@@ -414,12 +413,6 @@ declare class TomlDocument {
|
|
|
414
413
|
* and updated data, then strategically applies only the necessary changes to maintain the
|
|
415
414
|
* original document structure as much as possible.
|
|
416
415
|
*
|
|
417
|
-
* The result is verified internally: the output is re-parsed and checked against
|
|
418
|
-
* `updated`, and if it does not round-trip the patch is retried with a coarser
|
|
419
|
-
* writer that rewrites whole multiline inline containers. A patch that neither
|
|
420
|
-
* attempt can satisfy returns the fine-grained result, so this never fails where
|
|
421
|
-
* earlier versions succeeded.
|
|
422
|
-
*
|
|
423
416
|
* @param existing - The original TOML document as a string
|
|
424
417
|
* @param updated - The updated JavaScript object with desired changes
|
|
425
418
|
* @param format - Optional formatting options to apply to new or modified sections
|
package/dist/toml-patch.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
//! @decimalturn/toml-patch v3.0.
|
|
1
|
+
//! @decimalturn/toml-patch v3.0.5 - https://github.com/DecimalTurn/toml-patch - @license: MIT
|
|
2
2
|
function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableKey`}function r(e){return e.type===`TableArray`}function i(e){return e.type===`TableArrayKey`}function a(e){return e.type===`KeyValue`}function o(e){return e.type===`String`}function s(e){return e.type===`Float`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(e){return e.type===`Comment`}function p(n){return e(n)||t(n)||r(n)||d(n)||l(n)}function m(e){return n(e)||i(e)||u(e)}function h(e){return a(e)||t(e)||r(e)||f(e)}function g(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function _(e,t){let n=Array.isArray(e)?e:y(e);if(n.length===0)return{line:1,column:t};let r=0,i=n.length-1;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}n[r]<t&&r++;let a=r+1;return{line:a,column:t-(n[a-2]+1||0)}}function v(e,t){let n=y(e),r=n[t.line-2]===void 0?0:n[t.line-2]+1,i=n[t.line-1]||e.length;return e.substring(r,i)}function y(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===10?t.push(n):r===13&&(e.charCodeAt(n+1)===10?(t.push(n+1),n++):t.push(n))}return t.push(e.length),t}function b(e){return{line:e.line,column:e.column}}function x(e){return{start:b(e.start),end:b(e.end)}}function S(){return{line:1,column:0}}var C=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=v(e,t),i=`${w(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function w(e,t=` `){return t.repeat(e)}const T=/^[\w-]+$/,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
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===`"
|
|
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=
|
|
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===`"`&&!c&&(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===`
|
|
6
6
|
`||o===`\r`||o===` `||o===` `)){let t=o===`
|
|
7
7
|
`||o===`\r`,r=a;for(;r<n&&(e[r]===` `||e[r]===` `||e[r]===`
|
|
8
8
|
`||e[r]===`\r`);)(e[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 re(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var ie=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 oe();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?oe():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const ae=Object.freeze({value:void 0,done:!0});function oe(){return ae}const se=new WeakMap;function ce(e,t){se.set(e,t)}function le(e){return se.get(e)}function ue(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 de(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 fe(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 pe=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 me(e)}if(e.IS_TIME_ONLY.test(n)){if(t instanceof M)return t;{let e=ue(t),r=de(e.ms,n);return new M(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=ue(t),r=de(e.ms,n);return new he(`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`,!1,n)}if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=ue(t),r=de(e.ms,n);return new he(`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`,!0,n)}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=ue(new Date(t.getTime()+fe(i)*6e4)),s=a?` `:`T`,c=de(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)}return t}},me=class extends Date{constructor(e){super(e)}toISOString(){let e=ue(this);return`${e.year}-${e.month}-${e.day}`}},M=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=ue(this);return`${e.hours}:${e.minutes}:${e.seconds}${de(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=ue(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${de(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=ue(new Date(this.getTime()+fe(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=de(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=pe,_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 te(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 ie(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 ie(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(te(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 me(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 M(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)]}if(e.value.type===`Curly`){let[n,r]=Xe(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=Ze(e,t);return[n,...r]}throw e.value.type===`Dot`?new C(t,e.value.loc.start,`Number cannot start with a dot`):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&&ce(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&&ce(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 R(e){if(I(e))return`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${R(e[t])}`).join(`,`)}}`;if(Array.isArray(e))return`[${e.map(R).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)}`}return JSON.stringify(e)}function ht(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 gt=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function _t(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 vt(e,t){if(gt!==void 0&>.call(e))return;let n=_t(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 yt(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 bt=new WeakSet,xt=new WeakSet;function St(e){xt.add(e)}const Ct=new WeakMap,wt=new WeakSet,Tt=new WeakSet;function Et(e){return Tt.has(e)}function Dt(e){Tt.delete(e)}function Ot(e,t,n){Ut(n,z(e),t)}function kt(e){bt.add(e)}const At=new WeakMap,jt=e=>(At.has(e)||At.set(e,new WeakMap),At.get(e));function Mt(e){return At.has(e)||At.set(e,new WeakMap),At.get(e)}const Nt=new WeakMap;function z(e){return Nt.has(e)||Nt.set(e,new WeakMap),Nt.get(e)}function B(e,t,n,r){if(p(t)){let e=t.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.items.splice(e,1,r)}else if(a(t)&&d(t.value)&&!d(n)){let e=t.value.items.indexOf(n);if(e<0)throw Error(`Item not found in parent for replace`);t.value.items.splice(e,1,r)}else if(m(t))t.item=r;else if(a(t))t.key===n?t.key=r:t.value=r;else throw Error(`Unsupported parent type "${t.type}" for replace`);W(r,{lines:n.loc.start.line-r.loc.start.line,columns:n.loc.start.column-r.loc.start.column});let i=g(n.loc),o=g(r.loc);Ut({lines:o.lines-i.lines,columns:o.columns-i.columns},z(e),r,n),bt.add(e)}function V(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}=Lt(n,r,i):a&&e(n)?{shift:c,offset:u}=Rt(n,r,i):{shift:c,offset:u}=Pt(t,n,r,i,s),W(r,c);let m=n.items[i-1],h=m&&z(t).get(m);if(h&&(u.lines+=h.lines,u.columns+=h.columns,z(t).delete(m)),(d(n)||l(n))&&u.lines!==0&&(o||p(t))&&t!==n){let e=r.loc.start.line,i=o??t.items;for(let t=0;t<i.length;t++){let r=i[t];if(!f(r))continue;let a=r.loc.start.line;a<n.loc.start.line||a>n.loc.end.line||a<e&&(r.loc.start.line-=u.lines,r.loc.end.line-=u.lines)}}z(t).set(r,u),bt.add(t)}function Pt(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(xt.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=!xt.has(n)&&c===void 0&&(t(i)||r(i)||e(i))&&Ct.has(i),S=x&&!wt.has(i);x&&(Ct.delete(i),wt.delete(i));let C=x&&!S,w=0;if(C){let e=t(i)||r(i)?z(n).get(i.key):jt(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 Ft(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 It(e){return le(e)??2}function Lt(e,t,n){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let r=It(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),Ft(e,t,n,{useNewLine:Ht(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 Rt(e,t,n){let r=Ft(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),r}function H(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?z(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?z(n).get(c):void 0,d=z(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))&&Tt.add(i),(t(i)||r(i)||e(i))&&Ct.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&wt.add(i);let E=l(i)||d(i)?It(i):2;if(v&&b&&(C.columns-=E),v&&!c&&h&&(Ht(i)||(C.columns-=E)),v&&c&&!h&&(c.comma=!!a.comma,b)){var D;let e=c?((D=z(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=z(n)):(t(i)||r(i))&&`key`in i?(O=i.key,k=z(n)):(O=i,k=jt(n));let A=z(n),j=k.get(O);j&&(C.lines+=j.lines,C.columns+=j.columns);let ee=A.get(a);if(ee&&(C.lines+=ee.lines,S&&(C.columns+=ee.columns)),k.set(O,C),bt.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 zt(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 Bt(e,t,n=!0){if(!n||!t.items.length)return;Ut({lines:0,columns:1},jt(e),t);let r=F(t.items);Ut({lines:0,columns:1},z(e),r),bt.add(e)}function Vt(e,t,n=!1){if(!n||!t.items.length)return;let r=F(t.items);r.comma=!0,Ut({lines:0,columns:1},z(e),r),bt.add(e)}function U(e){if(!bt.has(e))return;let t=jt(e),n=z(e),r=0,i={};function a(e){switch(e.type){case`Document`:{let t=e;o(t);for(let e=0;e<t.items.length;e++)a(t.items[e]);s(t),zt(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),zt(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),zt(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),bt.delete(e),At.delete(e),Nt.delete(e)}function W(e,t,n={}){let{lines:r,columns:i}=t;if(r===0&&i===0)return e;let{first_line_only:a=!1}=n,o=e.loc.start.line,s=e.type;if(s===`Key`||s===`String`||s===`Integer`||s===`Float`||s===`Boolean`||s===`DateTime`||s===`Comment`)return(!a||e.loc.start.line===o)&&(e.loc.start.column+=i,e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=i)),e.loc.start.line+=r,e.loc.end.line+=r,e;if(s===`KeyValue`){let t=e,n=t.value.type;if(n===`String`||n===`Integer`||n===`Float`||n===`Boolean`||n===`DateTime`){(!a||t.loc.start.line===o)&&(t.loc.start.column+=i,t.loc.end.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 yt(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 Ht(e){return e.items.length?g(e.loc).lines>e.items.length:!1}function Ut(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function Wt(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)}const le=new WeakMap,ue=new WeakMap,de=new WeakSet,fe=new WeakMap;function pe(e,t){return(e[t.line-1]??e[e.length-1])+t.column}function me(e){let n=[0];for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&n.push(t+1);return i=>{let o=[i];for(;o.length>0;){let i=o.pop(),s=[pe(n,i.loc.start),pe(n,i.loc.end)];if(Object.defineProperty(i,"range",{configurable:!0,enumerable:!1,value:s}),le.set(i,e),fe.set(i,ge(i).slice()),a(i))o.push(i.value),o.push(i.key);else if(u(i))o.push(i.item);else if(t(i)||r(i)){o.push(i.key);let e=i.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}else if(p(i)){let e=i.items;for(let t=e.length-1;t>=0;t--)o.push(e[t])}}}}function N(e){return le.get(e)}function he(e){let t=fe.get(e);if(!t)return!1;let n=ge(e);return t.length===n.length&&t.every((e,t)=>e===n[t])}function ge(e){return a(e)?[e.key,e.value]:u(e)?[e.item]:t(e)||r(e)?[e.key,...e.items]:p(e)?e.items:[]}function _e(e){if(de.has(e))return;let t=[e];for(;t.length>0;){let e=t.pop();for(let n of ge(e))ue.set(n,e),t.push(n)}de.add(e)}function ve(e){let t=[e];for(;t.length>0;){let e=t.pop();be(e);for(let n of ge(e))t.push(n)}}function ye(e){ve(e)}function be(e){Object.defineProperty(e,"dirty",{configurable:!0,enumerable:!1,value:!0,writable:!0})}function xe(e,t,n){_e(e),n&&(ue.set(n,t),ve(n));let r=t;for(;r;)be(r),r=ue.get(r)}function Se(e){let t=fe.get(e);return!!(t!=null&&t[0])&&t[0].loc.start.line>e.loc.start.line}function Ce(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 we(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 Te(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 Ee=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 Ae)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new ke(e,!1)}let e=t.toISOString().split(`T`)[0];return new De(e)}if(e.IS_TIME_ONLY.test(n)){if(t instanceof Oe)return t;{let e=Ce(t),r=we(e.ms,n);return new Oe(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=Ce(t),r=we(e.ms,n);return new ke(`${e.year}-${e.month}-${e.day}T${e.hours}:${e.minutes}:${e.seconds}${r}`,!1,n)}if(e.IS_LOCAL_DATETIME_SPACE.test(n)){let e=Ce(t),r=we(e.ms,n);return new ke(`${e.year}-${e.month}-${e.day} ${e.hours}:${e.minutes}:${e.seconds}${r}`,!0,n)}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=Ce(new Date(t.getTime()+Te(i)*6e4)),s=a?` `:`T`,c=we(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new Ae(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}return t}},De=class extends Date{constructor(e){super(e)}toISOString(){let e=Ce(this);return`${e.year}-${e.month}-${e.day}`}},Oe=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=Ce(this);return`${e.hours}:${e.minutes}:${e.seconds}${we(e.ms,this.originalFormat)}`}},ke=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=Ce(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${we(e.ms,this.originalFormat)}`}},Ae=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=Ce(new Date(this.getTime()+Te(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=we(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 je=Ee,Me=`true`,Ne=/e/i,Pe=/_/g,Fe=/^[+-]?inf$/,Ie=/^[+-]?nan$/,Le=/^[+-]?0x/i;function Re(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const ze=/^[+-]?0o/i,Be=/^[+-]?0b/i;function Ve(e,t,n){for(let r=0;r<e.length;r++)if(!Re(e.charCodeAt(r)))throw new C(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function He(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new C(t,n,`Multiline strings cannot be keys`)}function Ue(e,t,n){try{return ee(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 Ge(e,t,n,r){let i=e.replace(Pe,``);if(/^[+-]?0\d/.test(i)&&!Le.test(e)&&!ze.test(e)&&!Be.test(e))throw new C(t,n,`Leading zeros are not allowed in ${r}`)}function Ke(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 qe(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 Je(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 Ye(e,t,n){if(Le.test(e)||ze.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 Xe(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)),r=me(e);for(;!n.next().done;){let t=st(n,e);for(let e of t)r(e),yield e}}function*Ze(e,t){for(let t of e)yield t;let n=new re(O(t));for(;!n.next().done;){let e=st(n,t);for(let t of e)yield t}}function Qe(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function $e(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;He(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||Ve(a,t,e.value.loc.start);let o;for(o=[Ue(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(`'`)||Ve(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=st(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 et(e,t){let n=Ue(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function tt(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===Me}}function nt(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&je.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&je.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(it(r,t,n.start),je.IS_FULL_DATE.test(r))i=je.IS_DATE_ONLY.test(r)?new De(r):je.IS_LOCAL_DATETIME_T.test(r)?new ke(r,!1):je.IS_LOCAL_DATETIME_SPACE.test(r)?new ke(r,!0):je.IS_OFFSET_DATETIME_T.test(r)?new Ae(r,!1):je.IS_OFFSET_DATETIME_SPACE.test(r)?new Ae(r,!0):new Date(r.replace(` `,`T`));else if(je.IS_TIME_ONLY.test(r))i=new Oe(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 rt(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 it(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;qe(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;qe(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>rt(parseInt(r,10),u))throw new C(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Je(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Je(r,i,a,e,t,n)}}function at(e,t){let n=e.value.loc,r=e.value.raw,i;if(Fe.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(Ie.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(Ne.test(r)&&!Le.test(r))throw new C(t,n.start,`Float "${r}": dot after exponent`);let e=r;Ge(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),Ke(n,r,t,e.value.loc.start)}i=Number(r.replace(Pe,``))}else{if(We(r,t,n.start),Ke(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`);Ge(r,t,n.start,`the integer part of a float`),i=Number(r.replace(Pe,``))}if(Number.isNaN(i)&&!Ie.test(r))throw new C(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function ot(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`);Ge(n,t,r.start,`decimal integers`),We(n,t,r.start),Ye(n,t,r.start);let i=10;Le.test(n)?(i=16,Xe(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):ze.test(n)?(i=8,Xe(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):Be.test(n)&&(i=2,Xe(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(Pe,``).replace(ze,``).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 st(e,t){if(e.value.type===`Comment`)return[Qe(e)];if(e.value.type===`Bracket`)return[$e(e,t)];if(e.value.type===`Literal`)return ct(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 ct(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 ':'`);He(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ve(n,t,e.value.loc.start);let r;r=[Ue(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;He(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ve(n,t,e.value.loc.start),i.loc.end=e.value.loc.end,i.raw+=`.${e.value.raw}`,i.value.push(Ue(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=lt(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 lt(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[et(e,t)]:n===Me||n===`false`?[tt(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[nt(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||Fe.test(n)||Ie.test(n)||Ne.test(n)&&!Le.test(n)?[at(e,t)]:[ot(e,t)]}if(e.value.type===`Curly`){let[n,r]=dt(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=ft(e,t);return[n,...r]}throw e.value.type===`Dot`?new C(t,e.value.loc.start,`Number cannot start with a dot`):new C(t,e.value.loc.start,`Unrecognized token type`)}function ut(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 dt(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(Qe(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=st(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=ut(n.items);e!==void 0&&se(n,e)}return[n,r]}function ft(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(Qe(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=lt(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=ut(n.items);e!==void 0&&se(n,e)}return[n,r]}function F(e){return e[e.length-1]}function pt(){return Object.create(null)}function mt(e){return typeof e==`string`}function ht(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)&&e>=-(2**53-1)&&e<=2**53-1}function gt(e){return typeof e==`bigint`}function _t(e){return typeof e==`number`&&(!ht(e)||!isFinite(e)||Object.is(e,-0))}function vt(e){return typeof e==`boolean`}function yt(e){return Object.prototype.toString.call(e)===`[object Date]`}const bt=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function xt(e){var t;return typeof e==`object`&&!!e&&bt.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`&&!yt(e)&&!xt(e)&&!Array.isArray(e)}function Ct(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function wt(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function Tt(e){return e.startsWith(`"""`)}function Et(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function Dt(e){return e.startsWith(`'''`)}function Ot(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 kt(e,t){return xt(e)&&xt(t)?e.toString()===t.toString():yt(e)&&yt(t)?e.toISOString()===t.toISOString():!1}function At(e){let t=[],n=new WeakSet,r=[{value:e}];for(;r.length>0;){let e=r.pop();if(`text`in e){t.push(e.text),`leave`in e&&n.delete(e.leave);continue}let i=e.value;if(I(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i);let e=Object.keys(i).sort();t.push(`{`),r.push({leave:i,text:`}`});for(let t=e.length-1;t>=0;t--){let n=e[t];t<e.length-1&&r.push({text:`,`}),r.push({value:i[n]}),r.push({text:`:`}),r.push({text:JSON.stringify(n)})}}else if(Array.isArray(i)){if(n.has(i))throw TypeError(`Cannot stableStringify a circular structure`);n.add(i),t.push(`[`),r.push({leave:i,text:`]`});for(let e=i.length-1;e>=0;e--)e<i.length-1&&r.push({text:`,`}),r.push({value:i[e]})}else if(xt(i))t.push(JSON.stringify(i.toString()));else if(yt(i))t.push(JSON.stringify(i.toISOString()));else if(typeof i==`bigint`)t.push(i.toString()+`n`);else if(typeof i==`number`&&!Number.isFinite(i)){let e=new Float64Array([i]),n=new DataView(e.buffer).getUint32(4,!0)&2147483648?`-`:`+`;t.push(`${n}${String(i)}`)}else t.push(JSON.stringify(i))}return t.join(``)}function jt(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 Mt=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function Nt(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 Pt(e,t){if(Mt!==void 0&&Mt.call(e))return;let n=Nt(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 Ft(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 It=new WeakSet,Lt=new WeakSet;function Rt(e){Lt.add(e)}const zt=new WeakMap,Bt=new WeakSet,Vt=new WeakSet;function Ht(e){return Vt.has(e)}function Ut(e){Vt.delete(e)}function Wt(e,t,n){on(n,R(e),t)}function Gt(e){ye(e),It.add(e)}const Kt=new WeakMap,qt=e=>(Kt.has(e)||Kt.set(e,new WeakMap),Kt.get(e));function Jt(e){return Kt.has(e)||Kt.set(e,new WeakMap),Kt.get(e)}const Yt=new WeakMap;function R(e){return Yt.has(e)||Yt.set(e,new WeakMap),Yt.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);on({lines:o.lines-i.lines,columns:o.columns-i.columns},R(e),r,n),xe(e,t,r),It.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}=$t(n,r,i):a&&e(n)?{shift:c,offset:u}=en(n,r,i):{shift:c,offset:u}=Xt(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),xe(t,n,r),It.add(t)}function Xt(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(Lt.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=!Lt.has(n)&&c===void 0&&(t(i)||r(i)||e(i))&&zt.has(i),S=x&&!Bt.has(i);x&&(zt.delete(i),Bt.delete(i));let C=x&&!S,w=0;if(C){let e=t(i)||r(i)?R(n).get(i.key):qt(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 Zt(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 Qt(e){return ce(e)??2}function $t(e,t,n){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let r=Qt(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),Zt(e,t,n,{useNewLine:an(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 en(e,t,n){let r=Zt(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`);xe(n,i);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))&&Vt.add(i),(t(i)||r(i)||e(i))&&zt.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&Bt.add(i);let E=l(i)||d(i)?Qt(i):2;if(v&&b&&(C.columns-=E),v&&!c&&h&&(an(i)||(C.columns-=E)),v&&c&&!h&&(c.comma=!!a.comma,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=qt(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),It.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 tn(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 nn(e,t,n=!0){if(!n||!t.items.length)return;on({lines:0,columns:1},qt(e),t);let r=F(t.items);on({lines:0,columns:1},R(e),r),It.add(e)}function rn(e,t,n=!1){if(!n||!t.items.length)return;let r=F(t.items);r.comma=!0,on({lines:0,columns:1},R(e),r),It.add(e)}function H(e){if(!It.has(e))return;let t=qt(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),tn(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),tn(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),tn(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),It.delete(e),Kt.delete(e),Yt.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 Ft(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 an(e){return e.items.length?g(e.loc).lines>e.items.length:!1}function on(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function sn(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
|
|
10
10
|
`?`\r
|
|
11
11
|
`:`
|
|
12
|
-
`}function
|
|
12
|
+
`}function cn(e,t){var n;let r=sn(e);e=e.replace(/\r\n/g,`
|
|
13
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
|
|
14
14
|
`||!t.includes(`\r
|
|
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
|
|
16
|
-
`;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 ln(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 un(e,t){return t===`singleline-basic`?e<=31||e===127:e>=0&&e<=7||e===11||e>=14&&e<=31||e===127}function dn(e,t){switch(e){case`\\`:return`\\\\`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`"`:return t===`singleline-basic`?`\\"`:`"`;case`
|
|
17
17
|
`:return t===`singleline-basic`?`\\n`:`
|
|
18
|
-
`;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return
|
|
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
|
|
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
|
|
18
|
+
`;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return un(n,t)?`\\u${n.toString(16).padStart(4,`0`).toUpperCase()}`:e}}}function fn(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=ln(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 pn(e,t,n){let r=``;for(let i of e){let e=t.get(i);if(e){r+=e;continue}r+=dn(i,n)}return r}function mn(e,t,n){let r=fn(t);if(r.size===0&&n===`singleline-basic`)return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,`\\u007F`);let i=pn(e,r,n);return n===`multiline-basic`?i.replace(/"""/g,`""\\"`):i}function hn(){return{type:`Document`,loc:{start:S(),end:S()},items:[]}}function W(e){let t=gn(e);return{type:`Table`,loc:x(t.loc),key:t,items:[]}}function gn(e){let t=xn(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 _n(e){let t=vn(e);return{type:`TableArray`,loc:x(t.loc),key:t,items:[]}}function vn(e){let t=xn(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 yn(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 bn(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function xn(e){return e.map(e=>(Pt(e,`Key ${JSON.stringify(e)}`),T.test(e)?e:bn(e))).join(`.`)}function Sn(e){let t=xn(e);return{type:`Key`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function Cn(e,t){return Pt(e,`String value`),t?wn(e,t):Tn(e)}function wn(e,t){if(wt(t))return Tn(e,t);if(Et(t))return e.includes(`'`)?e.includes(`'''`)?Tn(e):On(e,`'''${t.slice(1,-1)}'''`):En(e);if(Dt(t))return e.includes(`'''`)?Dn(e,`"""${t.slice(3,-3)}"""`):On(e,t);if(Tt(t))return Dn(e,t);throw Error(`Existing raw string value is not valid: ${t}`)}function Tn(e,t){let n=``;return n=t?`"${mn(e,t,`singleline-basic`)}"`:bn(e),{type:`String`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function En(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 Dn(e,t){let n=mn(e,t,`multiline-basic`),r=`"""`+(t.startsWith(`"""\r
|
|
21
21
|
`)?`\r
|
|
22
22
|
`:t.startsWith(`"""
|
|
23
23
|
`)?`
|
|
24
|
-
`:``)+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=cn(t,n);e!==null&&(r=e)}let a=kn(r);return{type:`String`,loc:{start:S(),end:a},raw:r,value:e}}function On(e,t){let n=`'''`+(t.startsWith(`'''\r
|
|
25
25
|
`)?`\r
|
|
26
26
|
`:t.startsWith(`'''
|
|
27
27
|
`)?`
|
|
28
|
-
`:``)+e+`'''`,r=
|
|
29
|
-
`)){let t=e.split(/\r\n|\n/),n=t[t.length-1];return{line:t.length,column:n.length}}return{line:1,column:e.length}}function
|
|
28
|
+
`:``)+e+`'''`,r=kn(n);return{type:`String`,loc:{start:S(),end:r},raw:n,value:e}}function kn(e){if(e.includes(`
|
|
29
|
+
`)){let t=e.split(/\r\n|\n/),n=t[t.length-1];return{line:t.length,column:n.length}}return{line:1,column:e.length}}function An(e){let t=e.toString();return{type:`Integer`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function jn(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);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 Mn(e){return{type:`Boolean`,loc:{start:S(),end:{line:1,column:e?4:5}},value:e}}function Nn(e,t=!1){t&&!(e instanceof Oe)&&e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0&&(e=new De(e.toISOString().split(`T`)[0]));let n=e.toISOString();return{type:`DateTime`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function Pn(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 Fn(){return{type:`InlineArray`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function In(e){return{type:`InlineItem`,loc:x(e.loc),item:e,comma:!1}}function Ln(){return{type:`InlineTable`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function Rn(e){return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}function zn(e){return e.charCodeAt(0)===65279}function Bn(e){return zn(e)?e.slice(1):e}function Vn(e){for(let t of e){let e=Gn(t);if(e!==null)return e}return!1}function Hn(e,t){for(let n of t){let t=Un(n,e);if(t!==null)return t}return!0}function Un(e,t){if(!e||typeof e!=`object`)return null;if((e.type===`InlineArray`||e.type===`InlineTable`)&&e.loc){let n=Wn(e.loc,t);if(n!==null)return n}if(e.items&&Array.isArray(e.items))for(let n of e.items){let e=Un(n,t);if(e!==null)return e;if(n.item){let e=Un(n.item,t);if(e!==null)return e}}for(let n of[`value`,`key`,`item`])if(e[n]){let r=Un(e[n],t);if(r!==null)return r}return null}function Wn(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+=`
|
|
30
30
|
`+(n[e]||``);n[i]&&(s+=`
|
|
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
|
|
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 Gn(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 Kn(e.items);if(e.type===`KeyValue`&&e.value)return Gn(e.value);if(e.items&&Array.isArray(e.items))for(let t of e.items){let e=Gn(t);if(e!==null)return e}return null}function Kn(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 qn(e){let t=e.indexOf(`
|
|
32
32
|
`);return t>0&&e[t-1]===`\r`?`\r
|
|
33
33
|
`:`
|
|
34
|
-
`}function
|
|
35
|
-
`;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function
|
|
34
|
+
`}function Jn(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 Yn(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}const Xn=new Map([[`
|
|
36
36
|
`,`
|
|
37
37
|
`],[`\r
|
|
38
38
|
`,`\r
|
|
@@ -42,13 +42,13 @@ function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}f
|
|
|
42
42
|
`],[`CRLF`,`\r
|
|
43
43
|
`],[`UNIX`,`
|
|
44
44
|
`],[`DOS`,`\r
|
|
45
|
-
`]]);function
|
|
46
|
-
`:
|
|
47
|
-
`,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=
|
|
45
|
+
`]]);function Zn(e){let t=Xn.get(e)??Xn.get(e.toUpperCase());if(t===void 0)throw TypeError(`Invalid newLine value: expected LF or CRLF`);return t}function Qn(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`newLine`in r&&(r.newLine=Zn(r.newLine)),r}function $n(e,t){if(e){if(e instanceof er)return e;{let n=Qn(e);return new er(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)}}return t}var er=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==null?`
|
|
46
|
+
`:Zn(e),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(`
|
|
47
|
+
`,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=zn(t);let i=Bn(t);r.newLine=qn(i),r.trailingNewline=Jn(i);try{let e=Array.isArray(n)?n:Array.from(n??P(i));r.trailingComma=Vn(e),r.bracketSpacing=Hn(i,e)}catch{r.trailingComma=!1,r.bracketSpacing=!0}return r.useTabsForIndentation=Yn(i),r.inlineTableStart=1,r.truncateZeroTimeInDates=!1,r.minimumDecimals=0,r.updateOrder=!1,r}static autoDetectFormatWithAst(t,n){return e.autoDetectFormatWithCst(t,n)}};function tr(e){return!l(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function nr(e){return!d(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function rr(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=sr(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,ir(t)):ar(t).forEach(t=>{B(e,e,t)})}),H(e),e)}function ir(e){let t=W(e.key.value);for(let n of e.value.items)B(t,t,n.item);return H(t),t}function ar(e){let t=hn();for(let n of e.value.items){let r=_n(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 or(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 sr(e){return Math.max(0,e.length-1)}function cr(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(sr(i.key.value)<t.inlineTableStart){let r=ir(i);V(e,e,i),B(e,e,r),lr(r,n,t)}}else(i.type===`Table`||r(i))&&lr(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 lr(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];sr(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),or(e),t.push({table:r,parent:e}),lr(r,t,n)}r.length>0&&H(e)}function ur(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 G(e,t=er.default()){e=hr(e);let n=hn();Rt(n);for(let r of dr(e,t))B(n,n,r);return H(n),rr(n,t),cr(n,t),ur(n)}function*dr(e,t){for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=hr(r);i!==void 0&&(yield yn([n],fr(i,t)))}}function fr(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 mt(e)?Cn(e):gt(e)?An(e):ht(e)?n>0?jn(e,n):An(e):_t(e)?jn(e,Math.max(n,1)):vt(e)?Mn(e):xt(e)?Pn(e,t.truncateZeroTimeInDates):yt(e)?Nn(e,t.truncateZeroTimeInDates):Array.isArray(e)?pr(e,t):mr(e,t)}function pr(e,t){let n=Fn();for(let r of e)B(n,n,In(fr(r,t)));return nn(n,n,t.bracketSpacing),rn(n,n,t.trailingComma),H(n),n}function mr(e,t){if(e=hr(e),!I(e))return fr(e,t);let n=Ln();for(let r of dr(e,t))B(n,n,In(r));return nn(n,n,t.bracketSpacing),rn(n,n,t.trailingComma),H(n),n}function hr(e){return!e||yt(e)||xt(e)?e:typeof e.toJSON==`function`?e.toJSON():e}const gr=/(\r\n|\n)/g;function _r(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;yr(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;yr(n,t.loc,`[[`+t.item.raw+`]]`);break}case`KeyValue`:{let t=e,i=t.loc.start.line;br(n,i,t.equals,`=`),r(t.key),r(t.value);break}case`Key`:yr(n,e.loc,e.raw);break;case`String`:yr(n,e.loc,e.raw);break;case`Integer`:yr(n,e.loc,e.raw);break;case`Float`:yr(n,e.loc,e.raw);break;case`Boolean`:yr(n,e.loc,e.value.toString());break;case`DateTime`:yr(n,e.loc,e.raw);break;case`InlineArray`:{let t=e,{start:i,end:a}=t.loc;br(n,i.line,i.column,`[`),br(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;br(n,i.line,i.column,`{`),br(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;br(n,e.line,e.column,`,`)}break}case`Comment`:yr(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],a=` `.repeat(t.length);n[e]=a+r.substring(t.length)}}}return n.join(t.newLine)+t.newLine.repeat(t.trailingNewline)}function vr(e,t){let n=Ct(e)?Array.from(e):[e],r=[],i=[],o=[],s=new WeakSet,c=1,l=0,d=e=>{if(e.type===`Comment`&&o.push(e),a(e))d(e.value);else if(u(e))d(e.item);else if(e.type===`Table`||e.type===`TableArray`)for(let t of e.items)d(t);else if(p(e))for(let t of e.items)d(t)};for(let e of n)d(e);let f=e=>(t.useTabsForIndentation?` `:` `).repeat(e),h=e=>{if(e.length===0)return;r.push(e);let t=e.split(/\r\n|\n/);t.length===1?l+=e.length:(c+=t.length-1,l=t[t.length-1].length)},g=(e,n)=>{e>c?(h(t.newLine.repeat(e-c)),n>0&&h(f(n))):e===c&&n>l?h(` `.repeat(n-l)):r.length>0&&(e<c||e===c&&n<l)&&(h(t.newLine),n>0&&h(f(n)))},_=e=>{switch(e.type){case`Key`:return e.raw;case`String`:return e.raw;case`Integer`:return e.raw;case`Float`:return e.raw;case`Boolean`:return e.value.toString();case`DateTime`:return e.raw;case`Comment`:return e.raw;default:return}},v=e=>{if(a(e))return[e.key,e.value];if(u(e)||m(e))return[e.item];if(e.type===`Table`||e.type===`TableArray`){let t=e;return[t.key,...t.items]}return p(e)?e.items:[]},y=e=>{let t=[e];for(;t.length>0;){let e=t.pop();if(e.dirty)return!1;let n=_(e);if(n!==void 0){let t=N(e);if(!t||!e.range||t.slice(e.range[0],e.range[1])!==n)return!1}else if(!he(e))return!1;t.push(...v(e))}return!0},b=e=>e.type!==`Document`&&e.type!==`InlineItem`&&e.type!==`TableKey`&&e.type!==`TableArrayKey`&&(_(e)!==void 0||he(e)),x=(e,n)=>{n.line>e.line?(h(t.newLine.repeat(n.line-e.line)),n.column>0&&h(f(n.column))):n.line===e.line&&n.column>e.column&&h(` `.repeat(n.column-e.column))},S=(e,t,n)=>{var r,i;let a=N(e);if(!a||!e.range||t&&N(t)!==a||n&&N(n)!==a)return;let o=(t==null||(r=t.range)==null?void 0:r[1])??e.range[0]+1,s=(n==null||(i=n.range)==null?void 0:i[0])??e.range[1]-1;if(o===void 0||s===void 0||s<o)return;let c=a.slice(o,s);return t!=null&&t.comma&&c.startsWith(`,`)&&(c=c.slice(1)),/^[\t \r\n]*$/.test(c)?c:void 0},C=(e,t)=>{let n=N(t);return n!==void 0&&N(e)===n&&t.range!==void 0&&e.range!==void 0&&e.range[0]>=t.range[0]&&e.range[1]<=t.range[1]},w=e=>{let n;for(let t of e.items){let r=n?{line:n.loc.end.line,column:n.loc.end.column+ +!!n.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},i=o.filter(n=>!s.has(n)&&C(n,e)&&n.loc.start.line>=r.line&&n.loc.end.line<=t.loc.start.line&&(n.loc.start.line>r.line||n.loc.start.column>=r.column)&&(n.loc.end.line<t.loc.start.line||n.loc.end.column<=t.loc.start.column)&&n.loc.start.line>=e.loc.start.line&&n.loc.end.line<=e.loc.end.line).sort((e,t)=>e.loc.start.line-t.loc.start.line||e.loc.start.column-t.loc.start.column);if(i.length>0){for(let e of i)x(r,e.loc.start),h(e.raw),s.add(e),r=e.loc.end;x(r,t.loc.start)}else{let i=S(e,n,t);if(i!==void 0)h(i);else{let i=N(t)!==N(e);if(n&&i&&t.loc.start.line===n.loc.end.line){let t=ce(e)??2,n=Math.max(0,t-1);n>0&&h(` `.repeat(n))}else x(r,t.loc.start)}}T(t,!1);for(let n of o){if(s.has(n)||!C(n,e)||n.loc.start.line!==t.loc.end.line||n.loc.start.column<t.loc.end.column||n.loc.start.line<e.loc.start.line||n.loc.end.line>e.loc.end.line)continue;let r=t.loc.end.column+ +!!t.comma;n.loc.start.column>r&&h(` `.repeat(n.loc.start.column-r)),h(n.raw),s.add(n)}n=t}let r=n?{line:n.loc.end.line,column:n.loc.end.column+ +!!n.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},i=o.filter(t=>!s.has(t)&&C(t,e)&&t.loc.start.line>=r.line&&t.loc.end.line<=e.loc.end.line).sort((e,t)=>e.loc.start.line-t.loc.start.line||e.loc.start.column-t.loc.start.column);if(i.length>0){for(let e of i)x(r,e.loc.start),h(e.raw),s.add(e),r=e.loc.end;x(r,{line:e.loc.end.line,column:e.loc.end.column-1})}else{let i=S(e,n,void 0);if(i!==void 0)h(i);else if(n)x(r,{line:e.loc.end.line,column:e.loc.end.column-1});else{let n=N(e);if(n&&e.range){let r=n.slice(e.range[0],e.range[1]),i=Math.max(r.lastIndexOf(`
|
|
48
|
+
`),r.lastIndexOf(`\r`));if(i!==-1&&e.items.length>0&&Se(e)){var a;let e=((a=r.slice(i+1,-1).match(/^[\t ]*/))==null?void 0:a[0])??``;h(t.newLine+e)}}}}},T=(e,t=!0)=>{if(e.type===`Comment`&&s.has(e))return;let n=N(e);if(!(n!==void 0&&e.range&&i.some(t=>t.source===n&&t.start<=e.range[0]&&t.end>=e.range[1]))){if(b(e)&&y(e)&&e.range&&n!==void 0){let r=n.slice(e.range[0],e.range[1]),a=_(e);if(a===void 0||a===r){t&&g(e.loc.start.line,e.loc.start.column),h(r),i.push({source:n,start:e.range[0],end:e.range[1]});return}}switch(e.type){case`Document`:for(let t of e.items)T(t);break;case`Table`:{let n=e;T(n.key,t);for(let e of n.items)T(e);break}case`TableKey`:{let n=e;t&&g(n.loc.start.line,n.loc.start.column),h(`[${n.item.raw}]`);break}case`TableArray`:{let n=e;T(n.key,t);for(let e of n.items)T(e);break}case`TableArrayKey`:{let n=e;t&&g(n.loc.start.line,n.loc.start.column),h(`[[${n.item.raw}]]`);break}case`KeyValue`:{let n=e;t&&g(n.loc.start.line,n.loc.start.column),T(n.key,!1),x(n.key.loc.end,{line:n.loc.start.line,column:n.equals}),h(`=`),x({line:n.loc.start.line,column:n.equals+1},n.value.loc.start),T(n.value,!1);break}case`Key`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;case`String`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;case`Integer`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;case`Float`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;case`Boolean`:t&&g(e.loc.start.line,e.loc.start.column),h(e.value.toString());break;case`DateTime`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;case`InlineArray`:{let n=e;t&&g(n.loc.start.line,n.loc.start.column),h(`[`),w(n),h(`]`);break}case`InlineTable`:{let n=e;t&&g(n.loc.start.line,n.loc.start.column),h(`{`),w(n),h(`}`);break}case`InlineItem`:{let t=e;if(T(t.item,!1),t.comma){let e=N(t);if(e&&t.range&&t.item.range&&N(t.item)===e){let n=e.slice(t.item.range[1],t.range[1]);/^[\t ]*$/.test(n)&&h(n)}h(`,`)}break}case`Comment`:t&&g(e.loc.start.line,e.loc.start.column),h(e.raw);break;default:throw Error(`toTOMLCursor: Unrecognized node type: ${String(e.type)}`)}}};for(let e of n)T(e);return r.join(``).replace(/\r\n|\n/g,t.newLine)+t.newLine.repeat(t.trailingNewline)}function yr(e,t,n){if(t.start.line===t.end.line){let r=xr(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(gr).filter(e=>e!==`
|
|
48
49
|
`&&e!==`\r
|
|
49
|
-
`),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=
|
|
50
|
-
`);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=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date),u=e=>e.length>4&&e.some(e=>typeof e==`string`)&&e.some(l),d=c||u(e)||u(t),f=e.slice(),p=0,m=!1,h=e=>{let t={type:`Remove`,path:n.concat(e)};return(!m||p>0)&&Object.defineProperty(t,"coordinate",{value:`source`}),t};for(let e=0;e<o.length;e++){let s=o[e],c=e>=a.length;if(!c&&a[e]===s)continue;let l=c?-1:a.indexOf(s,e+1);if(l>-1){let r=a[e],c=0;for(let t=e;t<a.length;t++)a[t]===r&&c++;let u=0;for(let t=e;t<o.length;t++)o[t]===r&&u++;let g=c>u;if(d&&(o.indexOf(a[e])===-1||g)){i.push(h(e+p)),a.splice(e,1),f.splice(e,1),p++,e--;continue}if(p>0&&g){i.push(h(e+p)),a.splice(e,1),f.splice(e,1),p++,e--;continue}if(d&&p>0){i.push({type:`Add`,path:n.concat(e)}),m=!0,a.splice(e,0,s),f.splice(e,0,t[e]),p--;continue}i.push({type:`Move`,path:n,from:l,to:e});let _=a.splice(l,1);a.splice(e,0,..._);let v=f.splice(l,1);f.splice(e,0,...v);continue}let u=!1;if(!c){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++;u=n>r}if(!c&&u){ht(i,yr(f[e],t[e],n.concat(e),r)),a[e]=s,f[e]=t[e];continue}i.push({type:`Add`,path:n.concat(e)}),m=!0,a.splice(e,0,s),f.splice(e,0,t[e]),p>0&&p--}for(let e=o.length;e<a.length;e++)i.push(h(e+p));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=R(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=Sr(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}return(a(l)||u(l)&&a(l.item))&&f.length>i.length&&L(f.slice(0,i.length),i)&&(c||=l),!1}catch{return!1}}),!s&&c&&(s=c),!s)throw Error(`Node not found at ${i.join(`.`)}`);return s}function Sr(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=R(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 Cr(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 wr=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,Tr=new RegExp(String.raw`^#\s*${wr}(?:\s*\.\s*${wr})*\s*=`),Er=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,Dr=new RegExp(String.raw`^#\s*${wr}(?:\s*\.\s*${wr})*\s*=\s*${Er}\s*$`),Or=new RegExp(String.raw`^#\s*\[\[?\s*${wr}(?:\s*\.\s*${wr})*\s*\]\]?\s*$`);function kr(e){return Dr.test(e.raw)||Or.test(e.raw)}function Ar(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 jr(e){return kr(e)?!0:Tr.test(e.raw)?Ar(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function Mr(e){let t=e.raw.match(Tr);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 Nr(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 Fr(e,t,n,r=Pr){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=jr(s[t])?Mr(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 Ir(t,n=()=>!0,r=Pr){let i=e(t)?0:t.key.loc.end.line;return Fr(t.items,i,n,r)}function Lr(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 Fr([...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 Rr(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 zr(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 Br(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=Vr(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),zt(i),n+=o.length}}function Vr(e,t){let n=F(Ir(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(kr);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=Vr(o,a);if(e)for(let t of e)H(n,o,t)}}if(e(i)||t(i)||r(i)){let e=Ir(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)&&H(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(Nr(i)&&e(n)){let e=zr(n,i);if(e){let t=Lr(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),H(n,i,a,e.items),U(n);return}}}H(n,i,a)}function Hr(t,n,r,i){let s=!1;if(Nr(n)&&e(t)){let e=zr(t,n);if(e){let c=Lr(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=z(t).get(e[n-1]),a=z(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;H(t,n,r,e.items);let w=!1;if(x&&S!==void 0&&r.loc.end.line>r.loc.start.line&&!Ht(n)&&z(t).get(S)&&(z(t).delete(S),w=!0),U(t),V(t,n,r,i,void 0,e.items),w){let e=z(t).get(r);e&&(e.lines=0,e.columns=0)}U(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){W(t,a);let n=e.items.findIndex(e=>e.loc.start.line>t.loc.start.line);n===-1?e.items.push(t):e.items.splice(n,0,t)}}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){W(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){W(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(`
|
|
51
|
-
`).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=
|
|
52
|
-
`))}
|
|
53
|
-
`);if(Array.isArray(e))return e.map(mi);if(typeof e==`bigint`)return`Int:${e.toString()}`;if(typeof e==`number`&&Number.isInteger(e))return`Int:${BigInt(e).toString()}`;if(e instanceof Date)return e.getUTCFullYear()<=0?`Time:${String(e.getUTCHours()).padStart(2,`0`)}:${String(e.getUTCMinutes()).padStart(2,`0`)}:${String(e.getUTCSeconds()).padStart(2,`0`)}.${String(e.getUTCMilliseconds()).padStart(3,`0`)}`:`Date:${e.getTime()}`;if(ot(e))return e.toString();if(e&&typeof e.toJSON==`function`)return mi(e.toJSON());if(e&&typeof e==`object`){let t={};for(let n of Object.keys(e)){let r=mi(e[n]);r!==void 0&&(t[n]=r)}return t}return e}}function hi(e,t,n){let r=D(),i=Array.from(P(wn(e),r)),a=Ln(n,Rn.autoDetectFormatWithCst(e,i));if(r.mixed){let e=a.newLine===`\r
|
|
54
|
-
`?`CRLF`:`LF`;console.warn(`toml-patch: Mixed line endings detected. Line endings in the output will be normalized to ${e}`)}let o=di(e)&&xi(i),s=Si(i,t,a).tomlString,c=e=>a.leadingBom?`${e}`:e;if(!o)return c(s);let l={temporal:fi(t)};if(pi(t,s,l))return c(s);let u=Si(Array.from(P(wn(e),D())),t,a,!0).tomlString;return pi(t,u,l)?c(u):c(s)}function gi(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 _i(e,t,n){if(n===void 0)return;let r=t.key.value;if(r.length<2)return;let i=r.slice(0,-1);for(let t=0;t<e.items.length;t++){let o=e.items[t];if(!u(o)||!a(o.item))continue;let s=o.item.key.value;if(s.length===r.length&&L(s.slice(0,-1),i)&&s[s.length-1]===n)return t}}function vi(e){let t=new WeakSet,n=e=>{t.add(e)};return yt(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 yi(e,t,n,r){if(!I(t))return t;let i=q(K(e,Ln({...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 bi(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);zt(i)}}}}}function xi(e){let t=!1,n=e=>e.loc.end.line>e.loc.start.line,r=(e,i)=>{if(t)return;if(o(e)&&n(e)&&i){t=!0;return}let s=i||(d(e)||l(e))&&n(e);if(a(e))r(e.value,s);else if(u(e))r(e.item,s);else if(p(e))for(let t of e.items)r(t,s)};for(let t of e)r(t,!1);return t}function Si(e,t,n,r=!1){let i=[...e],a=fi(t),o=1,s=0;for(let e of i){let t=e.loc.end;(t.line>o||t.line===o&&t.column>s)&&(o=t.line,s=t.column)}let c=q(i,``,{temporal:a}),l={type:`Document`,loc:{start:{line:1,column:0},end:{line:o,column:s}},items:i},u=n.inlineTableStart!=null&&n.inlineTableStart>1?1:n.inlineTableStart,d=Ln({...n,inlineTableStart:u},n),f=K(t,d),p=q(f.items,``,{temporal:a}),m=n.updateOrder?yi(t,p,d,a):p,h=Ci(wi(l,m,yr(c,m,[],{updateOrder:n.updateOrder,orderSource:t})));if(h.length===0)return{tomlString:tr(i,n),document:l};let g=Di(l,f,h,n,a,vi(l),t,r);return{tomlString:ui(g,tr(g.items,n),n),document:g}}function Ci(e){for(let t=0;t<e.length;t++){let n=e[t];if(Y(n)){let r=F(n.path),i=n.path.slice(0,-1),a=t+1;for(;a<e.length;){let o=e[a];if(J(o)){if(typeof F(o.path)==`number`&&L(i,o.path.slice(0,-1))){if(n.coordinate===`source`){let n=-1;for(let t=a+1;t<e.length;t++){let r=e[t];if(Y(r)&&r.coordinate===`source`&&L(i,r.path.slice(0,-1))){n=t;break}}if(n!==-1){let r=e.splice(n,1)[0];e.splice(t,0,r),t=-1;break}}break}a++;continue}if(_r(o)&&o.key===void 0){if(L(i,o.path))break;a++;continue}if(!Y(o)){a++;continue}let s=F(o.path),c=o.path.slice(0,-1);if(typeof r==`number`&&typeof s==`number`&&L(i,c)&&s>r){e.splice(a,1),e.splice(t,0,o),t=-1;break}a++}}}return e}function wi(e,t,n){let i=new Set,o=[],s=new Map;for(let e of n){if(!Y(e)&&!J(e))continue;let t=e.path.slice(0,-1);if(t.length===0)continue;let n=JSON.stringify(t),r=s.get(n);r||(r={path:t,removes:[],adds:[]},s.set(n,r)),(Y(e)?r.removes:r.adds).push(e)}for(let t of s.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)),o.push({type:`Edit`,path:t.path})));for(let t of n){if(i.has(t)||!Y(t)&&!J(t))continue;let r=t.path.slice(0,-1);if(r.length===0||typeof F(r)!=`number`)continue;let s=Z(e,r);if(!s||!u(s)||!d(s.item))continue;let c=n.filter(e=>!i.has(e)&&(Y(e)||J(e))&&L(e.path.slice(0,-1),r));if(c.length===0||c.some(e=>e.path.length!==r.length+1))continue;let l=new Set(s.item.items.filter(u).map(e=>{let t=a(e.item)?e.item:void 0;return(t==null?void 0:t.key.value.length)===1?t.key.value[0]:void 0}).filter(e=>e!==void 0)),f=new Set(c.filter(Y).map(e=>F(e.path)));if(!(!c.some(Y)||!c.some(J)||l.size!==f.size||[...l].some(e=>!f.has(e)))){for(let e of c)i.add(e);o.push({type:`Edit`,path:r})}}let c=new Map;for(let t of n){if(i.has(t)||!gr(t)&&!J(t)&&!Y(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)||c.set(JSON.stringify(n),n)}for(let e of c.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 a=n.filter(t=>!i.has(t)&&(gr(t)||J(t)||Y(t))&&t.path.length>e.length&&L(t.path.slice(0,e.length),e));if(!(a.length<2)){for(let e of a)i.add(e);o.push({type:`Edit`,path:e})}}if(i.size===0)return n;let l=n.filter(e=>!i.has(e));return l.push(...o),l}function Ti(e,t){return t.map(t=>T.test(t)?t:`"${Zt(t,e,`singleline-basic`)}"`).join(`.`)}function Ei(e,t){if(o(e)&&o(t)){let n=sn(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(!(pe.IS_TIME_ONLY.test(n)&&r instanceof Date&&r.getUTCFullYear()>1)){let e=pe.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=zn(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=Bn(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 Di(n,i,s,c,h=!1,_=new WeakSet,v=void 0,y=!1){let b=new Map,x=new Set;function S(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&&x.add(e)}}let C=new WeakMap;function w(e){let i=C.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=R(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&&C.set(e,c),c}function E(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 D(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 O(e,t){let n=[],r=!1;for(let i of e.items){if(!a(i)||!d(i.value)||!D(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=q([t.item],``,{temporal:h});for(let e of t.item.key.value)n=n==null?void 0:n[e];let r=Vi(n,c);r!==void 0&&e.push(nn(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=en(e.key.item.value);for(let e of n)V(i,i,e);return U(i),i}function k(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 A(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,W(e.value,{lines:0,columns:s},{first_line_only:!0}),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=s),B(n,i,r,e),Ai(n,e)}function j(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 ee(e,t,r,i){j(e,t),B(n,i,r,e)}function te(e,t,r){let i=Z(n,e);if(i&&!E(i,e))return null;let a=e.length;for(;a>0;){let t=Z(n,e.slice(0,a));if(t&&!E(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(v!==void 0){let e=v;for(let t of r)e=e==null?void 0:e[t];if(e!==void 0){let n=Vi(e,c);if(n!==void 0)return nn([...o,...t.key.value],n)}}let s=t.key,l=[...o,...s.value].map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),u=l.length-s.raw.length;return s.raw=l,s.value=[...o,...s.value],s.loc.end.column=s.loc.start.column+l.length,t.equals+=u,W(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 ne=new Set,re=new Set,ie=[],ae=new Map,oe=new Map,se=new Set,ce=new WeakMap,le=(e,t=[])=>{let n=(d(e)||l(e))&&e.loc.end.line>e.loc.start.line?[...t,e]:t;if(ce.set(e,n),a(e))le(e.value,n);else if(u(e))le(e.item,n);else if(p(e))for(let t of e.items)le(t,n)},ue=new WeakMap,de=new WeakMap;function fe(e){let t=ue.get(e);if(t!==void 0)return t;let n;return n=f(e)?!0:a(e)?fe(e.value):u(e)?fe(e.item):p(e)&&e.items.some(fe),ue.set(e,n),n}function pe(e){let t=de.get(e);if(t!==void 0)return t;let n;return n=o(e)?+(e.loc.end.line>e.loc.start.line):a(e)?pe(e.value):u(e)?pe(e.item):p(e)?e.items.reduce((e,t)=>e+pe(t),0):0,de.set(e,n),n}if(y){le(n);for(let e of s){let t=Z(n,e.path),r=!t;if(!t)for(let r=e.path.length-1;r>=0&&!t;r--)t=Z(n,e.path.slice(0,r));if(!t)continue;let i=ce.get(t)??[],a=(d(t)||l(t))&&t.loc.end.line>t.loc.start.line;for(let n of a?[...i,t]:i){if(fe(n)||pe(n)<1)continue;let t=oe.get(n);t?t.push(e):oe.set(n,[e]),r&&se.add(n);let i=w(n);i!==void 0&&ae.set(n,i)}}}let me=[...oe].filter(([e,t])=>{if(!ae.has(e))return!1;let n=t.length,r=t.some(e=>_r(e)||J(e)),i=pe(e);return(i>=2||i>=1&&(se.has(e)||n===1))&&(n>=3||n===2&&(!r||se.has(e))||n===1&&t.some(Y))}).map(([e])=>ae.get(e)).filter((e,t,n)=>!n.some((n,r)=>r!==t&&e.length>n.length&&L(e.slice(0,n.length),n)));y&&typeof process<`u`&&process.env.TOML_PATCH_DEBUG_TRANSACTION&&console.warn([...oe].map(([e,t])=>({type:e.type,path:ae.get(e),count:t.length,strings:pe(e),changes:t.map(e=>e.type)}))),me.length>0&&(s=s.filter(e=>!me.some(t=>e.path.length>=t.length&&L(e.path.slice(0,t.length),t))),s.push(...me.map(e=>({type:`Edit`,path:e})))),s.forEach(o=>{if(J(o)){var s;let f=X(i,o.path),m=o.path.slice(0,-1),g=F(o.path),_=r(f);if(et(g)&&!_&&!et(F(m))){let e=Z(n,m.concat(0));e&&r(e)&&(_=!0)}if(_&&et(g)&&!et(F(m))){let e=Z(n,m),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=q(i.items,``,{temporal:h});for(let t of o.path)e=e==null?void 0:e[t];let r=Ln({...c,inlineTableStart:0},c),s=e===void 0?void 0:K({tmp:e},r),l=s==null?void 0:s.items[0];if(l&&a(l)&&(f=bn(l.value),_=!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&&Bt(n,e,!0)}}}}if(_&&!r(f)){let e=m.filter(e=>typeof e==`string`),n=q(i.items,``,{temporal:h});for(let e of o.path)n=n==null?void 0:n[e];if(n!==void 0){let i=en(e),a=K(n,c);for(let e of a.items)V(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=on(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),U(i),f=i}}let v;if(t(f))v=n;else if(_){v=n;let e=n,i=Z(e,m.concat(g-1)),a=Z(e,m.concat(g));if(a)g=e.items.indexOf(a);else if(i){if(g=e.items.indexOf(i)+1,r(i)){let n=i.key.item.value,a=g-1;for(let i=g;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)}g=a+1,r(f)&&(f=O(f,i))}}else g=e.items.length}else{v=n;for(let e=o.path.length-1;e>=0;e--){let t=Z(n,o.path.slice(0,e));if(t&&!E(t,o.path.slice(0,e))){v=t;break}}a(v)?v=v.value:u(v)&&a(v.item)?v=v.item.value:(u(v)&&d(v.item)||u(v)&&l(v.item))&&(v=v.item)}if(l(v)){let e=Z(n,m),t=Z(n,m.slice(0,-1));if(e&&a(e)&&t){let n=oi(v,f,g);n!==0&&ii(t,e,n)}}let y=(l(v)||d(v))&&v.loc.end.line>v.loc.start.line;y&&re.has(v)&&U(n);let b=l(v)||d(v)?(s=zr(n,v))==null?void 0:s.items:void 0;if(r(v)||l(v)||e(v)){if(l(v)){let e=zn(v);if(u(f)){f.comma=e;let t=f,n=d(t.item)?t.item:void 0,r=n&&n.items.length>0?v.items.map(e=>e.item).find(e=>e!==t.item&&d(e)):void 0;if(n&&r){let e=Bn(r);if(e!==Bn(n)){let n=q(i.items,``,{temporal:h});for(let e of o.path)n=n==null?void 0:n[e];let r=Ln({...c,inlineTableStart:0,trailingComma:e},c),s=n===void 0?void 0:K({tmp:n},r).items[0];if(s&&a(s)){let e=bn(s.value);e.comma=t.comma,f=e}}}}}if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&e(v)&&t(f)){let e=zi(f,n,c);V(n,v,f,g);for(let t of e)V(n,n,t,void 0)}else{let i=f;u(f)&&(r(v)||e(v))&&(i=f.item);let s=g;if(e(v)&&a(i)){let e=v.items.findIndex(e=>t(e)||r(e));e!==-1&&(s=e)}let c=!1;if((r(v)||e(v))&&a(i)){let e=te(m,i,o.path);e&&(ne.has(v)&&U(n),i=e,c=!0)}l(v)&&v.items.length===0&&U(n),s===0&&l(v)&&Mt(n).has(v)&&U(n),s===0&&(e(v)||t(v)||r(v))&&Mt(n).has(v)&&U(n),V(n,v,i,s,void 0,b),c&&ne.add(v)}}else if(d(v)){v.items.length===0&&(U(n),Et(v)&&v.loc.end.line>v.loc.start.line&&(v.loc.end.line=v.loc.start.line));let e=Bn(v);if(a(f)){let t=bn(f);t.comma=e;let r=_i(v,f,o.before);V(n,v,t,r,void 0,b)}else if(u(f)&&a(f.item)){let t=f.item,r=te(m,t,o.path);r&&(ne.has(v)&&U(n),t=r);let i=bn(t);i.comma=e;let a=_i(v,t,o.before);V(n,v,i,a,void 0,b),r&&ne.add(v)}else V(n,v,f,void 0,void 0,b)}else if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&a(f)&&d(f.value)&&t(v))Gn([...v.key.item.value,...f.key.value])<c.inlineTableStart?Bi(f,v,n,c):V(n,v,f);else if(c.inlineTableStart===0&&a(f)&&d(f.value)&&e(v))V(n,v,f,void 0,!0);else{let i=f;u(f)&&(t(v)||r(v)||e(v))&&(i=f.item);let s=!1;if(t(v)&&a(i)){let e=te(m,i,o.path);e&&(ne.has(v)&&U(n),i=e,s=!0)}V(n,v,i),s&&ne.add(v)}y&&re.add(v)}else if(gr(o)){let s=Z(n,o.path),f;try{f=X(i,o.path)}catch{f=void 0}if(!s||!f){Mi(n,i,o,c,h,_,x);return}if(a(s)&&t(f)){let e=f.key.item.value;if($(n,e).some(e=>e!==s)){Mi(n,i,o,c,h,_,x);return}}if(u(s)&&(t(f)||r(f))){let e=Z(n,o.path.slice(0,-1)),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=v;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Ln({...c,inlineTableStart:0},c),n=K({tmp:e},t),r=n==null?void 0:n.items[0];r&&a(r)&&(f=bn(r.value))}}}let m,y=Z(n,o.path.slice(0,-1));y&&a(y)&&E(y,o.path.slice(0,-1))&&(y=k(n,y));let b=Hi(n,o.path);if(a(s)&&a(f)){let i=!1;if(s.key.value.length>1){let c=w(s),l=gi(o.path,s.key.value,c?c.length-s.key.value.length:0);if(l>0&&l<s.key.value.length){s.key.value=s.key.value.slice(0,l),s.key.raw=on(s.key.value).raw;let o=s.key.loc.end.column,c=s.key.loc.start.column+s.key.raw.length,u=c-o;s.key.loc.end.column=c,s.equals+=u,s.value.loc.start.column+=u,s.value.loc.end.line===s.value.loc.start.line&&(s.value.loc.end.column+=u),s.loc.end.line===s.loc.start.line&&(s.loc.end.column+=u),i=!0;let d=s.key.value;if(y&&(t(y)||e(y)||r(y))){let e=[...y.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===s)continue;let c=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;c&&c.length>=d.length&&L(c.slice(0,d.length),d)&&Q(n,y,o)}}}}if(!i&&a(f)&&y&&(t(y)||e(y)||r(y))&&Wi(n,y,s.key.value,s),Ei(s.value,f.value),y&&ri(y,s,s.value,f.value),m=s,s=s.value,f=f.value,i&&v!==void 0){let e=v;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Vi(e,c);t!==void 0&&(f=t,Ei(s,f))}}}else if(a(s)&&u(f)&&a(f.item)){let i=!1;if(s.key.value.length>1){let c=w(s),l=gi(o.path,s.key.value,c?c.length-s.key.value.length:0);if(l>0&&l<s.key.value.length){s.key.value=s.key.value.slice(0,l),s.key.raw=on(s.key.value).raw;let o=s.key.loc.end.column,c=s.key.loc.start.column+s.key.raw.length,u=c-o;s.key.loc.end.column=c,s.equals+=u,s.value.loc.start.column+=u,s.value.loc.end.line===s.value.loc.start.line&&(s.value.loc.end.column+=u),s.loc.end.line===s.loc.start.line&&(s.loc.end.column+=u),i=!0;let d=s.key.value;if(y&&(t(y)||e(y)||r(y))){let e=[...y.items];for(let i=e.length-1;i>=0;i--){let o=e[i];if(o===s)continue;let c=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;c&&c.length>=d.length&&L(c.slice(0,d.length),d)&&Q(n,y,o)}}}}if(!i&&a(f.item)&&y&&(t(y)||e(y)||r(y))&&Wi(n,y,s.key.value,s),m=s,s=s.value,f=f.item.value,i&&v!==void 0){let e=v;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Vi(e,c);t!==void 0&&(f=t)}}}else if(u(s)&&a(s.item)&&a(f)){let e=s.item,i=!1;if(e.key.value.length>1){let c=w(e),l=gi(o.path,e.key.value,c?c.length-e.key.value.length:0);if(l>0&&l<e.key.value.length){e.key.value=e.key.value.slice(0,l),e.key.raw=on(e.key.value).raw;let o=e.key.loc.end.column,c=e.key.loc.start.column+e.key.raw.length,d=c-o;e.key.loc.end.column=c,e.equals+=d,e.value.loc.start.column+=d,e.value.loc.end.line===e.value.loc.start.line&&(e.value.loc.end.column+=d),e.loc.end.line===e.loc.start.line&&(e.loc.end.column+=d),e.loc.end.line===e.loc.start.line&&Ot(n,e,{lines:0,columns:d}),i=!0;let f=e.key.value,m=y;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===s)continue;let c=a(o)?o.key.value:u(o)&&a(o.item)?o.item.key.value:t(o)||r(o)?o.key.item.value:void 0;c&&c.length>=f.length&&L(c.slice(0,f.length),f)&&Q(n,m,o)}}}}if(Ei(e.value,f.value),m=e,s=e.value,f=f.value,i&&v!==void 0){let e=v;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Vi(e,c);t!==void 0&&(f=t,Ei(s,f))}}}else if(u(s)&&u(f)&&a(s.item)&&a(f.item)){let e=!1,i=s.item;if(i.key.value.length>1){let c=w(i),l=gi(o.path,i.key.value,c?c.length-i.key.value.length:0);if(l>0&&l<i.key.value.length){i.key.value=i.key.value.slice(0,l),i.key.raw=on(i.key.value).raw;let o=i.key.loc.end.column,c=i.key.loc.start.column+i.key.raw.length,d=c-o;i.key.loc.end.column=c,i.equals+=d,i.value.loc.start.column+=d,i.value.loc.end.line===i.value.loc.start.line&&(i.value.loc.end.column+=d),i.loc.end.line===i.loc.start.line&&(i.loc.end.column+=d),i.loc.end.line===i.loc.start.line&&Ot(n,i,{lines:0,columns:d}),e=!0;let f=i.key.value,m=y;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===s)continue;let c=a(o)?o.key.value:u(o)&&a(o.item)?o.item.key.value:t(o)||r(o)?o.key.item.value:void 0;c&&c.length>=f.length&&L(c.slice(0,f.length),f)&&Q(n,m,o)}}}}if(Ei(i.value,f.item.value),m=i,s=i.value,f=f.item.value,e&&v!==void 0){let e=v;for(let t of o.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Vi(e,c);t!==void 0&&(f=t,Ei(s,f))}}}else if(t(s)){let l=q(i.items,``,{temporal:h});for(let e of o.path)l=l==null?void 0:l[e];if(l!==void 0){let i=s.key.item.value,u=i.slice(-1),d=i.slice(0,-1),f=k(n,s)??Cr(n,o.path);if(e(f)){let e=$(n,i).filter(e=>e!==s&&(t(e)||r(e)));for(let t of e)Q(n,f,t)}let p=K({[u[0]]:l},c),m=p.items[0];if(d.length>0){if(t(m)||r(m))ee(m,d,s,f),_.add(m);else if($(n,d).some(a))A(m,d,s,f),_.add(m);else{let e=n.items.find(e=>e!==s&&(t(e)||r(e))&&L(e.key.item.value,d));if(e)V(n,e,m,void 0),Q(n,f,s),_.add(m);else{let e=G(d);x.add(e),V(n,e,m,0),B(n,f,s,e),_.add(e)}}}else B(n,f,s,m),_.add(m),Ai(n,m);if(p.items.length>1)for(let e=1;e<p.items.length;e++){let t=p.items[e];d.length>0&&j(t,d);let r=e===1?m:p.items[e-1];V(n,f,t,f.items.indexOf(r)+1),_.add(t)}return}m=Cr(n,o.path)}else if(r(s)){let l=q(i.items,``,{temporal:h}),u=s.key.item.value,d=l,f=typeof o.path[o.path.length-1]==`number`?o.path.slice(0,-1):o.path;for(let e of f)d=d==null?void 0:d[e];if(d!==void 0){let i=u.slice(-1),l=u.slice(0,-1),f=k(n,s)??Cr(n,o.path),p=K({[i[0]]:d},c).items[0];if(Array.isArray(d)&&!d.every(e=>I(e))){let e=$(n,u).filter(e=>e!==s&&(t(e)||r(e)));for(let t of e)Q(n,n,t)}if(l.length>0){if(t(p)||r(p))ee(p,l,s,f),_.add(p);else{let r=e(f)?f.items.find(e=>t(e)&&L(e.key.item.value,l)):void 0;if(r){let e=r.items.find(e=>a(e)&&L(e.key.value,p.key.value));e?B(n,r,e,p):V(n,r,p,void 0),Q(n,f,s),_.add(r);return}if($(n,l).some(a))A(p,l,s,f),_.add(p);else{let e=G(l);x.add(e),V(n,e,p,0),B(n,f,s,e),_.add(e)}}}else B(n,f,s,p),_.add(p),Ai(n,p);return}m=Cr(n,o.path)}else if(m=Cr(n,o.path),a(m)){let e=X(n,o.path.slice(0,-1));a(e)&&l(e.value)&&(m=e.value)}else u(m)&&a(m.item)?m=m.item.value:(u(m)&&d(m.item)||u(m)&&l(m.item))&&(m=m.item);if(u(s)&&u(f)&&(f.comma=s.comma),b){let e=g(s.loc),t=g(f.loc).columns-e.columns;t!==0&&ai(b.container,b.row,t)}B(n,m,s,f),e(m)&&a(s)&&(t(f)||r(f))&&ji(n,f)}else if(Y(o)){let s=Z(n,o.path);if(s){let f=Cr(n,o.path);if(f===s&&(f=Cr(n,o.path.slice(0,-1))),f===s){let e=zr(n,s);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(s))&&(f=k(n,s)??(p(f)?n:zr(n,s)??n));let h=!1;if(o.path.length>1&&t(s)&&v!==void 0){let e=o.path.slice(0,-1),t=s.key.item.value.slice(0,-1);if($(n,t).filter(e=>e!==s).length===0){let r=v;for(let t of e)r=r==null?void 0:r[t];if(I(r)&&Object.keys(r).length===0){let e=s;for(;e.items.length>0;)H(n,e,F(e.items));U(n);let r=e.key,i=m(r)?r.item:r;i.value=t,i.raw=Ti(i.raw,i.value),i.loc.end.column=i.loc.start.column+i.raw.length,r.loc.end.column=r.loc.start.column+i.raw.length+2,e.loc.end.line=r.loc.end.line,e.loc.end.column=r.loc.end.column,S(e),h=!0}}}let g=e(f)&&p(f)?f.items.indexOf(s):-1,_=p(f)&&!e(f)?f.items.indexOf(s):-1,y=u(s)?s.comma:void 0,C=u(s)&&(l(f)||d(f))&&s.loc.end.line===f.loc.end.line?f.loc.end.column-s.loc.end.column:void 0,E=w(u(s)&&a(s.item)?s.item:s),D=a(s)?s:u(s)&&a(s.item)?s.item:void 0;if(D&&E&&p(f)){let e=E.length-D.key.value.length,i=o.path.slice(e);if(i.length>0&&i.length<D.key.value.length){let e=f.items,o=[];for(let n of e){if(n===s)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(D&&E&&p(f)){let e=D.key.value,i=f.items,o=[];for(let n of i){if(n===s)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(s)||r(s))&&p(f)){let e=s.key.item.value,i=f.items,o=[];for(let n of i){if(n===s)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,s),u(s)&&(l(f)||d(f))&&s.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&&_===e.length&&t){let t=C??f.loc.end.column-s.loc.end.column;U(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&&(Ot(n,t,{lines:0,columns:e}),kt(n),U(n))}}}}if(!h&&o.path.length>1&&(t(s)||r(s))&&v!==void 0){let e=o.path.slice(0,-1),t=s.key.item.value.slice(0,-1);if($(n,t).length===0){let r=v;for(let t of e)r=r==null?void 0:r[t];if(I(r)&&Object.keys(r).length===0){let e=G(t);x.add(e);let r=g>=0?Math.min(g,n.items.length):n.items.length;U(n),V(n,n,e,r)}}}if(!h&&o.path.length>1&&v!==void 0){let i=a(s)?s:u(s)&&a(s.item)?s.item:void 0;if(i&&i.key.value.length>1){let s=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<s.length;r++){for(;t<s.length&&typeof s[t]==`number`;)t++;if(t>=s.length||s[t]!==e[r])break;n++,t++}for(;t<s.length&&typeof s[t]==`number`;)t++;o=n===e.length?s.slice(t):s.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<s.length;){for(;t<s.length&&typeof s[t]==`number`;)t++;if(t>=s.length||s[t]!==e[n])break;n++,t++}for(;t<s.length&&typeof s[t]==`number`;)t++;o=n===e.length?s.slice(t):s.slice(e.length)}else o=s.slice(s.length-(i.key.value.length-1))}else o=s;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=v;for(let e of s)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=bn(t);e.comma=y??!1,U(n),Et(l)&&l.loc.end.line>l.loc.start.line&&(l.loc.end.line=l.loc.start.line),V(n,l,e,_>=0?_:void 0),c.bracketSpacing&&W(e,{lines:0,columns:1});let r=l.items[_+1],i=z(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=G(p||t(l)?l.key.item.value.concat(o):o);x.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=Oi(n);i=e>=0?e:n.items.length}U(n),V(n,n,r,i)}}}}}if(r(s)){let e=s.key.item.value,t=o.path.slice(0,-1);!Z(n,t.concat(0))&&Z(i,t)&&b.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&&v!==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=v;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));U(n),t.type=`Table`,r.type=`TableKey`;let i=m(r)?r.item:r;i.value=e,i.raw=Ti(i.raw,i.value),i.loc.end.column=i.loc.start.column+i.raw.length,r.loc.end.column=r.loc.start.column+i.raw.length+2,t.loc.end.line=r.loc.end.line,t.loc.end.column=r.loc.end.column,S(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;b.set(e.join(`.`),e)}if(!c&&o.path.length>1&&v!==void 0){let e=o.path.slice(0,-1);if($(n,e).length===0){let t=v;for(let n of e)t=t==null?void 0:t[n];if(I(t)&&Object.keys(t).length===0){let t=G(e);x.add(t);let r=s>=0?Math.min(s,n.items.length):n.items.length;U(n),V(n,n,t,r)}}}}else{let e=Ui(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&&v!==void 0){let t=e.slice(0,-1);if($(n,t).length===0){let e=v;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=G(t);x.add(e);let i=r>=0?Math.min(r,n.items.length):n.items.length;U(n),V(n,n,e,i)}}}}else X(n,o.path)}}}else if(_r(o)){if(o.key!==void 0){ie.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];Hr(n,e,t,o.to)}else{bi(n);let e=X(n,o.path.concat(o.from)),i=Ir(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])&&H(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=Ir(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)}V(n,n,i,b,void 0,void 0,o),b++}if(u!==void 0){U(n);let e=a[a.length-1],t=n.items.indexOf(e)+1;if(t<n.items.length){let r=n.items[t].loc.start.line-e.loc.end.line,i=u-r;if(i!==0)for(let e=t;e<n.items.length;e++)W(n.items[e],{lines:i,columns:0})}}}}else if(vr(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=Ti(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=Ti(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=Ti(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,W(s.value,{lines:0,columns:t},{first_line_only:!0}),Ot(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=Ti(d.raw,f.value),f.loc.end.column=f.loc.start.column+f.raw.length,B(n,m(l)?l:s,d,f)}}),U(n);for(let e=1;e<n.items.length;e++){let r=n.items[e-1],i=n.items[e];if(f(r)&&t(i)&&x.has(i)){let e=i.loc.start.line-r.loc.end.line-1;e>0&&W(i,{lines:-e,columns:0})}}let M=n.items;for(let e=0;e<M.length-1;e++){let n=M[e],i=M[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<M.length;t++)W(M[t],{lines:n,columns:0})}}}let he=!1;yt(n,{InlineTable:e=>{Et(e)&&(he=!0)},InlineArray:e=>{Et(e)&&(he=!0)}}),he&&U(n);let ge=!1,N=[];if(yt(n,{InlineTable:e=>{Et(e)&&(N.push(e),Ni(e),Dt(e),Bt(n,e,c.bracketSpacing),ge=!0)},InlineArray:e=>{Et(e)&&(Ni(e),Dt(e),Bt(n,e,c.bracketSpacing),ge=!0)}}),ge){U(n);for(let e of N)Pi(n,e);Fi(n)}return Li(n),Ri(n,b,c),Xr(n,ie,_),n}function Oi(e){return e.items.findIndex(e=>t(e)||r(e))}function ki(e){let t=Oi(e);return t===-1?void 0:t}function Ai(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=Oi(e);r===-1||r>n||(H(e,e,t),U(e),V(e,e,t,r))}function ji(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;U(e),H(e,e,n),V(e,e,n,s-1)}function Mi(e,n,i,o,s,c,l){let f=q(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=tr(K(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?B(e,s,n,t):V(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=on(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,W(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)H(e,e,t);let h=tr(K(p,o).items,o),g=Array.from(P(h)),_=ki(e);_!==void 0&&U(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)V(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)V(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,W(r.value,{lines:0,columns:n},{first_line_only:!0}),r.loc.end.line===r.loc.start.line&&(r.loc.end.column+=n)}V(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,W(r.value,{lines:0,columns:i},{first_line_only:!0}),r.loc.end.line===r.loc.start.line&&(r.loc.end.column+=i)}V(e,e,r,n===0?_:void 0),v||=r}continue}}n>0&&v&&t(v)&&a(i)?V(e,v,i,void 0):V(e,e,i,n===0?_:void 0),v||=i}let y=v;t(y)&&l.add(y),c.add(y)}function Ni(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 Pi(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,_=Ii(f)+g-h.loc.start.column;for(let e=m+1;e<c.items.length;e++)W(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 Fi(e){yt(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=Ii(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=Ii(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function Ii(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 Li(e){yt(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=Cr(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,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=K({[t]:[]},i),o=nn([t],r.items[0].value);U(e),V(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=nn(t,K({[t[t.length-1]]:[]},i).items[0].value);U(e),V(e,o,n);continue}}let n=nn(a,K({[a[a.length-1]]:[]},i).items[0].value);U(e),V(e,e,n,ki(e))}U(e)}}function zi(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(Gn(c)<(n.inlineTableStart??1)&&n.inlineTableStart!==0){let n=G(c);for(let e of s.value.items)u(e)&&a(e.item)&&V(t,n,e.item,void 0);e.items.splice(o,1),Wn(e),r.push(n),i(n,r)}}}};return i(e,r),r}function Bi(e,t,n,r){let i=G([...t.key.item.value,...e.key.value]);if(d(e.value))for(let t of e.value.items)u(t)&&a(t.item)&&V(n,i,t.item,void 0);V(n,n,i,void 0),Wn(t);let o=zi(i,n,r);for(let e of o)V(n,n,e,void 0)}function Vi(e,n){let r=Ln({...n,inlineTableStart:0},n),i=tr(K({__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 Hi(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 Ui(e,t){let n=[];for(let i of t)typeof i==`number`&&$(e,n).some(r)||n.push(i);return n}function Wi(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 Gi(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function Ki(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=Gi(t.loc.end,r)<0,n=Gi(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 qi=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:Sn(e),r=wn(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=Rn.autoDetectFormatWithCst(n,this._cst)}get toTomlString(){return this._format.leadingBom?`${this._currentTomlString}`:this._currentTomlString}get toJsObject(){let e=q(this._cst,this._currentTomlString,{integersAsBigInt:this._integersAsBigInt,temporal:this._temporal});return this._temporal?e:Xi(e)}get cst(){return this._cst}patch(e,t){let n=Ln(t,this._format),r=this._currentTomlString,i=di(r)&&xi(this._cst);if(!this._temporal&&Ji(e)){let t=q(this._cst,r,{integersAsBigInt:this._integersAsBigInt,temporal:!1});e=Yi(e,t)}let a=Si(this._cst,e,n),o=(e,t)=>{this._cst=t,this._format=n,this._currentTomlString=e};if(!i){o(a.tomlString,a.document.items);return}let s={temporal:fi(e),integersAsBigInt:this._integersAsBigInt};if(pi(e,a.tomlString,s)){o(a.tomlString,a.document.items);return}let c=Si(Array.from(P(r)),e,n,!0);if(pi(e,c.tomlString,s)){o(c.tomlString,c.document.items);return}o(a.tomlString,Array.from(P(a.tomlString)))}update(e){let t=wn(e);if(t===this._currentTomlString){this._format.leadingBom=Cn(e);return}let n=this._currentTomlString.split(this._format.newLine),r=jn(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}=Ki(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=Rn.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=wn(e);if(t===this._currentTomlString){this._format.leadingBom=Cn(e);return}this._cst=Array.from(P(t)),this._currentTomlString=t,this._format=Rn.autoDetectFormatWithCst(e,this._cst)}};function Ji(e,t=new WeakSet){return e instanceof Date?e.constructor===Date:!e||typeof e!=`object`||t.has(e)?!1:(t.add(e),Array.isArray(e)?e.some(e=>Ji(e,t)):Object.keys(e).some(n=>Ji(e[n],t)))}function Yi(e,t,n=new WeakSet){if(e instanceof Date)return e.constructor===Date&&t instanceof Date&&t.constructor!==Date&&t.getTime()===e.getTime()?t:e;if(!e||typeof e!=`object`||n.has(e))return e;if(n.add(e),Array.isArray(e)){if(!Array.isArray(t))return e;let r=!1,i=e.map((e,i)=>{let a=Yi(e,t[i],n);return a!==e&&(r=!0),a});return r?i:e}if(!I(t))return e;let r=!1,i={};for(let a of Object.keys(e)){let o=e[a],s=Yi(o,t[a],n);i[a]=s,s!==o&&(r=!0)}return r?i:e}function Xi(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(Xi);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=Xi(r);return t}return e}function Zi(e,t){let n=wn(typeof e==`string`?e:Sn(e));return q(P(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function Qi(e,t){let n=Ln(t,Rn.default()),r=tr(K(e,n).items,n);return n.leadingBom?`${r}`:r}function $i(e,t){return new qi(e,t)}export{me as LocalDate,he as LocalDateTime,M as LocalTime,ge as OffsetDateTime,qi as TomlDocument,Rn as TomlFormat,Zi as parse,$i as parseDocument,hi as patch,Qi as stringify};
|
|
50
|
+
`),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=xr(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 br(e,t,n,r){let i=xr(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 xr(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function Sr(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 Cr(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(q(r)),Cr(e.value,r,n)}}}function wr(e){var t,n,r,i,a,o;if((t=e.constructor)!=null&&(t=t.name)!=null&&(n=t.startsWith)!=null&&n.call(t,`Temporal.`)||((r=e.constructor)==null?void 0:r.name)===`PlainDate`||((i=e.constructor)==null?void 0:i.name)===`PlainTime`||((a=e.constructor)==null?void 0:a.name)===`PlainDateTime`||((o=e.constructor)==null?void 0:o.name)===`ZonedDateTime`)return e;let s=globalThis.Temporal;if(e instanceof De)return s.PlainDate.from(e.toISOString());if(e instanceof Oe)return s.PlainTime.from(e.toISOString());if(e instanceof ke)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof Ae){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 K(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=pt(),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)}return a;function m(e){let n=e.key.item.value;try{Er(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=q(n);o.add(r),c.add(r),d=Dr(a,n),f=n}function h(e){let n=e.key.item.value;try{Er(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=q(n);s.add(r),c.add(r),d=Or(a,n),f=n}function g(e){let n=e.key.value;try{Er(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=q(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=Tr(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(q(t)),Cr(e.value,t,u)}let o=n.length>1?Dr(d,n.slice(0,-1)):d;o[F(n)]=a,c.add(q(f.concat(n)))}}function Tr(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=pt(),i=new Set,a=new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=Tr(e.value,{integersAsBigInt:n,temporal:r}),c=jr(o),l=q(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=jr(o.slice(0,e));if(i.has(q(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=q(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?Dr(t,o.slice(0,-1)):t;u[F(o)]=s}),t;case`InlineArray`:return e.items.map(e=>Tr(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 wr(e.value)}return e.value;case`String`:return e.value;case`Integer`:return Sr(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function Er(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]=jr(a),s[e]=q(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(!Ot(e,t))return;if(Ar(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)&&!Ar(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 Dr(e,t){let n=kr(e,t.slice(0,-1)),r=F(t);return n[r]||(n[r]=pt()),n[r]}function Or(e,t){let n=kr(e,t.slice(0,-1)),r=F(t);n[r]||(n[r]=[]);let i=pt();return n[F(t)].push(i),i}function kr(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=pt()),Array.isArray(e[t])?F(e[t]):e[t]),e)}function Ar(e){return typeof e!=`object`&&!yt(e)}function jr(e){return e.join(`.`)}function q(e){return JSON.stringify(e)}function J(e){return e.type===`Add`}function Mr(e){return e.type===`Edit`}function Y(e){return e.type===`Remove`}function Nr(e){return e.type===`Move`}function Pr(e){return e.type===`Rename`}function Fr(e,t,n=[],r={}){if(e===t||kt(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)?Br(e,t,n,r):I(e)&&I(t)?Ir(e,t,n,r):[{type:`Edit`,path:n}]}function Ir(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>At(e[t])),s=Object.keys(t),c=s.map(e=>At(t[e])),l=new Map(s.map((e,t)=>[e,c[t]])),u=new Set(a),d=new Set(s),f=(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},p=f(a,o,d),m=f(s,c,u),h=new Map,g=new Set,_=new Map;for(let[e,t]of p){let n=m.get(e);if(!n)continue;let r=Math.min(t.length,n.length);for(let e=0;e<r;e++)h.set(t[e],n[e]),g.add(n[e]),_.set(n[e],t[e])}a.forEach((a,s)=>{let c=n.concat(a);if(d.has(a)){let n=e[a],u=t[a],d=typeof n==`number`&&!Number.isFinite(n)||typeof u==`number`&&!Number.isFinite(u);(r.updateOrder||d||o[s]!==l.get(a))&&jt(i,Fr(e[a],t[a],c,r))}else h.has(a)?i.push({type:`Rename`,path:n,from:a,to:h.get(a)}):i.push({type:`Remove`,path:c})}),s.forEach(e=>{if(!u.has(e)&&!g.has(e)){let t={type:`Add`,path:n.concat(e)};if(r.orderSource!==void 0){let i=r.orderSource;for(let e of n)i=i==null?void 0:i[e];if(I(i)){let n=Object.keys(i),r=n.indexOf(e);for(let e=r+1;e<n.length;e++){let r=n[e],i=_.get(r)??(u.has(r)?r:void 0);if(i!==void 0){t.before=i;break}}}}i.push(t)}});let v=s;if(r.orderSource!==void 0){let e=r.orderSource;for(let t of n)e=e==null?void 0:e[t];if(I(e)){let t=new Set(s);v=Object.keys(e).filter(e=>t.has(e))}}let y=i.filter(e=>J(e)&&e.path.length===n.length+1||Pr(e)&&e.path.length===n.length);if(r.orderSource!==void 0&&y.length>1){let e=[...y].sort((e,t)=>{let n=J(e)?e.path[e.path.length-1]:Pr(e)?e.to:``,r=J(t)?t.path[t.path.length-1]:Pr(t)?t.to:``;return v.indexOf(n)-v.indexOf(r)}),t=0;i=i.map(n=>y.includes(n)?e[t++]:n)}if(r.updateOrder){let e=[];for(let t of a)if(d.has(t))e.includes(t)||e.push(t);else if(h.has(t)){let n=h.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 Lr(e){if(typeof e==`string`)return e.includes(`
|
|
51
|
+
`);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(Lr)}return!1}function Rr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function zr(e){return e.length>4&&e.some(e=>typeof e==`string`)&&e.some(Rr)}function Br(e,t,n=[],r={}){let i=[],a=e.map(At),o=t.map(At),s=e.some(Lr)||t.some(Lr)||zr(e)||zr(t),c=e.slice(),l=0,u=!1,d=e=>{let t={type:`Remove`,path:n.concat(e)};return(!u||l>0)&&Object.defineProperty(t,"coordinate",{value:`source`}),t};for(let e=0;e<o.length;e++){let f=o[e],p=e>=a.length;if(!p&&a[e]===f)continue;let m=p?-1:a.indexOf(f,e+1);if(m>-1){let r=a[e],p=0;for(let t=e;t<a.length;t++)a[t]===r&&p++;let h=0;for(let t=e;t<o.length;t++)o[t]===r&&h++;let g=p>h;if(s&&(o.indexOf(a[e])===-1||g)){i.push(d(e+l)),a.splice(e,1),c.splice(e,1),l++,e--;continue}if(l>0&&g){i.push(d(e+l)),a.splice(e,1),c.splice(e,1),l++,e--;continue}if(s&&l>0){i.push({type:`Add`,path:n.concat(e)}),u=!0,a.splice(e,0,f),c.splice(e,0,t[e]),l--;continue}i.push({type:`Move`,path:n,from:m,to:e});let _=a.splice(m,1);a.splice(e,0,..._);let v=c.splice(m,1);c.splice(e,0,...v);continue}let h=!1;if(!p){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++;h=n>r}if(!p&&h){jt(i,Fr(c[e],t[e],n.concat(e),r)),a[e]=f,c[e]=t[e];continue}i.push({type:`Add`,path:n.concat(e)}),u=!0,a.splice(e,0,f),c.splice(e,0,t[e]),l>0&&l--}for(let e=o.length;e<a.length;e++)i.push(d(e+l));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=At(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=Vr(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}return(a(l)||u(l)&&a(l.item))&&f.length>i.length&&L(f.slice(0,i.length),i)&&(c||=l),!1}catch{return!1}}),!s&&c&&(s=c),!s)throw Error(`Node not found at ${i.join(`.`)}`);return s}function Vr(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=At(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 Hr(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 Ur=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,Wr=new RegExp(String.raw`^#\s*${Ur}(?:\s*\.\s*${Ur})*\s*=`),Gr=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,Kr=new RegExp(String.raw`^#\s*${Ur}(?:\s*\.\s*${Ur})*\s*=\s*${Gr}\s*$`),qr=new RegExp(String.raw`^#\s*\[\[?\s*${Ur}(?:\s*\.\s*${Ur})*\s*\]\]?\s*$`);function Jr(e){return Kr.test(e.raw)||qr.test(e.raw)}function Yr(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 Xr(e){return Jr(e)?!0:Wr.test(e.raw)?Yr(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function Zr(e){let t=e.raw.match(Wr);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 Qr(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function $r(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 ei(e,t,n,r=$r){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=Xr(s[t])?Zr(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 ti(t,n=()=>!0,r=$r){let i=e(t)?0:t.key.loc.end.line;return ei(t.items,i,n,r)}function ni(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 ei([...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 ri(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 ii(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 ai(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=oi(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),tn(i),n+=o.length}}function oi(e,t){let n=F(ti(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(Jr);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=oi(o,a);if(e)for(let t of e)V(n,o,t)}}if(e(i)||t(i)||r(i)){let e=ti(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(Qr(i)&&e(n)){let e=ii(n,i);if(e){let t=ni(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 si(t,n,r,i){let s=!1;if(Qr(n)&&e(t)){let e=ii(t,n);if(e){let c=ni(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&&!an(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(`
|
|
52
|
+
`).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=ri(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)&&Wt(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 ci(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 li(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 ui(e){return[...e.path,e.key].join(`.`)}function di(e,n,i,o){if(n.some(e=>typeof e!=`string`))return;let s=[...n,i],c=[{container:e,prefix:[]}];for(let n of e.items)(t(n)||r(n))&&c.push({container:n,prefix:n.key.item.value});for(let e of c)for(let t of e.container.items){if(!a(t)||t.key.value.length<2||o.has(t))continue;let n=[...e.prefix,...t.key.value];if(n.length===s.length&&n.every((e,t)=>e===s[t]))return{container:e.container,dottedPrefix:t.key.value.slice(0,-1)}}}function fi(n,i,o,s){if(i.length===0)return{container:n};let c;try{c=Z(n,i)}catch{return}if(!c)return;if(a(c)&&(c=c.value),c&&m(c)&&(c=c.item),c&&(e(c)||t(c)||r(c)))return{container:c};if(o===void 0)return;let l=di(n,i,o,s);if(l)return l;let u=-1;for(let e=i.length-1;e>=0;e--)if(typeof i[e]==`number`){u=e;break}if(u<0)return;let d=i.slice(u+1);if(d.length===0||d.some(e=>typeof e!=`string`))return;let f=Z(n,i.slice(0,u+1));if(!f||!r(f))return;let p=[...d,o];return f.items.some(e=>a(e)&&e.key.value.length===p.length&&e.key.value.every((e,t)=>e===p[t]))?{container:f,dottedPrefix:d}:void 0}function pi(e,t,n){if(t.key===void 0)return!1;let r;try{r=Z(e,t.path.concat(t.key))}catch{return!1}return r!==void 0&&u(r)&&!n.has(r)}function mi(t,n,r,i,o){let s=ci(ti(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(`"${ui(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=li(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),tn(t)}function hi(e,t,n){if(t.length===0)return;ai(e);let r=[],i=new Map;for(let o of t){var a;if(o.key===void 0)continue;let t=fi(e,o.path,o.key,n);if(!t){if(pi(e,o,n))continue;r.push(`"${ui(o)}" -- unsupported location for reordering (e.g. a dotted-key implicit table, or an interior of an inline table/array-of-tables entry)`);continue}let s=((a=t.dottedPrefix)==null?void 0:a.join(`\0`))??``,c=i.get(t.container);c||(c=new Map,i.set(t.container,c));let l=c.get(s);l?l.moves.push(o):c.set(s,{...t,moves:[o]})}for(let e of i.values())for(let t of e.values())mi(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(`
|
|
53
|
+
`))}tn(e)}const gi=new WeakMap,_i=new WeakMap;function vi(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 yi(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function bi(e,t,n){_i.has(e)||_i.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 xi(e,t){_i.set(t,t.loc.start.column),gi.set(t,t.loc.start.column-e.loc.end.column)}function Si(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=vi(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=[yi(i,a,-1),yi(i,a,1)],u;for(let e of l){if(e==null)continue;let t=vi(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;bi(o,u,f)}function Ci(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=vi(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[yi(r,i,-1),yi(r,i,1)];for(let e of c){if(e==null)continue;let t=vi(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){bi(a,t.loc.start.column,n);return}}}function wi(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=vi(r,i);a&&xi(t,a)}function Ti(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 Ei(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&Ei(i,n)}return n}function Di(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))&&Di(i,n)}return n}function Oi(e){for(let n of e.items)(t(n)||r(n))&&Oi(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 ki(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=Di(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=Ei(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=_i.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=_i.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=>gi.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(gi.has(e))return gi.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 Oi(e),s.join(r)+a}function Ai(e,t,n){let r=D(),i=Array.from(P(Bn(e),r)),a=$n(n,er.autoDetectFormatWithCst(e,i));if(r.mixed){let e=a.newLine===`\r
|
|
54
|
+
`?`CRLF`:`LF`;console.warn(`toml-patch: Mixed line endings detected. Line endings in the output will be normalized to ${e}`)}return(e=>a.leadingBom?`${e}`:e)(Ii(i,t,a).tomlString)}function ji(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 Mi(e,t,n){if(n===void 0)return;let r=t.key.value;if(r.length<2)return;let i=r.slice(0,-1);for(let t=0;t<e.items.length;t++){let o=e.items[t];if(!u(o)||!a(o.item))continue;let s=o.item.key.value;if(s.length===r.length&&L(s.slice(0,-1),i)&&s[s.length-1]===n)return t}}function Ni(e){let t=new WeakSet,n=e=>{t.add(e)};return Ft(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 Pi(e,t,n,r){if(!I(t))return t;let i=K(G(e,$n({...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);tn(i)}}}}}function Ii(e,t,n){let r=[...e],i=Ri(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=K(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=$n({...n,inlineTableStart:l},n),d=G(t,u),f=K(d.items,``,{temporal:i}),p=n.updateOrder?Pi(t,f,u,i):f;if(!n.updateOrder&&Li(s,p))return{tomlString:_r(r,n),document:c};let m=zi(Bi(c,p,Fr(s,p,[],{updateOrder:n.updateOrder,orderSource:t})));if(m.length===0)return{tomlString:_r(r,n),document:c};let h=Ui(c,d,m,n,i,Ni(c),t);return{tomlString:ki(h,vr(h.items,n),n),document:h}}function Li(e,t){let n=[[e,t]];for(;n.length>0;){let[e,t]=n.pop();if(typeof e==`number`&&typeof t==`number`&&(!Number.isFinite(e)||!Number.isFinite(t))||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t))return!1;if(Object.is(e,t))continue;if(e instanceof Date&&t instanceof Date){if(e.getTime()!==t.getTime())return!1;continue}if(!e||!t||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;if(!Array.isArray(e)){let n=Object.getPrototypeOf(e),r=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null||r!==Object.prototype&&r!==null)return!1}let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(let i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;n.push([e[i],t[i]])}}return!0}function Ri(e,t=new WeakSet){return typeof e!=`object`||!e?!1:xt(e)?!0:!t.has(e)&&(t.add(e),Object.values(e).some(e=>Ri(e,t)))}function zi(e){for(let t=0;t<e.length;t++){let n=e[t];if(Y(n)){let r=F(n.path),i=n.path.slice(0,-1),a=t+1;for(;a<e.length;){let o=e[a];if(J(o)){if(typeof F(o.path)==`number`&&L(i,o.path.slice(0,-1))){if(n.coordinate===`source`){let n=-1;for(let t=a+1;t<e.length;t++){let r=e[t];if(Y(r)&&r.coordinate===`source`&&L(i,r.path.slice(0,-1))){n=t;break}}if(n!==-1){let r=e.splice(n,1)[0];e.splice(t,0,r),t=-1;break}}break}a++;continue}if(Nr(o)&&o.key===void 0){if(L(i,o.path))break;a++;continue}if(!Y(o)){a++;continue}let s=F(o.path),c=o.path.slice(0,-1);if(typeof r==`number`&&typeof s==`number`&&L(i,c)&&s>r){e.splice(a,1),e.splice(t,0,o),t=-1;break}a++}}}return e}function Bi(e,t,n){let i=new Set,o=[],s=new Map;for(let e of n){if(!Y(e)&&!J(e))continue;let t=e.path.slice(0,-1);if(t.length===0)continue;let n=JSON.stringify(t),r=s.get(n);r||(r={path:t,removes:[],adds:[]},s.set(n,r)),(Y(e)?r.removes:r.adds).push(e)}for(let t of s.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)),o.push({type:`Edit`,path:t.path})));for(let t of n){if(i.has(t)||!Y(t)&&!J(t))continue;let r=t.path.slice(0,-1);if(r.length===0||typeof F(r)!=`number`)continue;let s=Z(e,r);if(!s||!u(s)||!d(s.item))continue;let c=n.filter(e=>!i.has(e)&&(Y(e)||J(e))&&L(e.path.slice(0,-1),r));if(c.length===0||c.some(e=>e.path.length!==r.length+1))continue;let l=new Set(s.item.items.filter(u).map(e=>{let t=a(e.item)?e.item:void 0;return(t==null?void 0:t.key.value.length)===1?t.key.value[0]:void 0}).filter(e=>e!==void 0)),f=new Set(c.filter(Y).map(e=>F(e.path)));if(!(!c.some(Y)||!c.some(J)||l.size!==f.size||[...l].some(e=>!f.has(e)))){for(let e of c)i.add(e);o.push({type:`Edit`,path:r})}}let c=new Map;for(let t of n){if(i.has(t)||!Mr(t)&&!J(t)&&!Y(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)||c.set(JSON.stringify(n),n)}for(let e of c.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 a=n.filter(t=>!i.has(t)&&(Mr(t)||J(t)||Y(t))&&t.path.length>e.length&&L(t.path.slice(0,e.length),e));if(!(a.length<2)){for(let e of a)i.add(e);o.push({type:`Edit`,path:e})}}if(i.size===0)return n;let l=n.filter(e=>!i.has(e));return l.push(...o),l}function Vi(e,t){return t.map(t=>T.test(t)?t:`"${mn(t,e,`singleline-basic`)}"`).join(`.`)}function Hi(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(xt(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(!(Ee.IS_TIME_ONLY.test(n)&&r instanceof Date&&r.getUTCFullYear()>1)){let e=Ee.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=tr(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=nr(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 Ui(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=At(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=K([t.item],``,{temporal:c});for(let e of t.item.key.value)n=n==null?void 0:n[e];let r=ra(n,s);r!==void 0&&e.push(yn(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=_n(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),Ki(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=ra(e,s);if(n!==void 0)return yn([...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(J(o)){var x;let f=X(i,o.path),m=o.path.slice(0,-1),h=F(o.path),g=r(f);if(ht(h)&&!g&&!ht(F(m))){let e=Z(n,m.concat(0));e&&r(e)&&(g=!0)}if(g&&ht(h)&&!ht(F(m))){let e=Z(n,m),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=K(i.items,``,{temporal:c});for(let t of o.path)e=e==null?void 0:e[t];let r=$n({...s,inlineTableStart:0},s),l=e===void 0?void 0:G({tmp:e},r),p=l==null?void 0:l.items[0];if(p&&a(p)&&(f=In(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&&nn(n,e,!0)}}}}if(g&&!r(f)){let e=m.filter(e=>typeof e==`string`),n=K(i.items,``,{temporal:c});for(let e of o.path)n=n==null?void 0:n[e];if(n!==void 0){let i=_n(e),a=G(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=Ti(_,f,h);n!==0&&Ci(t,e,n)}}let v=(l(_)||d(_))&&_.loc.end.line>_.loc.start.line;v&&ee.has(_)&&H(n);let y=l(_)||d(_)?(x=ii(n,_))==null?void 0:x.items:void 0;if(r(_)||l(_)||e(_)){if(l(_)){let e=tr(_);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=nr(r);if(e!==nr(n)){let n=K(i.items,``,{temporal:c});for(let e of o.path)n=n==null?void 0:n[e];let r=$n({...s,inlineTableStart:0,trailingComma:e},s),l=n===void 0?void 0:G({tmp:n},r).items[0];if(l&&a(l)){let e=In(l.value);e.comma=t.comma,f=e}}}}}if(s.inlineTableStart!==void 0&&s.inlineTableStart>0&&e(_)&&t(f)){let e=ta(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(_)&&Jt(n).has(_)&&H(n),s===0&&(e(_)||t(_)||r(_))&&Jt(n).has(_)&&H(n),B(n,_,i,s,void 0,y),c&&M.add(_)}}else if(d(_)){_.items.length===0&&(H(n),Ht(_)&&_.loc.end.line>_.loc.start.line&&(_.loc.end.line=_.loc.start.line));let e=nr(_);if(a(f)){let t=In(f);t.comma=e;let r=Mi(_,f,o.before);B(n,_,t,r,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=In(t);i.comma=e;let a=Mi(_,t,o.before);B(n,_,i,a,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(_))sr([..._.key.item.value,...f.key.value])<s.inlineTableStart?na(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(Mr(o)){let f=Z(n,o.path),m;try{m=X(i,o.path)}catch{m=void 0}if(!f||!m){Ji(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)){Ji(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=$n({...s,inlineTableStart:0},s),n=G({tmp:e},t),r=n==null?void 0:n.items[0];r&&a(r)&&(m=In(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=ia(n,o.path);if(a(f)&&a(m)){let i=!1;if(f.key.value.length>1){let s=S(f),c=ji(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))&&oa(n,b,f.key.value,f),Hi(f.value,m.value),b&&Si(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=ra(e,s);t!==void 0&&(m=t,Hi(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=ji(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))&&oa(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=ra(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=ji(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&&Wt(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(Hi(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=ra(e,s);t!==void 0&&(m=t,Hi(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=ji(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&&Wt(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(Hi(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=ra(e,s);t!==void 0&&(m=t,Hi(f,m))}}}else if(t(f)){let l=K(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)??Hr(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=G({[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),Ki(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=Hr(n,o.path)}else if(r(f)){let l=K(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)??Hr(n,o.path),p=G({[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),Ki(n,p);return}v=Hr(n,o.path)}else if(v=Hr(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&&wi(x.container,x.row,t)}z(n,v,f,m),e(v)&&a(f)&&(t(m)||r(m))&&qi(n,m)}else if(Y(o)){let c=Z(n,o.path);if(c){let f=Hr(n,o.path);if(f===c&&(f=Hr(n,o.path.slice(0,-1))),f===c){let e=ii(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:ii(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=Vi(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&&(Wt(n,t,{lines:0,columns:e}),Gt(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=In(t);e.comma=C??!1,H(n),Ht(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=Wi(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=Vi(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=aa(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(Nr(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];si(n,e,t,o.to)}else{Fi(n);let e=X(n,o.path.concat(o.from)),i=ti(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=ti(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(Pr(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=Vi(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=Vi(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=Vi(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}),Wt(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=Vi(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;Ft(n,{InlineTable:e=>{Ht(e)&&(re=!0)},InlineArray:e=>{Ht(e)&&(re=!0)}}),re&&H(n);let ie=!1,ae=[];if(Ft(n,{InlineTable:e=>{Ht(e)&&(ae.push(e),Yi(e),Ut(e),nn(n,e,s.bracketSpacing),ie=!0)},InlineArray:e=>{Ht(e)&&(Yi(e),Ut(e),nn(n,e,s.bracketSpacing),ie=!0)}}),ie){H(n);for(let e of ae)Xi(n,e);Zi(n)}return $i(n),ea(n,v,s),hi(n,te,h),te.length>0&&Gt(n),n}function Wi(e){return e.items.findIndex(e=>t(e)||r(e))}function Gi(e){let t=Wi(e);return t===-1?void 0:t}function Ki(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=Wi(e);r===-1||r>n||(V(e,e,t),H(e),B(e,e,t,r))}function qi(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 Ji(e,n,i,o,s,c,l){let f=K(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=_r(G(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=_r(G(p,o).items,o),g=Array.from(P(h)),_=Gi(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 Yi(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 Xi(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,_=Qi(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 Zi(e){Ft(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=Qi(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=Qi(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function Qi(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 $i(e){Ft(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=Hr(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 ea(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=G({[t]:[]},i),o=yn([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=yn(t,G({[t[t.length-1]]:[]},i).items[0].value);H(e),B(e,o,n);continue}}let n=yn(a,G({[a[a.length-1]]:[]},i).items[0].value);H(e),B(e,e,n,Gi(e))}H(e)}}function ta(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(sr(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),or(e),r.push(n),i(n,r)}}}};return i(e,r),r}function na(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),or(t);let o=ta(i,n,r);for(let e of o)B(n,n,e,void 0)}function ra(e,n){let r=$n({...n,inlineTableStart:0},n),i=_r(G({__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 ia(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 aa(e,t){let n=[];for(let i of t)typeof i==`number`&&$(e,n).some(r)||n.push(i);return n}function oa(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 sa(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function ca(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=sa(t.loc.end,r)<0,n=sa(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 la=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:Rn(e),r=Bn(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=er.autoDetectFormatWithCst(n,this._cst)}get toTomlString(){return this._format.leadingBom?`${this._currentTomlString}`:this._currentTomlString}get toJsObject(){let e=K(this._cst,this._currentTomlString,{integersAsBigInt:this._integersAsBigInt,temporal:this._temporal});return this._temporal?e:fa(e)}get cst(){return this._cst}patch(e,t){let n=$n(t,this._format),r=this._currentTomlString;if(!this._temporal&&ua(e)){let t=K(this._cst,r,{integersAsBigInt:this._integersAsBigInt,temporal:!1});e=da(e,t)}let i=Ii(this._cst,e,n);this._cst=Array.from(P(i.tomlString)),this._format=n,this._currentTomlString=i.tomlString}update(e){let t=Bn(e);if(t===this._currentTomlString){this._format.leadingBom=zn(e);return}let n=this._currentTomlString.split(this._format.newLine),r=qn(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}=ca(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(Ze(c,p)),this._currentTomlString=t,this._format=er.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=Bn(e);if(t===this._currentTomlString){this._format.leadingBom=zn(e);return}this._cst=Array.from(P(t)),this._currentTomlString=t,this._format=er.autoDetectFormatWithCst(e,this._cst)}};function ua(e,t=new WeakSet){return e instanceof Date?e.constructor===Date:!e||typeof e!=`object`||t.has(e)?!1:(t.add(e),Array.isArray(e)?e.some(e=>ua(e,t)):Object.keys(e).some(n=>ua(e[n],t)))}function da(e,t,n=new WeakSet){if(e instanceof Date)return e.constructor===Date&&t instanceof Date&&t.constructor!==Date&&t.getTime()===e.getTime()?t:e;if(!e||typeof e!=`object`||n.has(e))return e;if(n.add(e),Array.isArray(e)){if(!Array.isArray(t))return e;let r=!1,i=e.map((e,i)=>{let a=da(e,t[i],n);return a!==e&&(r=!0),a});return r?i:e}if(!I(t))return e;let r=!1,i={};for(let a of Object.keys(e)){let o=e[a],s=da(o,t[a],n);i[a]=s,s!==o&&(r=!0)}return r?i:e}function fa(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(fa);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=fa(r);return t}return e}function pa(e,t){let n=Bn(typeof e==`string`?e:Rn(e));return K(P(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function ma(e,t){let n=$n(t,er.default()),r=_r(G(e,n).items,n);return n.leadingBom?`${r}`:r}function ha(e,t){return new la(e,t)}export{De as LocalDate,ke as LocalDateTime,Oe as LocalTime,Ae as OffsetDateTime,la as TomlDocument,er as TomlFormat,pa as parse,ha as parseDocument,Ai as patch,ma as stringify};
|