@decimalturn/toml-patch 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,9 +19,9 @@ 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.1.0/CHANGELOG.md)
23
- - [Contributing](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/CONTRIBUTING.md)
24
- - [MIT License](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/LICENSE)
22
+ - [Changelog](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/CHANGELOG.md)
23
+ - [Contributing](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/CONTRIBUTING.md)
24
+ - [MIT License](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/LICENSE)
25
25
 
26
26
  ## Installation
27
27
 
@@ -37,7 +37,7 @@ For browser usage, you can use unpkg:
37
37
 
38
38
  ```html
39
39
  <script type="module">
40
- import * as TOML from 'https://unpkg.com/@decimalturn/toml-patch@v3.1.0/dist/toml-patch.js';
40
+ import * as TOML from 'https://unpkg.com/@decimalturn/toml-patch@v3.1.1/dist/toml-patch.js';
41
41
  </script>
42
42
  ```
43
43
 
@@ -46,7 +46,7 @@ For browser usage, you can use unpkg:
46
46
  overwrite(tomlString: string): void
47
47
  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.
48
48
 
49
- See the [API reference](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/docs/API.md) for `patch`, `parse`, `stringify` and the `TomlDocument` class.
49
+ See the [API reference](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/docs/API.md) for `patch`, `parse`, `stringify` and the `TomlDocument` class.
50
50
 
51
51
  For a quick start, patch an existing TOML string like this:
52
52
 
