vbapm 0.6.15 → 0.8.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.
Files changed (71) hide show
  1. package/README.md +86 -0
  2. package/addins/build/vbapm.xlam +0 -0
  3. package/lib/actions/add-source.d.ts +11 -0
  4. package/lib/actions/export-project.d.ts +2 -0
  5. package/lib/actions/update-project.d.ts +7 -0
  6. package/lib/add-source-BOumGmx7.js +17 -0
  7. package/lib/addin.d.ts +1 -0
  8. package/lib/bin/vbapm-add.d.ts +2 -0
  9. package/lib/bin/vbapm-update.d.ts +2 -0
  10. package/lib/build-project-De7NPBpt.js +3 -0
  11. package/lib/build-target-ooHNsSLD.js +9 -0
  12. package/lib/{create-project-CPIRr0DV.js → create-project-BYc3XMZw.js} +1 -1
  13. package/lib/debug.js +1 -1
  14. package/lib/errors.d.ts +6 -0
  15. package/lib/export-project-CgFMyE-g.js +4 -0
  16. package/lib/export-target-C0RYJqUX.js +4 -0
  17. package/lib/{get-target-CH6IpAa1.js → get-target-LUoY1UWJ.js} +1 -1
  18. package/lib/index-C61lSPb5.js +1 -0
  19. package/lib/index-CBGUBgfk.js +13 -0
  20. package/lib/index-ClUEyMCY.js +6 -0
  21. package/lib/{index-Dg07BXJE.js → index-Cp8MNK26.js} +1 -1
  22. package/lib/{index-D-khpcjL.js → index-Dv6JxqGo.js} +9 -9
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -1
  25. package/lib/init-project-9RKSVG_H.js +15 -0
  26. package/lib/installer-DPj-zT7L.js +9 -0
  27. package/lib/{load-from-project-Bpb6Ne_i.js → load-from-project-ClF4qaC0.js} +1 -1
  28. package/lib/messages.d.ts +2 -0
  29. package/lib/one_ini_bg.wasm +0 -0
  30. package/lib/project-BPmPCkUS.js +20 -0
  31. package/lib/run-macro-C1-aJWu5.js +1 -0
  32. package/lib/sat-solver-B6RXdyQs.js +1 -0
  33. package/lib/targets/build-target.d.ts +1 -0
  34. package/lib/targets/export-target.d.ts +3 -1
  35. package/lib/targets/transforms/format-xml.d.ts +2 -0
  36. package/lib/test-project-DXBFZH3o.js +1 -0
  37. package/lib/toml-patch-r8oqFm0h.js +3 -0
  38. package/lib/transform-build-graph-DgRrocSn.js +1 -0
  39. package/lib/transform-target-CYhuozxP.js +2 -0
  40. package/lib/utils/encoding.d.ts +30 -0
  41. package/lib/utils/run.d.ts +4 -1
  42. package/lib/utils/xml.d.ts +14 -0
  43. package/lib/vbapm-add-CASFjXAL.js +16 -0
  44. package/lib/vbapm-build-Bhm_pqQW.js +9 -0
  45. package/lib/vbapm-export-8KDCdFOz.js +9 -0
  46. package/lib/{vbapm-init-csKsZ87H.js → vbapm-init-Ba2xCez2.js} +1 -1
  47. package/lib/{vbapm-new-Dt0tX1xQ.js → vbapm-new-YQRNQ4Iq.js} +1 -1
  48. package/lib/{vbapm-run-Ccciwg2y.js → vbapm-run-J-R--noZ.js} +2 -2
  49. package/lib/{vbapm-test-u7AWC-AV.js → vbapm-test-C4KWMPLz.js} +1 -1
  50. package/lib/vbapm-update-DnbmW8tc.js +13 -0
  51. package/lib/vbapm-version-CRicT8YA.js +8 -0
  52. package/lib/vbapm.js +3 -1
  53. package/package.json +127 -137
  54. package/run-scripts/run.applescript +18 -7
  55. package/run-scripts/run.ps1 +42 -10
  56. package/lib/build-project-BczswKQl.js +0 -3
  57. package/lib/build-target-D6L5nsgt.js +0 -9
  58. package/lib/export-project-DQ3bfvbV.js +0 -4
  59. package/lib/export-target-CN6RA_mA.js +0 -4
  60. package/lib/index-DXFu_Z-o.js +0 -6
  61. package/lib/init-project-dRuDA4YO.js +0 -15
  62. package/lib/installer-CJlDenLg.js +0 -9
  63. package/lib/project-C3bWzV0O.js +0 -29
  64. package/lib/run-macro-D_9-BO3U.js +0 -1
  65. package/lib/sat-solver-5AniWyxz.js +0 -1
  66. package/lib/test-project-BTkTNZXs.js +0 -1
  67. package/lib/toml-patch.es-CxrbsPnB.js +0 -3
  68. package/lib/transform-target-Doak2S1q.js +0 -2
  69. package/lib/vbapm-build-B1OOy6VL.js +0 -9
  70. package/lib/vbapm-export-vvUDCDqi.js +0 -7
  71. package/lib/vbapm-version-Bsb-cWCD.js +0 -8
@@ -5,6 +5,7 @@ export interface BuildOptions {
5
5
  release?: boolean;
6
6
  target?: string;
7
7
  addin?: string;
8
+ open?: boolean;
8
9
  }
9
10
  /**
10
11
  * Build target:
@@ -2,6 +2,8 @@ import { Target } from "../manifest/target";
2
2
  import { Project } from "../project";
3
3
  import { ProjectInfo } from "./project-info";
4
4
  export interface ExportOptions {
5
+ xmlOnly?: boolean;
6
+ vbaOnly?: boolean;
5
7
  }
6
8
  /**
7
9
  * Export target (with staging directory)
@@ -11,5 +13,5 @@ export interface ExportOptions {
11
13
  * 3. Export build graph to src
12
14
  * 4. Move extracted to target to src
13
15
  */
14
- export declare function exportTarget(target: Target, info: ProjectInfo, staging: string): Promise<void>;
16
+ export declare function exportTarget(target: Target, info: ProjectInfo, staging: string, options?: ExportOptions): Promise<void>;
15
17
  export declare function extractTarget(project: Project, target: Target, staging: string): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import { UnzipFile } from "../../utils/zip";
