@decimalturn/toml-patch 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.0] - 2026-05-10
11
+
12
+ ### Added
13
+
14
+ - Formatting: Add `leadingBom` option to `TomlFormat` to preserve or add UTF-8 BOM (byte order mark) on output. This option is auto-detected from input strings and maintained through patch, stringify, and document update operations ([#198]).
15
+
16
+ ## [1.2.2] - 2026-05-08
17
+
18
+ ### Fixed
19
+
20
+ - Parsing: Strip leading UTF-8 BOM (byte order mark) from input strings and byte buffers ([#189]).
21
+ - Parsing: Reject disallowed control characters in bare tokens ([#189]).
22
+ - Parsing: Reject Arabic numerals and other Unicode digits in decimal integers ([#187]).
23
+
10
24
  ## [1.2.1] - 2026-05-05
11
25
 
12
26
  ### Fixed
@@ -259,3 +273,7 @@ This first forked version from [timhall/toml-patch](https://github.com/timhall/t
259
273
  [#158]: https://github.com/DecimalTurn/toml-patch/pull/158
260
274
  [#164]: https://github.com/DecimalTurn/toml-patch/pull/164
261
275
  [#165]: https://github.com/DecimalTurn/toml-patch/pull/165
276
+ [#176]: https://github.com/DecimalTurn/toml-patch/pull/176
277
+ [#187]: https://github.com/DecimalTurn/toml-patch/pull/187
278
+ [#189]: https://github.com/DecimalTurn/toml-patch/pull/189
279
+ [#198]: https://github.com/DecimalTurn/toml-patch/pull/198
package/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  [![NPM Version](https://img.shields.io/npm/v/%40decimalturn%2Ftoml-patch?logo=npm&logoColor=white&labelColor=red&color=blue)](https://www.npmjs.com/package/@decimalturn/toml-patch)
4
4
  [![JSR Version](https://img.shields.io/jsr/v/%40decimalturn/toml-patch?logo=jsr&color=blue)](https://jsr.io/@decimalturn/toml-patch)
5
5
  [![GitHub branch status](https://img.shields.io/github/check-runs/DecimalTurn/toml-patch/latest)](https://github.com/DecimalTurn/toml-patch/actions/workflows/test-and-build.yml)
6
+ <img src="assets/toml-patch-logo.png" alt="toml-patch logo" width="120" align="right" />
7
+
8
+
6
9
 
7
10
  Patch, parse, and stringify [TOML](https://toml.io/en/) (v1.1.0) while preserving comments and formatting.
8
11
 
@@ -387,6 +390,7 @@ class TomlFormat {
387
390
  inlineTableStart?: number
388
391
  truncateZeroTimeInDates: boolean
389
392
  minimumDecimals?: number
393
+ leadingBom: boolean
390
394
 
391
395
  static default(): TomlFormat
392
396
  static autoDetectFormat(tomlString: string): TomlFormat
@@ -463,6 +467,11 @@ format.bracketSpacing = true; // [ 1, 2, 3 ] and { x = 1, y = 2 }
463
467
  format.bracketSpacing = false; // [1, 2, 3] and {x = 1, y = 2}
464
468
  ```
465
469
 
470
+ **leadingBom**
471
+ - **Type:** `boolean`
472
+ - **Default:** `false` (auto-detected from input)
473
+ - **Description:** Whether to prepend a UTF-8 BOM (byte order mark, U+FEFF) to the output TOML. This is automatically detected from input strings and maintained through patch and stringify operations.
474
+
466
475
  **inlineTableStart**
467
476
  - **Type:** `number` (optional)
468
477
  - **Default:** `1`
@@ -1,4 +1,4 @@
1
- //! @decimalturn/toml-patch v1.2.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
1
+ //! @decimalturn/toml-patch v1.3.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
2
  declare class TomlFormat {
3
3
  /**
4
4
  * The line ending character(s) to use in the output TOML.
@@ -36,6 +36,12 @@ declare class TomlFormat {
36
36
  * - false: [1, 2, 3] and {x = 1, y = 2}
37
37
  */
38
38
  bracketSpacing: boolean;
39
+ /**
40
+ * Whether the output should include a leading UTF-8 BOM marker (U+FEFF).
41
+ *
42
+ * This is auto-detected from the source TOML and preserved during patching.
43
+ */
44
+ leadingBom: boolean;
39
45
  /**
40
46
  * The nesting depth at which new tables should start being formatted as inline tables.
41
47
  * When adding new tables during patching or stringifying objects:
@@ -80,7 +86,7 @@ declare class TomlFormat {
80
86
  * - 2: stringify({ x: 1, y: 1.5 }) → x = 1.00 / y = 1.50
81
87
  */
82
88
  minimumDecimals?: number;
83
- constructor(newLine?: string, trailingNewline?: number, trailingComma?: boolean, bracketSpacing?: boolean, inlineTableStart?: number, truncateZeroTimeInDates?: boolean, useTabsForIndentation?: boolean, minimumDecimals?: number);
89
+ constructor(newLine?: string, trailingNewline?: number, trailingComma?: boolean, bracketSpacing?: boolean, inlineTableStart?: number, truncateZeroTimeInDates?: boolean, useTabsForIndentation?: boolean, minimumDecimals?: number, leadingBom?: boolean);
84
90
  /**
85
91
  * Creates a new TomlFormat instance with default formatting preferences.
86
92
  *
@@ -89,8 +95,11 @@ declare class TomlFormat {
89
95
  * - trailingNewline: 1
90
96
  * - trailingComma: false
91
97
  * - bracketSpacing: true
98
+ * - leadingBom: false
92
99
  * - inlineTableStart: 1
93
100
  * - truncateZeroTimeInDates: false
101
+ * - useTabsForIndentation: false
102
+ * - minimumDecimals: 0
94
103
  */
95
104
  static default(): TomlFormat;
96
105
  /**
@@ -112,6 +121,18 @@ declare class TomlFormat {
112
121
  * ```
113
122
  */
114
123
  static autoDetectFormat(tomlString: string): TomlFormat;
124
+ /**
125
+ * Internal method: Auto-detects formatting preferences from a TOML string with optional pre-parsed AST.
126
+ *
127
+ * This is used internally to avoid redundant parsing when the AST is already available.
128
+ * External callers should use `autoDetectFormat(tomlString)` instead.
129
+ *
130
+ * @internal
131
+ * @param tomlString - The TOML string to analyze for formatting patterns
132
+ * @param syntaxTree - Optional pre-parsed AST to avoid redundant parsing
133
+ * @returns A new TomlFormat instance with detected formatting preferences
134
+ */
135
+ static autoDetectFormatWithAst(tomlString: string, syntaxTree?: Iterable<any>): TomlFormat;
115
136
  }
116
137
 
117
138
  type IntegersAsBigInt = boolean | 'asNeeded';
@@ -380,7 +401,7 @@ declare class TomlDocument {
380
401
  */
381
402
  update(tomlString: string): void;
382
403
  /**
383
- * Overwrites the internal AST by fully re-parsing the supplied tomlString.
404
+ * Overwrites the internal syntax tree by fully re-parsing the supplied tomlString.
384
405
  * This is simpler but slower than update() which uses incremental parsing.
385
406
  * @param tomlString - The TOML string to overwrite with
386
407
  */
@@ -1,2 +1,2 @@
1
- //! @decimalturn/toml-patch v1.2.1 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
- var e,t;function n(t){return t.type===e.Document}function o(t){return t.type===e.Table}function l(t){return t.type===e.TableArray}function r(t){return t.type===e.KeyValue}function i(t){return t.type===e.String}function s(t){return t.type===e.DateTime}function a(t){return t.type===e.InlineArray}function c(t){return t.type===e.InlineItem}function u(t){return t.type===e.InlineTable}function f(t){return t.type===e.Comment}function m(e){return n(e)||o(e)||l(e)||u(e)||a(e)}function h(t){return function(t){return t.type===e.TableKey}(t)||function(t){return t.type===e.TableArrayKey}(t)||c(t)}function d(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function p(e,t){const n=Array.isArray(e)?e:g(e);if(0===n.length)return{line:1,column:t};let o=0,l=n.length-1;for(;o<l;){const e=o+l>>>1;n[e]<t?o=e+1:l=e}n[o]<t&&o++;const r=o+1;return{line:r,column:t-(n[r-2]+1||0)}}function g(e){const t=[];for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);10===o?t.push(n):13===o&&(10===e.charCodeAt(n+1)?(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 y(e){return{start:w(e.start),end:w(e.end)}}!function(e){e.Document="Document",e.Table="Table",e.TableKey="TableKey",e.TableArray="TableArray",e.TableArrayKey="TableArrayKey",e.KeyValue="KeyValue",e.Key="Key",e.String="String",e.Integer="Integer",e.Float="Float",e.Boolean="Boolean",e.DateTime="DateTime",e.InlineArray="InlineArray",e.InlineItem="InlineItem",e.InlineTable="InlineTable",e.Comment="Comment"}(e||(e={}));class v extends Error{constructor(e,t,n){let o=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){const n=function(e,t){const n=g(e),o=void 0!==n[t.line-2]?n[t.line-2]+1:0,l=n[t.line-1]||e.length;return e.substring(o,l)}(e,t),l=`${function(e,t=" "){return t.repeat(e)}(t.column)}^`;n&&(o+=`${n}\n${l}\n`)}o+=n,super(o),this.line=t.line,this.column=t.column}}!function(e){e.Bracket="Bracket",e.Curly="Curly",e.Equal="Equal",e.Comma="Comma",e.Dot="Dot",e.Comment="Comment",e.Literal="Literal"}(t||(t={}));const b=/^[\w-]+$/,$='"',k="'",T=" ",S=/[\w,\d,",',+,\-,_]/,I=10,E=13,A=127;function*C(e){const n=e.length;let o=0;const l=[],r=(e,t)=>({start:p(l,e),end:p(l,t)});for(;o<n;){const c=e.charCodeAt(o);if((c<=31||c===A)&&9!==c&&c!==E&&c!==I)throw new v(e,p(l,o),`Control char 0x${c.toString(16).toUpperCase().padStart(2,"0")} not allowed`);if(c===E&&(o+1>=n||e.charCodeAt(o+1)!==I))throw new v(e,p(l,o),"Standalone CR; must be CRLF or LF");if(32===c||9===c||c===E);else if(c===I)l.push(o);else if(91===c||93===c)yield{type:t.Bracket,raw:e[o],loc:r(o,o+1)};else if(123===c||125===c)yield{type:t.Curly,raw:e[o],loc:r(o,o+1)};else if(61===c)yield{type:t.Equal,raw:"=",loc:r(o,o+1)};else if(44===c)yield{type:t.Comma,raw:",",loc:r(o,o+1)};else if(46===c)yield{type:t.Dot,raw:".",loc:r(o,o+1)};else if(35===c)yield i();else{const t=x(e,o,k)||x(e,o,$);t?yield s(t):yield a()}o++}function i(){const i=o;for(;o+1<n;){const t=e.charCodeAt(o+1);if(t===I||t===E)break;o++;const n=e.charCodeAt(o);if((n<=31||n===A)&&9!==n)throw new v(e,p(l,o),`Control char 0x${n.toString(16).toUpperCase().padStart(2,"0")} not allowed`)}return{type:t.Comment,raw:e.slice(i,o+1),loc:r(i,o+1)}}function s(i){const s=o,a=i+i+i;for(o+=3;o<n;){if(x(e,o,i)){let t=3;for(;e[o+t]===i;)t++;if(t>=6)throw new v(e,p(l,o),`Invalid multiline string: ${t} consecutive ${i} characters`);if(3===t){o+=2;break}o+=t-3,o+=2;break}const t=e.charCodeAt(o);if(t===E&&(o+1>=n||e.charCodeAt(o+1)!==I))throw new v(e,p(l,o),"Standalone CR in multiline string; must be CRLF or LF");if((t<=31||t===A)&&9!==t&&t!==I&&t!==E){const n=i===$?"multiline basic strings":"multiline literal strings",r=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let s="";0===t?s="Null":t===A&&(s="DEL");const a=s?`${s} (${r}) not allowed in ${n}`:`Control char ${r} not allowed in ${n}`;throw new v(e,p(l,o),a)}t===I&&l.push(o),o++}if(o>=n){if(i===$){let t=0,r=n-1;for(;r>=0&&"\\"===e[r];)t++,r--;if(t>0&&t%2!=0)throw new v(e,p(l,o),`Unterminated multiline ${a} (possible escape issue)`)}throw new v(e,p(l,o),`Unterminated multiline ${a}`)}return{type:t.Literal,raw:e.slice(s,o+1),loc:r(s,o+1)}}function a(){const i=e[o];if(!S.test(i))throw new v(e,p(l,o),`Unexpected char "${i}"`);const s=o;let a=i===$,c=i===k;for(;o<n&&!(o+1>=n);){const t=e.charCodeAt(o+1);if(!(a||c||32!==t&&9!==t&&t!==I&&t!==E&&44!==t&&46!==t&&93!==t&&125!==t&&61!==t&&35!==t))break;if(o++,a||c){const t=e.charCodeAt(o);if((t<=31||t===A)&&9!==t){const n=a?"basic strings":"literal strings",r=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let i="";t===I?i="Newline":t===E?i="Carriage return":0===t?i="Null":t===A&&(i="DEL");const s=i?`${i} (${r}) not allowed in ${n}`:`Control char ${r} not allowed in ${n}`;throw new v(e,p(l,o),s)}}const r=e[o];if(r===$&&(a=!a),r!==k||a||(c=!c),o+1>=n)break;if(a&&"\\"===r){const t=e[o+1];t!==$&&"\\"!==t||o++}}if(a||c)throw new v(e,p(l,s),`Expected close of string with ${a?$:k}`);return{type:t.Literal,raw:e.slice(s,o+1),loc:r(s,o+1)}}}function x(e,t,n){if(!n)return!1;if(!(e[t]===n&&e[t+1]===n&&e[t+2]===n))return!1;if(n===k)return n;let o=0,l=t-1;for(;l>=0&&"\\"===e[l];)o++,l--;if(0===o)return n;return!(o%2!=0)&&n}const _=new Int8Array(128);_.fill(-1);for(let e=0;e<10;e++)_[48+e]=e;for(let e=0;e<6;e++)_[65+e]=10+e,_[97+e]=10+e;function O(e){const t=e.charCodeAt(0);return t<128&&-1!==_[t]}function D(e,t){return _[e.charCodeAt(t)]<<12|_[e.charCodeAt(t+1)]<<8|_[e.charCodeAt(t+2)]<<4|_[e.charCodeAt(t+3)]}function F(e){return e.startsWith("'''")?L(e.slice(3,e.length-3)):e.startsWith(k)?e.slice(1,e.length-1):e.startsWith('"""')?M(L(e.slice(3,e.length-3)),!0):e.startsWith($)?M(e.slice(1,e.length-1),!1):e}function M(e,t){const n=e.length;if(!t&&-1===e.indexOf("\\"))return e;const o=[];let l=0;for(let r=0;r<n;r++){if("\\"!==e[r])continue;if(r>l&&o.push(e.slice(l,r)),r++,r>=n)throw new Error("Trailing backslash");const i=e[r];switch(i){case"b":o.push("\b");break;case"t":o.push("\t");break;case"n":o.push("\n");break;case"f":o.push("\f");break;case"r":o.push("\r");break;case'"':o.push('"');break;case"\\":o.push("\\");break;case"e":o.push("");break;case"u":{if(r+4>n||!O(e[r+1])||!O(e[r+2])||!O(e[r+3])||!O(e[r+4]))throw new Error(`Invalid Unicode escape: \\u${e.slice(r+1,r+5)}`);const t=D(e,r+1);if(t>=55296&&t<=57343)throw new Error(`Invalid \\u${e.slice(r+1,r+5)}: surrogates not allowed`);o.push(String.fromCharCode(t)),r+=4;break}case"U":{if(r+8>n)throw new Error(`Invalid Unicode escape: \\U${e.slice(r+1,r+9)}`);for(let t=1;t<=8;t++)if(!O(e[r+t]))throw new Error(`Invalid Unicode escape: \\U${e.slice(r+1,r+9)}`);const t=parseInt(e.slice(r+1,r+9),16);o.push(String.fromCodePoint(t)),r+=8;break}case"x":{if(r+2>n||!O(e[r+1])||!O(e[r+2]))throw new Error(`Invalid hex escape: \\x${e.slice(r+1,r+3)}`);const t=_[e.charCodeAt(r+1)]<<4|_[e.charCodeAt(r+2)];o.push(String.fromCharCode(t)),r+=2;break}default:if(t&&("\n"===i||"\r"===i||" "===i||"\t"===i)){let t="\n"===i||"\r"===i,o=r;for(;o<n&&(" "===e[o]||"\t"===e[o]||"\n"===e[o]||"\r"===e[o]);)"\n"!==e[o]&&"\r"!==e[o]||(t=!0),o++;if(!t)throw new Error(`Invalid escape sequence: \\${i}`);r=o-1;break}throw new Error(`Invalid escape sequence: \\${i}`)}l=r+1}return 0===l?e:(l<n&&o.push(e.slice(l)),o.join(""))}function L(e){return 10===e.charCodeAt(0)?e.slice(1):13===e.charCodeAt(0)&&10===e.charCodeAt(1)?e.slice(2):e}class N{constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){var e;if(this.done)return K();const t=this.peeked||this.iterator.next();return this.index+=1,this.value=t.value,this.done=null!==(e=t.done)&&void 0!==e&&e,this.peeked=null,t}peek(){return this.done?K():(this.peeked||(this.peeked=this.iterator.next()),this.peeked)}[Symbol.iterator](){return this}}const W=Object.freeze({value:void 0,done:!0});function K(){return W}function U(e){return{year:String(e.getUTCFullYear()).padStart(4,"0"),month:String(e.getUTCMonth()+1).padStart(2,"0"),day:String(e.getUTCDate()).padStart(2,"0"),hours:String(e.getUTCHours()).padStart(2,"0"),minutes:String(e.getUTCMinutes()).padStart(2,"0"),seconds:String(e.getUTCSeconds()).padStart(2,"0"),ms:e.getUTCMilliseconds()}}function j(e,t,n=/\.(\d+)\s*$/){if(t&&t.includes(".")){const o=t.match(n),l=o?o[1].length:3;return"."+String(e).padStart(3,"0").slice(0,l)}return e>0?"."+String(e).padStart(3,"0").replace(/0+$/,""):""}function B(e){if("Z"===e)return 0;const t="+"===e[0]?1:-1,[n,o]=e.slice(1).split(":");return t*(60*parseInt(n)+parseInt(o))}class Z{static createDateWithOriginalFormat(e,t){if(Z.IS_DATE_ONLY.test(t)){if(0!==e.getUTCHours()||0!==e.getUTCMinutes()||0!==e.getUTCSeconds()||0!==e.getUTCMilliseconds()){if(e instanceof R)return e;let t=e.toISOString().replace("Z","");return t=t.replace(/\.000$/,""),new q(t,!1)}const t=e.toISOString().split("T")[0];return new V(t)}if(Z.IS_TIME_ONLY.test(t)){if(e instanceof z)return e;{const n=U(e),o=j(n.ms,t);return new z(`${n.hours}:${n.minutes}:${n.seconds}${o}`,t)}}if(Z.IS_LOCAL_DATETIME_T.test(t)){const n=U(e),o=j(n.ms,t);return new q(`${n.year}-${n.month}-${n.day}T${n.hours}:${n.minutes}:${n.seconds}${o}`,!1,t)}if(Z.IS_LOCAL_DATETIME_SPACE.test(t)){const n=U(e),o=j(n.ms,t);return new q(`${n.year}-${n.month}-${n.day} ${n.hours}:${n.minutes}:${n.seconds}${o}`,!0,t)}if(Z.IS_OFFSET_DATETIME_T.test(t)||Z.IS_OFFSET_DATETIME_SPACE.test(t)){const n=t.match(/([+-]\d{2}:\d{2}|[Zz])$/),o=n?"z"===n[1]?"Z":n[1]:"Z",l=Z.IS_OFFSET_DATETIME_SPACE.test(t),r=U(new Date(e.getTime()+6e4*B(o))),i=l?" ":"T",s=j(r.ms,t,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),a=`${r.year}-${r.month}-${r.day}${i}${r.hours}:${r.minutes}:${r.seconds}${s}${o}`;return new R(a,l)}return e}}Z.IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/,Z.IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,Z.IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,Z.IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/,Z.IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;class V extends Date{constructor(e){super(e)}toISOString(){const e=U(this);return`${e.year}-${e.month}-${e.day}`}}class z extends Date{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(){const e=U(this);return`${e.hours}:${e.minutes}:${e.seconds}${j(e.ms,this.originalFormat)}`}}class q extends Date{constructor(e,t=!1,n){let o=e;/\d{2}:\d{2}:\d{2}/.test(e)||(o=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,"$1:00$2")),super(o.replace(" ","T")+"Z"),this.useSpaceSeparator=!1,this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){const e=U(this),t=this.useSpaceSeparator?" ":"T";return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${j(e.ms,this.originalFormat)}`}}class R extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=e;const o=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);o&&(this.originalOffset="z"===o[1]?"Z":o[1])}toISOString(){if(this.originalOffset){const e=U(new Date(this.getTime()+6e4*B(this.originalOffset))),t=this.useSpaceSeparator?" ":"T",n=j(e.ms,this.originalFormat,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/);return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${n}${this.originalOffset}`}const e=super.toISOString();return this.useSpaceSeparator?e.replace("T"," "):e}}const P=Z,H="true",J=/e/i,Y=/_/g,G=/^[+-]?inf$/,X=/^[+-]?nan$/,Q=/^[+-]?0x/i;function ee(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||95===e||45===e}const te=/^[+-]?0o/i,ne=/^[+-]?0b/i;function oe(e,t,n){for(let o=0;o<e.length;o++)if(!ee(e.charCodeAt(o)))throw new v(t,{line:n.line,column:n.column+o},`Invalid bare key char '${e[o]}'`)}function le(e,t,n){if(e.startsWith('"""')||e.startsWith("'''"))throw new v(t,n,"Multiline strings cannot be keys")}function re(e,t,n){try{return F(e)}catch(e){throw new v(t,n,e.message)}}function ie(e,t,n,o=!0){if(e.endsWith("_"))throw new v(t,n,"Underscore must be between digits");if(o?/^[+-]?_/.test(e):e.startsWith("_"))throw new v(t,n,"Underscore must be between digits");if(/__/.test(e))throw new v(t,n,"Consecutive underscores not allowed")}function se(e,t,n,o){const l=e.replace(Y,"");if(/^[+-]?0\d/.test(l)&&!Q.test(e)&&!te.test(e)&&!ne.test(e))throw new v(t,n,`Leading zeros are not allowed in ${o}`)}function ae(e,t,n,o){if(/_[eE]/.test(e))throw new v(n,o,"Underscore before exponent is not allowed");if(/[eE][+-]?_/.test(e))throw new v(n,o,"Underscore at start of exponent is not allowed");if(/[eE][+-]?$/.test(e))throw new v(n,o,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new v(n,o,`Invalid float "${t}": decimal point not allowed in exponent`)}function ce(e,t,n,o,l,r){if(2!==e.length)throw new v(l,r,`"${o}": hour must be 2 digits`);if(2!==t.length)throw new v(l,r,`"${o}": minute must be 2 digits`);if(n&&2!==n.length)throw new v(l,r,`"${o}": second must be 2 digits`)}function ue(e,t,n,o,l,r){if(void 0!==e){const t=parseInt(e,10);if(t<0||t>23)throw new v(l,r,`"${o}": hour must be 00-23`)}if(void 0!==t){const e=parseInt(t,10);if(e<0||e>59)throw new v(l,r,`"${o}": minute must be 00-59`)}if(void 0!==n){const e=parseInt(n,10);if(e<0||e>60)throw new v(l,r,`"${o}": second must be 00-60`)}}function fe(e,t,n,o,l,r,i){const s=o[0]+o[1].toUpperCase();if(new RegExp("^[+\\-]?"+s.replace(/([[\]])/g,"\\$1")).test(e))throw new v(t,n,`${r} prefix must be lowercase "${o}"`);if(new RegExp("^[+\\-]?"+o+"_","i").test(e))throw new v(t,n,"Underscore must be between digits");const a=new RegExp("^[+\\-]?"+o,"i"),c=e.replace(a,"");if(!c||"_"===c||c.startsWith("_"))throw new v(t,n,`Incomplete ${r.toLowerCase()} number`);const u=c.replace(/_/g,"");if(!l.test(u))throw new v(t,n,null!=i?i:`Invalid ${r.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new v(t,n,`${r} numbers cannot have a sign prefix`)}function*me(e){const t=new N(C(e));for(;!t.next().done;){const n=be(t,e);for(const e of n)yield e}}function he(t){return{type:e.Comment,loc:t.value.loc,raw:t.value.raw}}function de(n,o){const l=n.peek().done||n.peek().value.type!==t.Bracket?e.Table:e.TableArray,r=l===e.Table;if(r&&"["!==n.value.raw)throw new v(o,n.value.loc.start,`Expected table opening "[", found ${n.value.raw}`);if(!r){const e=n.peek();if(e.done)throw new v(o,n.value.loc.start,'Expected "[[" for Array of Tables, found end of input');if("["!==n.value.raw||"["!==e.value.raw)throw new v(o,n.value.loc.start,`Expected "[[", found ${n.value.raw+e.value.raw}`);const t=n.value,l=e.value;if(t.loc.end.line!==l.loc.start.line||t.loc.end.column!==l.loc.start.column)throw new v(o,t.loc.start,'"[[" brackets must be adjacent (no whitespace)')}const i=r?{type:e.TableKey,loc:n.value.loc}:{type:e.TableArrayKey,loc:n.value.loc};if(n.next(),l===e.TableArray&&n.next(),n.done)throw new v(o,i.loc.start,"Expected table key, reached end of file");if(n.value.type===t.Bracket&&"]"===n.value.raw)throw new v(o,n.value.loc.start,l===e.TableArray?"Array of Tables header [[]] requires a table name":"Table header [] requires a table name");const s=n.value.raw;le(s,o,n.value.loc.start);let a;for(s.startsWith('"')||s.startsWith("'")||oe(s,o,n.value.loc.start),a=[re(n.value.raw,o,n.value.loc.start)],i.item={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:a};!n.peek().done&&n.peek().value.type===t.Dot;){n.next();const e=n.value;n.next();const t=n.value.raw;t.startsWith('"')||t.startsWith("'")||oe(t,o,n.value.loc.start);const l=" ".repeat(e.loc.start.column-i.item.loc.end.column),r=" ".repeat(n.value.loc.start.column-e.loc.end.column);i.item.loc.end=n.value.loc.end,i.item.raw+=`${l}.${r}${n.value.raw}`;try{i.item.value.push(F(n.value.raw))}catch(e){const t=e;throw new v(o,n.value.loc.start,t.message)}}if(n.next(),!n.done){const e=i.loc.start.line;if(n.value.loc.start.line!==e)throw new v(o,n.value.loc.start,r?"Table header must be single-line":"Array of Tables header must be single-line")}if(r&&(n.done||"]"!==n.value.raw))throw new v(o,n.done?i.item.loc.end:n.value.loc.start,`Expected table closing "]", found ${n.done?"end of file":n.value.raw}`);if(!r&&(n.done||n.peek().done||"]"!==n.value.raw||"]"!==n.peek().value.raw))throw new v(o,n.done||n.peek().done?i.item.loc.end:n.value.loc.start,`Expected "]]" closing, found ${n.done||n.peek().done?"end of file":n.value.raw+n.peek().value.raw}`);if(!r){const e=n.value,t=n.peek().value;if(e.loc.end.line!==t.loc.start.line||e.loc.end.column!==t.loc.start.column)throw new v(o,e.loc.start,'"]]" brackets must be adjacent (no whitespace)')}if(r||n.next(),i.loc.end=n.value.loc.end,!n.peek().done){const e=n.peek().value;if(e.loc.start.line===i.loc.end.line&&e.type!==t.Comment)throw new v(o,e.loc.start,`Extra content after ${r?"table":"Array of Tables"} header`)}let c=[];for(;!n.peek().done&&n.peek().value.type!==t.Bracket;){n.next();const e=be(n,o);for(let t=0;t<e.length;t++)c.push(e[t])}return{type:r?e.Table:e.TableArray,loc:{start:w(i.loc.start),end:c.length?w(c[c.length-1].loc.end):w(i.loc.end)},key:i,items:c}}function pe(t,n){const o=re(t.value.raw,n,t.value.loc.start);return{type:e.String,loc:t.value.loc,raw:t.value.raw,value:o}}function ge(t){return{type:e.Boolean,loc:t.value.loc,value:t.value.raw===H}}function we(n,o){let l,r=n.value.loc,i=n.value.raw;if(!n.peek().done&&n.peek().value.type===t.Literal&&P.IS_FULL_DATE.test(i)&&P.IS_FULL_TIME.test(n.peek().value.raw)){const e=r.start;n.next(),r={start:e,end:n.value.loc.end},i+=` ${n.value.raw}`}if(!n.peek().done&&n.peek().value.type===t.Dot){const e=r.start;if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new v(o,n.value.loc.end,"Expected fractional value for DateTime");n.next(),r={start:e,end:n.value.loc.end},i+=`.${n.value.raw}`}if(function(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new v(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new v(t,n,`"${e}": offset needs HH:MM`);const o=/\d{2}:\d{2}/.test(e),l=o?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(l){const e=l[0],o=l[2],r=l[3],i=l[4];if(":"!==r)throw new v(t,n,`Offset "${e}": missing colon separator`);if(2!==o.length)throw new v(t,n,`Offset "${e}": hour must be 2 digits`);if(!i||0===i.length)throw new v(t,n,`Offset "${e}": minute required`);if(2!==i.length)throw new v(t,n,`Offset "${e}": minute must be 2 digits`);const s=parseInt(o,10);if(s<0||s>23)throw new v(t,n,`Offset "${e}": hour must be 00-23`);const a=parseInt(i,10);if(a<0||a>59)throw new v(t,n,`Offset "${e}": minute must be 00-59`)}const r=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!r.test(e)){if(/^\d{4}-\d{2}-\d{2}T$/.test(e))throw new v(t,n,`"${e}": 'T' requires time component`);if(/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e))throw new v(t,n,`Invalid date "${e}": unexpected character after date`);if(/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e))throw new v(t,n,`"${e}": missing 'T' or space separator`);throw new v(t,n,`Invalid datetime "${e}"`)}const i=e.match(/^(\d+)-/);if(i&&4!==i[1].length)throw new v(t,n,`"${e}": year must be 4 digits`);const s=/^(\d+)-(\d+)-(\d+)/,a=e.match(s);if(a){const[,,o,l]=a;if(2!==o.length)throw new v(t,n,`"${e}": month must be 2 digits`);if(2!==l.length)throw new v(t,n,`"${e}": day must be 2 digits`)}const c=/[T ](\d+):(\d+)(?::(\d+))?/,u=e.match(c);if(u){const[,o,l,r]=u;ce(o,l,r,e,t,n)}const f=/^(\d+):(\d+)(?::(\d+))?/,m=e.match(f);if(m&&!a){const[,o,l,r]=m;ce(o,l,r,e,t,n)}const h=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),d=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(h){const[,o,l,r,i,s,a]=h,c=parseInt(l,10);if(c<1||c>12)throw new v(t,n,`"${e}": month must be 01-12`);const u=parseInt(r,10);if(u<1||u>31)throw new v(t,n,`"${e}": day must be 01-31`);const f=function(e,t){const n=[31,28,31,30,31,30,31,31,30,31,30,31];if(2===t){return e%4==0&&e%100!=0||e%400==0?29:28}return n[t-1]}(parseInt(o,10),c);if(u>f)throw new v(t,n,`"${e}": day ${r} invalid for ${o}-${l}`);ue(i,s,a,e,t,n)}else if(d){const[,o,l,r]=d;ue(o,l,r,e,t,n)}}(i,o,r.start),P.IS_FULL_DATE.test(i))l=P.IS_DATE_ONLY.test(i)?new V(i):P.IS_LOCAL_DATETIME_T.test(i)?new q(i,!1):P.IS_LOCAL_DATETIME_SPACE.test(i)?new q(i,!0):P.IS_OFFSET_DATETIME_T.test(i)?new R(i,!1):P.IS_OFFSET_DATETIME_SPACE.test(i)?new R(i,!0):new Date(i.replace(" ","T"));else if(P.IS_TIME_ONLY.test(i))l=new z(i,i);else{const[e]=(new Date).toISOString().split("T");l=new Date(`${e}T${i}`)}return{type:e.DateTime,loc:r,raw:i,value:l}}function ye(n,o){let l,r=n.value.loc,i=n.value.raw;if(G.test(i))l=i.startsWith("-")?-1/0:1/0;else if(X.test(i))l=NaN;else if(n.peek().done||n.peek().value.type!==t.Dot){if(ie(i,o,r.start),ae(i,i,o,r.start),!n.peek().done&&n.peek().value.type===t.Dot)throw new v(o,n.peek().value.loc.start,`Float "${i}.": dot after exponent`);se(i,o,r.start,"the integer part of a float"),l=Number(i.replace(Y,""))}else{const e=r.start;{if(J.test(i)&&!Q.test(i))throw new v(o,r.start,`Float "${i}": dot after exponent`);const e=i;se(e,o,r.start,"the integer part of a float");const t=e.replace(/^[+-]/,"");if(""===t||"_"===t)throw new v(o,r.start,"Float: digit required before dot");ie(e,o,r.start)}if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new v(o,n.value.loc.end,"Expected fraction value for Float");n.next(),i+=`.${n.value.raw}`,r={start:e,end:n.value.loc.end};{const e=n.value.raw;if(!/^\d/.test(e))throw new v(o,n.value.loc.start,`Float: fraction must start with digit, found "${e}"`);ie(e,o,n.value.loc.start,!1),ae(e,i,o,n.value.loc.start)}l=Number(i.replace(Y,""))}if(Number.isNaN(l)&&!X.test(i))throw new v(o,r.start,`Invalid float "${i}"`);return{type:e.Float,loc:r,raw:i,value:l}}function ve(t,n){const o=t.value.raw,l=t.value.loc;if(/^\d{1,}-\d{1,}/.test(o)||/^\d{1,}:\d{1,}/.test(o)||/^\d{6}-\d{2}$/.test(o))throw new v(n,l.start,`Invalid integer "${o}"`);if("-0"===o||"+0"===o)return{type:e.Integer,loc:l,raw:o,value:0};if(/^[+-]{2,}/.test(o))throw new v(n,l.start,"Double sign is not allowed in integers");se(o,n,l.start,"decimal integers"),ie(o,n,l.start);let r=10;Q.test(o)?(r=16,fe(o,n,l.start,"0x",/^[0-9a-fA-F]+$/,"Hexadecimal")):te.test(o)?(r=8,fe(o,n,l.start,"0o",/^[0-7]+$/,"Octal","Invalid octal digits (must be 0-7)")):ne.test(o)&&(r=2,fe(o,n,l.start,"0b",/^[01]+$/,"Binary","Invalid binary digits (must be 0 or 1)"));const i=parseInt(o.replace(Y,"").replace(te,"").replace(ne,""),r);if(Number.isNaN(i))throw new v(n,l.start,`Invalid integer "${o}"`);return{type:e.Integer,loc:l,raw:o,value:i}}function be(n,o){if(n.value.type===t.Comment)return[he(n)];if(n.value.type===t.Bracket)return[de(n,o)];if(n.value.type===t.Literal)return function(n,o){const l=n.value.raw;if(l.endsWith(":"))throw new v(o,{line:n.value.loc.start.line,column:n.value.loc.start.column+[...l].length-1},"Use '=' to separate keys and values, not ':'");le(l,o,n.value.loc.start);l.startsWith('"')||l.startsWith("'")||oe(l,o,n.value.loc.start);let r;r=[re(n.value.raw,o,n.value.loc.start)];const i={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:r};for(;!n.peek().done&&n.peek().value.type===t.Dot;){n.next(),n.next();const e=n.value.raw;le(e,o,n.value.loc.start);e.startsWith('"')||e.startsWith("'")||oe(e,o,n.value.loc.start),i.loc.end=n.value.loc.end,i.raw+=`.${n.value.raw}`,i.value.push(re(n.value.raw,o,n.value.loc.start))}if(n.next(),!n.done&&n.value.loc.start.line!==i.loc.end.line)throw new v(o,n.value.loc.start,'"=" must be on same line as key');if(n.done||n.value.type!==t.Equal){if(!n.done&&":"===n.value.raw)throw new v(o,n.value.loc.start,"Use '=' to separate keys and values, not ':'");throw new v(o,n.done?i.loc.end:n.value.loc.start,'Expected "=" for key-value')}const s=n.value.loc.start.column,a=n.value.loc.start.line;if(n.next(),n.done)throw new v(o,i.loc.start,"Expected value, reached EOF");if(n.value.loc.start.line!==a)throw new v(o,n.value.loc.start,"Value must be on same line as '='");if(n.done)throw new v(o,i.loc.start,"Expected value for key-value");const c=$e(n,o),u=c[0];if(!n.peek().done){const l=n.peek().value;if(l.type===t.Dot&&l.loc.start.line===u.loc.end.line&&(u.type===e.Float||u.type===e.Integer))throw new v(o,l.loc.start,"Invalid number: multiple decimal points not allowed");if((l.type===t.Literal||l.type===t.Bracket)&&l.loc.start.line===u.loc.end.line)throw new v(o,l.loc.start,"Key/value pairs must be separated by a newline")}return c[0]={type:e.KeyValue,key:i,value:u,loc:{start:w(i.loc.start),end:w(u.loc.end)},equals:s},c}(n,o);throw n.value.type===t.Equal?new v(o,n.value.loc.start,"Missing key before '='"):new v(o,n.value.loc.start,`Unexpected token "${n.value.type}"`)}function $e(n,o){if(n.value.type===t.Literal){const e=n.value.raw;return e[0]===$||e[0]===k?[pe(n,o)]:e===H||"false"===e?[ge(n)]:/^\d/.test(e)&&(/^\d{1,}-\d{1,}/.test(e)||/^\d{1,}:\d{1,}/.test(e))?[we(n,o)]:!n.peek().done&&n.peek().value.type===t.Dot||G.test(e)||X.test(e)||J.test(e)&&!Q.test(e)?[ye(n,o)]:[ve(n,o)]}if(n.value.type===t.Curly){const[l,r]=function(n,o){if("{"!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "{" for inline table');const l={type:e.InlineTable,loc:n.value.loc,items:[]},r=[];n.next();for(;!n.done&&(n.value.type!==t.Curly||"}"!==n.value.raw);){if(n.value.type===t.Comment){r.push(he(n)),n.next();continue}if(n.value.type===t.Comma){const e=l.items[l.items.length-1];if(!e)throw new v(o,n.value.loc.start,"Leading comma in inline table");if(e.comma)throw new v(o,n.value.loc.start,"Consecutive commas in inline table");e.comma=!0,e.loc.end=n.value.loc.start,n.next();continue}const i=l.items[l.items.length-1];if(i&&!i.comma)throw new v(o,n.value.loc.start,"Missing comma between inline table items");const s=be(n,o),a=s[0];if(a.type===e.KeyValue){l.items.push({type:e.InlineItem,loc:y(a.loc),item:a,comma:!1});for(let e=1;e<s.length;e++)r.push(s[e])}n.next()}if(n.done||n.value.type!==t.Curly||"}"!==n.value.raw)throw new v(o,n.done?l.loc.start:n.value.loc.start,'Expected "}"');return l.loc.end=n.value.loc.end,[l,r]}(n,o);return[l,...r]}if(n.value.type===t.Bracket){const[l,r]=function(n,o){if("["!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "[" for inline array');const l={type:e.InlineArray,loc:n.value.loc,items:[]},r=[];n.next();for(;!n.done&&(n.value.type!==t.Bracket||"]"!==n.value.raw);){if(n.value.type===t.Comma){const e=l.items[l.items.length-1];if(!e)throw new v(o,n.value.loc.start,"Leading comma in array");if(e.comma)throw new v(o,n.value.loc.start,"Consecutive commas in array");e.comma=!0,e.loc.end=n.value.loc.start}else if(n.value.type===t.Comment)r.push(he(n));else{const t=l.items[l.items.length-1];if(t&&!t.comma)throw new v(o,n.value.loc.start,"Missing comma between array elements");const i=$e(n,o),s=i[0];l.items.push({type:e.InlineItem,loc:y(s.loc),item:s,comma:!1});for(let e=1;e<i.length;e++)r.push(i[e])}n.next()}if(n.done||n.value.type!==t.Bracket||"]"!==n.value.raw)throw new v(o,n.done?l.loc.start:n.value.loc.start,'Expected "]"');return l.loc.end=n.value.loc.end,[l,r]}(n,o);return[l,...r]}throw n.value.type===t.Dot?new v(o,n.value.loc.start,"Number cannot start with a dot"):new v(o,n.value.loc.start,"Unrecognized token type")}function ke(e){return e[e.length-1]}function Te(){return Object.create(null)}function Se(e){return"number"==typeof e&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function Ie(e){return"[object Date]"===Object.prototype.toString.call(e)}function Ee(e){return e&&"object"==typeof e&&!Ie(e)&&!Array.isArray(e)}function Ae(e){return null!=e&&"function"==typeof e[Symbol.iterator]}function Ce(e,t){return t in e}function xe(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 _e(e){if(Ee(e)){return`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${_e(e[t])}`).join(",")}}`}return Array.isArray(e)?`[${e.map(_e).join(",")}]`:JSON.stringify(e)}function Oe(e,t){const n=e.length,o=t.length;e.length=n+o;for(let l=0;l<o;l++)e[n+l]=t[l]}const De=new WeakSet,Fe=new WeakMap,Me=e=>(Fe.has(e)||Fe.set(e,new WeakMap),Fe.get(e)),Le=new WeakMap,Ne=e=>(Le.has(e)||Le.set(e,new WeakMap),Le.get(e));function We(e,t,n,o){if(m(t)){const e=t.items.indexOf(n);if(e<0)throw new Error("Item not found in parent for replace");t.items.splice(e,1,o)}else if(r(t)&&u(t.value)&&!u(n)){const e=t.value.items.indexOf(n);if(e<0)throw new Error("Item not found in parent for replace");t.value.items.splice(e,1,o)}else if(h(t))t.item=o;else{if(!r(t))throw new Error(`Unsupported parent type "${t.type}" for replace`);t.key===n?t.key=o:t.value=o}ze(o,{lines:n.loc.start.line-o.loc.start.line,columns:n.loc.start.column-o.loc.start.column});const l=d(n.loc),i=d(o.loc);Re({lines:i.lines-l.lines,columns:i.columns-l.columns},Ne(e),o,n),De.add(e)}function Ke(e,t,i,s,h){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for insert`);let p,g;s=null!=s&&"number"==typeof s?s:t.items.length,a(t)||u(t)?({shift:p,offset:g}=function(e,t,n){if(!c(t))throw new Error(`Incompatible child type "${t.type}"`);const o=null!=n?e.items[n-1]:ke(e.items),l=null==n||n===e.items.length;e.items.splice(n,0,t);const r=!!o,i=!l;r&&(o.comma=!0);i&&(t.comma=!0);const s=qe(e),a=l&&!0===t.comma;return Ue(e,t,n,{useNewLine:s,hasCommaHandling:!0,isLastElement:l,hasSeparatingCommaBefore:r,hasSeparatingCommaAfter:i,hasTrailingComma:a})}(t,i,s)):h&&n(t)?({shift:p,offset:g}=function(e,t,n){const o=Ue(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),o}(t,i,s)):({shift:p,offset:g}=function(e,t,i){if(s=t,!(r(s)||o(s)||l(s)||f(s)))throw new Error(`Incompatible child type "${t.type}"`);var s;const a=e.items[i-1],c=n(e)&&!e.items.length,u=n(e)&&!c&&void 0===a;e.items.splice(i,0,t);const m=a?{line:a.loc.end.line,column:f(a)?e.loc.start.column:a.loc.start.column}:w(e.loc.start),h=o(t)||l(t);let p=0;c||u||(p=h?2:1);m.line+=p;const g={lines:m.line-t.loc.start.line,columns:m.column-t.loc.start.column},y=d(t.loc),v={lines:u?y.lines+1:y.lines+(p-1),columns:y.columns};return{shift:g,offset:v}}(t,i,s)),ze(i,p);const y=t.items[s-1],v=y&&Ne(e).get(y);if(v&&(g.lines+=v.lines,g.columns+=v.columns,Ne(e).delete(y)),u(t)&&0!==g.lines&&m(e)&&e!==t){const t=i.loc.start.line,n=e.items;for(let e=0;e<n.length;e++){const o=n[e];if(!f(o))continue;o.loc.start.line<t&&(o.loc.start.line-=g.lines,o.loc.end.line-=g.lines)}}Ne(e).set(i,g),De.add(e)}function Ue(e,t,n,o={}){const{useNewLine:l=!1,skipCommaSpace:r=2,skipBracketSpace:i=1,hasCommaHandling:s=!1,isLastElement:a=!1,hasSeparatingCommaBefore:c=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:m=!1}=o,h=n>0?e.items[n-1]:void 0,p=h?{line:h.loc.end.line,column:l?f(h)?e.loc.start.column:h.loc.start.column:h.loc.end.column}:w(e.loc.start);let g=0;if(l)g=1;else{const e=c||!s&&!!h;e&&s?p.column+=r:(e||s&&!h)&&(p.column+=i)}p.line+=g;const y={lines:p.line-t.loc.start.line,columns:p.column-t.loc.start.column},v=d(t.loc);if(!s){return{shift:y,offset:{lines:v.lines+(g-1),columns:v.columns}}}let b=0;c&&m&&!u&&a&&(b=-1);return{shift:y,offset:{lines:v.lines+(g-1),columns:v.columns+(c||u?r:0)+(m?1+b:0)}}}function je(e,t,n){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for remove`);let r=t.items.indexOf(n);if(r<0){if(r=t.items.findIndex(e=>h(e)&&e.item===n),r<0)throw new Error("Node not found in parent for removal");n=t.items[r]}const i=t.items[r-1];let s=t.items[r+1];t.items.splice(r,1);let p=d(n.loc);s&&f(s)&&s.loc.start.line===n.loc.end.line&&(p=d({start:n.loc.start,end:s.loc.end}),s=t.items[r+1],t.items.splice(r,1));const g=i&&c(i)||s&&c(s),w=i&&i.loc.end.line===n.loc.start.line,y=s&&s.loc.start.line===n.loc.end.line,v=g&&(w||y),b={lines:-(p.lines-(v?1:0)),columns:v?-p.columns:0},$=(u(t)||a(t))&&t.loc.end.line>t.loc.start.line;if(void 0!==i||void 0!==s||$||(b.lines=0,b.columns=0),g&&w&&(b.columns-=2),g&&!i&&s&&(qe(t)||(b.columns-=2)),g&&i&&!s){const e=n.comma;i.comma=!!e}let k,T;i?(k=i,T=Ne(e)):(o(t)||l(t))&&"key"in t?(k=t.key,T=Ne(e)):(k=t,T=Me(e));const S=Ne(e),I=T.get(k);I&&(b.lines+=I.lines,b.columns+=I.columns);const E=S.get(n);if(E&&(b.lines+=E.lines,b.columns+=E.columns),T.set(k,b),De.add(e),$&&m(e)&&e!==t){const t=n.loc.start.line,o=e.items,l=[];for(let e=0;e<o.length;e++){const n=o[e];if(!f(n))continue;const r=n.loc.start.line;r===t?l.push(e):0!==b.lines&&r<t&&(n.loc.start.line-=b.lines,n.loc.end.line-=b.lines)}for(let e=l.length-1;e>=0;e--)o.splice(l[e],1)}}function Be(e,t,n=!0){if(!n)return;if(!t.items.length)return;Re({lines:0,columns:1},Me(e),t);const o=ke(t.items);Re({lines:0,columns:1},Ne(e),o),De.add(e)}function Ze(e,t,n=!1){if(!n)return;if(!t.items.length)return;const o=ke(t.items);o.comma=!0,Re({lines:0,columns:1},Ne(e),o),De.add(e)}function Ve(t){if(!De.has(t))return;const n=Me(t),o=Ne(t);let l=0;const r={};function i(e){let t=e.loc.start.line,n=e.loc.start.column;if("key"in e){const o=e.key.loc.end;(o.line>t||o.line===t&&o.column>n)&&(t=o.line,n=o.column)}for(let o=0;o<e.items.length;o++){const l=e.items[o].loc.end;(l.line>t||l.line===t&&l.column>n)&&(t=l.line,n=l.column)}e.loc.end={line:t,column:n}}function s(e){e.loc.start.line+=l;const t=r[e.loc.start.line]||0;e.loc.start.column+=t;const o=n.get(e);o&&(l+=o.lines,r[e.loc.start.line]=(r[e.loc.start.line]||0)+o.columns)}function a(e){e.loc.end.line+=l;const t=r[e.loc.end.line]||0;e.loc.end.column+=t;const n=o.get(e);n&&(l+=n.lines,r[e.loc.end.line]=(r[e.loc.end.line]||0)+n.columns)}!function t(n){switch(n.type){case e.Document:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.Table:{const e=n;s(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.TableArray:{const e=n;s(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.TableKey:{const e=n;s(e),t(e.item),a(e);break}case e.TableArrayKey:{const e=n;s(e),t(e.item),a(e);break}case e.KeyValue:{const e=n,i=e.loc.start.line+l,c=o.get(e.key);e.equals+=(r[i]||0)+(c?c.columns:0),s(e),t(e.key),t(e.value),a(e);break}case e.InlineArray:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e);break}case e.InlineTable:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e);break}case e.InlineItem:{const e=n;s(e),t(e.item),a(e);break}case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:s(n),a(n);break;default:throw new Error(`Unrecognized node type "${n.type}"`)}}(t),De.delete(t),Fe.delete(t),Le.delete(t)}function ze(t,n,o={}){const{lines:l,columns:r}=n;if(0===l&&0===r)return t;const{first_line_only:i=!1}=o,s=t.loc.start.line,a=t.type;if(a===e.Key||a===e.String||a===e.Integer||a===e.Float||a===e.Boolean||a===e.DateTime||a===e.Comment)return i&&t.loc.start.line!==s||(t.loc.start.column+=r,t.loc.end.line===t.loc.start.line&&(t.loc.end.column+=r)),t.loc.start.line+=l,t.loc.end.line+=l,t;if(a===e.KeyValue){const n=t,o=n.value.type;if(o===e.String||o===e.Integer||o===e.Float||o===e.Boolean||o===e.DateTime){i&&n.loc.start.line!==s||(n.loc.start.column+=r,n.loc.end.column+=r),n.loc.start.line+=l,n.loc.end.line+=l,n.equals+=r;const e=n.key;i&&e.loc.start.line!==s||(e.loc.start.column+=r,e.loc.end.column+=r),e.loc.start.line+=l,e.loc.end.line+=l;const o=n.value;return i&&o.loc.start.line!==s||(o.loc.start.column+=r,o.loc.end.column+=r),o.loc.start.line+=l,o.loc.end.line+=l,t}}const c=e=>{i&&e.loc.start.line!==s||(e.loc.start.column+=r,e.loc.end.column+=r),e.loc.start.line+=l,e.loc.end.line+=l};return function(t,n){function o(e,t){for(const n of e)l(n,t)}function l(t,r){const i=n[t.type];switch(i&&"function"==typeof i&&i(t,r),i&&i.enter&&i.enter(t,r),t.type){case e.Document:o(t.items,t);break;case e.Table:l(t.key,t),o(t.items,t);break;case e.TableKey:l(t.item,t);break;case e.TableArray:l(t.key,t),o(t.items,t);break;case e.TableArrayKey:l(t.item,t);break;case e.KeyValue:l(t.key,t),l(t.value,t);break;case e.InlineArray:o(t.items,t);break;case e.InlineItem:l(t.item,t);break;case e.InlineTable:o(t.items,t);break;case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:break;default:throw new Error(`Unrecognized node type "${t.type}"`)}i&&i.exit&&i.exit(t,r)}Ae(t)?o(t,null):l(t,null)}(t,{[e.Table]:c,[e.TableKey]:c,[e.TableArray]:c,[e.TableArrayKey]:c,[e.KeyValue](e){c(e),e.equals+=r},[e.Key]:c,[e.String]:c,[e.Integer]:c,[e.Float]:c,[e.Boolean]:c,[e.DateTime]:c,[e.InlineArray]:c,[e.InlineItem]:c,[e.InlineTable]:c,[e.Comment]:c}),t}function qe(e){if(!e.items.length)return!1;return d(e.loc).lines>e.items.length}function Re(e,t,n,o){const l=t.get(o||n);l&&(e.lines+=l.lines,e.columns+=l.columns),t.set(n,e)}function Pe(e){switch(e){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"\\":return"\\";default:return null}}function He(e,t){switch(e){case"\\":return"\\\\";case"\b":return"\\b";case"\t":return"\\t";case"\f":return"\\f";case'"':return"singleline-basic"===t?'\\"':'"';case"\n":return"singleline-basic"===t?"\\n":"\n";case"\r":return"singleline-basic"===t?"\\r":"\r";default:{const n=e.charCodeAt(0);return function(e,t){return"singleline-basic"===t?e<=31||127===e:e>=0&&e<=7||11===e||e>=14&&e<=31||127===e}(n,t)?`\\u${n.toString(16).padStart(4,"0").toUpperCase()}`:e}}}function Je(e,t,n){const o=function(e){const t=new Map;for(let n=0;n<e.length;n++){if("\\"!==e[n])continue;const o=e[n+1];if(!o)continue;const l=Pe(o);if(null===l){if("x"===o&&/^[0-9A-Fa-f]{2}$/.test(e.slice(n+2,n+4))){const o=e.slice(n,n+4),l=Number.parseInt(e.slice(n+2,n+4),16),r=String.fromCharCode(l);t.has(r)||t.set(r,o),n+=3;continue}if("u"===o&&/^[0-9A-Fa-f]{4}$/.test(e.slice(n+2,n+6))){const o=e.slice(n,n+6),l=Number.parseInt(e.slice(n+2,n+6),16),r=String.fromCodePoint(l);t.has(r)||t.set(r,o),n+=5;continue}if("U"===o&&/^[0-9A-Fa-f]{8}$/.test(e.slice(n+2,n+10))){const o=e.slice(n,n+10),l=Number.parseInt(e.slice(n+2,n+10),16),r=String.fromCodePoint(l);t.has(r)||t.set(r,o),n+=9;continue}}else"\n"===l||"\r"===l||t.has(l)||t.set(l,"\\"+o),n+=1}return t}(t);if(0===o.size&&"singleline-basic"===n){return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,"\\u007F")}const l=function(e,t,n){let o="";for(const l of e){const e=t.get(l);o+=e||He(l,n)}return o}(e,o,n);return"multiline-basic"===n?l.replace(/"""/g,'""\\"'):l}function Ye(){return{type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:[]}}function Ge(t){const n=function(t){const n=tt(t);return{type:e.TableKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+2}},item:{type:e.Key,loc:{start:{line:1,column:1},end:{line:1,column:n.length+1}},value:t,raw:n}}}(t);return{type:e.Table,loc:y(n.loc),key:n,items:[]}}function Xe(t){const n=function(t){const n=tt(t);return{type:e.TableArrayKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+4}},item:{type:e.Key,loc:{start:{line:1,column:2},end:{line:1,column:n.length+2}},value:t,raw:n}}}(t);return{type:e.TableArray,loc:y(n.loc),key:n,items:[]}}function Qe(t,n){const o=function(t){const n=tt(t);return{type:e.Key,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t),{column:l}=o.loc.end,r=l+1;return ze(n,{lines:0,columns:l+3-n.loc.start.column},{first_line_only:!0}),{type:e.KeyValue,loc:{start:w(o.loc.start),end:w(n.loc.end)},key:o,equals:r,value:n}}function et(e){return JSON.stringify(e).replace(/\x7f/g,"\\u007f")}function tt(e){return e.map(e=>b.test(e)?e:et(e)).join(".")}function nt(t,n){return n?function(t,n){if(o=n,o.startsWith('"')&&!o.startsWith('"""'))return ot(t,n);var o;if(function(e){return e.startsWith("'")&&!e.startsWith("'''")}(n)){if(!t.includes("'"))return function(t){const n=`'${t}'`;let o;if(n.includes("\n")){const e=n.split(/\r\n|\n/),t=e[e.length-1];o={line:e.length,column:t.length}}else o={line:1,column:n.length};return{type:e.String,loc:{start:{line:1,column:0},end:o},raw:n,value:t}}(t);if(!t.includes("'''")){return rt(t,`'''${n.slice(1,-1)}'''`)}return ot(t)}if(function(e){return e.startsWith("'''")}(n)){if(!t.includes("'''"))return rt(t,n);return lt(t,`"""${n.slice(3,-3)}"""`)}if(function(e){return e.startsWith('"""')}(n))return lt(t,n);throw new Error(`Existing raw string value is not valid: ${n}`)}(t,n):ot(t)}function ot(t,n){let o="";return o=n?`"${Je(t,n,"singleline-basic")}"`:et(t),{type:e.String,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}function lt(t,n){const o=Je(t,n,"multiline-basic");let l='"""'+(n.startsWith('"""\r\n')?"\r\n":n.startsWith('"""\n')?"\n":"")+o+'"""';const r=n.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(r)){const e=function(e,t){var n,o,l,r,i,s,a,c;const u=function(e){const t=e.match(/\r\n|\n/);return"\r\n"===(null==t?void 0:t[0])?"\r\n":"\n"}(e),f='"""';let m,h;(e=e.replace(/\r\n/g,"\n").replace(/\n/g,u)).startsWith(`${f}\\${u}`)?(m=4+u.length,h=`${f}\\${u}`):e.startsWith(`${f}${u}`)?(m=3+u.length,h=`${f}${u}`):(m=3,h=f);const d=e.length-3,p=e.slice(m,d).split(u),g=p[p.length-1],w=p.length>1&&/^[\t ]*$/.test(g),y=w?g:"",v=(w?p.slice(0,-1):p).map(e=>{var t,n;if(/^[\t ]*$/.test(e))return{indent:e,content:"",trailingWs:"",hasBackslash:!1,isBlank:!0};let o=e,l=0;for(let e=o.length-1;e>=0&&"\\"===o[e];e--)l++;const r=l%2==1;r&&(o=o.slice(0,-1));const i=null!==(n=null===(t=o.match(/^[\t ]*/))||void 0===t?void 0:t[0])&&void 0!==n?n:"",s=o.slice(i.length),a=s.match(/([\t ]+)$/),c=a?a[1]:"";return{indent:i,content:s.slice(0,s.length-c.length),trailingWs:c,hasBackslash:r,isBlank:!1}}),b=v.filter(e=>!e.isBlank),$=Math.max(...b.map(e=>e.content.length+e.trailingWs.length),1),k=b.filter(e=>e.hasBackslash),T=null!==(o=null!==(n=k[k.length-1])&&void 0!==n?n:b[b.length-1])&&void 0!==o?o:{indent:"",trailingWs:"",hasBackslash:!1,content:""},S=null!==(l=b[b.length-1])&&void 0!==l?l:T,I=[];{let e=[],t=0;for(const n of v)n.isBlank?e.push(n.indent):(t>0&&I.push(e),e=[],t++)}const E=b.some((e,t)=>!e.hasBackslash&&t<b.length-1),A=h===`${f}${u}`,C=A&&b.length>0&&null!==(i=null===(r=t.match(/^[\t ]*/))||void 0===r?void 0:r[0])&&void 0!==i?i:"",x=e=>{var t;const n=null!==(t=e.match(/\S+| +/g))&&void 0!==t?t:[],o=[];let l=0;for(;l<n.length;){let e=n[l++];for(;l<n.length&&" "===n[l][0];){const t=n[l],o=n[l+1];if(!o){l++;break}if(!(e.length+t.length+o.length<=$)){e+=t,l++;break}e+=t+o,l+=2}o.push(e)}return 0===o.length&&o.push(""),o},_=[],O=[],D=new Set,F=new Set,M=new Map;let L=!1;if(!E||!t.includes(u)||"\r\n"!==u&&t.includes("\r\n")){const e=t.replace(/\r\n/g,"\\r\\n").replace(/\n/g,"\\n").slice(C.length);if(e.length>0){if(" "===e[0])return null;if(e.length-e.trimEnd().length!==S.trailingWs.length)return null}if(!E){let t=0,n=0;for(let o=0;o<b.length-1;o++){const l=b[o];if(!l.hasBackslash)break;const r=l.content+l.trailingWs;if(e.slice(n,n+r.length)!==r)break;t++,n+=r.length}let o=0,l=0;for(let r=b.length-1;r>=t;r--){const t=b[r],i=t.content+t.trailingWs;if(0===i.length)break;const s=e.length-l-i.length;if(!(s>=n&&e.slice(s,s+i.length)===i))break;o++,l+=i.length}if(o>0){const r=e.slice(n,e.length-l);if(0===r.length||" "!==r[0]){for(let e=0;e<t;e++){const n=b[e];if(O.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}if(r.length>0){const e=x(r),n=e.join(""),l=/(?<!\\)\\n/.test(n);if(t>0&&!l){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}for(let n=0;n<e.length;n++){const o=e[n],i=t+n,s=i<b.length?b[i]:null,a=s?A&&0===i?C:s.indent:T.indent,c=o.length>0&&/\s$/.test(o)?"":r.endsWith(" ")?" ":"";if(O.push(`${a}${o}${c}\\`),n<e.length-1&&!l){const e=t+n;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}const i=b.length-o-1;if(!l&&i>=0&&i<I.length&&I[i].length>0)for(const e of I[i])O.push(e)}else if(t>0){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}const e=b.length-o;for(let t=e;t<b.length;t++){const n=b[t],o=t===b.length-1;if(t>e){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}O.push(o?`${n.indent}${n.content}${n.trailingWs}${n.hasBackslash&&""!==n.content?"\\":""}`:`${n.indent}${n.content}${n.trailingWs}\\`)}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}}const r=e.slice(n);if(t>0&&(n===e.length||r.length>0&&" "!==r[0])){for(let e=0;e<t;e++){const n=b[e];if(O.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}if(n===e.length){const e=b[t-1],n=S.hasBackslash&&""!==e.content?"\\":"";O[O.length-1]=`${e.indent}${e.content}${S.trailingWs}${n}`}else{const e=x(r),n=e.join(""),o=/(?<!\\)\\n/.test(n),l=t-1;if(!o&&l<I.length&&I[l].length>0)for(const e of I[l])O.push(e);for(let n=0;n<e.length;n++){const l=n===e.length-1,r=e[n],i=t+n,s=i<b.length?b[i]:null,a=s?A&&0===i?C:s.indent:l?S.indent:T.indent;let c,u;if(l?(c=S.trailingWs,u=S.hasBackslash&&""!==S.content?"\\":""):(c=r.length>0&&/\s$/.test(r)?"":" ",u="\\"),O.push(`${a}${r}${c}${u}`),!l){const e=t+n;if(!o&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}}const n=x(e);for(const e of n)_.push(e)}else{L=!0;const e=t.split(u),n=e[0].slice(C.length);if(n.length>0&&" "===n[0])return null;const o=e[e.length-1];if(o.length>0&&o.length-o.trimEnd().length!==S.trailingWs.length)return null;for(let t=0;t<e.length;t++){const n=e[t],o=0===t?n.slice(C.length):n,l=null!==(a=null===(s=o.match(/^[\t ]*/))||void 0===s?void 0:s[0])&&void 0!==a?a:"",r=x(o.slice(l.length)),i=_.length;F.add(i),t>0&&M.set(i,l);for(const e of r)_.push(e);t<e.length-1&&D.add(i+r.length-1)}}for(let e=0;e<_.length;e++){const t=e===_.length-1,n=D.has(e),o=t||n,l=e<b.length?b[e]:null,r=L&&F.has(e)&&e>0?null!==(c=M.get(e))&&void 0!==c?c:"":l?A&&0===e?C:l.indent:o?S.indent:T.indent,i=_[e];let s,a;if(o&&t?(s=S.trailingWs,a=S.hasBackslash&&""!==S.content?"\\":""):o?(s=S.trailingWs,a=""):(s=i.length>0&&/\s$/.test(i)?"":" ",a="\\"),O.push(`${r}${i}${s}${a}`),!t&&!n&&!L){const t=_.join("");if(!/(?<!\\)\\n/.test(t)&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}(n,o);null!==e&&(l=e)}const i=it(l);return{type:e.String,loc:{start:{line:1,column:0},end:i},raw:l,value:t}}function rt(t,n){const o="'''"+(n.startsWith("'''\r\n")?"\r\n":n.startsWith("'''\n")?"\n":"")+t+"'''",l=it(o);return{type:e.String,loc:{start:{line:1,column:0},end:l},raw:o,value:t}}function it(e){if(e.includes("\n")){const 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 st(t){const n=t.toString();return{type:e.Integer,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}function at(t,n=1){let o;if(t===1/0)o="inf";else if(t===-1/0)o="-inf";else if(Number.isNaN(t))o="nan";else if(Object.is(t,-0))o="-0."+"0".repeat(Math.max(n,1));else{o=t.toString();const e=o.search(/[eE]/);if(-1!==e){const t=o.slice(0,e),l=o.slice(e),r=t.indexOf(".");if(-1===r)o=`${t}.${"0".repeat(Math.max(n,1))}${l}`;else{const e=t.length-r-1;o=e<n?`${t}${"0".repeat(n-e)}${l}`:`${t}${l}`}}else{const e=o.indexOf(".");if(-1===e)o+="."+"0".repeat(Math.max(n,1));else{const t=o.length-e-1;t<n&&(o+="0".repeat(n-t))}}}return{type:e.Float,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}function ct(t){return{type:e.InlineItem,loc:y(t.loc),item:t,comma:!1}}const ut=!1,ft=!0,mt=!1,ht=!1;function dt(e,t){if(!e||"object"!=typeof e)return null;if(("InlineArray"===e.type||"InlineTable"===e.type)&&e.loc){const n=function(e,t){var n;if(!e||!e.start||!e.end)return null;const o=t.split(/\r?\n/),l=e.start.line-1,r=e.end.line-1,i=e.start.column,s=e.end.column;let a="";if(l===r)a=(null===(n=o[l])||void 0===n?void 0:n.substring(i,s+1))||"";else{o[l]&&(a+=o[l].substring(i));for(let e=l+1;e<r;e++)a+="\n"+(o[e]||"");o[r]&&(a+="\n"+o[r].substring(0,s+1))}const c=a.match(/^\[(\s*)/),u=a.match(/^\{(\s*)/);if(c)return c[1].length>0;if(u)return u[1].length>0;return null}(e.loc,t);if(null!==n)return n}if(e.items&&Array.isArray(e.items))for(const n of e.items){const e=dt(n,t);if(null!==e)return e;if(n.item){const e=dt(n.item,t);if(null!==e)return e}}for(const n of["value","key","item"])if(e[n]){const o=dt(e[n],t);if(null!==o)return o}return null}function pt(e){if(!e||"object"!=typeof e)return null;if("InlineArray"===e.type&&e.items&&Array.isArray(e.items))return gt(e.items);if("InlineTable"===e.type&&e.items&&Array.isArray(e.items))return gt(e.items);if("KeyValue"===e.type&&e.value)return pt(e.value);if(e.items&&Array.isArray(e.items))for(const t of e.items){const e=pt(t);if(null!==e)return e}return null}function gt(e){if(0===e.length)return null;const t=e[e.length-1];return!(!t||"object"!=typeof t||!("comma"in t))&&!0===t.comma}function wt(e){const t=e.indexOf("\n");return t>0&&"\r"===e[t-1]?"\r\n":"\n"}function yt(e,t){var n,o,l,r,i,s,a;if(e){if(e instanceof vt)return e;{const c=function(e){if(!e||"object"!=typeof e)return{};const t=e=>"boolean"==typeof e?null:"expected boolean, got "+typeof e,n={newLine:e=>"string"==typeof e?null:"expected string, got "+typeof e,trailingNewline:e=>"boolean"==typeof e||"number"==typeof e?null:"expected boolean or number, got "+typeof e,trailingComma:t,bracketSpacing:t,inlineTableStart:e=>null==e||"number"==typeof e&&Number.isInteger(e)&&e>=0?null:"expected non-negative integer or undefined, got "+typeof e,truncateZeroTimeInDates:t,useTabsForIndentation:t,minimumDecimals:e=>null==e||"number"==typeof e&&Number.isInteger(e)&&e>=0?null:"expected non-negative integer or undefined, got "+typeof e},o={},l=[],r=[];for(const t in e){const i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(i){const n=e[t],l=i(n);l?r.push(`${t} (${l})`):o[t]=n}else Object.prototype.hasOwnProperty.call(e,t)&&l.push(t)}if(l.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${l.join(", ")}. Supported properties are: ${Object.keys(n).join(", ")}`),r.length>0)throw new TypeError(`Invalid types for format properties: ${r.join(", ")}`);return o}(e);return new vt(null!==(n=c.newLine)&&void 0!==n?n:t.newLine,null!==(o=c.trailingNewline)&&void 0!==o?o:t.trailingNewline,null!==(l=c.trailingComma)&&void 0!==l?l:t.trailingComma,null!==(r=c.bracketSpacing)&&void 0!==r?r:t.bracketSpacing,void 0!==c.inlineTableStart?c.inlineTableStart:t.inlineTableStart,null!==(i=c.truncateZeroTimeInDates)&&void 0!==i?i:t.truncateZeroTimeInDates,null!==(s=c.useTabsForIndentation)&&void 0!==s?s:t.useTabsForIndentation,null!==(a=c.minimumDecimals)&&void 0!==a?a:t.minimumDecimals)}}return t}class vt{constructor(e,t,n,o,l,r,i,s){this.newLine=null!=e?e:"\n",this.trailingNewline=null!=t?t:1,this.trailingComma=null!=n?n:ut,this.bracketSpacing=null!=o?o:ft,this.inlineTableStart=null!=l?l:1,this.truncateZeroTimeInDates=null!=r?r:mt,this.useTabsForIndentation=null!=i?i:ht,this.minimumDecimals=null!=s?s:0}static default(){return new vt("\n",1,ut,ft,1,mt,ht)}static autoDetectFormat(e){const t=vt.default();t.newLine=wt(e),t.trailingNewline=function(e){let t=0,n=e.length;for(;n>0&&"\n"===e[n-1];)t++,n--,n>0&&"\r"===e[n-1]&&n--;return t}(e);try{const n=me(e),o=Array.from(n);t.trailingComma=function(e){const t=Array.from(e);for(const e of t){const t=pt(e);if(null!==t)return t}return ut}(o),t.bracketSpacing=function(e,t){const n=Array.from(t);for(const t of n){const n=dt(t,e);if(null!==n)return n}return ft}(e,o)}catch(e){t.trailingComma=ut,t.bracketSpacing=ft}return t.useTabsForIndentation=function(e){const t=e.split(/\r?\n/);let n=0,o=0;for(const e of t)if(0!==e.length&&("\t"===e[0]?n++:" "===e[0]&&o++,n+o>=5))break;return n>o}(e),t.inlineTableStart=1,t.truncateZeroTimeInDates=mt,t.minimumDecimals=0,t}}function bt(e){if(!a(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function $t(e){if(!u(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function kt(e,t){if(0===t.inlineTableStart)return e;return e.items.filter(e=>{if(!r(e))return!1;const n=u(e.value),o=a(e.value)&&e.value.items.length>0&&e.value.items.every(e=>u(e.item));if(n||o){const n=It(e.key.value);return void 0===t.inlineTableStart||n<t.inlineTableStart}return!1}).forEach(t=>{je(e,e,t),u(t.value)?Ke(e,e,Tt(t)):function(e){const t=Ye();for(const n of e.value.items){const o=Xe(e.key.value);Ke(t,t,o);for(const e of n.item.items)Ke(t,o,e.item)}return Ve(t),t.items}(t).forEach(t=>{Ke(e,e,t)})}),Ve(e),e}function Tt(e){const t=Ge(e.key.value);for(const n of e.value.items)Ke(t,t,n.item);return Ve(t),t}function St(e){if(e.items.length>0){const 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 It(e){return Math.max(0,e.length-1)}function Et(e,t,n){var o;for(let l=e.items.length-1;l>=0;l--){const i=e.items[l];if(r(i)&&u(i.value)){const l=[...e.key.item.value,...i.key.value];if(It(l)<(null!==(o=n.inlineTableStart)&&void 0!==o?o:1)){const o=Ge(l);for(const e of i.value.items)Ke(o,o,e.item);je(e,e,i),St(e),t.push(o),Et(o,t,n)}}}}function At(e,t=vt.default()){e=_t(e);const n=Ye();for(const o of Ct(e,t))Ke(n,n,o);return Ve(n),kt(n,t),function(e,t){if(void 0===t.inlineTableStart||0===t.inlineTableStart)return e;const n=[];for(const o of e.items)if(r(o)&&u(o.value)){if(It(o.key.value)<t.inlineTableStart){const l=Tt(o);je(e,e,o),Ke(e,e,l),Et(l,n,t)}}else("Table"===o.type||l(o))&&Et(o,n,t);for(const t of n)Ke(e,e,t);Ve(e)}(n,t),function(e){let t=0,n=0;for(const o of e.items)0===n&&o.loc.start.line>1?t=1-o.loc.start.line:o.loc.start.line+t>n+2&&(t+=n+2-(o.loc.start.line+t)),ze(o,{lines:t,columns:0}),n=o.loc.end.line;return e}(n)}function*Ct(e,t){for(const n of Object.keys(e)){const o=e[n];if(void 0===o)continue;const l=_t(o);void 0!==l&&(yield Qe([n],xt(l,t)))}}function xt(t,n){var o;const l=null!==(o=n.minimumDecimals)&&void 0!==o?o:0;if(null===t)throw new Error('"null" values are not supported');if(void 0===t)throw new Error('"undefined" values are not supported inside arrays');return function(e){return"string"==typeof e}(t)?nt(t):function(e){return"bigint"==typeof e}(t)?st(t):Se(t)?l>0?at(t,l):st(t):function(e){return"number"==typeof e&&(!Se(e)||!isFinite(e)||Object.is(e,-0))}(t)?at(t,Math.max(l,1)):function(e){return"boolean"==typeof e}(t)?function(t){return{type:e.Boolean,loc:{start:{line:1,column:0},end:{line:1,column:t?4:5}},value:t}}(t):Ie(t)?function(t,n=!1){n&&0===t.getUTCHours()&&0===t.getUTCMinutes()&&0===t.getUTCSeconds()&&0===t.getUTCMilliseconds()&&(t=new V(t.toISOString().split("T")[0]));const o=t.toISOString();return{type:e.DateTime,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}(t,n.truncateZeroTimeInDates):Array.isArray(t)?function(t,n){const o={type:e.InlineArray,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of t){Ke(o,o,ct(xt(e,n)))}return Be(o,o,n.bracketSpacing),Ze(o,o,n.trailingComma),Ve(o),o}(t,n):function(t,n){if(t=_t(t),!Ee(t))return xt(t,n);const o={type:e.InlineTable,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of Ct(t,n)){Ke(o,o,ct(e))}return Be(o,o,n.bracketSpacing),Ze(o,o,n.trailingComma),Ve(o),o}(t,n)}function _t(e){return e?Ie(e)?e:"function"==typeof e.toJSON?e.toJSON():e:e}const Ot=/(\r\n|\n)/g;function Dt(t,n){const o=[];function l(t){switch(t.type){case e.Document:for(let e=0;e<t.items.length;e++)l(t.items[e]);break;case e.Table:{const e=t;l(e.key);for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.TableKey:{const e=t,{start:n,end:r}=e.loc;Mt(o,n.line,n.column,"["),Mt(o,r.line,r.column-1,"]"),l(e.item);break}case e.TableArray:{const e=t;l(e.key);for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.TableArrayKey:{const e=t,{start:n,end:r}=e.loc;Lt(o,n.line,n.column,n.column+2,"[["),Lt(o,r.line,r.column-2,r.column,"]]"),l(e.item);break}case e.KeyValue:{const e=t,n=e.loc.start.line;Mt(o,n,e.equals,"="),l(e.key),l(e.value);break}case e.Key:case e.String:case e.Integer:case e.Float:Ft(o,t.loc,t.raw);break;case e.Boolean:Ft(o,t.loc,t.value.toString());break;case e.DateTime:Ft(o,t.loc,t.raw);break;case e.InlineArray:{const e=t,{start:n,end:r}=e.loc;Mt(o,n.line,n.column,"["),Mt(o,r.line,r.column-1,"]");for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.InlineTable:{const e=t,{start:n,end:r}=e.loc;Mt(o,n.line,n.column,"{"),Mt(o,r.line,r.column-1,"}");for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.InlineItem:{const e=t;if(l(e.item),e.comma){const t=e.loc.end;Mt(o,t.line,t.column,",")}break}case e.Comment:Ft(o,t.loc,t.raw);break;default:{const e=t.type;throw new Error(`toTOML: Unrecognized node type: ${String(e)}`)}}}if(Ae(t))for(const e of t)l(e);else l(t);if(n.useTabsForIndentation)for(let e=0;e<o.length;e++){const t=o[e],n=t.match(/^( +)/);if(n){const l=n[1],r="\t".repeat(l.length);o[e]=r+t.substring(l.length)}}return o.join(n.newLine)+n.newLine.repeat(n.trailingNewline)}function Ft(e,t,n){if(t.start.line===t.end.line){const o=Nt(e,t.start.line),l=o.substring(0,t.start.column),r=l.length<t.start.column?l.padEnd(t.start.column,T):l,i=o.substring(t.end.column);return void(e[t.start.line-1]=r+n+i)}const o=n.split(Ot).filter(e=>"\n"!==e&&"\r\n"!==e),l=t.end.line-t.start.line+1;if(o.length!==l)throw new Error(`Mismatch between location and raw string, expected ${l} lines for "${n}"`);for(let n=t.start.line;n<=t.end.line;n++){const l=Nt(e,n),r=n===t.start.line,i=n===t.end.line;let s="";if(r){const e=l.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column,T):e}const a=i?l.substring(t.end.column):"";e[n-1]=s+o[n-t.start.line]+a}}function Mt(e,t,n,o){const l=Nt(e,t),r=l.length<n?l.padEnd(n,T):l.substring(0,n),i=l.substring(n+1);e[t-1]=r+o+i}function Lt(e,t,n,o,l){const r=Nt(e,t),i=r.length<n?r.padEnd(n,T):r.substring(0,n),s=r.substring(o);e[t-1]=i+l+s}function Nt(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]="");return e[t-1]}function Wt(t,n,o){for(const l of t.items){const t=l.item;if(t.value.type===e.InlineTable){const e=n.concat(t.key.value);o.add(zt(e)),Wt(t.value,e,o)}}}function Kt(t,n="",o="asNeeded"){const l=Te(),r=new Set,i=new Set,s=new Set,a=new Set,c=new Set;let u=l,f=[];const m={tables:r,table_arrays:i,defined:s,implicit_tables:a,inline_tables:c};for(const n of t)switch(n.type){case e.Table:h(n);for(const t of n.items)t.type===e.KeyValue&&p(t);break;case e.TableArray:d(n);for(const t of n.items)t.type===e.KeyValue&&p(t);break;case e.KeyValue:p(n)}return l;function h(e){const t=e.key.item.value;try{jt(l,[],t,e.type,m)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const o=zt(t);r.add(o),s.add(o),u=Bt(l,t),f=t}function d(e){const t=e.key.item.value;try{jt(l,[],t,e.type,m)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const o=zt(t);i.add(o),s.add(o),u=function(e,t){const n=Zt(e,t.slice(0,-1)),o=ke(t);n[o]||(n[o]=[]);const l=Te();return n[ke(t)].push(l),l}(l,t),f=t}function p(t){const l=t.key.value;try{jt(u,f,l,t.type,m)}catch(e){const o=e;throw new v(n,t.key.loc.start,o.message)}if(l.length>1)for(let e=1;e<l.length;e++){const t=zt(f.concat(l.slice(0,e)));a.add(t),s.add(t)}let r;try{r=Ut(t.value,o)}catch(e){const o=e;throw new v(n,t.value.loc.start,o.message)}if(t.value.type===e.InlineTable){const e=f.concat(l);c.add(zt(e)),Wt(t.value,e,c)}(l.length>1?Bt(u,l.slice(0,-1)):u)[ke(l)]=r,s.add(zt(f.concat(l)))}}function Ut(t,n="asNeeded"){switch(t.type){case e.InlineTable:const o=Te(),l=new Set,r=new Map;return t.items.forEach(({item:e})=>{const t=e.key.value,i=Ut(e.value,n),s=zt(t);if(l.has(s))throw new Error(`Duplicate key "${s}" in inline table`);for(let e=1;e<t.length;e++){const n=zt(t.slice(0,e));if(l.has(n))throw new Error(`Key "${s}" conflicts with key: "${n}"`)}if(r.has(s)){const e=r.get(s);throw new Error(`Key "${s}" conflicts with key: "${e}"`)}l.add(s);for(let e=1;e<t.length;e++){const n=zt(t.slice(0,e));r.has(n)||r.set(n,s)}(t.length>1?Bt(o,t.slice(0,-1)):o)[ke(t)]=i}),o;case e.InlineArray:return t.items.map(e=>Ut(e.item,n));case e.DateTime:case e.String:return t.value;case e.Integer:return function(e,t="asNeeded"){const n=e.replace(/_/g,"");let o,l=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){const e="+"===n[0]||"-"===n[0]?n[0]:"";l=e+n.slice(e?1:0).toLowerCase()}try{o=BigInt(l)}catch(e){return Number(n)}return!0===t?o:!1===t||o>=BigInt(Number.MIN_SAFE_INTEGER)&&o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):o}(t.raw,n);case e.Float:case e.Boolean:return t.value;default:throw new Error(`Unrecognized value type "${t.type}"`)}}function jt(t,n,o,l,r){const i=n.length>0?zt(n):"",s=new Array(o.length);let a=i;for(let e=0;e<o.length;e++)a=a?a+"."+o[e]:o[e],s[e]=a;const c=s[o.length-1];if(l===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if((l===e.Table||l===e.TableArray)&&r.inline_tables.has(c))throw new Error(`Cannot extend inline table at ${c}`);if(l===e.Table||l===e.TableArray)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if(l===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.table_arrays.has(t))throw new Error(`Cannot traverse Array of Tables at ${t}`)}if((l===e.Table||l===e.TableArray)&&r.implicit_tables.has(c))throw new Error(`Implicit table already defined: ${c}`);if(l===e.KeyValue&&r.implicit_tables.has(c))throw new Error(`Table already defined: ${c}`);if(l===e.KeyValue&&o.length>1)for(let e=1;e<=o.length;e++){const t=s[e-1];if(r.tables.has(t))throw new Error(`Cannot extend explicit table ${t} with dotted keys`)}let u=0;for(const e of o){if(!Ce(t,e))return;if(Vt(t[e]))throw new Error(`Value already defined for ${s[u]}`);const n=s[u];if(Array.isArray(t[e])&&!r.table_arrays.has(n))throw new Error(`Cannot add to static array at ${n}`);const l=u++<o.length-1;t=Array.isArray(t[e])&&l?ke(t[e]):t[e]}const f=c;if(t&&l===e.Table&&r.defined.has(f))throw new Error(`Table already defined: ${f}`);if(t&&l===e.KeyValue&&1===o.length&&r.defined.has(f)&&!Vt(t))throw new Error(`Table already defined: ${f}`);if(t&&l===e.TableArray&&!r.table_arrays.has(f))throw new Error(`Cannot add Array of Tables to table at ${f}`)}function Bt(e,t){const n=Zt(e,t.slice(0,-1)),o=ke(t);return n[o]||(n[o]=Te()),n[o]}function Zt(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=Te()),Array.isArray(e[t])?ke(e[t]):e[t]),e)}function Vt(e){return"object"!=typeof e&&!Ie(e)}function zt(e){return e.join(".")}var qt;function Rt(e){return e.type===qt.Remove}function Pt(e,t,n=[]){return e===t||(l=t,Ie(o=e)&&Ie(l)&&o.toISOString()===l.toISOString())?[]:Array.isArray(e)&&Array.isArray(t)?function(e,t,n=[]){let o=[];const l=e.map(_e),r=t.map(_e);r.forEach((i,s)=>{const a=s>=l.length;if(!a&&l[s]===i)return;const c=l.indexOf(i,s+1);if(!a&&c>-1){o.push({type:qt.Move,path:n,from:c,to:s});const e=l.splice(c,1);return void l.splice(s,0,...e)}const u=!r.includes(l[s]);if(!a&&u)return Oe(o,Pt(e[s],t[s],n.concat(s))),void(l[s]=i);o.push({type:qt.Add,path:n.concat(s)}),l.splice(s,0,i)});for(let e=r.length;e<l.length;e++)o.push({type:qt.Remove,path:n.concat(e)});return o}(e,t,n):Ee(e)&&Ee(t)?function(e,t,n=[]){let o=[];const l=Object.keys(e),r=l.map(t=>_e(e[t])),i=Object.keys(t),s=i.map(e=>_e(t[e])),a=(e,t)=>{if(t.indexOf(e)<0)return!1;const n=l[r.indexOf(e)];return!i.includes(n)};return l.forEach((l,c)=>{const u=n.concat(l);if(i.includes(l))Oe(o,Pt(e[l],t[l],u));else if(a(r[c],s)){const e=i[s.indexOf(r[c])];o.push({type:qt.Rename,path:n,from:l,to:e})}else o.push({type:qt.Remove,path:u})}),i.forEach((e,t)=>{l.includes(e)||a(s[t],r)||o.push({type:qt.Add,path:n.concat(e)})}),o}(e,t,n):[{type:qt.Edit,path:n}];var o,l}function Ht(e,t){if(!t.length)return c(e)&&r(e.item)?e.item:e;if(r(e))return Ht(e.value,t);const i={};let s;if(m(e)&&e.items.some((a,u)=>{try{let f=[];if(r(a))f=a.key.value;else if(o(a))f=a.key.item.value;else if(l(a)){f=a.key.item.value;const e=_e(f);i[e]||(i[e]=0);const t=i[e]++;f=f.concat(t)}else c(a)&&r(a.item)?f=a.item.key.value:c(a)&&(f=[u]);if(f.length&&xe(f,t.slice(0,f.length))){const i=t.slice(f.length);if(n(e)&&l(a)&&i.length>0){const t=a.key.item.value,n=e,r=n.items.findIndex((e,n)=>n>u&&l(e)&&xe(e.key.item.value,t)),c=-1===r?n.items.length:r,f=n.items.slice(u+1,c);s=function(e,t,n,r){try{return Ht(e,t)}catch(e){}const i={};for(const e of r){let r=[];if(o(e)){const t=e.key.item.value;t.length>n.length&&xe(t.slice(0,n.length),n)&&(r=t.slice(n.length))}else if(l(e)){const t=e.key.item.value;if(t.length>n.length&&xe(t.slice(0,n.length),n)){const e=t.slice(n.length),o=_e(e);i[o]||(i[o]=0);const l=i[o]++;r=e.concat(l)}}if(r.length&&xe(r,t.slice(0,r.length)))try{return Ht(e,t.slice(r.length))}catch(e){}}throw new Error(`Node not found at (aot scope) ${t.join(".")}`)}(a,i,t,f)}else s=c(a)&&r(a.item)?t.length===f.length?a:Ht(a.item.value,i):c(a)&&t.length>f.length?Ht(a.item,i):Ht(a,i);return!0}return!1}catch(e){return!1}}),!s)throw new Error(`Node not found at ${t.join(".")}`);return s}function Jt(e,t){try{return Ht(e,t)}catch(e){}}function Yt(e,t){let n,o=t;for(;o.length&&!n;)o=o.slice(0,-1),n=Jt(e,o);if(!n)throw new Error(`Parent not found for ${t.join(".")}`);return n}!function(e){e.Add="Add",e.Edit="Edit",e.Remove="Remove",e.Move="Move",e.Rename="Rename"}(qt||(qt={}));const Gt=new WeakMap,Xt=new WeakMap;function Qt(e,t){const n=e[t].loc.end.line;for(let o=t+1;o<e.length;o++){const t=e[o];if(f(t)&&t.loc.start.line===n)return t;if(!f(t)&&t.loc.start.line>n)return}}function en(e,t,n){for(let o=t+n;o>=0&&o<e.length;o+=n)if(!f(e[o]))return o}function tn(e,t,n){Xt.has(e)||Xt.set(e,e.loc.start.column);const o=e.loc.start.column+n,l=Math.max(t,o)-o;0!==l&&(e.loc.start.column+=l,e.loc.end.column+=l)}function nn(e,t,n){if(!m(e)||0===n)return;const o=e.items,l=o.indexOf(t);if(l<0)return;const r=Qt(o,l);r&&function(e,t){Xt.set(t,t.loc.start.column),Gt.set(t,t.loc.start.column-e.loc.end.column)}(t,r)}function on(e,t=[]){for(const n of e.items)f(n)?t.push(n):(o(n)||l(n))&&on(n,t);return t}function ln(e,t=new Set){for(const n of e.items)r(n)&&u(n.value)&&n.loc.start.line===n.loc.end.line?t.add(n.loc.end.line):(o(n)||l(n))&&ln(n,t);return t}function rn(e){for(const t of e.items)(o(t)||l(t))&&rn(t);let t=e.loc.end.line,n=e.loc.end.column;const r=(e,o)=>{(e>t||e===t&&o>n)&&(t=e,n=o)};(o(e)||l(e))&&r(e.key.loc.end.line,e.key.loc.end.column);for(const t of e.items)r(t.loc.end.line,t.loc.end.column);e.loc.end.line=t,e.loc.end.column=n}function sn(e,t,n){var o,l;const r=n.newLine,i=t.match(/(?:\r\n|\n)+$/u),s=i?i[0]:"",a=s?t.slice(0,-s.length):t,c=a.length?a.split(r):[],u=ln(e),f=(e,t)=>{const n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},m=on(e).filter(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n);return o.trim().length>0&&/\s{2,}$/u.test(o)}).sort((e,t)=>e.loc.start.line-t.loc.start.line),h=[];let d=[];for(const e of m){const t=d[d.length-1];t&&e.loc.start.line!==t.loc.start.line+1?(d.length>0&&h.push(d),d=[e]):d.push(e)}d.length>0&&h.push(d);for(const e of h){if(e.length<2)continue;let t=null!==(o=Xt.get(e[0]))&&void 0!==o?o:e[0].loc.start.column;const n=new Map;for(const t of e){const e=null!==(l=Xt.get(t))&&void 0!==l?l:t.loc.start.column;n.set(e,(n.get(e)||0)+1)}let r=1;for(const[e,o]of n)o>r&&(r=o,t=e);const i=Math.max(...e.map(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e);return t.slice(0,n).trimEnd().length})),s=Math.min(...e.map(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n).trimEnd();return Math.max(1,n-o.length)}));let a=s;const m=e.filter(e=>Gt.has(e)),h=e.some(e=>!u.has(e.loc.start.line));if(m.length>0&&h){const t=Math.min(...e.map(e=>{if(Gt.has(e))return Gt.get(e)||1;const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n).trimEnd();return Math.max(1,n-o.length)}));a=Math.min(a,t)}if(t<i+1){const e=i+a;t=Math.max(t,e)}for(const n of e){const e=n.loc.start.line-1,o=c[e]||"",l=f(o,n),r=o.slice(0,l).trimEnd(),i=Math.max(t,r.length+1);if(l!==i){const t=" ".repeat(i-r.length);c[e]=r+t+n.raw}n.loc.start.column!==i&&(n.loc.start.column=i,n.loc.end.column=i+n.raw.length)}}return rn(e),c.join(r)+s}function an(e,t,n){return cn(me(e),t,yt(n,vt.autoDetectFormat(e))).tomlString}function cn(t,i,s){const f=[...t];let p=1,g=0;for(const e of f){const t=e.loc.end;(t.line>p||t.line===p&&t.column>g)&&(p=t.line,g=t.column)}const w=Kt(f),y={type:e.Document,loc:{start:{line:1,column:0},end:{line:p,column:g}},items:f},v=At(i,yt(Object.assign(Object.assign({},s),{inlineTableStart:void 0}),s)),$=function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Rt(n)){let o=t+1;for(;o<e.length;){const l=e[o];if(Rt(l)&&l.path[0]===n.path[0]&&l.path[1]>n.path[1]){e.splice(o,1),e.splice(t,0,l),t=-1;break}o++}}}return e}(Pt(w,Kt(v.items)));if(0===$.length)return{tomlString:Dt(f,s),document:y};const k=function(e,t,i,s){return i.forEach(i=>{if(function(e){return e.type===qt.Add}(i)){let f=Ht(t,i.path);const h=i.path.slice(0,-1);let p,g=ke(i.path),w=l(f);if(Se(g)&&!w&&!Se(ke(h))){const t=Jt(e,h.concat(0));t&&l(t)&&(w=!0)}if(w&&!l(f)){const e=h.filter(e=>"string"==typeof e);let n=Kt(t.items);for(const e of i.path)n=null==n?void 0:n[e];if(void 0!==n){const t=Xe(e),o=At(n,s);for(const e of o.items)Ke(t,t,e,void 0);Ve(t),f=t}}if(o(f))p=e;else if(w){p=e;const t=e,n=Jt(t,h.concat(g-1)),o=Jt(t,h.concat(g));g=o?t.items.indexOf(o):n?t.items.indexOf(n)+1:t.items.length}else p=Yt(e,i.path),r(p)?p=p.value:c(p)&&r(p.item)?p=p.item.value:c(p)&&u(p.item)&&(p=p.item);if(a(p)){const t=Jt(e,h),n=Jt(e,h.slice(0,-1));if(t&&r(t)&&n){const e=function(e,t,n){if(!a(e)&&!u(e))return 0;const o=d(t.loc),l=n>0,r=n<e.items.length,i=n===e.items.length,s=!!c(t)&&t.comma,f=l&&s&&!r&&i;return o.columns+(l||r?2:0)+(s?1+(f?-1:0):0)}(p,f,g);0!==e&&function(e,t,n){if(!m(e))return;const o=e.items,l=o.indexOf(t);if(l<0)return;const r=Qt(o,l);if(!r)return;const i=r.loc.start.column,s=r.loc.start.line,a=[en(o,l,-1),en(o,l,1)];for(const e of a){if(null==e)continue;const t=Qt(o,e);if(t&&1===Math.abs(t.loc.start.line-s)&&t.loc.start.column===i)return void tn(r,t.loc.start.column,n)}}(n,t,e)}}if(l(p)||a(p)||n(p)){if(a(p)){const e=bt(p);c(f)&&(f.comma=e)}if(void 0!==s.inlineTableStart&&s.inlineTableStart>0&&n(p)&&o(f)){const t=fn(f,e,s);Ke(e,p,f,g);for(const n of t)Ke(e,e,n,void 0)}else{let t=g;if(n(p)&&r(f)){const e=p.items.findIndex(e=>o(e)||l(e));-1!==e&&(t=e)}Ke(e,p,f,t)}}else if(u(p)){const t=$t(p);if(r(f)){const n=ct(f);n.comma=t,Ke(e,p,n)}else Ke(e,p,f)}else if(void 0!==s.inlineTableStart&&s.inlineTableStart>0&&r(f)&&u(f.value)&&o(p)){It([...p.key.item.value,...f.key.value])<s.inlineTableStart?function(e,t,n,o){const l=t.key.item.value,i=[...l,...e.key.value],s=Ge(i);if(u(e.value))for(const t of e.value.items)c(t)&&r(t.item)&&Ke(n,s,t.item,void 0);Ke(n,n,s,void 0),St(t);const a=fn(s,n,o);for(const e of a)Ke(n,n,e,void 0)}(f,p,e,s):Ke(e,p,f)}else if(0===s.inlineTableStart&&r(f)&&u(f.value)&&n(p))Ke(e,p,f,void 0,!0);else{let t=f;c(f)&&(o(p)||n(p))&&(t=f.item),Ke(e,p,t)}}else if(function(e){return e.type===qt.Edit}(i)){let n,l=Ht(e,i.path),f=Ht(t,i.path);const h=Jt(e,i.path.slice(0,-1)),p=function(e,t){for(let n=t.length-1;n>0;n--){const o=Jt(e,t.slice(0,n));if(!o||!r(o)||!u(o.value))continue;const l=Jt(e,t.slice(0,n-1));if(l&&m(l))return{container:l,row:o}}}(e,i.path);if(r(l)&&r(f))un(l.value,f.value),h&&function(e,t,n,o){if(!m(e))return;const l=e.items,r=l.indexOf(t);if(r<0)return;const i=Qt(l,r);if(!i)return;if(n.loc.start.line!==n.loc.end.line)return;if(o.loc.start.line!==o.loc.end.line)return;const s=i.loc.start.column,a=i.loc.start.line,c=[en(l,r,-1),en(l,r,1)];let u;for(const e of c){if(null==e)continue;const t=Qt(l,e);if(t&&1===Math.abs(t.loc.start.line-a)&&t.loc.start.column===s){u=t.loc.start.column;break}}if(null==u)return;const f=d(n.loc);tn(i,u,d(o.loc).columns-f.columns)}(h,l,l.value,f.value),n=l,l=l.value,f=f.value;else if(r(l)&&c(f)&&r(f.item))n=l,l=l.value,f=f.item.value;else if(c(l)&&r(l.item)&&r(f)){const e=l.item;un(e.value,f.value),n=e,l=e.value,f=f.value}else if(c(l)&&c(f)&&r(l.item)&&r(f.item))un(l.item.value,f.item.value),n=l.item,l=l.item.value,f=f.item.value;else if(o(l)){let o=Kt(t.items);for(const e of i.path)o=null==o?void 0:o[e];if(void 0!==o){const t=l.key.item.value,n=t.slice(-1),r=t.slice(0,-1),a=Yt(e,i.path),c=At({[n[0]]:o},s).items[0];if(r.length>0){const t=Ge(r);Ke(e,t,c,0),We(e,a,l,t)}else We(e,a,l,c);return}n=Yt(e,i.path)}else if(n=Yt(e,i.path),r(n)){const t=i.path.slice(0,-1),o=Ht(e,t);r(o)&&a(o.value)&&(n=o.value)}if(p){const e=d(l.loc),t=d(f.loc).columns-e.columns;0!==t&&nn(p.container,p.row,t)}We(e,n,l,f)}else if(Rt(i)){const t=Jt(e,i.path);if(t){let n=Yt(e,i.path);r(n)&&(n=n.value),c(n)&&r(n.item)&&(n=n.item.value),c(n)&&u(n.item)&&(n=n.item),m(n)&&!n.items.includes(t)&&(n=e),je(e,n,t)}else{if(Jt(e,i.path.concat(0))){let t;for(;t=Jt(e,i.path.concat(0));)je(e,e,t)}else Ht(e,i.path)}}else if(function(e){return e.type===qt.Move}(i)){let t=Jt(e,i.path);if(t){h(t)&&(t=t.item),r(t)&&(t=t.value);const n=t.items[i.from];je(e,t,n),Ke(e,t,n,i.to)}else{const t=Ht(e,i.path.concat(i.from));je(e,e,t);const n=Jt(e,i.path.concat(i.to)),o=n?e.items.indexOf(n):e.items.length;Ke(e,e,t,o)}}else if(function(e){return e.type===qt.Rename}(i)){let n=Ht(e,i.path.concat(i.from)),o=Ht(t,i.path.concat(i.to));h(n)&&(n=n.item),h(o)&&(o=o.item),o.key.raw=(f=n.key.raw,o.key.value.map(e=>b.test(e)?e:`"${Je(e,f,"singleline-basic")}"`).join(".")),o.key.loc.end.column=o.key.loc.start.column+o.key.raw.length,We(e,n,n.key,o.key)}var f}),Ve(e),e}(y,v,$,s);return{tomlString:sn(k,Dt(k.items,s),s),document:k}}function un(e,t){if(i(e)&&i(t)){const n=nt(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(s(e)&&s(t)){const n=e.raw,o=t.value,l=Z.createDateWithOriginalFormat(o,n);t.value=l,t.raw=l.toISOString(),t.loc.end.column=t.loc.start.column+t.raw.length}if(a(e)&&a(t)){const n=bt(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}if(u(e)&&u(t)){const n=$t(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}}function fn(e,t,n){const o=[],l=(e,o)=>{var i;for(let s=e.items.length-1;s>=0;s--){const a=e.items[s];if(r(a)&&u(a.value)){const u=[...e.key.item.value,...a.key.value];if(It(u)<(null!==(i=n.inlineTableStart)&&void 0!==i?i:1)&&0!==n.inlineTableStart){const n=Ge(u);for(const e of a.value.items)c(e)&&r(e.item)&&Ke(t,n,e.item,void 0);e.items.splice(s,1),St(e),o.push(n),l(n,o)}}}};return l(e,o),o}function mn(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}class hn{constructor(e,t){var n;const o="string"==typeof e?e:new TextDecoder("utf-8",{fatal:!0}).decode(e);this._currentTomlString=o,this._ast=Array.from(me(o)),this._integersAsBigInt=null!==(n=null==t?void 0:t.integersAsBigInt)&&void 0!==n?n:"asNeeded",this._format=vt.autoDetectFormat(o)}get toTomlString(){return this._currentTomlString}get toJsObject(){return dn(Kt(this._ast,this._currentTomlString,this._integersAsBigInt))}get ast(){return this._ast}patch(e,t){const n=yt(t,this._format),{tomlString:o,document:l}=cn(this._ast,e,n);this._ast=l.items,this._currentTomlString=o}update(e){if(e===this.toTomlString)return;const t=this.toTomlString.split(this._format.newLine),n=wt(e),o=e.split(n);let l=0;for(;l<t.length&&l<o.length&&t[l]===o[l];)l++;let r=0;if(l<t.length&&l<o.length){const e=t[l],n=o[l];for(let t=0;t<Math.max(e.length,n.length);t++)if(e[t]!==n[t]){r=t;break}}let i=l+1;const{truncatedAst:s,lastEndPosition:a}=function(e,t,n){const o={line:t,column:n},l=[];let r=null;for(const t of e){const e=mn(t.loc.end,o)<0,n=mn(t.loc.start,o)<0;if(!e){if(n&&!e)break;break}l.push(t),r=t.loc.end}return{truncatedAst:l,lastEndPosition:r}}(this._ast,i,r),c=a?a.line:1,u=a?a.column+1:0,f=o.slice(c-1);f.length>0&&u>0&&(f[0]=f[0].substring(u));const m=f.join(this._format.newLine);this._ast=Array.from(function*(e,t){for(const t of e)yield t;const n=new N(C(t));for(;!n.next().done;){const e=be(n,t);for(const t of e)yield t}}(s,m)),this._currentTomlString=e,this._format=vt.autoDetectFormat(e)}overwrite(e){e!==this.toTomlString&&(this._ast=Array.from(me(e)),this._currentTomlString=e,this._format=vt.autoDetectFormat(e))}}function dn(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(dn);if(e&&"object"==typeof e){const t={};for(const[n,o]of Object.entries(e))t[n]=dn(o);return t}return e}function pn(e,t){var n;const o="string"==typeof e?e:new TextDecoder("utf-8",{fatal:!0}).decode(e);return Kt(me(o),o,null!==(n=null==t?void 0:t.integersAsBigInt)&&void 0!==n?n:"asNeeded")}function gn(e,t){const n=yt(t,vt.default());return Dt(At(e,n).items,n)}export{V as LocalDate,q as LocalDateTime,z as LocalTime,R as OffsetDateTime,hn as TomlDocument,vt as TomlFormat,pn as parse,an as patch,gn as stringify};
1
+ //! @decimalturn/toml-patch v1.3.0 - https://github.com/DecimalTurn/toml-patch - @license: MIT
2
+ var e,t;function n(t){return t.type===e.Document}function o(t){return t.type===e.Table}function l(t){return t.type===e.TableArray}function r(t){return t.type===e.KeyValue}function i(t){return t.type===e.String}function s(t){return t.type===e.DateTime}function a(t){return t.type===e.InlineArray}function c(t){return t.type===e.InlineItem}function u(t){return t.type===e.InlineTable}function f(t){return t.type===e.Comment}function m(e){return n(e)||o(e)||l(e)||u(e)||a(e)}function h(t){return function(t){return t.type===e.TableKey}(t)||function(t){return t.type===e.TableArrayKey}(t)||c(t)}function d(e){return{lines:e.end.line-e.start.line+1,columns:e.end.column-e.start.column}}function p(e,t){const n=Array.isArray(e)?e:g(e);if(0===n.length)return{line:1,column:t};let o=0,l=n.length-1;for(;o<l;){const e=o+l>>>1;n[e]<t?o=e+1:l=e}n[o]<t&&o++;const r=o+1;return{line:r,column:t-(n[r-2]+1||0)}}function g(e){const t=[];for(let n=0;n<e.length;n++){const o=e.charCodeAt(n);10===o?t.push(n):13===o&&(10===e.charCodeAt(n+1)?(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 y(e){return{start:w(e.start),end:w(e.end)}}!function(e){e.Document="Document",e.Table="Table",e.TableKey="TableKey",e.TableArray="TableArray",e.TableArrayKey="TableArrayKey",e.KeyValue="KeyValue",e.Key="Key",e.String="String",e.Integer="Integer",e.Float="Float",e.Boolean="Boolean",e.DateTime="DateTime",e.InlineArray="InlineArray",e.InlineItem="InlineItem",e.InlineTable="InlineTable",e.Comment="Comment"}(e||(e={}));class v extends Error{constructor(e,t,n){let o=`Error parsing TOML (${t.line}, ${t.column+1}):\n`;if(e){const n=function(e,t){const n=g(e),o=void 0!==n[t.line-2]?n[t.line-2]+1:0,l=n[t.line-1]||e.length;return e.substring(o,l)}(e,t),l=`${function(e,t=" "){return t.repeat(e)}(t.column)}^`;n&&(o+=`${n}\n${l}\n`)}o+=n,super(o),this.line=t.line,this.column=t.column}}!function(e){e.Bracket="Bracket",e.Curly="Curly",e.Equal="Equal",e.Comma="Comma",e.Dot="Dot",e.Comment="Comment",e.Literal="Literal"}(t||(t={}));const b=/^[\w-]+$/,$='"',k="'",T=" ",S=/[\w,\d,",',+,\-,_]/,I=10,A=13,E=127;function*C(e){const n=e.length;let o=0;const l=[],r=(e,t)=>({start:p(l,e),end:p(l,t)});for(;o<n;){const c=e.charCodeAt(o);if((c<=31||c===E)&&9!==c&&c!==A&&c!==I)throw new v(e,p(l,o),`Control char 0x${c.toString(16).toUpperCase().padStart(2,"0")} not allowed`);if(c===A&&(o+1>=n||e.charCodeAt(o+1)!==I))throw new v(e,p(l,o),"Standalone CR; must be CRLF or LF");if(32===c||9===c||c===A);else if(c===I)l.push(o);else if(91===c||93===c)yield{type:t.Bracket,raw:e[o],loc:r(o,o+1)};else if(123===c||125===c)yield{type:t.Curly,raw:e[o],loc:r(o,o+1)};else if(61===c)yield{type:t.Equal,raw:"=",loc:r(o,o+1)};else if(44===c)yield{type:t.Comma,raw:",",loc:r(o,o+1)};else if(46===c)yield{type:t.Dot,raw:".",loc:r(o,o+1)};else if(35===c)yield i();else{const t=x(e,o,k)||x(e,o,$);t?yield s(t):yield a()}o++}function i(){const i=o;for(;o+1<n;){const t=e.charCodeAt(o+1);if(t===I||t===A)break;o++;const n=e.charCodeAt(o);if((n<=31||n===E)&&9!==n)throw new v(e,p(l,o),`Control char 0x${n.toString(16).toUpperCase().padStart(2,"0")} not allowed`)}return{type:t.Comment,raw:e.slice(i,o+1),loc:r(i,o+1)}}function s(i){const s=o,a=i+i+i;for(o+=3;o<n;){if(x(e,o,i)){let t=3;for(;e[o+t]===i;)t++;if(t>=6)throw new v(e,p(l,o),`Invalid multiline string: ${t} consecutive ${i} characters`);if(3===t){o+=2;break}o+=t-3,o+=2;break}const t=e.charCodeAt(o);if(t===A&&(o+1>=n||e.charCodeAt(o+1)!==I))throw new v(e,p(l,o),"Standalone CR in multiline string; must be CRLF or LF");if((t<=31||t===E)&&9!==t&&t!==I&&t!==A){const n=i===$?"multiline basic strings":"multiline literal strings",r=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let s="";0===t?s="Null":t===E&&(s="DEL");const a=s?`${s} (${r}) not allowed in ${n}`:`Control char ${r} not allowed in ${n}`;throw new v(e,p(l,o),a)}t===I&&l.push(o),o++}if(o>=n){if(i===$){let t=0,r=n-1;for(;r>=0&&"\\"===e[r];)t++,r--;if(t>0&&t%2!=0)throw new v(e,p(l,o),`Unterminated multiline ${a} (possible escape issue)`)}throw new v(e,p(l,o),`Unterminated multiline ${a}`)}return{type:t.Literal,raw:e.slice(s,o+1),loc:r(s,o+1)}}function a(){const i=e[o];if(!S.test(i))throw new v(e,p(l,o),`Unexpected char "${i}"`);const s=o;let a=i===$,c=i===k;for(;o<n&&!(o+1>=n);){const t=e.charCodeAt(o+1);if(!(a||c||32!==t&&9!==t&&t!==I&&t!==A&&44!==t&&46!==t&&93!==t&&125!==t&&61!==t&&35!==t))break;if(o++,!a&&!c){const t=e.charCodeAt(o);if(t<=31||t===E)throw new v(e,p(l,o),`Control char 0x${t.toString(16).toUpperCase().padStart(2,"0")} not allowed in unquoted value`)}if(a||c){const t=e.charCodeAt(o);if((t<=31||t===E)&&9!==t){const n=a?"basic strings":"literal strings",r=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let i="";t===I?i="Newline":t===A?i="Carriage return":0===t?i="Null":t===E&&(i="DEL");const s=i?`${i} (${r}) not allowed in ${n}`:`Control char ${r} not allowed in ${n}`;throw new v(e,p(l,o),s)}}const r=e[o];if(r===$&&(a=!a),r!==k||a||(c=!c),o+1>=n)break;if(a&&"\\"===r){const t=e[o+1];t!==$&&"\\"!==t||o++}}if(a||c)throw new v(e,p(l,s),`Expected close of string with ${a?$:k}`);return{type:t.Literal,raw:e.slice(s,o+1),loc:r(s,o+1)}}}function x(e,t,n){if(!n)return!1;if(!(e[t]===n&&e[t+1]===n&&e[t+2]===n))return!1;if(n===k)return n;let o=0,l=t-1;for(;l>=0&&"\\"===e[l];)o++,l--;if(0===o)return n;return!(o%2!=0)&&n}const _=new Int8Array(128);_.fill(-1);for(let e=0;e<10;e++)_[48+e]=e;for(let e=0;e<6;e++)_[65+e]=10+e,_[97+e]=10+e;function O(e){const t=e.charCodeAt(0);return t<128&&-1!==_[t]}function D(e,t){return _[e.charCodeAt(t)]<<12|_[e.charCodeAt(t+1)]<<8|_[e.charCodeAt(t+2)]<<4|_[e.charCodeAt(t+3)]}function F(e){return e.startsWith("'''")?L(e.slice(3,e.length-3)):e.startsWith(k)?e.slice(1,e.length-1):e.startsWith('"""')?M(L(e.slice(3,e.length-3)),!0):e.startsWith($)?M(e.slice(1,e.length-1),!1):e}function M(e,t){const n=e.length;if(!t&&-1===e.indexOf("\\"))return e;const o=[];let l=0;for(let r=0;r<n;r++){if("\\"!==e[r])continue;if(r>l&&o.push(e.slice(l,r)),r++,r>=n)throw new Error("Trailing backslash");const i=e[r];switch(i){case"b":o.push("\b");break;case"t":o.push("\t");break;case"n":o.push("\n");break;case"f":o.push("\f");break;case"r":o.push("\r");break;case'"':o.push('"');break;case"\\":o.push("\\");break;case"e":o.push("");break;case"u":{if(r+4>n||!O(e[r+1])||!O(e[r+2])||!O(e[r+3])||!O(e[r+4]))throw new Error(`Invalid Unicode escape: \\u${e.slice(r+1,r+5)}`);const t=D(e,r+1);if(t>=55296&&t<=57343)throw new Error(`Invalid \\u${e.slice(r+1,r+5)}: surrogates not allowed`);o.push(String.fromCharCode(t)),r+=4;break}case"U":{if(r+8>n)throw new Error(`Invalid Unicode escape: \\U${e.slice(r+1,r+9)}`);for(let t=1;t<=8;t++)if(!O(e[r+t]))throw new Error(`Invalid Unicode escape: \\U${e.slice(r+1,r+9)}`);const t=parseInt(e.slice(r+1,r+9),16);o.push(String.fromCodePoint(t)),r+=8;break}case"x":{if(r+2>n||!O(e[r+1])||!O(e[r+2]))throw new Error(`Invalid hex escape: \\x${e.slice(r+1,r+3)}`);const t=_[e.charCodeAt(r+1)]<<4|_[e.charCodeAt(r+2)];o.push(String.fromCharCode(t)),r+=2;break}default:if(t&&("\n"===i||"\r"===i||" "===i||"\t"===i)){let t="\n"===i||"\r"===i,o=r;for(;o<n&&(" "===e[o]||"\t"===e[o]||"\n"===e[o]||"\r"===e[o]);)"\n"!==e[o]&&"\r"!==e[o]||(t=!0),o++;if(!t)throw new Error(`Invalid escape sequence: \\${i}`);r=o-1;break}throw new Error(`Invalid escape sequence: \\${i}`)}l=r+1}return 0===l?e:(l<n&&o.push(e.slice(l)),o.join(""))}function L(e){return 10===e.charCodeAt(0)?e.slice(1):13===e.charCodeAt(0)&&10===e.charCodeAt(1)?e.slice(2):e}class W{constructor(e){this.iterator=e,this.index=-1,this.value=void 0,this.done=!1,this.peeked=null}next(){var e;if(this.done)return N();const t=this.peeked||this.iterator.next();return this.index+=1,this.value=t.value,this.done=null!==(e=t.done)&&void 0!==e&&e,this.peeked=null,t}peek(){return this.done?N():(this.peeked||(this.peeked=this.iterator.next()),this.peeked)}[Symbol.iterator](){return this}}const B=Object.freeze({value:void 0,done:!0});function N(){return B}function U(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 K(e,t,n=/\.(\d+)\s*$/){if(t&&t.includes(".")){const o=t.match(n),l=o?o[1].length:3;return"."+String(e).padStart(3,"0").slice(0,l)}return e>0?"."+String(e).padStart(3,"0").replace(/0+$/,""):""}function j(e){if("Z"===e)return 0;const t="+"===e[0]?1:-1,[n,o]=e.slice(1).split(":");return t*(60*parseInt(n)+parseInt(o))}class Z{static createDateWithOriginalFormat(e,t){if(Z.IS_DATE_ONLY.test(t)){if(0!==e.getUTCHours()||0!==e.getUTCMinutes()||0!==e.getUTCSeconds()||0!==e.getUTCMilliseconds()){if(e instanceof R)return e;let t=e.toISOString().replace("Z","");return t=t.replace(/\.000$/,""),new z(t,!1)}const t=e.toISOString().split("T")[0];return new V(t)}if(Z.IS_TIME_ONLY.test(t)){if(e instanceof q)return e;{const n=U(e),o=K(n.ms,t);return new q(`${n.hours}:${n.minutes}:${n.seconds}${o}`,t)}}if(Z.IS_LOCAL_DATETIME_T.test(t)){const n=U(e),o=K(n.ms,t);return new z(`${n.year}-${n.month}-${n.day}T${n.hours}:${n.minutes}:${n.seconds}${o}`,!1,t)}if(Z.IS_LOCAL_DATETIME_SPACE.test(t)){const n=U(e),o=K(n.ms,t);return new z(`${n.year}-${n.month}-${n.day} ${n.hours}:${n.minutes}:${n.seconds}${o}`,!0,t)}if(Z.IS_OFFSET_DATETIME_T.test(t)||Z.IS_OFFSET_DATETIME_SPACE.test(t)){const n=t.match(/([+-]\d{2}:\d{2}|[Zz])$/),o=n?"z"===n[1]?"Z":n[1]:"Z",l=Z.IS_OFFSET_DATETIME_SPACE.test(t),r=U(new Date(e.getTime()+6e4*j(o))),i=l?" ":"T",s=K(r.ms,t,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),a=`${r.year}-${r.month}-${r.day}${i}${r.hours}:${r.minutes}:${r.seconds}${s}${o}`;return new R(a,l)}return e}}Z.IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/,Z.IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,Z.IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,Z.IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,Z.IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/,Z.IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;class V extends Date{constructor(e){super(e)}toISOString(){const e=U(this);return`${e.year}-${e.month}-${e.day}`}}class q extends Date{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(){const e=U(this);return`${e.hours}:${e.minutes}:${e.seconds}${K(e.ms,this.originalFormat)}`}}class z extends Date{constructor(e,t=!1,n){let o=e;/\d{2}:\d{2}:\d{2}/.test(e)||(o=e.replace(/(\d{2}:\d{2})([\s\-+TZ]|$)/,"$1:00$2")),super(o.replace(" ","T")+"Z"),this.useSpaceSeparator=!1,this.useSpaceSeparator=t,this.originalFormat=n||e}toISOString(){const e=U(this),t=this.useSpaceSeparator?" ":"T";return`${e.year}-${e.month}-${e.day}${t}${e.hours}:${e.minutes}:${e.seconds}${K(e.ms,this.originalFormat)}`}}class R extends Date{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=!1,this.useSpaceSeparator=t,this.originalFormat=e;const o=e.match(/([+-]\d{2}:\d{2}|[Zz])$/);o&&(this.originalOffset="z"===o[1]?"Z":o[1])}toISOString(){if(this.originalOffset){const e=U(new Date(this.getTime()+6e4*j(this.originalOffset))),t=this.useSpaceSeparator?" ":"T",n=K(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}`}const e=super.toISOString();return this.useSpaceSeparator?e.replace("T"," "):e}}const P=Z,H="true",J=/e/i,Y=/_/g,G=/^[+-]?inf$/,X=/^[+-]?nan$/,Q=/^[+-]?0x/i;function ee(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||95===e||45===e}const te=/^[+-]?0o/i,ne=/^[+-]?0b/i;function oe(e,t,n){for(let o=0;o<e.length;o++)if(!ee(e.charCodeAt(o)))throw new v(t,{line:n.line,column:n.column+o},`Invalid bare key char '${e[o]}'`)}function le(e,t,n){if(e.startsWith('"""')||e.startsWith("'''"))throw new v(t,n,"Multiline strings cannot be keys")}function re(e,t,n){try{return F(e)}catch(e){throw new v(t,n,e.message)}}function ie(e,t,n,o=!0){if(e.endsWith("_"))throw new v(t,n,"Underscore must be between digits");if(o?/^[+-]?_/.test(e):e.startsWith("_"))throw new v(t,n,"Underscore must be between digits");if(/__/.test(e))throw new v(t,n,"Consecutive underscores not allowed")}function se(e,t,n,o){const l=e.replace(Y,"");if(/^[+-]?0\d/.test(l)&&!Q.test(e)&&!te.test(e)&&!ne.test(e))throw new v(t,n,`Leading zeros are not allowed in ${o}`)}function ae(e,t,n,o){if(/_[eE]/.test(e))throw new v(n,o,"Underscore before exponent is not allowed");if(/[eE][+-]?_/.test(e))throw new v(n,o,"Underscore at start of exponent is not allowed");if(/[eE][+-]?$/.test(e))throw new v(n,o,`Invalid float "${t}": incomplete exponent`);if(/[eE][+-]?.*\./.test(e))throw new v(n,o,`Invalid float "${t}": decimal point not allowed in exponent`)}function ce(e,t,n,o,l,r){if(2!==e.length)throw new v(l,r,`"${o}": hour must be 2 digits`);if(2!==t.length)throw new v(l,r,`"${o}": minute must be 2 digits`);if(n&&2!==n.length)throw new v(l,r,`"${o}": second must be 2 digits`)}function ue(e,t,n,o,l,r){if(void 0!==e){const t=parseInt(e,10);if(t<0||t>23)throw new v(l,r,`"${o}": hour must be 00-23`)}if(void 0!==t){const e=parseInt(t,10);if(e<0||e>59)throw new v(l,r,`"${o}": minute must be 00-59`)}if(void 0!==n){const e=parseInt(n,10);if(e<0||e>60)throw new v(l,r,`"${o}": second must be 00-60`)}}function fe(e,t,n,o,l,r,i){const s=o[0]+o[1].toUpperCase();if(new RegExp("^[+\\-]?"+s.replace(/([[\]])/g,"\\$1")).test(e))throw new v(t,n,`${r} prefix must be lowercase "${o}"`);if(new RegExp("^[+\\-]?"+o+"_","i").test(e))throw new v(t,n,"Underscore must be between digits");const a=new RegExp("^[+\\-]?"+o,"i"),c=e.replace(a,"");if(!c||"_"===c||c.startsWith("_"))throw new v(t,n,`Incomplete ${r.toLowerCase()} number`);const u=c.replace(/_/g,"");if(!l.test(u))throw new v(t,n,null!=i?i:`Invalid ${r.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new v(t,n,`${r} numbers cannot have a sign prefix`)}function*me(e){const t=new W(C(e));for(;!t.next().done;){const n=be(t,e);for(const e of n)yield e}}function he(t){return{type:e.Comment,loc:t.value.loc,raw:t.value.raw}}function de(n,o){const l=n.peek().done||n.peek().value.type!==t.Bracket?e.Table:e.TableArray,r=l===e.Table;if(r&&"["!==n.value.raw)throw new v(o,n.value.loc.start,`Expected table opening "[", found ${n.value.raw}`);if(!r){const e=n.peek();if(e.done)throw new v(o,n.value.loc.start,'Expected "[[" for Array of Tables, found end of input');if("["!==n.value.raw||"["!==e.value.raw)throw new v(o,n.value.loc.start,`Expected "[[", found ${n.value.raw+e.value.raw}`);const t=n.value,l=e.value;if(t.loc.end.line!==l.loc.start.line||t.loc.end.column!==l.loc.start.column)throw new v(o,t.loc.start,'"[[" brackets must be adjacent (no whitespace)')}const i=r?{type:e.TableKey,loc:n.value.loc}:{type:e.TableArrayKey,loc:n.value.loc};if(n.next(),l===e.TableArray&&n.next(),n.done)throw new v(o,i.loc.start,"Expected table key, reached end of file");if(n.value.type===t.Bracket&&"]"===n.value.raw)throw new v(o,n.value.loc.start,l===e.TableArray?"Array of Tables header [[]] requires a table name":"Table header [] requires a table name");const s=n.value.raw;le(s,o,n.value.loc.start);let a;for(s.startsWith('"')||s.startsWith("'")||oe(s,o,n.value.loc.start),a=[re(n.value.raw,o,n.value.loc.start)],i.item={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:a};!n.peek().done&&n.peek().value.type===t.Dot;){n.next();const e=n.value;n.next();const t=n.value.raw;t.startsWith('"')||t.startsWith("'")||oe(t,o,n.value.loc.start);const l=" ".repeat(e.loc.start.column-i.item.loc.end.column),r=" ".repeat(n.value.loc.start.column-e.loc.end.column);i.item.loc.end=n.value.loc.end,i.item.raw+=`${l}.${r}${n.value.raw}`;try{i.item.value.push(F(n.value.raw))}catch(e){const t=e;throw new v(o,n.value.loc.start,t.message)}}if(n.next(),!n.done){const e=i.loc.start.line;if(n.value.loc.start.line!==e)throw new v(o,n.value.loc.start,r?"Table header must be single-line":"Array of Tables header must be single-line")}if(r&&(n.done||"]"!==n.value.raw))throw new v(o,n.done?i.item.loc.end:n.value.loc.start,`Expected table closing "]", found ${n.done?"end of file":n.value.raw}`);if(!r&&(n.done||n.peek().done||"]"!==n.value.raw||"]"!==n.peek().value.raw))throw new v(o,n.done||n.peek().done?i.item.loc.end:n.value.loc.start,`Expected "]]" closing, found ${n.done||n.peek().done?"end of file":n.value.raw+n.peek().value.raw}`);if(!r){const e=n.value,t=n.peek().value;if(e.loc.end.line!==t.loc.start.line||e.loc.end.column!==t.loc.start.column)throw new v(o,e.loc.start,'"]]" brackets must be adjacent (no whitespace)')}if(r||n.next(),i.loc.end=n.value.loc.end,!n.peek().done){const e=n.peek().value;if(e.loc.start.line===i.loc.end.line&&e.type!==t.Comment)throw new v(o,e.loc.start,`Extra content after ${r?"table":"Array of Tables"} header`)}let c=[];for(;!n.peek().done&&n.peek().value.type!==t.Bracket;){n.next();const e=be(n,o);for(let t=0;t<e.length;t++)c.push(e[t])}return{type:r?e.Table:e.TableArray,loc:{start:w(i.loc.start),end:c.length?w(c[c.length-1].loc.end):w(i.loc.end)},key:i,items:c}}function pe(t,n){const o=re(t.value.raw,n,t.value.loc.start);return{type:e.String,loc:t.value.loc,raw:t.value.raw,value:o}}function ge(t){return{type:e.Boolean,loc:t.value.loc,value:t.value.raw===H}}function we(n,o){let l,r=n.value.loc,i=n.value.raw;if(!n.peek().done&&n.peek().value.type===t.Literal&&P.IS_FULL_DATE.test(i)&&P.IS_FULL_TIME.test(n.peek().value.raw)){const e=r.start;n.next(),r={start:e,end:n.value.loc.end},i+=` ${n.value.raw}`}if(!n.peek().done&&n.peek().value.type===t.Dot){const e=r.start;if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new v(o,n.value.loc.end,"Expected fractional value for DateTime");n.next(),r={start:e,end:n.value.loc.end},i+=`.${n.value.raw}`}if(function(e,t,n){if(/\.([Zz]|[+-])/.test(e))throw new v(t,n,`"${e}": fractional seconds needs digit after dot`);if(/[+-]$/.test(e))throw new v(t,n,`"${e}": offset needs HH:MM`);const o=/\d{2}:\d{2}/.test(e),l=o?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(l){const e=l[0],o=l[2],r=l[3],i=l[4];if(":"!==r)throw new v(t,n,`Offset "${e}": missing colon separator`);if(2!==o.length)throw new v(t,n,`Offset "${e}": hour must be 2 digits`);if(!i||0===i.length)throw new v(t,n,`Offset "${e}": minute required`);if(2!==i.length)throw new v(t,n,`Offset "${e}": minute must be 2 digits`);const s=parseInt(o,10);if(s<0||s>23)throw new v(t,n,`Offset "${e}": hour must be 00-23`);const a=parseInt(i,10);if(a<0||a>59)throw new v(t,n,`Offset "${e}": minute must be 00-59`)}const r=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/;if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!r.test(e)){if(/^\d{4}-\d{2}-\d{2}T$/.test(e))throw new v(t,n,`"${e}": 'T' requires time component`);if(/^\d{4}-\d{2}-\d{2}[a-su-zA-SU-Z]/.test(e))throw new v(t,n,`Invalid date "${e}": unexpected character after date`);if(/^\d{4}-\d{2}-\d{2}\d{2}:\d{2}/.test(e))throw new v(t,n,`"${e}": missing 'T' or space separator`);throw new v(t,n,`Invalid datetime "${e}"`)}const i=e.match(/^(\d+)-/);if(i&&4!==i[1].length)throw new v(t,n,`"${e}": year must be 4 digits`);const s=/^(\d+)-(\d+)-(\d+)/,a=e.match(s);if(a){const[,,o,l]=a;if(2!==o.length)throw new v(t,n,`"${e}": month must be 2 digits`);if(2!==l.length)throw new v(t,n,`"${e}": day must be 2 digits`)}const c=/[T ](\d+):(\d+)(?::(\d+))?/,u=e.match(c);if(u){const[,o,l,r]=u;ce(o,l,r,e,t,n)}const f=/^(\d+):(\d+)(?::(\d+))?/,m=e.match(f);if(m&&!a){const[,o,l,r]=m;ce(o,l,r,e,t,n)}const h=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),d=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(h){const[,o,l,r,i,s,a]=h,c=parseInt(l,10);if(c<1||c>12)throw new v(t,n,`"${e}": month must be 01-12`);const u=parseInt(r,10);if(u<1||u>31)throw new v(t,n,`"${e}": day must be 01-31`);const f=function(e,t){const n=[31,28,31,30,31,30,31,31,30,31,30,31];if(2===t){return e%4==0&&e%100!=0||e%400==0?29:28}return n[t-1]}(parseInt(o,10),c);if(u>f)throw new v(t,n,`"${e}": day ${r} invalid for ${o}-${l}`);ue(i,s,a,e,t,n)}else if(d){const[,o,l,r]=d;ue(o,l,r,e,t,n)}}(i,o,r.start),P.IS_FULL_DATE.test(i))l=P.IS_DATE_ONLY.test(i)?new V(i):P.IS_LOCAL_DATETIME_T.test(i)?new z(i,!1):P.IS_LOCAL_DATETIME_SPACE.test(i)?new z(i,!0):P.IS_OFFSET_DATETIME_T.test(i)?new R(i,!1):P.IS_OFFSET_DATETIME_SPACE.test(i)?new R(i,!0):new Date(i.replace(" ","T"));else if(P.IS_TIME_ONLY.test(i))l=new q(i,i);else{const[e]=(new Date).toISOString().split("T");l=new Date(`${e}T${i}`)}return{type:e.DateTime,loc:r,raw:i,value:l}}function ye(n,o){let l,r=n.value.loc,i=n.value.raw;if(G.test(i))l=i.startsWith("-")?-1/0:1/0;else if(X.test(i))l=NaN;else if(n.peek().done||n.peek().value.type!==t.Dot){if(ie(i,o,r.start),ae(i,i,o,r.start),!n.peek().done&&n.peek().value.type===t.Dot)throw new v(o,n.peek().value.loc.start,`Float "${i}.": dot after exponent`);se(i,o,r.start,"the integer part of a float"),l=Number(i.replace(Y,""))}else{const e=r.start;{if(J.test(i)&&!Q.test(i))throw new v(o,r.start,`Float "${i}": dot after exponent`);const e=i;se(e,o,r.start,"the integer part of a float");const t=e.replace(/^[+-]/,"");if(""===t||"_"===t)throw new v(o,r.start,"Float: digit required before dot");ie(e,o,r.start)}if(n.next(),n.peek().done||n.peek().value.type!==t.Literal)throw new v(o,n.value.loc.end,"Expected fraction value for Float");n.next(),i+=`.${n.value.raw}`,r={start:e,end:n.value.loc.end};{const e=n.value.raw;if(!/^\d/.test(e))throw new v(o,n.value.loc.start,`Float: fraction must start with digit, found "${e}"`);ie(e,o,n.value.loc.start,!1),ae(e,i,o,n.value.loc.start)}l=Number(i.replace(Y,""))}if(Number.isNaN(l)&&!X.test(i))throw new v(o,r.start,`Invalid float "${i}"`);return{type:e.Float,loc:r,raw:i,value:l}}function ve(t,n){const o=t.value.raw,l=t.value.loc;if(/^\d{1,}-\d{1,}/.test(o)||/^\d{1,}:\d{1,}/.test(o)||/^\d{6}-\d{2}$/.test(o))throw new v(n,l.start,`Invalid integer "${o}"`);if("-0"===o||"+0"===o)return{type:e.Integer,loc:l,raw:o,value:0};if(/^[+-]{2,}/.test(o))throw new v(n,l.start,"Double sign is not allowed in integers");se(o,n,l.start,"decimal integers"),ie(o,n,l.start),function(e,t,n){if(Q.test(e)||te.test(e)||ne.test(e))return;const o=e.replace(/^[+-]/,"").replace(/_/g,"");if(!/^[0-9]+$/.test(o))throw new v(t,n,`Invalid integer "${e}"`)}(o,n,l.start);let r=10;Q.test(o)?(r=16,fe(o,n,l.start,"0x",/^[0-9a-fA-F]+$/,"Hexadecimal")):te.test(o)?(r=8,fe(o,n,l.start,"0o",/^[0-7]+$/,"Octal","Invalid octal digits (must be 0-7)")):ne.test(o)&&(r=2,fe(o,n,l.start,"0b",/^[01]+$/,"Binary","Invalid binary digits (must be 0 or 1)"));const i=parseInt(o.replace(Y,"").replace(te,"").replace(ne,""),r);if(Number.isNaN(i))throw new v(n,l.start,`Invalid integer "${o}"`);return{type:e.Integer,loc:l,raw:o,value:i}}function be(n,o){if(n.value.type===t.Comment)return[he(n)];if(n.value.type===t.Bracket)return[de(n,o)];if(n.value.type===t.Literal)return function(n,o){const l=n.value.raw;if(l.endsWith(":"))throw new v(o,{line:n.value.loc.start.line,column:n.value.loc.start.column+[...l].length-1},"Use '=' to separate keys and values, not ':'");le(l,o,n.value.loc.start);l.startsWith('"')||l.startsWith("'")||oe(l,o,n.value.loc.start);let r;r=[re(n.value.raw,o,n.value.loc.start)];const i={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:r};for(;!n.peek().done&&n.peek().value.type===t.Dot;){n.next(),n.next();const e=n.value.raw;le(e,o,n.value.loc.start);e.startsWith('"')||e.startsWith("'")||oe(e,o,n.value.loc.start),i.loc.end=n.value.loc.end,i.raw+=`.${n.value.raw}`,i.value.push(re(n.value.raw,o,n.value.loc.start))}if(n.next(),!n.done&&n.value.loc.start.line!==i.loc.end.line)throw new v(o,n.value.loc.start,'"=" must be on same line as key');if(n.done||n.value.type!==t.Equal){if(!n.done&&":"===n.value.raw)throw new v(o,n.value.loc.start,"Use '=' to separate keys and values, not ':'");throw new v(o,n.done?i.loc.end:n.value.loc.start,'Expected "=" for key-value')}const s=n.value.loc.start.column,a=n.value.loc.start.line;if(n.next(),n.done)throw new v(o,i.loc.start,"Expected value, reached EOF");if(n.value.loc.start.line!==a)throw new v(o,n.value.loc.start,"Value must be on same line as '='");if(n.done)throw new v(o,i.loc.start,"Expected value for key-value");const c=$e(n,o),u=c[0];if(!n.peek().done){const l=n.peek().value;if(l.type===t.Dot&&l.loc.start.line===u.loc.end.line&&(u.type===e.Float||u.type===e.Integer))throw new v(o,l.loc.start,"Invalid number: multiple decimal points not allowed");if((l.type===t.Literal||l.type===t.Bracket)&&l.loc.start.line===u.loc.end.line)throw new v(o,l.loc.start,"Key/value pairs must be separated by a newline")}return c[0]={type:e.KeyValue,key:i,value:u,loc:{start:w(i.loc.start),end:w(u.loc.end)},equals:s},c}(n,o);throw n.value.type===t.Equal?new v(o,n.value.loc.start,"Missing key before '='"):new v(o,n.value.loc.start,`Unexpected token "${n.value.type}"`)}function $e(n,o){if(n.value.type===t.Literal){const e=n.value.raw;return e[0]===$||e[0]===k?[pe(n,o)]:e===H||"false"===e?[ge(n)]:/^\d/.test(e)&&(/^\d{1,}-\d{1,}/.test(e)||/^\d{1,}:\d{1,}/.test(e))?[we(n,o)]:!n.peek().done&&n.peek().value.type===t.Dot||G.test(e)||X.test(e)||J.test(e)&&!Q.test(e)?[ye(n,o)]:[ve(n,o)]}if(n.value.type===t.Curly){const[l,r]=function(n,o){if("{"!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "{" for inline table');const l={type:e.InlineTable,loc:n.value.loc,items:[]},r=[];n.next();for(;!n.done&&(n.value.type!==t.Curly||"}"!==n.value.raw);){if(n.value.type===t.Comment){r.push(he(n)),n.next();continue}if(n.value.type===t.Comma){const e=l.items[l.items.length-1];if(!e)throw new v(o,n.value.loc.start,"Leading comma in inline table");if(e.comma)throw new v(o,n.value.loc.start,"Consecutive commas in inline table");e.comma=!0,e.loc.end=n.value.loc.start,n.next();continue}const i=l.items[l.items.length-1];if(i&&!i.comma)throw new v(o,n.value.loc.start,"Missing comma between inline table items");const s=be(n,o),a=s[0];if(a.type===e.KeyValue){l.items.push({type:e.InlineItem,loc:y(a.loc),item:a,comma:!1});for(let e=1;e<s.length;e++)r.push(s[e])}n.next()}if(n.done||n.value.type!==t.Curly||"}"!==n.value.raw)throw new v(o,n.done?l.loc.start:n.value.loc.start,'Expected "}"');return l.loc.end=n.value.loc.end,[l,r]}(n,o);return[l,...r]}if(n.value.type===t.Bracket){const[l,r]=function(n,o){if("["!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "[" for inline array');const l={type:e.InlineArray,loc:n.value.loc,items:[]},r=[];n.next();for(;!n.done&&(n.value.type!==t.Bracket||"]"!==n.value.raw);){if(n.value.type===t.Comma){const e=l.items[l.items.length-1];if(!e)throw new v(o,n.value.loc.start,"Leading comma in array");if(e.comma)throw new v(o,n.value.loc.start,"Consecutive commas in array");e.comma=!0,e.loc.end=n.value.loc.start}else if(n.value.type===t.Comment)r.push(he(n));else{const t=l.items[l.items.length-1];if(t&&!t.comma)throw new v(o,n.value.loc.start,"Missing comma between array elements");const i=$e(n,o),s=i[0];l.items.push({type:e.InlineItem,loc:y(s.loc),item:s,comma:!1});for(let e=1;e<i.length;e++)r.push(i[e])}n.next()}if(n.done||n.value.type!==t.Bracket||"]"!==n.value.raw)throw new v(o,n.done?l.loc.start:n.value.loc.start,'Expected "]"');return l.loc.end=n.value.loc.end,[l,r]}(n,o);return[l,...r]}throw n.value.type===t.Dot?new v(o,n.value.loc.start,"Number cannot start with a dot"):new v(o,n.value.loc.start,"Unrecognized token type")}function ke(e){return e[e.length-1]}function Te(){return Object.create(null)}function Se(e){return"number"==typeof e&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function Ie(e){return"[object Date]"===Object.prototype.toString.call(e)}function Ae(e){return e&&"object"==typeof e&&!Ie(e)&&!Array.isArray(e)}function Ee(e){return null!=e&&"function"==typeof e[Symbol.iterator]}function Ce(e,t){return t in e}function xe(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 _e(e){if(Ae(e)){return`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${_e(e[t])}`).join(",")}}`}return Array.isArray(e)?`[${e.map(_e).join(",")}]`:JSON.stringify(e)}function Oe(e,t){const n=e.length,o=t.length;e.length=n+o;for(let l=0;l<o;l++)e[n+l]=t[l]}const De=new WeakSet,Fe=new WeakMap,Me=e=>(Fe.has(e)||Fe.set(e,new WeakMap),Fe.get(e)),Le=new WeakMap,We=e=>(Le.has(e)||Le.set(e,new WeakMap),Le.get(e));function Be(e,t,n,o){if(m(t)){const e=t.items.indexOf(n);if(e<0)throw new Error("Item not found in parent for replace");t.items.splice(e,1,o)}else if(r(t)&&u(t.value)&&!u(n)){const e=t.value.items.indexOf(n);if(e<0)throw new Error("Item not found in parent for replace");t.value.items.splice(e,1,o)}else if(h(t))t.item=o;else{if(!r(t))throw new Error(`Unsupported parent type "${t.type}" for replace`);t.key===n?t.key=o:t.value=o}qe(o,{lines:n.loc.start.line-o.loc.start.line,columns:n.loc.start.column-o.loc.start.column});const l=d(n.loc),i=d(o.loc);Re({lines:i.lines-l.lines,columns:i.columns-l.columns},We(e),o,n),De.add(e)}function Ne(e,t,i,s,h){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for insert`);let p,g;s=null!=s&&"number"==typeof s?s:t.items.length,a(t)||u(t)?({shift:p,offset:g}=function(e,t,n){if(!c(t))throw new Error(`Incompatible child type "${t.type}"`);const o=null!=n?e.items[n-1]:ke(e.items),l=null==n||n===e.items.length;e.items.splice(n,0,t);const r=!!o,i=!l;r&&(o.comma=!0);i&&(t.comma=!0);const s=ze(e),a=l&&!0===t.comma;return Ue(e,t,n,{useNewLine:s,hasCommaHandling:!0,isLastElement:l,hasSeparatingCommaBefore:r,hasSeparatingCommaAfter:i,hasTrailingComma:a})}(t,i,s)):h&&n(t)?({shift:p,offset:g}=function(e,t,n){const o=Ue(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),o}(t,i,s)):({shift:p,offset:g}=function(e,t,i){if(s=t,!(r(s)||o(s)||l(s)||f(s)))throw new Error(`Incompatible child type "${t.type}"`);var s;const a=e.items[i-1],c=n(e)&&!e.items.length,u=n(e)&&!c&&void 0===a;e.items.splice(i,0,t);const m=a?{line:a.loc.end.line,column:f(a)?e.loc.start.column:a.loc.start.column}:w(e.loc.start),h=o(t)||l(t);let p=0;c||u||(p=h?2:1);m.line+=p;const g={lines:m.line-t.loc.start.line,columns:m.column-t.loc.start.column},y=d(t.loc),v={lines:u?y.lines+1:y.lines+(p-1),columns:y.columns};return{shift:g,offset:v}}(t,i,s)),qe(i,p);const y=t.items[s-1],v=y&&We(e).get(y);if(v&&(g.lines+=v.lines,g.columns+=v.columns,We(e).delete(y)),u(t)&&0!==g.lines&&m(e)&&e!==t){const t=i.loc.start.line,n=e.items;for(let e=0;e<n.length;e++){const o=n[e];if(!f(o))continue;o.loc.start.line<t&&(o.loc.start.line-=g.lines,o.loc.end.line-=g.lines)}}We(e).set(i,g),De.add(e)}function Ue(e,t,n,o={}){const{useNewLine:l=!1,skipCommaSpace:r=2,skipBracketSpace:i=1,hasCommaHandling:s=!1,isLastElement:a=!1,hasSeparatingCommaBefore:c=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:m=!1}=o,h=n>0?e.items[n-1]:void 0,p=h?{line:h.loc.end.line,column:l?f(h)?e.loc.start.column:h.loc.start.column:h.loc.end.column}:w(e.loc.start);let g=0;if(l)g=1;else{const e=c||!s&&!!h;e&&s?p.column+=r:(e||s&&!h)&&(p.column+=i)}p.line+=g;const y={lines:p.line-t.loc.start.line,columns:p.column-t.loc.start.column},v=d(t.loc);if(!s){return{shift:y,offset:{lines:v.lines+(g-1),columns:v.columns}}}let b=0;c&&m&&!u&&a&&(b=-1);return{shift:y,offset:{lines:v.lines+(g-1),columns:v.columns+(c||u?r:0)+(m?1+b:0)}}}function Ke(e,t,n){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for remove`);let r=t.items.indexOf(n);if(r<0){if(r=t.items.findIndex(e=>h(e)&&e.item===n),r<0)throw new Error("Node not found in parent for removal");n=t.items[r]}const i=t.items[r-1];let s=t.items[r+1];t.items.splice(r,1);let p=d(n.loc);s&&f(s)&&s.loc.start.line===n.loc.end.line&&(p=d({start:n.loc.start,end:s.loc.end}),s=t.items[r+1],t.items.splice(r,1));const g=i&&c(i)||s&&c(s),w=i&&i.loc.end.line===n.loc.start.line,y=s&&s.loc.start.line===n.loc.end.line,v=g&&(w||y),b={lines:-(p.lines-(v?1:0)),columns:v?-p.columns:0},$=(u(t)||a(t))&&t.loc.end.line>t.loc.start.line;if(void 0!==i||void 0!==s||$||(b.lines=0,b.columns=0),g&&w&&(b.columns-=2),g&&!i&&s&&(ze(t)||(b.columns-=2)),g&&i&&!s){const e=n.comma;i.comma=!!e}let k,T;i?(k=i,T=We(e)):(o(t)||l(t))&&"key"in t?(k=t.key,T=We(e)):(k=t,T=Me(e));const S=We(e),I=T.get(k);I&&(b.lines+=I.lines,b.columns+=I.columns);const A=S.get(n);if(A&&(b.lines+=A.lines,b.columns+=A.columns),T.set(k,b),De.add(e),$&&m(e)&&e!==t){const t=n.loc.start.line,o=e.items,l=[];for(let e=0;e<o.length;e++){const n=o[e];if(!f(n))continue;const r=n.loc.start.line;r===t?l.push(e):0!==b.lines&&r<t&&(n.loc.start.line-=b.lines,n.loc.end.line-=b.lines)}for(let e=l.length-1;e>=0;e--)o.splice(l[e],1)}}function je(e,t,n=!0){if(!n)return;if(!t.items.length)return;Re({lines:0,columns:1},Me(e),t);const o=ke(t.items);Re({lines:0,columns:1},We(e),o),De.add(e)}function Ze(e,t,n=!1){if(!n)return;if(!t.items.length)return;const o=ke(t.items);o.comma=!0,Re({lines:0,columns:1},We(e),o),De.add(e)}function Ve(t){if(!De.has(t))return;const n=Me(t),o=We(t);let l=0;const r={};function i(e){let t=e.loc.start.line,n=e.loc.start.column;if("key"in e){const o=e.key.loc.end;(o.line>t||o.line===t&&o.column>n)&&(t=o.line,n=o.column)}for(let o=0;o<e.items.length;o++){const l=e.items[o].loc.end;(l.line>t||l.line===t&&l.column>n)&&(t=l.line,n=l.column)}e.loc.end={line:t,column:n}}function s(e){e.loc.start.line+=l;const t=r[e.loc.start.line]||0;e.loc.start.column+=t;const o=n.get(e);o&&(l+=o.lines,r[e.loc.start.line]=(r[e.loc.start.line]||0)+o.columns)}function a(e){e.loc.end.line+=l;const t=r[e.loc.end.line]||0;e.loc.end.column+=t;const n=o.get(e);n&&(l+=n.lines,r[e.loc.end.line]=(r[e.loc.end.line]||0)+n.columns)}!function t(n){switch(n.type){case e.Document:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.Table:{const e=n;s(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.TableArray:{const e=n;s(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e),i(e);break}case e.TableKey:{const e=n;s(e),t(e.item),a(e);break}case e.TableArrayKey:{const e=n;s(e),t(e.item),a(e);break}case e.KeyValue:{const e=n,i=e.loc.start.line+l,c=o.get(e.key);e.equals+=(r[i]||0)+(c?c.columns:0),s(e),t(e.key),t(e.value),a(e);break}case e.InlineArray:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e);break}case e.InlineTable:{const e=n;s(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);a(e);break}case e.InlineItem:{const e=n;s(e),t(e.item),a(e);break}case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:s(n),a(n);break;default:throw new Error(`Unrecognized node type "${n.type}"`)}}(t),De.delete(t),Fe.delete(t),Le.delete(t)}function qe(t,n,o={}){const{lines:l,columns:r}=n;if(0===l&&0===r)return t;const{first_line_only:i=!1}=o,s=t.loc.start.line,a=t.type;if(a===e.Key||a===e.String||a===e.Integer||a===e.Float||a===e.Boolean||a===e.DateTime||a===e.Comment)return i&&t.loc.start.line!==s||(t.loc.start.column+=r,t.loc.end.line===t.loc.start.line&&(t.loc.end.column+=r)),t.loc.start.line+=l,t.loc.end.line+=l,t;if(a===e.KeyValue){const n=t,o=n.value.type;if(o===e.String||o===e.Integer||o===e.Float||o===e.Boolean||o===e.DateTime){i&&n.loc.start.line!==s||(n.loc.start.column+=r,n.loc.end.column+=r),n.loc.start.line+=l,n.loc.end.line+=l,n.equals+=r;const e=n.key;i&&e.loc.start.line!==s||(e.loc.start.column+=r,e.loc.end.column+=r),e.loc.start.line+=l,e.loc.end.line+=l;const o=n.value;return i&&o.loc.start.line!==s||(o.loc.start.column+=r,o.loc.end.column+=r),o.loc.start.line+=l,o.loc.end.line+=l,t}}const c=e=>{i&&e.loc.start.line!==s||(e.loc.start.column+=r,e.loc.end.column+=r),e.loc.start.line+=l,e.loc.end.line+=l};return function(t,n){function o(e,t){for(const n of e)l(n,t)}function l(t,r){const i=n[t.type];switch(i&&"function"==typeof i&&i(t,r),i&&i.enter&&i.enter(t,r),t.type){case e.Document:o(t.items,t);break;case e.Table:l(t.key,t),o(t.items,t);break;case e.TableKey:l(t.item,t);break;case e.TableArray:l(t.key,t),o(t.items,t);break;case e.TableArrayKey:l(t.item,t);break;case e.KeyValue:l(t.key,t),l(t.value,t);break;case e.InlineArray:o(t.items,t);break;case e.InlineItem:l(t.item,t);break;case e.InlineTable:o(t.items,t);break;case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:break;default:throw new Error(`Unrecognized node type "${t.type}"`)}i&&i.exit&&i.exit(t,r)}Ee(t)?o(t,null):l(t,null)}(t,{[e.Table]:c,[e.TableKey]:c,[e.TableArray]:c,[e.TableArrayKey]:c,[e.KeyValue](e){c(e),e.equals+=r},[e.Key]:c,[e.String]:c,[e.Integer]:c,[e.Float]:c,[e.Boolean]:c,[e.DateTime]:c,[e.InlineArray]:c,[e.InlineItem]:c,[e.InlineTable]:c,[e.Comment]:c}),t}function ze(e){if(!e.items.length)return!1;return d(e.loc).lines>e.items.length}function Re(e,t,n,o){const l=t.get(o||n);l&&(e.lines+=l.lines,e.columns+=l.columns),t.set(n,e)}function Pe(e){switch(e){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"\\":return"\\";default:return null}}function He(e,t){switch(e){case"\\":return"\\\\";case"\b":return"\\b";case"\t":return"\\t";case"\f":return"\\f";case'"':return"singleline-basic"===t?'\\"':'"';case"\n":return"singleline-basic"===t?"\\n":"\n";case"\r":return"singleline-basic"===t?"\\r":"\r";default:{const n=e.charCodeAt(0);return function(e,t){return"singleline-basic"===t?e<=31||127===e:e>=0&&e<=7||11===e||e>=14&&e<=31||127===e}(n,t)?`\\u${n.toString(16).padStart(4,"0").toUpperCase()}`:e}}}function Je(e,t,n){const o=function(e){const t=new Map;for(let n=0;n<e.length;n++){if("\\"!==e[n])continue;const o=e[n+1];if(!o)continue;const l=Pe(o);if(null===l){if("x"===o&&/^[0-9A-Fa-f]{2}$/.test(e.slice(n+2,n+4))){const o=e.slice(n,n+4),l=Number.parseInt(e.slice(n+2,n+4),16),r=String.fromCharCode(l);t.has(r)||t.set(r,o),n+=3;continue}if("u"===o&&/^[0-9A-Fa-f]{4}$/.test(e.slice(n+2,n+6))){const o=e.slice(n,n+6),l=Number.parseInt(e.slice(n+2,n+6),16),r=String.fromCodePoint(l);t.has(r)||t.set(r,o),n+=5;continue}if("U"===o&&/^[0-9A-Fa-f]{8}$/.test(e.slice(n+2,n+10))){const o=e.slice(n,n+10),l=Number.parseInt(e.slice(n+2,n+10),16),r=String.fromCodePoint(l);t.has(r)||t.set(r,o),n+=9;continue}}else"\n"===l||"\r"===l||t.has(l)||t.set(l,"\\"+o),n+=1}return t}(t);if(0===o.size&&"singleline-basic"===n){return JSON.stringify(e).slice(1,-1).replace(/\x7f/g,"\\u007F")}const l=function(e,t,n){let o="";for(const l of e){const e=t.get(l);o+=e||He(l,n)}return o}(e,o,n);return"multiline-basic"===n?l.replace(/"""/g,'""\\"'):l}function Ye(){return{type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:[]}}function Ge(t){const n=function(t){const n=tt(t);return{type:e.TableKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+2}},item:{type:e.Key,loc:{start:{line:1,column:1},end:{line:1,column:n.length+1}},value:t,raw:n}}}(t);return{type:e.Table,loc:y(n.loc),key:n,items:[]}}function Xe(t){const n=function(t){const n=tt(t);return{type:e.TableArrayKey,loc:{start:{line:1,column:0},end:{line:1,column:n.length+4}},item:{type:e.Key,loc:{start:{line:1,column:2},end:{line:1,column:n.length+2}},value:t,raw:n}}}(t);return{type:e.TableArray,loc:y(n.loc),key:n,items:[]}}function Qe(t,n){const o=function(t){const n=tt(t);return{type:e.Key,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t),{column:l}=o.loc.end,r=l+1;return qe(n,{lines:0,columns:l+3-n.loc.start.column},{first_line_only:!0}),{type:e.KeyValue,loc:{start:w(o.loc.start),end:w(n.loc.end)},key:o,equals:r,value:n}}function et(e){return JSON.stringify(e).replace(/\x7f/g,"\\u007f")}function tt(e){return e.map(e=>b.test(e)?e:et(e)).join(".")}function nt(t,n){return n?function(t,n){if(o=n,o.startsWith('"')&&!o.startsWith('"""'))return ot(t,n);var o;if(function(e){return e.startsWith("'")&&!e.startsWith("'''")}(n)){if(!t.includes("'"))return function(t){const n=`'${t}'`;let o;if(n.includes("\n")){const e=n.split(/\r\n|\n/),t=e[e.length-1];o={line:e.length,column:t.length}}else o={line:1,column:n.length};return{type:e.String,loc:{start:{line:1,column:0},end:o},raw:n,value:t}}(t);if(!t.includes("'''")){return rt(t,`'''${n.slice(1,-1)}'''`)}return ot(t)}if(function(e){return e.startsWith("'''")}(n)){if(!t.includes("'''"))return rt(t,n);return lt(t,`"""${n.slice(3,-3)}"""`)}if(function(e){return e.startsWith('"""')}(n))return lt(t,n);throw new Error(`Existing raw string value is not valid: ${n}`)}(t,n):ot(t)}function ot(t,n){let o="";return o=n?`"${Je(t,n,"singleline-basic")}"`:et(t),{type:e.String,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}function lt(t,n){const o=Je(t,n,"multiline-basic");let l='"""'+(n.startsWith('"""\r\n')?"\r\n":n.startsWith('"""\n')?"\n":"")+o+'"""';const r=n.slice(3,-3);if(/(^|[^\\])(\\\\)*\\$/m.test(r)){const e=function(e,t){var n,o,l,r,i,s,a,c;const u=function(e){const t=e.match(/\r\n|\n/);return"\r\n"===(null==t?void 0:t[0])?"\r\n":"\n"}(e),f='"""';let m,h;(e=e.replace(/\r\n/g,"\n").replace(/\n/g,u)).startsWith(`${f}\\${u}`)?(m=4+u.length,h=`${f}\\${u}`):e.startsWith(`${f}${u}`)?(m=3+u.length,h=`${f}${u}`):(m=3,h=f);const d=e.length-3,p=e.slice(m,d).split(u),g=p[p.length-1],w=p.length>1&&/^[\t ]*$/.test(g),y=w?g:"",v=(w?p.slice(0,-1):p).map(e=>{var t,n;if(/^[\t ]*$/.test(e))return{indent:e,content:"",trailingWs:"",hasBackslash:!1,isBlank:!0};let o=e,l=0;for(let e=o.length-1;e>=0&&"\\"===o[e];e--)l++;const r=l%2==1;r&&(o=o.slice(0,-1));const i=null!==(n=null===(t=o.match(/^[\t ]*/))||void 0===t?void 0:t[0])&&void 0!==n?n:"",s=o.slice(i.length),a=s.match(/([\t ]+)$/),c=a?a[1]:"";return{indent:i,content:s.slice(0,s.length-c.length),trailingWs:c,hasBackslash:r,isBlank:!1}}),b=v.filter(e=>!e.isBlank),$=Math.max(...b.map(e=>e.content.length+e.trailingWs.length),1),k=b.filter(e=>e.hasBackslash),T=null!==(o=null!==(n=k[k.length-1])&&void 0!==n?n:b[b.length-1])&&void 0!==o?o:{indent:"",trailingWs:"",hasBackslash:!1,content:""},S=null!==(l=b[b.length-1])&&void 0!==l?l:T,I=[];{let e=[],t=0;for(const n of v)n.isBlank?e.push(n.indent):(t>0&&I.push(e),e=[],t++)}const A=b.some((e,t)=>!e.hasBackslash&&t<b.length-1),E=h===`${f}${u}`,C=E&&b.length>0&&null!==(i=null===(r=t.match(/^[\t ]*/))||void 0===r?void 0:r[0])&&void 0!==i?i:"",x=e=>{var t;const n=null!==(t=e.match(/\S+| +/g))&&void 0!==t?t:[],o=[];let l=0;for(;l<n.length;){let e=n[l++];for(;l<n.length&&" "===n[l][0];){const t=n[l],o=n[l+1];if(!o){l++;break}if(!(e.length+t.length+o.length<=$)){e+=t,l++;break}e+=t+o,l+=2}o.push(e)}return 0===o.length&&o.push(""),o},_=[],O=[],D=new Set,F=new Set,M=new Map;let L=!1;if(!A||!t.includes(u)||"\r\n"!==u&&t.includes("\r\n")){const e=t.replace(/\r\n/g,"\\r\\n").replace(/\n/g,"\\n").slice(C.length);if(e.length>0){if(" "===e[0])return null;if(e.length-e.trimEnd().length!==S.trailingWs.length)return null}if(!A){let t=0,n=0;for(let o=0;o<b.length-1;o++){const l=b[o];if(!l.hasBackslash)break;const r=l.content+l.trailingWs;if(e.slice(n,n+r.length)!==r)break;t++,n+=r.length}let o=0,l=0;for(let r=b.length-1;r>=t;r--){const t=b[r],i=t.content+t.trailingWs;if(0===i.length)break;const s=e.length-l-i.length;if(!(s>=n&&e.slice(s,s+i.length)===i))break;o++,l+=i.length}if(o>0){const r=e.slice(n,e.length-l);if(0===r.length||" "!==r[0]){for(let e=0;e<t;e++){const n=b[e];if(O.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}if(r.length>0){const e=x(r),n=e.join(""),l=/(?<!\\)\\n/.test(n);if(t>0&&!l){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}for(let n=0;n<e.length;n++){const o=e[n],i=t+n,s=i<b.length?b[i]:null,a=s?E&&0===i?C:s.indent:T.indent,c=o.length>0&&/\s$/.test(o)?"":r.endsWith(" ")?" ":"";if(O.push(`${a}${o}${c}\\`),n<e.length-1&&!l){const e=t+n;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}const i=b.length-o-1;if(!l&&i>=0&&i<I.length&&I[i].length>0)for(const e of I[i])O.push(e)}else if(t>0){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}const e=b.length-o;for(let t=e;t<b.length;t++){const n=b[t],o=t===b.length-1;if(t>e){const e=t-1;if(e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}O.push(o?`${n.indent}${n.content}${n.trailingWs}${n.hasBackslash&&""!==n.content?"\\":""}`:`${n.indent}${n.content}${n.trailingWs}\\`)}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}}const r=e.slice(n);if(t>0&&(n===e.length||r.length>0&&" "!==r[0])){for(let e=0;e<t;e++){const n=b[e];if(O.push(`${n.indent}${n.content}${n.trailingWs}\\`),e<t-1&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}if(n===e.length){const e=b[t-1],n=S.hasBackslash&&""!==e.content?"\\":"";O[O.length-1]=`${e.indent}${e.content}${S.trailingWs}${n}`}else{const e=x(r),n=e.join(""),o=/(?<!\\)\\n/.test(n),l=t-1;if(!o&&l<I.length&&I[l].length>0)for(const e of I[l])O.push(e);for(let n=0;n<e.length;n++){const l=n===e.length-1,r=e[n],i=t+n,s=i<b.length?b[i]:null,a=s?E&&0===i?C:s.indent:l?S.indent:T.indent;let c,u;if(l?(c=S.trailingWs,u=S.hasBackslash&&""!==S.content?"\\":""):(c=r.length>0&&/\s$/.test(r)?"":" ",u="\\"),O.push(`${a}${r}${c}${u}`),!l){const e=t+n;if(!o&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}}const n=x(e);for(const e of n)_.push(e)}else{L=!0;const e=t.split(u),n=e[0].slice(C.length);if(n.length>0&&" "===n[0])return null;const o=e[e.length-1];if(o.length>0&&o.length-o.trimEnd().length!==S.trailingWs.length)return null;for(let t=0;t<e.length;t++){const n=e[t],o=0===t?n.slice(C.length):n,l=null!==(a=null===(s=o.match(/^[\t ]*/))||void 0===s?void 0:s[0])&&void 0!==a?a:"",r=x(o.slice(l.length)),i=_.length;F.add(i),t>0&&M.set(i,l);for(const e of r)_.push(e);t<e.length-1&&D.add(i+r.length-1)}}for(let e=0;e<_.length;e++){const t=e===_.length-1,n=D.has(e),o=t||n,l=e<b.length?b[e]:null,r=L&&F.has(e)&&e>0?null!==(c=M.get(e))&&void 0!==c?c:"":l?E&&0===e?C:l.indent:o?S.indent:T.indent,i=_[e];let s,a;if(o&&t?(s=S.trailingWs,a=S.hasBackslash&&""!==S.content?"\\":""):o?(s=S.trailingWs,a=""):(s=i.length>0&&/\s$/.test(i)?"":" ",a="\\"),O.push(`${r}${i}${s}${a}`),!t&&!n&&!L){const t=_.join("");if(!/(?<!\\)\\n/.test(t)&&e<I.length&&I[e].length>0)for(const t of I[e])O.push(t)}}return!w||S.hasBackslash&&""===S.content?`${h}${O.join(u)}${f}`:`${h}${O.join(u)}${u}${y}${f}`}(n,o);null!==e&&(l=e)}const i=it(l);return{type:e.String,loc:{start:{line:1,column:0},end:i},raw:l,value:t}}function rt(t,n){const o="'''"+(n.startsWith("'''\r\n")?"\r\n":n.startsWith("'''\n")?"\n":"")+t+"'''",l=it(o);return{type:e.String,loc:{start:{line:1,column:0},end:l},raw:o,value:t}}function it(e){if(e.includes("\n")){const 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 st(t){const n=t.toString();return{type:e.Integer,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}function at(t,n=1){let o;if(t===1/0)o="inf";else if(t===-1/0)o="-inf";else if(Number.isNaN(t))o="nan";else if(Object.is(t,-0))o="-0."+"0".repeat(Math.max(n,1));else{o=t.toString();const e=o.search(/[eE]/);if(-1!==e){const t=o.slice(0,e),l=o.slice(e),r=t.indexOf(".");if(-1===r)o=`${t}.${"0".repeat(Math.max(n,1))}${l}`;else{const e=t.length-r-1;o=e<n?`${t}${"0".repeat(n-e)}${l}`:`${t}${l}`}}else{const e=o.indexOf(".");if(-1===e)o+="."+"0".repeat(Math.max(n,1));else{const t=o.length-e-1;t<n&&(o+="0".repeat(n-t))}}}return{type:e.Float,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}function ct(t){return{type:e.InlineItem,loc:y(t.loc),item:t,comma:!1}}function ut(e){return new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(e)}function ft(e){return 65279===e.charCodeAt(0)}function mt(e){return ft(e)?e.slice(1):e}const ht=!1,dt=!0,pt=!1,gt=!1,wt=!1;function yt(e,t){if(!e||"object"!=typeof e)return null;if(("InlineArray"===e.type||"InlineTable"===e.type)&&e.loc){const n=function(e,t){var n;if(!e||!e.start||!e.end)return null;const o=t.split(/\r?\n/),l=e.start.line-1,r=e.end.line-1,i=e.start.column,s=e.end.column;let a="";if(l===r)a=(null===(n=o[l])||void 0===n?void 0:n.substring(i,s+1))||"";else{o[l]&&(a+=o[l].substring(i));for(let e=l+1;e<r;e++)a+="\n"+(o[e]||"");o[r]&&(a+="\n"+o[r].substring(0,s+1))}const c=a.match(/^\[(\s*)/),u=a.match(/^\{(\s*)/);if(c)return c[1].length>0;if(u)return u[1].length>0;return null}(e.loc,t);if(null!==n)return n}if(e.items&&Array.isArray(e.items))for(const n of e.items){const e=yt(n,t);if(null!==e)return e;if(n.item){const e=yt(n.item,t);if(null!==e)return e}}for(const n of["value","key","item"])if(e[n]){const o=yt(e[n],t);if(null!==o)return o}return null}function vt(e){if(!e||"object"!=typeof e)return null;if("InlineArray"===e.type&&e.items&&Array.isArray(e.items))return bt(e.items);if("InlineTable"===e.type&&e.items&&Array.isArray(e.items))return bt(e.items);if("KeyValue"===e.type&&e.value)return vt(e.value);if(e.items&&Array.isArray(e.items))for(const t of e.items){const e=vt(t);if(null!==e)return e}return null}function bt(e){if(0===e.length)return null;const t=e[e.length-1];return!(!t||"object"!=typeof t||!("comma"in t))&&!0===t.comma}function $t(e){const t=e.indexOf("\n");return t>0&&"\r"===e[t-1]?"\r\n":"\n"}function kt(e,t){var n,o,l,r,i,s,a,c;if(e){if(e instanceof Tt)return e;{const u=function(e){if(!e||"object"!=typeof e)return{};const t=e=>"boolean"==typeof e?null:"expected boolean, got "+typeof e,n={newLine:e=>"string"==typeof e?null:"expected string, got "+typeof e,trailingNewline:e=>"boolean"==typeof e||"number"==typeof e?null:"expected boolean or number, got "+typeof e,trailingComma:t,bracketSpacing:t,leadingBom:t,inlineTableStart:e=>null==e||"number"==typeof e&&Number.isInteger(e)&&e>=0?null:"expected non-negative integer or undefined, got "+typeof e,truncateZeroTimeInDates:t,useTabsForIndentation:t,minimumDecimals:e=>null==e||"number"==typeof e&&Number.isInteger(e)&&e>=0?null:"expected non-negative integer or undefined, got "+typeof e},o={},l=[],r=[];for(const t in e){const i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(i){const n=e[t],l=i(n);l?r.push(`${t} (${l})`):o[t]=n}else Object.prototype.hasOwnProperty.call(e,t)&&l.push(t)}if(l.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${l.join(", ")}. Supported properties are: ${Object.keys(n).join(", ")}`),r.length>0)throw new TypeError(`Invalid types for format properties: ${r.join(", ")}`);return o}(e);return new Tt(null!==(n=u.newLine)&&void 0!==n?n:t.newLine,null!==(o=u.trailingNewline)&&void 0!==o?o:t.trailingNewline,null!==(l=u.trailingComma)&&void 0!==l?l:t.trailingComma,null!==(r=u.bracketSpacing)&&void 0!==r?r:t.bracketSpacing,void 0!==u.inlineTableStart?u.inlineTableStart:t.inlineTableStart,null!==(i=u.truncateZeroTimeInDates)&&void 0!==i?i:t.truncateZeroTimeInDates,null!==(s=u.useTabsForIndentation)&&void 0!==s?s:t.useTabsForIndentation,null!==(a=u.minimumDecimals)&&void 0!==a?a:t.minimumDecimals,null!==(c=u.leadingBom)&&void 0!==c?c:t.leadingBom)}}return t}class Tt{constructor(e,t,n,o,l,r,i,s,a){this.newLine=null!=e?e:"\n",this.trailingNewline=null!=t?t:1,this.trailingComma=null!=n?n:ht,this.bracketSpacing=null!=o?o:dt,this.inlineTableStart=null!=l?l:1,this.truncateZeroTimeInDates=null!=r?r:pt,this.useTabsForIndentation=null!=i?i:gt,this.minimumDecimals=null!=s?s:0,this.leadingBom=null!=a?a:wt}static default(){return new Tt("\n",1,ht,dt,1,pt,gt,0,wt)}static autoDetectFormat(e){return Tt.autoDetectFormatWithAst(e)}static autoDetectFormatWithAst(e,t){const n=Tt.default();n.leadingBom=ft(e);const o=mt(e);n.newLine=$t(o),n.trailingNewline=function(e){let t=0,n=e.length;for(;n>0&&"\n"===e[n-1];)t++,n--,n>0&&"\r"===e[n-1]&&n--;return t}(o);try{const e=Array.isArray(t)?t:Array.from(null!=t?t:me(o));n.trailingComma=function(e){for(const t of e){const e=vt(t);if(null!==e)return e}return ht}(e),n.bracketSpacing=function(e,t){for(const n of t){const t=yt(n,e);if(null!==t)return t}return dt}(o,e)}catch(e){n.trailingComma=ht,n.bracketSpacing=dt}return n.useTabsForIndentation=function(e){const t=e.split(/\r?\n/);let n=0,o=0;for(const e of t)if(0!==e.length&&("\t"===e[0]?n++:" "===e[0]&&o++,n+o>=5))break;return n>o}(o),n.inlineTableStart=1,n.truncateZeroTimeInDates=pt,n.minimumDecimals=0,n}}function St(e){if(!a(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function It(e){if(!u(e))return!1;if(0===e.items.length)return!1;return!0===e.items[e.items.length-1].comma}function At(e,t){if(0===t.inlineTableStart)return e;return e.items.filter(e=>{if(!r(e))return!1;const n=u(e.value),o=a(e.value)&&e.value.items.length>0&&e.value.items.every(e=>u(e.item));if(n||o){const n=xt(e.key.value);return void 0===t.inlineTableStart||n<t.inlineTableStart}return!1}).forEach(t=>{Ke(e,e,t),u(t.value)?Ne(e,e,Et(t)):function(e){const t=Ye();for(const n of e.value.items){const o=Xe(e.key.value);Ne(t,t,o);for(const e of n.item.items)Ne(t,o,e.item)}return Ve(t),t.items}(t).forEach(t=>{Ne(e,e,t)})}),Ve(e),e}function Et(e){const t=Ge(e.key.value);for(const n of e.value.items)Ne(t,t,n.item);return Ve(t),t}function Ct(e){if(e.items.length>0){const 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 xt(e){return Math.max(0,e.length-1)}function _t(e,t,n){var o;for(let l=e.items.length-1;l>=0;l--){const i=e.items[l];if(r(i)&&u(i.value)){const l=[...e.key.item.value,...i.key.value];if(xt(l)<(null!==(o=n.inlineTableStart)&&void 0!==o?o:1)){const o=Ge(l);for(const e of i.value.items)Ne(o,o,e.item);Ke(e,e,i),Ct(e),t.push(o),_t(o,t,n)}}}}function Ot(e,t=Tt.default()){e=Mt(e);const n=Ye();for(const o of Dt(e,t))Ne(n,n,o);return Ve(n),At(n,t),function(e,t){if(void 0===t.inlineTableStart||0===t.inlineTableStart)return e;const n=[];for(const o of e.items)if(r(o)&&u(o.value)){if(xt(o.key.value)<t.inlineTableStart){const l=Et(o);Ke(e,e,o),Ne(e,e,l),_t(l,n,t)}}else("Table"===o.type||l(o))&&_t(o,n,t);for(const t of n)Ne(e,e,t);Ve(e)}(n,t),function(e){let t=0,n=0;for(const o of e.items)0===n&&o.loc.start.line>1?t=1-o.loc.start.line:o.loc.start.line+t>n+2&&(t+=n+2-(o.loc.start.line+t)),qe(o,{lines:t,columns:0}),n=o.loc.end.line;return e}(n)}function*Dt(e,t){for(const n of Object.keys(e)){const o=e[n];if(void 0===o)continue;const l=Mt(o);void 0!==l&&(yield Qe([n],Ft(l,t)))}}function Ft(t,n){var o;const l=null!==(o=n.minimumDecimals)&&void 0!==o?o:0;if(null===t)throw new Error('"null" values are not supported');if(void 0===t)throw new Error('"undefined" values are not supported inside arrays');return function(e){return"string"==typeof e}(t)?nt(t):function(e){return"bigint"==typeof e}(t)?st(t):Se(t)?l>0?at(t,l):st(t):function(e){return"number"==typeof e&&(!Se(e)||!isFinite(e)||Object.is(e,-0))}(t)?at(t,Math.max(l,1)):function(e){return"boolean"==typeof e}(t)?function(t){return{type:e.Boolean,loc:{start:{line:1,column:0},end:{line:1,column:t?4:5}},value:t}}(t):Ie(t)?function(t,n=!1){n&&0===t.getUTCHours()&&0===t.getUTCMinutes()&&0===t.getUTCSeconds()&&0===t.getUTCMilliseconds()&&(t=new V(t.toISOString().split("T")[0]));const o=t.toISOString();return{type:e.DateTime,loc:{start:{line:1,column:0},end:{line:1,column:o.length}},raw:o,value:t}}(t,n.truncateZeroTimeInDates):Array.isArray(t)?function(t,n){const o={type:e.InlineArray,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of t){Ne(o,o,ct(Ft(e,n)))}return je(o,o,n.bracketSpacing),Ze(o,o,n.trailingComma),Ve(o),o}(t,n):function(t,n){if(t=Mt(t),!Ae(t))return Ft(t,n);const o={type:e.InlineTable,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of Dt(t,n)){Ne(o,o,ct(e))}return je(o,o,n.bracketSpacing),Ze(o,o,n.trailingComma),Ve(o),o}(t,n)}function Mt(e){return e?Ie(e)?e:"function"==typeof e.toJSON?e.toJSON():e:e}const Lt=/(\r\n|\n)/g;function Wt(t,n){const o=[];function l(t){switch(t.type){case e.Document:for(let e=0;e<t.items.length;e++)l(t.items[e]);break;case e.Table:{const e=t;l(e.key);for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.TableKey:{const e=t,{start:n,end:r}=e.loc;Nt(o,n.line,n.column,"["),Nt(o,r.line,r.column-1,"]"),l(e.item);break}case e.TableArray:{const e=t;l(e.key);for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.TableArrayKey:{const e=t,{start:n,end:r}=e.loc;Ut(o,n.line,n.column,n.column+2,"[["),Ut(o,r.line,r.column-2,r.column,"]]"),l(e.item);break}case e.KeyValue:{const e=t,n=e.loc.start.line;Nt(o,n,e.equals,"="),l(e.key),l(e.value);break}case e.Key:case e.String:case e.Integer:case e.Float:Bt(o,t.loc,t.raw);break;case e.Boolean:Bt(o,t.loc,t.value.toString());break;case e.DateTime:Bt(o,t.loc,t.raw);break;case e.InlineArray:{const e=t,{start:n,end:r}=e.loc;Nt(o,n.line,n.column,"["),Nt(o,r.line,r.column-1,"]");for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.InlineTable:{const e=t,{start:n,end:r}=e.loc;Nt(o,n.line,n.column,"{"),Nt(o,r.line,r.column-1,"}");for(let t=0;t<e.items.length;t++)l(e.items[t]);break}case e.InlineItem:{const e=t;if(l(e.item),e.comma){const t=e.loc.end;Nt(o,t.line,t.column,",")}break}case e.Comment:Bt(o,t.loc,t.raw);break;default:{const e=t.type;throw new Error(`toTOML: Unrecognized node type: ${String(e)}`)}}}if(Ee(t))for(const e of t)l(e);else l(t);if(n.useTabsForIndentation)for(let e=0;e<o.length;e++){const t=o[e],n=t.match(/^( +)/);if(n){const l=n[1],r="\t".repeat(l.length);o[e]=r+t.substring(l.length)}}return o.join(n.newLine)+n.newLine.repeat(n.trailingNewline)}function Bt(e,t,n){if(t.start.line===t.end.line){const o=Kt(e,t.start.line),l=o.substring(0,t.start.column),r=l.length<t.start.column?l.padEnd(t.start.column,T):l,i=o.substring(t.end.column);return void(e[t.start.line-1]=r+n+i)}const o=n.split(Lt).filter(e=>"\n"!==e&&"\r\n"!==e),l=t.end.line-t.start.line+1;if(o.length!==l)throw new Error(`Mismatch between location and raw string, expected ${l} lines for "${n}"`);for(let n=t.start.line;n<=t.end.line;n++){const l=Kt(e,n),r=n===t.start.line,i=n===t.end.line;let s="";if(r){const e=l.substring(0,t.start.column);s=e.length<t.start.column?e.padEnd(t.start.column,T):e}const a=i?l.substring(t.end.column):"";e[n-1]=s+o[n-t.start.line]+a}}function Nt(e,t,n,o){const l=Kt(e,t),r=l.length<n?l.padEnd(n,T):l.substring(0,n),i=l.substring(n+1);e[t-1]=r+o+i}function Ut(e,t,n,o,l){const r=Kt(e,t),i=r.length<n?r.padEnd(n,T):r.substring(0,n),s=r.substring(o);e[t-1]=i+l+s}function Kt(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]="");return e[t-1]}function jt(t,n,o){for(const l of t.items){const t=l.item;if(t.value.type===e.InlineTable){const e=n.concat(t.key.value);o.add(Ht(e)),jt(t.value,e,o)}}}function Zt(t,n="",o="asNeeded"){const l=Te(),r=new Set,i=new Set,s=new Set,a=new Set,c=new Set;let u=l,f=[];const m={tables:r,table_arrays:i,defined:s,implicit_tables:a,inline_tables:c};for(const n of t)switch(n.type){case e.Table:h(n);for(const t of n.items)t.type===e.KeyValue&&p(t);break;case e.TableArray:d(n);for(const t of n.items)t.type===e.KeyValue&&p(t);break;case e.KeyValue:p(n)}return l;function h(e){const t=e.key.item.value;try{qt(l,[],t,e.type,m)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const o=Ht(t);r.add(o),s.add(o),u=zt(l,t),f=t}function d(e){const t=e.key.item.value;try{qt(l,[],t,e.type,m)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const o=Ht(t);i.add(o),s.add(o),u=function(e,t){const n=Rt(e,t.slice(0,-1)),o=ke(t);n[o]||(n[o]=[]);const l=Te();return n[ke(t)].push(l),l}(l,t),f=t}function p(t){const l=t.key.value;try{qt(u,f,l,t.type,m)}catch(e){const o=e;throw new v(n,t.key.loc.start,o.message)}if(l.length>1)for(let e=1;e<l.length;e++){const t=Ht(f.concat(l.slice(0,e)));a.add(t),s.add(t)}let r;try{r=Vt(t.value,o)}catch(e){const o=e;throw new v(n,t.value.loc.start,o.message)}if(t.value.type===e.InlineTable){const e=f.concat(l);c.add(Ht(e)),jt(t.value,e,c)}(l.length>1?zt(u,l.slice(0,-1)):u)[ke(l)]=r,s.add(Ht(f.concat(l)))}}function Vt(t,n="asNeeded"){switch(t.type){case e.InlineTable:const o=Te(),l=new Set,r=new Map;return t.items.forEach(({item:e})=>{const t=e.key.value,i=Vt(e.value,n),s=Ht(t);if(l.has(s))throw new Error(`Duplicate key "${s}" in inline table`);for(let e=1;e<t.length;e++){const n=Ht(t.slice(0,e));if(l.has(n))throw new Error(`Key "${s}" conflicts with key: "${n}"`)}if(r.has(s)){const e=r.get(s);throw new Error(`Key "${s}" conflicts with key: "${e}"`)}l.add(s);for(let e=1;e<t.length;e++){const n=Ht(t.slice(0,e));r.has(n)||r.set(n,s)}(t.length>1?zt(o,t.slice(0,-1)):o)[ke(t)]=i}),o;case e.InlineArray:return t.items.map(e=>Vt(e.item,n));case e.DateTime:case e.String:return t.value;case e.Integer:return function(e,t="asNeeded"){const n=e.replace(/_/g,"");let o,l=n;if(/^[+-]?0x/i.test(n)||/^[+-]?0o/i.test(n)||/^[+-]?0b/i.test(n)){const e="+"===n[0]||"-"===n[0]?n[0]:"";l=e+n.slice(e?1:0).toLowerCase()}try{o=BigInt(l)}catch(e){return Number(n)}return!0===t?o:!1===t||o>=BigInt(Number.MIN_SAFE_INTEGER)&&o<=BigInt(Number.MAX_SAFE_INTEGER)?Number(o):o}(t.raw,n);case e.Float:case e.Boolean:return t.value;default:throw new Error(`Unrecognized value type "${t.type}"`)}}function qt(t,n,o,l,r){const i=n.length>0?Ht(n):"",s=new Array(o.length);let a=i;for(let e=0;e<o.length;e++)a=a?a+"."+o[e]:o[e],s[e]=a;const c=s[o.length-1];if(l===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if((l===e.Table||l===e.TableArray)&&r.inline_tables.has(c))throw new Error(`Cannot extend inline table at ${c}`);if(l===e.Table||l===e.TableArray)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if(l===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=s[e-1];if(r.table_arrays.has(t))throw new Error(`Cannot traverse Array of Tables at ${t}`)}if((l===e.Table||l===e.TableArray)&&r.implicit_tables.has(c))throw new Error(`Implicit table already defined: ${c}`);if(l===e.KeyValue&&r.implicit_tables.has(c))throw new Error(`Table already defined: ${c}`);if(l===e.KeyValue&&o.length>1)for(let e=1;e<=o.length;e++){const t=s[e-1];if(r.tables.has(t))throw new Error(`Cannot extend explicit table ${t} with dotted keys`)}let u=0;for(const e of o){if(!Ce(t,e))return;if(Pt(t[e]))throw new Error(`Value already defined for ${s[u]}`);const n=s[u];if(Array.isArray(t[e])&&!r.table_arrays.has(n))throw new Error(`Cannot add to static array at ${n}`);const l=u++<o.length-1;t=Array.isArray(t[e])&&l?ke(t[e]):t[e]}const f=c;if(t&&l===e.Table&&r.defined.has(f))throw new Error(`Table already defined: ${f}`);if(t&&l===e.KeyValue&&1===o.length&&r.defined.has(f)&&!Pt(t))throw new Error(`Table already defined: ${f}`);if(t&&l===e.TableArray&&!r.table_arrays.has(f))throw new Error(`Cannot add Array of Tables to table at ${f}`)}function zt(e,t){const n=Rt(e,t.slice(0,-1)),o=ke(t);return n[o]||(n[o]=Te()),n[o]}function Rt(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=Te()),Array.isArray(e[t])?ke(e[t]):e[t]),e)}function Pt(e){return"object"!=typeof e&&!Ie(e)}function Ht(e){return e.join(".")}var Jt;function Yt(e){return e.type===Jt.Remove}function Gt(e,t,n=[]){return e===t||(l=t,Ie(o=e)&&Ie(l)&&o.toISOString()===l.toISOString())?[]:Array.isArray(e)&&Array.isArray(t)?function(e,t,n=[]){let o=[];const l=e.map(_e),r=t.map(_e);r.forEach((i,s)=>{const a=s>=l.length;if(!a&&l[s]===i)return;const c=l.indexOf(i,s+1);if(!a&&c>-1){o.push({type:Jt.Move,path:n,from:c,to:s});const e=l.splice(c,1);return void l.splice(s,0,...e)}const u=!r.includes(l[s]);if(!a&&u)return Oe(o,Gt(e[s],t[s],n.concat(s))),void(l[s]=i);o.push({type:Jt.Add,path:n.concat(s)}),l.splice(s,0,i)});for(let e=r.length;e<l.length;e++)o.push({type:Jt.Remove,path:n.concat(e)});return o}(e,t,n):Ae(e)&&Ae(t)?function(e,t,n=[]){let o=[];const l=Object.keys(e),r=l.map(t=>_e(e[t])),i=Object.keys(t),s=i.map(e=>_e(t[e])),a=(e,t)=>{if(t.indexOf(e)<0)return!1;const n=l[r.indexOf(e)];return!i.includes(n)};return l.forEach((l,c)=>{const u=n.concat(l);if(i.includes(l))Oe(o,Gt(e[l],t[l],u));else if(a(r[c],s)){const e=i[s.indexOf(r[c])];o.push({type:Jt.Rename,path:n,from:l,to:e})}else o.push({type:Jt.Remove,path:u})}),i.forEach((e,t)=>{l.includes(e)||a(s[t],r)||o.push({type:Jt.Add,path:n.concat(e)})}),o}(e,t,n):[{type:Jt.Edit,path:n}];var o,l}function Xt(e,t){if(!t.length)return c(e)&&r(e.item)?e.item:e;if(r(e))return Xt(e.value,t);const i={};let s;if(m(e)&&e.items.some((a,u)=>{try{let f=[];if(r(a))f=a.key.value;else if(o(a))f=a.key.item.value;else if(l(a)){f=a.key.item.value;const e=_e(f);i[e]||(i[e]=0);const t=i[e]++;f=f.concat(t)}else c(a)&&r(a.item)?f=a.item.key.value:c(a)&&(f=[u]);if(f.length&&xe(f,t.slice(0,f.length))){const i=t.slice(f.length);if(n(e)&&l(a)&&i.length>0){const t=a.key.item.value,n=e,r=n.items.findIndex((e,n)=>n>u&&l(e)&&xe(e.key.item.value,t)),c=-1===r?n.items.length:r,f=n.items.slice(u+1,c);s=function(e,t,n,r){try{return Xt(e,t)}catch(e){}const i={};for(const e of r){let r=[];if(o(e)){const t=e.key.item.value;t.length>n.length&&xe(t.slice(0,n.length),n)&&(r=t.slice(n.length))}else if(l(e)){const t=e.key.item.value;if(t.length>n.length&&xe(t.slice(0,n.length),n)){const e=t.slice(n.length),o=_e(e);i[o]||(i[o]=0);const l=i[o]++;r=e.concat(l)}}if(r.length&&xe(r,t.slice(0,r.length)))try{return Xt(e,t.slice(r.length))}catch(e){}}throw new Error(`Node not found at (aot scope) ${t.join(".")}`)}(a,i,t,f)}else s=c(a)&&r(a.item)?t.length===f.length?a:Xt(a.item.value,i):c(a)&&t.length>f.length?Xt(a.item,i):Xt(a,i);return!0}return!1}catch(e){return!1}}),!s)throw new Error(`Node not found at ${t.join(".")}`);return s}function Qt(e,t){try{return Xt(e,t)}catch(e){}}function en(e,t){let n,o=t;for(;o.length&&!n;)o=o.slice(0,-1),n=Qt(e,o);if(!n)throw new Error(`Parent not found for ${t.join(".")}`);return n}!function(e){e.Add="Add",e.Edit="Edit",e.Remove="Remove",e.Move="Move",e.Rename="Rename"}(Jt||(Jt={}));const tn=new WeakMap,nn=new WeakMap;function on(e,t){const n=e[t].loc.end.line;for(let o=t+1;o<e.length;o++){const t=e[o];if(f(t)&&t.loc.start.line===n)return t;if(!f(t)&&t.loc.start.line>n)return}}function ln(e,t,n){for(let o=t+n;o>=0&&o<e.length;o+=n)if(!f(e[o]))return o}function rn(e,t,n){nn.has(e)||nn.set(e,e.loc.start.column);const o=e.loc.start.column+n,l=Math.max(t,o)-o;0!==l&&(e.loc.start.column+=l,e.loc.end.column+=l)}function sn(e,t,n){if(!m(e)||0===n)return;const o=e.items,l=o.indexOf(t);if(l<0)return;const r=on(o,l);r&&function(e,t){nn.set(t,t.loc.start.column),tn.set(t,t.loc.start.column-e.loc.end.column)}(t,r)}function an(e,t=[]){for(const n of e.items)f(n)?t.push(n):(o(n)||l(n))&&an(n,t);return t}function cn(e,t=new Set){for(const n of e.items)r(n)&&u(n.value)&&n.loc.start.line===n.loc.end.line?t.add(n.loc.end.line):(o(n)||l(n))&&cn(n,t);return t}function un(e){for(const t of e.items)(o(t)||l(t))&&un(t);let t=e.loc.end.line,n=e.loc.end.column;const r=(e,o)=>{(e>t||e===t&&o>n)&&(t=e,n=o)};(o(e)||l(e))&&r(e.key.loc.end.line,e.key.loc.end.column);for(const t of e.items)r(t.loc.end.line,t.loc.end.column);e.loc.end.line=t,e.loc.end.column=n}function fn(e,t,n){var o,l;const r=n.newLine,i=t.match(/(?:\r\n|\n)+$/u),s=i?i[0]:"",a=s?t.slice(0,-s.length):t,c=a.length?a.split(r):[],u=cn(e),f=(e,t)=>{const n=e.lastIndexOf(t.raw);return n>=0?n:t.loc.start.column},m=an(e).filter(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n);return o.trim().length>0&&/\s{2,}$/u.test(o)}).sort((e,t)=>e.loc.start.line-t.loc.start.line),h=[];let d=[];for(const e of m){const t=d[d.length-1];t&&e.loc.start.line!==t.loc.start.line+1?(d.length>0&&h.push(d),d=[e]):d.push(e)}d.length>0&&h.push(d);for(const e of h){if(e.length<2)continue;let t=null!==(o=nn.get(e[0]))&&void 0!==o?o:e[0].loc.start.column;const n=new Map;for(const t of e){const e=null!==(l=nn.get(t))&&void 0!==l?l:t.loc.start.column;n.set(e,(n.get(e)||0)+1)}let r=1;for(const[e,o]of n)o>r&&(r=o,t=e);const i=Math.max(...e.map(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e);return t.slice(0,n).trimEnd().length})),s=Math.min(...e.map(e=>{const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n).trimEnd();return Math.max(1,n-o.length)}));let a=s;const m=e.filter(e=>tn.has(e)),h=e.some(e=>!u.has(e.loc.start.line));if(m.length>0&&h){const t=Math.min(...e.map(e=>{if(tn.has(e))return tn.get(e)||1;const t=c[e.loc.start.line-1]||"",n=f(t,e),o=t.slice(0,n).trimEnd();return Math.max(1,n-o.length)}));a=Math.min(a,t)}if(t<i+1){const e=i+a;t=Math.max(t,e)}for(const n of e){const e=n.loc.start.line-1,o=c[e]||"",l=f(o,n),r=o.slice(0,l).trimEnd(),i=Math.max(t,r.length+1);if(l!==i){const t=" ".repeat(i-r.length);c[e]=r+t+n.raw}n.loc.start.column!==i&&(n.loc.start.column=i,n.loc.end.column=i+n.raw.length)}}return un(e),c.join(r)+s}function mn(e,t,n){const o=Array.from(me(mt(e))),l=kt(n,Tt.autoDetectFormatWithAst(e,o)),r=hn(o,t,l).tomlString;return l.leadingBom?`\ufeff${r}`:r}function hn(t,i,s){const f=[...t];let p=1,g=0;for(const e of f){const t=e.loc.end;(t.line>p||t.line===p&&t.column>g)&&(p=t.line,g=t.column)}const w=Zt(f),y={type:e.Document,loc:{start:{line:1,column:0},end:{line:p,column:g}},items:f},v=Ot(i,kt(Object.assign(Object.assign({},s),{inlineTableStart:void 0}),s)),$=function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Yt(n)){let o=t+1;for(;o<e.length;){const l=e[o];if(Yt(l)&&l.path[0]===n.path[0]&&l.path[1]>n.path[1]){e.splice(o,1),e.splice(t,0,l),t=-1;break}o++}}}return e}(Gt(w,Zt(v.items)));if(0===$.length)return{tomlString:Wt(f,s),document:y};const k=function(e,t,i,s){return i.forEach(i=>{if(function(e){return e.type===Jt.Add}(i)){let f=Xt(t,i.path);const h=i.path.slice(0,-1);let p,g=ke(i.path),w=l(f);if(Se(g)&&!w&&!Se(ke(h))){const t=Qt(e,h.concat(0));t&&l(t)&&(w=!0)}if(w&&!l(f)){const e=h.filter(e=>"string"==typeof e);let n=Zt(t.items);for(const e of i.path)n=null==n?void 0:n[e];if(void 0!==n){const t=Xe(e),o=Ot(n,s);for(const e of o.items)Ne(t,t,e,void 0);Ve(t),f=t}}if(o(f))p=e;else if(w){p=e;const t=e,n=Qt(t,h.concat(g-1)),o=Qt(t,h.concat(g));g=o?t.items.indexOf(o):n?t.items.indexOf(n)+1:t.items.length}else p=en(e,i.path),r(p)?p=p.value:c(p)&&r(p.item)?p=p.item.value:c(p)&&u(p.item)&&(p=p.item);if(a(p)){const t=Qt(e,h),n=Qt(e,h.slice(0,-1));if(t&&r(t)&&n){const e=function(e,t,n){if(!a(e)&&!u(e))return 0;const o=d(t.loc),l=n>0,r=n<e.items.length,i=n===e.items.length,s=!!c(t)&&t.comma,f=l&&s&&!r&&i;return o.columns+(l||r?2:0)+(s?1+(f?-1:0):0)}(p,f,g);0!==e&&function(e,t,n){if(!m(e))return;const o=e.items,l=o.indexOf(t);if(l<0)return;const r=on(o,l);if(!r)return;const i=r.loc.start.column,s=r.loc.start.line,a=[ln(o,l,-1),ln(o,l,1)];for(const e of a){if(null==e)continue;const t=on(o,e);if(t&&1===Math.abs(t.loc.start.line-s)&&t.loc.start.column===i)return void rn(r,t.loc.start.column,n)}}(n,t,e)}}if(l(p)||a(p)||n(p)){if(a(p)){const e=St(p);c(f)&&(f.comma=e)}if(void 0!==s.inlineTableStart&&s.inlineTableStart>0&&n(p)&&o(f)){const t=pn(f,e,s);Ne(e,p,f,g);for(const n of t)Ne(e,e,n,void 0)}else{let t=g;if(n(p)&&r(f)){const e=p.items.findIndex(e=>o(e)||l(e));-1!==e&&(t=e)}Ne(e,p,f,t)}}else if(u(p)){const t=It(p);if(r(f)){const n=ct(f);n.comma=t,Ne(e,p,n)}else Ne(e,p,f)}else if(void 0!==s.inlineTableStart&&s.inlineTableStart>0&&r(f)&&u(f.value)&&o(p)){xt([...p.key.item.value,...f.key.value])<s.inlineTableStart?function(e,t,n,o){const l=t.key.item.value,i=[...l,...e.key.value],s=Ge(i);if(u(e.value))for(const t of e.value.items)c(t)&&r(t.item)&&Ne(n,s,t.item,void 0);Ne(n,n,s,void 0),Ct(t);const a=pn(s,n,o);for(const e of a)Ne(n,n,e,void 0)}(f,p,e,s):Ne(e,p,f)}else if(0===s.inlineTableStart&&r(f)&&u(f.value)&&n(p))Ne(e,p,f,void 0,!0);else{let t=f;c(f)&&(o(p)||n(p))&&(t=f.item),Ne(e,p,t)}}else if(function(e){return e.type===Jt.Edit}(i)){let n,l=Xt(e,i.path),f=Xt(t,i.path);const h=Qt(e,i.path.slice(0,-1)),p=function(e,t){for(let n=t.length-1;n>0;n--){const o=Qt(e,t.slice(0,n));if(!o||!r(o)||!u(o.value))continue;const l=Qt(e,t.slice(0,n-1));if(l&&m(l))return{container:l,row:o}}}(e,i.path);if(r(l)&&r(f))dn(l.value,f.value),h&&function(e,t,n,o){if(!m(e))return;const l=e.items,r=l.indexOf(t);if(r<0)return;const i=on(l,r);if(!i)return;if(n.loc.start.line!==n.loc.end.line)return;if(o.loc.start.line!==o.loc.end.line)return;const s=i.loc.start.column,a=i.loc.start.line,c=[ln(l,r,-1),ln(l,r,1)];let u;for(const e of c){if(null==e)continue;const t=on(l,e);if(t&&1===Math.abs(t.loc.start.line-a)&&t.loc.start.column===s){u=t.loc.start.column;break}}if(null==u)return;const f=d(n.loc);rn(i,u,d(o.loc).columns-f.columns)}(h,l,l.value,f.value),n=l,l=l.value,f=f.value;else if(r(l)&&c(f)&&r(f.item))n=l,l=l.value,f=f.item.value;else if(c(l)&&r(l.item)&&r(f)){const e=l.item;dn(e.value,f.value),n=e,l=e.value,f=f.value}else if(c(l)&&c(f)&&r(l.item)&&r(f.item))dn(l.item.value,f.item.value),n=l.item,l=l.item.value,f=f.item.value;else if(o(l)){let o=Zt(t.items);for(const e of i.path)o=null==o?void 0:o[e];if(void 0!==o){const t=l.key.item.value,n=t.slice(-1),r=t.slice(0,-1),a=en(e,i.path),c=Ot({[n[0]]:o},s).items[0];if(r.length>0){const t=Ge(r);Ne(e,t,c,0),Be(e,a,l,t)}else Be(e,a,l,c);return}n=en(e,i.path)}else if(n=en(e,i.path),r(n)){const t=i.path.slice(0,-1),o=Xt(e,t);r(o)&&a(o.value)&&(n=o.value)}if(p){const e=d(l.loc),t=d(f.loc).columns-e.columns;0!==t&&sn(p.container,p.row,t)}Be(e,n,l,f)}else if(Yt(i)){const t=Qt(e,i.path);if(t){let n=en(e,i.path);r(n)&&(n=n.value),c(n)&&r(n.item)&&(n=n.item.value),c(n)&&u(n.item)&&(n=n.item),m(n)&&!n.items.includes(t)&&(n=e),Ke(e,n,t)}else{if(Qt(e,i.path.concat(0))){let t;for(;t=Qt(e,i.path.concat(0));)Ke(e,e,t)}else Xt(e,i.path)}}else if(function(e){return e.type===Jt.Move}(i)){let t=Qt(e,i.path);if(t){h(t)&&(t=t.item),r(t)&&(t=t.value);const n=t.items[i.from];Ke(e,t,n),Ne(e,t,n,i.to)}else{const t=Xt(e,i.path.concat(i.from));Ke(e,e,t);const n=Qt(e,i.path.concat(i.to)),o=n?e.items.indexOf(n):e.items.length;Ne(e,e,t,o)}}else if(function(e){return e.type===Jt.Rename}(i)){let n=Xt(e,i.path.concat(i.from)),o=Xt(t,i.path.concat(i.to));h(n)&&(n=n.item),h(o)&&(o=o.item),o.key.raw=(f=n.key.raw,o.key.value.map(e=>b.test(e)?e:`"${Je(e,f,"singleline-basic")}"`).join(".")),o.key.loc.end.column=o.key.loc.start.column+o.key.raw.length,Be(e,n,n.key,o.key)}var f}),Ve(e),e}(y,v,$,s);return{tomlString:fn(k,Wt(k.items,s),s),document:k}}function dn(e,t){if(i(e)&&i(t)){const n=nt(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(s(e)&&s(t)){const n=e.raw,o=t.value,l=Z.createDateWithOriginalFormat(o,n);t.value=l,t.raw=l.toISOString(),t.loc.end.column=t.loc.start.column+t.raw.length}if(a(e)&&a(t)){const n=St(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}if(u(e)&&u(t)){const n=It(e);if(t.items.length>0){t.items[t.items.length-1].comma=n}}}function pn(e,t,n){const o=[],l=(e,o)=>{var i;for(let s=e.items.length-1;s>=0;s--){const a=e.items[s];if(r(a)&&u(a.value)){const u=[...e.key.item.value,...a.key.value];if(xt(u)<(null!==(i=n.inlineTableStart)&&void 0!==i?i:1)&&0!==n.inlineTableStart){const n=Ge(u);for(const e of a.value.items)c(e)&&r(e.item)&&Ne(t,n,e.item,void 0);e.items.splice(s,1),Ct(e),o.push(n),l(n,o)}}}};return l(e,o),o}function gn(e,t){return e.line!==t.line?e.line-t.line:e.column-t.column}class wn{constructor(e,t){var n;const o="string"==typeof e?e:ut(e),l=mt(o);this._currentTomlString=l,this._ast=Array.from(me(l)),this._integersAsBigInt=null!==(n=null==t?void 0:t.integersAsBigInt)&&void 0!==n?n:"asNeeded",this._format=Tt.autoDetectFormatWithAst(o,this._ast)}get toTomlString(){return this._format.leadingBom?`\ufeff${this._currentTomlString}`:this._currentTomlString}get toJsObject(){return yn(Zt(this._ast,this._currentTomlString,this._integersAsBigInt))}get ast(){return this._ast}patch(e,t){const n=kt(t,this._format),{tomlString:o,document:l}=hn(this._ast,e,n);this._ast=l.items,this._format=n,this._currentTomlString=o}update(e){const t=mt(e);if(t===this._currentTomlString)return void(this._format.leadingBom=ft(e));const n=this._currentTomlString.split(this._format.newLine),o=$t(t),l=t.split(o);let r=0;for(;r<n.length&&r<l.length&&n[r]===l[r];)r++;let i=0;if(r<n.length&&r<l.length){const e=n[r],t=l[r];for(let n=0;n<Math.max(e.length,t.length);n++)if(e[n]!==t[n]){i=n;break}}let s=r+1;const{truncatedAst:a,lastEndPosition:c}=function(e,t,n){const o={line:t,column:n},l=[];let r=null;for(const t of e){const e=gn(t.loc.end,o)<0,n=gn(t.loc.start,o)<0;if(!e){if(n&&!e)break;break}l.push(t),r=t.loc.end}return{truncatedAst:l,lastEndPosition:r}}(this._ast,s,i),u=c?c.line:1,f=c?c.column+1:0,m=l.slice(u-1);m.length>0&&f>0&&(m[0]=m[0].substring(f));const h=m.join(this._format.newLine);this._ast=Array.from(function*(e,t){for(const t of e)yield t;const n=new W(C(t));for(;!n.next().done;){const e=be(n,t);for(const t of e)yield t}}(a,h)),this._currentTomlString=t,this._format=Tt.autoDetectFormatWithAst(e,this._ast)}overwrite(e){const t=mt(e);t!==this._currentTomlString?(this._ast=Array.from(me(t)),this._currentTomlString=t,this._format=Tt.autoDetectFormatWithAst(e,this._ast)):this._format.leadingBom=ft(e)}}function yn(e){if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(yn);if(e&&"object"==typeof e){const t={};for(const[n,o]of Object.entries(e))t[n]=yn(o);return t}return e}function vn(e,t){var n;const o=mt("string"==typeof e?e:ut(e));return Zt(me(o),o,null!==(n=null==t?void 0:t.integersAsBigInt)&&void 0!==n?n:"asNeeded")}function bn(e,t){const n=kt(t,Tt.default()),o=Wt(Ot(e,n).items,n);return n.leadingBom?`\ufeff${o}`:o}export{V as LocalDate,z as LocalDateTime,q as LocalTime,R as OffsetDateTime,wn as TomlDocument,Tt as TomlFormat,vn as parse,mn as patch,bn as stringify};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decimalturn/toml-patch",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "contributors": [
5
5
  "Tim Hall <tim.hall.engr@gmail.com>",
6
6
  "Martin Leduc <31558169+DecimalTurn@users.noreply.github.com>"
@@ -37,18 +37,18 @@
37
37
  }
38
38
  },
39
39
  "devDependencies": {
40
- "@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@1.2.0",
40
+ "@decimalturn/toml-patch": "npm:@decimalturn/toml-patch@1.2.2",
41
41
  "@playwright/test": "^1.59.1",
42
42
  "@rollup/plugin-terser": "^1.0.0",
43
43
  "@rollup/plugin-typescript": "^12.1.2",
44
44
  "@types/dedent": "^0.7.2",
45
45
  "@types/jest": "^30.0.0",
46
46
  "@types/js-yaml": "^4.0.0",
47
- "@types/node": "^24.0.0",
47
+ "@types/node": "^24.12.3",
48
48
  "benchmark": "^2",
49
49
  "dedent": "^1.5.3",
50
50
  "glob": "^13.0.0",
51
- "jest": "^30.0.0",
51
+ "jest": "^30.4.1",
52
52
  "jsr": "^0.14.0",
53
53
  "js-yaml": "^4.0.0",
54
54
  "mri": "^1",
@@ -74,10 +74,7 @@
74
74
  "json-comments": {
75
75
  "tips": "Please install the JsonComments plugin to enable commenting functionality for JSON files, see: https://github.com/zhangfisher/json_comments_extension",
76
76
  "package.json": {
77
- "devDependencies.js-yaml": "Used by specs/specs.test.ts to parse YAML expected-value fixtures from submodules/spec-tests (https://github.com/iarna/toml-spec-tests).",
78
- "pnpm.overrides.lodash": "Override needed to avoid vuln detailed in https://github.com/DecimalTurn/toml-patch/security/dependabot/44",
79
- "pnpm.overrides.picomatch": "Override needed to avoid picomatch vuln detailed in https://github.com/DecimalTurn/toml-patch/security/dependabot/42",
80
- "pnpm.overrides.serialize-javascript": "https://github.com/DecimalTurn/toml-patch/security/dependabot/40"
77
+ "devDependencies.js-yaml": "Used by specs/specs.test.ts to parse YAML expected-value fixtures from submodules/spec-tests (https://github.com/iarna/toml-spec-tests)."
81
78
  }
82
79
  },
83
80
  "scripts": {