@@ -62,8 +62,8 @@ const updated = patch(existing, {
62
62
 
63
63
  ## Comment Ownership
64
64
 
65
- When `patch()` removes or reorders an entry, any comment describing it — a same-line trailing
66
- comment, or an own-line comment directly above with no blank line in between — travels along with
65
+ When `patch()` removes or reorders an entry, any comment describing it (a same-line trailing
66
+ comment, or a line-comment directly above with no blank line in between) travels along with
67
67
  it, instead of being left behind to describe whatever ends up in that spot. This applies to root
68
68
  keys, `[table]`/`[[array-of-tables]]` blocks, and elements inside multi-line arrays and inline
69
69
  tables.
@@ -84,10 +84,10 @@ y = 2
84
84
  `);
85
85
  ```
86
86
 
87
- See the [comment ownership guide](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/docs/Comment-Ownership.md) for the full behavior, including how a blank line opts a comment out of ownership and current scope limitations.
87
+ See the [comment ownership guide](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/docs/Comment-Ownership.md) for the full behavior, including how a blank line opts a comment out of ownership and current scope limitations.
88
88
 
89
89
  Note that `patch()` does not reorder entries by default.
90
- 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.1.0/docs/Formatting.md#updateorder).
90
+ 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.1.1/docs/Formatting.md#updateorder).
91
91
 
92
92
  ## Date/Time Handling & Temporal
93
93
 
@@ -119,7 +119,7 @@ const obj2 = TOML.parse('d = 2024-01-15\n', { temporal: true });
119
119
 
120
120
  > **Note:** Only offset-based timezones (`+05:30`, `Z`) are supported in TOML. IANA timezone annotations (e.g., `[Asia/Kolkata]`) will throw an error.
121
121
 
122
- See the [date/time guide](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/docs/Dates.md) for details and examples.
122
+ See the [date/time guide](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/docs/Dates.md) for details and examples.
123
123
 
124
124
  ## Formatting
125
125
 
@@ -166,4 +166,4 @@ const toml = stringify({
166
166
  }, format);
167
167
 
168
168
  ```
169
- See the [formatting reference](https://github.com/DecimalTurn/toml-patch/blob/v3.1.0/docs/Formatting.md) for the complete list of options, auto-detection behavior, `updateOrder` and more examples.
169
+ See the [formatting reference](https://github.com/DecimalTurn/toml-patch/blob/v3.1.1/docs/Formatting.md) for the complete list of options, auto-detection behavior, `updateOrder` and more examples.
@@ -1,7 +1,7 @@
1
1
 
2
2
  //#region src/toml-format.d.ts
3
3
  type MultilineContainerMode = boolean | number | 'auto' | 'parent';
4
- declare class TomlFormat {
4
+ export declare class TomlFormat {
5
5
  /**
6
6
  * The line ending character(s) to use in the output TOML.
7
7
  * This option affects only the stringification process, not the internal representation (CST).
@@ -376,7 +376,7 @@ interface TreeNode {
376
376
  /**
377
377
  * TomlDocument encapsulates a TOML CST and provides methods to interact with it.
378
378
  */
379
- declare class TomlDocument {
379
+ export declare class TomlDocument {
380
380
  private _cst;
381
381
  private _currentTomlString;
382
382
  private _format;
@@ -447,7 +447,7 @@ declare function patch(existing: string, updated: any, format?: Partial<TomlForm
447
447
  * Custom Date class for local dates (date-only).
448
448
  * Format: 1979-05-27
449
449
  */
450
- declare class LocalDate extends Date {
450
+ export declare class LocalDate extends Date {
451
451
  constructor(value: string);
452
452
  toISOString(): string;
453
453
  }
@@ -455,7 +455,7 @@ declare class LocalDate extends Date {
455
455
  * Custom Date class for local times (time-only)
456
456
  * Format: 07:32:00 or 07:32:00.999
457
457
  */
458
- declare class LocalTime extends Date {
458
+ export declare class LocalTime extends Date {
459
459
  originalFormat: string;
460
460
  constructor(value: string, originalFormat: string);
461
461
  toISOString(): string;
@@ -464,7 +464,7 @@ declare class LocalTime extends Date {
464
464
  * Custom Date class for local datetime (no timezone)
465
465
  * Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00
466
466
  */
467
- declare class LocalDateTime extends Date {
467
+ export declare class LocalDateTime extends Date {
468
468
  useSpaceSeparator: boolean;
469
469
  originalFormat: string;
470
470
  constructor(value: string, useSpaceSeparator?: boolean, originalFormat?: string);
@@ -474,7 +474,7 @@ declare class LocalDateTime extends Date {
474
474
  * Custom Date class for offset datetime that preserves space separator
475
475
  * Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00
476
476
  */
477
- declare class OffsetDateTime extends Date {
477
+ export declare class OffsetDateTime extends Date {
478
478
  useSpaceSeparator: boolean;
479
479
  originalOffset?: string;
480
480
  originalFormat: string;
@@ -518,7 +518,7 @@ declare class OffsetDateTime extends Date {
518
518
  * Default: false.
519
519
  * @returns The parsed JavaScript object
520
520
  */
521
- declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
521
+ export declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
522
522
  /**
523
523
  * Converts a JavaScript object to a TOML string.
524
524
  *
@@ -526,7 +526,7 @@ declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
526
526
  * @param format - Optional formatting options for the resulting TOML
527
527
  * @returns The stringified TOML representation
528
528
  */
529
- declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
529
+ export declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
530
530
  /**
531
531
  * Parses a TOML string or raw UTF-8 bytes into a {@link TomlDocument}.
532
532
  *
@@ -536,6 +536,6 @@ declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat
536
536
  * @param options - Optional parse options
537
537
  * @returns A {@link TomlDocument} representing the parsed TOML
538
538
  */
539
- declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
539
+ export declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
540
540
  //#endregion
541
- export { type IntegersAsBigInt, LocalDate, LocalDateTime, LocalTime, type MultilineContainerMode, OffsetDateTime, type ParseOptions, TomlDocument, TomlFormat, parse, parseDocument, patch, stringify };
541
+ export { type IntegersAsBigInt, type MultilineContainerMode, type ParseOptions, patch };
@@ -1,18 +1,18 @@
1
- //! @decimalturn/toml-patch v3.1.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
- function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableKey`}function r(e){return e.type===`TableArray`}function i(e){return e.type===`TableArrayKey`}function a(e){return e.type===`KeyValue`}function o(e){return e.type===`String`}function s(e){return e.type===`Float`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(e){return e.type===`Comment`}function p(n){return e(n)||t(n)||r(n)||d(n)||l(n)}function m(e){return n(e)||i(e)||u(e)}function h(e){return a(e)||t(e)||r(e)||f(e)}function g(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function _(e,t){let n=Array.isArray(e)?e:y(e);if(n.length===0)return{line:1,column:t};let r=0,i=n.length-1;for(;r<i;){let e=r+i>>>1;n[e]<t?r=e+1:i=e}n[r]<t&&r++;let a=r+1;return{line:a,column:t-(n[a-2]+1||0)}}function v(e,t){let n=y(e),r=n[t.line-2]===void 0?0:n[t.line-2]+1,i=n[t.line-1]||e.length;return e.substring(r,i)}function y(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===10?t.push(n):r===13&&(e.charCodeAt(n+1)===10?(t.push(n+1),n++):t.push(n))}return t.push(e.length),t}function b(e){return{line:e.line,column:e.column}}function x(e){return{start:b(e.start),end:b(e.end)}}function S(){return{line:1,column:0}}var C=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=v(e,t),i=`${w(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function w(e,t=` `){return t.repeat(e)}const T=/^[\w-]+$/,E=/[\w,\d,",',+,\-,_]/;function D(){return{reference:null,mixed:!1}}function*O(e,t){let n=e.length,r=0,i=t??D(),a=[],o=(e,t)=>({start:_(a,e),end:_(a,t)});for(;r<n;){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9&&t!==13&&t!==10)throw new C(e,_(a,r),`Control char 0x${t.toString(16).toUpperCase().padStart(2,`0`)} not allowed`);if(t===13&&(r+1>=n||e.charCodeAt(r+1)!==10))throw new C(e,_(a,r),`Standalone CR; must be CRLF or LF`);if(t!==32&&t!==9&&t!==13){if(t===10)s(r);else if(t===91||t===93)yield{type:`Bracket`,raw:e[r],loc:o(r,r+1)};else if(t===123||t===125)yield{type:`Curly`,raw:e[r],loc:o(r,r+1)};else if(t===61)yield{type:`Equal`,raw:`=`,loc:o(r,r+1)};else if(t===44)yield{type:`Comma`,raw:`,`,loc:o(r,r+1)};else if(t===46)yield{type:`Dot`,raw:`.`,loc:o(r,r+1)};else if(t===35)yield c();else{let t=k(e,r,`'`)||k(e,r,`"`);t?yield l(t):yield u()}}r++}function s(t){a.push(t);let n=t>0&&e.charCodeAt(t-1)===13?`\r
1
+ //! @decimalturn/toml-patch v3.1.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
+ function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}function n(e){return e.type===`TableKey`}function r(e){return e.type===`TableArray`}function i(e){return e.type===`TableArrayKey`}function a(e){return e.type===`KeyValue`}function o(e){return e.type===`String`}function s(e){return e.type===`Float`}function c(e){return e.type===`DateTime`}function l(e){return e.type===`InlineArray`}function u(e){return e.type===`InlineItem`}function d(e){return e.type===`InlineTable`}function f(e){return e.type===`Comment`}function p(n){return e(n)||t(n)||r(n)||d(n)||l(n)}function m(e){return n(e)||i(e)||u(e)}function h(e){return a(e)||t(e)||r(e)||f(e)}let g,_;function v(e){if(g===e&&_!==void 0)return _;let t=C(e);return g=e,_=t,t}function y(){g=void 0,_=void 0}function b(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function x(e,t){let n=Array.isArray(e)?e:C(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 S(e,t){let n=v(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 C(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 w(e){return{line:e.line,column:e.column}}function T(e){return{start:w(e.start),end:w(e.end)}}function E(){return{line:1,column:0}}var D=class extends Error{line;column;constructor(e,t,n){let r=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){let n=S(e,t),i=`${O(t.column)}^`;n&&(r+=`${n}\n${i}\n`)}r+=n,super(r),this.line=t.line,this.column=t.column}};function O(e,t=` `){return t.repeat(e)}const k=/^[\w-]+$/,ee=/[\w,\d,",',+,\-,_]/;function A(){return{reference:null,mixed:!1}}function*te(e,t){let n=e.length,r=0,i=t??A(),a=[],o=(e,t)=>({start:x(a,e),end:x(a,t)});for(;r<n;){let t=e.charCodeAt(r);if((t<=31||t===127)&&t!==9&&t!==13&&t!==10)throw new D(e,x(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 D(e,x(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=ne(e,r,`'`)||ne(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===`"`&&!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 ee(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 te(e){return e.startsWith(`'''`)?re(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?ne(re(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?ne(e.slice(1,e.length-1),!1):e}function ne(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=ee(e,a+1);if(t>=55296&&t<=57343)throw Error(`Invalid \\u${e.slice(a+1,a+5)}: surrogates not allowed`);r.push(String.fromCharCode(t)),a+=4;break}case`U`:{if(a+8>n)throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);for(let t=1;t<=8;t++)if(!j(e[a+t]))throw Error(`Invalid Unicode escape: \\U${e.slice(a+1,a+9)}`);let t=parseInt(e.slice(a+1,a+9),16);if(t>=55296&&t<=57343)throw Error(`Invalid \\U${e.slice(a+1,a+9)}: surrogates not allowed`);r.push(String.fromCodePoint(t)),a+=8;break}case`x`:{if(a+2>n||!j(e[a+1])||!j(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=A[e.charCodeAt(a+1)]<<4|A[e.charCodeAt(a+2)];r.push(String.fromCharCode(t)),a+=2;break}default:if(t&&(o===`
4
+ `;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 D(e,x(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(ne(e,r,t)){let n=3;for(;e[r+n]===t;)n++;if(n>=6)throw new D(e,x(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 D(e,x(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 D(e,x(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 D(e,x(a,r),`Unterminated multiline ${c} (possible escape issue)`)}throw new D(e,x(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(!ee.test(t))throw new D(e,x(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 D(e,x(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 D(e,x(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 D(e,x(a,i),`Expected close of string with ${s?`"`:`'`}`);return{type:`Literal`,raw:e.slice(i,r+1),loc:o(i,r+1)}}}function ne(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 j=new Int8Array(128);j.fill(-1);for(let e=0;e<10;e++)j[48+e]=e;for(let e=0;e<6;e++)j[65+e]=10+e,j[97+e]=10+e;function M(e){let t=e.charCodeAt(0);return t<128&&j[t]!==-1}function re(e,t){return j[e.charCodeAt(t)]<<12|j[e.charCodeAt(t+1)]<<8|j[e.charCodeAt(t+2)]<<4|j[e.charCodeAt(t+3)]}function ie(e){return e.startsWith(`'''`)?oe(e.slice(3,e.length-3)):e.startsWith(`'`)?e.slice(1,e.length-1):e.startsWith(`"""`)?ae(oe(e.slice(3,e.length-3)),!0):e.startsWith(`"`)?ae(e.slice(1,e.length-1),!1):e}function ae(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||!M(e[a+1])||!M(e[a+2])||!M(e[a+3])||!M(e[a+4]))throw Error(`Invalid Unicode escape: \\u${e.slice(a+1,a+5)}`);let t=re(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(!M(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||!M(e[a+1])||!M(e[a+2]))throw Error(`Invalid hex escape: \\x${e.slice(a+1,a+3)}`);let t=j[e.charCodeAt(a+1)]<<4|j[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)}const ue=new WeakMap,de=new WeakMap,fe=new WeakSet,pe=new WeakMap;function me(e,t){return(e[t.line-1]??e[e.length-1])+t.column}function he(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=[me(n,i.loc.start),me(n,i.loc.end)];if(Object.defineProperty(i,"range",{configurable:!0,enumerable:!1,value:s}),ue.set(i,e),pe.set(i,_e(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 M(e){return ue.get(e)}function ge(e){let t=pe.get(e);if(!t)return!1;let n=_e(e);return t.length===n.length&&t.every((e,t)=>e===n[t])}function _e(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 ve(e){if(fe.has(e))return;let t=[e];for(;t.length>0;){let e=t.pop();for(let n of _e(e))de.set(n,e),t.push(n)}fe.add(e)}function ye(e){let t=[e];for(;t.length>0;){let e=t.pop();xe(e);for(let n of _e(e))t.push(n)}}function be(e){ye(e)}function xe(e){Object.defineProperty(e,"dirty",{configurable:!0,enumerable:!1,value:!0,writable:!0})}function Se(e,t,n){ve(e),n&&(de.set(n,t),ye(n));let r=t;for(;r;)xe(r),r=de.get(r)}function Ce(e){let t=pe.get(e);return!!(t!=null&&t[0])&&t[0].loc.start.line>e.loc.start.line}function we(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 Te(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 Ee(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 De=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 je)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new Ae(e,!1)}let e=t.toISOString().split(`T`)[0];return new Oe(e)}if(e.IS_TIME_ONLY.test(n)){if(t instanceof ke)return t;{let e=we(t),r=Te(e.ms,n);return new ke(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=we(t),r=Te(e.ms,n);return new Ae(`${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=we(t),r=Te(e.ms,n);return new Ae(`${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=we(new Date(t.getTime()+Ee(i)*6e4)),s=a?` `:`T`,c=Te(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new je(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}return t}},Oe=class extends Date{constructor(e){super(e)}toISOString(){let e=we(this);return`${e.year}-${e.month}-${e.day}`}},ke=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=we(this);return`${e.hours}:${e.minutes}:${e.seconds}${Te(e.ms,this.originalFormat)}`}},Ae=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=we(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${Te(e.ms,this.originalFormat)}`}},je=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=we(new Date(this.getTime()+Ee(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=Te(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 Me=De,Ne=`true`,Pe=/e/i,Fe=/_/g,Ie=/^[+-]?inf$/,Le=/^[+-]?nan$/,Re=/^[+-]?0x/i;function ze(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const Be=/^[+-]?0o/i,Ve=/^[+-]?0b/i;function He(e,t,n){for(let r=0;r<e.length;r++)if(!ze(e.charCodeAt(r)))throw new C(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function Ue(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new C(t,n,`Multiline strings cannot be keys`)}function We(e,t,n){try{return te(e)}catch(e){throw new C(t,n,e.message)}}function Ge(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 Ke(e,t,n,r){let i=e.replace(Fe,``);if(/^[+-]?0\d/.test(i)&&!Re.test(e)&&!Be.test(e)&&!Ve.test(e))throw new C(t,n,`Leading zeros are not allowed in ${r}`)}function qe(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 Je(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 Ye(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 Xe(e,t,n){if(Re.test(e)||Be.test(e)||Ve.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new C(t,n,`Invalid integer "${e}"`)}function Ze(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*Qe(e,t){let n=new ie(O(e,t)),r=he(e);for(;!n.next().done;){let t=lt(n,e);for(let e of t)r(e),yield e}}function*$e(e,t){for(let t of e)yield t;let n=new ie(O(t));for(;!n.next().done;){let e=lt(n,t);for(let t of e)yield t}}function et(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function tt(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;Ue(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||He(a,t,e.value.loc.start);let o;for(o=[We(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(`'`)||He(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=lt(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 nt(e,t){let n=We(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function rt(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===Ne}}function it(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&Me.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&Me.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(ot(r,t,n.start),Me.IS_FULL_DATE.test(r))i=Me.IS_DATE_ONLY.test(r)?new Oe(r):Me.IS_LOCAL_DATETIME_T.test(r)?new Ae(r,!1):Me.IS_LOCAL_DATETIME_SPACE.test(r)?new Ae(r,!0):Me.IS_OFFSET_DATETIME_T.test(r)?new je(r,!1):Me.IS_OFFSET_DATETIME_SPACE.test(r)?new je(r,!0):new Date(r.replace(` `,`T`));else if(Me.IS_TIME_ONLY.test(r))i=new ke(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 at(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 ot(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;Je(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;Je(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>at(parseInt(r,10),u))throw new C(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Ye(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Ye(r,i,a,e,t,n)}}function st(e,t){let n=e.value.loc,r=e.value.raw,i;if(Ie.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(Le.test(r)){let e=new Float64Array(1),t=new DataView(e.buffer);r.startsWith(`-`)?(t.setUint32(0,0,!0),t.setUint32(4,4294443008,!0)):(t.setUint32(0,0,!0),t.setUint32(4,2146959360,!0)),i=e[0];let a=r.startsWith(`+`)?`+`:r.startsWith(`-`)?`-`:void 0;return{type:`Float`,loc:n,raw:r,value:i,nanSign:a}}else if(!e.peek().done&&e.peek().value.type===`Dot`){let a=n.start;{if(Pe.test(r)&&!Re.test(r))throw new C(t,n.start,`Float "${r}": dot after exponent`);let e=r;Ke(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`);Ge(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}"`);Ge(n,t,e.value.loc.start,!1),qe(n,r,t,e.value.loc.start)}i=Number(r.replace(Fe,``))}else{if(Ge(r,t,n.start),qe(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`);Ke(r,t,n.start,`the integer part of a float`),i=Number(r.replace(Fe,``))}if(Number.isNaN(i)&&!Le.test(r))throw new C(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function ct(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`);Ke(n,t,r.start,`decimal integers`),Ge(n,t,r.start),Xe(n,t,r.start);let i=10;Re.test(n)?(i=16,Ze(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):Be.test(n)?(i=8,Ze(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):Ve.test(n)&&(i=2,Ze(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(Fe,``).replace(Be,``).replace(Ve,``),i);if(Number.isNaN(a))throw new C(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function lt(e,t){if(e.value.type===`Comment`)return[et(e)];if(e.value.type===`Bracket`)return[tt(e,t)];if(e.value.type===`Literal`)return ut(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 ut(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 ':'`);Ue(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||He(n,t,e.value.loc.start);let r;r=[We(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();let n=e.value;e.next();let r=e.value.raw;Ue(r,t,e.value.loc.start),r.startsWith(`"`)||r.startsWith(`'`)||He(r,t,e.value.loc.start);let a=v(t,i.loc.end),o=v(t,n.loc.end),s=a.slice(i.loc.end.column,n.loc.start.column),c=o.slice(n.loc.end.column,e.value.loc.start.column);i.loc.end=e.value.loc.end,i.raw+=`${s}.${c}${e.value.raw}`,i.value.push(We(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=dt(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 dt(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[nt(e,t)]:n===Ne||n===`false`?[rt(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[it(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||Ie.test(n)||Le.test(n)||Pe.test(n)&&!Re.test(n)?[st(e,t)]:[ct(e,t)]}if(e.value.type===`Curly`){let[n,r]=pt(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=mt(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 ft(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 pt(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(et(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=lt(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=ft(n.items);e!==void 0&&ce(n,e)}return[n,r]}function mt(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(et(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=dt(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=ft(n.items);e!==void 0&&ce(n,e)}return[n,r]}function N(e){return e[e.length-1]}function ht(){return Object.create(null)}function gt(e){return typeof e==`string`}function _t(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)&&e>=-(2**53-1)&&e<=2**53-1}function vt(e){return typeof e==`bigint`}function yt(e){return typeof e==`number`&&(!_t(e)||!isFinite(e)||Object.is(e,-0))}function bt(e){return typeof e==`boolean`}function xt(e){return Object.prototype.toString.call(e)===`[object Date]`}const St=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function Ct(e){var t;return typeof e==`object`&&!!e&&St.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function wt(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 P(e){return e&&typeof e==`object`&&!xt(e)&&!Ct(e)&&!Array.isArray(e)}function Tt(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function Et(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function Dt(e){return e.startsWith(`"""`)}function Ot(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function kt(e){return e.startsWith(`'''`)}function At(e,t){return t in e}function F(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 jt(e,t){return Ct(e)&&Ct(t)?e.toString()===t.toString():xt(e)&&xt(t)?e.toISOString()===t.toISOString():!1}function Mt(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(P(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(Ct(i))t.push(JSON.stringify(i.toString()));else if(xt(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 Nt(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 Pt=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function Ft(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 It(e,t){if(Pt!==void 0&&Pt.call(e))return;let n=Ft(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 Lt(e,t){Tt(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)}}function Rt(e){return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}function zt(e){return e.charCodeAt(0)===65279}function Bt(e){return zt(e)?e.slice(1):e}const Vt=`auto`,Ht=`auto`;function Ut(e){for(let t of e){let e=qt(t);if(e!==null)return e}return!1}function Wt(e,t){for(let n of t){let t=Gt(n,e);if(t!==null)return t}return!0}function Gt(e,t){if(!e||typeof e!=`object`)return null;if((e.type===`InlineArray`||e.type===`InlineTable`)&&e.loc){let n=Kt(e.loc,t);if(n!==null)return n}if(e.items&&Array.isArray(e.items))for(let n of e.items){let e=Gt(n,t);if(e!==null)return e;if(n.item){let e=Gt(n.item,t);if(e!==null)return e}}for(let n of[`value`,`key`,`item`])if(e[n]){let r=Gt(e[n],t);if(r!==null)return r}return null}function Kt(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+=`
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 oe(e){return e.charCodeAt(0)===10?e.slice(1):e.charCodeAt(0)===13&&e.charCodeAt(1)===10?e.slice(2):e}var se=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 le();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?le():(this.peeked||=this.iterator.next(),this.peeked)}[Symbol.iterator](){return this}};const ce=Object.freeze({value:void 0,done:!0});function le(){return ce}const ue=new WeakMap;function de(e,t){ue.set(e,t)}function fe(e){return ue.get(e)}const pe=new WeakMap,me=new WeakMap,he=new WeakSet,ge=new WeakMap;function _e(e,t){return(e[t.line-1]??e[e.length-1])+t.column}function ve(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=[_e(n,i.loc.start),_e(n,i.loc.end)];if(Object.defineProperty(i,"range",{configurable:!0,enumerable:!1,value:s}),pe.set(i,e),ge.set(i,be(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 pe.get(e)}function ye(e){let t=ge.get(e);if(!t)return!1;let n=be(e);return t.length===n.length&&t.every((e,t)=>e===n[t])}function be(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 xe(e){if(he.has(e))return;let t=[e];for(;t.length>0;){let e=t.pop();for(let n of be(e))me.set(n,e),t.push(n)}he.add(e)}function Se(e){let t=[e];for(;t.length>0;){let e=t.pop();we(e);for(let n of be(e))t.push(n)}}function Ce(e){Se(e)}function we(e){Object.defineProperty(e,"dirty",{configurable:!0,enumerable:!1,value:!0,writable:!0})}function Te(e,t,n){xe(e),n&&(me.set(n,t),Se(n));let r=t;for(;r;)we(r),r=me.get(r)}function Ee(e){let t=ge.get(e);return!!(t!=null&&t[0])&&t[0].loc.start.line>e.loc.start.line}function De(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 Oe(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 ke(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 Ae=class e{static IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/;static IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;static IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/;static IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/;static IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;static createDateWithOriginalFormat(t,n){if(e.IS_DATE_ONLY.test(n)){if(t.getUTCHours()!==0||t.getUTCMinutes()!==0||t.getUTCSeconds()!==0||t.getUTCMilliseconds()!==0){if(t instanceof Pe)return t;let e=t.toISOString().replace(`Z`,``);return e=e.replace(/\.000$/,``),new Ne(e,!1)}let e=t.toISOString().split(`T`)[0];return new je(e)}if(e.IS_TIME_ONLY.test(n)){if(t instanceof Me)return t;{let e=De(t),r=Oe(e.ms,n);return new Me(`${e.hours}:${e.minutes}:${e.seconds}${r}`,n)}}if(e.IS_LOCAL_DATETIME_T.test(n)){let e=De(t),r=Oe(e.ms,n);return new Ne(`${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=De(t),r=Oe(e.ms,n);return new Ne(`${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=De(new Date(t.getTime()+ke(i)*6e4)),s=a?` `:`T`,c=Oe(o.ms,n,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return new Pe(`${o.year}-${o.month}-${o.day}${s}${o.hours}:${o.minutes}:${o.seconds}${c}${i}`,a)}return t}},je=class extends Date{constructor(e){super(e)}toISOString(){let e=De(this);return`${e.year}-${e.month}-${e.day}`}},Me=class extends Date{originalFormat;constructor(e,t){let n=e;/:\d{2}:\d{2}/.test(e)||(n=e+`:00`),super(`0000-01-01T${n}Z`),this.originalFormat=t}toISOString(){let e=De(this);return`${e.hours}:${e.minutes}:${e.seconds}${Oe(e.ms,this.originalFormat)}`}},Ne=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=De(this),t=this.useSpaceSeparator?` `:`T`;return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${Oe(e.ms,this.originalFormat)}`}},Pe=class extends Date{useSpaceSeparator=!1;originalOffset;originalFormat;constructor(e,t=!1){let n=e;/\d{2}:\d{2}:\d{2}/.test(e)||(n=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,`$1:00$2`)),super(n.replace(` `,`T`)),this.useSpaceSeparator=t,this.originalFormat=e;let r=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);r&&(this.originalOffset=r[1]===`z`?`Z`:r[1])}toISOString(){if(this.originalOffset){let e=De(new Date(this.getTime()+ke(this.originalOffset)*6e4)),t=this.useSpaceSeparator?` `:`T`,n=Oe(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 Fe=Ae,Ie=`true`,Le=/e/i,Re=/_/g,ze=/^[+-]?inf$/,Be=/^[+-]?nan$/,Ve=/^[+-]?0x/i;function He(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===95||e===45}const Ue=/^[+-]?0o/i,We=/^[+-]?0b/i;function Ge(e,t,n){for(let r=0;r<e.length;r++)if(!He(e.charCodeAt(r)))throw new D(t,{line:n.line,column:n.column+r},`Invalid bare key char '${e[r]}'`)}function Ke(e,t,n){if(e.startsWith(`"""`)||e.startsWith(`'''`))throw new D(t,n,`Multiline strings cannot be keys`)}function qe(e,t,n){try{return ie(e)}catch(e){throw new D(t,n,e.message)}}function Je(e,t,n,r=!0){if(e.endsWith(`_`)||(r?/^[+-]?_/.test(e):e.startsWith(`_`)))throw new D(t,n,`Underscore must be between digits`);if(/__/.test(e))throw new D(t,n,`Consecutive underscores not allowed`)}function Ye(e,t,n,r){let i=e.replace(Re,``);if(/^[+-]?0\d/.test(i)&&!Ve.test(e)&&!Ue.test(e)&&!We.test(e))throw new D(t,n,`Leading zeros are not allowed in ${r}`)}function Xe(e,t,n,r){if(/_[eE]/.test(e))throw new D(n,r,`Underscore before exponent is not allowed`);if(/[eE][+-]?_/.test(e))throw new D(n,r,`Underscore at start of exponent is not allowed`);if(/[eE][+-]?$/.test(e))throw new D(n,r,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new D(n,r,`Invalid float "${t}": decimal point not allowed in exponent`)}function Ze(e,t,n,r,i,a){if(e.length!==2)throw new D(i,a,`"${r}": hour must be 2 digits`);if(t.length!==2)throw new D(i,a,`"${r}": minute must be 2 digits`);if(n&&n.length!==2)throw new D(i,a,`"${r}": second must be 2 digits`)}function Qe(e,t,n,r,i,a){if(e!==void 0){let t=parseInt(e,10);if(t<0||t>23)throw new D(i,a,`"${r}": hour must be 00-23`)}if(t!==void 0){let e=parseInt(t,10);if(e<0||e>59)throw new D(i,a,`"${r}": minute must be 00-59`)}if(n!==void 0){let e=parseInt(n,10);if(e<0||e>60)throw new D(i,a,`"${r}": second must be 00-60`)}}function $e(e,t,n){if(Ve.test(e)||Ue.test(e)||We.test(e))return;let r=e.replace(/^[+-]/,``).replace(/_/g,``);if(!/^[0-9]+$/.test(r))throw new D(t,n,`Invalid integer "${e}"`)}function et(e,t,n,r,i,a,o){let s=r[0]+r[1].toUpperCase();if(RegExp(`^[+\\-]?`+s.replace(/([[\]])/g,`\\$1`)).test(e))throw new D(t,n,`${a} prefix must be lowercase "${r}"`);if(RegExp(`^[+\\-]?`+r+`_`,`i`).test(e))throw new D(t,n,`Underscore must be between digits`);let c=RegExp(`^[+\\-]?`+r,`i`),l=e.replace(c,``);if(!l||l===`_`||l.startsWith(`_`))throw new D(t,n,`Incomplete ${a.toLowerCase()} number`);let u=l.replace(/_/g,``);if(!i.test(u))throw new D(t,n,o??`Invalid ${a.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new D(t,n,`${a} numbers cannot have a sign prefix`)}function*tt(e,t){let n=new se(te(e,t)),r=ve(e);try{for(;!n.next().done;){let t=ft(n,e);for(let e of t)r(e),yield e}}finally{y()}}function*nt(e,t){for(let t of e)yield t;let n=new se(te(t));try{for(;!n.next().done;){let e=ft(n,t);for(let t of e)yield t}}finally{y()}}function rt(e){return{type:`Comment`,loc:e.value.loc,raw:e.value.raw}}function it(e,t){let n=!e.peek().done&&e.peek().value.type===`Bracket`?`TableArray`:`Table`,r=n===`Table`;if(r&&e.value.raw!==`[`)throw new D(t,e.value.loc.start,`Expected table opening "[", found ${e.value.raw}`);if(!r){let n=e.peek();if(n.done)throw new D(t,e.value.loc.start,`Expected "[[" for Array of Tables, found end of input`);if(e.value.raw!==`[`||n.value.raw!==`[`)throw new D(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 D(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 D(t,i.loc.start,`Expected table key, reached end of file`);if(e.value.type===`Bracket`&&e.value.raw===`]`)throw new D(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;Ke(a,t,e.value.loc.start),a.startsWith(`"`)||a.startsWith(`'`)||Ge(a,t,e.value.loc.start);let o;for(o=[qe(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(`'`)||Ge(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(ie(e.value.raw))}catch(n){let r=n;throw new D(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 D(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 D(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 D(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 D(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 D(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=ft(e,t);for(let e=0;e<n.length;e++)s.push(n[e])}return{type:r?`Table`:`TableArray`,loc:{start:w(i.loc.start),end:s.length?w(s[s.length-1].loc.end):w(i.loc.end)},key:i,items:s}}function at(e,t){let n=qe(e.value.raw,t,e.value.loc.start);return{type:`String`,loc:e.value.loc,raw:e.value.raw,value:n}}function ot(e){return{type:`Boolean`,loc:e.value.loc,value:e.value.raw===Ie}}function st(e,t){let n=e.value.loc,r=e.value.raw,i;if(!e.peek().done&&e.peek().value.type===`Literal`&&Fe.IS_FULL_DATE.test(r)&&/^\d/.test(e.peek().value.raw)&&Fe.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 D(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(lt(r,t,n.start),Fe.IS_FULL_DATE.test(r))i=Fe.IS_DATE_ONLY.test(r)?new je(r):Fe.IS_LOCAL_DATETIME_T.test(r)?new Ne(r,!1):Fe.IS_LOCAL_DATETIME_SPACE.test(r)?new Ne(r,!0):Fe.IS_OFFSET_DATETIME_T.test(r)?new Pe(r,!1):Fe.IS_OFFSET_DATETIME_SPACE.test(r)?new Pe(r,!0):new Date(r.replace(` `,`T`));else if(Fe.IS_TIME_ONLY.test(r))i=new Me(r,r);else{let[e]=new Date().toISOString().split(`T`);i=new Date(`${e}T${r}`)}return{type:`DateTime`,loc:n,raw:r,value:i}}function ct(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 lt(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new D(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new D(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 D(t,n,`Offset "${e}": missing colon separator`);if(i.length!==2)throw new D(t,n,`Offset "${e}": hour must be 2 digits`);if(!o||o.length===0)throw new D(t,n,`Offset "${e}": minute required`);if(o.length!==2)throw new D(t,n,`Offset "${e}": minute must be 2 digits`);let s=parseInt(i,10);if(s<0||s>23)throw new D(t,n,`Offset "${e}": hour must be 00-23`);let c=parseInt(o,10);if(c<0||c>59)throw new D(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 D(t,n,`"${e}": 'T' requires time component`):/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e)?new D(t,n,`Invalid date "${e}": unexpected character after date`):/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e)?new D(t,n,`"${e}": missing 'T' or space separator`):new D(t,n,`Invalid datetime "${e}"`);let i=e.match(/^(\d+)-/);if(i&&i[1].length!==4)throw new D(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 D(t,n,`"${e}": month must be 2 digits`);if(i.length!==2)throw new D(t,n,`"${e}": day must be 2 digits`)}let o=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(o){let[,r,i,a]=o;Ze(r,i,a,e,t,n)}let s=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(s&&!a){let[,r,i,a]=s;Ze(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 D(t,n,`"${e}": month must be 01-12`);let d=parseInt(a,10);if(d<1||d>31)throw new D(t,n,`"${e}": day must be 01-31`);if(d>ct(parseInt(r,10),u))throw new D(t,n,`"${e}": day ${a} invalid for ${r}-${i}`);Qe(o,s,l,e,t,n)}else if(l){let[,r,i,a]=l;Qe(r,i,a,e,t,n)}}function ut(e,t){let n=e.value.loc,r=e.value.raw,i;if(ze.test(r))i=r.startsWith(`-`)?-1/0:1/0;else if(Be.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(Le.test(r)&&!Ve.test(r))throw new D(t,n.start,`Float "${r}": dot after exponent`);let e=r;Ye(e,t,n.start,`the integer part of a float`);let i=e.replace(/^[+-]/,``);if(i===``||i===`_`)throw new D(t,n.start,`Float: digit required before dot`);Je(e,t,n.start)}if(e.next(),e.peek().done||e.peek().value.type!==`Literal`)throw new D(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 D(t,e.value.loc.start,`Float: fraction must start with digit, found "${n}"`);Je(n,t,e.value.loc.start,!1),Xe(n,r,t,e.value.loc.start)}i=Number(r.replace(Re,``))}else{if(Je(r,t,n.start),Xe(r,r,t,n.start),!e.peek().done&&e.peek().value.type===`Dot`)throw new D(t,e.peek().value.loc.start,`Float "${r}.": dot after exponent`);Ye(r,t,n.start,`the integer part of a float`),i=Number(r.replace(Re,``))}if(Number.isNaN(i)&&!Be.test(r))throw new D(t,n.start,`Invalid float "${r}"`);return{type:`Float`,loc:n,raw:r,value:i}}function dt(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 D(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 D(t,r.start,`Double sign is not allowed in integers`);Ye(n,t,r.start,`decimal integers`),Je(n,t,r.start),$e(n,t,r.start);let i=10;Ve.test(n)?(i=16,et(n,t,r.start,`0x`,/^[0-9a-fA-F]+$/,`Hexadecimal`)):Ue.test(n)?(i=8,et(n,t,r.start,`0o`,/^[0-7]+$/,`Octal`,`Invalid octal digits (must be 0-7)`)):We.test(n)&&(i=2,et(n,t,r.start,`0b`,/^[01]+$/,`Binary`,`Invalid binary digits (must be 0 or 1)`));let a=parseInt(n.replace(Re,``).replace(Ue,``).replace(We,``),i);if(Number.isNaN(a))throw new D(t,r.start,`Invalid integer "${n}"`);return{type:`Integer`,loc:r,raw:n,value:a}}function ft(e,t){if(e.value.type===`Comment`)return[rt(e)];if(e.value.type===`Bracket`)return[it(e,t)];if(e.value.type===`Literal`)return pt(e,t);throw e.value.type===`Equal`?new D(t,e.value.loc.start,`Missing key before '='`):new D(t,e.value.loc.start,`Unexpected token "${e.value.type}"`)}function pt(e,t){let n=e.value.raw;if(n.endsWith(`:`))throw new D(t,{line:e.value.loc.start.line,column:e.value.loc.start.column+[...n].length-1},`Use '=' to separate keys and values, not ':'`);Ke(n,t,e.value.loc.start),n.startsWith(`"`)||n.startsWith(`'`)||Ge(n,t,e.value.loc.start);let r;r=[qe(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();let n=e.value;e.next();let r=e.value.raw;Ke(r,t,e.value.loc.start),r.startsWith(`"`)||r.startsWith(`'`)||Ge(r,t,e.value.loc.start);let a=S(t,i.loc.end),o=S(t,n.loc.end),s=a.slice(i.loc.end.column,n.loc.start.column),c=o.slice(n.loc.end.column,e.value.loc.start.column);i.loc.end=e.value.loc.end,i.raw+=`${s}.${c}${e.value.raw}`,i.value.push(qe(e.value.raw,t,e.value.loc.start))}if(e.next(),!e.done&&e.value.loc.start.line!==i.loc.end.line)throw new D(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 D(t,e.value.loc.start,`Use '=' to separate keys and values, not ':'`):new D(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 D(t,i.loc.start,`Expected value, reached EOF`);if(e.value.loc.start.line!==o)throw new D(t,e.value.loc.start,`Value must be on same line as '='`);if(e.done)throw new D(t,i.loc.start,`Expected value for key-value`);let s=mt(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 D(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 D(t,n.loc.start,`Key/value pairs must be separated by a newline`)}return s[0]={type:`KeyValue`,key:i,value:c,loc:{start:w(i.loc.start),end:w(c.loc.end)},equals:a},s}function mt(e,t){if(e.value.type===`Literal`){let n=e.value.raw;return n[0]===`"`||n[0]===`'`?[at(e,t)]:n===Ie||n===`false`?[ot(e)]:/^\d/.test(n)&&(/^\d{1,}-\d{1,}/.test(n)||/^\d{1,}:\d{1,}/.test(n))?[st(e,t)]:!e.peek().done&&e.peek().value.type===`Dot`||ze.test(n)||Be.test(n)||Le.test(n)&&!Ve.test(n)?[ut(e,t)]:[dt(e,t)]}if(e.value.type===`Curly`){let[n,r]=gt(e,t);return[n,...r]}if(e.value.type===`Bracket`){let[n,r]=_t(e,t);return[n,...r]}throw e.value.type===`Dot`?new D(t,e.value.loc.start,`Number cannot start with a dot`):new D(t,e.value.loc.start,`Unrecognized token type`)}function ht(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 gt(e,t){if(e.value.raw!==`{`)throw new D(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(rt(e)),e.next();continue}if(e.value.type===`Comma`){let r=n.items[n.items.length-1];if(!r)throw new D(t,e.value.loc.start,`Leading comma in inline table`);if(r.comma)throw new D(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 D(t,e.value.loc.start,`Missing comma between inline table items`);let a=ft(e,t),o=a[0];if(o.type===`KeyValue`){n.items.push({type:`InlineItem`,loc:T(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 D(t,e.done?n.loc.start:e.value.loc.start,`Expected "}"`);n.loc.end=e.value.loc.end;{let e=ht(n.items);e!==void 0&&de(n,e)}return[n,r]}function _t(e,t){if(e.value.raw!==`[`)throw new D(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 D(t,e.value.loc.start,`Leading comma in array`);if(r.comma)throw new D(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(rt(e));else{let i=n.items[n.items.length-1];if(i&&!i.comma)throw new D(t,e.value.loc.start,`Missing comma between array elements`);let a=mt(e,t),o=a[0];n.items.push({type:`InlineItem`,loc:T(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 D(t,e.done?n.loc.start:e.value.loc.start,`Expected "]"`);n.loc.end=e.value.loc.end;{let e=ht(n.items);e!==void 0&&de(n,e)}return[n,r]}function P(e){return e[e.length-1]}function vt(){return Object.create(null)}function yt(e){return typeof e==`string`}function bt(e){return typeof e==`number`&&e%1==0&&isFinite(e)&&!Object.is(e,-0)&&e>=-(2**53-1)&&e<=2**53-1}function xt(e){return typeof e==`bigint`}function St(e){return typeof e==`number`&&(!bt(e)||!isFinite(e)||Object.is(e,-0))}function Ct(e){return typeof e==`boolean`}function wt(e){return Object.prototype.toString.call(e)===`[object Date]`}const Tt=new Set([`Temporal.PlainDate`,`Temporal.PlainTime`,`Temporal.PlainDateTime`,`Temporal.ZonedDateTime`,`PlainDate`,`PlainTime`,`PlainDateTime`,`ZonedDateTime`]);function Et(e){var t;return typeof e==`object`&&!!e&&Tt.has((t=e.constructor)==null?void 0:t.name)&&typeof e.equals==`function`}function Dt(e){var t;let n=((t=e.constructor)==null?void 0:t.name)??``;if(n===`Temporal.ZonedDateTime`||n===`ZonedDateTime`){let t=e.toString(),n=t.match(/\[(.+)\]$/);if(n&&!/^[+-]\d{2}:\d{2}$/.test(n[1]))throw Error(`ZonedDateTime with IANA timezone "${t}" cannot be represented in TOML. TOML only supports offset-based timezones (+05:30, Z).`);return t.replace(/\[.*\]$/,``).replace(/(\+00:00)$/,`Z`)}let r=e.toString();if(/\[.*\]/.test(r))throw Error(`Temporal value contains unsupported annotation: "${r}". TOML only supports ISO 8601 calendar.`);return r}function F(e){return e&&typeof e==`object`&&!wt(e)&&!Et(e)&&!Array.isArray(e)}function Ot(e){return e!=null&&typeof e[Symbol.iterator]==`function`}function kt(e){return e.startsWith(`"`)&&!e.startsWith(`"""`)}function At(e){return e.startsWith(`"""`)}function jt(e){return e.startsWith(`'`)&&!e.startsWith(`'''`)}function Mt(e){return e.startsWith(`'''`)}function Nt(e,t){return t in e}function I(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Pt(e,t){return Et(e)&&Et(t)?e.toString()===t.toString():wt(e)&&wt(t)?e.toISOString()===t.toISOString():!1}function Ft(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(F(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(Et(i))t.push(JSON.stringify(i.toString()));else if(wt(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 It(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 Lt=typeof String.prototype.isWellFormed==`function`?String.prototype.isWellFormed:void 0;function Rt(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 zt(e,t){if(Lt!==void 0&&Lt.call(e))return;let n=Rt(e);if(!n)return;let r=n.code.toString(16).toUpperCase().padStart(4,`0`);throw Error(`${t} contains a lone surrogate (U+${r}) at index ${n.index}. Unpaired surrogates are not Unicode scalar values and cannot be encoded as TOML.`)}function Bt(e,t){Ot(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)}}function Vt(e){return new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}).decode(e)}function Ht(e){return e.charCodeAt(0)===65279}function Ut(e){return Ht(e)?e.slice(1):e}const Wt=`auto`,Gt=`auto`;function Kt(e){for(let t of e){let e=Xt(t);if(e!==null)return e}return!1}function qt(e,t){for(let n of t){let t=Jt(n,e);if(t!==null)return t}return!0}function Jt(e,t){if(!e||typeof e!=`object`)return null;if((e.type===`InlineArray`||e.type===`InlineTable`)&&e.loc){let n=Yt(e.loc,t);if(n!==null)return n}if(e.items&&Array.isArray(e.items))for(let n of e.items){let e=Jt(n,t);if(e!==null)return e;if(n.item){let e=Jt(n.item,t);if(e!==null)return e}}for(let n of[`value`,`key`,`item`])if(e[n]){let r=Jt(e[n],t);if(r!==null)return r}return null}function Yt(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+=`
10
10
  `+(n[e]||``);n[i]&&(s+=`
11
- `+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 qt(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 Jt(e.items);if(e.type===`KeyValue`&&e.value)return qt(e.value);if(e.items&&Array.isArray(e.items))for(let t of e.items){let e=qt(t);if(e!==null)return e}return null}function Jt(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 Yt(e){let t=e.indexOf(`
11
+ `+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 Xt(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 Zt(e.items);if(e.type===`KeyValue`&&e.value)return Xt(e.value);if(e.items&&Array.isArray(e.items))for(let t of e.items){let e=Xt(t);if(e!==null)return e}return null}function Zt(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 Qt(e){let t=e.indexOf(`
12
12
  `);return t>0&&e[t-1]===`\r`?`\r
13
13
  `:`
14
- `}function Xt(e){let t=0,n=e.length;for(;n>0&&e[n-1]===`
15
- `;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function Zt(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>0&&n>=r}function Qt(e){let t=0;for(;t<e.length&&e[t]===` `;)t++;return t}function $t(e,t){let n=e.split(/\r?\n/),r=[],i=new Set([`Table`,`TableArray`,`InlineTable`,`InlineArray`]),a=new Set([`Table`,`TableArray`,`InlineTable`,`InlineArray`,`KeyValue`,`InlineItem`,`Comment`]),o=(e,t)=>{var s,c,l;if(!e||typeof e!=`object`)return;if(t!==void 0&&a.has(e.type)&&((s=e.loc)==null||(s=s.start)==null?void 0:s.line)>t){let t=Qt(n[e.loc.start.line-1]??``);t>0&&r.push(t)}let u=i.has(e.type)&&((c=e.loc)==null||(c=c.end)==null?void 0:c.line)>((l=e.loc)==null||(l=l.start)==null?void 0:l.line)?e.loc.start.line:t;if(Array.isArray(e.items))for(let t of e.items)o(t,u);e.item&&o(e.item,u),e.value&&o(e.value,u)},s=Array.isArray(t)?t:Array.from(t??[]);for(let e of s)o(e);if(r.length>0)return Math.min(...r);let c=n.filter(e=>e.trim().length>0&&!e.trimStart().startsWith(`#`)).map(Qt).filter(e=>e>0);return c.length>0?Math.min(...c):2}const en=new Map([[`
14
+ `}function $t(e){let t=0,n=e.length;for(;n>0&&e[n-1]===`
15
+ `;)t++,n--,n>0&&e[n-1]===`\r`&&n--;return t}function en(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>0&&n>=r}function tn(e){let t=0;for(;t<e.length&&e[t]===` `;)t++;return t}function nn(e,t){let n=e.split(/\r?\n/),r=[],i=new Set([`Table`,`TableArray`,`InlineTable`,`InlineArray`]),a=new Set([`Table`,`TableArray`,`InlineTable`,`InlineArray`,`KeyValue`,`InlineItem`,`Comment`]),o=(e,t)=>{var s,c,l;if(!e||typeof e!=`object`)return;if(t!==void 0&&a.has(e.type)&&((s=e.loc)==null||(s=s.start)==null?void 0:s.line)>t){let t=tn(n[e.loc.start.line-1]??``);t>0&&r.push(t)}let u=i.has(e.type)&&((c=e.loc)==null||(c=c.end)==null?void 0:c.line)>((l=e.loc)==null||(l=l.start)==null?void 0:l.line)?e.loc.start.line:t;if(Array.isArray(e.items))for(let t of e.items)o(t,u);e.item&&o(e.item,u),e.value&&o(e.value,u)},s=Array.isArray(t)?t:Array.from(t??[]);for(let e of s)o(e);if(r.length>0)return Math.min(...r);let c=n.filter(e=>e.trim().length>0&&!e.trimStart().startsWith(`#`)).map(tn).filter(e=>e>0);return c.length>0?Math.min(...c):2}const rn=new Map([[`
16
16
  `,`
17
17
  `],[`\r
18
18
  `,`\r
@@ -22,33 +22,33 @@ function e(e){return e.type===`Document`}function t(e){return e.type===`Table`}f
22
22
  `],[`CRLF`,`\r
23
23
  `],[`UNIX`,`
24
24
  `],[`DOS`,`\r
25
- `]]);function tn(e){let t=en.get(e)??en.get(e.toUpperCase());if(t===void 0)throw TypeError(`Invalid newLine value: expected LF or CRLF`);return t}function nn(e){if(!e||typeof e!=`object`)return{};let t=e=>typeof e==`boolean`?null:`expected boolean, got ${typeof e}`,n=e=>e==null||typeof e==`boolean`||e===`auto`||e===`parent`||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected boolean, non-negative integer, "auto" or "parent", got ${typeof e}`,r={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,indentWidth:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>0?null:`expected positive integer or undefined, got ${typeof e}`,minimumDecimals:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected non-negative integer or undefined, got ${typeof e}`,updateOrder:t,multilineTable:n,multilineArray:n},i={},a=[],o=[];for(let t in e){let n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;if(n){let r=e[t],a=n(r);a?o.push(`${t} (${a})`):i[t]=r}else Object.prototype.hasOwnProperty.call(e,t)&&a.push(t)}if(a.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${a.join(`, `)}. Supported properties are: ${Object.keys(r).join(`, `)}`),o.length>0)throw TypeError(`Invalid types for format properties: ${o.join(`, `)}`);return`newLine`in i&&(i.newLine=tn(i.newLine)),i}function I(e,t){if(e){if(e instanceof L)return e;{let n=nn(e);return new L(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,n.indentWidth??t.indentWidth,n.multilineTable??t.multilineTable,n.multilineArray??t.multilineArray)}}return t}var L=class e{newLine;trailingNewline;trailingComma;bracketSpacing;leadingBom;inlineTableStart;truncateZeroTimeInDates;useTabsForIndentation;indentWidth;minimumDecimals;updateOrder;multilineTable;multilineArray;constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){this.newLine=e==null?`
26
- `:tn(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.indentWidth=this.useTabsForIndentation?1:u??2,this.minimumDecimals=s??0,this.leadingBom=c??!1,this.updateOrder=l??!1,this.multilineTable=d??`auto`,this.multilineArray=f??`auto`}static default(){return new e(`
27
- `,1,!1,!0,1,!1,!1,0,!1,!1,2,Vt,Ht)}static autoDetectFormat(t){return e.autoDetectFormatWithCst(t)}static autoDetectFormatWithCst(t,n){let r=e.default();r.leadingBom=zt(t);let i=Bt(t),a=[];r.newLine=Yt(i),r.trailingNewline=Xt(i);try{a=Array.isArray(n)?n:Array.from(n??Qe(i)),r.trailingComma=Ut(a),r.bracketSpacing=Wt(i,a)}catch{r.trailingComma=!1,r.bracketSpacing=!0}return r.useTabsForIndentation=Zt(i),r.indentWidth=r.useTabsForIndentation?1:$t(i,a),r.inlineTableStart=1,r.truncateZeroTimeInDates=!1,r.minimumDecimals=0,r.updateOrder=!1,r.multilineTable=Vt,r.multilineArray=Ht,r}static autoDetectFormatWithAst(t,n){return e.autoDetectFormatWithCst(t,n)}};const rn=new WeakMap,an=new WeakSet,on=new WeakSet,sn=new WeakSet,cn=new WeakSet;function ln(e,t,n,r){let i=e===`array`?r.multilineArray:r.multilineTable;return typeof i==`boolean`?i:typeof i==`number`?t>=i:i===`parent`&&n}function un(e,t){rn.set(e,t),t&&e.items.length===0&&(e.loc.end.line=e.loc.start.line+1,e.loc.end.column=e.loc.start.column+1)}function dn(e){return rn.get(e)}function fn(e){an.add(e)}function pn(e){return an.has(e)}function mn(e){on.add(e)}function hn(e){return on.has(e)}function gn(e){sn.add(e)}function _n(e){return sn.has(e)}function vn(e){cn.add(e)}function yn(e){return cn.has(e)}function bn(e){return e.items.length?e.items.some((t,n)=>{let r=e.items[n-1];return t.loc.start.line>((r==null?void 0:r.loc.end.line)??e.loc.start.line)}):e.loc.end.line>e.loc.start.line}function xn(e,t){let n=(e,r)=>{if(e===t)return r;if(a(e))return n(e.value,r);if(u(e))return n(e.item,r);if(l(e)||d(e)){for(let t of e.items){let e=n(t,r+1);if(e!==void 0)return e}return}if(p(e))for(let t of e.items){let e=n(t,r);if(e!==void 0)return e}};return n(e,0)}function Sn(e,t){let n=(e,r)=>{if(e===t)return r;if(a(e))return n(e.value,r);if(u(e))return n(e.item,r);if(l(e)||d(e)){for(let t of e.items){let r=n(t,e);if(r)return r}return}if(p(e))for(let t of e.items){let e=n(t,r);if(e)return e}};return n(e,void 0)}const Cn=new WeakSet,wn=new WeakSet,Tn=new WeakMap,En=new WeakMap;function Dn(e,t){Tn.set(e,t)}function On(e,t){En.set(e,t)}function kn(e){wn.add(e)}const An=new WeakMap,jn=new WeakSet,Mn=new WeakSet;function Nn(e){return Mn.has(e)}function Pn(e){Mn.delete(e)}function Fn(e,t,n){Zn(n,R(e),t)}function In(e){be(e),Cn.add(e)}const Ln=new WeakMap,Rn=e=>(Ln.has(e)||Ln.set(e,new WeakMap),Ln.get(e));function zn(e){return Ln.has(e)||Ln.set(e,new WeakMap),Ln.get(e)}const Bn=new WeakMap;function R(e){return Bn.has(e)||Bn.set(e,new WeakMap),Bn.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);Zn({lines:o.lines-i.lines,columns:o.columns-i.columns},R(e),r,n),Se(e,t,r),Cn.add(e)}function B(t,n,r,i,a,o,s,c=!1){if(!p(n))throw Error(`Unsupported parent type "${n.type}" for insert`);i=i!=null&&typeof i==`number`?i:n.items.length;let u,m;l(n)||d(n)?{shift:u,offset:m}=Gn(n,r,i,Tn.get(t)??2):a&&e(n)?{shift:u,offset:m}=Kn(n,r,i):{shift:u,offset:m}=Hn(t,n,r,i,s),U(r,u,{first_line_only:c});let h=n.items[i-1],g=h&&R(t).get(h);if(g&&(m.lines+=g.lines,m.columns+=g.columns,R(t).delete(h)),(d(n)||l(n))&&m.lines!==0&&(o||p(t))&&t!==n){let e=r.loc.start.line,i=o??t.items,a=Vn(n,i);for(let t=0;t<i.length;t++){let n=i[t];if(!f(n))continue;let r=n.loc.start.line;r<a.loc.start.line||r>a.loc.end.line||r<e&&(n.loc.start.line-=m.lines,n.loc.end.line-=m.lines)}}R(t).set(r,m),Se(t,n,r),Cn.add(t)}function Vn(e,t){for(let n of t){if(!a(n))continue;let t=n.value;if(!l(t)&&!d(t))continue;let r=!1,i=t=>{t===e&&(r=!0)};if(Lt(t,{InlineArray:i,InlineTable:i}),r)return t}return e}function Hn(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(wn.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=!wn.has(n)&&c===void 0&&(t(i)||r(i)||e(i))&&An.has(i),S=x&&!jn.has(i);x&&(An.delete(i),jn.delete(i));let C=x&&!S,w=0;if(C){let e=t(i)||r(i)?R(n).get(i.key):Rn(n).get(i);w=e?-e.lines:1}let T=S||C?_-2:_-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 Un(e,t,n,r={}){let{useNewLine:i=!1,skipCommaSpace:a=2,skipBracketSpace:o=1,hasCommaHandling:s=!1,isLastElement:c=!1,hasSeparatingCommaBefore:u=!1,hasSeparatingCommaAfter:p=!1,hasTrailingComma:m=!1,indentWidth:h=2}=r,_=n>0?e.items[n-1]:void 0,v=_?{line:_.loc.end.line,column:i?f(_)?e.loc.start.column:_.loc.start.column:_.loc.end.column}:b(e.loc.start);if(!_&&i){let t=e.items.find((e,t)=>t>n&&!f(e));t?v.column=t.loc.start.column:e.loc.end.line>e.loc.start.line&&(v.column=(l(e)||d(e)?En.get(e):void 0)??e.loc.end.column-1+h)}let y=0;if(i)y=1;else{let e=u||!s&&!!_;e&&s?v.column+=a:(e||s&&!_)&&(v.column+=o)}v.line+=y;let x={lines:v.line-t.loc.start.line,columns:v.column-t.loc.start.column},S=g(t.loc);if(!s)return{shift:x,offset:{lines:S.lines+(y-1),columns:S.columns}};let C=u&&m&&!p&&c,w=0;C&&(w=-1);let T=S.columns+(u||p?a:0)+(m?1+w:0);return i&&c&&_&&e.loc.end.line===_.loc.end.line&&(T=S.columns-(_.loc.end.column-_.loc.start.column)),{shift:x,offset:{lines:S.lines+(y-1),columns:T}}}function Wn(e){return le(e)??2}function Gn(e,t,n,r){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let i=Wn(e),a=n==null?N(e.items):e.items[n-1],o=n==null||n===e.items.length,s=n==null?void 0:e.items[n];e.items.splice(n,0,t);let c=!!a,l=!o;return c&&(a.comma=!0),l&&(t.comma=!0),Un(e,t,n,{useNewLine:Xn(e,t)&&!(a&&s&&s.loc.start.line===a.loc.end.line&&s.loc.start.column>=a.loc.end.column)&&!(dn(e)!==!0&&d(e)&&!s&&a&&a.loc.end.line===e.loc.end.line),skipCommaSpace:i,hasCommaHandling:!0,isLastElement:o,hasSeparatingCommaBefore:c,hasSeparatingCommaAfter:l,hasTrailingComma:o&&t.comma===!0,indentWidth:r})}function Kn(e,t,n){let r=Un(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`);Se(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;w&&!T&&c===void 0&&h===void 0&&a.loc.start.line>i.loc.start.line&&i.loc.end.line>a.loc.end.line&&vn(i),c===void 0&&h===void 0&&(!w||T)&&(C.lines=0,C.columns=0,(d(i)||l(i))&&Mn.add(i),(t(i)||r(i)||e(i))&&An.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&jn.add(i);let E=l(i)||d(i)?Wn(i):2;if(v&&b&&(C.columns-=E),v&&!c&&h&&(Xn(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=Rn(n));let A=R(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),Cn.add(n),w&&(o||p(n))&&n!==i){let e=a.loc.start.line,t=o??n.items,r=Vn(i,t),s=[];for(let n=0;n<t.length;n++){let a=t[n];if(!f(a))continue;let o=a.loc.start.line;o<r.loc.start.line||o>r.loc.end.line||(o===e&&(o<i.loc.end.line||a.loc.start.column<i.loc.end.column)?s.push(n):C.lines!==0&&o<e&&(a.loc.start.line-=C.lines,a.loc.end.line-=C.lines))}for(let e=s.length-1;e>=0;e--)t.splice(s[e],1)}}function qn(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 Jn(e,t,n=!0){if(!n||!t.items.length)return;Zn({lines:0,columns:1},Rn(e),t);let r=N(t.items);Zn({lines:0,columns:1},R(e),r),Cn.add(e)}function Yn(e,t,n=!1){if(!n||!t.items.length)return;let r=N(t.items);r.comma=!0,Zn({lines:0,columns:1},R(e),r),Cn.add(e)}function H(e){if(!Cn.has(e))return;let t=Rn(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),qn(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),qn(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),qn(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),Cn.delete(e),Ln.delete(e),Bn.delete(e)}function U(e,t,n={}){let{lines:r,columns:i}=t;if(r===0&&i===0)return e;let{first_line_only:o=!1,shift_generated_multiline_end:s=!1}=n,c=e.loc.start.line,f=e.type;if(f===`Key`||f===`String`||f===`Integer`||f===`Float`||f===`Boolean`||f===`DateTime`||f===`Comment`)return(!o||e.loc.start.line===c)&&(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(f===`KeyValue`){let t=e,n=t.value.type;if(n===`String`||n===`Integer`||n===`Float`||n===`Boolean`||n===`DateTime`){let n=!o||t.loc.start.line===c;n&&(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,n&&(t.equals+=i);let a=t.key;(!o||a.loc.start.line===c)&&(a.loc.start.column+=i,a.loc.end.column+=i),a.loc.start.line+=r,a.loc.end.line+=r;let s=t.value;return(!o||s.loc.start.line===c)&&(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 p=e=>{if(!o||e.loc.start.line===c){e.loc.start.column+=i;let t=(!o||s)&&e.loc.end.line!==e.loc.start.line&&((l(e)||d(e))&&dn(e)!==void 0&&!pn(e)||u(e)&&((l(e.item)||d(e.item))&&dn(e.item)!==void 0&&!pn(e.item)||a(e.item)&&(l(e.item.value)||d(e.item.value))&&dn(e.item.value)!==void 0&&!pn(e.item.value))||a(e)&&(l(e.value)||d(e.value))&&dn(e.value)!==void 0);(e.loc.end.line===e.loc.start.line||t)&&(e.loc.end.column+=i)}e.loc.start.line+=r,e.loc.end.line+=r};return Lt(e,{Table:p,TableKey:p,TableArray:p,TableArrayKey:p,KeyValue(e){let t=!o||e.loc.start.line===c;p(e),t&&(e.equals+=i)},Key:p,String:p,Integer:p,Float:p,Boolean:p,DateTime:p,InlineArray:p,InlineItem:p,InlineTable:p,Comment:p}),e}function Xn(e,t){let n=dn(e);if(n===!0)return!0;if(n!==void 0||!e.items.length)return!1;let r=t?e.items.filter(e=>e!==t):e.items;return r.length?e.loc.end.line>e.loc.start.line&&r.every((e,t)=>t===0||e.loc.start.line>r[t-1].loc.start.line):e.loc.end.line>e.loc.start.line}function Zn(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function Qn(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
25
+ `]]);function an(e){let t=rn.get(e)??rn.get(e.toUpperCase());if(t===void 0)throw TypeError(`Invalid newLine value: expected LF or CRLF`);return t}function on(e){if(!e||typeof e!=`object`)return{};let t=e=>typeof e==`boolean`?null:`expected boolean, got ${typeof e}`,n=e=>e==null||typeof e==`boolean`||e===`auto`||e===`parent`||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected boolean, non-negative integer, "auto" or "parent", got ${typeof e}`,r={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,indentWidth:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>0?null:`expected positive integer or undefined, got ${typeof e}`,minimumDecimals:e=>e==null||typeof e==`number`&&Number.isInteger(e)&&e>=0?null:`expected non-negative integer or undefined, got ${typeof e}`,updateOrder:t,multilineTable:n,multilineArray:n},i={},a=[],o=[];for(let t in e){let n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;if(n){let r=e[t],a=n(r);a?o.push(`${t} (${a})`):i[t]=r}else Object.prototype.hasOwnProperty.call(e,t)&&a.push(t)}if(a.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${a.join(`, `)}. Supported properties are: ${Object.keys(r).join(`, `)}`),o.length>0)throw TypeError(`Invalid types for format properties: ${o.join(`, `)}`);return`newLine`in i&&(i.newLine=an(i.newLine)),i}function L(e,t){if(e){if(e instanceof R)return e;{let n=on(e);return new R(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,n.indentWidth??t.indentWidth,n.multilineTable??t.multilineTable,n.multilineArray??t.multilineArray)}}return t}var R=class e{newLine;trailingNewline;trailingComma;bracketSpacing;leadingBom;inlineTableStart;truncateZeroTimeInDates;useTabsForIndentation;indentWidth;minimumDecimals;updateOrder;multilineTable;multilineArray;constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){this.newLine=e==null?`
26
+ `:an(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.indentWidth=this.useTabsForIndentation?1:u??2,this.minimumDecimals=s??0,this.leadingBom=c??!1,this.updateOrder=l??!1,this.multilineTable=d??`auto`,this.multilineArray=f??`auto`}static default(){return new e(`
27
+ `,1,!1,!0,1,!1,!1,0,!1,!1,2,Wt,Gt)}static autoDetectFormat(t){return e.autoDetectFormatWithCst(t)}static autoDetectFormatWithCst(t,n){let r=e.default();r.leadingBom=Ht(t);let i=Ut(t),a=[];r.newLine=Qt(i),r.trailingNewline=$t(i);try{a=Array.isArray(n)?n:Array.from(n??tt(i)),r.trailingComma=Kt(a),r.bracketSpacing=qt(i,a)}catch{r.trailingComma=!1,r.bracketSpacing=!0}return r.useTabsForIndentation=en(i),r.indentWidth=r.useTabsForIndentation?1:nn(i,a),r.inlineTableStart=1,r.truncateZeroTimeInDates=!1,r.minimumDecimals=0,r.updateOrder=!1,r.multilineTable=Wt,r.multilineArray=Gt,r}static autoDetectFormatWithAst(t,n){return e.autoDetectFormatWithCst(t,n)}};const sn=new WeakMap,cn=new WeakSet,ln=new WeakSet,un=new WeakSet,dn=new WeakSet;function fn(e,t,n,r){let i=e===`array`?r.multilineArray:r.multilineTable;return typeof i==`boolean`?i:typeof i==`number`?t>=i:i===`parent`&&n}function pn(e,t){sn.set(e,t),t&&e.items.length===0&&(e.loc.end.line=e.loc.start.line+1,e.loc.end.column=e.loc.start.column+1)}function mn(e){return sn.get(e)}function hn(e){cn.add(e)}function gn(e){return cn.has(e)}function _n(e){ln.add(e)}function vn(e){return ln.has(e)}function yn(e){un.add(e)}function bn(e){return un.has(e)}function xn(e){dn.add(e)}function Sn(e){return dn.has(e)}function Cn(e){return e.items.length?e.items.some((t,n)=>{let r=e.items[n-1];return t.loc.start.line>((r==null?void 0:r.loc.end.line)??e.loc.start.line)}):e.loc.end.line>e.loc.start.line}function wn(e,t){let n=(e,r)=>{if(e===t)return r;if(a(e))return n(e.value,r);if(u(e))return n(e.item,r);if(l(e)||d(e)){for(let t of e.items){let e=n(t,r+1);if(e!==void 0)return e}return}if(p(e))for(let t of e.items){let e=n(t,r);if(e!==void 0)return e}};return n(e,0)}function Tn(e,t){let n=(e,r)=>{if(e===t)return r;if(a(e))return n(e.value,r);if(u(e))return n(e.item,r);if(l(e)||d(e)){for(let t of e.items){let r=n(t,e);if(r)return r}return}if(p(e))for(let t of e.items){let e=n(t,r);if(e)return e}};return n(e,void 0)}const En=new WeakSet,Dn=new WeakSet,On=new WeakMap,kn=new WeakMap;function An(e,t){On.set(e,t)}function jn(e,t){kn.set(e,t)}function Mn(e){Dn.add(e)}const Nn=new WeakMap,Pn=new WeakSet,Fn=new WeakSet;function In(e){return Fn.has(e)}function Ln(e){Fn.delete(e)}function Rn(e,t,n){tr(n,z(e),t)}function zn(e){Ce(e),En.add(e)}const Bn=new WeakMap,Vn=e=>(Bn.has(e)||Bn.set(e,new WeakMap),Bn.get(e));function Hn(e){return Bn.has(e)||Bn.set(e,new WeakMap),Bn.get(e)}const Un=new WeakMap;function z(e){return Un.has(e)||Un.set(e,new WeakMap),Un.get(e)}function Wn(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=b(n.loc),o=b(r.loc);tr({lines:o.lines-i.lines,columns:o.columns-i.columns},z(e),r,n),Te(e,t,r),En.add(e)}function B(t,n,r,i,a,o,s,c=!1){if(!p(n))throw Error(`Unsupported parent type "${n.type}" for insert`);i=i!=null&&typeof i==`number`?i:n.items.length;let u,m;l(n)||d(n)?{shift:u,offset:m}=Yn(n,r,i,On.get(t)??2):a&&e(n)?{shift:u,offset:m}=Xn(n,r,i):{shift:u,offset:m}=Kn(t,n,r,i,s),U(r,u,{first_line_only:c});let h=n.items[i-1],g=h&&z(t).get(h);if(g&&(m.lines+=g.lines,m.columns+=g.columns,z(t).delete(h)),(d(n)||l(n))&&m.lines!==0&&(o||p(t))&&t!==n){let e=r.loc.start.line,i=o??t.items,a=Gn(n,i);for(let t=0;t<i.length;t++){let n=i[t];if(!f(n))continue;let r=n.loc.start.line;r<a.loc.start.line||r>a.loc.end.line||r<e&&(n.loc.start.line-=m.lines,n.loc.end.line-=m.lines)}}z(t).set(r,m),Te(t,n,r),En.add(t)}function Gn(e,t){for(let n of t){if(!a(n))continue;let t=n.value;if(!l(t)&&!d(t))continue;let r=!1,i=t=>{t===e&&(r=!0)};if(Bt(t,{InlineArray:i,InlineTable:i}),r)return t}return e}function Kn(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(Dn.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}:w(i.loc.start),m=t(a)||r(a),g=0;s===void 0?l||u||(g=m?2:1):g=s,p.line+=g;let _={lines:p.line-a.loc.start.line,columns:p.column-a.loc.start.column},v=b(a.loc),y=!Dn.has(n)&&c===void 0&&(t(i)||r(i)||e(i))&&Nn.has(i),x=y&&!Pn.has(i);y&&(Nn.delete(i),Pn.delete(i));let S=y&&!x,C=0;if(S){let e=t(i)||r(i)?z(n).get(i.key):Vn(n).get(i);C=e?-e.lines:1}let T=x||S?g-2:g-1,E={lines:u?v.lines+1:v.lines+T,columns:v.columns};return{shift:{lines:_.lines+C,columns:_.columns},offset:E}}function qn(e,t,n,r={}){let{useNewLine:i=!1,skipCommaSpace:a=2,skipBracketSpace:o=1,hasCommaHandling:s=!1,isLastElement:c=!1,hasSeparatingCommaBefore:u=!1,hasSeparatingCommaAfter:p=!1,hasTrailingComma:m=!1,indentWidth:h=2}=r,g=n>0?e.items[n-1]:void 0,_=g?{line:g.loc.end.line,column:i?f(g)?e.loc.start.column:g.loc.start.column:g.loc.end.column}:w(e.loc.start);if(!g&&i){let t=e.items.find((e,t)=>t>n&&!f(e));t?_.column=t.loc.start.column:e.loc.end.line>e.loc.start.line&&(_.column=(l(e)||d(e)?kn.get(e):void 0)??e.loc.end.column-1+h)}let v=0;if(i)v=1;else{let e=u||!s&&!!g;e&&s?_.column+=a:(e||s&&!g)&&(_.column+=o)}_.line+=v;let y={lines:_.line-t.loc.start.line,columns:_.column-t.loc.start.column},x=b(t.loc);if(!s)return{shift:y,offset:{lines:x.lines+(v-1),columns:x.columns}};let S=u&&m&&!p&&c,C=0;S&&(C=-1);let T=x.columns+(u||p?a:0)+(m?1+C:0);return i&&c&&g&&e.loc.end.line===g.loc.end.line&&(T=x.columns-(g.loc.end.column-g.loc.start.column)),{shift:y,offset:{lines:x.lines+(v-1),columns:T}}}function Jn(e){return fe(e)??2}function Yn(e,t,n,r){if(!u(t))throw Error(`Incompatible child type "${t.type}"`);let i=Jn(e),a=n==null?P(e.items):e.items[n-1],o=n==null||n===e.items.length,s=n==null?void 0:e.items[n];e.items.splice(n,0,t);let c=!!a,l=!o;return c&&(a.comma=!0),l&&(t.comma=!0),qn(e,t,n,{useNewLine:er(e,t)&&!(a&&s&&s.loc.start.line===a.loc.end.line&&s.loc.start.column>=a.loc.end.column)&&!(mn(e)!==!0&&d(e)&&!s&&a&&a.loc.end.line===e.loc.end.line),skipCommaSpace:i,hasCommaHandling:!0,isLastElement:o,hasSeparatingCommaBefore:c,hasSeparatingCommaAfter:l,hasTrailingComma:o&&t.comma===!0,indentWidth:r})}function Xn(e,t,n){let r=qn(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`);Te(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=b(a.loc);h&&f(h)&&h.loc.start.line===a.loc.end.line&&(g=b({start:a.loc.start,end:h.loc.end}),h=i.items[s+1],i.items.splice(s,1));let _=c&&u(c)||h&&u(h),v=c?z(n).get(c):void 0,y=c&&c.loc.end.line===a.loc.start.line+((v==null?void 0:v.lines)??0),x=h&&h.loc.start.line===a.loc.end.line,S=_&&(y||x),C={lines:-(g.lines-+!!S),columns:S?-g.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;w&&!T&&c===void 0&&h===void 0&&a.loc.start.line>i.loc.start.line&&i.loc.end.line>a.loc.end.line&&xn(i),c===void 0&&h===void 0&&(!w||T)&&(C.lines=0,C.columns=0,(d(i)||l(i))&&Fn.add(i),(t(i)||r(i)||e(i))&&Nn.set(i,!0)),(c!==void 0||h!==void 0)&&(t(i)||r(i)||e(i))&&Pn.add(i);let E=l(i)||d(i)?Jn(i):2;if(_&&y&&(C.columns-=E),_&&!c&&h&&(er(i)||(C.columns-=E)),_&&c&&!h&&(c.comma=!!a.comma,y)){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=Vn(n));let ee=z(n),A=k.get(O);A&&(C.lines+=A.lines,C.columns+=A.columns);let te=ee.get(a);if(te&&(C.lines+=te.lines,S&&(C.columns+=te.columns)),k.set(O,C),En.add(n),w&&(o||p(n))&&n!==i){let e=a.loc.start.line,t=o??n.items,r=Gn(i,t),s=[];for(let n=0;n<t.length;n++){let a=t[n];if(!f(a))continue;let o=a.loc.start.line;o<r.loc.start.line||o>r.loc.end.line||(o===e&&(o<i.loc.end.line||a.loc.start.column<i.loc.end.column)?s.push(n):C.lines!==0&&o<e&&(a.loc.start.line-=C.lines,a.loc.end.line-=C.lines))}for(let e=s.length-1;e>=0;e--)t.splice(s[e],1)}}function Zn(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 Qn(e,t,n=!0){if(!n||!t.items.length)return;tr({lines:0,columns:1},Vn(e),t);let r=P(t.items);tr({lines:0,columns:1},z(e),r),En.add(e)}function $n(e,t,n=!1){if(!n||!t.items.length)return;let r=P(t.items);r.comma=!0,tr({lines:0,columns:1},z(e),r),En.add(e)}function H(e){if(!En.has(e))return;let t=Vn(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),Zn(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),Zn(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),Zn(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),En.delete(e),Bn.delete(e),Un.delete(e)}function U(e,t,n={}){let{lines:r,columns:i}=t;if(r===0&&i===0)return e;let{first_line_only:o=!1,shift_generated_multiline_end:s=!1}=n,c=e.loc.start.line,f=e.type;if(f===`Key`||f===`String`||f===`Integer`||f===`Float`||f===`Boolean`||f===`DateTime`||f===`Comment`)return(!o||e.loc.start.line===c)&&(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(f===`KeyValue`){let t=e,n=t.value.type;if(n===`String`||n===`Integer`||n===`Float`||n===`Boolean`||n===`DateTime`){let n=!o||t.loc.start.line===c;n&&(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,n&&(t.equals+=i);let a=t.key;(!o||a.loc.start.line===c)&&(a.loc.start.column+=i,a.loc.end.column+=i),a.loc.start.line+=r,a.loc.end.line+=r;let s=t.value;return(!o||s.loc.start.line===c)&&(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 p=e=>{if(!o||e.loc.start.line===c){e.loc.start.column+=i;let t=(!o||s)&&e.loc.end.line!==e.loc.start.line&&((l(e)||d(e))&&mn(e)!==void 0&&!gn(e)||u(e)&&((l(e.item)||d(e.item))&&mn(e.item)!==void 0&&!gn(e.item)||a(e.item)&&(l(e.item.value)||d(e.item.value))&&mn(e.item.value)!==void 0&&!gn(e.item.value))||a(e)&&(l(e.value)||d(e.value))&&mn(e.value)!==void 0);(e.loc.end.line===e.loc.start.line||t)&&(e.loc.end.column+=i)}e.loc.start.line+=r,e.loc.end.line+=r};return Bt(e,{Table:p,TableKey:p,TableArray:p,TableArrayKey:p,KeyValue(e){let t=!o||e.loc.start.line===c;p(e),t&&(e.equals+=i)},Key:p,String:p,Integer:p,Float:p,Boolean:p,DateTime:p,InlineArray:p,InlineItem:p,InlineTable:p,Comment:p}),e}function er(e,t){let n=mn(e);if(n===!0)return!0;if(n!==void 0||!e.items.length)return!1;let r=t?e.items.filter(e=>e!==t):e.items;return r.length?e.loc.end.line>e.loc.start.line&&r.every((e,t)=>t===0||e.loc.start.line>r[t-1].loc.start.line):e.loc.end.line>e.loc.start.line}function tr(e,t,n,r){let i=t.get(r||n);i&&(e.lines+=i.lines,e.columns+=i.columns),t.set(n,e)}function nr(e){let t=e.match(/\r\n|\n/);return(t==null?void 0:t[0])===`\r
28
28
  `?`\r
29
29
  `:`
30
- `}function $n(e,t){var n;let r=Qn(e);e=e.replace(/\r\n/g,`
30
+ `}function rr(e,t){var n;let r=nr(e);e=e.replace(/\r\n/g,`
31
31
  `).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
32
32
  `||!t.includes(`\r
33
- `))){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 er(e){switch(e){case`b`:return`\b`;case`t`:return` `;case`n`:return`
34
- `;case`f`:return`\f`;case`r`:return`\r`;case`"`:return`"`;case`\\`:return`\\`;default:return null}}function tr(e,t){return t===`singleline-basic`?e<=31||e===127:e>=0&&e<=7||e===11||e>=14&&e<=31||e===127}function nr(e,t){switch(e){case`\\`:return`\\\\`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`"`:return t===`singleline-basic`?`\\"`:`"`;case`
33
+ `))){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 ir(e){switch(e){case`b`:return`\b`;case`t`:return` `;case`n`:return`
34
+ `;case`f`:return`\f`;case`r`:return`\r`;case`"`:return`"`;case`\\`:return`\\`;default:return null}}function ar(e,t){return t===`singleline-basic`?e<=31||e===127:e>=0&&e<=7||e===11||e>=14&&e<=31||e===127}function or(e,t){switch(e){case`\\`:return`\\\\`;case`\b`:return`\\b`;case` `:return`\\t`;case`\f`:return`\\f`;case`"`:return t===`singleline-basic`?`\\"`:`"`;case`
35
35
  `:return t===`singleline-basic`?`\\n`:`
36
- `;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return tr(n,t)?`\\u${n.toString(16).padStart(4,`0`).toUpperCase()}`:e}}}function rr(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=er(r);if(i!==null){i!==`
37
- `&&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 ir(e,t,n){let r=``;for(let i of e){let e=t.get(i);if(e){r+=e;continue}r+=nr(i,n)}return r}function ar(e,t,n){let r=rr(t);if(r.size===0&&n===`singleline-basic`)return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,`\\u007F`);let i=ir(e,r,n);return n===`multiline-basic`?i.replace(/"""/g,`""\\"`):i}function or(){return{type:`Document`,loc:{start:S(),end:S()},items:[]}}function W(e){let t=sr(e);return{type:`Table`,loc:x(t.loc),key:t,items:[]}}function sr(e){let t=fr(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 cr(e){let t=lr(e);return{type:`TableArray`,loc:x(t.loc),key:t,items:[]}}function lr(e){let t=fr(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 ur(e,t,n=!1){let r=pr(e),{column:i}=r.loc.end,a=i+1;return U(t,{lines:1-t.loc.start.line,columns:i+3-t.loc.start.column},{first_line_only:!0,shift_generated_multiline_end:n}),{type:`KeyValue`,loc:{start:b(r.loc.start),end:b(t.loc.end)},key:r,equals:a,value:t}}function dr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function fr(e){return e.map(e=>(It(e,`Key ${JSON.stringify(e)}`),T.test(e)?e:dr(e))).join(`.`)}function pr(e){let t=fr(e);return{type:`Key`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function mr(e,t){return It(e,`String value`),t?hr(e,t):gr(e)}function hr(e,t){if(Et(t))return gr(e,t);if(Ot(t))return e.includes(`'`)?e.includes(`'''`)?gr(e):yr(e,`'''${t.slice(1,-1)}'''`):_r(e);if(kt(t))return e.includes(`'''`)?vr(e,`"""${t.slice(3,-3)}"""`):yr(e,t);if(Dt(t))return vr(e,t);throw Error(`Existing raw string value is not valid: ${t}`)}function gr(e,t){let n=``;return n=t?`"${ar(e,t,`singleline-basic`)}"`:dr(e),{type:`String`,loc:{start:S(),end:{line:1,column:n.length}},raw:n,value:e}}function _r(e){let t=`'${e}'`,n;if(t.includes(`
38
- `)){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 vr(e,t){let n=ar(e,t,`multiline-basic`),r=`"""`+(t.startsWith(`"""\r
36
+ `;case`\r`:return t===`singleline-basic`?`\\r`:`\r`;default:{let n=e.charCodeAt(0);return ar(n,t)?`\\u${n.toString(16).padStart(4,`0`).toUpperCase()}`:e}}}function sr(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=ir(r);if(i!==null){i!==`
37
+ `&&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 cr(e,t,n){let r=``;for(let i of e){let e=t.get(i);if(e){r+=e;continue}r+=or(i,n)}return r}function lr(e,t,n){let r=sr(t);if(r.size===0&&n===`singleline-basic`)return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,`\\u007F`);let i=cr(e,r,n);return n===`multiline-basic`?i.replace(/"""/g,`""\\"`):i}function ur(){return{type:`Document`,loc:{start:E(),end:E()},items:[]}}function W(e){let t=dr(e);return{type:`Table`,loc:T(t.loc),key:t,items:[]}}function dr(e){let t=gr(e);return{type:`TableKey`,loc:{start:E(),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 fr(e){let t=pr(e);return{type:`TableArray`,loc:T(t.loc),key:t,items:[]}}function pr(e){let t=gr(e);return{type:`TableArrayKey`,loc:{start:E(),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 mr(e,t,n=!1){let r=_r(e),{column:i}=r.loc.end,a=i+1;return U(t,{lines:1-t.loc.start.line,columns:i+3-t.loc.start.column},{first_line_only:!0,shift_generated_multiline_end:n}),{type:`KeyValue`,loc:{start:w(r.loc.start),end:w(t.loc.end)},key:r,equals:a,value:t}}function hr(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function gr(e){return e.map(e=>(zt(e,`Key ${JSON.stringify(e)}`),k.test(e)?e:hr(e))).join(`.`)}function _r(e){let t=gr(e);return{type:`Key`,loc:{start:E(),end:{line:1,column:t.length}},raw:t,value:e}}function vr(e,t){return zt(e,`String value`),t?yr(e,t):br(e)}function yr(e,t){if(kt(t))return br(e,t);if(jt(t))return e.includes(`'`)?e.includes(`'''`)?br(e):Cr(e,`'''${t.slice(1,-1)}'''`):xr(e);if(Mt(t))return e.includes(`'''`)?Sr(e,`"""${t.slice(3,-3)}"""`):Cr(e,t);if(At(t))return Sr(e,t);throw Error(`Existing raw string value is not valid: ${t}`)}function br(e,t){let n=``;return n=t?`"${lr(e,t,`singleline-basic`)}"`:hr(e),{type:`String`,loc:{start:E(),end:{line:1,column:n.length}},raw:n,value:e}}function xr(e){let t=`'${e}'`,n;if(t.includes(`
38
+ `)){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:E(),end:n},raw:t,value:e}}function Sr(e,t){let n=lr(e,t,`multiline-basic`),r=`"""`+(t.startsWith(`"""\r
39
39
  `)?`\r
40
40
  `:t.startsWith(`"""
41
41
  `)?`
42
- `:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=$n(t,n);e!==null&&(r=e)}let a=br(r);return{type:`String`,loc:{start:S(),end:a},raw:r,value:e}}function yr(e,t){let n=`'''`+(t.startsWith(`'''\r
42
+ `:``)+n+`"""`,i=t.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(i)){let e=rr(t,n);e!==null&&(r=e)}let a=wr(r);return{type:`String`,loc:{start:E(),end:a},raw:r,value:e}}function Cr(e,t){let n=`'''`+(t.startsWith(`'''\r
43
43
  `)?`\r
44
44
  `:t.startsWith(`'''
45
45
  `)?`
46
- `:``)+e+`'''`,r=br(n);return{type:`String`,loc:{start:S(),end:r},raw:n,value:e}}function br(e){if(e.includes(`
47
- `)){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 xr(e){let t=e.toString();return{type:`Integer`,loc:{start:S(),end:{line:1,column:t.length}},raw:t,value:e}}function Sr(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 Cr(e){return{type:`Boolean`,loc:{start:S(),end:{line:1,column:e?4:5}},value:e}}function wr(e,t=!1){t&&!(e instanceof ke)&&e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0&&(e=new Oe(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 Tr(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=wt(e);else if(a)s=wt(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=wt(n),{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:n}}s=wt(e)}else s=wt(e);return{type:`DateTime`,loc:{start:S(),end:{line:1,column:s.length}},raw:s,value:e}}function Er(){return{type:`InlineArray`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function G(e){return{type:`InlineItem`,loc:x(e.loc),item:e,comma:!1}}function Dr(){return{type:`InlineTable`,loc:{start:S(),end:{line:1,column:2}},items:[]}}function Or(e){return!l(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function kr(e){return!d(e)||e.items.length===0?!1:e.items[e.items.length-1].comma===!0}function Ar(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=zr(e.key.value);return t.inlineTableStart===void 0||n<t.inlineTableStart}return!1}).forEach(n=>{V(e,e,n),d(n.value)?n.value.items.length===0?B(e,e,W(n.key.value)):B(e,e,jr(n,t.bracketSpacing)):Mr(n,t.bracketSpacing).forEach(t=>{B(e,e,t)})}),H(e),e)}function jr(e,t){let n=W(e.key.value);for(let t of e.value.items)B(n,n,t.item,void 0,void 0,void 0,void 0,!0);return H(n),Ir(n,1,t),n}function Mr(e,n){let i=or();for(let t of e.value.items){let n=cr(e.key.value);B(i,i,n);for(let e of t.item.items)B(i,n,e.item,void 0,void 0,void 0,void 0,!0)}H(i);for(let e of i.items)(t(e)||r(e))&&Ir(e,1,n);return i.items}function Nr(e){let t=dn(e);return t===void 0?bn(e):t}function Pr(e){return Math.max(e,2)}function Fr(e,t,n,r=!0){let i=Nr(e),o=!1;if(i){let i=t+n;for(let t of e.items)U(t,{lines:0,columns:i-t.loc.start.column}),u(t)&&(l(t.item)||d(t.item)?Fr(t.item,t.item.loc.start.column,Pr(n),r)&&(t.loc.end={...t.item.loc.end},o=!0):a(t.item)&&(l(t.item.value)||d(t.item.value))&&Fr(t.item.value,t.item.loc.start.column,n,r)&&(t.item.loc.end={...t.item.value.loc.end},t.loc.end={...t.item.loc.end},o=!0));e.loc.end.column=t+1,o=!0}for(let t of e.items)if(u(t)){if(l(t.item)||d(t.item))Fr(t.item,t.item.loc.start.column,Pr(n),r)&&(t.loc.end={...t.item.loc.end},o=!0);else if(a(t.item)&&(l(t.item.value)||d(t.item.value))){let e=t.item.value,i=t.item.loc.start.column,a=Nr(e);Fr(e,i,n,r)&&(a&&(e.loc.end.column=i+1),t.item.loc.end={...e.loc.end},t.loc.end={...t.item.loc.end},o=!0)}}let s=le(e)??2;for(let t=1;t<e.items.length;t++){let n=e.items[t-1],r=e.items[t];n.loc.end.line===r.loc.start.line&&U(r,{lines:0,columns:n.loc.end.column+(n.comma?s:1)-r.loc.start.column})}if(o&&!i&&e.items.length>0){let t=e.items[e.items.length-1];e.loc.end={line:t.loc.end.line,column:t.loc.end.column+ +!!t.comma+(r?2:1)}}return o}function Ir(e,t,n=!0){let r=a(e)?[e]:e.items;for(let e of r)a(e)&&(l(e.value)||d(e.value))&&Fr(e.value,e.loc.start.column,t,n)}function Lr(e,t){let n=(e,r)=>{if(r&&(delete e.range,dn(e)===!0||bn(e))){let n=e.loc.start.column+t;for(let t of e.items)U(t,{lines:0,columns:n-t.loc.start.column});e.loc.end.column=e.loc.start.column+1}for(let t of e.items)u(t)&&(l(t.item)||d(t.item)?n(t.item,l(e)&&d(t.item)):a(t.item)&&(l(t.item.value)||d(t.item.value))&&n(t.item.value,!1))};n(e,!1)}function Rr(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 zr(e){return Math.max(0,e.length-1)}function Br(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(zr(i.key.value)<t.inlineTableStart){let r=jr(i,t.bracketSpacing);V(e,e,i),B(e,e,r),Vr(r,n,t)}}else(i.type===`Table`||r(i))&&Vr(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 Vr(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];zr(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),Rr(e),t.push({table:r,parent:e}),Vr(r,t,n)}r.length>0&&H(e)}function Hr(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 Ur(e){return e.items.length>0&&e.loc.end.line-e.loc.start.line+1>e.items.length}function Wr(e){return l(e)||d(e)}function Gr(e,t,n){if(!u(t)||!Wr(t.item)||!Ur(e))return;let r=e.items.find(e=>Wr(e.item)&&e.item.type===t.item.type&&Ur(e.item));if(!r||!Wr(r.item))return;let i=t.item,a=r.item,o=a.items.length>0?a.items[0].loc.start.column-a.loc.start.column:n,s=a.items.length>0?a.items[0].loc.start.line-a.loc.start.line:1,c=a.items.length>0?a.loc.end.line-a.items[a.items.length-1].loc.end.line:1,l=i.loc.start.line,d=i.loc.start.column,f=l+s;for(let e of i.items)U(e,{lines:f-e.loc.start.line,columns:d+o-e.loc.start.column}),f=e.loc.end.line+1;i.loc.end={line:f-1+c,column:a.loc.end.column},fn(i),t.loc={start:b(i.loc.start),end:b(i.loc.end)}}function Kr(e,t){let n=e=>{let r=!1;for(let i of e.items){if(!u(i)||!Wr(i.item))continue;let a=i.item;if(d(a)&&bn(a)){delete i.range,delete a.range;let n=a.loc.start.column+Math.max(t,2);for(let e of a.items)U(e,{lines:0,columns:n-e.loc.start.column});a.loc.end.column=a.loc.start.column+1,mn(a),fn(a),r=!0,gn(e),i.comma=!0,i.loc.end={line:a.loc.end.line,column:a.loc.end.column},e.loc.end={line:a.loc.end.line,column:a.loc.end.column+(i.comma?2:1)}}l(a)&&n(a)&&(delete a.range,delete i.range,i.loc.end={line:a.loc.end.line,column:a.loc.end.column},r=!0,gn(e))}if(r){for(let t=1;t<e.items.length;t++){let n=e.items[t-1],r=e.items[t];n.loc.end.line===r.loc.start.line&&U(r,{lines:0,columns:n.loc.end.column+(n.comma?2:1)-r.loc.start.column})}let t=e.items[e.items.length-1];t&&(e.loc.end={line:Math.max(e.loc.end.line,t.loc.end.line),column:t.loc.end.column+(t.comma?2:1)})}return r};n(e)}function K(e,t=L.default(),n=0,r=!1){e=Zr(e);let i=or();kn(i),Dn(i,t.indentWidth);for(let a of qr(e,t,n,r))B(i,i,a);H(i),Ar(i,t),Br(i,t);for(let e of i.items)(e.type===`Table`||e.type===`TableArray`||a(e)&&(l(e.value)||d(e.value)))&&Ir(e,t.indentWidth,t.bracketSpacing);return Hr(i)}function*qr(e,t,n=0,r=!1){for(let i of Object.keys(e)){let a=e[i];if(a===void 0)continue;let o=Zr(a);o!==void 0&&(yield ur([i],Jr(o,t,n,r),n>0&&!r))}}function Jr(e,t,n,r){let i=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 gt(e)?mr(e):vt(e)?xr(e):_t(e)?i>0?Sr(e,i):xr(e):yt(e)?Sr(e,Math.max(i,1)):bt(e)?Cr(e):Ct(e)?Tr(e,t.truncateZeroTimeInDates):xt(e)?wr(e,t.truncateZeroTimeInDates):Array.isArray(e)?Yr(e,t,n,r):Xr(e,t,n,r)}function Yr(e,t,n,r){let i=Er(),a=!(e.length===0&&n>0)&&ln(`array`,n,r,t);un(i,a),Dn(i,t.indentWidth);for(let r of e){let e=Jr(r,t,n+1,a),o=G(e);!a&&(e.type===`InlineArray`||e.type===`InlineTable`)&&dn(e)===!0&&fn(e),Gr(i,o,t.indentWidth),B(i,i,o)}return Jn(i,i,t.bracketSpacing),Yn(i,i,t.trailingComma),H(i),i}function Xr(e,t,n,r){if(e=Zr(e),!P(e))return Jr(e,t,n,r);let i=Dr(),a=!(Object.keys(e).length===0&&n>0)&&ln(`table`,n,r,t);un(i,a),Dn(i,t.indentWidth);for(let r of qr(e,t,n+1,a))B(i,i,G(r));return Jn(i,i,t.bracketSpacing),Yn(i,i,t.trailingComma),H(i),i}function Zr(e){return!e||xt(e)||Ct(e)?e:typeof e.toJSON==`function`?e.toJSON():e}const Qr=/(\r\n|\n)/g;function $r(e,t){let n=[],r=e=>{let t={line:e.loc.end.line,column:e.loc.end.column-1},n=e.items[e.items.length-1];return n&&(n.loc.end.line>t.line||n.loc.end.line===t.line&&n.loc.end.column>t.column)&&(t.line=n.loc.end.line,t.column=n.loc.end.column+ +!!n.comma),t};function i(e){switch(e.type){case`Document`:for(let t=0;t<e.items.length;t++)i(e.items[t]);break;case`Table`:{let t=e;i(t.key);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`TableKey`:{let t=e;ti(n,t.loc,`[`+t.item.raw+`]`);break}case`TableArray`:{let t=e;i(t.key);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`TableArrayKey`:{let t=e;ti(n,t.loc,`[[`+t.item.raw+`]]`);break}case`KeyValue`:{let t=e,r=t.loc.start.line;ni(n,r,t.equals,`=`),i(t.key),i(t.value);break}case`Key`:ti(n,e.loc,e.raw);break;case`String`:ti(n,e.loc,e.raw);break;case`Integer`:ti(n,e.loc,e.raw);break;case`Float`:ti(n,e.loc,e.raw);break;case`Boolean`:ti(n,e.loc,e.value.toString());break;case`DateTime`:ti(n,e.loc,e.raw);break;case`InlineArray`:{let t=e,{start:a}=t.loc,o=r(t);ni(n,a.line,a.column,`[`),ni(n,o.line,o.column,`]`);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`InlineTable`:{let t=e,{start:a}=t.loc,o=r(t);ni(n,a.line,a.column,`{`),ni(n,o.line,o.column,`}`);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`InlineItem`:{let t=e;if(i(t.item),t.comma){let e=t.loc.end;ni(n,e.line,e.column,`,`)}break}case`Comment`:ti(n,e.loc,e.raw);break;default:{let t=e.type;throw Error(`toTOML: Unrecognized node type: ${String(t)}`)}}}if(Tt(e))for(let t of e)i(t);else i(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(Tt(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 ei(e,n){let i=Tt(e)?Array.from(e):[e],o=[],s=[],c=[],f=new WeakSet,h=1,g=0,_=e=>{if(e.type===`Comment`&&c.push(e),a(e))_(e.value);else if(u(e))_(e.item);else if(e.type===`Table`||e.type===`TableArray`)for(let t of e.items)_(t);else if(p(e))for(let t of e.items)_(t)};for(let e of i)_(e);let v=new WeakSet,y=e=>{for(let n of e)if(a(n)){let e=n.value;(d(e)||l(e))&&v.add(e)}else(t(n)||r(n))&&y(n.items)};y(i);let b=e=>(n.useTabsForIndentation?` `:` `).repeat(e),x=e=>{if(e.length===0)return;o.push(e);let t=e.split(/\r\n|\n/);t.length===1?g+=e.length:(h+=t.length-1,g=t[t.length-1].length)},S=(e,t)=>{e>h?(x(n.newLine.repeat(e-h)),t>0&&x(b(t))):e===h&&t>g?x(g===0?b(t):` `.repeat(t-g)):o.length>0&&(e<h||e===h&&t<g)&&(x(n.newLine),t>0&&x(b(t)))},C=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}},w=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:[]},T=e=>{let t=[e];for(;t.length>0;){let e=t.pop();if(e.dirty)return!1;let n=C(e);if(n!==void 0){let t=M(e);if(!t||!e.range||t.slice(e.range[0],e.range[1])!==n)return!1}else if(!ge(e))return!1;t.push(...w(e))}return!0},E=e=>e.type!==`Document`&&e.type!==`InlineItem`&&e.type!==`TableKey`&&e.type!==`TableArrayKey`&&(C(e)!==void 0||ge(e)),D=(e,t,r=!1)=>{t.line>e.line?(x(n.newLine.repeat(t.line-e.line)),t.column>0&&x(r?` `.repeat(t.column):b(t.column))):t.line===e.line&&t.column>e.column&&x(` `.repeat(t.column-e.column))},O=(e,t,n)=>{var r,i;let a=M(e);if(!a||!e.range||l(e)&&_n(e)&&(!n||t&&!t.range||n&&!n.range)||t&&M(t)!==a||n&&M(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);if(t!=null&&t.comma&&c.startsWith(`,`)&&(c=c.slice(1)),/^[\t \r\n]*$/.test(c))return c},k=(e,t)=>{let n=M(t);return n!==void 0&&M(e)===n&&t.range!==void 0&&e.range!==void 0&&e.range[0]>=t.range[0]&&e.range[1]<=t.range[1]},A=e=>{let t=d(e)&&hn(e),r;for(let n of e.items){let i=r?{line:r.loc.end.line,column:r.loc.end.column+ +!!r.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},a=c.filter(t=>!f.has(t)&&k(t,e)&&t.loc.start.line>=i.line&&t.loc.end.line<=n.loc.start.line&&(t.loc.start.line>i.line||t.loc.start.column>=i.column)&&(t.loc.end.line<n.loc.start.line||t.loc.end.column<=n.loc.start.column)&&t.loc.start.line>=e.loc.start.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(a.length>0){for(let e of a)D(i,e.loc.start),x(e.raw),f.add(e),i=e.loc.end;D(i,n.loc.start)}else{let a=O(e,r,n);if(a!==void 0)x(a);else{let a=M(n)!==M(e);if(r&&a&&n.loc.start.line===r.loc.end.line){let t=le(e)??2,n=Math.max(0,t-1);n>0&&x(` `.repeat(n))}else D(i,n.loc.start,t)}}j(n,!1);for(let t of c){if(f.has(t)||!k(t,e)||t.loc.start.line!==n.loc.end.line||t.loc.start.column<n.loc.end.column||t.loc.start.line<e.loc.start.line||t.loc.end.line>e.loc.end.line)continue;let r=n.loc.end.column+ +!!n.comma;t.loc.start.column>r&&x(` `.repeat(t.loc.start.column-r)),x(t.raw),f.add(t)}r=n}let i=r?{line:r.loc.end.line,column:r.loc.end.column+ +!!r.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},a=c.filter(t=>!f.has(t)&&k(t,e)&&t.loc.start.line>=i.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(a.length>0){for(let e of a)D(i,e.loc.start),x(e.raw),f.add(e),i=e.loc.end;D(i,{line:e.loc.end.line,column:e.loc.end.column-1})}else{let a=O(e,r,void 0);if(a!==void 0)x(a);else if(r)t&&r.comma&&x(` `),D(i,{line:e.loc.end.line,column:e.loc.end.column-1},t);else{let t=M(e);if(t&&e.range){let r=t.slice(e.range[0],e.range[1]),i=Math.max(r.lastIndexOf(`
48
- `),r.lastIndexOf(`\r`)),a=v.has(e)||yn(e);if(i!==-1&&a&&Ce(e)){var o;let e=((o=r.slice(i+1,-1).match(/^[\t ]*/))==null?void 0:o[0])??``;x(n.newLine+e)}}}}},j=(e,t=!0)=>{if(e.type===`Comment`&&f.has(e))return;let n=M(e);if(!(n!==void 0&&e.range&&s.some(t=>t.source===n&&t.start<=e.range[0]&&t.end>=e.range[1]))){if(E(e)&&T(e)&&e.range&&n!==void 0){let r=n.slice(e.range[0],e.range[1]),i=C(e);if(i===void 0||i===r){t&&S(e.loc.start.line,e.loc.start.column),x(r),s.push({source:n,start:e.range[0],end:e.range[1]});return}}switch(e.type){case`Document`:for(let t of e.items)j(t);break;case`Table`:{let n=e;j(n.key,t);for(let e of n.items)j(e);break}case`TableKey`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[${n.item.raw}]`);break}case`TableArray`:{let n=e;j(n.key,t);for(let e of n.items)j(e);break}case`TableArrayKey`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[[${n.item.raw}]]`);break}case`KeyValue`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),j(n.key,!1),D(n.key.loc.end,{line:n.loc.start.line,column:n.equals}),x(`=`),D({line:n.loc.start.line,column:n.equals+1},n.value.loc.start),j(n.value,!1);break}case`Key`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`String`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Integer`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Float`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Boolean`:t&&S(e.loc.start.line,e.loc.start.column),x(e.value.toString());break;case`DateTime`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`InlineArray`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[`),A(n),x(`]`);break}case`InlineTable`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`{`),A(n),x(`}`);break}case`InlineItem`:{let t=e;if(j(t.item,!1),t.comma){let e=M(t);if(e&&t.range&&t.item.range&&M(t.item)===e){let n=e.slice(t.item.range[1],t.range[1]);/^[\t ]*$/.test(n)&&x(n)}x(`,`)}break}case`Comment`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;default:throw Error(`toTOMLCursor: Unrecognized node type: ${String(e.type)}`)}}};for(let e of i)j(e);return o.join(``).replace(/\r\n|\n/g,n.newLine)+n.newLine.repeat(n.trailingNewline)}function ti(e,t,n){if(t.start.line===t.end.line){let r=ri(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(Qr).filter(e=>e!==`
46
+ `:``)+e+`'''`,r=wr(n);return{type:`String`,loc:{start:E(),end:r},raw:n,value:e}}function wr(e){if(e.includes(`
47
+ `)){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 Tr(e){let t=e.toString();return{type:`Integer`,loc:{start:E(),end:{line:1,column:t.length}},raw:t,value:e}}function Er(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:E(),end:{line:1,column:n.length}},raw:n,value:e,...r===void 0?{}:{nanSign:r}}}function Dr(e){return{type:`Boolean`,loc:{start:E(),end:{line:1,column:e?4:5}},value:e}}function Or(e,t=!1){t&&!(e instanceof Me)&&e.getUTCHours()===0&&e.getUTCMinutes()===0&&e.getUTCSeconds()===0&&e.getUTCMilliseconds()===0&&(e=new je(e.toISOString().split(`T`)[0]));let n=e.toISOString();return{type:`DateTime`,loc:{start:E(),end:{line:1,column:n.length}},raw:n,value:e}}function kr(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=Dt(e);else if(a)s=Dt(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=Dt(n),{type:`DateTime`,loc:{start:E(),end:{line:1,column:s.length}},raw:s,value:n}}s=Dt(e)}else s=Dt(e);return{type:`DateTime`,loc:{start:E(),end:{line:1,column:s.length}},raw:s,value:e}}function Ar(){return{type:`InlineArray`,loc:{start:E(),end:{line:1,column:2}},items:[]}}function G(e){return{type:`InlineItem`,loc:T(e.loc),item:e,comma:!1}}function jr(){return{type:`InlineTable`,loc:{start:E(),end:{line:1,column:2}},items:[]}}function Mr(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 Pr(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=Ur(e.key.value);return t.inlineTableStart===void 0||n<t.inlineTableStart}return!1}).forEach(n=>{V(e,e,n),d(n.value)?n.value.items.length===0?B(e,e,W(n.key.value)):B(e,e,Fr(n,t.bracketSpacing)):Ir(n,t.bracketSpacing).forEach(t=>{B(e,e,t)})}),H(e),e)}function Fr(e,t){let n=W(e.key.value);for(let t of e.value.items)B(n,n,t.item,void 0,void 0,void 0,void 0,!0);return H(n),Br(n,1,t),n}function Ir(e,n){let i=ur();for(let t of e.value.items){let n=fr(e.key.value);B(i,i,n);for(let e of t.item.items)B(i,n,e.item,void 0,void 0,void 0,void 0,!0)}H(i);for(let e of i.items)(t(e)||r(e))&&Br(e,1,n);return i.items}function Lr(e){let t=mn(e);return t===void 0?Cn(e):t}function Rr(e){return Math.max(e,2)}function zr(e,t,n,r=!0){let i=Lr(e),o=!1;if(i){let i=t+n;for(let t of e.items)U(t,{lines:0,columns:i-t.loc.start.column}),u(t)&&(l(t.item)||d(t.item)?zr(t.item,t.item.loc.start.column,Rr(n),r)&&(t.loc.end={...t.item.loc.end},o=!0):a(t.item)&&(l(t.item.value)||d(t.item.value))&&zr(t.item.value,t.item.loc.start.column,n,r)&&(t.item.loc.end={...t.item.value.loc.end},t.loc.end={...t.item.loc.end},o=!0));e.loc.end.column=t+1,o=!0}for(let t of e.items)if(u(t)){if(l(t.item)||d(t.item))zr(t.item,t.item.loc.start.column,Rr(n),r)&&(t.loc.end={...t.item.loc.end},o=!0);else if(a(t.item)&&(l(t.item.value)||d(t.item.value))){let e=t.item.value,i=t.item.loc.start.column,a=Lr(e);zr(e,i,n,r)&&(a&&(e.loc.end.column=i+1),t.item.loc.end={...e.loc.end},t.loc.end={...t.item.loc.end},o=!0)}}let s=fe(e)??2;for(let t=1;t<e.items.length;t++){let n=e.items[t-1],r=e.items[t];n.loc.end.line===r.loc.start.line&&U(r,{lines:0,columns:n.loc.end.column+(n.comma?s:1)-r.loc.start.column})}if(o&&!i&&e.items.length>0){let t=e.items[e.items.length-1];e.loc.end={line:t.loc.end.line,column:t.loc.end.column+ +!!t.comma+(r?2:1)}}return o}function Br(e,t,n=!0){let r=a(e)?[e]:e.items;for(let e of r)a(e)&&(l(e.value)||d(e.value))&&zr(e.value,e.loc.start.column,t,n)}function Vr(e,t){let n=(e,r)=>{if(r&&(delete e.range,mn(e)===!0||Cn(e))){let n=e.loc.start.column+t;for(let t of e.items)U(t,{lines:0,columns:n-t.loc.start.column});e.loc.end.column=e.loc.start.column+1}for(let t of e.items)u(t)&&(l(t.item)||d(t.item)?n(t.item,l(e)&&d(t.item)):a(t.item)&&(l(t.item.value)||d(t.item.value))&&n(t.item.value,!1))};n(e,!1)}function Hr(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 Ur(e){return Math.max(0,e.length-1)}function Wr(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(Ur(i.key.value)<t.inlineTableStart){let r=Fr(i,t.bracketSpacing);V(e,e,i),B(e,e,r),Gr(r,n,t)}}else(i.type===`Table`||r(i))&&Gr(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 Gr(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];Ur(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),Hr(e),t.push({table:r,parent:e}),Gr(r,t,n)}r.length>0&&H(e)}function Kr(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 qr(e){return e.items.length>0&&e.loc.end.line-e.loc.start.line+1>e.items.length}function Jr(e){return l(e)||d(e)}function Yr(e,t,n){if(!u(t)||!Jr(t.item)||!qr(e))return;let r=e.items.find(e=>Jr(e.item)&&e.item.type===t.item.type&&qr(e.item));if(!r||!Jr(r.item))return;let i=t.item,a=r.item,o=a.items.length>0?a.items[0].loc.start.column-a.loc.start.column:n,s=a.items.length>0?a.items[0].loc.start.line-a.loc.start.line:1,c=a.items.length>0?a.loc.end.line-a.items[a.items.length-1].loc.end.line:1,l=i.loc.start.line,d=i.loc.start.column,f=l+s;for(let e of i.items)U(e,{lines:f-e.loc.start.line,columns:d+o-e.loc.start.column}),f=e.loc.end.line+1;i.loc.end={line:f-1+c,column:a.loc.end.column},hn(i),t.loc={start:w(i.loc.start),end:w(i.loc.end)}}function Xr(e,t){let n=e=>{let r=!1;for(let i of e.items){if(!u(i)||!Jr(i.item))continue;let a=i.item;if(d(a)&&Cn(a)){delete i.range,delete a.range;let n=a.loc.start.column+Math.max(t,2);for(let e of a.items)U(e,{lines:0,columns:n-e.loc.start.column});a.loc.end.column=a.loc.start.column+1,_n(a),hn(a),r=!0,yn(e),i.comma=!0,i.loc.end={line:a.loc.end.line,column:a.loc.end.column},e.loc.end={line:a.loc.end.line,column:a.loc.end.column+(i.comma?2:1)}}l(a)&&n(a)&&(delete a.range,delete i.range,i.loc.end={line:a.loc.end.line,column:a.loc.end.column},r=!0,yn(e))}if(r){for(let t=1;t<e.items.length;t++){let n=e.items[t-1],r=e.items[t];n.loc.end.line===r.loc.start.line&&U(r,{lines:0,columns:n.loc.end.column+(n.comma?2:1)-r.loc.start.column})}let t=e.items[e.items.length-1];t&&(e.loc.end={line:Math.max(e.loc.end.line,t.loc.end.line),column:t.loc.end.column+(t.comma?2:1)})}return r};n(e)}function K(e,t=R.default(),n=0,r=!1){e=ti(e);let i=ur();Mn(i),An(i,t.indentWidth);for(let a of Zr(e,t,n,r))B(i,i,a);H(i),Pr(i,t),Wr(i,t);for(let e of i.items)(e.type===`Table`||e.type===`TableArray`||a(e)&&(l(e.value)||d(e.value)))&&Br(e,t.indentWidth,t.bracketSpacing);return Kr(i)}function*Zr(e,t,n=0,r=!1){for(let i of Object.keys(e)){let a=e[i];if(a===void 0)continue;let o=ti(a);o!==void 0&&(yield mr([i],Qr(o,t,n,r),n>0&&!r))}}function Qr(e,t,n,r){let i=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 yt(e)?vr(e):xt(e)?Tr(e):bt(e)?i>0?Er(e,i):Tr(e):St(e)?Er(e,Math.max(i,1)):Ct(e)?Dr(e):Et(e)?kr(e,t.truncateZeroTimeInDates):wt(e)?Or(e,t.truncateZeroTimeInDates):Array.isArray(e)?$r(e,t,n,r):ei(e,t,n,r)}function $r(e,t,n,r){let i=Ar(),a=!(e.length===0&&n>0)&&fn(`array`,n,r,t);pn(i,a),An(i,t.indentWidth);for(let r of e){let e=Qr(r,t,n+1,a),o=G(e);!a&&(e.type===`InlineArray`||e.type===`InlineTable`)&&mn(e)===!0&&hn(e),Yr(i,o,t.indentWidth),B(i,i,o)}return Qn(i,i,t.bracketSpacing),$n(i,i,t.trailingComma),H(i),i}function ei(e,t,n,r){if(e=ti(e),!F(e))return Qr(e,t,n,r);let i=jr(),a=!(Object.keys(e).length===0&&n>0)&&fn(`table`,n,r,t);pn(i,a),An(i,t.indentWidth);for(let r of Zr(e,t,n+1,a))B(i,i,G(r));return Qn(i,i,t.bracketSpacing),$n(i,i,t.trailingComma),H(i),i}function ti(e){return!e||wt(e)||Et(e)?e:typeof e.toJSON==`function`?e.toJSON():e}const ni=/(\r\n|\n)/g;function ri(e,t){let n=[],r=e=>{let t={line:e.loc.end.line,column:e.loc.end.column-1},n=e.items[e.items.length-1];return n&&(n.loc.end.line>t.line||n.loc.end.line===t.line&&n.loc.end.column>t.column)&&(t.line=n.loc.end.line,t.column=n.loc.end.column+ +!!n.comma),t};function i(e){switch(e.type){case`Document`:for(let t=0;t<e.items.length;t++)i(e.items[t]);break;case`Table`:{let t=e;i(t.key);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`TableKey`:{let t=e;ai(n,t.loc,`[`+t.item.raw+`]`);break}case`TableArray`:{let t=e;i(t.key);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`TableArrayKey`:{let t=e;ai(n,t.loc,`[[`+t.item.raw+`]]`);break}case`KeyValue`:{let t=e,r=t.loc.start.line;oi(n,r,t.equals,`=`),i(t.key),i(t.value);break}case`Key`:ai(n,e.loc,e.raw);break;case`String`:ai(n,e.loc,e.raw);break;case`Integer`:ai(n,e.loc,e.raw);break;case`Float`:ai(n,e.loc,e.raw);break;case`Boolean`:ai(n,e.loc,e.value.toString());break;case`DateTime`:ai(n,e.loc,e.raw);break;case`InlineArray`:{let t=e,{start:a}=t.loc,o=r(t);oi(n,a.line,a.column,`[`),oi(n,o.line,o.column,`]`);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`InlineTable`:{let t=e,{start:a}=t.loc,o=r(t);oi(n,a.line,a.column,`{`),oi(n,o.line,o.column,`}`);for(let e=0;e<t.items.length;e++)i(t.items[e]);break}case`InlineItem`:{let t=e;if(i(t.item),t.comma){let e=t.loc.end;oi(n,e.line,e.column,`,`)}break}case`Comment`:ai(n,e.loc,e.raw);break;default:{let t=e.type;throw Error(`toTOML: Unrecognized node type: ${String(t)}`)}}}if(Ot(e))for(let t of e)i(t);else i(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(Ot(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 ii(e,n){let i=Ot(e)?Array.from(e):[e],o=[],s=[],c=[],f=new WeakSet,h=1,g=0,_=e=>{if(e.type===`Comment`&&c.push(e),a(e))_(e.value);else if(u(e))_(e.item);else if(e.type===`Table`||e.type===`TableArray`)for(let t of e.items)_(t);else if(p(e))for(let t of e.items)_(t)};for(let e of i)_(e);let v=new WeakSet,y=e=>{for(let n of e)if(a(n)){let e=n.value;(d(e)||l(e))&&v.add(e)}else(t(n)||r(n))&&y(n.items)};y(i);let b=e=>(n.useTabsForIndentation?` `:` `).repeat(e),x=e=>{if(e.length===0)return;o.push(e);let t=e.split(/\r\n|\n/);t.length===1?g+=e.length:(h+=t.length-1,g=t[t.length-1].length)},S=(e,t)=>{e>h?(x(n.newLine.repeat(e-h)),t>0&&x(b(t))):e===h&&t>g?x(g===0?b(t):` `.repeat(t-g)):o.length>0&&(e<h||e===h&&t<g)&&(x(n.newLine),t>0&&x(b(t)))},C=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}},w=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:[]},T=e=>{let t=[e];for(;t.length>0;){let e=t.pop();if(e.dirty)return!1;let n=C(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(!ye(e))return!1;t.push(...w(e))}return!0},E=e=>e.type!==`Document`&&e.type!==`InlineItem`&&e.type!==`TableKey`&&e.type!==`TableArrayKey`&&(C(e)!==void 0||ye(e)),D=(e,t,r=!1)=>{t.line>e.line?(x(n.newLine.repeat(t.line-e.line)),t.column>0&&x(r?` `.repeat(t.column):b(t.column))):t.line===e.line&&t.column>e.column&&x(` `.repeat(t.column-e.column))},O=(e,t,n)=>{var r,i;let a=N(e);if(!a||!e.range||l(e)&&bn(e)&&(!n||t&&!t.range||n&&!n.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);if(t!=null&&t.comma&&c.startsWith(`,`)&&(c=c.slice(1)),/^[\t \r\n]*$/.test(c))return c},k=(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]},ee=e=>{let t=d(e)&&vn(e),r;for(let n of e.items){let i=r?{line:r.loc.end.line,column:r.loc.end.column+ +!!r.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},a=c.filter(t=>!f.has(t)&&k(t,e)&&t.loc.start.line>=i.line&&t.loc.end.line<=n.loc.start.line&&(t.loc.start.line>i.line||t.loc.start.column>=i.column)&&(t.loc.end.line<n.loc.start.line||t.loc.end.column<=n.loc.start.column)&&t.loc.start.line>=e.loc.start.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(a.length>0){for(let e of a)D(i,e.loc.start),x(e.raw),f.add(e),i=e.loc.end;D(i,n.loc.start)}else{let a=O(e,r,n);if(a!==void 0)x(a);else{let a=N(n)!==N(e);if(r&&a&&n.loc.start.line===r.loc.end.line){let t=fe(e)??2,n=Math.max(0,t-1);n>0&&x(` `.repeat(n))}else D(i,n.loc.start,t)}}A(n,!1);for(let t of c){if(f.has(t)||!k(t,e)||t.loc.start.line!==n.loc.end.line||t.loc.start.column<n.loc.end.column||t.loc.start.line<e.loc.start.line||t.loc.end.line>e.loc.end.line)continue;let r=n.loc.end.column+ +!!n.comma;t.loc.start.column>r&&x(` `.repeat(t.loc.start.column-r)),x(t.raw),f.add(t)}r=n}let i=r?{line:r.loc.end.line,column:r.loc.end.column+ +!!r.comma}:{line:e.loc.start.line,column:e.loc.start.column+1},a=c.filter(t=>!f.has(t)&&k(t,e)&&t.loc.start.line>=i.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(a.length>0){for(let e of a)D(i,e.loc.start),x(e.raw),f.add(e),i=e.loc.end;D(i,{line:e.loc.end.line,column:e.loc.end.column-1})}else{let a=O(e,r,void 0);if(a!==void 0)x(a);else if(r)t&&r.comma&&x(` `),D(i,{line:e.loc.end.line,column:e.loc.end.column-1},t);else{let t=N(e);if(t&&e.range){let r=t.slice(e.range[0],e.range[1]),i=Math.max(r.lastIndexOf(`
48
+ `),r.lastIndexOf(`\r`)),a=v.has(e)||Sn(e);if(i!==-1&&a&&Ee(e)){var o;let e=((o=r.slice(i+1,-1).match(/^[\t ]*/))==null?void 0:o[0])??``;x(n.newLine+e)}}}}},A=(e,t=!0)=>{if(e.type===`Comment`&&f.has(e))return;let n=N(e);if(!(n!==void 0&&e.range&&s.some(t=>t.source===n&&t.start<=e.range[0]&&t.end>=e.range[1]))){if(E(e)&&T(e)&&e.range&&n!==void 0){let r=n.slice(e.range[0],e.range[1]),i=C(e);if(i===void 0||i===r){t&&S(e.loc.start.line,e.loc.start.column),x(r),s.push({source:n,start:e.range[0],end:e.range[1]});return}}switch(e.type){case`Document`:for(let t of e.items)A(t);break;case`Table`:{let n=e;A(n.key,t);for(let e of n.items)A(e);break}case`TableKey`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[${n.item.raw}]`);break}case`TableArray`:{let n=e;A(n.key,t);for(let e of n.items)A(e);break}case`TableArrayKey`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[[${n.item.raw}]]`);break}case`KeyValue`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),A(n.key,!1),D(n.key.loc.end,{line:n.loc.start.line,column:n.equals}),x(`=`),D({line:n.loc.start.line,column:n.equals+1},n.value.loc.start),A(n.value,!1);break}case`Key`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`String`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Integer`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Float`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`Boolean`:t&&S(e.loc.start.line,e.loc.start.column),x(e.value.toString());break;case`DateTime`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;case`InlineArray`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`[`),ee(n),x(`]`);break}case`InlineTable`:{let n=e;t&&S(n.loc.start.line,n.loc.start.column),x(`{`),ee(n),x(`}`);break}case`InlineItem`:{let t=e;if(A(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)&&x(n)}x(`,`)}break}case`Comment`:t&&S(e.loc.start.line,e.loc.start.column),x(e.raw);break;default:throw Error(`toTOMLCursor: Unrecognized node type: ${String(e.type)}`)}}};for(let e of i)A(e);return o.join(``).replace(/\r\n|\n/g,n.newLine)+n.newLine.repeat(n.trailingNewline)}function ai(e,t,n){if(t.start.line===t.end.line){let r=si(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(ni).filter(e=>e!==`
49
49
  `&&e!==`\r
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=ri(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 ni(e,t,n,r){let i=ri(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 ri(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function ii(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 ai(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(mi(r)),ai(e.value,r,n)}}}function oi(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 Oe)return s.PlainDate.from(e.toISOString());if(e instanceof ke)return s.PlainTime.from(e.toISOString());if(e instanceof Ae)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof je){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 q(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=ht(),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{ci(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=mi(n);o.add(r),c.add(r),d=li(a,n),f=n}function h(e){let n=e.key.item.value;try{ci(a,[],n,e.type,p)}catch(n){let r=n;throw new C(t,e.key.loc.start,r.message)}let r=mi(n);s.add(r),c.add(r),d=ui(a,n),f=n}function g(e){let n=e.key.value;try{ci(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=mi(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=si(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(mi(t)),ai(e.value,t,u)}let o=n.length>1?li(d,n.slice(0,-1)):d;o[N(n)]=a,c.add(mi(f.concat(n)))}}function si(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=ht(),i=new Set,a=new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=si(e.value,{integersAsBigInt:n,temporal:r}),c=pi(o),l=mi(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=pi(o.slice(0,e));if(i.has(mi(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=mi(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?li(t,o.slice(0,-1)):t;u[N(o)]=s}),t;case`InlineArray`:return e.items.map(e=>si(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 oi(e.value)}return e.value;case`String`:return e.value;case`Integer`:return ii(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function ci(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]=pi(a),s[e]=mi(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(!At(e,t))return;if(fi(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?N(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)&&!fi(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 li(e,t){let n=di(e,t.slice(0,-1)),r=N(t);return n[r]||(n[r]=ht()),n[r]}function ui(e,t){let n=di(e,t.slice(0,-1)),r=N(t);n[r]||(n[r]=[]);let i=ht();return n[N(t)].push(i),i}function di(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=ht()),Array.isArray(e[t])?N(e[t]):e[t]),e)}function fi(e){return typeof e!=`object`&&!xt(e)}function pi(e){return e.join(`.`)}function mi(e){return JSON.stringify(e)}function J(e){return e.type===`Add`}function hi(e){return e.type===`Edit`}function Y(e){return e.type===`Remove`}function gi(e){return e.type===`Move`}function _i(e){return e.type===`Rename`}function vi(e,t,n=[],r={}){if(e===t||jt(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)?Ci(e,t,n,r):P(e)&&P(t)?yi(e,t,n,r):[{type:`Edit`,path:n}]}function yi(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>Mt(e[t])),s=Object.keys(t),c=s.map(e=>Mt(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))&&Nt(i,vi(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(P(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(P(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||_i(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]:_i(e)?e.to:``,r=J(t)?t.path[t.path.length-1]:_i(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 bi(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(bi)}return!1}function xi(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function Si(e){return e.length>4&&e.some(e=>typeof e==`string`)&&e.some(xi)}function Ci(e,t,n=[],r={}){let i=[],a=e.map(Mt),o=t.map(Mt),s=e.some(bi)||t.some(bi)||Si(e)||Si(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){Nt(i,vi(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=Mt(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&&F(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)&&F(t.key.item.value,e)),o=a===-1?i.items.length:a;s=wi(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&&F(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 wi(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&&F(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&&F(t.slice(0,i.length),i)){let e=t.slice(i.length),n=Mt(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&F(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 Ti(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 Ei=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,Di=new RegExp(String.raw`^#\s*${Ei}(?:\s*\.\s*${Ei})*\s*=`),Oi=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,ki=new RegExp(String.raw`^#\s*${Ei}(?:\s*\.\s*${Ei})*\s*=\s*${Oi}\s*$`),Ai=new RegExp(String.raw`^#\s*\[\[?\s*${Ei}(?:\s*\.\s*${Ei})*\s*\]\]?\s*$`);function ji(e){return ki.test(e.raw)||Ai.test(e.raw)}function Mi(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 Ni(e){return ji(e)?!0:Di.test(e.raw)?Mi(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function Pi(e){let t=e.raw.match(Di);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 Fi(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function Ii(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 Li(e,t,n,r=Ii){let i=[],a=t,o,s=[],c=()=>{s.length&&(i.push({kind:`pinned`,items:s,startLine:s[0].loc.start.line,endLine:N(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?N(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(N(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=Ni(s[t])?Pi(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:N(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 Ri(t,n=()=>!0,r=Ii){let i=e(t)?0:t.key.loc.end.line;return Li(t.items,i,n,r)}function zi(e,t){let n=t.filter(t=>f(t)&&(t.loc.start.line>e.loc.start.line||t.loc.start.line===e.loc.start.line&&t.loc.start.column>=e.loc.start.column)&&(t.loc.end.line<e.loc.end.line||t.loc.end.line===e.loc.end.line&&t.loc.end.column<=e.loc.end.column));return Li([...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 Bi(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 Vi(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 Hi(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=Ui(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),qn(i),n+=o.length}}function Ui(e,t){let n=N(Ri(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(ji);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=Ui(o,a);if(e)for(let t of e)V(n,o,t)}}if(e(i)||t(i)||r(i)){let e=Ri(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(Fi(i)&&e(n)){let e=Vi(n,i);if(e){let t=zi(i,e.items).find(e=>e.member===a);if(t){let r=t.items.filter(e=>e!==a);for(let t of r){let n=e.items.indexOf(t);n<0||e.items.splice(n,1)}r.length&&(a.loc.start=t.items[0].loc.start,a.loc.end=N(t.items).loc.end),V(n,i,a,e.items),H(n);return}}}V(n,i,a)}function Wi(t,n,r,i){let s=!1;if(Fi(n)&&e(t)){let e=Vi(t,n);if(e){let c=zi(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(N(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&&!Xn(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=Bi(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)&&Fn(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 Gi(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 Ki(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 qi(e){return[...e.path,e.key].join(`.`)}function Ji(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 Yi(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=Ji(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 Xi(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 Zi(t,n,r,i,o){let s=Gi(Ri(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(`"${qi(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=Ki(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),qn(t)}function Qi(e,t,n){if(t.length===0)return;Hi(e);let r=[],i=new Map;for(let o of t){var a;if(o.key===void 0)continue;let t=Yi(e,o.path,o.key,n);if(!t){if(Xi(e,o,n))continue;r.push(`"${qi(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())Zi(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
- `))}qn(e)}const $i=new WeakMap,ea=new WeakMap;function ta(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 na(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function ra(e,t,n){ea.has(e)||ea.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 ia(e,t){ea.set(t,t.loc.start.column),$i.set(t,t.loc.start.column-e.loc.end.column)}function aa(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=ta(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=[na(i,a,-1),na(i,a,1)],u;for(let e of l){if(e==null)continue;let t=ta(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;ra(o,u,f)}function oa(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=ta(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[na(r,i,-1),na(r,i,1)];for(let e of c){if(e==null)continue;let t=ta(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){ra(a,t.loc.start.column,n);return}}}function sa(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=ta(r,i);a&&ia(t,a)}function ca(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 la(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&la(i,n)}return n}function ua(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))&&ua(i,n)}return n}function da(e){for(let n of e.items)(t(n)||r(n))&&da(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 fa(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=ua(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=la(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=ea.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=ea.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=>$i.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($i.has(e))return $i.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 da(e),s.join(r)+a}function pa(e,t,n){let r=D(),i=Array.from(Qe(Bt(e),r)),a=I(n,L.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)(ya(i,t,a,n instanceof L||n!=null&&Object.prototype.hasOwnProperty.call(n,`indentWidth`),n instanceof L||n!=null&&Object.prototype.hasOwnProperty.call(n,`trailingComma`)).tomlString)}function ma(e,t,n){let r=e.slice(n),i=0,a=Math.min(r.length,t.length);for(let e=1;e<=a;e++)F(r.slice(r.length-e),t.slice(0,e))&&(i=e);return i}function ha(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&&F(s.slice(0,-1),i)&&s[s.length-1]===n)return t}}function ga(e){let t=new WeakSet,n=e=>{t.add(e)};return Lt(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 _a(e,t,n,r){if(!P(t))return t;let i=q(K(e,I({...n,inlineTableStart:0},n)).items,``,{temporal:r});if(!P(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 va(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(F(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);qn(i)}}}}}function ya(e,t,n,r=!1,i=!0){let a=[...e];t=Sa(t);let o=xa(t),s=1,c=0;for(let e of a){let t=e.loc.end;(t.line>s||t.line===s&&t.column>c)&&(s=t.line,c=t.column)}let l=q(a,``,{temporal:o}),u={type:`Document`,loc:{start:{line:1,column:0},end:{line:s,column:c}},items:a};Dn(u,n.indentWidth);let d=n.inlineTableStart!=null&&n.inlineTableStart>1?1:n.inlineTableStart,f=I({...n,inlineTableStart:d},n),p=K(t,f),m=q(p.items,``,{temporal:o}),h=n.updateOrder?_a(t,m,f,o):m;if(!n.updateOrder&&ba(l,h))return{tomlString:$r(a,n),document:u};let g=Ca(wa(u,h,vi(l,h,[],{updateOrder:n.updateOrder,orderSource:t})));if(g.length===0)return{tomlString:$r(a,n),document:u};let _=ja(u,p,g,n,o,ga(u),t,r,i);return{tomlString:fa(_,ei(_.items,n),n),document:_}}function ba(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 xa(e,t=new WeakSet){return typeof e!=`object`||!e?!1:Ct(e)?!0:!t.has(e)&&(t.add(e),Object.values(e).some(e=>xa(e,t)))}function Sa(e){if(Array.isArray(e)){let t=!1,n=[];for(let r=0;r<e.length;r++){if(!Object.prototype.hasOwnProperty.call(e,r)){t=!0;continue}let i=Sa(e[r]);t||=i!==e[r],n.push(i)}return t?n:e}if(!P(e))return e;let t=e;for(let n of Object.keys(e)){let r=Sa(e[n]);r!==e[n]&&(t===e&&(t={...e}),t[n]=r)}return t}function Ca(e){for(let t=0;t<e.length;t++){let n=e[t];if(Y(n)){let r=N(n.path),i=n.path.slice(0,-1),a=t+1;for(;a<e.length;){let o=e[a];if(J(o)){if(typeof N(o.path)==`number`&&F(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`&&F(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(gi(o)&&o.key===void 0){if(F(i,o.path))break;a++;continue}if(!Y(o)){a++;continue}let s=N(o.path),c=o.path.slice(0,-1);if(typeof r==`number`&&typeof s==`number`&&F(i,c)&&s>r){e.splice(a,1),e.splice(t,0,o),t=-1;break}a++}}}return e}function wa(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 N(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))&&F(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=>N(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)||!hi(t)&&!J(t)&&!Y(t)||typeof N(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=>P(e)))continue;let a=n.filter(t=>!i.has(t)&&(hi(t)||J(t)||Y(t))&&t.path.length>e.length&&F(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 Ta(e,t){return t.map(t=>T.test(t)?t:`"${ar(t,e,`singleline-basic`)}"`).join(`.`)}function Ea(e){let t=[],n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(n){n===`"`&&r?r=!1:n===`"`&&a===`\\`?r=!0:a===n&&(n=void 0);continue}if(a===`"`||a===`'`){n=a;continue}if(a!==`.`)continue;let o=i;for(;o>0&&(e[o-1]===` `||e[o-1]===` `);)o--;let s=i+1;for(;s<e.length&&(e[s]===` `||e[s]===` `);)s++;t.push(e.slice(o,s))}return t}function Da(e){let t=[],n=0,r,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(r){r===`"`&&i?i=!1:r===`"`&&o===`\\`?i=!0:o===r&&(r=void 0);continue}o===`"`||o===`'`?r=o:o===`.`&&(t.push(e.slice(n,a)),n=a+1)}return t.push(e.slice(n)),t}function Oa(e,t){let n=Ea(t);n.length!==0&&(e.raw=Da(e.raw).reduce((e,t,r)=>r===0?t:`${e}${n[Math.min(r-1,n.length-1)]}${t}`,``),e.loc.end.column=e.loc.start.column+e.raw.length)}function ka(e,t){let n;return Lt(e,{KeyValue:e=>{!n&&e.key.value.length>t.length&&F(e.key.value.slice(0,t.length),t)&&Ea(e.key.raw).length>0&&(n=e)}}),n}function Aa(e,t){if(o(e)&&o(t)){let n=mr(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(Ct(r)){let e=wt(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(!(De.IS_TIME_ONLY.test(n)&&r instanceof Date&&r.getUTCFullYear()>1)){let e=De.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=Or(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=kr(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 ja(n,i,s,c,h=!1,_=new WeakSet,v=void 0,y=!1,b=!0){let x=new Map,S=new Set;function C(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&&S.add(e)}}let w=new WeakMap;function E(e){let i=w.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=Mt(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&&w.set(e,c),c}function D(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||!F(n.key.value,t.slice(t.length-r))}function O(e,i){let o=e.key.item.value.concat(i);return e.items.some(e=>a(e)&&e.key.value.length>i.length&&F(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&&F(n.slice(0,o.length),o)})}function k(e,t){let n=[],r=!1;for(let i of e.items){if(!a(i)||!d(i.value)||!O(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=Ka(n,c);r!==void 0&&e.push(ur(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=cr(e.key.item.value);for(let e of n)B(i,i,e);return H(i),i}function A(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 j(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),Fa(n,e)}function ee(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 te(e,t,r,i){ee(e,t),z(n,i,r,e)}function ne(e,t,r){let i=Z(n,e);if(i&&!D(i,e))return null;let a=e.length;for(;a>0;){let t=Z(n,e.slice(0,a));if(t&&!D(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=Ka(e,c);if(n!==void 0)return ur([...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,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 re=new Set,ie=new Set,ae=new WeakMap;function oe(e,t){return ae.get(e)??t}let se=[],ce=new Set,le=[];function ue(e,t,r){if(!l(e)&&!d(e)||!u(r)||d(e)&&!a(r.item))return r;let i=v;for(let e of t)i=i==null?void 0:i[e];if(!Array.isArray(i)&&!P(i))return r;let o=xn(n,e)??0,s=Xn(e)||e.items.length===0&&e.loc.end.line>e.loc.start.line,f=y?c.indentWidth:l(e)&&e.items.length===0?Math.max(c.indentWidth,4):c.indentWidth;l(e)&&e.items.length===0&&!c.useTabsForIndentation&&On(e,Math.max(f,4));let p=Array.isArray(i)?`array`:`table`,m=e.items.map(t=>d(e)&&a(t.item)?t.item.value:t.item).find(e=>p===`array`?l(e):d(e)),h=m&&p===`array`?Or(m):m&&p===`table`?kr(m):!1,g=m,_=g&&g.items.length>0?g.items[0].loc.start.column-g.loc.start.column>1:void 0,x=ln(p,o+1,s,c),S=p===`array`?`multilineArray`:`multilineTable`,C=I({...c,inlineTableStart:0,[S]:x,trailingComma:b?c.trailingComma:h,bracketSpacing:_??c.bracketSpacing,indentWidth:f},c),w=K({tmp:i},C,o+1,s).items[0];if(!w||!a(w))return r;let T=w.value;if(x&&(l(T)||d(T))){let e=T.loc.start.column;T.loc.start.column=0,T.loc.end.line===T.loc.start.line?T.loc.end.column-=e:ln(l(T)?`array`:`table`,o+1,s,C)&&(T.loc.end.column=1)}if(d(e)){let e=G(ur(r.item.key.value,T));return e.comma=r.comma,e}let E=G(T);return e.items.length===0&&l(e)&&d(T)&&(E.comma=!0),E}function de(e,t,r){let i=u(t)?t.item:t;if(!l(i)&&!d(i))return t;let o=v;for(let e of r)o=o==null?void 0:o[e];if(!Array.isArray(o)&&!P(o))return t;let s=Sn(n,e),f=s?xn(n,s)??0:-1,p=s?Xn(s)||s.items.length===0&&s.loc.end.line>s.loc.start.line:!1,m=Array.isArray(o)?`array`:`table`,h=m===`array`?c.multilineArray:c.multilineTable,g=ln(m,f+1,p,c),_=u(e)?e.item:e,y=l(_)||d(_)?_:void 0,x=l(_)?`array`:d(_)?`table`:void 0,S=y!==void 0&&x!==m&&bn(y)&&h===`auto`;if(!(g||S))return t;let C=m===`array`?`multilineArray`:`multilineTable`,w=I({...c,inlineTableStart:0,[C]:!0,trailingComma:b?c.trailingComma:!1},c),T=K({tmp:o},w,f+1,p).items[0];if(!T||!a(T))return t;let E=T.value;if(l(E)||d(E)){let t=u(e)?e.item.loc.start.column:e.loc.start.column;E.loc.end.line===E.loc.start.line?E.loc.end.column+=t-E.loc.start.column:E.loc.end.column=1,E.loc.start.column=t}if(u(t)){let e=G(E);return e.comma=t.comma,e}return E}s.forEach(s=>{if(J(s)){var y;let o=X(i,s.path),m=s.path.slice(0,-1),g=N(s.path),_=r(o);if(_t(g)&&!_&&!_t(N(m))){let e=Z(n,m.concat(0));e&&r(e)&&(_=!0)}if(_&&_t(g)&&!_t(N(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 s.path)e=e==null?void 0:e[t];let r=I({...c,inlineTableStart:0},c),l=e===void 0?void 0:K({tmp:e},r),f=l==null?void 0:l.items[0];if(f&&a(f)&&(o=G(f.value),_=!1,u(o)&&d(o.item)&&o.item.items.length>0)){let e=o.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&&Jn(n,e,!0)}}}}if(_&&!r(o)){let e=m.filter(e=>typeof e==`string`),n=q(i.items,``,{temporal:h});for(let e of s.path)n=n==null?void 0:n[e];if(n!==void 0){let i=cr(e),a=K(n,c);for(let e of a.items)B(i,i,e,void 0);let s=n=>{if(p(n))for(let i of n.items){if(!t(i)&&!r(i))continue;let n=i.key,a=n.item,o=e.concat(a.value);a.value=o,a.raw=pr(o).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,s(i)}};s(i),H(i),o=i}}let v;if(t(o))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&&F(s.slice(0,n.length),n)&&(a=i)}g=a+1,r(o)&&(o=k(o,i))}}else g=e.items.length}else{v=n;for(let e=s.path.length-1;e>=0;e--){let t=Z(n,s.path.slice(0,e));if(t&&!D(t,s.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)||d(v))&&(o=ue(v,s.path,o),Gr(v,o,c.indentWidth)),l(v)){let e=Z(n,m),t=Z(n,m.slice(0,-1));if(e&&a(e)&&t){let n=ca(v,o,g);n!==0&&oa(t,e,n)}}let b=(l(v)||d(v))&&v.loc.end.line>v.loc.start.line;b&&ie.has(v)&&H(n);let x=l(v)||d(v)?(y=Vi(n,v))==null?void 0:y.items:void 0;if(r(v)||l(v)||e(v)){if(l(v)){let e=oe(v,Or(v));if(u(o)){let t=v.items.length===0&&d(o.item)&&Xn(o.item);o.comma=t||e;let n=o,r=d(n.item)?n.item:void 0,l=r&&r.items.length>0?v.items.map(e=>e.item).find(e=>e!==n.item&&d(e)):void 0;if(r&&l){let e=kr(l);if(e!==kr(r)){let t=q(i.items,``,{temporal:h});for(let e of s.path)t=t==null?void 0:t[e];let r=I({...c,inlineTableStart:0,trailingComma:e},c),l=t===void 0?void 0:K({tmp:t},r).items[0];if(l&&a(l)){let e=G(l.value);e.comma=n.comma,o=e}}}}}if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&e(v)&&t(o)){let e=Wa(o,n,c);B(n,v,o,g);for(let t of e)B(n,n,t,void 0)}else{let i=o;u(o)&&(r(v)||e(v))&&(i=o.item);let c=g;if(e(v)&&a(i)){let e=v.items.findIndex(e=>t(e)||r(e));e!==-1&&(c=e)}let d=!1;if((r(v)||e(v))&&a(i)){let e=ne(m,i,s.path);e&&(re.has(v)&&H(n),i=e,d=!0)}if(l(v)&&v.items.length===0&&H(n),c===0&&l(v)&&zn(n).has(v)&&H(n),c===0&&(e(v)||t(v)||r(v))&&zn(n).has(v)&&H(n),a(i)&&i.key.value.length>1){let e=ka(n,i.key.value.slice(0,-1));if(e){let t=i.equals;Oa(i.key,e.key.raw),i.equals=i.key.loc.end.column+e.equals-e.key.loc.end.column;let n=i.equals-t;U(i.value,{lines:0,columns:n},{first_line_only:!0}),i.loc.end.line===i.loc.start.line&&(i.loc.end.column+=n)}}B(n,v,i,c,void 0,x),d&&re.add(v)}}else if(d(v)){v.items.length===0&&(H(n),Nn(v)&&v.loc.end.line>v.loc.start.line&&(v.loc.end.line=v.loc.start.line));let e=oe(v,kr(v));if(a(o)){let t=G(o);t.comma=e;let r=ha(v,o,s.before);B(n,v,t,r,void 0,x)}else if(u(o)&&a(o.item)){let t=o.item,r=ne(m,t,s.path);r&&(re.has(v)&&H(n),t=r);let i=G(t);i.comma=e;let a=ha(v,t,s.before);B(n,v,i,a,void 0,x),r&&re.add(v)}else B(n,v,o,void 0,void 0,x)}else if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&a(o)&&d(o.value)&&t(v))zr([...v.key.item.value,...o.key.value])<c.inlineTableStart?Ga(o,v,n,c):B(n,v,o);else if(c.inlineTableStart===0&&a(o)&&d(o.value)&&e(v))B(n,v,o,void 0,!0);else{let i=o;u(o)&&(t(v)||r(v)||e(v))&&(i=o.item);let c=!1;if(t(v)&&a(i)){let e=ne(m,i,s.path);e&&(re.has(v)&&H(n),i=e,c=!0)}let l=(t(v)||r(v))&&v.items.length>0&&v.items.every(f)?2:void 0;B(n,v,i,void 0,void 0,void 0,l),c&&re.add(v)}b&&ie.add(v)}else if(hi(s)){let f=Z(n,s.path),m;try{m=X(i,s.path)}catch{m=void 0}if(!f||!m){La(n,i,s,c,h,_,S);return}if(a(f)&&t(m)){let e=m.key.item.value;if($(n,e).some(e=>e!==f)){La(n,i,s,c,h,_,S);return}}if(u(f)&&(t(m)||r(m))){let e=Z(n,s.path.slice(0,-1)),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=v;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=I({...c,inlineTableStart:0},c),n=K({tmp:e},t),r=n==null?void 0:n.items[0];r&&a(r)&&(m=G(r.value))}}}let y,b=Z(n,s.path.slice(0,-1));b&&a(b)&&D(b,s.path.slice(0,-1))&&(b=A(n,b));let x=qa(n,s.path);if(a(f)&&a(m)){let i=!1;if(f.key.value.length>1){let o=E(f),c=ma(s.path,f.key.value,o?o.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=pr(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&&F(s.slice(0,u.length),u)&&Q(n,b,o)}}}}if(!i&&a(m)&&b&&(t(b)||e(b)||r(b))&&Ya(n,b,f.key.value,f),Aa(f.value,m.value),b&&aa(b,f,f.value,m.value),y=f,f=f.value,m=m.value,i&&v!==void 0){let e=v;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Ka(e,c);t!==void 0&&(m=t,Aa(f,m))}}}else if(a(f)&&u(m)&&a(m.item)){let i=!1;if(f.key.value.length>1){let o=E(f),c=ma(s.path,f.key.value,o?o.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=pr(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&&F(s.slice(0,u.length),u)&&Q(n,b,o)}}}}if(!i&&a(m.item)&&b&&(t(b)||e(b)||r(b))&&Ya(n,b,f.key.value,f),y=f,f=f.value,m=m.item.value,i&&v!==void 0){let e=v;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Ka(e,c);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 o=E(e),c=ma(s.path,e.key.value,o?o.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=pr(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&&Fn(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&&F(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(Aa(e.value,m.value),y=e,f=e.value,m=m.value,i&&v!==void 0){let e=v;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Ka(e,c);t!==void 0&&(m=t,Aa(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 o=E(i),c=ma(s.path,i.key.value,o?o.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=pr(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&&Fn(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&&F(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(Aa(i.value,m.item.value),y=i,f=i.value,m=m.item.value,e&&v!==void 0){let e=v;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Ka(e,c);t!==void 0&&(m=t,Aa(f,m))}}}else if(t(f)){let o=q(i.items,``,{temporal:h});for(let e of s.path)o=o==null?void 0:o[e];if(o!==void 0){let i=f.key.item.value,l=i.slice(-1),u=i.slice(0,-1),d=A(n,f)??Ti(n,s.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=K({[l[0]]:o},c),m=p.items[0];if(u.length>0){if(t(m)||r(m))te(m,u,f,d),_.add(m);else if($(n,u).some(a))j(m,u,f,d),_.add(m);else{let e=n.items.find(e=>e!==f&&(t(e)||r(e))&&F(e.key.item.value,u));if(e)B(n,e,m,void 0),Q(n,d,f),_.add(m);else{let e=W(u);S.add(e),B(n,e,m,0),z(n,d,f,e),_.add(e)}}}else z(n,d,f,m),_.add(m),Fa(n,m);if(p.items.length>1)for(let e=1;e<p.items.length;e++){let t=p.items[e];u.length>0&&ee(t,u);let r=e===1?m:p.items[e-1];B(n,d,t,d.items.indexOf(r)+1),_.add(t)}return}y=Ti(n,s.path)}else if(r(f)){let o=q(i.items,``,{temporal:h}),l=f.key.item.value,u=o,d=typeof s.path[s.path.length-1]==`number`?s.path.slice(0,-1):s.path;for(let e of d)u=u==null?void 0:u[e];if(u!==void 0){let i=l.slice(-1),o=l.slice(0,-1),d=A(n,f)??Ti(n,s.path),p=K({[i[0]]:u},c).items[0];if(Array.isArray(u)&&!u.every(e=>P(e))){let e=$(n,l).filter(e=>e!==f&&(t(e)||r(e)));for(let t of e)Q(n,n,t)}if(o.length>0){if(t(p)||r(p))te(p,o,f,d),_.add(p);else{let r=e(d)?d.items.find(e=>t(e)&&F(e.key.item.value,o)):void 0;if(r){let e=r.items.find(e=>a(e)&&F(e.key.value,p.key.value));e?z(n,r,e,p):B(n,r,p,void 0),Q(n,d,f),_.add(r);return}if($(n,o).some(a))j(p,o,f,d),_.add(p);else{let e=W(o);S.add(e),B(n,e,p,0),z(n,d,f,e),_.add(e)}}}else z(n,d,f,p),_.add(p),Fa(n,p);return}y=Ti(n,s.path)}else if(y=Ti(n,s.path),a(y)){let e=X(n,s.path.slice(0,-1));a(e)&&l(e.value)&&(y=e.value)}else u(y)&&a(y.item)?y=y.item.value:(u(y)&&d(y.item)||u(y)&&l(y.item))&&(y=y.item);if(u(f)&&u(m)&&(o(f.item)&&o(m.item)&&(Aa(f.item,m.item),m.loc={start:{...m.item.loc.start},end:{...m.item.loc.end}}),m.comma=f.comma),x){let e=g(f.loc),t=g(m.loc).columns-e.columns;t!==0&&sa(x.container,x.row,t)}m=de(f,m,s.path),z(n,y,f,m),l(m)&&ce.add(m),(l(m)||d(m))&&(H(n),Lr(m,c.indentWidth),le.push({owner:y,container:m})),e(y)&&a(f)&&(t(m)||r(m))&&Ia(n,m)}else if(Y(s)){let o=Z(n,s.path);if(o){let f=Ti(n,s.path);if(f===o&&(f=Ti(n,s.path.slice(0,-1))),f===o){let e=Vi(n,o);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(o))&&(f=A(n,o)??(p(f)?n:Vi(n,o)??n));let h=!1;if(s.path.length>1&&t(o)&&v!==void 0){let e=s.path.slice(0,-1),t=o.key.item.value.slice(0,-1);if($(n,t).filter(e=>e!==o).length===0){let r=v;for(let t of e)r=r==null?void 0:r[t];if(P(r)&&Object.keys(r).length===0){let e=o;for(;e.items.length>0;)V(n,e,N(e.items));H(n);let r=e.key,i=m(r)?r.item:r;i.value=t,i.raw=Ta(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,C(e),h=!0}}}let g=e(f)&&p(f)?f.items.indexOf(o):-1,_=p(f)&&!e(f)?f.items.indexOf(o):-1,y=u(o)?o.comma:void 0;u(o)&&(l(f)||d(f))&&On(f,o.loc.start.column),u(o)&&(l(f)||d(f))&&_===f.items.length-1&&y!==void 0&&ae.set(f,y);let b=u(o)&&(l(f)||d(f))&&o.loc.end.line===f.loc.end.line?f.loc.end.column-o.loc.end.column:void 0,w=E(u(o)&&a(o.item)?o.item:o),D=a(o)?o:u(o)&&a(o.item)?o.item:void 0;if(D&&w&&p(f)){let e=w.length-D.key.value.length,i=s.path.slice(e);if(i.length>0&&i.length<D.key.value.length){let e=f.items,s=[];for(let n of e){if(n===o)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&&F(e.slice(0,i.length),i)&&s.push(n)}for(let e of s)Q(n,f,e)}}if(D&&w&&p(f)){let e=D.key.value,i=f.items,s=[];for(let n of i){if(n===o)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&&F(i.slice(0,e.length),e)&&s.push(n)}for(let e of s)Q(n,f,e)}if((t(o)||r(o))&&p(f)){let e=o.key.item.value,i=f.items,s=[];for(let n of i){if(n===o)continue;let i=a(n)?n.key.value:t(n)||r(n)?n.key.item.value:void 0;i&&i.length>e.length&&F(i.slice(0,e.length),e)&&s.push(n)}for(let e of s)Q(n,f,e)}if(h||Q(n,f,o),u(o)&&(l(f)||d(f))&&o.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&&N(e).loc.end.line===f.loc.end.line;if(e.length>0&&_===e.length&&t){let t=b??f.loc.end.column-o.loc.end.column;H(n);let r=N(e).loc.end.column+t;f.loc.end.column!==r&&(f.loc.end.column=r);let i,s=e=>{if(a(e))return e.value===f?e:s(e.value);if(u(e))return s(e.item);if(p(e))for(let t of e.items){let e=s(u(t)?t.item:t);if(e)return e}};if(i=s(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&&(Fn(n,t,{lines:0,columns:e}),In(n),H(n))}}}}if(!h&&s.path.length>1&&(t(o)||r(o))&&v!==void 0){let e=s.path.slice(0,-1),t=o.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(P(r)&&Object.keys(r).length===0){let e=W(t);S.add(e);let r=g>=0?Math.min(g,n.items.length):n.items.length;H(n),B(n,n,e,r)}}}if(!h&&s.path.length>1&&v!==void 0){let i=a(o)?o:u(o)&&a(o.item)?o.item:void 0;if(i&&i.key.value.length>1){let o=s.path.slice(0,-1),l=e(f)||t(f)||r(f)||d(f)?f:n;if(p(l)){let s;if(t(l)||r(l)){let e=l.key.item.value,t=0,n=0;for(let r=0;r<e.length&&t<o.length;r++){for(;t<o.length&&typeof o[t]==`number`;)t++;if(t>=o.length||o[t]!==e[r])break;n++,t++}for(;t<o.length&&typeof o[t]==`number`;)t++;s=n===e.length?o.slice(t):o.slice(e.length+ +!!r(l))}else if(d(l)){if(w){let e=w.slice(0,w.length-i.key.value.length),t=0,n=0;for(;n<e.length&&t<o.length;){for(;t<o.length&&typeof o[t]==`number`;)t++;if(t>=o.length||o[t]!==e[n])break;n++,t++}for(;t<o.length&&typeof o[t]==`number`;)t++;s=n===e.length?o.slice(t):o.slice(e.length)}else s=o.slice(o.length-(i.key.value.length-1))}else s=o;s=s.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?F(t.slice(0,s.length),s):!1}),p=r(l),m=[];p&&f.length===0&&(m=$(n,l.key.item.value.concat(s)));let h=s.length===0&&(t(l)||r(l)||d(l));if(f.length===0&&m.length===0&&!h){let r=v;for(let e of o)r=r==null?void 0:r[e];if(P(r)&&Object.keys(r).length===0){if(d(l)){let e=s.map(e=>T.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),t=Array.from(Qe(`${e} = {}`))[0];if(a(t)){let e=G(t);e.comma=y??!1,H(n),Nn(l)&&l.loc.end.line>l.loc.start.line&&(l.loc.end.line=l.loc.start.line),B(n,l,e,_>=0?_:void 0),c.bracketSpacing&&U(e,{lines:0,columns:1});let r=l.items[_+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(s):s);S.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=Na(n);i=e>=0?e:n.items.length}H(n),B(n,n,r,i)}}}}}if(r(o)){let e=o.key.item.value,t=s.path.slice(0,-1);!Z(n,t.concat(0))&&Z(i,t)&&x.set(e.join(`.`),e)}}else{let e=()=>Z(n,s.path.concat(0))||$(n,s.path).filter(r)[0],a=e();if(a){let o=n.items.indexOf(a),c=!1;if(s.path.length>1&&v!==void 0){let e=s.path.slice(0,-1);if($(n,e).filter(e=>!(r(e)&&F(e.key.item.value,s.path))).length===0){let t=v;for(let n of e)t=t==null?void 0:t[n];if(P(t)&&Object.keys(t).length===0){let t=a,r=t.key;for(;t.items.length>0;)Q(n,t,N(t.items));H(n),t.type=`Table`,r.type=`TableKey`;let i=m(r)?r.item:r;i.value=e,i.raw=Ta(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,C(t),c=!0}}}let l;for(;l=e();)Q(n,n,l);for(let e of $(n,s.path).filter(t))Q(n,n,e);if(Z(i,s.path)){let e=s.path;x.set(e.join(`.`),e)}if(!c&&s.path.length>1&&v!==void 0){let e=s.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(P(t)&&Object.keys(t).length===0){let t=W(e);S.add(t);let r=o>=0?Math.min(o,n.items.length):n.items.length;H(n),B(n,n,t,r)}}}}else{let e=Ja(n,s.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 s.path.slice(0,-1))e=e==null?void 0:e[t];if(P(e)&&Object.keys(e).length===0){let e=W(t);S.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,s.path)}}}else if(gi(s)){if(s.key!==void 0){se.push(s);return}let e=Z(n,s.path);if(e){if(m(e)&&(e=e.item),a(e)&&(e=e.value),s.from>=e.items.length)return;let t=e.items[s.from];Wi(n,e,t,s.to)}else{va(n);let e=X(n,s.path.concat(s.from)),i=Ri(n).find(t=>t.member===e),a=i?[...i.items]:[e],o=a.map(e=>({startLine:e.loc.start.line,endLine:e.loc.end.line})),c=n.items.indexOf(i?i.items[0]:e),l=o[o.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=o[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,s.path.concat(s.to)),m,h=!1,g=i&&i.items[0]!==e&&f(i.items[0]);if(p){let e=Ri(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],s;if((y||g&&m>0&&m<n.items.length)&&b>0){let n=e===0?_:o[e-1].endLine,a=e===0&&v!==void 0?v-_:o[e].startLine-n;a!==(t(i)||r(i)?2:1)&&(s=a)}B(n,n,i,b,void 0,void 0,s),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(_i(s)){let e=s.path.concat(s.from),o=Z(n,e);if(!o){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,a=n.raw;n.value[r]=s.to,n.raw=Ta(n.raw,n.value),Oa(n,a),n.loc.end.column=n.loc.start.column+n.raw.length;return}}o||=X(n,e);let c=X(i,s.path.concat(s.to));m(o)&&(o=o.item),m(c)&&(c=c.item);let l=o.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=s.path.concat(s.from);if((t(o)||r(o))&&a(c)&&F(d.value.slice(0,e.length),e)){let t=e.length-1,n=d.raw;d.value[t]=s.to,d.raw=Ta(d.raw,d.value),Oa(d,n),d.loc.end.column=d.loc.start.column+d.raw.length;return}if(a(o)&&a(c)&&d.value.length<=e.length&&F(d.value,e.slice(e.length-d.value.length))){let e=d.raw;d.value[d.value.length-1]=s.to,d.raw=Ta(d.raw,d.value),d.loc.end.column=d.loc.start.column+d.raw.length;let t=d.raw.length-e.length;t>0&&(o.equals+=t,U(o.value,{lines:0,columns:t},{first_line_only:!0}),Fn(n,o.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=Ta(d.raw,f.value),Oa(f,d.raw),f.loc.end.column=f.loc.start.column+f.raw.length,z(n,m(l)?l:o,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)&&S.has(i)){let e=i.loc.start.line-r.loc.end.line-1;e>0&&U(i,{lines:-e,columns:0})}}let fe=n.items;for(let e=0;e<fe.length-1;e++){let n=fe[e],i=fe[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<fe.length;t++)U(fe[t],{lines:n,columns:0})}}}let pe=!1;Lt(n,{InlineTable:e=>{Nn(e)&&(pe=!0)},InlineArray:e=>{Nn(e)&&(pe=!0)}}),pe&&H(n);let me=!1,he=[];if(Lt(n,{InlineTable:e=>{Nn(e)&&(he.push(e),Ra(e),Pn(e),Jn(n,e,c.bracketSpacing),me=!0)},InlineArray:e=>{Nn(e)&&(Ra(e),Pn(e),Jn(n,e,c.bracketSpacing),me=!0)}}),me){H(n);for(let e of he)za(n,e);Ba(n)}if(Ha(n),Ua(n,x,c),Qi(n,se,_),se.length>0&&In(n),ce.size>0){H(n);for(let e of ce)Kr(e,c.indentWidth)}if(le.length>0){H(n);for(let{owner:e,container:t}of le)Ma(t),Fr(t,e.loc.start.column,c.indentWidth,c.bracketSpacing)}return n}function Ma(e){if(delete e.range,p(e))for(let t of e.items)Ma(t);m(e)&&Ma(e.item),a(e)&&(Ma(e.key),Ma(e.value))}function Na(e){return e.items.findIndex(e=>t(e)||r(e))}function Pa(e){let t=Na(e);return t===-1?void 0:t}function Fa(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=Na(e);r===-1||r>n||(V(e,e,t),H(e),B(e,e,t,r))}function Ia(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 La(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&&F(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(K(d,o).items,o),m=Array.from(Qe(p)),h=t=>{let n=s.items.find(e=>a(e)&&F(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=pr(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(K(p,o).items,o),g=Array.from(Qe(h)),_=Pa(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)&&F(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)&&F(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 Ra(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 za(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,_=Va(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 Ba(e){Lt(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=Va(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=Va(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function Va(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 Ha(e){Lt(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=Ti(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 Ua(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=ur([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=ur(t,K({[t[t.length-1]]:[]},i).items[0].value);H(e),B(e,o,n);continue}}let n=ur(a,K({[a[a.length-1]]:[]},i).items[0].value);H(e),B(e,e,n,Pa(e))}H(e)}}function Wa(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(zr(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),Rr(e),r.push(n),i(n,r)}}}};return i(e,r),r}function Ga(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),Rr(t);let o=Wa(i,n,r);for(let e of o)B(n,n,e,void 0)}function Ka(e,n){let r=I({...n,inlineTableStart:0},n),i=$r(K({__tmp__:e},r).items,r),o=Array.from(Qe(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 qa(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&&F(e.slice(0,n.length),n)&&i.push(o)}return i}function Ja(e,t){let n=[];for(let i of t)typeof i==`number`&&$(e,n).some(r)||n.push(i);return n}function Ya(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&&F(u.slice(0,i.length),i)&&Q(e,n,l)}}function Xa(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function Za(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=Xa(t.loc.end,r)<0,n=Xa(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 Qa=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:Rt(e),r=Bt(n);this._currentTomlString=r,this._cst=Array.from(Qe(r)),this._integersAsBigInt=(t==null?void 0:t.integersAsBigInt)??`asNeeded`,this._temporal=(t==null?void 0:t.temporal)??!1,this._format=L.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:to(e)}get cst(){return this._cst}patch(e,t){let n=I(t,this._format),r=this._currentTomlString;if(!this._temporal&&$a(e)){let t=q(this._cst,r,{integersAsBigInt:this._integersAsBigInt,temporal:!1});e=eo(e,t)}let i=t instanceof L||t!=null&&Object.prototype.hasOwnProperty.call(t,`indentWidth`),a=t instanceof L||t!=null&&Object.prototype.hasOwnProperty.call(t,`trailingComma`),o=ya(this._cst,e,n,i,a);this._cst=Array.from(Qe(o.tomlString)),this._format=n,this._currentTomlString=o.tomlString}update(e){let t=Bt(e);if(t===this._currentTomlString){this._format.leadingBom=zt(e);return}let n=this._currentTomlString.split(this._format.newLine),r=Yt(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}=Za(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($e(c,p)),this._currentTomlString=t,this._format=L.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=Bt(e);if(t===this._currentTomlString){this._format.leadingBom=zt(e);return}this._cst=Array.from(Qe(t)),this._currentTomlString=t,this._format=L.autoDetectFormatWithCst(e,this._cst)}};function $a(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=>$a(e,t)):Object.keys(e).some(n=>$a(e[n],t)))}function eo(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=eo(e,t[i],n);return a!==e&&(r=!0),a});return r?i:e}if(!P(t))return e;let r=!1,i={};for(let a of Object.keys(e)){let o=e[a],s=eo(o,t[a],n);i[a]=s,s!==o&&(r=!0)}return r?i:e}function to(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(to);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=to(r);return t}return e}function no(e,t){let n=Bt(typeof e==`string`?e:Rt(e));return q(Qe(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function ro(e,t){let n=I(t,L.default()),r=$r(K(e,n).items,n);return n.leadingBom?`${r}`:r}function io(e,t){return new Qa(e,t)}export{Oe as LocalDate,Ae as LocalDateTime,ke as LocalTime,je as OffsetDateTime,Qa as TomlDocument,L as TomlFormat,no as parse,io as parseDocument,pa as patch,ro 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=si(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 oi(e,t,n,r){let i=si(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 si(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]=``);return e[t-1]}function ci(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 li(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(vi(r)),li(e.value,r,n)}}}function ui(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 je)return s.PlainDate.from(e.toISOString());if(e instanceof Me)return s.PlainTime.from(e.toISOString());if(e instanceof Ne)return s.PlainDateTime.from(e.toISOString().replace(` `,`T`));if(e instanceof Pe){let t=e.toISOString().replace(` `,`T`),n=t.match(/([+-]\d{2}:\d{2}|Z)$/),r=n?n[1]:`Z`,i=t.replace(/([+-]\d{2}:\d{2}|Z)$/,``),a=r===`Z`?`+00:00`:r;return s.ZonedDateTime.from(`${i}${r}[${a}]`)}return s.PlainDateTime.from(e.toISOString().replace(`Z`,``))}function q(e,t=``,n={}){let{integersAsBigInt:r=`asNeeded`,temporal:i=!1}=n,a=vt(),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{fi(a,[],n,e.type,p)}catch(n){let r=n;throw new D(t,e.key.loc.start,r.message)}let r=vi(n);o.add(r),c.add(r),d=pi(a,n),f=n}function h(e){let n=e.key.item.value;try{fi(a,[],n,e.type,p)}catch(n){let r=n;throw new D(t,e.key.loc.start,r.message)}let r=vi(n);s.add(r),c.add(r),d=mi(a,n),f=n}function g(e){let n=e.key.value;try{fi(d,f,n,e.type,p)}catch(n){let r=n;throw new D(t,e.key.loc.start,r.message)}if(n.length>1)for(let e=1;e<n.length;e++){let t=vi(f.concat(n.slice(0,e)));l.add(t),c.add(t)}let a;try{a=di(e.value,{integersAsBigInt:r,temporal:i})}catch(n){let r=n;throw new D(t,e.value.loc.start,r.message)}if(e.value.type===`InlineTable`){let t=f.concat(n);u.add(vi(t)),li(e.value,t,u)}let o=n.length>1?pi(d,n.slice(0,-1)):d;o[P(n)]=a,c.add(vi(f.concat(n)))}}function di(e,t={}){let{integersAsBigInt:n=`asNeeded`,temporal:r=!1}=t;switch(e.type){case`InlineTable`:let t=vt(),i=new Set,a=new Map;return e.items.forEach(({item:e})=>{let o=e.key.value,s=di(e.value,{integersAsBigInt:n,temporal:r}),c=_i(o),l=vi(o);if(i.has(l))throw Error(`Duplicate key "${c}" in inline table`);for(let e=1;e<o.length;e++){let t=_i(o.slice(0,e));if(i.has(vi(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=vi(o.slice(0,e));a.has(t)||a.set(t,c)}let u=o.length>1?pi(t,o.slice(0,-1)):t;u[P(o)]=s}),t;case`InlineArray`:return e.items.map(e=>di(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 ui(e.value)}return e.value;case`String`:return e.value;case`Integer`:return ci(e.raw,n);case`Float`:case`Boolean`:return e.value;default:throw Error(`Unrecognized value type "${e.type}"`)}}function fi(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]=_i(a),s[e]=vi(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(!Nt(e,t))return;if(gi(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?P(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)&&!gi(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 pi(e,t){let n=hi(e,t.slice(0,-1)),r=P(t);return n[r]||(n[r]=vt()),n[r]}function mi(e,t){let n=hi(e,t.slice(0,-1)),r=P(t);n[r]||(n[r]=[]);let i=vt();return n[P(t)].push(i),i}function hi(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=vt()),Array.isArray(e[t])?P(e[t]):e[t]),e)}function gi(e){return typeof e!=`object`&&!wt(e)}function _i(e){return e.join(`.`)}function vi(e){return JSON.stringify(e)}function J(e){return e.type===`Add`}function yi(e){return e.type===`Edit`}function Y(e){return e.type===`Remove`}function bi(e){return e.type===`Move`}function xi(e){return e.type===`Rename`}function Si(e,t,n=[],r={}){if(e===t||Pt(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)?Di(e,t,n,r):F(e)&&F(t)?Ci(e,t,n,r):[{type:`Edit`,path:n}]}function Ci(e,t,n=[],r={}){let i=[],a=Object.keys(e),o=a.map(t=>Ft(e[t])),s=Object.keys(t),c=s.map(e=>Ft(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))&&It(i,Si(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(F(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(F(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||xi(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]:xi(e)?e.to:``,r=J(t)?t.path[t.path.length-1]:xi(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 wi(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(wi)}return!1}function Ti(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function Ei(e){return e.length>4&&e.some(e=>typeof e==`string`)&&e.some(Ti)}function Di(e,t,n=[],r={}){let i=[],a=e.map(Ft),o=t.map(Ft),s=e.some(wi)||t.some(wi)||Ei(e)||Ei(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){It(i,Si(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=Ft(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&&I(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)&&I(t.key.item.value,e)),o=a===-1?i.items.length:a;s=Oi(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&&I(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 Oi(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&&I(t.slice(0,i.length),i)&&(a=t.slice(i.length))}else if(r(e)){let t=e.key.item.value;if(t.length>i.length&&I(t.slice(0,i.length),i)){let e=t.slice(i.length),n=Ft(e);o[n]||(o[n]=0);let r=o[n]++;a=e.concat(r)}}if(a.length&&I(a,n.slice(0,a.length)))try{return 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 ki(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 Ai=String.raw`(?:[\w-]+|"[^"]*"|'[^']*')`,ji=new RegExp(String.raw`^#\s*${Ai}(?:\s*\.\s*${Ai})*\s*=`),Mi=String.raw`(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|"""[\s\S]*?"""|'''[\s\S]*?'''|[^\s#]+)`,Ni=new RegExp(String.raw`^#\s*${Ai}(?:\s*\.\s*${Ai})*\s*=\s*${Mi}\s*$`),Pi=new RegExp(String.raw`^#\s*\[\[?\s*${Ai}(?:\s*\.\s*${Ai})*\s*\]\]?\s*$`);function Fi(e){return Ni.test(e.raw)||Pi.test(e.raw)}function Ii(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 Li(e){return Fi(e)?!0:ji.test(e.raw)?Ii(e)?!0:e.raw.replace(/^[^=]*=\s*/,``).split(/\s+/).filter(Boolean).length<=3:!1}function Ri(e){let t=e.raw.match(ji);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 zi(e){return(d(e)||l(e))&&e.loc.end.line>e.loc.start.line}function Bi(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 Vi(e,t,n,r=Bi){let i=[],a=t,o,s=[],c=()=>{s.length&&(i.push({kind:`pinned`,items:s,startLine:s[0].loc.start.line,endLine:P(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?P(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(P(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=Li(s[t])?Ri(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:P(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 Hi(t,n=()=>!0,r=Bi){let i=e(t)?0:t.key.loc.end.line;return Vi(t.items,i,n,r)}function Ui(e,t){let n=t.filter(t=>f(t)&&(t.loc.start.line>e.loc.start.line||t.loc.start.line===e.loc.start.line&&t.loc.start.column>=e.loc.start.column)&&(t.loc.end.line<e.loc.end.line||t.loc.end.line===e.loc.end.line&&t.loc.end.column<=e.loc.end.column));return Vi([...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 Wi(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 Gi(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 Ki(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=qi(i,a);if(!o)continue;let s=i.items;s.splice(s.length-o.length,o.length),e.items.splice(n+1,0,...o),Zn(i),n+=o.length}}function qi(e,t){let n=P(Hi(e));if(!n||n.kind!==`pinned`)return;let r=n.items,i=n.endLine+1===t.loc.start.line,a=r.every(Fi);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=qi(o,a);if(e)for(let t of e)V(n,o,t)}}if(e(i)||t(i)||r(i)){let e=Hi(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(zi(i)&&e(n)){let e=Gi(n,i);if(e){let t=Ui(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=P(t.items).loc.end),V(n,i,a,e.items),H(n);return}}}V(n,i,a)}function Ji(t,n,r,i){let s=!1;if(zi(n)&&e(t)){let e=Gi(t,n);if(e){let c=Ui(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:w(r.loc.start),end:w(r.loc.end)}),r.loc.end.line>t&&r.loc.end.line>r.loc.start.line&&_.push({node:r,start:w(r.loc.start),end:w(r.loc.end),endOnly:!0}),u(r)){let e=r.item;if(i){let t=a(e)?e:void 0;_.push({node:e,start:w(e.loc.start),end:w(e.loc.end),equals:t?t.equals:void 0}),t&&(_.push({node:t.key,start:w(t.key.loc.start),end:w(t.key.loc.end)}),_.push({node:t.value,start:w(t.value.loc.start),end:w(t.value.loc.end)}))}e.loc.end.line>t&&e.loc.end.line>e.loc.start.line&&_.push({node:e,start:w(e.loc.start),end:w(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=w(r.loc.start),h=w(r.loc.end),u(r)&&(g=w(r.item.loc.end)),v(u(r)?r.item:r,m.line),n.length&&(r.loc.start=w(t.items[0].loc.start),r.loc.end=w(P(t.items).loc.end))),n.length){f.push({owner:t.member,ownerOriginalStart:w(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),b=y===n.items.length-1,x=y>0?n.items[y-1]:void 0,S=i===0&&y>0&&r.loc.end.line>r.loc.start.line&&x!==void 0&&x.loc.start.line===r.loc.start.line;V(t,n,r,e.items);let C=!1;if(b&&x!==void 0&&r.loc.end.line>r.loc.start.line&&!er(n)&&z(t).get(x)&&(z(t).delete(x),C=!0),H(t),B(t,n,r,i,void 0,e.items),C){let e=z(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||S){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=w(T.loc.end);T.loc.end={line:n.line,column:n.column-1};let r=Wi(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)&&Rn(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],b=y.loc.start.column-c.loc.start.column-1;b!==g&&U(y,{lines:0,columns:g-b});let x=v[v.length-1];c.loc.end.column-1-x.loc.end.column!==_&&(c.loc.end.column=x.loc.end.column+1+_)}function Yi(e){let n=[];for(let i of e){if(i.kind===`pinned`){n.push({kind:`pinned`,isSection:!1,movable:!1,groups:[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.groups.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,groups:[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 Xi(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 Zi(e){return[...e.path,e.key].join(`.`)}function Qi(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 $i(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=Qi(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 ea(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 ta(t,n,r,i,o){let s=Yi(Hi(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(`"${Zi(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=Xi(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),Zn(t)}function na(e,t,n){if(t.length===0)return;Ki(e);let r=[],i=new Map;for(let o of t){var a;if(o.key===void 0)continue;let t=$i(e,o.path,o.key,n);if(!t){if(ea(e,o,n))continue;r.push(`"${Zi(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())ta(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
+ `))}Zn(e)}const ra=new WeakMap,ia=new WeakMap;function aa(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 oa(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(!f(e[r]))return r}function sa(e,t,n){ia.has(e)||ia.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 ca(e,t){ia.set(t,t.loc.start.column),ra.set(t,t.loc.start.column-e.loc.end.column)}function la(e,t,n,r){if(!p(e))return;let i=e.items,a=i.indexOf(t);if(a<0)return;let o=aa(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=[oa(i,a,-1),oa(i,a,1)],u;for(let e of l){if(e==null)continue;let t=aa(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=b(n.loc),f=b(r.loc).columns-d.columns;sa(o,u,f)}function ua(e,t,n){if(!p(e))return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=aa(r,i);if(!a)return;let o=a.loc.start.column,s=a.loc.start.line,c=[oa(r,i,-1),oa(r,i,1)];for(let e of c){if(e==null)continue;let t=aa(r,e);if(t&&Math.abs(t.loc.start.line-s)===1&&t.loc.start.column===o){sa(a,t.loc.start.column,n);return}}}function da(e,t,n){if(!p(e)||n===0)return;let r=e.items,i=r.indexOf(t);if(i<0)return;let a=aa(r,i);a&&ca(t,a)}function fa(e,t,n){if(!l(e)&&!d(e))return 0;let r=b(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 pa(e,n=[]){for(let i of e.items){if(f(i)){n.push(i);continue}(t(i)||r(i))&&pa(i,n)}return n}function ma(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))&&ma(i,n)}return n}function ha(e){for(let n of e.items)(t(n)||r(n))&&ha(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 ga(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=ma(e),l=(e,t)=>{let n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},u=pa(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=ia.get(e[0])??e[0].loc.start.column,n=new Map;for(let t of e){let e=ia.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=>ra.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(ra.has(e))return ra.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 ha(e),s.join(r)+a}function _a(e,t,n){let r=A(),i=Array.from(tt(Ut(e),r)),a=L(n,R.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)(Ca(i,t,a,n instanceof R||n!=null&&Object.prototype.hasOwnProperty.call(n,`indentWidth`),n instanceof R||n!=null&&Object.prototype.hasOwnProperty.call(n,`trailingComma`)).tomlString)}function va(e,t,n){let r=e.slice(n),i=0,a=Math.min(r.length,t.length);for(let e=1;e<=a;e++)I(r.slice(r.length-e),t.slice(0,e))&&(i=e);return i}function ya(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&&I(s.slice(0,-1),i)&&s[s.length-1]===n)return t}}function ba(e){let t=new WeakSet,n=e=>{t.add(e)};return Bt(e,{Document:n,Table:n,TableKey:n,TableArray:n,TableArrayKey:n,KeyValue:n,Key:n,String:n,Integer:n,Float:n,Boolean:n,DateTime:n,InlineArray:n,InlineItem:n,InlineTable:n,Comment:n}),t}function xa(e,t,n,r){if(!F(t))return t;let i=q(K(e,L({...n,inlineTableStart:0},n)).items,``,{temporal:r});if(!F(i))return t;let a={};for(let e of Object.keys(i))Object.prototype.hasOwnProperty.call(t,e)&&(a[e]=t[e]);for(let e of Object.keys(t))Object.prototype.hasOwnProperty.call(a,e)||(a[e]=t[e]);return a}function Sa(e){let n=e.items;for(let e=0;e<n.length;e++){let i=n[e];if(!((t(i)||r(i))&&p(i)))continue;let a=i.items,o=a.length;for(;o>0&&f(a[o-1]);)o--;if(o<a.length){let t=n[e+1];if(t&&r(t)){let e=i.key.item.value,r=t.key.item.value;if(I(e,r.slice(0,e.length))){let e=a.splice(o),r=n.indexOf(t);for(let t of[...e].reverse())n.splice(r,0,t);Zn(i)}}}}}function Ca(e,t,n,r=!1,i=!0){let a=[...e];t=Ea(t);let o=Ta(t),s=1,c=0;for(let e of a){let t=e.loc.end;(t.line>s||t.line===s&&t.column>c)&&(s=t.line,c=t.column)}let l=q(a,``,{temporal:o}),u={type:`Document`,loc:{start:{line:1,column:0},end:{line:s,column:c}},items:a};An(u,n.indentWidth);let d=n.inlineTableStart!=null&&n.inlineTableStart>1?1:n.inlineTableStart,f=L({...n,inlineTableStart:d},n),p=K(t,f),m=q(p.items,``,{temporal:o}),h=n.updateOrder?xa(t,m,f,o):m;if(!n.updateOrder&&wa(l,h))return{tomlString:ri(a,n),document:u};let g=Da(Oa(u,h,Si(l,h,[],{updateOrder:n.updateOrder,orderSource:t})));if(g.length===0)return{tomlString:ri(a,n),document:u};let _=Fa(u,p,g,n,o,ba(u),t,r,i);return{tomlString:ga(_,ii(_.items,n),n),document:_}}function wa(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 Ta(e,t=new WeakSet){return typeof e!=`object`||!e?!1:Et(e)?!0:!t.has(e)&&(t.add(e),Object.values(e).some(e=>Ta(e,t)))}function Ea(e){if(Array.isArray(e)){let t=!1,n=[];for(let r=0;r<e.length;r++){if(!Object.prototype.hasOwnProperty.call(e,r)){t=!0;continue}let i=Ea(e[r]);t||=i!==e[r],n.push(i)}return t?n:e}if(!F(e))return e;let t=e;for(let n of Object.keys(e)){let r=Ea(e[n]);r!==e[n]&&(t===e&&(t={...e}),t[n]=r)}return t}function Da(e){for(let t=0;t<e.length;t++){let n=e[t];if(Y(n)){let r=P(n.path),i=n.path.slice(0,-1),a=t+1;for(;a<e.length;){let o=e[a];if(J(o)){if(typeof P(o.path)==`number`&&I(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`&&I(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(bi(o)&&o.key===void 0){if(I(i,o.path))break;a++;continue}if(!Y(o)){a++;continue}let s=P(o.path),c=o.path.slice(0,-1);if(typeof r==`number`&&typeof s==`number`&&I(i,c)&&s>r){e.splice(a,1),e.splice(t,0,o),t=-1;break}a++}}}return e}function Oa(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 P(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))&&I(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=>P(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)||!yi(t)&&!J(t)&&!Y(t)||typeof P(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=>F(e)))continue;let a=n.filter(t=>!i.has(t)&&(yi(t)||J(t)||Y(t))&&t.path.length>e.length&&I(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 ka(e,t){return t.map(t=>k.test(t)?t:`"${lr(t,e,`singleline-basic`)}"`).join(`.`)}function Aa(e){let t=[],n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(n){n===`"`&&r?r=!1:n===`"`&&a===`\\`?r=!0:a===n&&(n=void 0);continue}if(a===`"`||a===`'`){n=a;continue}if(a!==`.`)continue;let o=i;for(;o>0&&(e[o-1]===` `||e[o-1]===` `);)o--;let s=i+1;for(;s<e.length&&(e[s]===` `||e[s]===` `);)s++;t.push(e.slice(o,s))}return t}function ja(e){let t=[],n=0,r,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(r){r===`"`&&i?i=!1:r===`"`&&o===`\\`?i=!0:o===r&&(r=void 0);continue}o===`"`||o===`'`?r=o:o===`.`&&(t.push(e.slice(n,a)),n=a+1)}return t.push(e.slice(n)),t}function Ma(e,t){let n=Aa(t);n.length!==0&&(e.raw=ja(e.raw).reduce((e,t,r)=>r===0?t:`${e}${n[Math.min(r-1,n.length-1)]}${t}`,``),e.loc.end.column=e.loc.start.column+e.raw.length)}function Na(e,t){let n;return Bt(e,{KeyValue:e=>{!n&&e.key.value.length>t.length&&I(e.key.value.slice(0,t.length),t)&&Aa(e.key.raw).length>0&&(n=e)}}),n}function Pa(e,t){if(o(e)&&o(t)){let n=vr(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(Et(r)){let e=Dt(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(!(Ae.IS_TIME_ONLY.test(n)&&r instanceof Date&&r.getUTCFullYear()>1)){let e=Ae.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=Mr(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 Fa(n,i,s,c,h=!1,g=new WeakSet,_=void 0,v=!1,y=!0){let x=new Map,S=new Set;function C(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&&S.add(e)}}let w=new WeakMap;function T(e){let i=w.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=Ft(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&&w.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||!I(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&&I(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&&I(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=Xa(n,c);r!==void 0&&e.push(mr(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=fr(e.key.item.value);for(let e of n)B(i,i,e);return H(i),i}function ee(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=>k.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),Wn(n,i,r,e),za(n,e)}function te(e,t){let n=e.key.item,r=n.raw,i=t.concat(n.value),a=i.map(e=>k.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 ne(e,t,r,i){te(e,t),Wn(n,i,r,e)}function j(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(_!==void 0){let e=_;for(let t of r)e=e==null?void 0:e[t];if(e!==void 0){let n=Xa(e,c);if(n!==void 0)return mr([...o,...t.key.value],n)}}let s=t.key,l=[...o,...s.value].map(e=>k.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,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,re=new Set,ie=new WeakMap;function ae(e,t){return ie.get(e)??t}let oe=[],se=new Set,ce=[];function le(e,t,r){if(!l(e)&&!d(e)||!u(r)||d(e)&&!a(r.item))return r;let i=_;for(let e of t)i=i==null?void 0:i[e];if(!Array.isArray(i)&&!F(i))return r;let o=wn(n,e)??0,s=er(e)||e.items.length===0&&e.loc.end.line>e.loc.start.line,f=v?c.indentWidth:l(e)&&e.items.length===0?Math.max(c.indentWidth,4):c.indentWidth;l(e)&&e.items.length===0&&!c.useTabsForIndentation&&jn(e,Math.max(f,4));let p=Array.isArray(i)?`array`:`table`,m=e.items.map(t=>d(e)&&a(t.item)?t.item.value:t.item).find(e=>p===`array`?l(e):d(e)),h=m&&p===`array`?Mr(m):m&&p===`table`?Nr(m):!1,g=m,b=g&&g.items.length>0?g.items[0].loc.start.column-g.loc.start.column>1:void 0,x=fn(p,o+1,s,c),S=p===`array`?`multilineArray`:`multilineTable`,C=L({...c,inlineTableStart:0,[S]:x,trailingComma:y?c.trailingComma:h,bracketSpacing:b??c.bracketSpacing,indentWidth:f},c),w=K({tmp:i},C,o+1,s).items[0];if(!w||!a(w))return r;let T=w.value;if(x&&(l(T)||d(T))){let e=T.loc.start.column;T.loc.start.column=0,T.loc.end.line===T.loc.start.line?T.loc.end.column-=e:fn(l(T)?`array`:`table`,o+1,s,C)&&(T.loc.end.column=1)}if(d(e)){let e=G(mr(r.item.key.value,T));return e.comma=r.comma,e}let E=G(T);return e.items.length===0&&l(e)&&d(T)&&(E.comma=!0),E}function ue(e,t,r){let i=u(t)?t.item:t;if(!l(i)&&!d(i))return t;let o=_;for(let e of r)o=o==null?void 0:o[e];if(!Array.isArray(o)&&!F(o))return t;let s=Tn(n,e),f=s?wn(n,s)??0:-1,p=s?er(s)||s.items.length===0&&s.loc.end.line>s.loc.start.line:!1,m=Array.isArray(o)?`array`:`table`,h=m===`array`?c.multilineArray:c.multilineTable,g=fn(m,f+1,p,c),v=u(e)?e.item:e,b=l(v)||d(v)?v:void 0,x=l(v)?`array`:d(v)?`table`:void 0,S=b!==void 0&&x!==m&&Cn(b)&&h===`auto`;if(!(g||S))return t;let C=m===`array`?`multilineArray`:`multilineTable`,w=L({...c,inlineTableStart:0,[C]:!0,trailingComma:y?c.trailingComma:!1},c),T=K({tmp:o},w,f+1,p).items[0];if(!T||!a(T))return t;let E=T.value;if(l(E)||d(E)){let t=u(e)?e.item.loc.start.column:e.loc.start.column;E.loc.end.line===E.loc.start.line?E.loc.end.column+=t-E.loc.start.column:E.loc.end.column=1,E.loc.start.column=t}if(u(t)){let e=G(E);return e.comma=t.comma,e}return E}s.forEach(s=>{if(J(s)){var v;let o=X(i,s.path),m=s.path.slice(0,-1),g=P(s.path),_=r(o);if(bt(g)&&!_&&!bt(P(m))){let e=Z(n,m.concat(0));e&&r(e)&&(_=!0)}if(_&&bt(g)&&!bt(P(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 s.path)e=e==null?void 0:e[t];let r=L({...c,inlineTableStart:0},c),l=e===void 0?void 0:K({tmp:e},r),f=l==null?void 0:l.items[0];if(f&&a(f)&&(o=G(f.value),_=!1,u(o)&&d(o.item)&&o.item.items.length>0)){let e=o.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&&Qn(n,e,!0)}}}}if(_&&!r(o)){let e=m.filter(e=>typeof e==`string`),n=q(i.items,``,{temporal:h});for(let e of s.path)n=n==null?void 0:n[e];if(n!==void 0){let i=fr(e),a=K(n,c);for(let e of a.items)B(i,i,e,void 0);let s=n=>{if(p(n))for(let i of n.items){if(!t(i)&&!r(i))continue;let n=i.key,a=n.item,o=e.concat(a.value);a.value=o,a.raw=_r(o).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,s(i)}};s(i),H(i),o=i}}let y;if(t(o))y=n;else if(_){y=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&&I(s.slice(0,n.length),n)&&(a=i)}g=a+1,r(o)&&(o=O(o,i))}}else g=e.items.length}else{y=n;for(let e=s.path.length-1;e>=0;e--){let t=Z(n,s.path.slice(0,e));if(t&&!E(t,s.path.slice(0,e))){y=t;break}}a(y)?y=y.value:u(y)&&a(y.item)?y=y.item.value:(u(y)&&d(y.item)||u(y)&&l(y.item))&&(y=y.item)}if((l(y)||d(y))&&(o=le(y,s.path,o),Yr(y,o,c.indentWidth)),l(y)){let e=Z(n,m),t=Z(n,m.slice(0,-1));if(e&&a(e)&&t){let n=fa(y,o,g);n!==0&&ua(t,e,n)}}let b=(l(y)||d(y))&&y.loc.end.line>y.loc.start.line;b&&re.has(y)&&H(n);let x=l(y)||d(y)?(v=Gi(n,y))==null?void 0:v.items:void 0;if(r(y)||l(y)||e(y)){if(l(y)){let e=ae(y,Mr(y));if(u(o)){let t=y.items.length===0&&d(o.item)&&er(o.item);o.comma=t||e;let n=o,r=d(n.item)?n.item:void 0,l=r&&r.items.length>0?y.items.map(e=>e.item).find(e=>e!==n.item&&d(e)):void 0;if(r&&l){let e=Nr(l);if(e!==Nr(r)){let t=q(i.items,``,{temporal:h});for(let e of s.path)t=t==null?void 0:t[e];let r=L({...c,inlineTableStart:0,trailingComma:e},c),l=t===void 0?void 0:K({tmp:t},r).items[0];if(l&&a(l)){let e=G(l.value);e.comma=n.comma,o=e}}}}}if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&e(y)&&t(o)){let e=Ja(o,n,c);B(n,y,o,g);for(let t of e)B(n,n,t,void 0)}else{let i=o;u(o)&&(r(y)||e(y))&&(i=o.item);let c=g;if(e(y)&&a(i)){let e=y.items.findIndex(e=>t(e)||r(e));e!==-1&&(c=e)}let d=!1;if((r(y)||e(y))&&a(i)){let e=j(m,i,s.path);e&&(M.has(y)&&H(n),i=e,d=!0)}if(l(y)&&y.items.length===0&&H(n),c===0&&l(y)&&Hn(n).has(y)&&H(n),c===0&&(e(y)||t(y)||r(y))&&Hn(n).has(y)&&H(n),a(i)&&i.key.value.length>1){let e=Na(n,i.key.value.slice(0,-1));if(e){let t=i.equals;Ma(i.key,e.key.raw),i.equals=i.key.loc.end.column+e.equals-e.key.loc.end.column;let n=i.equals-t;U(i.value,{lines:0,columns:n},{first_line_only:!0}),i.loc.end.line===i.loc.start.line&&(i.loc.end.column+=n)}}B(n,y,i,c,void 0,x),d&&M.add(y)}}else if(d(y)){y.items.length===0&&(H(n),In(y)&&y.loc.end.line>y.loc.start.line&&(y.loc.end.line=y.loc.start.line));let e=ae(y,Nr(y));if(a(o)){let t=G(o);t.comma=e;let r=ya(y,o,s.before);B(n,y,t,r,void 0,x)}else if(u(o)&&a(o.item)){let t=o.item,r=j(m,t,s.path);r&&(M.has(y)&&H(n),t=r);let i=G(t);i.comma=e;let a=ya(y,t,s.before);B(n,y,i,a,void 0,x),r&&M.add(y)}else B(n,y,o,void 0,void 0,x)}else if(c.inlineTableStart!==void 0&&c.inlineTableStart>0&&a(o)&&d(o.value)&&t(y))Ur([...y.key.item.value,...o.key.value])<c.inlineTableStart?Ya(o,y,n,c):B(n,y,o);else if(c.inlineTableStart===0&&a(o)&&d(o.value)&&e(y))B(n,y,o,void 0,!0);else{let i=o;u(o)&&(t(y)||r(y)||e(y))&&(i=o.item);let c=!1;if(t(y)&&a(i)){let e=j(m,i,s.path);e&&(M.has(y)&&H(n),i=e,c=!0)}let l=(t(y)||r(y))&&y.items.length>0&&y.items.every(f)?2:void 0;B(n,y,i,void 0,void 0,void 0,l),c&&M.add(y)}b&&re.add(y)}else if(yi(s)){let f=Z(n,s.path),m;try{m=X(i,s.path)}catch{m=void 0}if(!f||!m){Va(n,i,s,c,h,g,S);return}if(a(f)&&t(m)){let e=m.key.item.value;if($(n,e).some(e=>e!==f)){Va(n,i,s,c,h,g,S);return}}if(u(f)&&(t(m)||r(m))){let e=Z(n,s.path.slice(0,-1)),t=e&&a(e)?e.value:e;if(t&&l(t)){let e=_;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=L({...c,inlineTableStart:0},c),n=K({tmp:e},t),r=n==null?void 0:n.items[0];r&&a(r)&&(m=G(r.value))}}}let v,y=Z(n,s.path.slice(0,-1));y&&a(y)&&E(y,s.path.slice(0,-1))&&(y=ee(n,y));let x=Za(n,s.path);if(a(f)&&a(m)){let i=!1;if(f.key.value.length>1){let o=T(f),c=va(s.path,f.key.value,o?o.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=_r(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(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===f)continue;let s=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=u.length&&I(s.slice(0,u.length),u)&&Q(n,y,o)}}}}if(!i&&a(m)&&y&&(t(y)||e(y)||r(y))&&$a(n,y,f.key.value,f),Pa(f.value,m.value),y&&la(y,f,f.value,m.value),v=f,f=f.value,m=m.value,i&&_!==void 0){let e=_;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Xa(e,c);t!==void 0&&(m=t,Pa(f,m))}}}else if(a(f)&&u(m)&&a(m.item)){let i=!1;if(f.key.value.length>1){let o=T(f),c=va(s.path,f.key.value,o?o.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=_r(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(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===f)continue;let s=a(o)?o.key.value:t(o)||r(o)?o.key.item.value:void 0;s&&s.length>=u.length&&I(s.slice(0,u.length),u)&&Q(n,y,o)}}}}if(!i&&a(m.item)&&y&&(t(y)||e(y)||r(y))&&$a(n,y,f.key.value,f),v=f,f=f.value,m=m.item.value,i&&_!==void 0){let e=_;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Xa(e,c);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 o=T(e),c=va(s.path,e.key.value,o?o.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=_r(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&&Rn(n,e,{lines:0,columns:l}),i=!0;let d=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===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&&I(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(Pa(e.value,m.value),v=e,f=e.value,m=m.value,i&&_!==void 0){let e=_;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Xa(e,c);t!==void 0&&(m=t,Pa(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 o=T(i),c=va(s.path,i.key.value,o?o.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=_r(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&&Rn(n,i,{lines:0,columns:l}),e=!0;let d=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===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&&I(s.slice(0,d.length),d)&&Q(n,m,o)}}}}if(Pa(i.value,m.item.value),v=i,f=i.value,m=m.item.value,e&&_!==void 0){let e=_;for(let t of s.path)e=e==null?void 0:e[t];if(e!==void 0){let t=Xa(e,c);t!==void 0&&(m=t,Pa(f,m))}}}else if(t(f)){let o=q(i.items,``,{temporal:h});for(let e of s.path)o=o==null?void 0:o[e];if(o!==void 0){let i=f.key.item.value,l=i.slice(-1),u=i.slice(0,-1),d=ee(n,f)??ki(n,s.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=K({[l[0]]:o},c),m=p.items[0];if(u.length>0){if(t(m)||r(m))ne(m,u,f,d),g.add(m);else if($(n,u).some(a))A(m,u,f,d),g.add(m);else{let e=n.items.find(e=>e!==f&&(t(e)||r(e))&&I(e.key.item.value,u));if(e)B(n,e,m,void 0),Q(n,d,f),g.add(m);else{let e=W(u);S.add(e),B(n,e,m,0),Wn(n,d,f,e),g.add(e)}}}else Wn(n,d,f,m),g.add(m),za(n,m);if(p.items.length>1)for(let e=1;e<p.items.length;e++){let t=p.items[e];u.length>0&&te(t,u);let r=e===1?m:p.items[e-1];B(n,d,t,d.items.indexOf(r)+1),g.add(t)}return}v=ki(n,s.path)}else if(r(f)){let o=q(i.items,``,{temporal:h}),l=f.key.item.value,u=o,d=typeof s.path[s.path.length-1]==`number`?s.path.slice(0,-1):s.path;for(let e of d)u=u==null?void 0:u[e];if(u!==void 0){let i=l.slice(-1),o=l.slice(0,-1),d=ee(n,f)??ki(n,s.path),p=K({[i[0]]:u},c).items[0];if(Array.isArray(u)&&!u.every(e=>F(e))){let e=$(n,l).filter(e=>e!==f&&(t(e)||r(e)));for(let t of e)Q(n,n,t)}if(o.length>0){if(t(p)||r(p))ne(p,o,f,d),g.add(p);else{let r=e(d)?d.items.find(e=>t(e)&&I(e.key.item.value,o)):void 0;if(r){let e=r.items.find(e=>a(e)&&I(e.key.value,p.key.value));e?Wn(n,r,e,p):B(n,r,p,void 0),Q(n,d,f),g.add(r);return}if($(n,o).some(a))A(p,o,f,d),g.add(p);else{let e=W(o);S.add(e),B(n,e,p,0),Wn(n,d,f,e),g.add(e)}}}else Wn(n,d,f,p),g.add(p),za(n,p);return}v=ki(n,s.path)}else if(v=ki(n,s.path),a(v)){let e=X(n,s.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)&&(o(f.item)&&o(m.item)&&(Pa(f.item,m.item),m.loc={start:{...m.item.loc.start},end:{...m.item.loc.end}}),m.comma=f.comma),x){let e=b(f.loc),t=b(m.loc).columns-e.columns;t!==0&&da(x.container,x.row,t)}m=ue(f,m,s.path),Wn(n,v,f,m),l(m)&&se.add(m),(l(m)||d(m))&&(H(n),Vr(m,c.indentWidth),ce.push({owner:v,container:m})),e(v)&&a(f)&&(t(m)||r(m))&&Ba(n,m)}else if(Y(s)){let o=Z(n,s.path);if(o){let f=ki(n,s.path);if(f===o&&(f=ki(n,s.path.slice(0,-1))),f===o){let e=Gi(n,o);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(o))&&(f=ee(n,o)??(p(f)?n:Gi(n,o)??n));let h=!1;if(s.path.length>1&&t(o)&&_!==void 0){let e=s.path.slice(0,-1),t=o.key.item.value.slice(0,-1);if($(n,t).filter(e=>e!==o).length===0){let r=_;for(let t of e)r=r==null?void 0:r[t];if(F(r)&&Object.keys(r).length===0){let e=o;for(;e.items.length>0;)V(n,e,P(e.items));H(n);let r=e.key,i=m(r)?r.item:r;i.value=t,i.raw=ka(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,C(e),h=!0}}}let g=e(f)&&p(f)?f.items.indexOf(o):-1,v=p(f)&&!e(f)?f.items.indexOf(o):-1,y=u(o)?o.comma:void 0;u(o)&&(l(f)||d(f))&&jn(f,o.loc.start.column),u(o)&&(l(f)||d(f))&&v===f.items.length-1&&y!==void 0&&ie.set(f,y);let b=u(o)&&(l(f)||d(f))&&o.loc.end.line===f.loc.end.line?f.loc.end.column-o.loc.end.column:void 0,w=T(u(o)&&a(o.item)?o.item:o),E=a(o)?o:u(o)&&a(o.item)?o.item:void 0;if(E&&w&&p(f)){let e=w.length-E.key.value.length,i=s.path.slice(e);if(i.length>0&&i.length<E.key.value.length){let e=f.items,s=[];for(let n of e){if(n===o)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&&I(e.slice(0,i.length),i)&&s.push(n)}for(let e of s)Q(n,f,e)}}if(E&&w&&p(f)){let e=E.key.value,i=f.items,s=[];for(let n of i){if(n===o)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&&I(i.slice(0,e.length),e)&&s.push(n)}for(let e of s)Q(n,f,e)}if((t(o)||r(o))&&p(f)){let e=o.key.item.value,i=f.items,s=[];for(let n of i){if(n===o)continue;let i=a(n)?n.key.value:t(n)||r(n)?n.key.item.value:void 0;i&&i.length>e.length&&I(i.slice(0,e.length),e)&&s.push(n)}for(let e of s)Q(n,f,e)}if(h||Q(n,f,o),u(o)&&(l(f)||d(f))&&o.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&&P(e).loc.end.line===f.loc.end.line;if(e.length>0&&v===e.length&&t){let t=b??f.loc.end.column-o.loc.end.column;H(n);let r=P(e).loc.end.column+t;f.loc.end.column!==r&&(f.loc.end.column=r);let i,s=e=>{if(a(e))return e.value===f?e:s(e.value);if(u(e))return s(e.item);if(p(e))for(let t of e.items){let e=s(u(t)?t.item:t);if(e)return e}};if(i=s(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&&(Rn(n,t,{lines:0,columns:e}),zn(n),H(n))}}}}if(!h&&s.path.length>1&&(t(o)||r(o))&&_!==void 0){let e=s.path.slice(0,-1),t=o.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(F(r)&&Object.keys(r).length===0){let e=W(t);S.add(e);let r=g>=0?Math.min(g,n.items.length):n.items.length;H(n),B(n,n,e,r)}}}if(!h&&s.path.length>1&&_!==void 0){let i=a(o)?o:u(o)&&a(o.item)?o.item:void 0;if(i&&i.key.value.length>1){let o=s.path.slice(0,-1),l=e(f)||t(f)||r(f)||d(f)?f:n;if(p(l)){let s;if(t(l)||r(l)){let e=l.key.item.value,t=0,n=0;for(let r=0;r<e.length&&t<o.length;r++){for(;t<o.length&&typeof o[t]==`number`;)t++;if(t>=o.length||o[t]!==e[r])break;n++,t++}for(;t<o.length&&typeof o[t]==`number`;)t++;s=n===e.length?o.slice(t):o.slice(e.length+ +!!r(l))}else if(d(l)){if(w){let e=w.slice(0,w.length-i.key.value.length),t=0,n=0;for(;n<e.length&&t<o.length;){for(;t<o.length&&typeof o[t]==`number`;)t++;if(t>=o.length||o[t]!==e[n])break;n++,t++}for(;t<o.length&&typeof o[t]==`number`;)t++;s=n===e.length?o.slice(t):o.slice(e.length)}else s=o.slice(o.length-(i.key.value.length-1))}else s=o;s=s.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?I(t.slice(0,s.length),s):!1}),p=r(l),m=[];p&&f.length===0&&(m=$(n,l.key.item.value.concat(s)));let h=s.length===0&&(t(l)||r(l)||d(l));if(f.length===0&&m.length===0&&!h){let r=_;for(let e of o)r=r==null?void 0:r[e];if(F(r)&&Object.keys(r).length===0){if(d(l)){let e=s.map(e=>k.test(e)?e:JSON.stringify(e).replace(/\x7f/g,`\\u007f`)).join(`.`),t=Array.from(tt(`${e} = {}`))[0];if(a(t)){let e=G(t);e.comma=y??!1,H(n),In(l)&&l.loc.end.line>l.loc.start.line&&(l.loc.end.line=l.loc.start.line),B(n,l,e,v>=0?v:void 0),c.bracketSpacing&&U(e,{lines:0,columns:1});let r=l.items[v+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=W(p||t(l)?l.key.item.value.concat(s):s);S.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=La(n);i=e>=0?e:n.items.length}H(n),B(n,n,r,i)}}}}}if(r(o)){let e=o.key.item.value,t=s.path.slice(0,-1);!Z(n,t.concat(0))&&Z(i,t)&&x.set(e.join(`.`),e)}}else{let e=()=>Z(n,s.path.concat(0))||$(n,s.path).filter(r)[0],a=e();if(a){let o=n.items.indexOf(a),c=!1;if(s.path.length>1&&_!==void 0){let e=s.path.slice(0,-1);if($(n,e).filter(e=>!(r(e)&&I(e.key.item.value,s.path))).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(F(t)&&Object.keys(t).length===0){let t=a,r=t.key;for(;t.items.length>0;)Q(n,t,P(t.items));H(n),t.type=`Table`,r.type=`TableKey`;let i=m(r)?r.item:r;i.value=e,i.raw=ka(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,C(t),c=!0}}}let l;for(;l=e();)Q(n,n,l);for(let e of $(n,s.path).filter(t))Q(n,n,e);if(Z(i,s.path)){let e=s.path;x.set(e.join(`.`),e)}if(!c&&s.path.length>1&&_!==void 0){let e=s.path.slice(0,-1);if($(n,e).length===0){let t=_;for(let n of e)t=t==null?void 0:t[n];if(F(t)&&Object.keys(t).length===0){let t=W(e);S.add(t);let r=o>=0?Math.min(o,n.items.length):n.items.length;H(n),B(n,n,t,r)}}}}else{let e=Qa(n,s.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 s.path.slice(0,-1))e=e==null?void 0:e[t];if(F(e)&&Object.keys(e).length===0){let e=W(t);S.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,s.path)}}}else if(bi(s)){if(s.key!==void 0){oe.push(s);return}let e=Z(n,s.path);if(e){if(m(e)&&(e=e.item),a(e)&&(e=e.value),s.from>=e.items.length)return;let t=e.items[s.from];Ji(n,e,t,s.to)}else{Sa(n);let e=X(n,s.path.concat(s.from)),i=Hi(n).find(t=>t.member===e),a=i?[...i.items]:[e],o=a.map(e=>({startLine:e.loc.start.line,endLine:e.loc.end.line})),c=n.items.indexOf(i?i.items[0]:e),l=o[o.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=o[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,s.path.concat(s.to)),m,h=!1,g=i&&i.items[0]!==e&&f(i.items[0]);if(p){let e=Hi(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],s;if((y||g&&m>0&&m<n.items.length)&&b>0){let n=e===0?_:o[e-1].endLine,a=e===0&&v!==void 0?v-_:o[e].startLine-n;a!==(t(i)||r(i)?2:1)&&(s=a)}B(n,n,i,b,void 0,void 0,s),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(xi(s)){let e=s.path.concat(s.from),o=Z(n,e);if(!o){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,a=n.raw;n.value[r]=s.to,n.raw=ka(n.raw,n.value),Ma(n,a),n.loc.end.column=n.loc.start.column+n.raw.length;return}}o||=X(n,e);let c=X(i,s.path.concat(s.to));m(o)&&(o=o.item),m(c)&&(c=c.item);let l=o.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=s.path.concat(s.from);if((t(o)||r(o))&&a(c)&&I(d.value.slice(0,e.length),e)){let t=e.length-1,n=d.raw;d.value[t]=s.to,d.raw=ka(d.raw,d.value),Ma(d,n),d.loc.end.column=d.loc.start.column+d.raw.length;return}if(a(o)&&a(c)&&d.value.length<=e.length&&I(d.value,e.slice(e.length-d.value.length))){let e=d.raw;d.value[d.value.length-1]=s.to,d.raw=ka(d.raw,d.value),d.loc.end.column=d.loc.start.column+d.raw.length;let t=d.raw.length-e.length;t>0&&(o.equals+=t,U(o.value,{lines:0,columns:t},{first_line_only:!0}),Rn(n,o.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=ka(d.raw,f.value),Ma(f,d.raw),f.loc.end.column=f.loc.start.column+f.raw.length,Wn(n,m(l)?l:o,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)&&S.has(i)){let e=i.loc.start.line-r.loc.end.line-1;e>0&&U(i,{lines:-e,columns:0})}}let de=n.items;for(let e=0;e<de.length-1;e++){let n=de[e],i=de[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<de.length;t++)U(de[t],{lines:n,columns:0})}}}let fe=!1;Bt(n,{InlineTable:e=>{In(e)&&(fe=!0)},InlineArray:e=>{In(e)&&(fe=!0)}}),fe&&H(n);let pe=!1,me=[];if(Bt(n,{InlineTable:e=>{In(e)&&(me.push(e),Ha(e),Ln(e),Qn(n,e,c.bracketSpacing),pe=!0)},InlineArray:e=>{In(e)&&(Ha(e),Ln(e),Qn(n,e,c.bracketSpacing),pe=!0)}}),pe){H(n);for(let e of me)Ua(n,e);Wa(n)}if(Ka(n),qa(n,x,c),na(n,oe,g),oe.length>0&&zn(n),se.size>0){H(n);for(let e of se)Xr(e,c.indentWidth)}if(ce.length>0){H(n);for(let{owner:e,container:t}of ce)Ia(t),zr(t,e.loc.start.column,c.indentWidth,c.bracketSpacing)}return n}function Ia(e){if(delete e.range,p(e))for(let t of e.items)Ia(t);m(e)&&Ia(e.item),a(e)&&(Ia(e.key),Ia(e.value))}function La(e){return e.items.findIndex(e=>t(e)||r(e))}function Ra(e){let t=La(e);return t===-1?void 0:t}function za(e,t){let n=e.items.indexOf(t);if(n<0)return;let r=La(e);r===-1||r>n||(V(e,e,t),H(e),B(e,e,t,r))}function Ba(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 Va(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&&I(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=ri(K(d,o).items,o),m=Array.from(tt(p)),h=t=>{let n=s.items.find(e=>a(e)&&I(e.key.value,t.key.value));n?Wn(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=_r(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=ri(K(p,o).items,o),g=Array.from(tt(h)),_=Ra(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)&&I(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)&&I(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=>k.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=>k.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 Ha(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 Ua(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,_=Ga(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 Wa(e){Bt(e,{InlineTable:{exit:e=>{if(e.items.length===0||e.loc.end.line!==e.loc.start.line)return;let t=e.items[e.items.length-1],n=Ga(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=Ga(t),r=e.loc.end.column,i=n+(r-t.loc.end.column);i!==r&&(e.loc.end.column=i)}}})}function Ga(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 Ka(e){Bt(e,{KeyValue:t=>{let n=t.value;if(!l(n)||n.items.length>0)return;let r=ki(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 qa(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=mr([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=mr(t,K({[t[t.length-1]]:[]},i).items[0].value);H(e),B(e,o,n);continue}}let n=mr(a,K({[a[a.length-1]]:[]},i).items[0].value);H(e),B(e,e,n,Ra(e))}H(e)}}function Ja(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(Ur(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),Hr(e),r.push(n),i(n,r)}}}};return i(e,r),r}function Ya(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),Hr(t);let o=Ja(i,n,r);for(let e of o)B(n,n,e,void 0)}function Xa(e,n){let r=L({...n,inlineTableStart:0},n),i=ri(K({__tmp__:e},r).items,r),o=Array.from(tt(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 Za(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&&I(e.slice(0,n.length),n)&&i.push(o)}return i}function Qa(e,t){let n=[];for(let i of t)typeof i==`number`&&$(e,n).some(r)||n.push(i);return n}function $a(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&&I(u.slice(0,i.length),i)&&Q(e,n,l)}}function eo(e,t){return e.line===t.line?e.column-t.column:e.line-t.line}function to(e,t,n){let r={line:t,column:n},i=[],a=null;for(let t of e){let e=eo(t.loc.end,r)<0,n=eo(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 no=class{_cst;_currentTomlString;_format;_integersAsBigInt;_temporal;constructor(e,t){let n=typeof e==`string`?e:Vt(e),r=Ut(n);this._currentTomlString=r,this._cst=Array.from(tt(r)),this._integersAsBigInt=(t==null?void 0:t.integersAsBigInt)??`asNeeded`,this._temporal=(t==null?void 0:t.temporal)??!1,this._format=R.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:ao(e)}get cst(){return this._cst}patch(e,t){let n=L(t,this._format),r=this._currentTomlString;if(!this._temporal&&ro(e)){let t=q(this._cst,r,{integersAsBigInt:this._integersAsBigInt,temporal:!1});e=io(e,t)}let i=t instanceof R||t!=null&&Object.prototype.hasOwnProperty.call(t,`indentWidth`),a=t instanceof R||t!=null&&Object.prototype.hasOwnProperty.call(t,`trailingComma`),o=Ca(this._cst,e,n,i,a);this._cst=Array.from(tt(o.tomlString)),this._format=n,this._currentTomlString=o.tomlString}update(e){let t=Ut(e);if(t===this._currentTomlString){this._format.leadingBom=Ht(e);return}let n=this._currentTomlString.split(this._format.newLine),r=Qt(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}=to(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(nt(c,p)),this._currentTomlString=t,this._format=R.autoDetectFormatWithCst(e,this._cst)}overwrite(e){let t=Ut(e);if(t===this._currentTomlString){this._format.leadingBom=Ht(e);return}this._cst=Array.from(tt(t)),this._currentTomlString=t,this._format=R.autoDetectFormatWithCst(e,this._cst)}};function ro(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=>ro(e,t)):Object.keys(e).some(n=>ro(e[n],t)))}function io(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=io(e,t[i],n);return a!==e&&(r=!0),a});return r?i:e}if(!F(t))return e;let r=!1,i={};for(let a of Object.keys(e)){let o=e[a],s=io(o,t[a],n);i[a]=s,s!==o&&(r=!0)}return r?i:e}function ao(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(ao);if(e&&typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=ao(r);return t}return e}function oo(e,t){let n=Ut(typeof e==`string`?e:Vt(e));return q(tt(n),n,{integersAsBigInt:(t==null?void 0:t.integersAsBigInt)??`asNeeded`,temporal:(t==null?void 0:t.temporal)??!1})}function so(e,t){let n=L(t,R.default()),r=ri(K(e,n).items,n);return n.leadingBom?`${r}`:r}function co(e,t){return new no(e,t)}export{je as LocalDate,Ne as LocalDateTime,Me as LocalTime,Pe as OffsetDateTime,no as TomlDocument,R as TomlFormat,oo as parse,co as parseDocument,_a as patch,so as stringify};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decimalturn/toml-patch",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "contributors": [
5
5
  "Tim Hall <tim.hall.engr@gmail.com>",
6
6
  "Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "devDependencies": {
46
- "@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@3.0.2",
46
+ "@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@3.1.0",
47
47
  "@js-temporal/polyfill": "^0.5.1",
48
48
  "@playwright/test": "^1.59.1",
49
49
  "@types/dedent": "^0.7.2",
@@ -59,10 +59,10 @@
59
59
  "oxlint": "^1.55.0",
60
60
  "rimraf": "^6.0.0",
61
61
  "smol-toml": "^1.6.1",
62
- "tsdown": "^0.22.13",
62
+ "tsdown": "^0.23.0",
63
63
  "tslib": "^2.0.0",
64
64
  "typescript": "7.0.2",
65
- "vitest": "^4.1.10"
65
+ "vitest": "^5.0.0"
66
66
  },
67
67
  "prettier": {
68
68
  "singleQuote": true,
@@ -91,6 +91,7 @@
91
91
  "specs": "vitest run --config vitest.specs.config.ts",
92
92
  "benchmark": "npm-run-all2 bench:*",
93
93
  "benchmark:ci": "npm-run-all2 \"bench:* -- --sample --versions latest\"",
94
+ "benchmark:smol": "node benchmark/smol-benchmark.mjs",
94
95
  "fuzz": "npx -y tsx scripts/fuzz-run.ts --seed 0 --to 9999 --mutations 3 --progress 100",
95
96
  "seed-toml": "npx -y tsx scripts/generate-seed-toml.ts",
96
97
  "fuzz2": "npx -y tsx scripts/fuzz-run2.ts --seed 0 --to 9999 --mutations 3",