2
+ export default function transformFormatXml(file: UnzipFile): UnzipFile;
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./installer-DPj-zT7L.js"),t=require("./run-macro-C1-aJWu5.js");exports.testProject=async function(s){const{target:e,args:a}=s,n=r.env.isWindows?"CON":"/dev/stdout";await t.runMacro({target:e,macro:"Tests.Run",args:[n,...a]})};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ //! @decimalturn/toml-patch v1.0.5 - https://github.com/DecimalTurn/toml-patch - @license: MIT
3
+ var e,t;function n(t){return t.type===e.Document}function o(t){return t.type===e.Table}function r(t){return t.type===e.TableArray}function l(t){return t.type===e.KeyValue}function a(t){return t.type===e.String}function i(t){return t.type===e.DateTime}function s(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)||r(e)||u(e)||s(e)}function d(t){return function(t){return t.type===e.TableKey}(t)||function(t){return t.type===e.TableArrayKey}(t)||c(t)}function h(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:w(e);if(0===n.length)return{line:1,column:t};let o=0,r=n.length-1;for(;o<r;){const e=o+r>>>1;n[e]<t?o=e+1:r=e}n[o]<t&&o++;const l=o+1;return{line:l,column:t-(n[l-2]+1||0)}}function w(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 y(e){return{line:e.line,column:e.column}}function g(e){return{start:y(e.start),end:y(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=w(e),o=void 0!==n[t.line-2]?n[t.line-2]+1:0,r=n[t.line-1]||e.length;return e.substring(o,r)}(e,t),r=`${function(e,t=" "){return t.repeat(e)}(t.column)}^`;n&&(o+=`${n}\n${r}\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='"',$="'",T=" ",k=/[\w,\d,",',+,\-,_]/,S=10,I=13,E=127;function*A(e){const n=e.length;let o=0;const r=[],l=(e,t)=>({start:p(r,e),end:p(r,t)});for(;o<n;){const c=e.charCodeAt(o);if((c<=31||c===E)&&9!==c&&c!==I&&c!==S)throw new v(e,p(r,o),`Control char 0x${c.toString(16).toUpperCase().padStart(2,"0")} not allowed`);if(c===I&&(o+1>=n||e.charCodeAt(o+1)!==S))throw new v(e,p(r,o),"Standalone CR; must be CRLF or LF");if(32===c||9===c||c===I);else if(c===S)r.push(o);else if(91===c||93===c)yield{type:t.Bracket,raw:e[o],loc:l(o,o+1)};else if(123===c||125===c)yield{type:t.Curly,raw:e[o],loc:l(o,o+1)};else if(61===c)yield{type:t.Equal,raw:"=",loc:l(o,o+1)};else if(44===c)yield{type:t.Comma,raw:",",loc:l(o,o+1)};else if(46===c)yield{type:t.Dot,raw:".",loc:l(o,o+1)};else if(35===c)yield a();else{const t=C(e,o,$)||C(e,o,b);t?yield i(t):yield s()}o++}function a(){const a=o;for(;o+1<n;){const t=e.charCodeAt(o+1);if(t===S||t===I)break;o++;const n=e.charCodeAt(o);if((n<=31||n===E)&&9!==n)throw new v(e,p(r,o),`Control char 0x${n.toString(16).toUpperCase().padStart(2,"0")} not allowed`)}return{type:t.Comment,raw:e.slice(a,o+1),loc:l(a,o+1)}}function i(a){const i=o,s=a+a+a;for(o+=3;o<n;){if(C(e,o,a)){let t=3;for(;e[o+t]===a;)t++;if(t>=6)throw new v(e,p(r,o),`Invalid multiline string: ${t} consecutive ${a} characters`);if(3===t){o+=2;break}o+=t-3,o+=2;break}const t=e.charCodeAt(o);if(t===I&&(o+1>=n||e.charCodeAt(o+1)!==S))throw new v(e,p(r,o),"Standalone CR in multiline string; must be CRLF or LF");if((t<=31||t===E)&&9!==t&&t!==S&&t!==I){const n=a===b?"multiline basic strings":"multiline literal strings",l=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let i="";0===t?i="Null":t===E&&(i="DEL");const s=i?`${i} (${l}) not allowed in ${n}`:`Control char ${l} not allowed in ${n}`;throw new v(e,p(r,o),s)}t===S&&r.push(o),o++}if(o>=n){if(a===b){let t=0,l=n-1;for(;l>=0&&"\\"===e[l];)t++,l--;if(t>0&&t%2!=0)throw new v(e,p(r,o),`Unterminated multiline ${s} (possible escape issue)`)}throw new v(e,p(r,o),`Unterminated multiline ${s}`)}return{type:t.Literal,raw:e.slice(i,o+1),loc:l(i,o+1)}}function s(){const a=e[o];if(!k.test(a))throw new v(e,p(r,o),`Unexpected char "${a}"`);const i=o;let s=a===b,c=a===$;for(;o<n&&!(o+1>=n);){const t=e.charCodeAt(o+1);if(!(s||c||32!==t&&9!==t&&t!==S&&t!==I&&44!==t&&46!==t&&93!==t&&125!==t&&61!==t&&35!==t))break;if(o++,s||c){const t=e.charCodeAt(o);if((t<=31||t===E)&&9!==t){const n=s?"basic strings":"literal strings",l=`0x${t.toString(16).toUpperCase().padStart(2,"0")}`;let a="";t===S?a="Newline":t===I?a="Carriage return":0===t?a="Null":t===E&&(a="DEL");const i=a?`${a} (${l}) not allowed in ${n}`:`Control char ${l} not allowed in ${n}`;throw new v(e,p(r,o),i)}}const l=e[o];if(l===b&&(s=!s),l!==$||s||(c=!c),o+1>=n)break;if(s&&"\\"===l){const t=e[o+1];t!==b&&"\\"!==t||o++}}if(s||c)throw new v(e,p(r,i),`Expected close of string with ${s?b:$}`);return{type:t.Literal,raw:e.slice(i,o+1),loc:l(i,o+1)}}}function C(e,t,n){if(!n)return!1;if(e[t]!==n||e[t+1]!==n||e[t+2]!==n)return!1;if(n===$)return n;let o=0,r=t-1;for(;r>=0&&"\\"===e[r];)o++,r--;return(0===o||!(o%2!=0))&&n}const x=new Int8Array(128);x.fill(-1);for(let e=0;e<10;e++)x[48+e]=e;for(let e=0;e<6;e++)x[65+e]=10+e,x[97+e]=10+e;function _(e){const t=e.charCodeAt(0);return t<128&&-1!==x[t]}function O(e,t){return x[e.charCodeAt(t)]<<12|x[e.charCodeAt(t+1)]<<8|x[e.charCodeAt(t+2)]<<4|x[e.charCodeAt(t+3)]}function D(e){return e.startsWith("'''")?L(e.slice(3,e.length-3)):e.startsWith($)?e.slice(1,e.length-1):e.startsWith('"""')?F(L(e.slice(3,e.length-3)),!0):e.startsWith(b)?F(e.slice(1,e.length-1),!1):e}function F(e,t){const n=e.length;if(!t&&-1===e.indexOf("\\"))return e;const o=[];let r=0;for(let l=0;l<n;l++){if("\\"!==e[l])continue;if(l>r&&o.push(e.slice(r,l)),l++,l>=n)throw new Error("Trailing backslash");const a=e[l];switch(a){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(l+4>n||!_(e[l+1])||!_(e[l+2])||!_(e[l+3])||!_(e[l+4]))throw new Error(`Invalid Unicode escape: \\u${e.slice(l+1,l+5)}`);const t=O(e,l+1);if(t>=55296&&t<=57343)throw new Error(`Invalid \\u${e.slice(l+1,l+5)}: surrogates not allowed`);o.push(String.fromCharCode(t)),l+=4;break}case"U":{if(l+8>n)throw new Error(`Invalid Unicode escape: \\U${e.slice(l+1,l+9)}`);for(let t=1;t<=8;t++)if(!_(e[l+t]))throw new Error(`Invalid Unicode escape: \\U${e.slice(l+1,l+9)}`);const t=parseInt(e.slice(l+1,l+9),16);o.push(String.fromCodePoint(t)),l+=8;break}case"x":{if(l+2>n||!_(e[l+1])||!_(e[l+2]))throw new Error(`Invalid hex escape: \\x${e.slice(l+1,l+3)}`);const t=x[e.charCodeAt(l+1)]<<4|x[e.charCodeAt(l+2)];o.push(String.fromCharCode(t)),l+=2;break}default:if(t&&("\n"===a||"\r"===a||" "===a||"\t"===a)){let t="\n"===a||"\r"===a,o=l;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: \\${a}`);l=o-1;break}throw new Error(`Invalid escape sequence: \\${a}`)}r=l+1}return 0===r?e:(r<n&&o.push(e.slice(r)),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 K{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 M();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?M():(this.peeked||(this.peeked=this.iterator.next()),this.peeked)}[Symbol.iterator](){return this}}const U=Object.freeze({value:void 0,done:!0});function M(){return U}function N(e){return{year:String(e.getUTCFullYear()),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),r=o?o[1].length:3;return"."+String(e).padStart(3,"0").slice(0,r)}return e>0?"."+String(e).padStart(3,"0").replace(/0+$/,""):""}function W(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 B{static createDateWithOriginalFormat(e,t){if(B.IS_DATE_ONLY.test(t)){if(0!==e.getUTCHours()||0!==e.getUTCMinutes()||0!==e.getUTCSeconds()||0!==e.getUTCMilliseconds()){if(e instanceof z)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 Z(t)}if(B.IS_TIME_ONLY.test(t)){if(e instanceof V)return e;{const n=N(e),o=j(n.ms,t);return new V(`${n.hours}:${n.minutes}:${n.seconds}${o}`,t)}}if(B.IS_LOCAL_DATETIME_T.test(t)){const n=N(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(B.IS_LOCAL_DATETIME_SPACE.test(t)){const n=N(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(B.IS_OFFSET_DATETIME_T.test(t)||B.IS_OFFSET_DATETIME_SPACE.test(t)){const n=t.match(/([+-]\d{2}:\d{2}|[Zz])$/),o=n?"z"===n[1]?"Z":n[1]:"Z",r=B.IS_OFFSET_DATETIME_SPACE.test(t),l=N(new Date(e.getTime()+6e4*W(o))),a=r?" ":"T",i=j(l.ms,t,/\.(\d+)(?:[Zz]|[+-]\d{2}:\d{2})\s*$/),s=`${l.year}-${l.month}-${l.day}${a}${l.hours}:${l.minutes}:${l.seconds}${i}${o}`;return new z(s,r)}return e}}B.IS_DATE_ONLY=/^\d{4}-\d{2}-\d{2}$/,B.IS_TIME_ONLY=/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,B.IS_LOCAL_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,B.IS_LOCAL_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/,B.IS_OFFSET_DATETIME_T=/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,B.IS_OFFSET_DATETIME_SPACE=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/,B.IS_FULL_DATE=/(\d{4})-(\d+)-(\d+)/,B.IS_FULL_TIME=/(\d+):(\d+)(?::(\d+))?/;class Z extends Date{constructor(e){super(e)}toISOString(){const e=N(this);return`${e.year}-${e.month}-${e.day}`}}class V 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=N(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=N(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 z 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=N(new Date(this.getTime()+6e4*W(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 R=B,P="true",H=/e/i,Y=/_/g,J=/^[+-]?inf$/,G=/^[+-]?nan$/,Q=/^[+-]?0x/i;function X(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||95===e||45===e}const ee=/^[+-]?0o/i,te=/^[+-]?0b/i;function ne(e,t,n){for(let o=0;o<e.length;o++)if(!X(e.charCodeAt(o)))throw new v(t,{line:n.line,column:n.column+o},`Invalid bare key char '${e[o]}'`)}function oe(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 D(e)}catch(e){throw new v(t,n,e.message)}}function le(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 ae(e,t,n,o){const r=e.replace(Y,"");if(/^[+-]?0\d/.test(r)&&!Q.test(e)&&!ee.test(e)&&!te.test(e))throw new v(t,n,`Leading zeros are not allowed in ${o}`)}function ie(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 se(e,t,n,o,r,l){if(2!==e.length)throw new v(r,l,`"${o}": hour must be 2 digits`);if(2!==t.length)throw new v(r,l,`"${o}": minute must be 2 digits`);if(n&&2!==n.length)throw new v(r,l,`"${o}": second must be 2 digits`)}function ce(e,t,n,o,r,l){if(void 0!==e){const t=parseInt(e,10);if(t<0||t>23)throw new v(r,l,`"${o}": hour must be 00-23`)}if(void 0!==t){const e=parseInt(t,10);if(e<0||e>59)throw new v(r,l,`"${o}": minute must be 00-59`)}if(void 0!==n){const e=parseInt(n,10);if(e<0||e>60)throw new v(r,l,`"${o}": second must be 00-60`)}}function ue(e,t,n,o,r,l,a){const i=o[0]+o[1].toUpperCase();if(new RegExp("^[+\\-]?"+i.replace(/([[\]])/g,"\\$1")).test(e))throw new v(t,n,`${l} prefix must be lowercase "${o}"`);if(new RegExp("^[+\\-]?"+o+"_","i").test(e))throw new v(t,n,"Underscore must be between digits");const s=new RegExp("^[+\\-]?"+o,"i"),c=e.replace(s,"");if(!c||"_"===c||c.startsWith("_"))throw new v(t,n,`Incomplete ${l.toLowerCase()} number`);const u=c.replace(/_/g,"");if(!r.test(u))throw new v(t,n,null!=a?a:`Invalid ${l.toLowerCase()} digits`);if(/^[+-]/.test(e))throw new v(t,n,`${l} numbers cannot have a sign prefix`)}function*fe(e){const t=new K(A(e));for(;!t.next().done;){const n=ve(t,e);for(const e of n)yield e}}function me(t){return{type:e.Comment,loc:t.value.loc,raw:t.value.raw}}function de(n,o){const r=n.peek().done||n.peek().value.type!==t.Bracket?e.Table:e.TableArray,l=r===e.Table;if(l&&"["!==n.value.raw)throw new v(o,n.value.loc.start,`Expected table opening "[", found ${n.value.raw}`);if(!l){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,r=e.value;if(t.loc.end.line!==r.loc.start.line||t.loc.end.column!==r.loc.start.column)throw new v(o,t.loc.start,'"[[" brackets must be adjacent (no whitespace)')}const a=l?{type:e.TableKey,loc:n.value.loc}:{type:e.TableArrayKey,loc:n.value.loc};if(n.next(),r===e.TableArray&&n.next(),n.done)throw new v(o,a.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,r===e.TableArray?"Array of Tables header [[]] requires a table name":"Table header [] requires a table name");const i=n.value.raw;let s;for(oe(i,o,n.value.loc.start),i.startsWith('"')||i.startsWith("'")||ne(i,o,n.value.loc.start),s=[re(n.value.raw,o,n.value.loc.start)],a.item={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:s};!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("'")||ne(t,o,n.value.loc.start);const r=" ".repeat(e.loc.start.column-a.item.loc.end.column),l=" ".repeat(n.value.loc.start.column-e.loc.end.column);a.item.loc.end=n.value.loc.end,a.item.raw+=`${r}.${l}${n.value.raw}`;try{a.item.value.push(D(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=a.loc.start.line;if(n.value.loc.start.line!==e)throw new v(o,n.value.loc.start,l?"Table header must be single-line":"Array of Tables header must be single-line")}if(l&&(n.done||"]"!==n.value.raw))throw new v(o,n.done?a.item.loc.end:n.value.loc.start,`Expected table closing "]", found ${n.done?"end of file":n.value.raw}`);if(!l&&(n.done||n.peek().done||"]"!==n.value.raw||"]"!==n.peek().value.raw))throw new v(o,n.done||n.peek().done?a.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(!l){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(l||n.next(),a.loc.end=n.value.loc.end,!n.peek().done){const e=n.peek().value;if(e.loc.start.line===a.loc.end.line&&e.type!==t.Comment)throw new v(o,e.loc.start,`Extra content after ${l?"table":"Array of Tables"} header`)}let c=[];for(;!n.peek().done&&n.peek().value.type!==t.Bracket;){n.next();const e=ve(n,o);for(let t=0;t<e.length;t++)c.push(e[t])}return{type:l?e.Table:e.TableArray,loc:{start:y(a.loc.start),end:c.length?y(c[c.length-1].loc.end):y(a.loc.end)},key:a,items:c}}function he(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 pe(t){return{type:e.Boolean,loc:t.value.loc,value:t.value.raw===P}}function we(n,o){let r,l=n.value.loc,a=n.value.raw;if(!n.peek().done&&n.peek().value.type===t.Literal&&R.IS_FULL_DATE.test(a)&&R.IS_FULL_TIME.test(n.peek().value.raw)){const e=l.start;n.next(),l={start:e,end:n.value.loc.end},a+=` ${n.value.raw}`}if(!n.peek().done&&n.peek().value.type===t.Dot){const e=l.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(),l={start:e,end:n.value.loc.end},a+=`.${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)?e.match(/([+-])(\d+)(:?)(\d*)$/):null;if(o){const e=o[0],r=o[2],l=o[3],a=o[4];if(":"!==l)throw new v(t,n,`Offset "${e}": missing colon separator`);if(2!==r.length)throw new v(t,n,`Offset "${e}": hour must be 2 digits`);if(!a||0===a.length)throw new v(t,n,`Offset "${e}": minute required`);if(2!==a.length)throw new v(t,n,`Offset "${e}": minute must be 2 digits`);const i=parseInt(r,10);if(i<0||i>23)throw new v(t,n,`Offset "${e}": hour must be 00-23`);const s=parseInt(a,10);if(s<0||s>59)throw new v(t,n,`Offset "${e}": minute must be 00-59`)}if(!/^\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?$/.test(e)&&!/^\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?$/.test(e)){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 r=e.match(/^(\d+)-/);if(r&&4!==r[1].length)throw new v(t,n,`"${e}": year must be 4 digits`);const l=e.match(/^(\d+)-(\d+)-(\d+)/);if(l){const[,,o,r]=l;if(2!==o.length)throw new v(t,n,`"${e}": month must be 2 digits`);if(2!==r.length)throw new v(t,n,`"${e}": day must be 2 digits`)}const a=e.match(/[T ](\d+):(\d+)(?::(\d+))?/);if(a){const[,o,r,l]=a;se(o,r,l,e,t,n)}const i=e.match(/^(\d+):(\d+)(?::(\d+))?/);if(i&&!l){const[,o,r,l]=i;se(o,r,l,e,t,n)}const s=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?/),c=e.match(/^(\d{2}):(\d{2})(?::(\d{2}))?/);if(s){const[,o,r,l,a,i,c]=s,u=parseInt(r,10);if(u<1||u>12)throw new v(t,n,`"${e}": month must be 01-12`);const f=parseInt(l,10);if(f<1||f>31)throw new v(t,n,`"${e}": day must be 01-31`);const m=function(e,t){return 2===t?e%4==0&&e%100!=0||e%400==0?29:28:[31,28,31,30,31,30,31,31,30,31,30,31][t-1]}(parseInt(o,10),u);if(f>m)throw new v(t,n,`"${e}": day ${l} invalid for ${o}-${r}`);ce(a,i,c,e,t,n)}else if(c){const[,o,r,l]=c;ce(o,r,l,e,t,n)}}(a,o,l.start),R.IS_FULL_DATE.test(a))r=R.IS_DATE_ONLY.test(a)?new Z(a):R.IS_LOCAL_DATETIME_T.test(a)?new q(a,!1):R.IS_LOCAL_DATETIME_SPACE.test(a)?new q(a,!0):R.IS_OFFSET_DATETIME_T.test(a)?new z(a,!1):R.IS_OFFSET_DATETIME_SPACE.test(a)?new z(a,!0):new Date(a.replace(" ","T"));else if(R.IS_TIME_ONLY.test(a))r=new V(a,a);else{const[e]=(new Date).toISOString().split("T");r=new Date(`${e}T${a}`)}return{type:e.DateTime,loc:l,raw:a,value:r}}function ye(n,o){let r,l=n.value.loc,a=n.value.raw;if(J.test(a))r=a.startsWith("-")?-1/0:1/0;else if(G.test(a))r=NaN;else if(n.peek().done||n.peek().value.type!==t.Dot){if(le(a,o,l.start),ie(a,a,o,l.start),!n.peek().done&&n.peek().value.type===t.Dot)throw new v(o,n.peek().value.loc.start,`Float "${a}.": dot after exponent`);ae(a,o,l.start,"the integer part of a float"),r=Number(a.replace(Y,""))}else{const e=l.start;{if(H.test(a)&&!Q.test(a))throw new v(o,l.start,`Float "${a}": dot after exponent`);const e=a;ae(e,o,l.start,"the integer part of a float");const t=e.replace(/^[+-]/,"");if(""===t||"_"===t)throw new v(o,l.start,"Float: digit required before dot");le(e,o,l.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(),a+=`.${n.value.raw}`,l={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}"`);le(e,o,n.value.loc.start,!1),ie(e,a,o,n.value.loc.start)}r=Number(a.replace(Y,""))}if(Number.isNaN(r)&&!G.test(a))throw new v(o,l.start,`Invalid float "${a}"`);return{type:e.Float,loc:l,raw:a,value:r}}function ge(t,n){const o=t.value.raw,r=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,r.start,`Invalid integer "${o}"`);if("-0"===o||"+0"===o)return{type:e.Integer,loc:r,raw:o,value:0};if(/^[+-]{2,}/.test(o))throw new v(n,r.start,"Double sign is not allowed in integers");ae(o,n,r.start,"decimal integers"),le(o,n,r.start);let l=10;Q.test(o)?(l=16,ue(o,n,r.start,"0x",/^[0-9a-fA-F]+$/,"Hexadecimal")):ee.test(o)?(l=8,ue(o,n,r.start,"0o",/^[0-7]+$/,"Octal","Invalid octal digits (must be 0-7)")):te.test(o)&&(l=2,ue(o,n,r.start,"0b",/^[01]+$/,"Binary","Invalid binary digits (must be 0 or 1)"));const a=parseInt(o.replace(Y,"").replace(ee,"").replace(te,""),l);if(Number.isNaN(a))throw new v(n,r.start,`Invalid integer "${o}"`);return{type:e.Integer,loc:r,raw:o,value:a}}function ve(n,o){if(n.value.type===t.Comment)return[me(n)];if(n.value.type===t.Bracket)return[de(n,o)];if(n.value.type===t.Literal)return function(n,o){const r=n.value.raw;if(r.endsWith(":"))throw new v(o,{line:n.value.loc.start.line,column:n.value.loc.start.column+[...r].length-1},"Use '=' to separate keys and values, not ':'");let l;oe(r,o,n.value.loc.start),r.startsWith('"')||r.startsWith("'")||ne(r,o,n.value.loc.start),l=[re(n.value.raw,o,n.value.loc.start)];const a={type:e.Key,loc:n.value.loc,raw:n.value.raw,value:l};for(;!n.peek().done&&n.peek().value.type===t.Dot;){n.next(),n.next();const e=n.value.raw;oe(e,o,n.value.loc.start),e.startsWith('"')||e.startsWith("'")||ne(e,o,n.value.loc.start),a.loc.end=n.value.loc.end,a.raw+=`.${n.value.raw}`,a.value.push(re(n.value.raw,o,n.value.loc.start))}if(n.next(),!n.done&&n.value.loc.start.line!==a.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?a.loc.end:n.value.loc.start,'Expected "=" for key-value')}const i=n.value.loc.start.column,s=n.value.loc.start.line;if(n.next(),n.done)throw new v(o,a.loc.start,"Expected value, reached EOF");if(n.value.loc.start.line!==s)throw new v(o,n.value.loc.start,"Value must be on same line as '='");if(n.done)throw new v(o,a.loc.start,"Expected value for key-value");const c=be(n,o),u=c[0];if(!n.peek().done){const r=n.peek().value;if(r.type===t.Dot&&r.loc.start.line===u.loc.end.line&&(u.type===e.Float||u.type===e.Integer))throw new v(o,r.loc.start,"Invalid number: multiple decimal points not allowed");if((r.type===t.Literal||r.type===t.Bracket)&&r.loc.start.line===u.loc.end.line)throw new v(o,r.loc.start,"Key/value pairs must be separated by a newline")}return c[0]={type:e.KeyValue,key:a,value:u,loc:{start:y(a.loc.start),end:y(u.loc.end)},equals:i},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 be(n,o){if(n.value.type===t.Literal){const e=n.value.raw;return e[0]===b||e[0]===$?[he(n,o)]:e===P||"false"===e?[pe(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||J.test(e)||G.test(e)||H.test(e)&&!Q.test(e)?[ye(n,o)]:[ge(n,o)]}if(n.value.type===t.Curly){const[r,l]=function(n,o){if("{"!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "{" for inline table');const r={type:e.InlineTable,loc:n.value.loc,items:[]},l=[];for(n.next();!n.done&&(n.value.type!==t.Curly||"}"!==n.value.raw);){if(n.value.type===t.Comment){l.push(me(n)),n.next();continue}if(n.value.type===t.Comma){const e=r.items[r.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 a=r.items[r.items.length-1];if(a&&!a.comma)throw new v(o,n.value.loc.start,"Missing comma between inline table items");const i=ve(n,o),s=i[0];if(s.type===e.KeyValue){r.items.push({type:e.InlineItem,loc:g(s.loc),item:s,comma:!1});for(let e=1;e<i.length;e++)l.push(i[e])}n.next()}if(n.done||n.value.type!==t.Curly||"}"!==n.value.raw)throw new v(o,n.done?r.loc.start:n.value.loc.start,'Expected "}"');return r.loc.end=n.value.loc.end,[r,l]}(n,o);return[r,...l]}if(n.value.type===t.Bracket){const[r,l]=function(n,o){if("["!==n.value.raw)throw new v(o,n.value.loc.start,'Expected "[" for inline array');const r={type:e.InlineArray,loc:n.value.loc,items:[]},l=[];for(n.next();!n.done&&(n.value.type!==t.Bracket||"]"!==n.value.raw);){if(n.value.type===t.Comma){const e=r.items[r.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)l.push(me(n));else{const t=r.items[r.items.length-1];if(t&&!t.comma)throw new v(o,n.value.loc.start,"Missing comma between array elements");const a=be(n,o),i=a[0];r.items.push({type:e.InlineItem,loc:g(i.loc),item:i,comma:!1});for(let e=1;e<a.length;e++)l.push(a[e])}n.next()}if(n.done||n.value.type!==t.Bracket||"]"!==n.value.raw)throw new v(o,n.done?r.loc.start:n.value.loc.start,'Expected "]"');return r.loc.end=n.value.loc.end,[r,l]}(n,o);return[r,...l]}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 $e(e){return e[e.length-1]}function Te(){return Object.create(null)}function ke(e){return"number"==typeof e&&e%1==0&&isFinite(e)&&!Object.is(e,-0)}function Se(e){return"[object Date]"===Object.prototype.toString.call(e)}function Ie(e){return e&&"object"==typeof e&&!Se(e)&&!Array.isArray(e)}function Ee(e){return null!=e&&"function"==typeof e[Symbol.iterator]}function Ae(e,t){return t in e}function Ce(e){return Ie(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Ce(e[t])}`).join(",")}}`:Array.isArray(e)?`[${e.map(Ce).join(",")}]`:JSON.stringify(e)}function xe(e,t){const n=e.length,o=t.length;e.length=n+o;for(let r=0;r<o;r++)e[n+r]=t[r]}function _e(e){return e.startsWith('"""')||e.startsWith("'''")}const Oe=new WeakSet,De=new WeakMap,Fe=e=>(De.has(e)||De.set(e,new WeakMap),De.get(e)),Le=new WeakMap,Ke=e=>(Le.has(e)||Le.set(e,new WeakMap),Le.get(e));function Ue(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(l(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(d(t))t.item=o;else{if(!l(t))throw new Error(`Unsupported parent type "${t.type}" for replace`);t.key===n?t.key=o:t.value=o}Ve(o,{lines:n.loc.start.line-o.loc.start.line,columns:n.loc.start.column-o.loc.start.column});const r=h(n.loc),a=h(o.loc);qe({lines:a.lines-r.lines,columns:a.columns-r.columns},Ke(e),o,n),Oe.add(e)}function Me(e,t,a,i,d){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for insert`);let p,w;i=null!=i&&"number"==typeof i?i:t.items.length,s(t)||u(t)?({shift:p,offset:w}=function(e,t,n){if(!c(t))throw new Error(`Incompatible child type "${t.type}"`);const o=null!=n?e.items[n-1]:$e(e.items),r=null==n||n===e.items.length;e.items.splice(n,0,t);const l=!!o,a=!r;l&&(o.comma=!0),a&&(t.comma=!0);const i=s(e)&&function(e){return!!e.items.length&&h(e.loc).lines>e.items.length}(e);return Ne(e,t,n,{useNewLine:i,hasCommaHandling:!0,isLastElement:r,hasSeparatingCommaBefore:l,hasSeparatingCommaAfter:a,hasTrailingComma:r&&!0===t.comma})}(t,a,i)):d&&n(t)?({shift:p,offset:w}=function(e,t,n){const o=Ne(e,t,n,{useNewLine:!1,hasCommaHandling:!1});return e.items.splice(n,0,t),o}(t,a,i)):({shift:p,offset:w}=function(e,t,a){if(!(l(i=t)||o(i)||r(i)||f(i)))throw new Error(`Incompatible child type "${t.type}"`);var i;const s=e.items[a-1],c=n(e)&&!e.items.length;e.items.splice(a,0,t);const u=s?{line:s.loc.end.line,column:f(s)?e.loc.start.column:s.loc.start.column}:y(e.loc.start),m=o(t)||r(t);let d=0;c||(d=m?2:1),u.line+=d;const p={lines:u.line-t.loc.start.line,columns:u.column-t.loc.start.column},w=h(t.loc);return{shift:p,offset:{lines:w.lines+(d-1),columns:w.columns}}}(t,a,i)),Ve(a,p);const g=t.items[i-1],v=g&&Ke(e).get(g);v&&(w.lines+=v.lines,w.columns+=v.columns,Ke(e).delete(g)),Ke(e).set(a,w),Oe.add(e)}function Ne(e,t,n,o={}){const{useNewLine:r=!1,skipCommaSpace:l=2,skipBracketSpace:a=1,hasCommaHandling:i=!1,isLastElement:s=!1,hasSeparatingCommaBefore:c=!1,hasSeparatingCommaAfter:u=!1,hasTrailingComma:m=!1}=o,d=n>0?e.items[n-1]:void 0,p=d?{line:d.loc.end.line,column:r?f(d)?e.loc.start.column:d.loc.start.column:d.loc.end.column}:y(e.loc.start);let w=0;if(r)w=1;else{const e=c||!i&&!!d;e&&i?p.column+=l:(e||i&&!d)&&(p.column+=a)}p.line+=w;const g={lines:p.line-t.loc.start.line,columns:p.column-t.loc.start.column},v=h(t.loc);if(!i)return{shift:g,offset:{lines:v.lines+(w-1),columns:v.columns}};let b=0;return c&&m&&!u&&s&&(b=-1),{shift:g,offset:{lines:v.lines+(w-1),columns:v.columns+(c||u?l:0)+(m?1+b:0)}}}function je(e,t,n){if(!m(t))throw new Error(`Unsupported parent type "${t.type}" for remove`);let l=t.items.indexOf(n);if(l<0){if(l=t.items.findIndex(e=>d(e)&&e.item===n),l<0)throw new Error("Node not found in parent for removal");n=t.items[l]}const a=t.items[l-1];let i=t.items[l+1];t.items.splice(l,1);let s=h(n.loc);i&&f(i)&&i.loc.start.line===n.loc.end.line&&(s=h({start:n.loc.start,end:i.loc.end}),i=t.items[l+1],t.items.splice(l,1));const u=a&&c(a)||i&&c(i),p=a&&a.loc.end.line===n.loc.start.line,w=i&&i.loc.start.line===n.loc.end.line,y=u&&(p||w),g={lines:-(s.lines-(y?1:0)),columns:y?-s.columns:0};if(void 0===a&&void 0===i&&(g.lines=0,g.columns=0),u&&p&&(g.columns-=2),u&&!a&&i&&(g.columns-=2),u&&a&&!i){const e=n.comma;a.comma=!!e}let v,b;a?(v=a,b=Ke(e)):(o(t)||r(t))&&"key"in t?(v=t.key,b=Ke(e)):(v=t,b=Fe(e));const $=Ke(e),T=b.get(v);T&&(g.lines+=T.lines,g.columns+=T.columns);const k=$.get(n);k&&(g.lines+=k.lines,g.columns+=k.columns),b.set(v,g),Oe.add(e)}function We(e,t,n=!0){if(!n)return;if(!t.items.length)return;qe({lines:0,columns:1},Fe(e),t);const o=$e(t.items);qe({lines:0,columns:1},Ke(e),o),Oe.add(e)}function Be(e,t,n=!1){if(!n)return;if(!t.items.length)return;const o=$e(t.items);o.comma=!0,qe({lines:0,columns:1},Ke(e),o),Oe.add(e)}function Ze(t){if(!Oe.has(t))return;const n=Fe(t),o=Ke(t);let r=0;const l={};function a(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 r=e.items[o].loc.end;(r.line>t||r.line===t&&r.column>n)&&(t=r.line,n=r.column)}e.loc.end={line:t,column:n}}function i(e){e.loc.start.line+=r;const t=l[e.loc.start.line]||0;e.loc.start.column+=t;const o=n.get(e);o&&(r+=o.lines,l[e.loc.start.line]=(l[e.loc.start.line]||0)+o.columns)}function s(e){e.loc.end.line+=r;const t=l[e.loc.end.line]||0;e.loc.end.column+=t;const n=o.get(e);n&&(r+=n.lines,l[e.loc.end.line]=(l[e.loc.end.line]||0)+n.columns)}!function t(n){switch(n.type){case e.Document:{const e=n;i(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);s(e),a(e);break}case e.Table:{const e=n;i(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);s(e),a(e);break}case e.TableArray:{const e=n;i(e),t(e.key);for(let n=0;n<e.items.length;n++)t(e.items[n]);s(e),a(e);break}case e.TableKey:{const e=n;i(e),t(e.item),s(e);break}case e.TableArrayKey:{const e=n;i(e),t(e.item),s(e);break}case e.KeyValue:{const e=n,a=e.loc.start.line+r,c=o.get(e.key);e.equals+=(l[a]||0)+(c?c.columns:0),i(e),t(e.key),t(e.value),s(e);break}case e.InlineArray:{const e=n;i(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);s(e);break}case e.InlineTable:{const e=n;i(e);for(let n=0;n<e.items.length;n++)t(e.items[n]);s(e);break}case e.InlineItem:{const e=n;i(e),t(e.item),s(e);break}case e.Key:case e.String:case e.Integer:case e.Float:case e.Boolean:case e.DateTime:case e.Comment:i(n),s(n);break;default:throw new Error(`Unrecognized node type "${n.type}"`)}}(t),Oe.delete(t),De.delete(t),Le.delete(t)}function Ve(t,n,o={}){const{lines:r,columns:l}=n;if(0===r&&0===l)return t;const{first_line_only:a=!1}=o,i=t.loc.start.line,s=t.type;if(s===e.Key||s===e.String||s===e.Integer||s===e.Float||s===e.Boolean||s===e.DateTime||s===e.Comment)return a&&t.loc.start.line!==i||(t.loc.start.column+=l,t.loc.end.column+=l),t.loc.start.line+=r,t.loc.end.line+=r,t;if(s===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){a&&n.loc.start.line!==i||(n.loc.start.column+=l,n.loc.end.column+=l),n.loc.start.line+=r,n.loc.end.line+=r,n.equals+=l;const e=n.key;a&&e.loc.start.line!==i||(e.loc.start.column+=l,e.loc.end.column+=l),e.loc.start.line+=r,e.loc.end.line+=r;const o=n.value;return a&&o.loc.start.line!==i||(o.loc.start.column+=l,o.loc.end.column+=l),o.loc.start.line+=r,o.loc.end.line+=r,t}}const c=e=>{a&&e.loc.start.line!==i||(e.loc.start.column+=l,e.loc.end.column+=l),e.loc.start.line+=r,e.loc.end.line+=r};return function(t,n){function o(e,t){for(const n of e)r(n,t)}function r(t,l){const a=n[t.type];switch(a&&"function"==typeof a&&a(t,l),a&&a.enter&&a.enter(t,l),t.type){case e.Document:o(t.items,t);break;case e.Table:r(t.key,t),o(t.items,t);break;case e.TableKey:r(t.item,t);break;case e.TableArray:r(t.key,t),o(t.items,t);break;case e.TableArrayKey:r(t.item,t);break;case e.KeyValue:r(t.key,t),r(t.value,t);break;case e.InlineArray:o(t.items,t);break;case e.InlineItem:r(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}"`)}a&&a.exit&&a.exit(t,l)}Ee(t)?o(t,null):r(t,null)}(t,{[e.Table]:c,[e.TableKey]:c,[e.TableArray]:c,[e.TableArrayKey]:c,[e.KeyValue](e){c(e),e.equals+=l},[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,t,n,o){const r=t.get(o||n);r&&(e.lines+=r.lines,e.columns+=r.columns),t.set(n,e)}function ze(){return{type:e.Document,loc:{start:{line:1,column:0},end:{line:1,column:0}},items:[]}}function Re(t){const n=function(t){const n=Je(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:g(n.loc),key:n,items:[]}}function Pe(t){const n=function(t){const n=Je(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:g(n.loc),key:n,items:[]}}function He(t,n){const o=function(t){const n=Je(t);return{type:e.Key,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t),{column:r}=o.loc.end,l=r+1;return Ve(n,{lines:0,columns:r+3-n.loc.start.column},{first_line_only:!0}),{type:e.KeyValue,loc:{start:y(o.loc.start),end:y(n.loc.end)},key:o,equals:l,value:n}}const Ye=/^[\w-]+$/;function Je(e){return e.map(e=>Ye.test(e)?e:JSON.stringify(e)).join(".")}function Ge(t,n){let o,r;if(n&&_e(n)){let e=n.startsWith("'''");e&&t.includes("'''")&&(e=!1);const r=e?"'''":'"""',l=n.includes("\r\n")?"\r\n":"\n",a=n.startsWith(`${r}${l}`)||(n.startsWith("'''\n")||n.startsWith("'''\r\n"))&&!e;let i;i=e?t:t.replace(/\\/g,"\\\\").replace(/\x08/g,"\\b").replace(/\f/g,"\\f").replace(/\t/g,"\\t").replace(/[\x00-\x07\x0B\x0E-\x1F\x7F]/g,e=>"\\u"+e.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()).replace(/"""/g,'""\\"'),o=a?`${r}${l}${i}${r}`:`${r}${i}${r}`}else o=JSON.stringify(t);if(o.includes("\r\n")||o.includes("\n")&&!o.includes("\r\n")){const e=o.includes("\r\n")?"\r\n":"\n",t=(o.match(new RegExp("\r\n"===e?"\\r\\n":"\\n","g"))||[]).length;r=t>0?{line:1+t,column:3}:{line:1,column:o.length}}else r={line:1,column:o.length};return{type:e.String,loc:{start:{line:1,column:0},end:r},raw:o,value:t}}function Qe(t){return{type:e.InlineItem,loc:g(t.loc),item:t,comma:!1}}const Xe=!1,et=!0,tt=!1,nt=!1;function ot(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/),r=e.start.line-1,l=e.end.line-1,a=e.start.column,i=e.end.column;let s="";if(r===l)s=(null===(n=o[r])||void 0===n?void 0:n.substring(a,i+1))||"";else{o[r]&&(s+=o[r].substring(a));for(let e=r+1;e<l;e++)s+="\n"+(o[e]||"");o[l]&&(s+="\n"+o[l].substring(0,i+1))}const c=s.match(/^\[(\s*)/),u=s.match(/^\{(\s*)/);return c?c[1].length>0:u?u[1].length>0:null}(e.loc,t);if(null!==n)return n}if(e.items&&Array.isArray(e.items))for(const n of e.items){const e=ot(n,t);if(null!==e)return e;if(n.item){const e=ot(n.item,t);if(null!==e)return e}}for(const n of["value","key","item"])if(e[n]){const o=ot(e[n],t);if(null!==o)return o}return null}function rt(e){if(!e||"object"!=typeof e)return null;if("InlineArray"===e.type&&e.items&&Array.isArray(e.items))return lt(e.items);if("InlineTable"===e.type&&e.items&&Array.isArray(e.items))return lt(e.items);if("KeyValue"===e.type&&e.value)return rt(e.value);if(e.items&&Array.isArray(e.items))for(const t of e.items){const e=rt(t);if(null!==e)return e}return null}function lt(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 at(e,t){var n,o,r,l,a,i;if(e){if(e instanceof it)return e;{const s=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},o={},r=[],l=[];for(const t in e){const a=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(a){const n=e[t],r=a(n);r?l.push(`${t} (${r})`):o[t]=n}else Object.prototype.hasOwnProperty.call(e,t)&&r.push(t)}if(r.length>0&&console.warn(`toml-patch: Ignoring unsupported format properties: ${r.join(", ")}. Supported properties are: ${Object.keys(n).join(", ")}`),l.length>0)throw new TypeError(`Invalid types for format properties: ${l.join(", ")}`);return o}(e);return new it(null!==(n=s.newLine)&&void 0!==n?n:t.newLine,null!==(o=s.trailingNewline)&&void 0!==o?o:t.trailingNewline,null!==(r=s.trailingComma)&&void 0!==r?r:t.trailingComma,null!==(l=s.bracketSpacing)&&void 0!==l?l:t.bracketSpacing,void 0!==s.inlineTableStart?s.inlineTableStart:t.inlineTableStart,null!==(a=s.truncateZeroTimeInDates)&&void 0!==a?a:t.truncateZeroTimeInDates,null!==(i=s.useTabsForIndentation)&&void 0!==i?i:t.useTabsForIndentation)}}return t}class it{constructor(e,t,n,o,r,l,a){this.newLine=null!=e?e:"\n",this.trailingNewline=null!=t?t:1,this.trailingComma=null!=n?n:Xe,this.bracketSpacing=null!=o?o:et,this.inlineTableStart=null!=r?r:1,this.truncateZeroTimeInDates=null!=l?l:tt,this.useTabsForIndentation=null!=a?a:nt}static default(){return new it("\n",1,Xe,et,1,tt,nt)}static autoDetectFormat(e){const t=it.default();t.newLine=function(e){const t=e.indexOf("\n");return t>0&&"\r"===e.substring(t-1,t)?"\r\n":"\n"}(e),t.trailingNewline=function(e,t){let n=0,o=e.length;for(;o>=t.length&&e.substring(o-t.length,o)===t;)n++,o-=t.length;return n}(e,t.newLine);try{const n=fe(e),o=Array.from(n);t.trailingComma=function(e){const t=Array.from(e);for(const e of t){const t=rt(e);if(null!==t)return t}return Xe}(o),t.bracketSpacing=function(e,t){const n=Array.from(t);for(const t of n){const n=ot(t,e);if(null!==n)return n}return et}(e,o)}catch(e){t.trailingComma=Xe,t.bracketSpacing=et}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=tt,t}}function st(e){return!!s(e)&&(0!==e.items.length&&!0===e.items[e.items.length-1].comma)}function ct(e){return!!u(e)&&(0!==e.items.length&&!0===e.items[e.items.length-1].comma)}function ut(e){const t=Re(e.key.value);for(const n of e.value.items)Me(t,t,n.item);return Ze(t),t}function ft(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 mt(e){return Math.max(0,e.length-1)}function dt(e,t,n){var o;for(let r=e.items.length-1;r>=0;r--){const a=e.items[r];if(l(a)&&u(a.value)){const r=[...e.key.item.value,...a.key.value];if(mt(r)<(null!==(o=n.inlineTableStart)&&void 0!==o?o:1)){const o=Re(r);for(const e of a.value.items)Me(o,o,e.item);je(e,e,a),ft(e),t.push(o),dt(o,t,n)}}}}function ht(e,t=it.default()){e=yt(e);const n=ze();for(const o of pt(e,t))Me(n,n,o);return Ze(n),function(e,t){0===t.inlineTableStart||(e.items.filter(e=>{if(!l(e))return!1;const n=u(e.value),o=s(e.value)&&e.value.items.length&&u(e.value.items[0].item);if(n||o){const n=mt(e.key.value);return void 0===t.inlineTableStart||n<t.inlineTableStart}return!1}).forEach(t=>{je(e,e,t),u(t.value)?Me(e,e,ut(t)):function(e){const t=ze();for(const n of e.value.items){const o=Pe(e.key.value);Me(t,t,o);for(const e of n.item.items)Me(t,o,e.item)}return Ze(t),t.items}(t).forEach(t=>{Me(e,e,t)})}),Ze(e))}(n,t),function(e,t){if(void 0===t.inlineTableStart||0===t.inlineTableStart)return e;const n=[];for(const o of e.items)if(l(o)&&u(o.value)){if(mt(o.key.value)<t.inlineTableStart){const r=ut(o);je(e,e,o),Me(e,e,r),dt(r,n,t)}}else"Table"===o.type&&dt(o,n,t);for(const t of n)Me(e,e,t);Ze(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)),Ve(o,{lines:t,columns:0}),n=o.loc.end.line;return e}(n)}function*pt(e,t){for(const n of Object.keys(e))yield He([n],wt(e[n],t))}function wt(t,n){if(null==t)throw new Error('"null" and "undefined" values are not supported');return function(e){return"string"==typeof e}(t)?Ge(t):ke(t)?function(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}}(t):function(e){return"number"==typeof e&&(!ke(e)||!isFinite(e)||Object.is(e,-0))}(t)?function(t){let n;return n=t===1/0?"inf":t===-1/0?"-inf":Number.isNaN(t)?"nan":Object.is(t,-0)?"-0.0":t.toString(),{type:e.Float,loc:{start:{line:1,column:0},end:{line:1,column:n.length}},raw:n,value:t}}(t):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):Se(t)?function(t,n=!1){n&&0===t.getUTCHours()&&0===t.getUTCMinutes()&&0===t.getUTCSeconds()&&0===t.getUTCMilliseconds()&&(t=new Z(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)Me(o,o,Qe(wt(e,n)));return We(o,o,n.bracketSpacing),Be(o,o,n.trailingComma),Ze(o),o}(t,n):function(t,n){if(!Ie(t=yt(t)))return wt(t,n);const o={type:e.InlineTable,loc:{start:{line:1,column:0},end:{line:1,column:2}},items:[]};for(const e of pt(t,n))Me(o,o,Qe(e));return We(o,o,n.bracketSpacing),Be(o,o,n.trailingComma),Ze(o),o}(t,n)}function yt(e){return e?Se(e)?e:"function"==typeof e.toJSON?e.toJSON():e:e}const gt=/(\r\n|\n)/g;function vt(t,n){const o=[];function r(t){switch(t.type){case e.Document:for(let e=0;e<t.items.length;e++)r(t.items[e]);break;case e.Table:{const e=t;r(e.key);for(let t=0;t<e.items.length;t++)r(e.items[t]);break}case e.TableKey:{const e=t,{start:n,end:l}=e.loc;$t(o,n.line,n.column,"["),$t(o,l.line,l.column-1,"]"),r(e.item);break}case e.TableArray:{const e=t;r(e.key);for(let t=0;t<e.items.length;t++)r(e.items[t]);break}case e.TableArrayKey:{const e=t,{start:n,end:l}=e.loc;Tt(o,n.line,n.column,n.column+2,"[["),Tt(o,l.line,l.column-2,l.column,"]]"),r(e.item);break}case e.KeyValue:{const e=t,n=e.loc.start.line;$t(o,n,e.equals,"="),r(e.key),r(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:l}=e.loc;$t(o,n.line,n.column,"["),$t(o,l.line,l.column-1,"]");for(let t=0;t<e.items.length;t++)r(e.items[t]);break}case e.InlineTable:{const e=t,{start:n,end:l}=e.loc;$t(o,n.line,n.column,"{"),$t(o,l.line,l.column-1,"}");for(let t=0;t<e.items.length;t++)r(e.items[t]);break}case e.InlineItem:{const e=t;if(r(e.item),e.comma){const t=e.loc.end;$t(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)r(e);else r(t);if(n.useTabsForIndentation)for(let e=0;e<o.length;e++){const t=o[e],n=t.match(/^( +)/);if(n){const r=n[1],l="\t".repeat(r.length);o[e]=l+t.substring(r.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),r=o.substring(0,t.start.column),l=r.length<t.start.column?r.padEnd(t.start.column,T):r,a=o.substring(t.end.column);return void(e[t.start.line-1]=l+n+a)}const o=n.split(gt).filter(e=>"\n"!==e&&"\r\n"!==e),r=t.end.line-t.start.line+1;if(o.length!==r)throw new Error(`Mismatch between location and raw string, expected ${r} lines for "${n}"`);for(let n=t.start.line;n<=t.end.line;n++){const r=kt(e,n),l=n===t.start.line,a=n===t.end.line;let i="";if(l){const e=r.substring(0,t.start.column);i=e.length<t.start.column?e.padEnd(t.start.column,T):e}const s=a?r.substring(t.end.column):"";e[n-1]=i+o[n-t.start.line]+s}}function $t(e,t,n,o){const r=kt(e,t),l=r.length<n?r.padEnd(n,T):r.substring(0,n),a=r.substring(n+1);e[t-1]=l+o+a}function Tt(e,t,n,o,r){const l=kt(e,t),a=l.length<n?l.padEnd(n,T):l.substring(0,n),i=l.substring(o);e[t-1]=a+r+i}function kt(e,t){if(!e[t-1])for(let n=0;n<t;n++)e[n]||(e[n]="");return e[t-1]}function St(t,n,o){for(const r of t.items){const t=r.item;if(t.value.type===e.InlineTable){const e=n.concat(t.key.value);o.add(Ot(e)),St(t.value,e,o)}}}function It(t,n=""){const o=Te(),r=new Set,l=new Set,a=new Set,i=new Set,s=new Set;let c=o,u=[];const f={tables:r,table_arrays:l,defined:a,implicit_tables:i,inline_tables:s};for(const n of t)switch(n.type){case e.Table:m(n);for(const t of n.items)t.type===e.KeyValue&&h(t);break;case e.TableArray:d(n);for(const t of n.items)t.type===e.KeyValue&&h(t);break;case e.KeyValue:h(n)}return o;function m(e){const t=e.key.item.value;try{At(o,[],t,e.type,f)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const l=Ot(t);r.add(l),a.add(l),c=Ct(o,t),u=t}function d(e){const t=e.key.item.value;try{At(o,[],t,e.type,f)}catch(t){const o=t;throw new v(n,e.key.loc.start,o.message)}const r=Ot(t);l.add(r),a.add(r),c=function(e,t){const n=xt(e,t.slice(0,-1)),o=$e(t);n[o]||(n[o]=[]);const r=Te();return n[$e(t)].push(r),r}(o,t),u=t}function h(t){const o=t.key.value;try{At(c,u,o,t.type,f)}catch(e){const o=e;throw new v(n,t.key.loc.start,o.message)}if(o.length>1)for(let e=1;e<o.length;e++){const t=Ot(u.concat(o.slice(0,e)));i.add(t),a.add(t)}let r;try{r=Et(t.value)}catch(e){const o=e;throw new v(n,t.value.loc.start,o.message)}if(t.value.type===e.InlineTable){const e=u.concat(o);s.add(Ot(e)),St(t.value,e,s)}(o.length>1?Ct(c,o.slice(0,-1)):c)[$e(o)]=r,a.add(Ot(u.concat(o)))}}function Et(t){switch(t.type){case e.InlineTable:const n=Te(),o=new Set,r=new Map;return t.items.forEach(({item:e})=>{const t=e.key.value,l=Et(e.value),a=Ot(t);if(o.has(a))throw new Error(`Duplicate key "${a}" in inline table`);for(let e=1;e<t.length;e++){const n=Ot(t.slice(0,e));if(o.has(n))throw new Error(`Key "${a}" conflicts with key: "${n}"`)}if(r.has(a)){const e=r.get(a);throw new Error(`Key "${a}" conflicts with key: "${e}"`)}o.add(a);for(let e=1;e<t.length;e++){const n=Ot(t.slice(0,e));r.has(n)||r.set(n,a)}(t.length>1?Ct(n,t.slice(0,-1)):n)[$e(t)]=l}),n;case e.InlineArray:return t.items.map(e=>Et(e.item));case e.DateTime:case e.String:case e.Integer:case e.Float:case e.Boolean:return t.value;default:throw new Error(`Unrecognized value type "${t.type}"`)}}function At(t,n,o,r,l){const a=n.length>0?Ot(n):"",i=new Array(o.length);let s=a;for(let e=0;e<o.length;e++)s=s?s+"."+o[e]:o[e],i[e]=s;const c=i[o.length-1];if(r===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=i[e-1];if(l.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if((r===e.Table||r===e.TableArray)&&l.inline_tables.has(c))throw new Error(`Cannot extend inline table at ${c}`);if(r===e.Table||r===e.TableArray)for(let e=1;e<o.length;e++){const t=i[e-1];if(l.inline_tables.has(t))throw new Error(`Cannot extend inline table at ${t}`)}if(r===e.KeyValue&&o.length>1)for(let e=1;e<o.length;e++){const t=i[e-1];if(l.table_arrays.has(t))throw new Error(`Cannot traverse Array of Tables at ${t}`)}if((r===e.Table||r===e.TableArray)&&l.implicit_tables.has(c))throw new Error(`Implicit table already defined: ${c}`);if(r===e.KeyValue&&l.implicit_tables.has(c))throw new Error(`Table already defined: ${c}`);if(r===e.KeyValue&&o.length>1)for(let e=1;e<=o.length;e++){const t=i[e-1];if(l.tables.has(t))throw new Error(`Cannot extend explicit table ${t} with dotted keys`)}let u=0;for(const e of o){if(!Ae(t,e))return;if(_t(t[e]))throw new Error(`Value already defined for ${i[u]}`);const n=i[u];if(Array.isArray(t[e])&&!l.table_arrays.has(n))throw new Error(`Cannot add to static array at ${n}`);const r=u++<o.length-1;t=Array.isArray(t[e])&&r?$e(t[e]):t[e]}const f=c;if(t&&r===e.Table&&l.defined.has(f))throw new Error(`Table already defined: ${f}`);if(t&&r===e.KeyValue&&1===o.length&&l.defined.has(f)&&!_t(t))throw new Error(`Table already defined: ${f}`);if(t&&r===e.TableArray&&!l.table_arrays.has(f))throw new Error(`Cannot add Array of Tables to table at ${f}`)}function Ct(e,t){const n=xt(e,t.slice(0,-1)),o=$e(t);return n[o]||(n[o]=Te()),n[o]}function xt(e,t){return t.reduce((e,t)=>(e[t]||(e[t]=Te()),Array.isArray(e[t])?$e(e[t]):e[t]),e)}function _t(e){return"object"!=typeof e&&!Se(e)}function Ot(e){return e.join(".")}var Dt;function Ft(e){return e.type===Dt.Remove}function Lt(e,t,n=[]){return e===t||(r=t,Se(o=e)&&Se(r)&&o.toISOString()===r.toISOString())?[]:Array.isArray(e)&&Array.isArray(t)?function(e,t,n=[]){let o=[];const r=e.map(Ce),l=t.map(Ce);l.forEach((a,i)=>{const s=i>=r.length;if(!s&&r[i]===a)return;const c=r.indexOf(a,i+1);if(!s&&c>-1){o.push({type:Dt.Move,path:n,from:c,to:i});const e=r.splice(c,1);return void r.splice(i,0,...e)}const u=!l.includes(r[i]);if(!s&&u)return xe(o,Lt(e[i],t[i],n.concat(i))),void(r[i]=a);o.push({type:Dt.Add,path:n.concat(i)}),r.splice(i,0,a)});for(let e=l.length;e<r.length;e++)o.push({type:Dt.Remove,path:n.concat(e)});return o}(e,t,n):Ie(e)&&Ie(t)?function(e,t,n=[]){let o=[];const r=Object.keys(e),l=r.map(t=>Ce(e[t])),a=Object.keys(t),i=a.map(e=>Ce(t[e])),s=(e,t)=>{if(t.indexOf(e)<0)return!1;const n=r[l.indexOf(e)];return!a.includes(n)};return r.forEach((r,c)=>{const u=n.concat(r);if(a.includes(r))xe(o,Lt(e[r],t[r],u));else if(s(l[c],i)){const e=a[i.indexOf(l[c])];o.push({type:Dt.Rename,path:n,from:r,to:e})}else o.push({type:Dt.Remove,path:u})}),a.forEach((e,t)=>{r.includes(e)||s(i[t],l)||o.push({type:Dt.Add,path:n.concat(e)})}),o}(e,t,n):[{type:Dt.Edit,path:n}];var o,r}function Kt(e,t){if(!t.length)return c(e)&&l(e.item)?e.item:e;if(l(e))return Kt(e.value,t);const n={};let a;if(m(e)&&e.items.some((e,i)=>{try{let s=[];if(l(e))s=e.key.value;else if(o(e))s=e.key.item.value;else if(r(e)){s=e.key.item.value;const t=Ce(s);n[t]||(n[t]=0);const o=n[t]++;s=s.concat(o)}else c(e)&&l(e.item)?s=e.item.key.value:c(e)&&(s=[i]);return!(!s.length||!function(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}(s,t.slice(0,s.length))||(a=c(e)&&l(e.item)?t.length===s.length?e:Kt(e.item.value,t.slice(s.length)):Kt(e,t.slice(s.length)),0))}catch(e){return!1}}),!a)throw new Error(`Node not found at ${t.join(".")}`);return a}function Ut(e,t){try{return Kt(e,t)}catch(e){}}function Mt(e,t){let n,o=t;for(;o.length&&!n;)o=o.slice(0,-1),n=Ut(e,o);if(!n)throw new Error(`Parent not found for ${t.join(".")}`);return n}function Nt(t,a,i){const f=[...t];let h=1,p=0;for(const e of f){const t=e.loc.end;(t.line>h||t.line===h&&t.column>p)&&(h=t.line,p=t.column)}const w=It(f),y={type:e.Document,loc:{start:{line:1,column:0},end:{line:h,column:p}},items:f},g=ht(a,at(Object.assign(Object.assign({},i),{inlineTableStart:void 0}),i)),v=function(e){for(let t=0;t<e.length;t++){const n=e[t];if(Ft(n)){let o=t+1;for(;o<e.length;){const r=e[o];if(Ft(r)&&r.path[0]===n.path[0]&&r.path[1]>n.path[1]){e.splice(o,1),e.splice(t,0,r),t=-1;break}o++}}}return e}(Lt(w,a));if(0===v.length)return{tomlString:vt(f,i),document:y};const b=function(e,t,a,i){return a.forEach(a=>{if(function(e){return e.type===Dt.Add}(a)){const f=Kt(t,a.path),m=a.path.slice(0,-1);let d,h=$e(a.path),p=r(f);if(ke(h)&&!m.some(ke)){const t=Ut(e,m.concat(0));t&&r(t)&&(p=!0)}if(o(f))d=e;else if(p){d=e;const t=e,n=Ut(t,m.concat(h-1)),o=Ut(t,m.concat(h));h=o?t.items.indexOf(o):n?t.items.indexOf(n)+1:t.items.length}else d=Mt(e,a.path),l(d)?d=d.value:c(d)&&l(d.item)&&(d=d.item.value);if(r(d)||s(d)||n(d)){if(s(d)){const e=st(d);c(f)&&(f.comma=e)}if(void 0!==i.inlineTableStart&&i.inlineTableStart>0&&n(d)&&o(f)){const t=Wt(f,e,i);Me(e,d,f,h);for(const n of t)Me(e,e,n,void 0)}else Me(e,d,f,h)}else if(u(d)){const t=ct(d);if(l(f)){const n=Qe(f);n.comma=t,Me(e,d,n)}else Me(e,d,f)}else if(void 0!==i.inlineTableStart&&i.inlineTableStart>0&&l(f)&&u(f.value)&&o(d))mt([...d.key.item.value,...f.key.value])<i.inlineTableStart?function(e,t,n,o){const r=Re([...t.key.item.value,...e.key.value]);if(u(e.value))for(const t of e.value.items)c(t)&&l(t.item)&&Me(n,r,t.item,void 0);Me(n,n,r,void 0),ft(t);const a=Wt(r,n,o);for(const e of a)Me(n,n,e,void 0)}(f,d,e,i):Me(e,d,f);else if(0===i.inlineTableStart&&l(f)&&u(f.value)&&n(d))Me(e,d,f,void 0,!0);else{let t=f;c(f)&&(o(d)||n(d))&&(t=f.item),Me(e,d,t)}}else if(function(e){return e.type===Dt.Edit}(a)){let n,o=Kt(e,a.path),r=Kt(t,a.path);if(l(o)&&l(r))jt(o.value,r.value),n=o,o=o.value,r=r.value;else if(l(o)&&c(r)&&l(r.item))n=o,o=o.value,r=r.item.value;else if(c(o)&&l(r))n=o,o=o.item;else if(c(o)&&c(r)&&l(o.item)&&l(r.item))jt(o.item.value,r.item.value),n=o.item,o=o.item.value,r=r.item.value;else if(n=Mt(e,a.path),l(n)){const t=a.path.slice(0,-1),o=Kt(e,t);l(o)&&s(o.value)&&(n=o.value)}Ue(e,n,o,r)}else if(Ft(a)){const t=Ut(e,a.path);if(t){let n=Mt(e,a.path);l(n)&&(n=n.value),m(n)&&!n.items.includes(t)&&(n=e),je(e,n,t)}else if(Ut(e,a.path.concat(0))){let t;for(;t=Ut(e,a.path.concat(0));)je(e,e,t)}else Kt(e,a.path)}else if(function(e){return e.type===Dt.Move}(a)){let t=Ut(e,a.path);if(t){d(t)&&(t=t.item),l(t)&&(t=t.value);const n=t.items[a.from];je(e,t,n),Me(e,t,n,a.to)}else{const t=Kt(e,a.path.concat(a.from));je(e,e,t);const n=Ut(e,a.path.concat(a.to)),o=n?e.items.indexOf(n):e.items.length;Me(e,e,t,o)}}else if(function(e){return e.type===Dt.Rename}(a)){let n=Kt(e,a.path.concat(a.from)),o=Kt(t,a.path.concat(a.to));d(n)&&(n=n.item),d(o)&&(o=o.item),Ue(e,n,n.key,o.key)}}),Ze(e),e}(y,g,v,i);return{tomlString:vt(b.items,i),document:b}}function jt(e,t){if(a(e)&&a(t)&&_e(e.raw)){const n=Ge(t.value,e.raw);t.raw=n.raw,t.loc=n.loc}if(i(e)&&i(t)){const n=e.raw,o=t.value,r=B.createDateWithOriginalFormat(o,n);t.value=r,t.raw=r.toISOString(),0!==t.raw.length-n.length&&(t.loc.end.column=t.loc.start.column+t.raw.length)}if(s(e)&&s(t)){const n=st(e);t.items.length>0&&(t.items[t.items.length-1].comma=n)}if(u(e)&&u(t)){const n=ct(e);t.items.length>0&&(t.items[t.items.length-1].comma=n)}}function Wt(e,t,n){const o=[],r=(e,o)=>{var a;for(let i=e.items.length-1;i>=0;i--){const s=e.items[i];if(l(s)&&u(s.value)){const u=[...e.key.item.value,...s.key.value];if(mt(u)<(null!==(a=n.inlineTableStart)&&void 0!==a?a:1)&&0!==n.inlineTableStart){const n=Re(u);for(const e of s.value.items)c(e)&&l(e.item)&&Me(t,n,e.item,void 0);e.items.splice(i,1),ft(e),o.push(n),r(n,o)}}}};return r(e,o),o}!function(e){e.Add="Add",e.Edit="Edit",e.Remove="Remove",e.Move="Move",e.Rename="Rename"}(Dt||(Dt={})),exports.TomlFormat=it,exports.parse=function(e){return It(fe(e),e)},exports.patch=function(e,t,n){return Nt(fe(e),t,at(n,it.autoDetectFormat(e))).tomlString},exports.stringify=function(e,t){const n=at(t,it.default());return vt(ht(e,n).items,n)};
@@ -0,0 +1 @@
1
+ "use strict";var t=require("./installer-DPj-zT7L.js"),e=require("path"),n=require("./_commonjsHelpers-Bjf42z7h.js"),r=require("fs"),i=require("node:fs"),s=require("node:path"),o=require("node:buffer");const a={excel:["xlsx","xlsm","xlam"]},c={excel:t.join(t.env.addins,"vbapm.xlam")},l={};for(const[t,e]of Object.entries(a))for(const n of e)l[n]=t;function h(e,n,r={}){const i=u(n.type);return{application:i,addin:c[i],file:t.join(r.staging?e.paths.staging:e.paths.build,n.filename)}}function u(e){e=e.replace(".","");const n=l[e];if(!n)throw new t.CliError(t.ErrorCode.AddinUnsupportedType,`The target type "${e} is not currently supported.`);return n}var p,f,g={},d={},m={};function b(){return f||(f=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.EXPANSION_MAX=void 0,t.expand=function(e,a={}){if(!e)return[];const{max:c=t.EXPANSION_MAX}=a;"{}"===e.slice(0,2)&&(e="\\{\\}"+e.slice(2));return M(function(t){return t.replace(f,n).replace(g,r).replace(d,i).replace(b,s).replace(y,o)}(e),c,!0).map(w)};const e=(p||(p=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.range=t.balanced=void 0,t.balanced=(n,r,i)=>{const s=n instanceof RegExp?e(n,i):n,o=r instanceof RegExp?e(r,i):r,a=null!==s&&null!=o&&(0,t.range)(s,o,i);return a&&{start:a[0],end:a[1],pre:i.slice(0,a[0]),body:i.slice(a[0]+s.length,a[1]),post:i.slice(a[1]+o.length)}};const e=(t,e)=>{const n=e.match(t);return n?n[0]:null};t.range=(t,e,n)=>{let r,i,s,o,a,c=n.indexOf(t),l=n.indexOf(e,c+1),h=c;if(c>=0&&l>0){if(t===e)return[c,l];for(r=[],s=n.length;h>=0&&!a;){if(h===c)r.push(h),c=n.indexOf(t,h+1);else if(1===r.length){const t=r.pop();void 0!==t&&(a=[t,l])}else i=r.pop(),void 0!==i&&i<s&&(s=i,o=l),l=n.indexOf(e,h+1);h=c<l&&c>=0?c:l}r.length&&void 0!==o&&(a=[s,o])}return a}}(m)),m),n="\0SLASH"+Math.random()+"\0",r="\0OPEN"+Math.random()+"\0",i="\0CLOSE"+Math.random()+"\0",s="\0COMMA"+Math.random()+"\0",o="\0PERIOD"+Math.random()+"\0",a=new RegExp(n,"g"),c=new RegExp(r,"g"),l=new RegExp(i,"g"),h=new RegExp(s,"g"),u=new RegExp(o,"g"),f=/\\\\/g,g=/\\{/g,d=/\\}/g,b=/\\,/g,y=/\\./g;function _(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function w(t){return t.replace(a,"\\").replace(c,"{").replace(l,"}").replace(h,",").replace(u,".")}function S(t){if(!t)return[""];const n=[],r=(0,e.balanced)("{","}",t);if(!r)return t.split(",");const{pre:i,body:s,post:o}=r,a=i.split(",");a[a.length-1]+="{"+s+"}";const c=S(o);return o.length&&(a[a.length-1]+=c.shift(),a.push.apply(a,c)),n.push.apply(n,a),n}function v(t){return"{"+t+"}"}function x(t){return/^-?0\d/.test(t)}function O(t,e){return t<=e}function E(t,e){return t>=e}function M(t,n,r){const s=[],o=(0,e.balanced)("{","}",t);if(!o)return[t];const a=o.pre,c=o.post.length?M(o.post,n,!1):[""];if(/\$$/.test(o.pre))for(let t=0;t<c.length&&t<n;t++){const e=a+"{"+o.body+"}"+c[t];s.push(e)}else{const e=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),h=e||l,u=o.body.indexOf(",")>=0;if(!h&&!u)return o.post.match(/,(?!,).*\}/)?M(t=o.pre+"{"+o.body+i+o.post,n,!0):[t];let p,f;if(h)p=o.body.split(/\.\./);else if(p=S(o.body),1===p.length&&void 0!==p[0]&&(p=M(p[0],n,!1).map(v),1===p.length))return c.map(t=>o.pre+p[0]+t);if(h&&void 0!==p[0]&&void 0!==p[1]){const t=_(p[0]),e=_(p[1]),n=Math.max(p[0].length,p[1].length);let r=3===p.length&&void 0!==p[2]?Math.abs(_(p[2])):1,i=O;e<t&&(r*=-1,i=E);const s=p.some(x);f=[];for(let o=t;i(o,e);o+=r){let t;if(l)t=String.fromCharCode(o),"\\"===t&&(t="");else if(t=String(o),s){const e=n-t.length;if(e>0){const n=new Array(e+1).join("0");t=o<0?"-"+n+t.slice(1):n+t}}f.push(t)}}else{f=[];for(let t=0;t<p.length;t++)f.push.apply(f,M(p[t],n,!1))}for(let t=0;t<f.length;t++)for(let e=0;e<c.length&&s.length<n;e++){const n=a+f[t]+c[e];(!r||h||n)&&s.push(n)}}return s}t.EXPANSION_MAX=1e5}(d)),d}var y,_={};var w,S={},v={};var x,O,E={};function M(){if(x)return E;x=1,Object.defineProperty(E,"__esModule",{value:!0}),E.unescape=void 0;return E.unescape=(t,{windowsPathsNoEscape:e=!1,magicalBraces:n=!0}={})=>n?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),E}function P(){if(O)return S;O=1,Object.defineProperty(S,"__esModule",{value:!0}),S.AST=void 0;const t=function(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.parseClass=void 0;const t={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},e=t=>t.replace(/[[\]\\-]/g,"\\$&"),n=t=>t.join("");return v.parseClass=(r,i)=>{const s=i;if("["!==r.charAt(s))throw new Error("not in a brace expression");const o=[],a=[];let c=s+1,l=!1,h=!1,u=!1,p=!1,f=s,g="";t:for(;c<r.length;){const n=r.charAt(c);if("!"!==n&&"^"!==n||c!==s+1){if("]"===n&&l&&!u){f=c+1;break}if(l=!0,"\\"!==n||u){if("["===n&&!u)for(const[e,[n,i,l]]of Object.entries(t))if(r.startsWith(e,c)){if(g)return["$.",!1,r.length-s,!0];c+=e.length,l?a.push(n):o.push(n),h=h||i;continue t}u=!1,g?(n>g?o.push(e(g)+"-"+e(n)):n===g&&o.push(e(n)),g="",c++):r.startsWith("-]",c+1)?(o.push(e(n+"-")),c+=2):r.startsWith("-",c+1)?(g=n,c+=2):(o.push(e(n)),c++)}else u=!0,c++}else p=!0,c++}if(f<c)return["",!1,0,!1];if(!o.length&&!a.length)return["$.",!1,r.length-s,!0];if(0===a.length&&1===o.length&&/^\\?.$/.test(o[0])&&!p){return[(d=2===o[0].length?o[0].slice(-1):o[0],d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),!1,f-s,!1]}var d;const m="["+(p?"^":"")+n(o)+"]",b="["+(p?"":"^")+n(a)+"]";return[o.length&&a.length?"("+m+"|"+b+")":o.length?m:b,h,f-s,!0]},v}(),e=M(),n=new Set(["!","?","+","*","@"]),r=t=>n.has(t),i="(?!\\.)",s=new Set(["[","."]),o=new Set(["..","."]),a=new Set("().*{}+?[]^$\\!"),c=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),l="[^/]",h=l+"*?",u=l+"+?";class p{type;#t;#e;#n=!1;#r=[];#i;#s;#o;#a=!1;#c;#l;#h=!1;constructor(t,e,n={}){this.type=t,t&&(this.#e=!0),this.#i=e,this.#t=this.#i?this.#i.#t:this,this.#c=this.#t===this?n:this.#t.#c,this.#o=this.#t===this?[]:this.#t.#o,"!"!==t||this.#t.#a||this.#o.push(this),this.#s=this.#i?this.#i.#r.length:0}get hasMagic(){if(void 0!==this.#e)return this.#e;for(const t of this.#r)if("string"!=typeof t&&(t.type||t.hasMagic))return this.#e=!0;return this.#e}toString(){return void 0!==this.#l?this.#l:this.type?this.#l=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#l=this.#r.map(t=>String(t)).join("")}#u(){if(this!==this.#t)throw new Error("should only call on root");if(this.#a)return this;let t;for(this.toString(),this.#a=!0;t=this.#o.pop();){if("!"!==t.type)continue;let e=t,n=e.#i;for(;n;){for(let r=e.#s+1;!n.type&&r<n.#r.length;r++)for(const e of t.#r){if("string"==typeof e)throw new Error("string part in extglob AST??");e.copyIn(n.#r[r])}e=n,n=e.#i}}return this}push(...t){for(const e of t)if(""!==e){if("string"!=typeof e&&!(e instanceof p&&e.#i===this))throw new Error("invalid part: "+e);this.#r.push(e)}}toJSON(){const t=null===this.type?this.#r.slice().map(t=>"string"==typeof t?t:t.toJSON()):[this.type,...this.#r.map(t=>t.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#a&&"!"===this.#i?.type)&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(0===this.#s)return!0;const t=this.#i;for(let e=0;e<this.#s;e++){const n=t.#r[e];if(!(n instanceof p&&"!"===n.type))return!1}return!0}isEnd(){if(this.#t===this)return!0;if("!"===this.#i?.type)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();const t=this.#i?this.#i.#r.length:0;return this.#s===t-1}copyIn(t){"string"==typeof t?this.push(t):this.push(t.clone(this))}clone(t){const e=new p(this.type,t);for(const t of this.#r)e.copyIn(t);return e}static#p(t,e,n,i){let s=!1,o=!1,a=-1,c=!1;if(null===e.type){let l=n,h="";for(;l<t.length;){const n=t.charAt(l++);if(s||"\\"===n)s=!s,h+=n;else if(o)l===a+1?"^"!==n&&"!"!==n||(c=!0):"]"!==n||l===a+2&&c||(o=!1),h+=n;else if("["!==n){if(!i.noext&&r(n)&&"("===t.charAt(l)){e.push(h),h="";const r=new p(n,e);l=p.#p(t,r,l,i),e.push(r);continue}h+=n}else o=!0,a=l,c=!1,h+=n}return e.push(h),l}let l=n+1,h=new p(null,e);const u=[];let f="";for(;l<t.length;){const n=t.charAt(l++);if(s||"\\"===n)s=!s,f+=n;else if(o)l===a+1?"^"!==n&&"!"!==n||(c=!0):"]"!==n||l===a+2&&c||(o=!1),f+=n;else if("["!==n){if(r(n)&&"("===t.charAt(l)){h.push(f),f="";const e=new p(n,h);h.push(e),l=p.#p(t,e,l,i);continue}if("|"!==n){if(")"===n)return""===f&&0===e.#r.length&&(e.#h=!0),h.push(f),f="",e.push(...u,h),l;f+=n}else h.push(f),f="",u.push(h),h=new p(null,e)}else o=!0,a=l,c=!1,f+=n}return e.type=null,e.#e=void 0,e.#r=[t.substring(n-1)],l}static fromGlob(t,e={}){const n=new p(null,void 0,e);return p.#p(t,n,0,e),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();const t=this.toString(),[e,n,r,i]=this.toRegExpSource();if(!(r||this.#e||this.#c.nocase&&!this.#c.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;const s=(this.#c.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${e}$`,s),{_src:e,_glob:t})}get options(){return this.#c}toRegExpSource(t){const n=t??!!this.#c.dot;if(this.#t===this&&this.#u(),!this.type){const r=this.isStart()&&this.isEnd()&&!this.#r.some(t=>"string"!=typeof t),a=this.#r.map(e=>{const[n,i,s,o]="string"==typeof e?p.#f(e,this.#e,r):e.toRegExpSource(t);return this.#e=this.#e||s,this.#n=this.#n||o,n}).join("");let c="";if(this.isStart()&&"string"==typeof this.#r[0]){if(!(1===this.#r.length&&o.has(this.#r[0]))){const e=s,r=n&&e.has(a.charAt(0))||a.startsWith("\\.")&&e.has(a.charAt(2))||a.startsWith("\\.\\.")&&e.has(a.charAt(4)),o=!n&&!t&&e.has(a.charAt(0));c=r?"(?!(?:^|/)\\.\\.?(?:$|/))":o?i:""}}let l="";this.isEnd()&&this.#t.#a&&"!"===this.#i?.type&&(l="(?:$|\\/)");return[c+a+l,(0,e.unescape)(a),this.#e=!!this.#e,this.#n]}const r="*"===this.type||"+"===this.type,a="!"===this.type?"(?:(?!(?:":"(?:";let c=this.#g(n);if(this.isStart()&&this.isEnd()&&!c&&"!"!==this.type){const t=this.toString();return this.#r=[t],this.type=null,this.#e=void 0,[t,(0,e.unescape)(this.toString()),!1,!1]}let l=!r||t||n?"":this.#g(!0);l===c&&(l=""),l&&(c=`(?:${c})(?:${l})*?`);let f="";if("!"===this.type&&this.#h)f=(this.isStart()&&!n?i:"")+u;else{f=a+c+("!"===this.type?"))"+(!this.isStart()||n||t?"":i)+h+")":"@"===this.type?")":"?"===this.type?")?":"+"===this.type&&l?")":"*"===this.type&&l?")?":`)${this.type}`)}return[f,(0,e.unescape)(c),this.#e=!!this.#e,this.#n]}#g(t){return this.#r.map(e=>{if("string"==typeof e)throw new Error("string type in extglob ast??");const[n,r,i,s]=e.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(t=>!(this.isStart()&&this.isEnd()&&!t)).join("|")}static#f(n,r,i=!1){let s=!1,o="",p=!1,f=!1;for(let e=0;e<n.length;e++){const g=n.charAt(e);if(s)s=!1,o+=(a.has(g)?"\\":"")+g;else if("*"!==g)if(f=!1,"\\"!==g){if("["===g){const[i,s,a,c]=(0,t.parseClass)(n,e);if(a){o+=i,p=p||s,e+=a-1,r=r||c;continue}}"?"!==g?o+=c(g):(o+=l,r=!0)}else e===n.length-1?o+="\\\\":s=!0;else{if(f)continue;f=!0,o+=i&&/^[*]+$/.test(n)?u:h,r=!0}}return[o,(0,e.unescape)(n),!!r,p]}}return S.AST=p,S}var j,A,T,$,N,R,L,C,B={};function k(){if(j)return B;j=1,Object.defineProperty(B,"__esModule",{value:!0}),B.escape=void 0;return B.escape=(t,{windowsPathsNoEscape:e=!1,magicalBraces:n=!1}={})=>n?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),B}function W(){return A||(A=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.unescape=t.escape=t.AST=t.Minimatch=t.match=t.makeRe=t.braceExpand=t.defaults=t.filter=t.GLOBSTAR=t.sep=t.minimatch=void 0;const e=b(),n=(y||(y=1,Object.defineProperty(_,"__esModule",{value:!0}),_.assertValidPattern=void 0,_.assertValidPattern=t=>{if("string"!=typeof t)throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")}),_),r=P(),i=k(),s=M();t.minimatch=(t,e,r={})=>((0,n.assertValidPattern)(e),!(!r.nocomment&&"#"===e.charAt(0))&&new B(e,r).match(t));const o=/^\*+([^+@!?\*\[\(]*)$/,a=t=>e=>!e.startsWith(".")&&e.endsWith(t),c=t=>e=>e.endsWith(t),l=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),h=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),u=/^\*+\.\*+$/,p=t=>!t.startsWith(".")&&t.includes("."),f=t=>"."!==t&&".."!==t&&t.includes("."),g=/^\.\*+$/,d=t=>"."!==t&&".."!==t&&t.startsWith("."),m=/^\*+$/,w=t=>0!==t.length&&!t.startsWith("."),S=t=>0!==t.length&&"."!==t&&".."!==t,v=/^\?+([^+@!?\*\[\(]*)?$/,x=([t,e=""])=>{const n=A([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n},O=([t,e=""])=>{const n=T([t]);return e?(e=e.toLowerCase(),t=>n(t)&&t.toLowerCase().endsWith(e)):n},E=([t,e=""])=>{const n=T([t]);return e?t=>n(t)&&t.endsWith(e):n},j=([t,e=""])=>{const n=A([t]);return e?t=>n(t)&&t.endsWith(e):n},A=([t])=>{const e=t.length;return t=>t.length===e&&!t.startsWith(".")},T=([t])=>{const e=t.length;return t=>t.length===e&&"."!==t&&".."!==t},$="object"==typeof process&&process?"object"==typeof process.env&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",N={sep:"\\"},R={sep:"/"};t.sep="win32"===$?N.sep:R.sep,t.minimatch.sep=t.sep,t.GLOBSTAR=Symbol("globstar **"),t.minimatch.GLOBSTAR=t.GLOBSTAR;t.filter=(e,n={})=>r=>(0,t.minimatch)(r,e,n),t.minimatch.filter=t.filter;const L=(t,e={})=>Object.assign({},t,e);t.defaults=e=>{if(!e||"object"!=typeof e||!Object.keys(e).length)return t.minimatch;const n=t.minimatch;return Object.assign((t,r,i={})=>n(t,r,L(e,i)),{Minimatch:class extends n.Minimatch{constructor(t,n={}){super(t,L(e,n))}static defaults(t){return n.defaults(L(e,t)).Minimatch}},AST:class extends n.AST{constructor(t,n,r={}){super(t,n,L(e,r))}static fromGlob(t,r={}){return n.AST.fromGlob(t,L(e,r))}},unescape:(t,r={})=>n.unescape(t,L(e,r)),escape:(t,r={})=>n.escape(t,L(e,r)),filter:(t,r={})=>n.filter(t,L(e,r)),defaults:t=>n.defaults(L(e,t)),makeRe:(t,r={})=>n.makeRe(t,L(e,r)),braceExpand:(t,r={})=>n.braceExpand(t,L(e,r)),match:(t,r,i={})=>n.match(t,r,L(e,i)),sep:n.sep,GLOBSTAR:t.GLOBSTAR})},t.minimatch.defaults=t.defaults;t.braceExpand=(t,r={})=>((0,n.assertValidPattern)(t),r.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,e.expand)(t,{max:r.braceExpandMax})),t.minimatch.braceExpand=t.braceExpand;t.makeRe=(t,e={})=>new B(t,e).makeRe(),t.minimatch.makeRe=t.makeRe;t.match=(t,e,n={})=>{const r=new B(e,n);return t=t.filter(t=>r.match(t)),r.options.nonull&&!t.length&&t.push(e),t},t.minimatch.match=t.match;const C=/[?*]|[+@!]\(.*?\)|\[|\]/;class B{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){(0,n.assertValidPattern)(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||$,this.isWindows="win32"===this.platform;this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||!1===e.allowWindowsEscape,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=void 0!==e.windowsNoMagicRoot?e.windowsNoMagicRoot:!(!this.isWindows||!this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const t of this.set)for(const e of t)if("string"!=typeof e)return!0;return!1}debug(...t){}make(){const t=this.pattern,e=this.options;if(!e.nocomment&&"#"===t.charAt(0))return void(this.comment=!0);if(!t)return void(this.empty=!0);this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...t)=>console.error(...t)),this.debug(this.pattern,this.globSet);const n=this.globSet.map(t=>this.slashSplit(t));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((t,e,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){const e=!(""!==t[0]||""!==t[1]||"?"!==t[2]&&C.test(t[2])||C.test(t[3])),n=/^[a-z]:/i.test(t[0]);if(e)return[...t.slice(0,4),...t.slice(4).map(t=>this.parse(t))];if(n)return[t[0],...t.slice(1).map(t=>this.parse(t))]}return t.map(t=>this.parse(t))});if(this.debug(this.pattern,r),this.set=r.filter(t=>-1===t.indexOf(!1)),this.isWindows)for(let t=0;t<this.set.length;t++){const e=this.set[t];""===e[0]&&""===e[1]&&"?"===this.globParts[t][2]&&"string"==typeof e[3]&&/^[a-z]:$/i.test(e[3])&&(e[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)"**"===t[e][n]&&(t[e][n]="*");const{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):t=e>=1?this.levelOneOptimize(t):this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(t=>{let e=-1;for(;-1!==(e=t.indexOf("**",e+1));){let n=e;for(;"**"===t[n+1];)n++;n!==e&&t.splice(e,n-e)}return t})}levelOneOptimize(t){return t.map(t=>0===(t=t.reduce((t,e)=>{const n=t[t.length-1];return"**"===e&&"**"===n?t:".."===e&&n&&".."!==n&&"."!==n&&"**"!==n?(t.pop(),t):(t.push(e),t)},[])).length?[""]:t)}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let n=1;n<t.length-1;n++){const r=t[n];1===n&&""===r&&""===t[0]||("."!==r&&""!==r||(e=!0,t.splice(n,1),n--))}"."!==t[0]||2!==t.length||"."!==t[1]&&""!==t[1]||(e=!0,t.pop())}let n=0;for(;-1!==(n=t.indexOf("..",n+1));){const r=t[n-1];r&&"."!==r&&".."!==r&&"**"!==r&&(e=!0,t.splice(n-1,2),n-=2)}}while(e);return 0===t.length?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let n of t){let r=-1;for(;-1!==(r=n.indexOf("**",r+1));){let i=r;for(;"**"===n[i+1];)i++;i>r&&n.splice(r+1,i-r);let s=n[r+1];const o=n[r+2],a=n[r+3];if(".."!==s)continue;if(!o||"."===o||".."===o||!a||"."===a||".."===a)continue;e=!0,n.splice(r,1);const c=n.slice(0);c[r]="**",t.push(c),r--}if(!this.preserveMultipleSlashes){for(let t=1;t<n.length-1;t++){const r=n[t];1===t&&""===r&&""===n[0]||("."!==r&&""!==r||(e=!0,n.splice(t,1),t--))}"."!==n[0]||2!==n.length||"."!==n[1]&&""!==n[1]||(e=!0,n.pop())}let i=0;for(;-1!==(i=n.indexOf("..",i+1));){const t=n[i-1];if(t&&"."!==t&&".."!==t&&"**"!==t){e=!0;const t=1===i&&"**"===n[i+1]?["."]:[];n.splice(i-1,2,...t),0===n.length&&n.push(""),i-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++){const r=this.partsMatch(t[e],t[n],!this.preserveMultipleSlashes);if(r){t[e]=[],t[n]=r;break}}return t.filter(t=>t.length)}partsMatch(t,e,n=!1){let r=0,i=0,s=[],o="";for(;r<t.length&&i<e.length;)if(t[r]===e[i])s.push("b"===o?e[i]:t[r]),r++,i++;else if(n&&"**"===t[r]&&e[i]===t[r+1])s.push(t[r]),r++;else if(n&&"**"===e[i]&&t[r]===e[i+1])s.push(e[i]),i++;else if("*"!==t[r]||!e[i]||!this.options.dot&&e[i].startsWith(".")||"**"===e[i]){if("*"!==e[i]||!t[r]||!this.options.dot&&t[r].startsWith(".")||"**"===t[r])return!1;if("a"===o)return!1;o="b",s.push(e[i]),r++,i++}else{if("b"===o)return!1;o="a",s.push(t[r]),r++,i++}return t.length===e.length&&s}parseNegate(){if(this.nonegate)return;const t=this.pattern;let e=!1,n=0;for(let r=0;r<t.length&&"!"===t.charAt(r);r++)e=!e,n++;n&&(this.pattern=t.slice(n)),this.negate=e}matchOne(e,n,r=!1){const i=this.options;if(this.isWindows){const t="string"==typeof e[0]&&/^[a-z]:$/i.test(e[0]),r=!t&&""===e[0]&&""===e[1]&&"?"===e[2]&&/^[a-z]:$/i.test(e[3]),i="string"==typeof n[0]&&/^[a-z]:$/i.test(n[0]),s=r?3:t?0:void 0,o=!i&&""===n[0]&&""===n[1]&&"?"===n[2]&&"string"==typeof n[3]&&/^[a-z]:$/i.test(n[3])?3:i?0:void 0;if("number"==typeof s&&"number"==typeof o){const[t,r]=[e[s],n[o]];t.toLowerCase()===r.toLowerCase()&&(n[o]=t,o>s?n=n.slice(o):s>o&&(e=e.slice(s)))}}const{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:n}),this.debug("matchOne",e.length,n.length);for(var o=0,a=0,c=e.length,l=n.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");var h=n[a],u=e[o];if(this.debug(n,h,u),!1===h)return!1;if(h===t.GLOBSTAR){this.debug("GLOBSTAR",[n,h,u]);var p=o,f=a+1;if(f===l){for(this.debug("** at the end");o<c;o++)if("."===e[o]||".."===e[o]||!i.dot&&"."===e[o].charAt(0))return!1;return!0}for(;p<c;){var g=e[p];if(this.debug("\nglobstar while",e,p,n,f,g),this.matchOne(e.slice(p),n.slice(f),r))return this.debug("globstar found match!",p,c,g),!0;if("."===g||".."===g||!i.dot&&"."===g.charAt(0)){this.debug("dot detected!",e,p,n,f);break}this.debug("globstar swallow a segment, and continue"),p++}return!(!r||(this.debug("\n>>> no match, partial?",e,p,n,f),p!==c))}let s;if("string"==typeof h?(s=u===h,this.debug("string match",h,u,s)):(s=h.test(u),this.debug("pattern match",h,u,s)),!s)return!1}if(o===c&&a===l)return!0;if(o===c)return r;if(a===l)return o===c-1&&""===e[o];throw new Error("wtf?")}braceExpand(){return(0,t.braceExpand)(this.pattern,this.options)}parse(e){(0,n.assertValidPattern)(e);const i=this.options;if("**"===e)return t.GLOBSTAR;if(""===e)return"";let s,b=null;(s=e.match(m))?b=i.dot?S:w:(s=e.match(o))?b=(i.nocase?i.dot?h:l:i.dot?c:a)(s[1]):(s=e.match(v))?b=(i.nocase?i.dot?O:x:i.dot?E:j)(s):(s=e.match(u))?b=i.dot?f:p:(s=e.match(g))&&(b=d);const y=r.AST.fromGlob(e,this.options).toMMPattern();return b&&"object"==typeof y&&Reflect.defineProperty(y,"test",{value:b}),y}makeRe(){if(this.regexp||!1===this.regexp)return this.regexp;const e=this.set;if(!e.length)return this.regexp=!1,this.regexp;const n=this.options,r=n.noglobstar?"[^/]*?":n.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",i=new Set(n.nocase?["i"]:[]);let s=e.map(e=>{const n=e.map(e=>{if(e instanceof RegExp)for(const t of e.flags.split(""))i.add(t);return"string"==typeof e?e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):e===t.GLOBSTAR?t.GLOBSTAR:e._src});n.forEach((e,i)=>{const s=n[i+1],o=n[i-1];e===t.GLOBSTAR&&o!==t.GLOBSTAR&&(void 0===o?void 0!==s&&s!==t.GLOBSTAR?n[i+1]="(?:\\/|"+r+"\\/)?"+s:n[i]=r:void 0===s?n[i-1]=o+"(?:\\/|\\/"+r+")?":s!==t.GLOBSTAR&&(n[i-1]=o+"(?:\\/|\\/"+r+"\\/)"+s,n[i+1]=t.GLOBSTAR))});const s=n.filter(e=>e!==t.GLOBSTAR);if(this.partial&&s.length>=1){const t=[];for(let e=1;e<=s.length;e++)t.push(s.slice(0,e).join("/"));return"(?:"+t.join("|")+")"}return s.join("/")}).join("|");const[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.partial&&(s="^(?:\\/|"+o+s.slice(1,-1)+a+")$"),this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch(t){this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return""===t;if("/"===t&&e)return!0;const n=this.options;this.isWindows&&(t=t.split("\\").join("/"));const r=this.slashSplit(t);this.debug(this.pattern,"split",r);const i=this.set;this.debug(this.pattern,"set",i);let s=r[r.length-1];if(!s)for(let t=r.length-2;!s&&t>=0;t--)s=r[t];for(let t=0;t<i.length;t++){const o=i[t];let a=r;n.matchBase&&1===o.length&&(a=[s]);if(this.matchOne(a,o,e))return!!n.flipNegate||!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return t.minimatch.defaults(e).Minimatch}}t.Minimatch=B;var W=P();Object.defineProperty(t,"AST",{enumerable:!0,get:function(){return W.AST}});var I=k();Object.defineProperty(t,"escape",{enumerable:!0,get:function(){return I.escape}});var z=M();Object.defineProperty(t,"unescape",{enumerable:!0,get:function(){return z.unescape}}),t.minimatch.AST=r.AST,t.minimatch.Minimatch=B,t.minimatch.escape=i.escape,t.minimatch.unescape=s.unescape}(g)),g}var I=function(){if(C)return L;C=1;const t=r,n=function(){if($)return T;$=1;var t=W();return T=function(){function e(e){this.matchers=e.map(function(e){return"string"==typeof e?new t.Minimatch(e):e})}return e.prototype.match=function(t){for(var e=0;e<this.matchers.length;e++)if(this.matchers[e].match(t))return!0;return!1},e.prototype.mayContain=function(t){for(var e=t.split(/\/|\\/g).filter(Boolean),n=0;n<this.matchers.length;n++)for(var r=this.matchers[n],i=0;i<r.set.length;i++)if(r.matchOne(e,r.set[i],!0))return!0;return!1},e}()}(),i=W(),s=function(){if(R)return N;R=1;var t=e;return N=function(e){return"/"!==t.sep?e.split(t.sep).join("/"):e}}(),o=e;function a(t,e){const n=l(e);let r;return r=n.includeBasePath?function(t){return t.basePath.split(o.sep).join("/").replace(/\/+$/,"")+"/"+t.relativePath}:function(t){return t.relativePath},p(t,n,null,[]).map(r)}function c(t){return void 0!==t}function l(t){let e={};return Array.isArray(t)?e.globs=t:t&&(e=t),e}function h(t,e){return null==t?void 0:t.map(t=>"string"==typeof t?new i.Minimatch(t,e):t)}function u(t,e){const n=t.relativePath,r=e.relativePath;return n===r?0:n<r?-1:1}function p(e,r,i,s){var o;const l=null!==(o=r.fs)&&void 0!==o?o:t,f=function(t){return null==t?"":"/"!==t.slice(-1)?t+"/":t}(i),g=l.realpathSync(e+"/"+f);if(s.indexOf(g)>=0)return[];s.push(g);try{const i=r.globOptions,o=c(i)?h(r.ignore,i):r.ignore,g=c(i)?h(r.globs,i):r.globs;let d,m,b=[];if(o&&(m=new n(o)),g&&(d=new n(g)),d&&!d.mayContain(f))return b;const y=l.readdirSync(e+"/"+f).map(n=>{let r=f+n;if(m&&m.match(r))return;let i=function(e,n=t){try{return n.statSync(e)}catch(t){if(null!==t&&"object"==typeof t&&["ENOENT","ENOTDIR","EPERM"].includes(t.code))return;throw t}}(e+"/"+r,l);return i&&i.isDirectory()?new a.Entry(r+"/",e,i.mode,i.size,i.mtime.getTime()):new a.Entry(r,e,i&&i.mode||0,i&&i.size||0,i&&i.mtime.getTime()||0)}).filter(c),_=y.sort(u);for(let t=0;t<_.length;++t){let n=_[t];n.isDirectory()?(!1===r.directories||d&&!d.match(n.relativePath)||b.push(n),b=b.concat(p(e,r,n.relativePath,s))):d&&!d.match(n.relativePath)||b.push(n)}return b}finally{s.pop()}}return function(e){e.entries=function(t,e){const n=l(e);return p(s(t),n,null,[])};e.Entry=class{constructor(t,e,n,r,i){this.relativePath=t,this.basePath=e,this.mode=n,this.size=r,this.mtime=i}get fullPath(){return`${this.basePath}/${this.relativePath}`}isDirectory(){return(this.mode&t.constants.S_IFMT)===t.constants.S_IFDIR}}}(a||(a={})),L=a}(),z=n.getDefaultExportFromCjs(I);function G(...t){return async e=>{let n=e;for(const e of t)n=await e(n);return n}}var D,F={},V={};function J(){if(D)return V;D=1;const t=Object.freeze({Key:0,0:"Key",Value:1,1:"Value",Section:2,2:"Section",CommentIndicator:3,3:"CommentIndicator",CommentValue:4,4:"CommentValue"});function e(t){const n=typeof t;if("number"==n||"boolean"==n||null==t)return`${t}`;if("string"==n)return`"${t}"`;if("symbol"==n){const e=t.description;return null==e?"Symbol":`Symbol(${e})`}if("function"==n){const e=t.name;return"string"==typeof e&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const n=t.length;let r="[";n>0&&(r+=e(t[0]));for(let i=1;i<n;i++)r+=", "+e(t[i]);return r+="]",r}const r=/\[object ([^\]]+)\]/.exec(toString.call(t));let i;if(!(r&&r.length>1))return toString.call(t);if(i=r[1],"Object"==i)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:i}V.TokenTypes=t,V.parse_to_json=function(t){const e=l(t,m.__wbindgen_malloc,m.__wbindgen_realloc),n=p;return m.parse_to_json(e,n)},V.parse_to_uint32array=function(t){const e=function(t,e){const n=e(1*t.length,1)>>>0;return c().set(t,n/1),p=t.length,n}(t,m.__wbindgen_malloc),n=p,r=m.parse_to_uint32array(e,n);if(r[3])throw function(t){const e=m.__wbindgen_externrefs.get(t);return m.__externref_table_dealloc(t),e}(r[2]);var i,s,a=(i=r[0],s=r[1],i>>>=0,(null!==o&&0!==o.byteLength||(o=new Uint32Array(m.memory.buffer)),o).subarray(i/4,i/4+s)).slice();return m.__wbindgen_free(r[0],4*r[1],4),a},V.version=function(){let t,e;try{const n=m.version();return t=n[0],e=n[1],s(n[0],n[1])}finally{m.__wbindgen_free(t,e,1)}};let n=null;function i(){return(null===n||!0===n.buffer.detached||void 0===n.buffer.detached&&n.buffer!==m.memory.buffer)&&(n=new DataView(m.memory.buffer)),n}function s(t,e){return function(t,e){return h.decode(c().subarray(t,t+e))}(t>>>=0,e)}let o=null;let a=null;function c(){return null!==a&&0!==a.byteLength||(a=new Uint8Array(m.memory.buffer)),a}function l(t,e,n){if(void 0===n){const n=u.encode(t),r=e(n.length,1)>>>0;return c().subarray(r,r+n.length).set(n),p=n.length,r}let r=t.length,i=e(r,1)>>>0;const s=c();let o=0;for(;o<r;o++){const e=t.charCodeAt(o);if(e>127)break;s[i+o]=e}if(o!==r){0!==o&&(t=t.slice(o)),i=n(i,r,r=o+3*t.length,1)>>>0;const e=c().subarray(i+o,i+r);o+=u.encodeInto(t,e).written,i=n(i,r,o,1)>>>0}return p=o,i}let h=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});h.decode();const u=new TextEncoder;"encodeInto"in u||(u.encodeInto=function(t,e){const n=u.encode(t);return e.set(n),{read:t.length,written:n.length}});let p=0;const f=`${__dirname}/one_ini_bg.wasm`,g=r.readFileSync(f),d=new WebAssembly.Module(g);let m=new WebAssembly.Instance(d,function(){const t={__proto__:null,__wbg_Error_ecbf49c1b9d07c30:function(t,e){return Error(s(t,e))},__wbg___wbindgen_debug_string_43c7ccb034739216:function(t,n){const r=l(e(n),m.__wbindgen_malloc,m.__wbindgen_realloc),s=p;i().setInt32(t+4,s,!0),i().setInt32(t+0,r,!0)},__wbg___wbindgen_throw_df03e93053e0f4bc:function(t,e){throw new Error(s(t,e))},__wbg_fromCodePoint_e00c387b1e85dfa6:function(){return function(t,e){try{return t.apply(this,e)}catch(t){const e=function(t){const e=m.__externref_table_alloc();return m.__wbindgen_externrefs.set(e,t),e}(t);m.__wbindgen_exn_store(e)}}(function(t){return String.fromCodePoint(t>>>0)},arguments)},__wbg_new_62f131e968c83d75:function(){return new Object},__wbg_new_66075f8c2ea6575e:function(){return new Array},__wbg_set_6be42768c690e380:function(t,e,n){t[e]=n},__wbg_set_7bf9e2df46e7632c:function(t,e,n){t[e>>>0]=n},__wbindgen_cast_0000000000000001:function(t,e){return s(t,e)},__wbindgen_init_externref_table:function(){const t=m.__wbindgen_externrefs,e=t.grow(4);t.set(0,void 0),t.set(e+0,void 0),t.set(e+1,null),t.set(e+2,!0),t.set(e+3,!1)}};return{__proto__:null,"./one_ini_bg.js":t}}()).exports;return m.__wbindgen_start(),V}var q,X={name:"editorconfig",version:"3.0.2",description:"EditorConfig File Locator and Interpreter for Node.js",keywords:["editorconfig","core"],main:"./lib/index.js",files:["lib/*","bin/*"],contributors:["Hong Xu (topbug.net)","Jed Mao (https://github.com/jedmao/)","Trey Hunner (http://treyhunner.com)","Joe Hildebrand (https://github.com/hildjj/)","SunsetTechuila (https://github.com/SunsetTechuila/)","Rex Lorenzo (https://github.com/rlorenzo/)"],directories:{bin:"./bin",lib:"./lib"},repository:{type:"git",url:"git://github.com/editorconfig/editorconfig-core-js.git"},bugs:"https://github.com/editorconfig/editorconfig-core-js/issues",author:"EditorConfig Team",license:"MIT",dependencies:{"@one-ini/wasm":"0.2.1",commander:"^14.0.3",minimatch:"~10.2.4",semver:"^7.7.4"},engines:{node:">=20"}};var H=function(){if(q)return F;q=1;var e,n=F&&F.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),r=F&&F.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=F&&F.__importStar||(e=function(t){return e=Object.getOwnPropertyNames||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[e.length]=n);return e},e(t)},function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var s=e(t),o=0;o<s.length;o++)"default"!==s[o]&&n(i,t,s[o]);return r(i,t),i}),c=F&&F.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(F,"__esModule",{value:!0}),F.parseBuffer=_,F.parseString=function(t){return _(g.Buffer.from(t))},F.unset=P,F.parseFromFilesSync=A,F.parseFromFiles=async function(t,e,n={}){return A(t,await e,n)},F.parse=async function(t,e={}){const[n,r]=M(t,e),i=w(n,r),s=await async function(t,e){const n=[];for(const r of t){const t=await O(r,e);if(!t.notfound&&(n.push(t),t.root))break}return n}(i,r);return j(n,s,r)},F.parseSync=function(t,e={}){const[n,r]=M(t,e),i=function(t,e){const n=[];for(const r of t){const t=E(r,e);if(!t.notfound&&(n.push(t),t.root))break}return n}(w(n,r),r);return j(n,i,r)},F.matcher=function(t,...e){const[n,r]=M("",t),i=e.map((t,e)=>x(h.join(r.root,`buffer-${e}`),t,r));return t=>j(h.resolve(t),i,r)};const l=a(i),h=a(s),u=a(t.requireSemver()),p=W(),f=J(),g=o,d=c(X),m=new RegExp(h.sep.replace(/\\/g,"\\\\"),"g"),b={matchBase:!0,dot:!0},y=new Set(["charset","end_of_line","indent_size","indent_style","insert_final_newline","trim_trailing_whitespace"]);function _(t){const e=(0,f.parse_to_uint32array)(t);let n={};const r=[[null,n]];let i=null;for(let s=0;s<e.length;s+=3)switch(e[s]){case f.TokenTypes.Section:n={},r.push([t.toString("utf8",e[s+1],e[s+2]),n]);break;case f.TokenTypes.Key:i=t.toString("utf8",e[s+1],e[s+2]);break;case f.TokenTypes.Value:n[i]=t.toString("utf8",e[s+1],e[s+2])}return r}function w(t,e){const n=[];do{t=h.dirname(t),n.push(h.join(t,e.config))}while(t!==e.root);return n}function S(t,e){switch(e.indexOf("/")){case-1:e=`**/${e}`;break;case 0:e=e.substring(1)}return e=(e=e.replace(/\\\\/g,"\\\\\\\\")).replace(/\*\*/g,"{*,**/**/**}"),new p.Minimatch(`${t}/${e}`,b)}function v(t){const e={};for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const r=t[n],i=n.toLowerCase();let s=r;y.has(i)&&(s=String(r).toLowerCase());try{s=JSON.parse(String(r))}catch(t){}null==s&&(s=String(r)),e[i]=s}return e}function x(t,e,n){let r;if(e){let n=h.dirname(t);"/"!==h.sep&&(n=n.replace(m,"/")),n=(0,p.escape)(n,{windowsPathsNoEscape:!0}),n=n.replace(/^#/,"[#]");const i=_(e).map(([t,e])=>[t,v(e),t?S(n,t):null]);r={root:Boolean(i[0][1].root),name:t,config:i}}else r={root:!1,notfound:!0,name:t,config:[[null,{},null]]};return n.cache&&n.cache.set(t,r),r}async function O(t,e){if(e.cache){const n=e.cache.get(t);if(n)return n}const n=await new Promise(e=>{l.readFile(t,(t,n)=>{e(n)})});return x(t,n,e)}function E(t,e){if(e.cache){const n=e.cache.get(t);if(n)return n}let n;try{n=l.readFileSync(t)}catch(t){}return x(t,n,e)}function M(t,e={}){const n=h.resolve(t);return[n,{config:e.config||".editorconfig",version:e.version||d.default.version,root:h.resolve(e.root||h.parse(n).root),files:e.files,cache:e.cache,unset:e.unset}]}function P(t){const e=Object.keys(t);for(const n of e)"unset"===t[n]&&delete t[n]}function j(t,e,n){const r=e.reverse().reduce((e,r)=>{for(const[i,s,o]of r.config)(null==o?void 0:o.match(t))&&(Object.assign(e,s),n.files&&n.files.push({fileName:r.name,glob:i}));return e},{});return n.unset&&P(r),function(t,e){return"indent_style"in t&&"tab"===t.indent_style&&!("indent_size"in t)&&u.gte(e,"0.10.0")&&(t.indent_size="tab"),"indent_size"in t&&!("tab_width"in t)&&"tab"!==t.indent_size&&(t.tab_width=t.indent_size),"indent_size"in t&&"tab_width"in t&&"tab"===t.indent_size&&(t.indent_size=t.tab_width),t}(r,n.version)}function A(t,e,n={}){const[r,i]=M(t,n),s=[];for(const t of e){let e;if(n.cache&&(e=n.cache.get(t.name))||(e=x(t.name,t.contents,i)),e.notfound||s.push(e),e.root)break}return j(r,s,i)}return F}();const Z=t.env.debug("vbapm:editor-config"),U=new Map;async function K(n){const{end_of_line:r,trim_trailing_whitespace:i,insert_final_newline:s}=await async function(t){const n=e.extname(t.filename);if(U.has(n))return U.get(n);const r=await H.parse(t.filename);return U.set(n,r),Z(`Formatting ${n} with`,r),r}(n),o="lf"===r?"\n":"\r\n",a=n.code.split(t.BY_LINE).map(i?Y:Q).join(o);return n.code=s?function(t){"\n"!==t[t.length-1]&&(t+="\n");return t}(a):a,n}function Y(t){return t.trimEnd()}function Q(t){return t}var tt=Object.freeze({__proto__:null,toCompiled:async function(t){return t},toSrc:async function(e){const{name:n,references:r,fromDependencies:i}=e;return{name:n,components:await t.parallel(e.components,K),references:r,fromDependencies:i}}});const et=[tt];G(...et.map(t=>t.toCompiled).filter(Boolean));const nt=G(...et.map(t=>t.toSrc).filter(Boolean));exports.addins=c,exports.createDocument=async function(n,r,i={}){const{application:s,addin:o,file:a}=h(n,r,i),c=!t.env.isWindows&&!i.staging;let l=c?t.join(n.paths.staging,r.filename):a;return await t.mkdirsExports.ensureDir(e.dirname(l)),await t.run(s,i.addin||o,"Build.CreateDocument",[JSON.stringify({path:l})]),c&&(await t.mkdirsExports.ensureDir(e.dirname(a)),await t.copyExports.copy(l,a)),a},exports.exportTo=async function(n,r,i,s={}){let{application:o,addin:a,file:c}=h(n,r);if(!t.env.isWindows){const n=t.join(i,"staged",r.filename);await t.pathExistsExports.pathExists(n)||(await t.mkdirsExports.ensureDir(e.dirname(n)),await t.copyExports.copy(c,n)),c=n}await t.run(o,s.addin||a,"Build.ExportTo",[JSON.stringify({file:c,staging:i})])},exports.extensionToApplication=u,exports.importGraph=async function(e,n,r,i,s={}){const{application:o,addin:a}=h(e,n),{name:c,components:l,references:u}=r;await t.run(o,s.addin||a,"Build.ImportGraph",[JSON.stringify({file:i,name:c,src:l,references:u})],{keepOpen:s.open})},exports.requireCommonjs=W,exports.toSrc=nt,exports.walk=z;
@@ -0,0 +1,2 @@
1
+ "use strict";var t=require("string_decoder"),e=require("./installer-DPj-zT7L.js");var n,r,a,i,s,o,c,u,l,f,m,p,E,g,d,T={};function y(){return n||(n=1,function(e){e.parser=function(t,e){return new a(t,e)},e.SAXParser=a,e.SAXStream=s,e.createStream=function(t,e){return new s(t,e)},e.MAX_BUFFER_LENGTH=65536;var n,r=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function a(t,n){if(!(this instanceof a))return new a(t,n);var i=this;!function(t){for(var e=0,n=r.length;e<n;e++)t[r[e]]=""}(i),i.q=i.c="",i.bufferCheckPosition=e.MAX_BUFFER_LENGTH,i.opt=n||{},i.opt.lowercase=i.opt.lowercase||i.opt.lowercasetags,i.looseCase=i.opt.lowercase?"toLowerCase":"toUpperCase",i.tags=[],i.closed=i.closedRoot=i.sawRoot=!1,i.tag=i.error=null,i.strict=!!t,i.noscript=!(!t&&!i.opt.noscript),i.state=F.BEGIN,i.strictEntities=i.opt.strictEntities,i.ENTITIES=i.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),i.attribList=[],i.opt.xmlns&&(i.ns=Object.create(f)),i.trackPosition=!1!==i.opt.position,i.trackPosition&&(i.position=i.line=i.column=0),I(i,"onready")}e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(t){function e(){}return e.prototype=t,new e}),Object.keys||(Object.keys=function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e}),a.prototype={end:function(){w(this)},write:function(t){var n=this;if(this.error)throw this.error;if(n.closed)return v(n,"Cannot write after close. Assign an onready handler.");if(null===t)return w(n);"object"==typeof t&&(t=t.toString());for(var a=0,i="";i=M(t,a++),n.c=i,i;)switch(n.trackPosition&&(n.position++,"\n"===i?(n.line++,n.column=0):n.column++),n.state){case F.BEGIN:if(n.state=F.BEGIN_WHITESPACE,"\ufeff"===i)continue;k(n,i);continue;case F.BEGIN_WHITESPACE:k(n,i);continue;case F.TEXT:if(n.sawRoot&&!n.closedRoot){for(var s=a-1;i&&"<"!==i&&"&"!==i;)(i=M(t,a++))&&n.trackPosition&&(n.position++,"\n"===i?(n.line++,n.column=0):n.column++);n.textNode+=t.substring(s,a-1)}"<"!==i||n.sawRoot&&n.closedRoot&&!n.strict?(d(i)||n.sawRoot&&!n.closedRoot||K(n,"Text data outside of root node."),"&"===i?n.state=F.TEXT_ENTITY:n.textNode+=i):(n.state=F.OPEN_WAKA,n.startTagPosition=n.position);continue;case F.SCRIPT:"<"===i?n.state=F.SCRIPT_ENDING:n.script+=i;continue;case F.SCRIPT_ENDING:"/"===i?n.state=F.CLOSE_TAG:(n.script+="<"+i,n.state=F.SCRIPT);continue;case F.OPEN_WAKA:if("!"===i)n.state=F.SGML_DECL,n.sgmlDecl="";else if(d(i));else if(h(m,i))n.state=F.OPEN_TAG,n.tagName=i;else if("/"===i)n.state=F.CLOSE_TAG,n.tagName="";else if("?"===i)n.state=F.PROC_INST,n.procInstName=n.procInstBody="";else{if(K(n,"Unencoded <"),n.startTagPosition+1<n.position){var u=n.position-n.startTagPosition;i=new Array(u).join(" ")+i}n.textNode+="<"+i,n.state=F.TEXT}continue;case F.SGML_DECL:(n.sgmlDecl+i).toUpperCase()===o?(D(n,"onopencdata"),n.state=F.CDATA,n.sgmlDecl="",n.cdata=""):n.sgmlDecl+i==="--"?(n.state=F.COMMENT,n.comment="",n.sgmlDecl=""):(n.sgmlDecl+i).toUpperCase()===c?(n.state=F.DOCTYPE,(n.doctype||n.sawRoot)&&K(n,"Inappropriately located doctype declaration"),n.doctype="",n.sgmlDecl=""):">"===i?(D(n,"onsgmldeclaration",n.sgmlDecl),n.sgmlDecl="",n.state=F.TEXT):T(i)?(n.state=F.SGML_DECL_QUOTED,n.sgmlDecl+=i):n.sgmlDecl+=i;continue;case F.SGML_DECL_QUOTED:i===n.q&&(n.state=F.SGML_DECL,n.q=""),n.sgmlDecl+=i;continue;case F.DOCTYPE:">"===i?(n.state=F.TEXT,D(n,"ondoctype",n.doctype),n.doctype=!0):(n.doctype+=i,"["===i?n.state=F.DOCTYPE_DTD:T(i)&&(n.state=F.DOCTYPE_QUOTED,n.q=i));continue;case F.DOCTYPE_QUOTED:n.doctype+=i,i===n.q&&(n.q="",n.state=F.DOCTYPE);continue;case F.DOCTYPE_DTD:n.doctype+=i,"]"===i?n.state=F.DOCTYPE:T(i)&&(n.state=F.DOCTYPE_DTD_QUOTED,n.q=i);continue;case F.DOCTYPE_DTD_QUOTED:n.doctype+=i,i===n.q&&(n.state=F.DOCTYPE_DTD,n.q="");continue;case F.COMMENT:"-"===i?n.state=F.COMMENT_ENDING:n.comment+=i;continue;case F.COMMENT_ENDING:"-"===i?(n.state=F.COMMENT_ENDED,n.comment=O(n.opt,n.comment),n.comment&&D(n,"oncomment",n.comment),n.comment=""):(n.comment+="-"+i,n.state=F.COMMENT);continue;case F.COMMENT_ENDED:">"!==i?(K(n,"Malformed comment"),n.comment+="--"+i,n.state=F.COMMENT):n.state=F.TEXT;continue;case F.CDATA:"]"===i?n.state=F.CDATA_ENDING:n.cdata+=i;continue;case F.CDATA_ENDING:"]"===i?n.state=F.CDATA_ENDING_2:(n.cdata+="]"+i,n.state=F.CDATA);continue;case F.CDATA_ENDING_2:">"===i?(n.cdata&&D(n,"oncdata",n.cdata),D(n,"onclosecdata"),n.cdata="",n.state=F.TEXT):"]"===i?n.cdata+="]":(n.cdata+="]]"+i,n.state=F.CDATA);continue;case F.PROC_INST:"?"===i?n.state=F.PROC_INST_ENDING:d(i)?n.state=F.PROC_INST_BODY:n.procInstName+=i;continue;case F.PROC_INST_BODY:if(!n.procInstBody&&d(i))continue;"?"===i?n.state=F.PROC_INST_ENDING:n.procInstBody+=i;continue;case F.PROC_INST_ENDING:">"===i?(D(n,"onprocessinginstruction",{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody="",n.state=F.TEXT):(n.procInstBody+="?"+i,n.state=F.PROC_INST_BODY);continue;case F.OPEN_TAG:h(p,i)?n.tagName+=i:(S(n),">"===i?L(n):"/"===i?n.state=F.OPEN_TAG_SLASH:(d(i)||K(n,"Invalid character in tag name"),n.state=F.ATTRIB));continue;case F.OPEN_TAG_SLASH:">"===i?(L(n,!0),R(n)):(K(n,"Forward-slash in opening tag not followed by >"),n.state=F.ATTRIB);continue;case F.ATTRIB:if(d(i))continue;">"===i?L(n):"/"===i?n.state=F.OPEN_TAG_SLASH:h(m,i)?(n.attribName=i,n.attribValue="",n.state=F.ATTRIB_NAME):K(n,"Invalid attribute name");continue;case F.ATTRIB_NAME:"="===i?n.state=F.ATTRIB_VALUE:">"===i?(K(n,"Attribute without value"),n.attribValue=n.attribName,P(n),L(n)):d(i)?n.state=F.ATTRIB_NAME_SAW_WHITE:h(p,i)?n.attribName+=i:K(n,"Invalid attribute name");continue;case F.ATTRIB_NAME_SAW_WHITE:if("="===i)n.state=F.ATTRIB_VALUE;else{if(d(i))continue;K(n,"Attribute without value"),n.tag.attributes[n.attribName]="",n.attribValue="",D(n,"onattribute",{name:n.attribName,value:""}),n.attribName="",">"===i?L(n):h(m,i)?(n.attribName=i,n.state=F.ATTRIB_NAME):(K(n,"Invalid attribute name"),n.state=F.ATTRIB)}continue;case F.ATTRIB_VALUE:if(d(i))continue;T(i)?(n.q=i,n.state=F.ATTRIB_VALUE_QUOTED):(K(n,"Unquoted attribute value"),n.state=F.ATTRIB_VALUE_UNQUOTED,n.attribValue=i);continue;case F.ATTRIB_VALUE_QUOTED:if(i!==n.q){"&"===i?n.state=F.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=i;continue}P(n),n.q="",n.state=F.ATTRIB_VALUE_CLOSED;continue;case F.ATTRIB_VALUE_CLOSED:d(i)?n.state=F.ATTRIB:">"===i?L(n):"/"===i?n.state=F.OPEN_TAG_SLASH:h(m,i)?(K(n,"No whitespace between attributes"),n.attribName=i,n.attribValue="",n.state=F.ATTRIB_NAME):K(n,"Invalid attribute name");continue;case F.ATTRIB_VALUE_UNQUOTED:if(!y(i)){"&"===i?n.state=F.ATTRIB_VALUE_ENTITY_U:n.attribValue+=i;continue}P(n),">"===i?L(n):n.state=F.ATTRIB;continue;case F.CLOSE_TAG:if(n.tagName)">"===i?R(n):h(p,i)?n.tagName+=i:n.script?(n.script+="</"+n.tagName,n.tagName="",n.state=F.SCRIPT):(d(i)||K(n,"Invalid tagname in closing tag"),n.state=F.CLOSE_TAG_SAW_WHITE);else{if(d(i))continue;b(m,i)?n.script?(n.script+="</"+i,n.state=F.SCRIPT):K(n,"Invalid tagname in closing tag."):n.tagName=i}continue;case F.CLOSE_TAG_SAW_WHITE:if(d(i))continue;">"===i?R(n):K(n,"Invalid characters in closing tag");continue;case F.TEXT_ENTITY:case F.ATTRIB_VALUE_ENTITY_Q:case F.ATTRIB_VALUE_ENTITY_U:var l,f;switch(n.state){case F.TEXT_ENTITY:l=F.TEXT,f="textNode";break;case F.ATTRIB_VALUE_ENTITY_Q:l=F.ATTRIB_VALUE_QUOTED,f="attribValue";break;case F.ATTRIB_VALUE_ENTITY_U:l=F.ATTRIB_VALUE_UNQUOTED,f="attribValue"}";"===i?(n[f]+=U(n),n.entity="",n.state=l):h(n.entity.length?g:E,i)?n.entity+=i:(K(n,"Invalid character in entity name"),n[f]+="&"+n.entity+i,n.entity="",n.state=l);continue;default:throw new Error(n,"Unknown state: "+n.state)}return n.position>=n.bufferCheckPosition&&function(t){for(var n=Math.max(e.MAX_BUFFER_LENGTH,10),a=0,i=0,s=r.length;i<s;i++){var o=t[r[i]].length;if(o>n)switch(r[i]){case"textNode":C(t);break;case"cdata":D(t,"oncdata",t.cdata),t.cdata="";break;case"script":D(t,"onscript",t.script),t.script="";break;default:v(t,"Max buffer length exceeded: "+r[i])}a=Math.max(a,o)}var c=e.MAX_BUFFER_LENGTH-a;t.bufferCheckPosition=c+t.position}(n),n}
2
+ /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var t;C(t=this),""!==t.cdata&&(D(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(D(t,"onscript",t.script),t.script="")}};try{n=require("stream").Stream}catch(t){n=function(){}}var i=e.EVENTS.filter(function(t){return"error"!==t&&"end"!==t});function s(t,e){if(!(this instanceof s))return new s(t,e);n.apply(this),this._parser=new a(t,e),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(t){r.emit("error",t),r._parser.error=null},this._decoder=null,i.forEach(function(t){Object.defineProperty(r,"on"+t,{get:function(){return r._parser["on"+t]},set:function(e){if(!e)return r.removeAllListeners(t),r._parser["on"+t]=e,e;r.on(t,e)},enumerable:!0,configurable:!1})})}s.prototype=Object.create(n.prototype,{constructor:{value:s}}),s.prototype.write=function(e){if("function"==typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(e)){if(!this._decoder){var n=t.StringDecoder;this._decoder=new n("utf8")}e=this._decoder.write(e)}return this._parser.write(e.toString()),this.emit("data",e),!0},s.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},s.prototype.on=function(t,e){var r=this;return r._parser["on"+t]||-1===i.indexOf(t)||(r._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),r.emit.apply(r,e)}),n.prototype.on.call(r,t,e)};var o="[CDATA[",c="DOCTYPE",u="http://www.w3.org/XML/1998/namespace",l="http://www.w3.org/2000/xmlns/",f={xml:u,xmlns:l},m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,E=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,g=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function d(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function T(t){return'"'===t||"'"===t}function y(t){return">"===t||d(t)}function h(t,e){return t.test(e)}function b(t,e){return!h(t,e)}var N,A,x,F=0;for(var _ in e.STATE={BEGIN:F++,BEGIN_WHITESPACE:F++,TEXT:F++,TEXT_ENTITY:F++,OPEN_WAKA:F++,SGML_DECL:F++,SGML_DECL_QUOTED:F++,DOCTYPE:F++,DOCTYPE_QUOTED:F++,DOCTYPE_DTD:F++,DOCTYPE_DTD_QUOTED:F++,COMMENT_STARTING:F++,COMMENT:F++,COMMENT_ENDING:F++,COMMENT_ENDED:F++,CDATA:F++,CDATA_ENDING:F++,CDATA_ENDING_2:F++,PROC_INST:F++,PROC_INST_BODY:F++,PROC_INST_ENDING:F++,OPEN_TAG:F++,OPEN_TAG_SLASH:F++,ATTRIB:F++,ATTRIB_NAME:F++,ATTRIB_NAME_SAW_WHITE:F++,ATTRIB_VALUE:F++,ATTRIB_VALUE_QUOTED:F++,ATTRIB_VALUE_CLOSED:F++,ATTRIB_VALUE_UNQUOTED:F++,ATTRIB_VALUE_ENTITY_Q:F++,ATTRIB_VALUE_ENTITY_U:F++,CLOSE_TAG:F++,CLOSE_TAG_SAW_WHITE:F++,SCRIPT:F++,SCRIPT_ENDING:F++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(t){var n=e.ENTITIES[t],r="number"==typeof n?String.fromCharCode(n):n;e.ENTITIES[t]=r}),e.STATE)e.STATE[e.STATE[_]]=_;function I(t,e,n){t[e]&&t[e](n)}function D(t,e,n){t.textNode&&C(t),I(t,e,n)}function C(t){t.textNode=O(t.opt,t.textNode),t.textNode&&I(t,"ontext",t.textNode),t.textNode=""}function O(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function v(t,e){return C(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,I(t,"onerror",e),t}function w(t){return t.sawRoot&&!t.closedRoot&&K(t,"Unclosed root tag"),t.state!==F.BEGIN&&t.state!==F.BEGIN_WHITESPACE&&t.state!==F.TEXT&&v(t,"Unexpected end"),C(t),t.c="",t.closed=!0,I(t,"onend"),a.call(t,t.strict,t.opt),t}function K(t,e){if("object"!=typeof t||!(t instanceof a))throw new Error("bad call to strictFail");t.strict&&v(t,e)}function S(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,n=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(n.ns=e.ns),t.attribList.length=0,D(t,"onopentagstart",n)}function B(t,e){var n=t.indexOf(":")<0?["",t]:t.split(":"),r=n[0],a=n[1];return e&&"xmlns"===t&&(r="xmlns",a=""),{prefix:r,local:a}}function P(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=B(t.attribName,!0),n=e.prefix,r=e.local;if("xmlns"===n)if("xml"===r&&t.attribValue!==u)K(t,"xml: prefix must be bound to "+u+"\nActual: "+t.attribValue);else if("xmlns"===r&&t.attribValue!==l)K(t,"xmlns: prefix must be bound to "+l+"\nActual: "+t.attribValue);else{var a=t.tag,i=t.tags[t.tags.length-1]||t;a.ns===i.ns&&(a.ns=Object.create(i.ns)),a.ns[r]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,D(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function L(t,e){if(t.opt.xmlns){var n=t.tag,r=B(t.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||"",n.prefix&&!n.uri&&(K(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),n.uri=r.prefix);var a=t.tags[t.tags.length-1]||t;n.ns&&a.ns!==n.ns&&Object.keys(n.ns).forEach(function(e){D(t,"onopennamespace",{prefix:e,uri:n.ns[e]})});for(var i=0,s=t.attribList.length;i<s;i++){var o=t.attribList[i],c=o[0],u=o[1],l=B(c,!0),f=l.prefix,m=l.local,p=""===f?"":n.ns[f]||"",E={name:c,value:u,prefix:f,local:m,uri:p};f&&"xmlns"!==f&&!p&&(K(t,"Unbound namespace prefix: "+JSON.stringify(f)),E.uri=f),t.tag.attributes[c]=E,D(t,"onattribute",E)}t.attribList.length=0}t.tag.isSelfClosing=!!e,t.sawRoot=!0,t.tags.push(t.tag),D(t,"onopentag",t.tag),e||(t.noscript||"script"!==t.tagName.toLowerCase()?t.state=F.TEXT:t.state=F.SCRIPT,t.tag=null,t.tagName=""),t.attribName=t.attribValue="",t.attribList.length=0}function R(t){if(!t.tagName)return K(t,"Weird empty close tag."),t.textNode+="</>",void(t.state=F.TEXT);if(t.script){if("script"!==t.tagName)return t.script+="</"+t.tagName+">",t.tagName="",void(t.state=F.SCRIPT);D(t,"onscript",t.script),t.script=""}var e=t.tags.length,n=t.tagName;t.strict||(n=n[t.looseCase]());for(var r=n;e--&&t.tags[e].name!==r;)K(t,"Unexpected close tag");if(e<0)return K(t,"Unmatched closing tag: "+t.tagName),t.textNode+="</"+t.tagName+">",void(t.state=F.TEXT);t.tagName=n;for(var a=t.tags.length;a-- >e;){var i=t.tag=t.tags.pop();t.tagName=t.tag.name,D(t,"onclosetag",t.tagName);var s={};for(var o in i.ns)s[o]=i.ns[o];var c=t.tags[t.tags.length-1]||t;t.opt.xmlns&&i.ns!==c.ns&&Object.keys(i.ns).forEach(function(e){var n=i.ns[e];D(t,"onclosenamespace",{prefix:e,uri:n})})}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=F.TEXT}function U(t){var e,n=t.entity,r=n.toLowerCase(),a="";return t.ENTITIES[n]?t.ENTITIES[n]:t.ENTITIES[r]?t.ENTITIES[r]:("#"===(n=r).charAt(0)&&("x"===n.charAt(1)?(n=n.slice(2),a=(e=parseInt(n,16)).toString(16)):(n=n.slice(1),a=(e=parseInt(n,10)).toString(10))),n=n.replace(/^0+/,""),isNaN(e)||a.toLowerCase()!==n?(K(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function k(t,e){"<"===e?(t.state=F.OPEN_WAKA,t.startTagPosition=t.position):d(e)||(K(t,"Non-whitespace before first tag."),t.textNode=e,t.state=F.TEXT)}function M(t,e){var n="";return e<t.length&&(n=t.charAt(e)),n}F=e.STATE,String.fromCodePoint||(N=String.fromCharCode,A=Math.floor,x=function(){var t,e,n=[],r=-1,a=arguments.length;if(!a)return"";for(var i="";++r<a;){var s=Number(arguments[r]);if(!isFinite(s)||s<0||s>1114111||A(s)!==s)throw RangeError("Invalid code point: "+s);s<=65535?n.push(s):(t=55296+((s-=65536)>>10),e=s%1024+56320,n.push(t,e)),(r+1===a||n.length>16384)&&(i+=N.apply(null,n),n.length=0)}return i},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:x,configurable:!0,writable:!0}):String.fromCodePoint=x)}(T)),T}function h(){return a?r:(a=1,r={isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}})}function b(){if(s)return i;s=1;var t=h().isArray;return i={copyOptions:function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n},ensureFlagExists:function(t,e){t in e&&"boolean"==typeof e[t]||(e[t]=!1)},ensureSpacesExists:function(t){(!("spaces"in t)||"number"!=typeof t.spaces&&"string"!=typeof t.spaces)&&(t.spaces=0)},ensureAlwaysArrayExists:function(e){"alwaysArray"in e&&("boolean"==typeof e.alwaysArray||t(e.alwaysArray))||(e.alwaysArray=!1)},ensureKeyExists:function(t,e){t+"Key"in e&&"string"==typeof e[t+"Key"]||(e[t+"Key"]=e.compact?"_"+t:t)},checkFnExists:function(t,e){return t+"Fn"in e}}}function N(){if(c)return o;c=1;var t,e,n=y(),r=b(),a=h().isArray;function i(t){var e=Number(t);if(!isNaN(e))return e;var n=t.toLowerCase();return"true"===n||"false"!==n&&t}function s(n,r){var i;if(t.compact){if(!e[t[n+"Key"]]&&(a(t.alwaysArray)?-1!==t.alwaysArray.indexOf(t[n+"Key"]):t.alwaysArray)&&(e[t[n+"Key"]]=[]),e[t[n+"Key"]]&&!a(e[t[n+"Key"]])&&(e[t[n+"Key"]]=[e[t[n+"Key"]]]),n+"Fn"in t&&"string"==typeof r&&(r=t[n+"Fn"](r,e)),"instruction"===n&&("instructionFn"in t||"instructionNameFn"in t))for(i in r)if(r.hasOwnProperty(i))if("instructionFn"in t)r[i]=t.instructionFn(r[i],i,e);else{var s=r[i];delete r[i],r[t.instructionNameFn(i,s,e)]=s}a(e[t[n+"Key"]])?e[t[n+"Key"]].push(r):e[t[n+"Key"]]=r}else{e[t.elementsKey]||(e[t.elementsKey]=[]);var o={};if(o[t.typeKey]=n,"instruction"===n){for(i in r)if(r.hasOwnProperty(i))break;o[t.nameKey]="instructionNameFn"in t?t.instructionNameFn(i,r,e):i,t.instructionHasAttributes?(o[t.attributesKey]=r[i][t.attributesKey],"instructionFn"in t&&(o[t.attributesKey]=t.instructionFn(o[t.attributesKey],i,e))):("instructionFn"in t&&(r[i]=t.instructionFn(r[i],i,e)),o[t.instructionKey]=r[i])}else n+"Fn"in t&&(r=t[n+"Fn"](r,e)),o[t[n+"Key"]]=r;t.addParent&&(o[t.parentKey]=e),e[t.elementsKey].push(o)}}function u(n){var r;if("attributesFn"in t&&n&&(n=t.attributesFn(n,e)),(t.trim||"attributeValueFn"in t||"attributeNameFn"in t||t.nativeTypeAttributes)&&n)for(r in n)if(n.hasOwnProperty(r)&&(t.trim&&(n[r]=n[r].trim()),t.nativeTypeAttributes&&(n[r]=i(n[r])),"attributeValueFn"in t&&(n[r]=t.attributeValueFn(n[r],r,e)),"attributeNameFn"in t)){var a=n[r];delete n[r],n[t.attributeNameFn(r,n[r],e)]=a}return n}function l(n){var r={};if(n.body&&("xml"===n.name.toLowerCase()||t.instructionHasAttributes)){for(var a,i=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;null!==(a=i.exec(n.body));)r[a[1]]=a[2]||a[3]||a[4];r=u(r)}if("xml"===n.name.toLowerCase()){if(t.ignoreDeclaration)return;e[t.declarationKey]={},Object.keys(r).length&&(e[t.declarationKey][t.attributesKey]=r),t.addParent&&(e[t.declarationKey][t.parentKey]=e)}else{if(t.ignoreInstruction)return;t.trim&&(n.body=n.body.trim());var o={};t.instructionHasAttributes&&Object.keys(r).length?(o[n.name]={},o[n.name][t.attributesKey]=r):o[n.name]=n.body,s("instruction",o)}}function f(n,r){var i;if("object"==typeof n&&(r=n.attributes,n=n.name),r=u(r),"elementNameFn"in t&&(n=t.elementNameFn(n,e)),t.compact){var s;if(i={},!t.ignoreAttributes&&r&&Object.keys(r).length)for(s in i[t.attributesKey]={},r)r.hasOwnProperty(s)&&(i[t.attributesKey][s]=r[s]);!(n in e)&&(a(t.alwaysArray)?-1!==t.alwaysArray.indexOf(n):t.alwaysArray)&&(e[n]=[]),e[n]&&!a(e[n])&&(e[n]=[e[n]]),a(e[n])?e[n].push(i):e[n]=i}else e[t.elementsKey]||(e[t.elementsKey]=[]),(i={})[t.typeKey]="element",i[t.nameKey]=n,!t.ignoreAttributes&&r&&Object.keys(r).length&&(i[t.attributesKey]=r),t.alwaysChildren&&(i[t.elementsKey]=[]),e[t.elementsKey].push(i);i[t.parentKey]=e,e=i}function m(e){t.ignoreText||(e.trim()||t.captureSpacesBetweenElements)&&(t.trim&&(e=e.trim()),t.nativeType&&(e=i(e)),t.sanitize&&(e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),s("text",e))}function p(e){t.ignoreComment||(t.trim&&(e=e.trim()),s("comment",e))}function E(n){var r=e[t.parentKey];t.addParent||delete e[t.parentKey],e=r}function g(e){t.ignoreCdata||(t.trim&&(e=e.trim()),s("cdata",e))}function d(e){t.ignoreDoctype||(e=e.replace(/^ /,""),t.trim&&(e=e.trim()),s("doctype",e))}function T(t){t.note=t}return o=function(a,i){var s=n.parser(!0,{}),o={};if(e=o,t=function(e){return t=r.copyOptions(e),r.ensureFlagExists("ignoreDeclaration",t),r.ensureFlagExists("ignoreInstruction",t),r.ensureFlagExists("ignoreAttributes",t),r.ensureFlagExists("ignoreText",t),r.ensureFlagExists("ignoreComment",t),r.ensureFlagExists("ignoreCdata",t),r.ensureFlagExists("ignoreDoctype",t),r.ensureFlagExists("compact",t),r.ensureFlagExists("alwaysChildren",t),r.ensureFlagExists("addParent",t),r.ensureFlagExists("trim",t),r.ensureFlagExists("nativeType",t),r.ensureFlagExists("nativeTypeAttributes",t),r.ensureFlagExists("sanitize",t),r.ensureFlagExists("instructionHasAttributes",t),r.ensureFlagExists("captureSpacesBetweenElements",t),r.ensureAlwaysArrayExists(t),r.ensureKeyExists("declaration",t),r.ensureKeyExists("instruction",t),r.ensureKeyExists("attributes",t),r.ensureKeyExists("text",t),r.ensureKeyExists("comment",t),r.ensureKeyExists("cdata",t),r.ensureKeyExists("doctype",t),r.ensureKeyExists("type",t),r.ensureKeyExists("name",t),r.ensureKeyExists("elements",t),r.ensureKeyExists("parent",t),r.checkFnExists("doctype",t),r.checkFnExists("instruction",t),r.checkFnExists("cdata",t),r.checkFnExists("comment",t),r.checkFnExists("text",t),r.checkFnExists("instructionName",t),r.checkFnExists("elementName",t),r.checkFnExists("attributeName",t),r.checkFnExists("attributeValue",t),r.checkFnExists("attributes",t),t}(i),s.opt={strictEntities:!0},s.onopentag=f,s.ontext=m,s.oncomment=p,s.onclosetag=E,s.onerror=T,s.oncdata=g,s.ondoctype=d,s.onprocessinginstruction=l,s.write(a).close(),o[t.elementsKey]){var c=o[t.elementsKey];delete o[t.elementsKey],o[t.elementsKey]=c,delete o.text}return o}}function A(){if(l)return u;l=1;var t=b(),e=N();return u=function(n,r){var a,i,s;return a=function(e){var n=t.copyOptions(e);return t.ensureSpacesExists(n),n}(r),i=e(n,a),s="compact"in a&&a.compact?"_parent":"parent",("addParent"in a&&a.addParent?JSON.stringify(i,function(t,e){return t===s?"_":e},a.spaces):JSON.stringify(i,null,a.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}}function x(){if(m)return f;m=1;var t,e,n=b(),r=h().isArray;function a(t,e,n){return(!n&&t.spaces?"\n":"")+Array(e+1).join(t.spaces)}function i(n,r,i){if(r.ignoreAttributes)return"";"attributesFn"in r&&(n=r.attributesFn(n,e,t));var s,o,c,u,l=[];for(s in n)n.hasOwnProperty(s)&&null!==n[s]&&void 0!==n[s]&&(u=r.noQuotesForNativeAttributes&&"string"!=typeof n[s]?"":'"',o=(o=""+n[s]).replace(/"/g,"&quot;"),c="attributeNameFn"in r?r.attributeNameFn(s,o,e,t):s,l.push(r.spaces&&r.indentAttributes?a(r,i+1,!1):" "),l.push(c+"="+u+("attributeValueFn"in r?r.attributeValueFn(o,s,e,t):o)+u));return n&&Object.keys(n).length&&r.spaces&&r.indentAttributes&&l.push(a(r,i,!1)),l.join("")}function s(n,r,a){return t=n,e="xml",r.ignoreDeclaration?"":"<?xml"+i(n[r.attributesKey],r,a)+"?>"}function o(n,r,a){if(r.ignoreInstruction)return"";var s;for(s in n)if(n.hasOwnProperty(s))break;var o="instructionNameFn"in r?r.instructionNameFn(s,n[s],e,t):s;if("object"==typeof n[s])return t=n,e=o,"<?"+o+i(n[s][r.attributesKey],r,a)+"?>";var c=n[s]?n[s]:"";return"instructionFn"in r&&(c=r.instructionFn(c,s,e,t)),"<?"+o+(c?" "+c:"")+"?>"}function c(n,r){return r.ignoreComment?"":"\x3c!--"+("commentFn"in r?r.commentFn(n,e,t):n)+"--\x3e"}function u(n,r){return r.ignoreCdata?"":"<![CDATA["+("cdataFn"in r?r.cdataFn(n,e,t):n.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function l(n,r){return r.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in r?r.doctypeFn(n,e,t):n)+">"}function p(n,r){return r.ignoreText?"":(n=(n=(n=""+n).replace(/&amp;/g,"&")).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in r?r.textFn(n,e,t):n)}function E(n,r,s,f){return n.reduce(function(n,m){var g=a(r,s,f&&!n);switch(m.type){case"element":return n+g+function(n,r,a){t=n,e=n.name;var s=[],o="elementNameFn"in r?r.elementNameFn(n.name,n):n.name;s.push("<"+o),n[r.attributesKey]&&s.push(i(n[r.attributesKey],r,a));var c=n[r.elementsKey]&&n[r.elementsKey].length||n[r.attributesKey]&&"preserve"===n[r.attributesKey]["xml:space"];return c||(c="fullTagEmptyElementFn"in r?r.fullTagEmptyElementFn(n.name,n):r.fullTagEmptyElement),c?(s.push(">"),n[r.elementsKey]&&n[r.elementsKey].length&&(s.push(E(n[r.elementsKey],r,a+1)),t=n,e=n.name),s.push(r.spaces&&function(t,e){var n;if(t.elements&&t.elements.length)for(n=0;n<t.elements.length;++n)switch(t.elements[n][e.typeKey]){case"text":if(e.indentText)return!0;break;case"cdata":if(e.indentCdata)return!0;break;case"instruction":if(e.indentInstruction)return!0;break;default:return!0}return!1}(n,r)?"\n"+Array(a+1).join(r.spaces):""),s.push("</"+o+">")):s.push("/>"),s.join("")}(m,r,s);case"comment":return n+g+c(m[r.commentKey],r);case"doctype":return n+g+l(m[r.doctypeKey],r);case"cdata":return n+(r.indentCdata?g:"")+u(m[r.cdataKey],r);case"text":return n+(r.indentText?g:"")+p(m[r.textKey],r);case"instruction":var d={};return d[m[r.nameKey]]=m[r.attributesKey]?m:m[r.instructionKey],n+(r.indentInstruction?g:"")+o(d,r,s)}},"")}function g(t,e,n){var r;for(r in t)if(t.hasOwnProperty(r))switch(r){case e.parentKey:case e.attributesKey:break;case e.textKey:if(e.indentText||n)return!0;break;case e.cdataKey:if(e.indentCdata||n)return!0;break;case e.instructionKey:if(e.indentInstruction||n)return!0;break;case e.doctypeKey:case e.commentKey:default:return!0}return!1}function d(n,r,s,o,c){t=n,e=r;var u="elementNameFn"in s?s.elementNameFn(r,n):r;if(null==n||""===n)return"fullTagEmptyElementFn"in s&&s.fullTagEmptyElementFn(r,n)||s.fullTagEmptyElement?"<"+u+"></"+u+">":"<"+u+"/>";var l=[];if(r){if(l.push("<"+u),"object"!=typeof n)return l.push(">"+p(n,s)+"</"+u+">"),l.join("");n[s.attributesKey]&&l.push(i(n[s.attributesKey],s,o));var f=g(n,s,!0)||n[s.attributesKey]&&"preserve"===n[s.attributesKey]["xml:space"];if(f||(f="fullTagEmptyElementFn"in s?s.fullTagEmptyElementFn(r,n):s.fullTagEmptyElement),!f)return l.push("/>"),l.join("");l.push(">")}return l.push(T(n,s,o+1,!1)),t=n,e=r,r&&l.push((c?a(s,o,!1):"")+"</"+u+">"),l.join("")}function T(t,e,n,i){var f,m,E,T=[];for(m in t)if(t.hasOwnProperty(m))for(E=r(t[m])?t[m]:[t[m]],f=0;f<E.length;++f){switch(m){case e.declarationKey:T.push(s(E[f],e,n));break;case e.instructionKey:T.push((e.indentInstruction?a(e,n,i):"")+o(E[f],e,n));break;case e.attributesKey:case e.parentKey:break;case e.textKey:T.push((e.indentText?a(e,n,i):"")+p(E[f],e));break;case e.cdataKey:T.push((e.indentCdata?a(e,n,i):"")+u(E[f],e));break;case e.doctypeKey:T.push(a(e,n,i)+l(E[f],e));break;case e.commentKey:T.push(a(e,n,i)+c(E[f],e));break;default:T.push(a(e,n,i)+d(E[f],m,e,n,g(E[f],e)))}i=i&&!T.length}return T.join("")}return f=function(r,a){a=function(t){var e=n.copyOptions(t);return n.ensureFlagExists("ignoreDeclaration",e),n.ensureFlagExists("ignoreInstruction",e),n.ensureFlagExists("ignoreAttributes",e),n.ensureFlagExists("ignoreText",e),n.ensureFlagExists("ignoreComment",e),n.ensureFlagExists("ignoreCdata",e),n.ensureFlagExists("ignoreDoctype",e),n.ensureFlagExists("compact",e),n.ensureFlagExists("indentText",e),n.ensureFlagExists("indentCdata",e),n.ensureFlagExists("indentAttributes",e),n.ensureFlagExists("indentInstruction",e),n.ensureFlagExists("fullTagEmptyElement",e),n.ensureFlagExists("noQuotesForNativeAttributes",e),n.ensureSpacesExists(e),"number"==typeof e.spaces&&(e.spaces=Array(e.spaces+1).join(" ")),n.ensureKeyExists("declaration",e),n.ensureKeyExists("instruction",e),n.ensureKeyExists("attributes",e),n.ensureKeyExists("text",e),n.ensureKeyExists("comment",e),n.ensureKeyExists("cdata",e),n.ensureKeyExists("doctype",e),n.ensureKeyExists("type",e),n.ensureKeyExists("name",e),n.ensureKeyExists("elements",e),n.checkFnExists("doctype",e),n.checkFnExists("instruction",e),n.checkFnExists("cdata",e),n.checkFnExists("comment",e),n.checkFnExists("text",e),n.checkFnExists("instructionName",e),n.checkFnExists("elementName",e),n.checkFnExists("attributeName",e),n.checkFnExists("attributeValue",e),n.checkFnExists("attributes",e),n.checkFnExists("fullTagEmptyElement",e),e}(a);var i=[];return t=r,e="_root_",a.compact?i.push(T(r,a,0,!0)):(r[a.declarationKey]&&i.push(s(r[a.declarationKey],a,0)),r[a.elementsKey]&&r[a.elementsKey].length&&i.push(E(r[a.elementsKey],a,0,!i.length))),i.join("")}}function F(){if(E)return p;E=1;var t=x();return p=function(e,n){e instanceof Buffer&&(e=e.toString());var r=null;if("string"==typeof e)try{r=JSON.parse(e)}catch(t){throw new Error("The JSON structure is invalid")}else r=e;return t(r,n)}}var _=function(){if(d)return g;d=1;var t=N(),e=A(),n=x(),r=F();return g={xml2js:t,xml2json:e,js2xml:n,json2xml:r}}();function I(t){const e=Buffer.allocUnsafe(t.length);for(let n=0;n<t.length-1;n+=2)e[n]=t[n+1],e[n+1]=t[n];return t.length%2==1&&(e[t.length-1]=t[t.length-1]),e}function D(t){const e=function(t){if(t.length>=2){if(255===t[0]&&254===t[1])return{encoding:"utf16le",hasBom:!0};if(254===t[0]&&255===t[1])return{encoding:"utf16be",hasBom:!0}}let e=0,n=0;for(let r=0;r<t.length;r++)0===t[r]&&(r%2==0?n++:e++);return e>8&&e>2*n?{encoding:"utf16le",hasBom:!1}:n>8&&n>2*e?{encoding:"utf16be",hasBom:!1}:{encoding:"utf8",hasBom:!1}}(t);if("utf16le"===e.encoding){return{text:(e.hasBom?t.subarray(2):t).toString("utf16le"),encoding:e}}if("utf16be"===e.encoding){return{text:I(e.hasBom?t.subarray(2):t).toString("utf16le"),encoding:e}}return{text:t.toString("utf8"),encoding:e}}function C(t){return Buffer.isBuffer(t)&&(t=D(t).text),_.xml2js(t,{compact:!1})}function O(t){return t.replace(/&(?!(?:amp|lt|gt|quot);)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function v(t,e){return _.js2xml(t,{attributeValueFn:O,...e})}function w(t,e={}){var n;Buffer.isBuffer(t)&&(t=D(t).text);const r=null!==(n=e.spaces)&&void 0!==n?n:2;return function(t,e){let n=0;for(;n<t.length&&t.charCodeAt(n)<=32;)n++;if(n>=t.length||"<"!==t[n])throw new Error("Not valid XML: must start with <");const r=t.length,a=[];let i=n,s=0;for(;i<r;){for(;i<r&&t.charCodeAt(i)<=32;)i++;if(i>=r)break;if("<"!==t[i]){const n=t.indexOf("<",i),o=-1===n?t.slice(i):t.slice(i,n);o&&a.push(e.repeat(s),o,"\n"),i=-1===n?r:n;continue}const n=t[i+1];if("?"===n){const n=t.indexOf("?>",i);if(-1===n)throw new Error("Unterminated processing instruction");a.push(e.repeat(s),t.slice(i,n+2),"\n"),i=n+2}else if("!"===n&&"-"===t[i+2]&&"-"===t[i+3]){const n=t.indexOf("--\x3e",i);if(-1===n)throw new Error("Unterminated comment");a.push(e.repeat(s),t.slice(i,n+3),"\n"),i=n+3}else if("!"===n&&"["===t[i+2]){const n=t.indexOf("]]>",i);if(-1===n)throw new Error("Unterminated CDATA section");a.push(e.repeat(s),t.slice(i,n+3),"\n"),i=n+3}else if("/"===n){if(s--,s<0)throw new Error("Unexpected closing tag");const n=t.indexOf(">",i);if(-1===n)throw new Error("Unterminated closing tag");a.push(e.repeat(s),t.slice(i,n+1),"\n"),i=n+1}else{let n=i+1;for(;n<r&&">"!==t[n];){if('"'===t[n])for(n++;n<r&&'"'!==t[n];)n++;else if("'"===t[n])for(n++;n<r&&"'"!==t[n];)n++;n++}if(n>=r)throw new Error("Unterminated tag");const o=n+1;if("/"===t[n-1])a.push(e.repeat(s),t.slice(i,o),"\n"),i=o;else{const n=t.indexOf("<",o);if(-1!==n&&"/"===t[n+1]){const r=t.slice(o,n),c=t.indexOf(">",n);if(-1===c)throw new Error("Unterminated closing tag");a.push(e.repeat(s),t.slice(i,o),r,t.slice(n,c+1),"\n"),i=c+1}else a.push(e.repeat(s),t.slice(i,o),"\n"),s++,i=o}}}return a.join("")}(t,"string"==typeof r?r:" ".repeat(r))}function K(t,e={},n){if(t.length>=5242880){const e=(t.length/1048576).toFixed(2),r=n?`"${n}"`:"XML buffer";return console.log(`Skipping XML formatting: ${r} size (${e} MB) exceeds the 5 MB limit.`),t}const r=D(t);return function(t,e){if("utf16le"===e.encoding){const n=Buffer.from(t,"utf16le");return e.hasBom?Buffer.concat([Buffer.from([255,254]),n]):n}if("utf16be"===e.encoding){const n=I(Buffer.from(t,"utf16le"));return e.hasBom?Buffer.concat([Buffer.from([254,255]),n]):n}const n=Buffer.from(t,"utf8");return e.hasBom?Buffer.concat([Buffer.from([239,187,191]),n]):n}(w(r.text,e),r.encoding)}function S(t,e){return function(t,e){return t&&t.find(e)}(t,t=>t.name===e)}const B=e.env.debug("vbapm:target.transforms.core-xml"),P=/docProps[\/,\\]core\.xml/i;const L=/\.(xml|rels)$/i;function R(t,...e){t=t.slice();for(const n of e){const e=t.indexOf(n);t.splice(e,1)}return t}const U=e.env.debug("vbapm:target.transforms.workbook-xml"),k=/xl[\/,\\]workbook\.xml/i;const M=/vba.*\.bin/i;const V=function(...t){return(e,n,r)=>t.reduce((t,a)=>t?a(e,n,r):t,!0)}(function(t){return!M.test(t.path)}),G=function(...t){return(e,n,r)=>t.reduce((t,e)=>e(t,n,r),e)}(function(t){if(!P.test(t.path))return t;const e=C(t.data.toString("utf8")),n=S(e.elements,"cp:coreProperties");if(n){const t=S(n.elements,"cp:lastModifiedBy"),e=S(n.elements,"dc:creator");t&&e&&(t.elements[0].text=e.elements[0].text);const r=S(n.elements,"dcterms:modified"),a=S(n.elements,"dcterms:created");r&&a&&(r.elements[0].text=a.elements[0].text)}else B("Warning: cp:coreProperties not found, unable to transform core.xml");return t.data=Buffer.from(v(e)),t},function(t){if(!k.test(t.path))return t;const e=C(t.data.toString("utf8")),n=S(e.elements,"workbook");if(n){const t=S(n.elements,"mc:AlternateContent"),e=S(t&&t.elements,"mc:Choice"),r=S(e&&e.elements,"x15ac:absPath");r&&(r.attributes.url="");const a=S(n.elements,"bookViews");a&&(n.elements=R(n.elements,a));const i=S(n.elements,"fileVersion");i&&(n.elements=R(n.elements,i));const s=S(n.elements,"calcPr");s&&(s.attributes.calcId="0")}else U("Warning: workbook not found, unable to transform workbook.xml");return t.data=Buffer.from(v(e)),t},function(t){if(!L.test(t.path))return t;try{t.data=K(t.data,{spaces:2},t.path)}catch{console.warn(`Warning: Failed to parse ${t.path} as XML. Leaving unmodified.`)}return t});exports.filterTarget=V,exports.mapTarget=G;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Text encoding detection and buffer round-trip helpers.
3
+ *
4
+ * This utility was originally created to handle XML documents generated in
5
+ * Open XML formats (e.g. OOXML parts), where files may be encoded as UTF-8,
6
+ * UTF-16 LE, or UTF-16 BE and must keep their original encoding after edits.
7
+ */
8
+ export type TextEncoding = "utf8" | "utf16le" | "utf16be";
9
+ export interface BufferEncoding {
10
+ encoding: TextEncoding;
11
+ hasBom: boolean;
12
+ }
13
+ /**
14
+ * Decodes a UTF-8, UTF-16 LE, or UTF-16 BE buffer into a text string, along with the detected encoding and BOM presence for later re-encoding.
15
+ * If the buffer has a BOM, it will be stripped from the output text.
16
+ * @param data The buffer containing the encoded text.
17
+ * @returns An object containing the decoded text and the detected encoding information.
18
+ */
19
+ export declare function decodeBuffer(data: Buffer): {
20
+ text: string;
21
+ encoding: BufferEncoding;
22
+ };
23
+ /**
24
+ * Encodes a text string into a UTF-8, UTF-16 LE, or UTF-16 BE buffer.
25
+ * Optionally includes a BOM if specified in the encoding information.
26
+ * @param text The text string to encode.
27
+ * @param encoding The encoding information, including the desired encoding and BOM presence.
28
+ * @returns A buffer containing the encoded text.
29
+ */
30
+ export declare function encodeBuffer(text: string, encoding: BufferEncoding): Buffer;
@@ -11,7 +11,10 @@ export declare class RunError extends Error {
11
11
  constructor(result: RunResult);
12
12
  }
13
13
  export declare function isRunError(error: Error | RunError): error is RunError;
14
- export declare function run(application: string, file: string, macro: string, args: string[]): Promise<RunResult>;
14
+ export interface RunOptions {
15
+ keepOpen?: boolean;
16
+ }
17
+ export declare function run(application: string, file: string, macro: string, args: string[], options?: RunOptions): Promise<RunResult>;
15
18
  export declare function escape(value: string): string;
16
19
  export declare function unescape(value: string): string;
17
20
  export declare function toResult(stdout: string, stderr: string, err?: Error): RunResult;
@@ -1,9 +1,23 @@
1
1
  import { Element } from "xml-js";
2
2
  export type Xml = any;
3
+ /**
4
+ * Parses an XML string or buffer into an (xml-js) Element object.
5
+ * @param xml The XML content as a string or buffer.
6
+ * @returns The parsed XML as an (xml-js) Element object.
7
+ */
3
8
  export declare function parseXml(xml: string | Buffer): Element;
4
9
  export interface ConvertOptions {
5
10
  compact?: boolean;
11
+ spaces?: number | string;
6
12
  }
7
13
  export declare function convertXml(value: Xml, options?: ConvertOptions): string;
14
+ /**
15
+ * Single-pass XML formatting
16
+ * @param xml The XML string or buffer to format.
17
+ * @param options Formatting options.
18
+ * @returns The formatted XML string.
19
+ */
20
+ export declare function formatXml(xml: string | Buffer, options?: ConvertOptions): string;
21
+ export declare function formatXmlBuffer(xml: Buffer, options?: ConvertOptions, fileName?: string): Buffer;
8
22
  export declare function findElement(elements: Element[] | undefined, callback: (element: Element, index: number, elements: Element[]) => boolean): Element | undefined;
9
23
  export declare function findElementByName(elements: Element[] | undefined, name: string): Element | undefined;
@@ -0,0 +1,16 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./add-source-BOumGmx7.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./index-CBGUBgfk.js");const s=e.dedent`
2
+ Create and register a new source file in vbaproject.toml
3
+
4
+ Usage: vbapm add <name> [options]
5
+
6
+ Options:
7
+ <name> Source name or file path (optionally with .bas or .cls extension)
8
+ --type=TYPE Source type (module or class)
9
+ --dev Add to [dev-src] instead of [src]
10
+
11
+ Examples:
12
+ vbapm add ./src/subfolder/Module1.bas
13
+ vbapm add Module1
14
+ vbapm add JsonParser --type class
15
+ vbapm add TestHelpers --dev
16
+ `;exports.default=async function(e){if(e.help)return void console.log(s);const[t]=e._,a=e.type,i=!!e.dev,o=await r.addSource({name:t,type:a,dev:i});o.isNew?console.log(`Created ${o.path}`):console.log(`Registered existing file ${o.path}`)};
@@ -0,0 +1,9 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("node:process"),t=require("node:path"),o=require("node:url"),i=require("node:child_process"),n=require("node:fs/promises"),a=require("node:util"),s=require("node:os"),c=require("node:fs"),l=require("node:buffer"),u=require("./index-C61lSPb5.js"),d=require("./build-project-De7NPBpt.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./project-BPmPCkUS.js"),require("./index-CBGUBgfk.js"),require("querystring"),require("./build-target-ooHNsSLD.js"),require("./transform-build-graph-DgRrocSn.js"),require("./load-from-project-ClF4qaC0.js"),require("./transform-target-CYhuozxP.js"),require("string_decoder"),require("./get-target-LUoY1UWJ.js");var m="undefined"!=typeof document?document.currentScript:null;let p,f;function g(){return void 0===p&&(p=function(){try{return c.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return c.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),p}function w(){return void 0===f&&(f=(()=>{try{return c.statSync("/run/.containerenv"),!0}catch{return!1}})()||g()),f}const h=()=>{if("linux"!==r.platform)return!1;if(s.release().toLowerCase().includes("microsoft"))return!w();try{if(c.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!w()}catch{}return!(!c.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")&&!c.existsSync("/run/WSL"))&&!w()};var v=r.env.__IS_WSL_TEST__?h:h();const y=a.promisify(i.execFile),x=()=>`${r.env.SYSTEMROOT||r.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,b=async(e,r={})=>{const{powerShellPath:t,...o}=r,i=b.encodeCommand(e);return y(t??x(),[...b.argumentsPrefix,i],{encoding:"utf8",...o})};b.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"],b.encodeCommand=e=>l.Buffer.from(e,"utf16le").toString("base64"),b.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;const S=a.promisify(i.execFile),P=(()=>{const e="/mnt/";let r;return async function(){if(r)return r;const t="/etc/wsl.conf";let o=!1;try{await n.access(t,n.constants.F_OK),o=!0}catch{}if(!o)return e;const i=function(e){for(const r of e.split("\n")){if(/^\s*#/.test(r))continue;const e=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(r);if(e)return e.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}(await n.readFile(t,{encoding:"utf8"}));return void 0===i?e:(r=i,r=r.endsWith("/")?r:`${r}/`,r)}})(),q=v?async()=>`${await P()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:x;let E;function C(e,r,t){const o=t=>Object.defineProperty(e,r,{value:t,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){const e=t();return o(e),e},set(e){o(e)}}),e}const B=a.promisify(i.execFile);const T=a.promisify(i.execFile);async function A(e){return async function(e,{humanReadableOutput:t=!0,signal:o}={}){if("darwin"!==r.platform)throw new Error("macOS only");const i=t?[]:["-ss"],n={};o&&(n.signal=o);const{stdout:a}=await T("osascript",["-e",e,i],n);return a.trim()}(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const F=a.promisify(i.execFile),L={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},_=new Map(Object.entries(L));class j extends Error{}const O=a.promisify(i.execFile);async function H(){if("darwin"===r.platform){const e=await async function(){if("darwin"!==r.platform)throw new Error("macOS only");const{stdout:e}=await B("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e),o=t?.groups.id??"com.apple.Safari";return"com.apple.safari"===o?"com.apple.Safari":o}();return{name:await A(e),id:e}}if("linux"===r.platform){const{stdout:e}=await O("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:r.replace(/.desktop$/,"").replace("-"," ").toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase()),id:r}}if("win32"===r.platform)return async function(e=F){const{stdout:r}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!t)throw new j(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);const{id:o}=t.groups,i=o.lastIndexOf("."),n=o.lastIndexOf("-"),a=-1===i?void 0:o.slice(0,i),s=-1===n?void 0:o.slice(0,n);return L[o]??L[a]??L[s]??{name:o,id:o}}();throw new Error("Only macOS, Linux, and Windows are supported")}const M=Boolean(r.env.SSH_CONNECTION||r.env.SSH_CLIENT||r.env.SSH_TTY),U=Symbol("fallbackAttempt"),I=("undefined"==typeof document?require("url").pathToFileURL(__filename).href:m&&"SCRIPT"===m.tagName.toUpperCase()&&m.src||new URL("vbapm-build-Bhm_pqQW.js",document.baseURI).href)?t.dirname(o.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:m&&"SCRIPT"===m.tagName.toUpperCase()&&m.src||new URL("vbapm-build-Bhm_pqQW.js",document.baseURI).href)):"",R=t.join(I,"xdg-open"),{platform:$,arch:N}=r,W=async(e,r)=>{if(0===e.length)return;const t=[];for(const o of e)try{return await r(o)}catch(e){t.push(e)}throw new AggregateError(t,"Failed to open in all supported apps")},k=async e=>{const t=!0===(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e})[U];if(delete e[U],Array.isArray(e.app))return W(e.app,r=>k({...e,app:r,[U]:!0}));let o,{name:a,arguments:s=[]}=e.app??{};if(s=[...s],Array.isArray(a))return W(a,r=>k({...e,app:{name:r,arguments:s},[U]:!0}));if("browser"===a||"browserPrivate"===a){const r={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},t={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"};let o;if(v){const e=await(async()=>{const e=await q(),r=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:t}=await b(r,{powerShellPath:e});return t.trim()})();o=_.get(e)??{}}else o=await H();if(o.id in r){const i=r[o.id.toLowerCase()];if("browserPrivate"===a){if("safari"===i)throw new Error("Safari doesn't support opening in private mode via command line");s.push(t[i])}return k({...e,app:{name:Y[i],arguments:s}})}throw new Error(`${o.name} is not supported as a default browser`)}const c=[],l={};let u=!1;if(!v||w()||M||a||(u=await(async()=>(E??=(async()=>{try{const e=await q();return await n.access(e,n.constants.X_OK),!0}catch{return!1}})(),E))()),"darwin"===$)o="open",e.wait&&c.push("--wait-apps"),e.background&&c.push("--background"),e.newInstance&&c.push("--new"),a&&c.push("-a",a);else if("win32"===$||u){o=await q(),c.push(...b.argumentsPrefix),v||(l.windowsVerbatimArguments=!0),v&&e.target&&(e.target=await(async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{const{stdout:r}=await S("wslpath",["-aw",e],{encoding:"utf8"});return r.trim()}catch{return e}})(e.target));const r=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&r.push("-Wait"),a?(r.push(b.escapeArgument(a)),e.target&&s.push(e.target)):e.target&&r.push(b.escapeArgument(e.target)),s.length>0&&(s=s.map(e=>b.escapeArgument(e)),r.push("-ArgumentList",s.join(","))),e.target=b.encodeCommand(r.join(" ")),e.wait||(l.stdio="ignore")}else{if(a)o=a;else{const e=!I||"/"===I;let t=!1;try{await n.access(R,n.constants.X_OK),t=!0}catch{}o=r.versions.electron??("android"===$||e||!t)?"xdg-open":R}s.length>0&&c.push(...s),e.wait||(l.stdio="ignore",l.detached=!0)}"darwin"===$&&s.length>0&&c.push("--args",...s),e.target&&c.push(e.target);const d=i.spawn(o,c,l);return e.wait?new Promise((r,t)=>{d.once("error",t),d.once("close",o=>{e.allowNonzeroExitCode||0===o?r(d):t(new Error(`Exited with code ${o}`))})}):t?new Promise((e,r)=>{d.once("error",r),d.once("spawn",()=>{d.once("close",t=>{d.off("error",r),0===t?(d.unref(),e(d)):r(new Error(`Exited with code ${t}`))})})}):(d.unref(),new Promise((e,r)=>{d.once("error",r),d.once("spawn",()=>{d.off("error",r),e(d)})}))};function z(e){if("string"==typeof e||Array.isArray(e))return e;const{[N]:r}=e;if(!r)throw new Error(`${N} is not supported`);return r}function D({[$]:e},{wsl:r}={}){if(r&&v)return z(r);if(!e)throw new Error(`${$} is not supported`);return z(e)}const Y={browser:"browser",browserPrivate:"browserPrivate"};C(Y,"chrome",()=>D({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}})),C(Y,"brave",()=>D({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}})),C(Y,"firefox",()=>D({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"})),C(Y,"edge",()=>D({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"})),C(Y,"safari",()=>D({darwin:"Safari"}));const G=e.dedent`
2
+ Build project from manifest (after backing up any existing built targets).
3
+
4
+ Usage: vbapm build [options]
5
+
6
+ Options:
7
+ --target=TYPE Build target of type TYPE
8
+ --release Exclude dev-* items from build
9
+ --open Open built target`;exports.default=async function(e){if(e.help)return void console.log(G);const r=process.hrtime(),t=e.target,o=e.addin,i=!!e.release,n=await d.buildProject({target:t,addin:o,release:i});if(console.log(`Done. ${u.time(process.hrtime(r))}`),e.open){console.log(`Opening built target: ${n}`);try{await((e,r)=>{if("string"!=typeof e)throw new TypeError("Expected a `target`");return k({...r,target:e})})(n,{wait:!0})}catch(e){throw console.error(`Failed to open built target: ${(null==e?void 0:e.message)||e}`),e}}};
@@ -0,0 +1,9 @@
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./export-project-CgFMyE-g.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./transform-build-graph-DgRrocSn.js"),require("node:fs"),require("node:path"),require("node:buffer"),require("./project-BPmPCkUS.js"),require("./index-CBGUBgfk.js"),require("querystring"),require("./export-target-C0RYJqUX.js"),require("./load-from-project-ClF4qaC0.js"),require("./transform-target-CYhuozxP.js"),require("string_decoder");const t=e.dedent`
2
+ Export built project, including src, references, and target.
3
+
4
+ Usage: vbapm export
5
+
6
+ Options:
7
+ --target=TYPE Export target of type TYPE
8
+ --xml-only Only extract the target XML, skip VBA source export
9
+ --vba-only Only export the VBA source, skip target XML extraction`;exports.default=async function(e){if(e.help)return void console.log(t);const i=e.target,o=e.completed,s=e.addin,u=!!e["xml-only"],n=!!e["vba-only"];await r.exportProject({target:i,completed:o,addin:s,xmlOnly:u,vbaOnly:n})};
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("./installer-CJlDenLg.js"),r=require("./init-project-dRuDA4YO.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./project-C3bWzV0O.js"),require("querystring"),require("./transform-target-Doak2S1q.js"),require("string_decoder"),require("./build-target-D6L5nsgt.js"),require("./load-from-project-Bpb6Ne_i.js"),require("./export-target-CN6RA_mA.js");const t=e.dedent`
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./init-project-9RKSVG_H.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./index-CBGUBgfk.js"),require("./project-BPmPCkUS.js"),require("querystring"),require("./transform-build-graph-DgRrocSn.js"),require("node:fs"),require("node:path"),require("node:buffer"),require("./build-target-ooHNsSLD.js"),require("./load-from-project-ClF4qaC0.js"),require("./export-target-C0RYJqUX.js"),require("./transform-target-CYhuozxP.js"),require("string_decoder");const t=e.dedent`
2
2
  Initialize a new project in the current directory
3
3
 
4
4
  Usage: vbapm init [options]
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("./installer-CJlDenLg.js"),r=require("./create-project-CPIRr0DV.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./init-project-dRuDA4YO.js"),require("./project-C3bWzV0O.js"),require("querystring"),require("./transform-target-Doak2S1q.js"),require("string_decoder"),require("./build-target-D6L5nsgt.js"),require("./load-from-project-Bpb6Ne_i.js"),require("./export-target-CN6RA_mA.js");const t=e.dedent`
1
+ "use strict";var e=require("./installer-DPj-zT7L.js"),r=require("./create-project-BYc3XMZw.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./init-project-9RKSVG_H.js"),require("./index-CBGUBgfk.js"),require("./project-BPmPCkUS.js"),require("querystring"),require("./transform-build-graph-DgRrocSn.js"),require("node:fs"),require("node:path"),require("node:buffer"),require("./build-target-ooHNsSLD.js"),require("./load-from-project-ClF4qaC0.js"),require("./export-target-C0RYJqUX.js"),require("./transform-target-CYhuozxP.js"),require("string_decoder");const t=e.dedent`
2
2
  Create a new project / package in a new directory
3
3
 
4
4
  Usage: vbapm new <name> [options]
@@ -1,4 +1,4 @@
1
- "use strict";var r=require("./installer-CJlDenLg.js"),e=require("./run-macro-D_9-BO3U.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./transform-target-Doak2S1q.js"),require("string_decoder"),require("./project-C3bWzV0O.js"),require("querystring"),require("./get-target-CH6IpAa1.js");const t=r.dedent`
1
+ "use strict";var r=require("./installer-DPj-zT7L.js"),e=require("./run-macro-C1-aJWu5.js");require("child_process"),require("util"),require("assert"),require("path"),require("fs"),require("./_commonjsHelpers-Bjf42z7h.js"),require("crypto"),require("events"),require("os"),require("constants"),require("stream"),require("http"),require("url"),require("punycode"),require("https"),require("zlib"),require("./transform-build-graph-DgRrocSn.js"),require("node:fs"),require("node:path"),require("node:buffer"),require("./project-BPmPCkUS.js"),require("./index-CBGUBgfk.js"),require("querystring"),require("./transform-target-CYhuozxP.js"),require("string_decoder"),require("./get-target-LUoY1UWJ.js");const i=r.dedent`
2
2
  Run macro in given workbook or add-in.
3
3
 
4
4
  Usage: vbapm run <macro> [<arg>...] [options]
@@ -7,4 +7,4 @@
7
7
  <macro> Public macro to run in given file (e.g. Tests.RunTests)
8
8
  <arg> Arguments to pass to macro (optional)
9
9
  --target=TYPE Run in pre-built target of type TYPE
10
- --file=PATH Full path to workbook or name of add-in`;exports.default=async function(r){if(r.help)return void console.log(t);const[i,...o]=r._,u=r.target;let s=r.file;await e.runMacro({target:u,file:s,macro:i,args:o})};
10
+ --file=PATH Full path to workbook or name of add-in`;exports.default=async function(r){if(r.help)return void console.log(i);const[t,...o]=r._,u=r.target;let s=r.file;await e.runMacro({target:u,file:s,macro:t,args:o})};