@pickled-dev/cli 0.20.0 → 0.22.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +213 -190
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,227 +1,227 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var UX=Object.create;var{getPrototypeOf:WX,defineProperty:w5,getOwnPropertyNames:VX}=Object;var KX=Object.prototype.hasOwnProperty;function BX($){return this[$]}var LX,TX,P5=($,Z,X)=>{var z=$!=null&&typeof $==="object";if(z){var q=Z?LX??=new WeakMap:TX??=new WeakMap,G=q.get($);if(G)return G}X=$!=null?UX(WX($)):{};let J=Z||!$||!$.__esModule?w5(X,"default",{value:$,enumerable:!0}):X;for(let Q of VX($))if(!KX.call(J,Q))w5(J,Q,{get:BX.bind($,Q),enumerable:!0});if(z)q.set($,J);return J};var F=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var L0=import.meta.require;var f$=F((DX)=>{class K4 extends Error{constructor($,Z,X){super(X);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Z,this.exitCode=$,this.nestedError=void 0}}class I5 extends K4{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}DX.CommanderError=K4;DX.InvalidArgumentError=I5});var C1=F((wX)=>{var{InvalidArgumentError:MX}=f$();class R5{constructor($,Z){switch(this.description=Z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new MX(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function OX($){let Z=$.name()+($.variadic===!0?"...":"");return $.required?"<"+Z+">":"["+Z+"]"}wX.Argument=R5;wX.humanReadableArgName=OX});var B4=F((AX)=>{var{humanReadableArgName:RX}=C1();class A5{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let Z=$.commands.filter((z)=>!z._hidden),X=$._getHelpCommand();if(X&&!X._hidden)Z.push(X);if(this.sortSubcommands)Z.sort((z,q)=>{return z.name().localeCompare(q.name())});return Z}compareOptions($,Z){let X=(z)=>{return z.short?z.short.replace(/^-/,""):z.long.replace(/^--/,"")};return X($).localeCompare(X(Z))}visibleOptions($){let Z=$.options.filter((z)=>!z.hidden),X=$._getHelpOption();if(X&&!X.hidden){let z=X.short&&$._findOption(X.short),q=X.long&&$._findOption(X.long);if(!z&&!q)Z.push(X);else if(X.long&&!q)Z.push($.createOption(X.long,X.description));else if(X.short&&!z)Z.push($.createOption(X.short,X.description))}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let Z=[];for(let X=$.parent;X;X=X.parent){let z=X.options.filter((q)=>!q.hidden);Z.push(...z)}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((Z)=>{Z.description=Z.description||$._argsDescription[Z.name()]||""});if($.registeredArguments.find((Z)=>Z.description))return $.registeredArguments;return[]}subcommandTerm($){let Z=$.registeredArguments.map((X)=>RX(X)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(Z?" "+Z:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,Z){return Z.visibleCommands($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleSubcommandTerm(Z.subcommandTerm(z))))},0)}longestOptionTermLength($,Z){return Z.visibleOptions($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(z))))},0)}longestGlobalOptionTermLength($,Z){return Z.visibleGlobalOptions($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(z))))},0)}longestArgumentTermLength($,Z){return Z.visibleArguments($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleArgumentTerm(Z.argumentTerm(z))))},0)}commandUsage($){let Z=$._name;if($._aliases[0])Z=Z+"|"+$._aliases[0];let X="";for(let z=$.parent;z;z=z.parent)X=z.name()+" "+X;return X+Z+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)Z.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)Z.push(`env: ${$.envVar}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}argumentDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0)Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}formatItemList($,Z,X){if(Z.length===0)return[];return[X.styleTitle($),...Z,""]}groupItems($,Z,X){let z=new Map;return $.forEach((q)=>{let G=X(q);if(!z.has(G))z.set(G,[])}),Z.forEach((q)=>{let G=X(q);if(!z.has(G))z.set(G,[]);z.get(G).push(q)}),z}formatHelp($,Z){let X=Z.padWidth($,Z),z=Z.helpWidth??80;function q(W,U){return Z.formatItem(W,X,U,Z)}let G=[`${Z.styleTitle("Usage:")} ${Z.styleUsage(Z.commandUsage($))}`,""],J=Z.commandDescription($);if(J.length>0)G=G.concat([Z.boxWrap(Z.styleCommandDescription(J),z),""]);let Q=Z.visibleArguments($).map((W)=>{return q(Z.styleArgumentTerm(Z.argumentTerm(W)),Z.styleArgumentDescription(Z.argumentDescription(W)))});if(G=G.concat(this.formatItemList("Arguments:",Q,Z)),this.groupItems($.options,Z.visibleOptions($),(W)=>W.helpGroupHeading??"Options:").forEach((W,U)=>{let V=W.map((B)=>{return q(Z.styleOptionTerm(Z.optionTerm(B)),Z.styleOptionDescription(Z.optionDescription(B)))});G=G.concat(this.formatItemList(U,V,Z))}),Z.showGlobalOptions){let W=Z.visibleGlobalOptions($).map((U)=>{return q(Z.styleOptionTerm(Z.optionTerm(U)),Z.styleOptionDescription(Z.optionDescription(U)))});G=G.concat(this.formatItemList("Global Options:",W,Z))}return this.groupItems($.commands,Z.visibleCommands($),(W)=>W.helpGroup()||"Commands:").forEach((W,U)=>{let V=W.map((B)=>{return q(Z.styleSubcommandTerm(Z.subcommandTerm(B)),Z.styleSubcommandDescription(Z.subcommandDescription(B)))});G=G.concat(this.formatItemList(U,V,Z))}),G.join(`
4
- `)}displayWidth($){return j5($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z==="[command]")return this.styleSubcommandText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleCommandText(Z)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleSubcommandText(Z)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,Z){return Math.max(Z.longestOptionTermLength($,Z),Z.longestGlobalOptionTermLength($,Z),Z.longestSubcommandTermLength($,Z),Z.longestArgumentTermLength($,Z))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,Z,X,z){let G=" ".repeat(2);if(!X)return G+$;let J=$.padEnd(Z+$.length-z.displayWidth($)),Q=2,H=(this.helpWidth??80)-Z-Q-2,W;if(H<this.minWidthToWrap||z.preformatted(X))W=X;else W=z.boxWrap(X,H).replace(/\n/g,`
5
- `+" ".repeat(Z+Q));return G+J+" ".repeat(Q)+W.replace(/\n/g,`
6
- ${G}`)}boxWrap($,Z){if(Z<this.minWidthToWrap)return $;let X=$.split(/\r\n|\n/),z=/[\s]*[^\s]+/g,q=[];return X.forEach((G)=>{let J=G.match(z);if(J===null){q.push("");return}let Q=[J.shift()],Y=this.displayWidth(Q[0]);J.forEach((H)=>{let W=this.displayWidth(H);if(Y+W<=Z){Q.push(H),Y+=W;return}q.push(Q.join(""));let U=H.trimStart();Q=[U],Y=this.displayWidth(U)}),q.push(Q.join(""))}),q.join(`
7
- `)}}function j5($){let Z=/\x1b\[\d*(;\d*)*m/g;return $.replace(Z,"")}AX.Help=A5;AX.stripColor=j5});var L4=F((EX)=>{var{InvalidArgumentError:SX}=f$();class S5{constructor($,Z){this.flags=$,this.description=Z||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let X=CX($);if(this.short=X.shortFlag,this.long=X.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let Z=$;if(typeof $==="string")Z={[$]:!0};return this.implied=Object.assign(this.implied||{},Z),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new SX(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return N5(this.name().replace(/^no-/,""));return N5(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class C5{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((Z)=>{if(Z.negate)this.negativeOptions.set(Z.attributeName(),Z);else this.positiveOptions.set(Z.attributeName(),Z)}),this.negativeOptions.forEach((Z,X)=>{if(this.positiveOptions.has(X))this.dualOptions.add(X)})}valueFromOption($,Z){let X=Z.attributeName();if(!this.dualOptions.has(X))return!0;let z=this.negativeOptions.get(X).presetArg,q=z!==void 0?z:!1;return Z.negate===(q===$)}}function N5($){return $.split("-").reduce((Z,X)=>{return Z+X[0].toUpperCase()+X.slice(1)})}function CX($){let Z,X,z=/^-[^-]$/,q=/^--[^-]/,G=$.split(/[ |,]+/).concat("guard");if(z.test(G[0]))Z=G.shift();if(q.test(G[0]))X=G.shift();if(!Z&&z.test(G[0]))Z=G.shift();if(!Z&&q.test(G[0]))Z=X,X=G.shift();if(G[0].startsWith("-")){let J=G[0],Q=`option creation failed due to '${J}' in option flags '${$}'`;if(/^-[^-][^-]/.test(J))throw Error(`${Q}
3
+ var oz=Object.create;var{getPrototypeOf:tz,defineProperty:X3,getOwnPropertyNames:ez}=Object;var $J=Object.prototype.hasOwnProperty;function ZJ($){return this[$]}var XJ,YJ,Y3=($,Z,X)=>{var Y=$!=null&&typeof $==="object";if(Y){var G=Z?XJ??=new WeakMap:YJ??=new WeakMap,z=G.get($);if(z)return z}X=$!=null?oz(tz($)):{};let J=Z||!$||!$.__esModule?X3(X,"default",{value:$,enumerable:!0}):X;for(let Q of ez($))if(!$J.call(J,Q))X3(J,Q,{get:ZJ.bind($,Q),enumerable:!0});if(Y)G.set($,J);return J};var R=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var r0=import.meta.require;var I2=R((GJ)=>{class WX extends Error{constructor($,Z,X){super(X);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Z,this.exitCode=$,this.nestedError=void 0}}class G3 extends WX{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}GJ.CommanderError=WX;GJ.InvalidArgumentError=G3});var rZ=R((VJ)=>{var{InvalidArgumentError:QJ}=I2();class z3{constructor($,Z){switch(this.description=Z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new QJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function WJ($){let Z=$.name()+($.variadic===!0?"...":"");return $.required?"<"+Z+">":"["+Z+"]"}VJ.Argument=z3;VJ.humanReadableArgName=WJ});var VX=R((UJ)=>{var{humanReadableArgName:BJ}=rZ();class J3{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let Z=$.commands.filter((Y)=>!Y._hidden),X=$._getHelpCommand();if(X&&!X._hidden)Z.push(X);if(this.sortSubcommands)Z.sort((Y,G)=>{return Y.name().localeCompare(G.name())});return Z}compareOptions($,Z){let X=(Y)=>{return Y.short?Y.short.replace(/^-/,""):Y.long.replace(/^--/,"")};return X($).localeCompare(X(Z))}visibleOptions($){let Z=$.options.filter((Y)=>!Y.hidden),X=$._getHelpOption();if(X&&!X.hidden){let Y=X.short&&$._findOption(X.short),G=X.long&&$._findOption(X.long);if(!Y&&!G)Z.push(X);else if(X.long&&!G)Z.push($.createOption(X.long,X.description));else if(X.short&&!Y)Z.push($.createOption(X.short,X.description))}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let Z=[];for(let X=$.parent;X;X=X.parent){let Y=X.options.filter((G)=>!G.hidden);Z.push(...Y)}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((Z)=>{Z.description=Z.description||$._argsDescription[Z.name()]||""});if($.registeredArguments.find((Z)=>Z.description))return $.registeredArguments;return[]}subcommandTerm($){let Z=$.registeredArguments.map((X)=>BJ(X)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(Z?" "+Z:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,Z){return Z.visibleCommands($).reduce((X,Y)=>{return Math.max(X,this.displayWidth(Z.styleSubcommandTerm(Z.subcommandTerm(Y))))},0)}longestOptionTermLength($,Z){return Z.visibleOptions($).reduce((X,Y)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(Y))))},0)}longestGlobalOptionTermLength($,Z){return Z.visibleGlobalOptions($).reduce((X,Y)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(Y))))},0)}longestArgumentTermLength($,Z){return Z.visibleArguments($).reduce((X,Y)=>{return Math.max(X,this.displayWidth(Z.styleArgumentTerm(Z.argumentTerm(Y))))},0)}commandUsage($){let Z=$._name;if($._aliases[0])Z=Z+"|"+$._aliases[0];let X="";for(let Y=$.parent;Y;Y=Y.parent)X=Y.name()+" "+X;return X+Z+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)Z.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)Z.push(`env: ${$.envVar}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}argumentDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0)Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}formatItemList($,Z,X){if(Z.length===0)return[];return[X.styleTitle($),...Z,""]}groupItems($,Z,X){let Y=new Map;return $.forEach((G)=>{let z=X(G);if(!Y.has(z))Y.set(z,[])}),Z.forEach((G)=>{let z=X(G);if(!Y.has(z))Y.set(z,[]);Y.get(z).push(G)}),Y}formatHelp($,Z){let X=Z.padWidth($,Z),Y=Z.helpWidth??80;function G(K,H){return Z.formatItem(K,X,H,Z)}let z=[`${Z.styleTitle("Usage:")} ${Z.styleUsage(Z.commandUsage($))}`,""],J=Z.commandDescription($);if(J.length>0)z=z.concat([Z.boxWrap(Z.styleCommandDescription(J),Y),""]);let Q=Z.visibleArguments($).map((K)=>{return G(Z.styleArgumentTerm(Z.argumentTerm(K)),Z.styleArgumentDescription(Z.argumentDescription(K)))});if(z=z.concat(this.formatItemList("Arguments:",Q,Z)),this.groupItems($.options,Z.visibleOptions($),(K)=>K.helpGroupHeading??"Options:").forEach((K,H)=>{let B=K.map((U)=>{return G(Z.styleOptionTerm(Z.optionTerm(U)),Z.styleOptionDescription(Z.optionDescription(U)))});z=z.concat(this.formatItemList(H,B,Z))}),Z.showGlobalOptions){let K=Z.visibleGlobalOptions($).map((H)=>{return G(Z.styleOptionTerm(Z.optionTerm(H)),Z.styleOptionDescription(Z.optionDescription(H)))});z=z.concat(this.formatItemList("Global Options:",K,Z))}return this.groupItems($.commands,Z.visibleCommands($),(K)=>K.helpGroup()||"Commands:").forEach((K,H)=>{let B=K.map((U)=>{return G(Z.styleSubcommandTerm(Z.subcommandTerm(U)),Z.styleSubcommandDescription(Z.subcommandDescription(U)))});z=z.concat(this.formatItemList(H,B,Z))}),z.join(`
4
+ `)}displayWidth($){return Q3($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z==="[command]")return this.styleSubcommandText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleCommandText(Z)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleSubcommandText(Z)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,Z){return Math.max(Z.longestOptionTermLength($,Z),Z.longestGlobalOptionTermLength($,Z),Z.longestSubcommandTermLength($,Z),Z.longestArgumentTermLength($,Z))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,Z,X,Y){let z=" ".repeat(2);if(!X)return z+$;let J=$.padEnd(Z+$.length-Y.displayWidth($)),Q=2,V=(this.helpWidth??80)-Z-Q-2,K;if(V<this.minWidthToWrap||Y.preformatted(X))K=X;else K=Y.boxWrap(X,V).replace(/\n/g,`
5
+ `+" ".repeat(Z+Q));return z+J+" ".repeat(Q)+K.replace(/\n/g,`
6
+ ${z}`)}boxWrap($,Z){if(Z<this.minWidthToWrap)return $;let X=$.split(/\r\n|\n/),Y=/[\s]*[^\s]+/g,G=[];return X.forEach((z)=>{let J=z.match(Y);if(J===null){G.push("");return}let Q=[J.shift()],W=this.displayWidth(Q[0]);J.forEach((V)=>{let K=this.displayWidth(V);if(W+K<=Z){Q.push(V),W+=K;return}G.push(Q.join(""));let H=V.trimStart();Q=[H],W=this.displayWidth(H)}),G.push(Q.join(""))}),G.join(`
7
+ `)}}function Q3($){let Z=/\x1b\[\d*(;\d*)*m/g;return $.replace(Z,"")}UJ.Help=J3;UJ.stripColor=Q3});var HX=R((wJ)=>{var{InvalidArgumentError:FJ}=I2();class V3{constructor($,Z){this.flags=$,this.description=Z||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let X=LJ($);if(this.short=X.shortFlag,this.long=X.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let Z=$;if(typeof $==="string")Z={[$]:!0};return this.implied=Object.assign(this.implied||{},Z),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new FJ(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return W3(this.name().replace(/^no-/,""));return W3(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class H3{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((Z)=>{if(Z.negate)this.negativeOptions.set(Z.attributeName(),Z);else this.positiveOptions.set(Z.attributeName(),Z)}),this.negativeOptions.forEach((Z,X)=>{if(this.positiveOptions.has(X))this.dualOptions.add(X)})}valueFromOption($,Z){let X=Z.attributeName();if(!this.dualOptions.has(X))return!0;let Y=this.negativeOptions.get(X).presetArg,G=Y!==void 0?Y:!1;return Z.negate===(G===$)}}function W3($){return $.split("-").reduce((Z,X)=>{return Z+X[0].toUpperCase()+X.slice(1)})}function LJ($){let Z,X,Y=/^-[^-]$/,G=/^--[^-]/,z=$.split(/[ |,]+/).concat("guard");if(Y.test(z[0]))Z=z.shift();if(G.test(z[0]))X=z.shift();if(!Z&&Y.test(z[0]))Z=z.shift();if(!Z&&G.test(z[0]))Z=X,X=z.shift();if(z[0].startsWith("-")){let J=z[0],Q=`option creation failed due to '${J}' in option flags '${$}'`;if(/^-[^-][^-]/.test(J))throw Error(`${Q}
8
8
  - a short flag is a single dash and a single character
9
9
  - either use a single dash and a single character (for a short flag)
10
- - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(z.test(J))throw Error(`${Q}
11
- - too many short flags`);if(q.test(J))throw Error(`${Q}
10
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(Y.test(J))throw Error(`${Q}
11
+ - too many short flags`);if(G.test(J))throw Error(`${Q}
12
12
  - too many long flags`);throw Error(`${Q}
13
- - unrecognised flag format`)}if(Z===void 0&&X===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:Z,longFlag:X}}EX.Option=S5;EX.DualOptions=C5});var E5=F((fX)=>{function xX($,Z){if(Math.abs($.length-Z.length)>3)return Math.max($.length,Z.length);let X=[];for(let z=0;z<=$.length;z++)X[z]=[z];for(let z=0;z<=Z.length;z++)X[0][z]=z;for(let z=1;z<=Z.length;z++)for(let q=1;q<=$.length;q++){let G=1;if($[q-1]===Z[z-1])G=0;else G=1;if(X[q][z]=Math.min(X[q-1][z]+1,X[q][z-1]+1,X[q-1][z-1]+G),q>1&&z>1&&$[q-1]===Z[z-2]&&$[q-2]===Z[z-1])X[q][z]=Math.min(X[q][z],X[q-2][z-2]+1)}return X[$.length][Z.length]}function kX($,Z){if(!Z||Z.length===0)return"";Z=Array.from(new Set(Z));let X=$.startsWith("--");if(X)$=$.slice(2),Z=Z.map((J)=>J.slice(2));let z=[],q=3,G=0.4;if(Z.forEach((J)=>{if(J.length<=1)return;let Q=xX($,J),Y=Math.max($.length,J.length);if((Y-Q)/Y>G){if(Q<q)q=Q,z=[J];else if(Q===q)z.push(J)}}),z.sort((J,Q)=>J.localeCompare(Q)),X)z=z.map((J)=>`--${J}`);if(z.length>1)return`
14
- (Did you mean one of ${z.join(", ")}?)`;if(z.length===1)return`
15
- (Did you mean ${z[0]}?)`;return""}fX.suggestSimilar=kX});var k5=F((lX)=>{var gX=L0("events").EventEmitter,T4=L0("child_process"),T0=L0("path"),E1=L0("fs"),b=L0("process"),{Argument:vX,humanReadableArgName:uX}=C1(),{CommanderError:D4}=f$(),{Help:mX,stripColor:dX}=B4(),{Option:b5,DualOptions:pX}=L4(),{suggestSimilar:y5}=E5();class F4 extends gX{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(Z)=>b.stdout.write(Z),writeErr:(Z)=>b.stderr.write(Z),outputError:(Z,X)=>X(Z),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,getOutHasColors:()=>_4()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>_4()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:(Z)=>dX(Z)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let Z=this;Z;Z=Z.parent)$.push(Z);return $}command($,Z,X){let z=Z,q=X;if(typeof z==="object"&&z!==null)q=z,z=null;q=q||{};let[,G,J]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(G);if(z)Q.description(z),Q._executableHandler=!0;if(q.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(q.noHelp||q.hidden),Q._executableFile=q.executableFile||null,J)Q.arguments(J);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),z)return this;return Q}createCommand($){return new F4($)}createHelp(){return Object.assign(new mX,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,Z){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
16
- - specify the name in Command constructor or using .name()`);if(Z=Z||{},Z.isDefault)this._defaultCommandName=$._name;if(Z.noHelp||Z.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,Z){return new vX($,Z)}argument($,Z,X,z){let q=this.createArgument($,Z);if(typeof X==="function")q.default(z).argParser(X);else q.default(X);return this.addArgument(q),this}arguments($){return $.trim().split(/ +/).forEach((Z)=>{this.argument(Z)}),this}addArgument($){let Z=this.registeredArguments.slice(-1)[0];if(Z?.variadic)throw Error(`only the last argument can be variadic '${Z.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,Z){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let X=$??"help [command]",[,z,q]=X.match(/([^ ]+) *(.*)/),G=Z??"display help for command",J=this.createCommand(z);if(J.helpOption(!1),q)J.arguments(q);if(G)J.description(G);if(this._addImplicitHelpCommand=!0,this._helpCommand=J,$||Z)this._initCommandGroup(J);return this}addHelpCommand($,Z){if(typeof $!=="object")return this.helpCommand($,Z),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,Z){let X=["preSubcommand","preAction","postAction"];if(!X.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
17
- Expecting one of '${X.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(Z);else this._lifeCycleHooks[$]=[Z];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(Z)=>{if(Z.code!=="commander.executeSubCommandAsync")throw Z};return this}_exit($,Z,X){if(this._exitCallback)this._exitCallback(new D4($,Z,X));b.exit($)}action($){let Z=(X)=>{let z=this.registeredArguments.length,q=X.slice(0,z);if(this._storeOptionsAsProperties)q[z]=this;else q[z]=this.opts();return q.push(this),$.apply(this,q)};return this._actionHandler=Z,this}createOption($,Z){return new b5($,Z)}_callParseArg($,Z,X,z){try{return $.parseArg(Z,X)}catch(q){if(q.code==="commander.invalidArgument"){let G=`${z} ${q.message}`;this.error(G,{exitCode:q.exitCode,code:q.code})}throw q}}_registerOption($){let Z=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(Z){let X=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${X}'
18
- - already used by option '${Z.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let Z=(z)=>{return[z.name()].concat(z.aliases())},X=Z($).find((z)=>this._findCommand(z));if(X){let z=Z(this._findCommand(X)).join("|"),q=Z($).join("|");throw Error(`cannot add command '${q}' as already have command '${z}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let Z=$.name(),X=$.attributeName();if($.negate){let q=$.long.replace(/^--no-/,"--");if(!this._findOption(q))this.setOptionValueWithSource(X,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(X,$.defaultValue,"default");let z=(q,G,J)=>{if(q==null&&$.presetArg!==void 0)q=$.presetArg;let Q=this.getOptionValue(X);if(q!==null&&$.parseArg)q=this._callParseArg($,q,Q,G);else if(q!==null&&$.variadic)q=$._collectValue(q,Q);if(q==null)if($.negate)q=!1;else if($.isBoolean()||$.optional)q=!0;else q="";this.setOptionValueWithSource(X,q,J)};if(this.on("option:"+Z,(q)=>{let G=`error: option '${$.flags}' argument '${q}' is invalid.`;z(q,G,"cli")}),$.envVar)this.on("optionEnv:"+Z,(q)=>{let G=`error: option '${$.flags}' value '${q}' from env '${$.envVar}' is invalid.`;z(q,G,"env")});return this}_optionEx($,Z,X,z,q){if(typeof Z==="object"&&Z instanceof b5)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let G=this.createOption(Z,X);if(G.makeOptionMandatory(!!$.mandatory),typeof z==="function")G.default(q).argParser(z);else if(z instanceof RegExp){let J=z;z=(Q,Y)=>{let H=J.exec(Q);return H?H[0]:Y},G.default(q).argParser(z)}else G.default(z);return this.addOption(G)}option($,Z,X,z){return this._optionEx({},$,Z,X,z)}requiredOption($,Z,X,z){return this._optionEx({mandatory:!0},$,Z,X,z)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,Z){return this.setOptionValueWithSource($,Z,void 0)}setOptionValueWithSource($,Z,X){if(this._storeOptionsAsProperties)this[$]=Z;else this._optionValues[$]=Z;return this._optionValueSources[$]=X,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let Z;return this._getCommandAndAncestors().forEach((X)=>{if(X.getOptionValueSource($)!==void 0)Z=X.getOptionValueSource($)}),Z}_prepareUserArgs($,Z){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(Z=Z||{},$===void 0&&Z.from===void 0){if(b.versions?.electron)Z.from="electron";let z=b.execArgv??[];if(z.includes("-e")||z.includes("--eval")||z.includes("-p")||z.includes("--print"))Z.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let X;switch(Z.from){case void 0:case"node":this._scriptPath=$[1],X=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],X=$.slice(2);else X=$.slice(1);break;case"user":X=$.slice(0);break;case"eval":X=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${Z.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",X}parse($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return this._parseCommand([],X),this}async parseAsync($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return await this._parseCommand([],X),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
19
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,Z,X){if(E1.existsSync($))return;let z=Z?`searched for local subcommand relative to directory '${Z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",q=`'${$}' does not exist
13
+ - unrecognised flag format`)}if(Z===void 0&&X===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:Z,longFlag:X}}wJ.Option=V3;wJ.DualOptions=H3});var K3=R((PJ)=>{function OJ($,Z){if(Math.abs($.length-Z.length)>3)return Math.max($.length,Z.length);let X=[];for(let Y=0;Y<=$.length;Y++)X[Y]=[Y];for(let Y=0;Y<=Z.length;Y++)X[0][Y]=Y;for(let Y=1;Y<=Z.length;Y++)for(let G=1;G<=$.length;G++){let z=1;if($[G-1]===Z[Y-1])z=0;else z=1;if(X[G][Y]=Math.min(X[G-1][Y]+1,X[G][Y-1]+1,X[G-1][Y-1]+z),G>1&&Y>1&&$[G-1]===Z[Y-2]&&$[G-2]===Z[Y-1])X[G][Y]=Math.min(X[G][Y],X[G-2][Y-2]+1)}return X[$.length][Z.length]}function _J($,Z){if(!Z||Z.length===0)return"";Z=Array.from(new Set(Z));let X=$.startsWith("--");if(X)$=$.slice(2),Z=Z.map((J)=>J.slice(2));let Y=[],G=3,z=0.4;if(Z.forEach((J)=>{if(J.length<=1)return;let Q=OJ($,J),W=Math.max($.length,J.length);if((W-Q)/W>z){if(Q<G)G=Q,Y=[J];else if(Q===G)Y.push(J)}}),Y.sort((J,Q)=>J.localeCompare(Q)),X)Y=Y.map((J)=>`--${J}`);if(Y.length>1)return`
14
+ (Did you mean one of ${Y.join(", ")}?)`;if(Y.length===1)return`
15
+ (Did you mean ${Y[0]}?)`;return""}PJ.suggestSimilar=_J});var T3=R((jJ)=>{var EJ=r0("events").EventEmitter,KX=r0("child_process"),s0=r0("path"),sZ=r0("fs"),c=r0("process"),{Argument:RJ,humanReadableArgName:AJ}=rZ(),{CommanderError:BX}=I2(),{Help:SJ,stripColor:CJ}=VX(),{Option:B3,DualOptions:IJ}=HX(),{suggestSimilar:U3}=K3();class qX extends EJ{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(Z)=>c.stdout.write(Z),writeErr:(Z)=>c.stderr.write(Z),outputError:(Z,X)=>X(Z),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:void 0,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:void 0,getOutHasColors:()=>UX()??(c.stdout.isTTY&&c.stdout.hasColors?.()),getErrHasColors:()=>UX()??(c.stderr.isTTY&&c.stderr.hasColors?.()),stripColor:(Z)=>CJ(Z)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let Z=this;Z;Z=Z.parent)$.push(Z);return $}command($,Z,X){let Y=Z,G=X;if(typeof Y==="object"&&Y!==null)G=Y,Y=null;G=G||{};let[,z,J]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(z);if(Y)Q.description(Y),Q._executableHandler=!0;if(G.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(G.noHelp||G.hidden),Q._executableFile=G.executableFile||null,J)Q.arguments(J);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),Y)return this;return Q}createCommand($){return new qX($)}createHelp(){return Object.assign(new SJ,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,Z){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
16
+ - specify the name in Command constructor or using .name()`);if(Z=Z||{},Z.isDefault)this._defaultCommandName=$._name;if(Z.noHelp||Z.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,Z){return new RJ($,Z)}argument($,Z,X,Y){let G=this.createArgument($,Z);if(typeof X==="function")G.default(Y).argParser(X);else G.default(X);return this.addArgument(G),this}arguments($){return $.trim().split(/ +/).forEach((Z)=>{this.argument(Z)}),this}addArgument($){let Z=this.registeredArguments.slice(-1)[0];if(Z?.variadic)throw Error(`only the last argument can be variadic '${Z.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,Z){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let X=$??"help [command]",[,Y,G]=X.match(/([^ ]+) *(.*)/),z=Z??"display help for command",J=this.createCommand(Y);if(J.helpOption(!1),G)J.arguments(G);if(z)J.description(z);if(this._addImplicitHelpCommand=!0,this._helpCommand=J,$||Z)this._initCommandGroup(J);return this}addHelpCommand($,Z){if(typeof $!=="object")return this.helpCommand($,Z),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,Z){let X=["preSubcommand","preAction","postAction"];if(!X.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
17
+ Expecting one of '${X.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(Z);else this._lifeCycleHooks[$]=[Z];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(Z)=>{if(Z.code!=="commander.executeSubCommandAsync")throw Z};return this}_exit($,Z,X){if(this._exitCallback)this._exitCallback(new BX($,Z,X));c.exit($)}action($){let Z=(X)=>{let Y=this.registeredArguments.length,G=X.slice(0,Y);if(this._storeOptionsAsProperties)G[Y]=this;else G[Y]=this.opts();return G.push(this),$.apply(this,G)};return this._actionHandler=Z,this}createOption($,Z){return new B3($,Z)}_callParseArg($,Z,X,Y){try{return $.parseArg(Z,X)}catch(G){if(G.code==="commander.invalidArgument"){let z=`${Y} ${G.message}`;this.error(z,{exitCode:G.exitCode,code:G.code})}throw G}}_registerOption($){let Z=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(Z){let X=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${X}'
18
+ - already used by option '${Z.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let Z=(Y)=>{return[Y.name()].concat(Y.aliases())},X=Z($).find((Y)=>this._findCommand(Y));if(X){let Y=Z(this._findCommand(X)).join("|"),G=Z($).join("|");throw Error(`cannot add command '${G}' as already have command '${Y}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let Z=$.name(),X=$.attributeName();if($.negate){let G=$.long.replace(/^--no-/,"--");if(!this._findOption(G))this.setOptionValueWithSource(X,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(X,$.defaultValue,"default");let Y=(G,z,J)=>{if(G==null&&$.presetArg!==void 0)G=$.presetArg;let Q=this.getOptionValue(X);if(G!==null&&$.parseArg)G=this._callParseArg($,G,Q,z);else if(G!==null&&$.variadic)G=$._collectValue(G,Q);if(G==null)if($.negate)G=!1;else if($.isBoolean()||$.optional)G=!0;else G="";this.setOptionValueWithSource(X,G,J)};if(this.on("option:"+Z,(G)=>{let z=`error: option '${$.flags}' argument '${G}' is invalid.`;Y(G,z,"cli")}),$.envVar)this.on("optionEnv:"+Z,(G)=>{let z=`error: option '${$.flags}' value '${G}' from env '${$.envVar}' is invalid.`;Y(G,z,"env")});return this}_optionEx($,Z,X,Y,G){if(typeof Z==="object"&&Z instanceof B3)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let z=this.createOption(Z,X);if(z.makeOptionMandatory(!!$.mandatory),typeof Y==="function")z.default(G).argParser(Y);else if(Y instanceof RegExp){let J=Y;Y=(Q,W)=>{let V=J.exec(Q);return V?V[0]:W},z.default(G).argParser(Y)}else z.default(Y);return this.addOption(z)}option($,Z,X,Y){return this._optionEx({},$,Z,X,Y)}requiredOption($,Z,X,Y){return this._optionEx({mandatory:!0},$,Z,X,Y)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,Z){return this.setOptionValueWithSource($,Z,void 0)}setOptionValueWithSource($,Z,X){if(this._storeOptionsAsProperties)this[$]=Z;else this._optionValues[$]=Z;return this._optionValueSources[$]=X,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let Z;return this._getCommandAndAncestors().forEach((X)=>{if(X.getOptionValueSource($)!==void 0)Z=X.getOptionValueSource($)}),Z}_prepareUserArgs($,Z){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(Z=Z||{},$===void 0&&Z.from===void 0){if(c.versions?.electron)Z.from="electron";let Y=c.execArgv??[];if(Y.includes("-e")||Y.includes("--eval")||Y.includes("-p")||Y.includes("--print"))Z.from="eval"}if($===void 0)$=c.argv;this.rawArgs=$.slice();let X;switch(Z.from){case void 0:case"node":this._scriptPath=$[1],X=$.slice(2);break;case"electron":if(c.defaultApp)this._scriptPath=$[1],X=$.slice(2);else X=$.slice(1);break;case"user":X=$.slice(0);break;case"eval":X=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${Z.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",X}parse($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return this._parseCommand([],X),this}async parseAsync($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return await this._parseCommand([],X),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
19
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,Z,X){if(sZ.existsSync($))return;let Y=Z?`searched for local subcommand relative to directory '${Z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",G=`'${$}' does not exist
20
20
  - if '${X}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
21
21
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
22
- - ${z}`;throw Error(q)}_executeSubCommand($,Z){Z=Z.slice();let X=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function q(H,W){let U=T0.resolve(H,W);if(E1.existsSync(U))return U;if(z.includes(T0.extname(W)))return;let V=z.find((B)=>E1.existsSync(`${U}${B}`));if(V)return`${U}${V}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=$._executableFile||`${this._name}-${$._name}`,J=this._executableDir||"";if(this._scriptPath){let H;try{H=E1.realpathSync(this._scriptPath)}catch{H=this._scriptPath}J=T0.resolve(T0.dirname(H),J)}if(J){let H=q(J,G);if(!H&&!$._executableFile&&this._scriptPath){let W=T0.basename(this._scriptPath,T0.extname(this._scriptPath));if(W!==this._name)H=q(J,`${W}-${$._name}`)}G=H||G}X=z.includes(T0.extname(G));let Q;if(b.platform!=="win32")if(X)Z.unshift(G),Z=x5(b.execArgv).concat(Z),Q=T4.spawn(b.argv[0],Z,{stdio:"inherit"});else Q=T4.spawn(G,Z,{stdio:"inherit"});else this._checkForMissingExecutable(G,J,$._name),Z.unshift(G),Z=x5(b.execArgv).concat(Z),Q=T4.spawn(b.execPath,Z,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((W)=>{b.on(W,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(W)})});let Y=this._exitCallback;Q.on("close",(H)=>{if(H=H??1,!Y)b.exit(H);else Y(new D4(H,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(H)=>{if(H.code==="ENOENT")this._checkForMissingExecutable(G,J,$._name);else if(H.code==="EACCES")throw Error(`'${G}' not executable`);if(!Y)b.exit(1);else{let W=new D4(1,"commander.executeSubCommandAsync","(error)");W.nestedError=H,Y(W)}}),this.runningCommand=Q}_dispatchSubcommand($,Z,X){let z=this._findCommand($);if(!z)this.help({error:!0});z._prepareForParse();let q;return q=this._chainOrCallSubCommandHook(q,z,"preSubcommand"),q=this._chainOrCall(q,()=>{if(z._executableHandler)this._executeSubCommand(z,Z.concat(X));else return z._parseCommand(Z,X)}),q}_dispatchHelpCommand($){if(!$)this.help();let Z=this._findCommand($);if(Z&&!Z._executableHandler)Z.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,Z)=>{if($.required&&this.args[Z]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(X,z,q)=>{let G=z;if(z!==null&&X.parseArg){let J=`error: command-argument value '${z}' is invalid for argument '${X.name()}'.`;G=this._callParseArg(X,z,q,J)}return G};this._checkNumberOfArguments();let Z=[];this.registeredArguments.forEach((X,z)=>{let q=X.defaultValue;if(X.variadic){if(z<this.args.length){if(q=this.args.slice(z),X.parseArg)q=q.reduce((G,J)=>{return $(X,J,G)},X.defaultValue)}else if(q===void 0)q=[]}else if(z<this.args.length){if(q=this.args[z],X.parseArg)q=$(X,q,X.defaultValue)}Z[z]=q}),this.processedArgs=Z}_chainOrCall($,Z){if($?.then&&typeof $.then==="function")return $.then(()=>Z());return Z()}_chainOrCallHooks($,Z){let X=$,z=[];if(this._getCommandAndAncestors().reverse().filter((q)=>q._lifeCycleHooks[Z]!==void 0).forEach((q)=>{q._lifeCycleHooks[Z].forEach((G)=>{z.push({hookedCommand:q,callback:G})})}),Z==="postAction")z.reverse();return z.forEach((q)=>{X=this._chainOrCall(X,()=>{return q.callback(q.hookedCommand,this)})}),X}_chainOrCallSubCommandHook($,Z,X){let z=$;if(this._lifeCycleHooks[X]!==void 0)this._lifeCycleHooks[X].forEach((q)=>{z=this._chainOrCall(z,()=>{return q(this,Z)})});return z}_parseCommand($,Z){let X=this.parseOptions(Z);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(X.operands),Z=X.unknown,this.args=$.concat(Z),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),Z);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(Z),this._dispatchSubcommand(this._defaultCommandName,$,Z);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(X.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=()=>{if(X.unknown.length>0)this.unknownOption(X.unknown[0])},q=`command:${this.name()}`;if(this._actionHandler){z(),this._processArguments();let G;if(G=this._chainOrCallHooks(G,"preAction"),G=this._chainOrCall(G,()=>this._actionHandler(this.processedArgs)),this.parent)G=this._chainOrCall(G,()=>{this.parent.emit(q,$,Z)});return G=this._chainOrCallHooks(G,"postAction"),G}if(this.parent?.listenerCount(q))z(),this._processArguments(),this.parent.emit(q,$,Z);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,Z);if(this.listenerCount("command:*"))this.emit("command:*",$,Z);else if(this.commands.length)this.unknownCommand();else z(),this._processArguments()}else if(this.commands.length)z(),this.help({error:!0});else z(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((Z)=>Z._name===$||Z._aliases.includes($))}_findOption($){return this.options.find((Z)=>Z.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((Z)=>{if(Z.mandatory&&$.getOptionValue(Z.attributeName())===void 0)$.missingMandatoryOptionValue(Z)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((X)=>{let z=X.attributeName();if(this.getOptionValue(z)===void 0)return!1;return this.getOptionValueSource(z)!=="default"});$.filter((X)=>X.conflictsWith.length>0).forEach((X)=>{let z=$.find((q)=>X.conflictsWith.includes(q.attributeName()));if(z)this._conflictingOption(X,z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let Z=[],X=[],z=Z;function q(H){return H.length>1&&H[0]==="-"}let G=(H)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(H))return!1;return!this._getCommandAndAncestors().some((W)=>W.options.map((U)=>U.short).some((U)=>/^-\d$/.test(U)))},J=null,Q=null,Y=0;while(Y<$.length||Q){let H=Q??$[Y++];if(Q=null,H==="--"){if(z===X)z.push(H);z.push(...$.slice(Y));break}if(J&&(!q(H)||G(H))){this.emit(`option:${J.name()}`,H);continue}if(J=null,q(H)){let W=this._findOption(H);if(W){if(W.required){let U=$[Y++];if(U===void 0)this.optionMissingArgument(W);this.emit(`option:${W.name()}`,U)}else if(W.optional){let U=null;if(Y<$.length&&(!q($[Y])||G($[Y])))U=$[Y++];this.emit(`option:${W.name()}`,U)}else this.emit(`option:${W.name()}`);J=W.variadic?W:null;continue}}if(H.length>2&&H[0]==="-"&&H[1]!=="-"){let W=this._findOption(`-${H[1]}`);if(W){if(W.required||W.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${W.name()}`,H.slice(2));else this.emit(`option:${W.name()}`),Q=`-${H.slice(2)}`;continue}}if(/^--[^=]+=/.test(H)){let W=H.indexOf("="),U=this._findOption(H.slice(0,W));if(U&&(U.required||U.optional)){this.emit(`option:${U.name()}`,H.slice(W+1));continue}}if(z===Z&&q(H)&&!(this.commands.length===0&&G(H)))z=X;if((this._enablePositionalOptions||this._passThroughOptions)&&Z.length===0&&X.length===0){if(this._findCommand(H)){Z.push(H),X.push(...$.slice(Y));break}else if(this._getHelpCommand()&&H===this._getHelpCommand().name()){Z.push(H,...$.slice(Y));break}else if(this._defaultCommandName){X.push(H,...$.slice(Y));break}}if(this._passThroughOptions){z.push(H,...$.slice(Y));break}z.push(H)}return{operands:Z,unknown:X}}opts(){if(this._storeOptionsAsProperties){let $={},Z=this.options.length;for(let X=0;X<Z;X++){let z=this.options[X].attributeName();$[z]=z===this._versionOptionName?this._version:this[z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,Z)=>Object.assign($,Z.opts()),{})}error($,Z){if(this._outputConfiguration.outputError(`${$}
22
+ - ${Y}`;throw Error(G)}_executeSubCommand($,Z){Z=Z.slice();let X=!1,Y=[".js",".ts",".tsx",".mjs",".cjs"];function G(V,K){let H=s0.resolve(V,K);if(sZ.existsSync(H))return H;if(Y.includes(s0.extname(K)))return;let B=Y.find((U)=>sZ.existsSync(`${H}${U}`));if(B)return`${H}${B}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=$._executableFile||`${this._name}-${$._name}`,J=this._executableDir||"";if(this._scriptPath){let V;try{V=sZ.realpathSync(this._scriptPath)}catch{V=this._scriptPath}J=s0.resolve(s0.dirname(V),J)}if(J){let V=G(J,z);if(!V&&!$._executableFile&&this._scriptPath){let K=s0.basename(this._scriptPath,s0.extname(this._scriptPath));if(K!==this._name)V=G(J,`${K}-${$._name}`)}z=V||z}X=Y.includes(s0.extname(z));let Q;if(c.platform!=="win32")if(X)Z.unshift(z),Z=q3(c.execArgv).concat(Z),Q=KX.spawn(c.argv[0],Z,{stdio:"inherit"});else Q=KX.spawn(z,Z,{stdio:"inherit"});else this._checkForMissingExecutable(z,J,$._name),Z.unshift(z),Z=q3(c.execArgv).concat(Z),Q=KX.spawn(c.execPath,Z,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((K)=>{c.on(K,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(K)})});let W=this._exitCallback;Q.on("close",(V)=>{if(V=V??1,!W)c.exit(V);else W(new BX(V,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(V)=>{if(V.code==="ENOENT")this._checkForMissingExecutable(z,J,$._name);else if(V.code==="EACCES")throw Error(`'${z}' not executable`);if(!W)c.exit(1);else{let K=new BX(1,"commander.executeSubCommandAsync","(error)");K.nestedError=V,W(K)}}),this.runningCommand=Q}_dispatchSubcommand($,Z,X){let Y=this._findCommand($);if(!Y)this.help({error:!0});Y._prepareForParse();let G;return G=this._chainOrCallSubCommandHook(G,Y,"preSubcommand"),G=this._chainOrCall(G,()=>{if(Y._executableHandler)this._executeSubCommand(Y,Z.concat(X));else return Y._parseCommand(Z,X)}),G}_dispatchHelpCommand($){if(!$)this.help();let Z=this._findCommand($);if(Z&&!Z._executableHandler)Z.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,Z)=>{if($.required&&this.args[Z]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(X,Y,G)=>{let z=Y;if(Y!==null&&X.parseArg){let J=`error: command-argument value '${Y}' is invalid for argument '${X.name()}'.`;z=this._callParseArg(X,Y,G,J)}return z};this._checkNumberOfArguments();let Z=[];this.registeredArguments.forEach((X,Y)=>{let G=X.defaultValue;if(X.variadic){if(Y<this.args.length){if(G=this.args.slice(Y),X.parseArg)G=G.reduce((z,J)=>{return $(X,J,z)},X.defaultValue)}else if(G===void 0)G=[]}else if(Y<this.args.length){if(G=this.args[Y],X.parseArg)G=$(X,G,X.defaultValue)}Z[Y]=G}),this.processedArgs=Z}_chainOrCall($,Z){if($?.then&&typeof $.then==="function")return $.then(()=>Z());return Z()}_chainOrCallHooks($,Z){let X=$,Y=[];if(this._getCommandAndAncestors().reverse().filter((G)=>G._lifeCycleHooks[Z]!==void 0).forEach((G)=>{G._lifeCycleHooks[Z].forEach((z)=>{Y.push({hookedCommand:G,callback:z})})}),Z==="postAction")Y.reverse();return Y.forEach((G)=>{X=this._chainOrCall(X,()=>{return G.callback(G.hookedCommand,this)})}),X}_chainOrCallSubCommandHook($,Z,X){let Y=$;if(this._lifeCycleHooks[X]!==void 0)this._lifeCycleHooks[X].forEach((G)=>{Y=this._chainOrCall(Y,()=>{return G(this,Z)})});return Y}_parseCommand($,Z){let X=this.parseOptions(Z);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(X.operands),Z=X.unknown,this.args=$.concat(Z),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),Z);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(Z),this._dispatchSubcommand(this._defaultCommandName,$,Z);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(X.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Y=()=>{if(X.unknown.length>0)this.unknownOption(X.unknown[0])},G=`command:${this.name()}`;if(this._actionHandler){Y(),this._processArguments();let z;if(z=this._chainOrCallHooks(z,"preAction"),z=this._chainOrCall(z,()=>this._actionHandler(this.processedArgs)),this.parent)z=this._chainOrCall(z,()=>{this.parent.emit(G,$,Z)});return z=this._chainOrCallHooks(z,"postAction"),z}if(this.parent?.listenerCount(G))Y(),this._processArguments(),this.parent.emit(G,$,Z);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,Z);if(this.listenerCount("command:*"))this.emit("command:*",$,Z);else if(this.commands.length)this.unknownCommand();else Y(),this._processArguments()}else if(this.commands.length)Y(),this.help({error:!0});else Y(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((Z)=>Z._name===$||Z._aliases.includes($))}_findOption($){return this.options.find((Z)=>Z.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((Z)=>{if(Z.mandatory&&$.getOptionValue(Z.attributeName())===void 0)$.missingMandatoryOptionValue(Z)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((X)=>{let Y=X.attributeName();if(this.getOptionValue(Y)===void 0)return!1;return this.getOptionValueSource(Y)!=="default"});$.filter((X)=>X.conflictsWith.length>0).forEach((X)=>{let Y=$.find((G)=>X.conflictsWith.includes(G.attributeName()));if(Y)this._conflictingOption(X,Y)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let Z=[],X=[],Y=Z;function G(V){return V.length>1&&V[0]==="-"}let z=(V)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(V))return!1;return!this._getCommandAndAncestors().some((K)=>K.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},J=null,Q=null,W=0;while(W<$.length||Q){let V=Q??$[W++];if(Q=null,V==="--"){if(Y===X)Y.push(V);Y.push(...$.slice(W));break}if(J&&(!G(V)||z(V))){this.emit(`option:${J.name()}`,V);continue}if(J=null,G(V)){let K=this._findOption(V);if(K){if(K.required){let H=$[W++];if(H===void 0)this.optionMissingArgument(K);this.emit(`option:${K.name()}`,H)}else if(K.optional){let H=null;if(W<$.length&&(!G($[W])||z($[W])))H=$[W++];this.emit(`option:${K.name()}`,H)}else this.emit(`option:${K.name()}`);J=K.variadic?K:null;continue}}if(V.length>2&&V[0]==="-"&&V[1]!=="-"){let K=this._findOption(`-${V[1]}`);if(K){if(K.required||K.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${K.name()}`,V.slice(2));else this.emit(`option:${K.name()}`),Q=`-${V.slice(2)}`;continue}}if(/^--[^=]+=/.test(V)){let K=V.indexOf("="),H=this._findOption(V.slice(0,K));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,V.slice(K+1));continue}}if(Y===Z&&G(V)&&!(this.commands.length===0&&z(V)))Y=X;if((this._enablePositionalOptions||this._passThroughOptions)&&Z.length===0&&X.length===0){if(this._findCommand(V)){Z.push(V),X.push(...$.slice(W));break}else if(this._getHelpCommand()&&V===this._getHelpCommand().name()){Z.push(V,...$.slice(W));break}else if(this._defaultCommandName){X.push(V,...$.slice(W));break}}if(this._passThroughOptions){Y.push(V,...$.slice(W));break}Y.push(V)}return{operands:Z,unknown:X}}opts(){if(this._storeOptionsAsProperties){let $={},Z=this.options.length;for(let X=0;X<Z;X++){let Y=this.options[X].attributeName();$[Y]=Y===this._versionOptionName?this._version:this[Y]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,Z)=>Object.assign($,Z.opts()),{})}error($,Z){if(this._outputConfiguration.outputError(`${$}
23
23
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
24
24
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
25
- `),this.outputHelp({error:!0});let X=Z||{},z=X.exitCode||1,q=X.code||"commander.error";this._exit(z,q,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let Z=$.attributeName();if(this.getOptionValue(Z)===void 0||["default","config","env"].includes(this.getOptionValueSource(Z)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new pX(this.options),Z=(X)=>{return this.getOptionValue(X)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(X))};this.options.filter((X)=>X.implied!==void 0&&Z(X.attributeName())&&$.valueFromOption(this.getOptionValue(X.attributeName()),X)).forEach((X)=>{Object.keys(X.implied).filter((z)=>!Z(z)).forEach((z)=>{this.setOptionValueWithSource(z,X.implied[z],"implied")})})}missingArgument($){let Z=`error: missing required argument '${$}'`;this.error(Z,{code:"commander.missingArgument"})}optionMissingArgument($){let Z=`error: option '${$.flags}' argument missing`;this.error(Z,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let Z=`error: required option '${$.flags}' not specified`;this.error(Z,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,Z){let X=(G)=>{let J=G.attributeName(),Q=this.getOptionValue(J),Y=this.options.find((W)=>W.negate&&J===W.attributeName()),H=this.options.find((W)=>!W.negate&&J===W.attributeName());if(Y&&(Y.presetArg===void 0&&Q===!1||Y.presetArg!==void 0&&Q===Y.presetArg))return Y;return H||G},z=(G)=>{let J=X(G),Q=J.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},q=`error: ${z($)} cannot be used with ${z(Z)}`;this.error(q,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let Z="";if($.startsWith("--")&&this._showSuggestionAfterError){let z=[],q=this;do{let G=q.createHelp().visibleOptions(q).filter((J)=>J.long).map((J)=>J.long);z=z.concat(G),q=q.parent}while(q&&!q._enablePositionalOptions);Z=y5($,z)}let X=`error: unknown option '${$}'${Z}`;this.error(X,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let Z=this.registeredArguments.length,X=Z===1?"":"s",q=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${Z} argument${X} but got ${$.length}.`;this.error(q,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],Z="";if(this._showSuggestionAfterError){let z=[];this.createHelp().visibleCommands(this).forEach((q)=>{if(z.push(q.name()),q.alias())z.push(q.alias())}),Z=y5($,z)}let X=`error: unknown command '${$}'${Z}`;this.error(X,{code:"commander.unknownCommand"})}version($,Z,X){if($===void 0)return this._version;this._version=$,Z=Z||"-V, --version",X=X||"output the version number";let z=this.createOption(Z,X);return this._versionOptionName=z.attributeName(),this._registerOption(z),this.on("option:"+z.name(),()=>{this._outputConfiguration.writeOut(`${$}
26
- `),this._exit(0,"commander.version",$)}),this}description($,Z){if($===void 0&&Z===void 0)return this._description;if(this._description=$,Z)this._argsDescription=Z;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let Z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)Z=this.commands[this.commands.length-1];if($===Z._name)throw Error("Command alias can't be the same as its name");let X=this.parent?._findCommand($);if(X){let z=[X.name()].concat(X.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${z}'`)}return Z._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((Z)=>this.alias(Z)),this}usage($){if($===void 0){if(this._usage)return this._usage;let Z=this.registeredArguments.map((X)=>{return uX(X)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?Z:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=T0.basename($,T0.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let Z=this.createHelp(),X=this._getOutputContext($);Z.prepareContext({error:X.error,helpWidth:X.helpWidth,outputHasColors:X.hasColors});let z=Z.formatHelp(this,Z);if(X.hasColors)return z;return this._outputConfiguration.stripColor(z)}_getOutputContext($){$=$||{};let Z=!!$.error,X,z,q;if(Z)X=(J)=>this._outputConfiguration.writeErr(J),z=this._outputConfiguration.getErrHasColors(),q=this._outputConfiguration.getErrHelpWidth();else X=(J)=>this._outputConfiguration.writeOut(J),z=this._outputConfiguration.getOutHasColors(),q=this._outputConfiguration.getOutHelpWidth();return{error:Z,write:(J)=>{if(!z)J=this._outputConfiguration.stripColor(J);return X(J)},hasColors:z,helpWidth:q}}outputHelp($){let Z;if(typeof $==="function")Z=$,$=void 0;let X=this._getOutputContext($),z={error:X.error,write:X.write,command:this};this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",z)),this.emit("beforeHelp",z);let q=this.helpInformation({error:X.error});if(Z){if(q=Z(q),typeof q!=="string"&&!Buffer.isBuffer(q))throw Error("outputHelp callback must return a string or a Buffer")}if(X.write(q),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",z),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",z))}helpOption($,Z){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",Z??"display help for command"),$||Z)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let Z=Number(b.exitCode??0);if(Z===0&&$&&typeof $!=="function"&&$.error)Z=1;this._exit(Z,"commander.help","(outputHelp)")}addHelpText($,Z){let X=["beforeAll","before","after","afterAll"];if(!X.includes($))throw Error(`Unexpected value for position to addHelpText.
27
- Expecting one of '${X.join("', '")}'`);let z=`${$}Help`;return this.on(z,(q)=>{let G;if(typeof Z==="function")G=Z({error:q.error,command:q.command});else G=Z;if(G)q.write(`${G}
28
- `)}),this}_outputHelpIfRequested($){let Z=this._getHelpOption();if(Z&&$.find((z)=>Z.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function x5($){return $.map((Z)=>{if(!Z.startsWith("--inspect"))return Z;let X,z="127.0.0.1",q="9229",G;if((G=Z.match(/^(--inspect(-brk)?)$/))!==null)X=G[1];else if((G=Z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(X=G[1],/^\d+$/.test(G[3]))q=G[3];else z=G[3];else if((G=Z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)X=G[1],z=G[3],q=G[4];if(X&&q!=="0")return`${X}=${z}:${parseInt(q)+1}`;return Z})}function _4(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0;return}lX.Command=F4;lX.useColor=_4});var v5=F((sX)=>{var{Argument:f5}=C1(),{Command:M4}=k5(),{CommanderError:aX,InvalidArgumentError:h5}=f$(),{Help:nX}=B4(),{Option:g5}=L4();sX.program=new M4;sX.createCommand=($)=>new M4($);sX.createOption=($,Z)=>new g5($,Z);sX.createArgument=($,Z)=>new f5($,Z);sX.Command=M4;sX.Option=g5;sX.Argument=f5;sX.Help=nX;sX.CommanderError=aX;sX.InvalidArgumentError=h5;sX.InvalidOptionArgumentError=h5});var E=F((Lz)=>{var I4=Symbol.for("yaml.alias"),d5=Symbol.for("yaml.document"),b1=Symbol.for("yaml.map"),p5=Symbol.for("yaml.pair"),R4=Symbol.for("yaml.scalar"),y1=Symbol.for("yaml.seq"),D0=Symbol.for("yaml.node.type"),Yz=($)=>!!$&&typeof $==="object"&&$[D0]===I4,Hz=($)=>!!$&&typeof $==="object"&&$[D0]===d5,Uz=($)=>!!$&&typeof $==="object"&&$[D0]===b1,Wz=($)=>!!$&&typeof $==="object"&&$[D0]===p5,l5=($)=>!!$&&typeof $==="object"&&$[D0]===R4,Vz=($)=>!!$&&typeof $==="object"&&$[D0]===y1;function c5($){if($&&typeof $==="object")switch($[D0]){case b1:case y1:return!0}return!1}function Kz($){if($&&typeof $==="object")switch($[D0]){case I4:case b1:case R4:case y1:return!0}return!1}var Bz=($)=>(l5($)||c5($))&&!!$.anchor;Lz.ALIAS=I4;Lz.DOC=d5;Lz.MAP=b1;Lz.NODE_TYPE=D0;Lz.PAIR=p5;Lz.SCALAR=R4;Lz.SEQ=y1;Lz.hasAnchor=Bz;Lz.isAlias=Yz;Lz.isCollection=c5;Lz.isDocument=Hz;Lz.isMap=Uz;Lz.isNode=Kz;Lz.isPair=Wz;Lz.isScalar=l5;Lz.isSeq=Vz});var h$=F((bz)=>{var v=E(),r=Symbol("break visit"),i5=Symbol("skip children"),W0=Symbol("remove node");function x1($,Z){let X=a5(Z);if(v.isDocument($)){if(z$(null,$.contents,X,Object.freeze([$]))===W0)$.contents=null}else z$(null,$,X,Object.freeze([]))}x1.BREAK=r;x1.SKIP=i5;x1.REMOVE=W0;function z$($,Z,X,z){let q=n5($,Z,X,z);if(v.isNode(q)||v.isPair(q))return s5($,z,q),z$($,q,X,z);if(typeof q!=="symbol"){if(v.isCollection(Z)){z=Object.freeze(z.concat(Z));for(let G=0;G<Z.items.length;++G){let J=z$(G,Z.items[G],X,z);if(typeof J==="number")G=J-1;else if(J===r)return r;else if(J===W0)Z.items.splice(G,1),G-=1}}else if(v.isPair(Z)){z=Object.freeze(z.concat(Z));let G=z$("key",Z.key,X,z);if(G===r)return r;else if(G===W0)Z.key=null;let J=z$("value",Z.value,X,z);if(J===r)return r;else if(J===W0)Z.value=null}}return q}async function k1($,Z){let X=a5(Z);if(v.isDocument($)){if(await q$(null,$.contents,X,Object.freeze([$]))===W0)$.contents=null}else await q$(null,$,X,Object.freeze([]))}k1.BREAK=r;k1.SKIP=i5;k1.REMOVE=W0;async function q$($,Z,X,z){let q=await n5($,Z,X,z);if(v.isNode(q)||v.isPair(q))return s5($,z,q),q$($,q,X,z);if(typeof q!=="symbol"){if(v.isCollection(Z)){z=Object.freeze(z.concat(Z));for(let G=0;G<Z.items.length;++G){let J=await q$(G,Z.items[G],X,z);if(typeof J==="number")G=J-1;else if(J===r)return r;else if(J===W0)Z.items.splice(G,1),G-=1}}else if(v.isPair(Z)){z=Object.freeze(z.concat(Z));let G=await q$("key",Z.key,X,z);if(G===r)return r;else if(G===W0)Z.key=null;let J=await q$("value",Z.value,X,z);if(J===r)return r;else if(J===W0)Z.value=null}}return q}function a5($){if(typeof $==="object"&&($.Collection||$.Node||$.Value))return Object.assign({Alias:$.Node,Map:$.Node,Scalar:$.Node,Seq:$.Node},$.Value&&{Map:$.Value,Scalar:$.Value,Seq:$.Value},$.Collection&&{Map:$.Collection,Seq:$.Collection},$);return $}function n5($,Z,X,z){if(typeof X==="function")return X($,Z,z);if(v.isMap(Z))return X.Map?.($,Z,z);if(v.isSeq(Z))return X.Seq?.($,Z,z);if(v.isPair(Z))return X.Pair?.($,Z,z);if(v.isScalar(Z))return X.Scalar?.($,Z,z);if(v.isAlias(Z))return X.Alias?.($,Z,z);return}function s5($,Z,X){let z=Z[Z.length-1];if(v.isCollection(z))z.items[$]=X;else if(v.isPair(z))if($==="key")z.key=X;else z.value=X;else if(v.isDocument(z))z.contents=X;else{let q=v.isAlias(z)?"alias":"scalar";throw Error(`Cannot replace node with ${q} parent`)}}bz.visit=x1;bz.visitAsync=k1});var A4=F((gz)=>{var r5=E(),kz=h$(),fz={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},hz=($)=>$.replace(/[!,[\]{}]/g,(Z)=>fz[Z]);class Z0{constructor($,Z){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Z0.defaultYaml,$),this.tags=Object.assign({},Z0.defaultTags,Z)}clone(){let $=new Z0(this.yaml,this.tags);return $.docStart=this.docStart,$}atDocument(){let $=new Z0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Z0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Z0.defaultTags);break}return $}add($,Z){if(this.atNextDocument)this.yaml={explicit:Z0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Z0.defaultTags),this.atNextDocument=!1;let X=$.trim().split(/[ \t]+/),z=X.shift();switch(z){case"%TAG":{if(X.length!==2){if(Z(0,"%TAG directive should contain exactly two parts"),X.length<2)return!1}let[q,G]=X;return this.tags[q]=G,!0}case"%YAML":{if(this.yaml.explicit=!0,X.length!==1)return Z(0,"%YAML directive should contain exactly one part"),!1;let[q]=X;if(q==="1.1"||q==="1.2")return this.yaml.version=q,!0;else{let G=/^\d+\.\d+$/.test(q);return Z(6,`Unsupported YAML version ${q}`,G),!1}}default:return Z(0,`Unknown directive ${z}`,!0),!1}}tagName($,Z){if($==="!")return"!";if($[0]!=="!")return Z(`Not a valid tag: ${$}`),null;if($[1]==="<"){let G=$.slice(2,-1);if(G==="!"||G==="!!")return Z(`Verbatim tags aren't resolved, so ${$} is invalid.`),null;if($[$.length-1]!==">")Z("Verbatim tags must end with a >");return G}let[,X,z]=$.match(/^(.*!)([^!]*)$/s);if(!z)Z(`The ${$} tag has no suffix`);let q=this.tags[X];if(q)try{return q+decodeURIComponent(z)}catch(G){return Z(String(G)),null}if(X==="!")return $;return Z(`Could not resolve tag: ${$}`),null}tagString($){for(let[Z,X]of Object.entries(this.tags))if($.startsWith(X))return Z+hz($.substring(X.length));return $[0]==="!"?$:`!<${$}>`}toString($){let Z=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],X=Object.entries(this.tags),z;if($&&X.length>0&&r5.isNode($.contents)){let q={};kz.visit($.contents,(G,J)=>{if(r5.isNode(J)&&J.tag)q[J.tag]=!0}),z=Object.keys(q)}else z=[];for(let[q,G]of X){if(q==="!!"&&G==="tag:yaml.org,2002:")continue;if(!$||z.some((J)=>J.startsWith(G)))Z.push(`%TAG ${q} ${G}`)}return Z.join(`
29
- `)}}Z0.defaultYaml={explicit:!1,version:"1.2"};Z0.defaultTags={"!!":"tag:yaml.org,2002:"};gz.Directives=Z0});var f1=F((pz)=>{var o5=E(),uz=h$();function mz($){if(/[\x00-\x19\s,[\]{}]/.test($)){let X=`Anchor must not contain whitespace or control characters: ${JSON.stringify($)}`;throw Error(X)}return!0}function t5($){let Z=new Set;return uz.visit($,{Value(X,z){if(z.anchor)Z.add(z.anchor)}}),Z}function e5($,Z){for(let X=1;;++X){let z=`${$}${X}`;if(!Z.has(z))return z}}function dz($,Z){let X=[],z=new Map,q=null;return{onAnchor:(G)=>{X.push(G),q??(q=t5($));let J=e5(Z,q);return q.add(J),J},setAnchors:()=>{for(let G of X){let J=z.get(G);if(typeof J==="object"&&J.anchor&&(o5.isScalar(J.node)||o5.isCollection(J.node)))J.node.anchor=J.anchor;else{let Q=Error("Failed to resolve repeated object (this should not happen)");throw Q.source=G,Q}}},sourceObjects:z}}pz.anchorIsValid=mz;pz.anchorNames=t5;pz.createNodeAnchors=dz;pz.findNewAnchor=e5});var j4=F((nz)=>{function g$($,Z,X,z){if(z&&typeof z==="object")if(Array.isArray(z))for(let q=0,G=z.length;q<G;++q){let J=z[q],Q=g$($,z,String(q),J);if(Q===void 0)delete z[q];else if(Q!==J)z[q]=Q}else if(z instanceof Map)for(let q of Array.from(z.keys())){let G=z.get(q),J=g$($,z,q,G);if(J===void 0)z.delete(q);else if(J!==G)z.set(q,J)}else if(z instanceof Set)for(let q of Array.from(z)){let G=g$($,z,q,q);if(G===void 0)z.delete(q);else if(G!==q)z.delete(q),z.add(G)}else for(let[q,G]of Object.entries(z)){let J=g$($,z,q,G);if(J===void 0)delete z[q];else if(J!==G)z[q]=J}return $.call(Z,X,z)}nz.applyReviver=g$});var R0=F((oz)=>{var rz=E();function $6($,Z,X){if(Array.isArray($))return $.map((z,q)=>$6(z,String(q),X));if($&&typeof $.toJSON==="function"){if(!X||!rz.hasAnchor($))return $.toJSON(Z,X);let z={aliasCount:0,count:1,res:void 0};X.anchors.set($,z),X.onCreate=(G)=>{z.res=G,delete X.onCreate};let q=$.toJSON(Z,X);if(X.onCreate)X.onCreate(q);return q}if(typeof $==="bigint"&&!X?.keep)return Number($);return $}oz.toJS=$6});var h1=F((Z3)=>{var ez=j4(),Z6=E(),$3=R0();class X6{constructor($){Object.defineProperty(this,Z6.NODE_TYPE,{value:$})}clone(){let $=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)$.range=this.range.slice();return $}toJS($,{mapAsMap:Z,maxAliasCount:X,onAnchor:z,reviver:q}={}){if(!Z6.isDocument($))throw TypeError("A document argument is required");let G={anchors:new Map,doc:$,keep:!0,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof X==="number"?X:100},J=$3.toJS(this,"",G);if(typeof z==="function")for(let{count:Q,res:Y}of G.anchors.values())z(Y,Q);return typeof q==="function"?ez.applyReviver(q,{"":J},"",J):J}}Z3.NodeBase=X6});var v$=F((Q3)=>{var z3=f1(),q3=h$(),G$=E(),G3=h1(),J3=R0();class z6 extends G3.NodeBase{constructor($){super(G$.ALIAS);this.source=$,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve($,Z){let X;if(Z?.aliasResolveCache)X=Z.aliasResolveCache;else if(X=[],q3.visit($,{Node:(q,G)=>{if(G$.isAlias(G)||G$.hasAnchor(G))X.push(G)}}),Z)Z.aliasResolveCache=X;let z=void 0;for(let q of X){if(q===this)break;if(q.anchor===this.source)z=q}return z}toJSON($,Z){if(!Z)return{source:this.source};let{anchors:X,doc:z,maxAliasCount:q}=Z,G=this.resolve(z,Z);if(!G){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(Q)}let J=X.get(G);if(!J)J3.toJS(G,null,Z),J=X.get(G);if(J?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(q>=0){if(J.count+=1,J.aliasCount===0)J.aliasCount=g1(z,G,X);if(J.count*J.aliasCount>q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return J.res}toString($,Z,X){let z=`*${this.source}`;if($){if(z3.anchorIsValid(this.source),$.options.verifyAliasOrder&&!$.anchors.has(this.source)){let q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(q)}if($.implicitKey)return`${z} `}return z}}function g1($,Z,X){if(G$.isAlias(Z)){let z=Z.resolve($),q=X&&z&&X.get(z);return q?q.count*q.aliasCount:0}else if(G$.isCollection(Z)){let z=0;for(let q of Z.items){let G=g1($,q,X);if(G>z)z=G}return z}else if(G$.isPair(Z)){let z=g1($,Z.key,X),q=g1($,Z.value,X);return Math.max(z,q)}return 1}Q3.Alias=z6});var g=F((K3)=>{var H3=E(),U3=h1(),W3=R0(),V3=($)=>!$||typeof $!=="function"&&typeof $!=="object";class d0 extends U3.NodeBase{constructor($){super(H3.SCALAR);this.value=$}toJSON($,Z){return Z?.keep?this.value:W3.toJS(this.value,$,Z)}toString(){return String(this.value)}}d0.BLOCK_FOLDED="BLOCK_FOLDED";d0.BLOCK_LITERAL="BLOCK_LITERAL";d0.PLAIN="PLAIN";d0.QUOTE_DOUBLE="QUOTE_DOUBLE";d0.QUOTE_SINGLE="QUOTE_SINGLE";K3.Scalar=d0;K3.isScalarValue=V3});var u$=F((M3)=>{var T3=v$(),p0=E(),q6=g(),D3="tag:yaml.org,2002:";function _3($,Z,X){if(Z){let z=X.filter((G)=>G.tag===Z),q=z.find((G)=>!G.format)??z[0];if(!q)throw Error(`Tag ${Z} not found`);return q}return X.find((z)=>z.identify?.($)&&!z.format)}function F3($,Z,X){if(p0.isDocument($))$=$.contents;if(p0.isNode($))return $;if(p0.isPair($)){let U=X.schema[p0.MAP].createNode?.(X.schema,null,X);return U.items.push($),U}if($ instanceof String||$ instanceof Number||$ instanceof Boolean||typeof BigInt<"u"&&$ instanceof BigInt)$=$.valueOf();let{aliasDuplicateObjects:z,onAnchor:q,onTagObj:G,schema:J,sourceObjects:Q}=X,Y=void 0;if(z&&$&&typeof $==="object")if(Y=Q.get($),Y)return Y.anchor??(Y.anchor=q($)),new T3.Alias(Y.anchor);else Y={anchor:null,node:null},Q.set($,Y);if(Z?.startsWith("!!"))Z=D3+Z.slice(2);let H=_3($,Z,J.tags);if(!H){if($&&typeof $.toJSON==="function")$=$.toJSON();if(!$||typeof $!=="object"){let U=new q6.Scalar($);if(Y)Y.node=U;return U}H=$ instanceof Map?J[p0.MAP]:(Symbol.iterator in Object($))?J[p0.SEQ]:J[p0.MAP]}if(G)G(H),delete X.onTagObj;let W=H?.createNode?H.createNode(X.schema,$,X):typeof H?.nodeClass?.from==="function"?H.nodeClass.from(X.schema,$,X):new q6.Scalar($);if(Z)W.tag=Z;else if(!H.default)W.tag=H.tag;if(Y)Y.node=W;return W}M3.createNode=F3});var v1=F((I3)=>{var w3=u$(),V0=E(),P3=h1();function N4($,Z,X){let z=X;for(let q=Z.length-1;q>=0;--q){let G=Z[q];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let J=[];J[G]=z,z=J}else z=new Map([[G,z]])}return w3.createNode(z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:$,sourceObjects:new Map})}var G6=($)=>$==null||typeof $==="object"&&!!$[Symbol.iterator]().next().done;class J6 extends P3.NodeBase{constructor($,Z){super($);Object.defineProperty(this,"schema",{value:Z,configurable:!0,enumerable:!1,writable:!0})}clone($){let Z=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if($)Z.schema=$;if(Z.items=Z.items.map((X)=>V0.isNode(X)||V0.isPair(X)?X.clone($):X),this.range)Z.range=this.range.slice();return Z}addIn($,Z){if(G6($))this.add(Z);else{let[X,...z]=$,q=this.get(X,!0);if(V0.isCollection(q))q.addIn(z,Z);else if(q===void 0&&this.schema)this.set(X,N4(this.schema,z,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${z}`)}}deleteIn($){let[Z,...X]=$;if(X.length===0)return this.delete(Z);let z=this.get(Z,!0);if(V0.isCollection(z))return z.deleteIn(X);else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${X}`)}getIn($,Z){let[X,...z]=$,q=this.get(X,!0);if(z.length===0)return!Z&&V0.isScalar(q)?q.value:q;else return V0.isCollection(q)?q.getIn(z,Z):void 0}hasAllNullValues($){return this.items.every((Z)=>{if(!V0.isPair(Z))return!1;let X=Z.value;return X==null||$&&V0.isScalar(X)&&X.value==null&&!X.commentBefore&&!X.comment&&!X.tag})}hasIn($){let[Z,...X]=$;if(X.length===0)return this.has(Z);let z=this.get(Z,!0);return V0.isCollection(z)?z.hasIn(X):!1}setIn($,Z){let[X,...z]=$;if(z.length===0)this.set(X,Z);else{let q=this.get(X,!0);if(V0.isCollection(q))q.setIn(z,Z);else if(q===void 0&&this.schema)this.set(X,N4(this.schema,z,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${z}`)}}}I3.Collection=J6;I3.collectionFromPath=N4;I3.isEmptyPath=G6});var m$=F((C3)=>{var N3=($)=>$.replace(/^(?!$)(?: $)?/gm,"#");function S4($,Z){if(/^\n+$/.test($))return $.substring(1);return Z?$.replace(/^(?! *$)/gm,Z):$}var S3=($,Z,X)=>$.endsWith(`
30
- `)?S4(X,Z):X.includes(`
25
+ `),this.outputHelp({error:!0});let X=Z||{},Y=X.exitCode||1,G=X.code||"commander.error";this._exit(Y,G,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in c.env){let Z=$.attributeName();if(this.getOptionValue(Z)===void 0||["default","config","env"].includes(this.getOptionValueSource(Z)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,c.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new IJ(this.options),Z=(X)=>{return this.getOptionValue(X)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(X))};this.options.filter((X)=>X.implied!==void 0&&Z(X.attributeName())&&$.valueFromOption(this.getOptionValue(X.attributeName()),X)).forEach((X)=>{Object.keys(X.implied).filter((Y)=>!Z(Y)).forEach((Y)=>{this.setOptionValueWithSource(Y,X.implied[Y],"implied")})})}missingArgument($){let Z=`error: missing required argument '${$}'`;this.error(Z,{code:"commander.missingArgument"})}optionMissingArgument($){let Z=`error: option '${$.flags}' argument missing`;this.error(Z,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let Z=`error: required option '${$.flags}' not specified`;this.error(Z,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,Z){let X=(z)=>{let J=z.attributeName(),Q=this.getOptionValue(J),W=this.options.find((K)=>K.negate&&J===K.attributeName()),V=this.options.find((K)=>!K.negate&&J===K.attributeName());if(W&&(W.presetArg===void 0&&Q===!1||W.presetArg!==void 0&&Q===W.presetArg))return W;return V||z},Y=(z)=>{let J=X(z),Q=J.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},G=`error: ${Y($)} cannot be used with ${Y(Z)}`;this.error(G,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let Z="";if($.startsWith("--")&&this._showSuggestionAfterError){let Y=[],G=this;do{let z=G.createHelp().visibleOptions(G).filter((J)=>J.long).map((J)=>J.long);Y=Y.concat(z),G=G.parent}while(G&&!G._enablePositionalOptions);Z=U3($,Y)}let X=`error: unknown option '${$}'${Z}`;this.error(X,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let Z=this.registeredArguments.length,X=Z===1?"":"s",G=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${Z} argument${X} but got ${$.length}.`;this.error(G,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],Z="";if(this._showSuggestionAfterError){let Y=[];this.createHelp().visibleCommands(this).forEach((G)=>{if(Y.push(G.name()),G.alias())Y.push(G.alias())}),Z=U3($,Y)}let X=`error: unknown command '${$}'${Z}`;this.error(X,{code:"commander.unknownCommand"})}version($,Z,X){if($===void 0)return this._version;this._version=$,Z=Z||"-V, --version",X=X||"output the version number";let Y=this.createOption(Z,X);return this._versionOptionName=Y.attributeName(),this._registerOption(Y),this.on("option:"+Y.name(),()=>{this._outputConfiguration.writeOut(`${$}
26
+ `),this._exit(0,"commander.version",$)}),this}description($,Z){if($===void 0&&Z===void 0)return this._description;if(this._description=$,Z)this._argsDescription=Z;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let Z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)Z=this.commands[this.commands.length-1];if($===Z._name)throw Error("Command alias can't be the same as its name");let X=this.parent?._findCommand($);if(X){let Y=[X.name()].concat(X.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${Y}'`)}return Z._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((Z)=>this.alias(Z)),this}usage($){if($===void 0){if(this._usage)return this._usage;let Z=this.registeredArguments.map((X)=>{return AJ(X)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?Z:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=s0.basename($,s0.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let Z=this.createHelp(),X=this._getOutputContext($);Z.prepareContext({error:X.error,helpWidth:X.helpWidth,outputHasColors:X.hasColors});let Y=Z.formatHelp(this,Z);if(X.hasColors)return Y;return this._outputConfiguration.stripColor(Y)}_getOutputContext($){$=$||{};let Z=!!$.error,X,Y,G;if(Z)X=(J)=>this._outputConfiguration.writeErr(J),Y=this._outputConfiguration.getErrHasColors(),G=this._outputConfiguration.getErrHelpWidth();else X=(J)=>this._outputConfiguration.writeOut(J),Y=this._outputConfiguration.getOutHasColors(),G=this._outputConfiguration.getOutHelpWidth();return{error:Z,write:(J)=>{if(!Y)J=this._outputConfiguration.stripColor(J);return X(J)},hasColors:Y,helpWidth:G}}outputHelp($){let Z;if(typeof $==="function")Z=$,$=void 0;let X=this._getOutputContext($),Y={error:X.error,write:X.write,command:this};this._getCommandAndAncestors().reverse().forEach((z)=>z.emit("beforeAllHelp",Y)),this.emit("beforeHelp",Y);let G=this.helpInformation({error:X.error});if(Z){if(G=Z(G),typeof G!=="string"&&!Buffer.isBuffer(G))throw Error("outputHelp callback must return a string or a Buffer")}if(X.write(G),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",Y),this._getCommandAndAncestors().forEach((z)=>z.emit("afterAllHelp",Y))}helpOption($,Z){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",Z??"display help for command"),$||Z)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let Z=Number(c.exitCode??0);if(Z===0&&$&&typeof $!=="function"&&$.error)Z=1;this._exit(Z,"commander.help","(outputHelp)")}addHelpText($,Z){let X=["beforeAll","before","after","afterAll"];if(!X.includes($))throw Error(`Unexpected value for position to addHelpText.
27
+ Expecting one of '${X.join("', '")}'`);let Y=`${$}Help`;return this.on(Y,(G)=>{let z;if(typeof Z==="function")z=Z({error:G.error,command:G.command});else z=Z;if(z)G.write(`${z}
28
+ `)}),this}_outputHelpIfRequested($){let Z=this._getHelpOption();if(Z&&$.find((Y)=>Z.is(Y)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function q3($){return $.map((Z)=>{if(!Z.startsWith("--inspect"))return Z;let X,Y="127.0.0.1",G="9229",z;if((z=Z.match(/^(--inspect(-brk)?)$/))!==null)X=z[1];else if((z=Z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(X=z[1],/^\d+$/.test(z[3]))G=z[3];else Y=z[3];else if((z=Z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)X=z[1],Y=z[3],G=z[4];if(X&&G!=="0")return`${X}=${Y}:${parseInt(G)+1}`;return Z})}function UX(){if(c.env.NO_COLOR||c.env.FORCE_COLOR==="0"||c.env.FORCE_COLOR==="false")return!1;if(c.env.FORCE_COLOR||c.env.CLICOLOR_FORCE!==void 0)return!0;return}jJ.Command=qX;jJ.useColor=UX});var M3=R((yJ)=>{var{Argument:F3}=rZ(),{Command:TX}=T3(),{CommanderError:bJ,InvalidArgumentError:L3}=I2(),{Help:fJ}=VX(),{Option:w3}=HX();yJ.program=new TX;yJ.createCommand=($)=>new TX($);yJ.createOption=($,Z)=>new w3($,Z);yJ.createArgument=($,Z)=>new F3($,Z);yJ.Command=TX;yJ.Option=w3;yJ.Argument=F3;yJ.Help=fJ;yJ.CommanderError=bJ;yJ.InvalidArgumentError=L3;yJ.InvalidOptionArgumentError=L3});var m=R((XQ)=>{var MX=Symbol.for("yaml.alias"),_3=Symbol.for("yaml.document"),oZ=Symbol.for("yaml.map"),P3=Symbol.for("yaml.pair"),NX=Symbol.for("yaml.scalar"),tZ=Symbol.for("yaml.seq"),o0=Symbol.for("yaml.node.type"),rJ=($)=>!!$&&typeof $==="object"&&$[o0]===MX,sJ=($)=>!!$&&typeof $==="object"&&$[o0]===_3,oJ=($)=>!!$&&typeof $==="object"&&$[o0]===oZ,tJ=($)=>!!$&&typeof $==="object"&&$[o0]===P3,D3=($)=>!!$&&typeof $==="object"&&$[o0]===NX,eJ=($)=>!!$&&typeof $==="object"&&$[o0]===tZ;function E3($){if($&&typeof $==="object")switch($[o0]){case oZ:case tZ:return!0}return!1}function $Q($){if($&&typeof $==="object")switch($[o0]){case MX:case oZ:case NX:case tZ:return!0}return!1}var ZQ=($)=>(D3($)||E3($))&&!!$.anchor;XQ.ALIAS=MX;XQ.DOC=_3;XQ.MAP=oZ;XQ.NODE_TYPE=o0;XQ.PAIR=P3;XQ.SCALAR=NX;XQ.SEQ=tZ;XQ.hasAnchor=ZQ;XQ.isAlias=rJ;XQ.isCollection=E3;XQ.isDocument=sJ;XQ.isMap=oJ;XQ.isNode=$Q;XQ.isPair=tJ;XQ.isScalar=D3;XQ.isSeq=eJ});var j2=R((MQ)=>{var t=m(),M0=Symbol("break visit"),R3=Symbol("skip children"),u0=Symbol("remove node");function eZ($,Z){let X=A3(Z);if(t.isDocument($)){if(N1(null,$.contents,X,Object.freeze([$]))===u0)$.contents=null}else N1(null,$,X,Object.freeze([]))}eZ.BREAK=M0;eZ.SKIP=R3;eZ.REMOVE=u0;function N1($,Z,X,Y){let G=S3($,Z,X,Y);if(t.isNode(G)||t.isPair(G))return C3($,Y,G),N1($,G,X,Y);if(typeof G!=="symbol"){if(t.isCollection(Z)){Y=Object.freeze(Y.concat(Z));for(let z=0;z<Z.items.length;++z){let J=N1(z,Z.items[z],X,Y);if(typeof J==="number")z=J-1;else if(J===M0)return M0;else if(J===u0)Z.items.splice(z,1),z-=1}}else if(t.isPair(Z)){Y=Object.freeze(Y.concat(Z));let z=N1("key",Z.key,X,Y);if(z===M0)return M0;else if(z===u0)Z.key=null;let J=N1("value",Z.value,X,Y);if(J===M0)return M0;else if(J===u0)Z.value=null}}return G}async function $6($,Z){let X=A3(Z);if(t.isDocument($)){if(await O1(null,$.contents,X,Object.freeze([$]))===u0)$.contents=null}else await O1(null,$,X,Object.freeze([]))}$6.BREAK=M0;$6.SKIP=R3;$6.REMOVE=u0;async function O1($,Z,X,Y){let G=await S3($,Z,X,Y);if(t.isNode(G)||t.isPair(G))return C3($,Y,G),O1($,G,X,Y);if(typeof G!=="symbol"){if(t.isCollection(Z)){Y=Object.freeze(Y.concat(Z));for(let z=0;z<Z.items.length;++z){let J=await O1(z,Z.items[z],X,Y);if(typeof J==="number")z=J-1;else if(J===M0)return M0;else if(J===u0)Z.items.splice(z,1),z-=1}}else if(t.isPair(Z)){Y=Object.freeze(Y.concat(Z));let z=await O1("key",Z.key,X,Y);if(z===M0)return M0;else if(z===u0)Z.key=null;let J=await O1("value",Z.value,X,Y);if(J===M0)return M0;else if(J===u0)Z.value=null}}return G}function A3($){if(typeof $==="object"&&($.Collection||$.Node||$.Value))return Object.assign({Alias:$.Node,Map:$.Node,Scalar:$.Node,Seq:$.Node},$.Value&&{Map:$.Value,Scalar:$.Value,Seq:$.Value},$.Collection&&{Map:$.Collection,Seq:$.Collection},$);return $}function S3($,Z,X,Y){if(typeof X==="function")return X($,Z,Y);if(t.isMap(Z))return X.Map?.($,Z,Y);if(t.isSeq(Z))return X.Seq?.($,Z,Y);if(t.isPair(Z))return X.Pair?.($,Z,Y);if(t.isScalar(Z))return X.Scalar?.($,Z,Y);if(t.isAlias(Z))return X.Alias?.($,Z,Y);return}function C3($,Z,X){let Y=Z[Z.length-1];if(t.isCollection(Y))Y.items[$]=X;else if(t.isPair(Y))if($==="key")Y.key=X;else Y.value=X;else if(t.isDocument(Y))Y.contents=X;else{let G=t.isAlias(Y)?"alias":"scalar";throw Error(`Cannot replace node with ${G} parent`)}}MQ.visit=eZ;MQ.visitAsync=$6});var OX=R((EQ)=>{var I3=m(),_Q=j2(),PQ={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},DQ=($)=>$.replace(/[!,[\]{}]/g,(Z)=>PQ[Z]);class C0{constructor($,Z){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},C0.defaultYaml,$),this.tags=Object.assign({},C0.defaultTags,Z)}clone(){let $=new C0(this.yaml,this.tags);return $.docStart=this.docStart,$}atDocument(){let $=new C0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:C0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},C0.defaultTags);break}return $}add($,Z){if(this.atNextDocument)this.yaml={explicit:C0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},C0.defaultTags),this.atNextDocument=!1;let X=$.trim().split(/[ \t]+/),Y=X.shift();switch(Y){case"%TAG":{if(X.length!==2){if(Z(0,"%TAG directive should contain exactly two parts"),X.length<2)return!1}let[G,z]=X;return this.tags[G]=z,!0}case"%YAML":{if(this.yaml.explicit=!0,X.length!==1)return Z(0,"%YAML directive should contain exactly one part"),!1;let[G]=X;if(G==="1.1"||G==="1.2")return this.yaml.version=G,!0;else{let z=/^\d+\.\d+$/.test(G);return Z(6,`Unsupported YAML version ${G}`,z),!1}}default:return Z(0,`Unknown directive ${Y}`,!0),!1}}tagName($,Z){if($==="!")return"!";if($[0]!=="!")return Z(`Not a valid tag: ${$}`),null;if($[1]==="<"){let z=$.slice(2,-1);if(z==="!"||z==="!!")return Z(`Verbatim tags aren't resolved, so ${$} is invalid.`),null;if($[$.length-1]!==">")Z("Verbatim tags must end with a >");return z}let[,X,Y]=$.match(/^(.*!)([^!]*)$/s);if(!Y)Z(`The ${$} tag has no suffix`);let G=this.tags[X];if(G)try{return G+decodeURIComponent(Y)}catch(z){return Z(String(z)),null}if(X==="!")return $;return Z(`Could not resolve tag: ${$}`),null}tagString($){for(let[Z,X]of Object.entries(this.tags))if($.startsWith(X))return Z+DQ($.substring(X.length));return $[0]==="!"?$:`!<${$}>`}toString($){let Z=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],X=Object.entries(this.tags),Y;if($&&X.length>0&&I3.isNode($.contents)){let G={};_Q.visit($.contents,(z,J)=>{if(I3.isNode(J)&&J.tag)G[J.tag]=!0}),Y=Object.keys(G)}else Y=[];for(let[G,z]of X){if(G==="!!"&&z==="tag:yaml.org,2002:")continue;if(!$||Y.some((J)=>J.startsWith(z)))Z.push(`%TAG ${G} ${z}`)}return Z.join(`
29
+ `)}}C0.defaultYaml={explicit:!1,version:"1.2"};C0.defaultTags={"!!":"tag:yaml.org,2002:"};EQ.Directives=C0});var Z6=R((IQ)=>{var j3=m(),AQ=j2();function SQ($){if(/[\x00-\x19\s,[\]{}]/.test($)){let X=`Anchor must not contain whitespace or control characters: ${JSON.stringify($)}`;throw Error(X)}return!0}function x3($){let Z=new Set;return AQ.visit($,{Value(X,Y){if(Y.anchor)Z.add(Y.anchor)}}),Z}function k3($,Z){for(let X=1;;++X){let Y=`${$}${X}`;if(!Z.has(Y))return Y}}function CQ($,Z){let X=[],Y=new Map,G=null;return{onAnchor:(z)=>{X.push(z),G??(G=x3($));let J=k3(Z,G);return G.add(J),J},setAnchors:()=>{for(let z of X){let J=Y.get(z);if(typeof J==="object"&&J.anchor&&(j3.isScalar(J.node)||j3.isCollection(J.node)))J.node.anchor=J.anchor;else{let Q=Error("Failed to resolve repeated object (this should not happen)");throw Q.source=z,Q}}},sourceObjects:Y}}IQ.anchorIsValid=SQ;IQ.anchorNames=x3;IQ.createNodeAnchors=CQ;IQ.findNewAnchor=k3});var _X=R((fQ)=>{function x2($,Z,X,Y){if(Y&&typeof Y==="object")if(Array.isArray(Y))for(let G=0,z=Y.length;G<z;++G){let J=Y[G],Q=x2($,Y,String(G),J);if(Q===void 0)delete Y[G];else if(Q!==J)Y[G]=Q}else if(Y instanceof Map)for(let G of Array.from(Y.keys())){let z=Y.get(G),J=x2($,Y,G,z);if(J===void 0)Y.delete(G);else if(J!==z)Y.set(G,J)}else if(Y instanceof Set)for(let G of Array.from(Y)){let z=x2($,Y,G,G);if(z===void 0)Y.delete(G);else if(z!==G)Y.delete(G),Y.add(z)}else for(let[G,z]of Object.entries(Y)){let J=x2($,Y,G,z);if(J===void 0)delete Y[G];else if(J!==z)Y[G]=J}return $.call(Z,X,Y)}fQ.applyReviver=x2});var K$=R((vQ)=>{var gQ=m();function b3($,Z,X){if(Array.isArray($))return $.map((Y,G)=>b3(Y,String(G),X));if($&&typeof $.toJSON==="function"){if(!X||!gQ.hasAnchor($))return $.toJSON(Z,X);let Y={aliasCount:0,count:1,res:void 0};X.anchors.set($,Y),X.onCreate=(z)=>{Y.res=z,delete X.onCreate};let G=$.toJSON(Z,X);if(X.onCreate)X.onCreate(G);return G}if(typeof $==="bigint"&&!X?.keep)return Number($);return $}vQ.toJS=b3});var X6=R((dQ)=>{var uQ=_X(),f3=m(),mQ=K$();class y3{constructor($){Object.defineProperty(this,f3.NODE_TYPE,{value:$})}clone(){let $=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)$.range=this.range.slice();return $}toJS($,{mapAsMap:Z,maxAliasCount:X,onAnchor:Y,reviver:G}={}){if(!f3.isDocument($))throw TypeError("A document argument is required");let z={anchors:new Map,doc:$,keep:!0,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof X==="number"?X:100},J=mQ.toJS(this,"",z);if(typeof Y==="function")for(let{count:Q,res:W}of z.anchors.values())Y(W,Q);return typeof G==="function"?uQ.applyReviver(G,{"":J},"",J):J}}dQ.NodeBase=y3});var k2=R((nQ)=>{var lQ=Z6(),pQ=j2(),_1=m(),iQ=X6(),aQ=K$();class g3 extends iQ.NodeBase{constructor($){super(_1.ALIAS);this.source=$,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve($,Z){let X;if(Z?.aliasResolveCache)X=Z.aliasResolveCache;else if(X=[],pQ.visit($,{Node:(G,z)=>{if(_1.isAlias(z)||_1.hasAnchor(z))X.push(z)}}),Z)Z.aliasResolveCache=X;let Y=void 0;for(let G of X){if(G===this)break;if(G.anchor===this.source)Y=G}return Y}toJSON($,Z){if(!Z)return{source:this.source};let{anchors:X,doc:Y,maxAliasCount:G}=Z,z=this.resolve(Y,Z);if(!z){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(Q)}let J=X.get(z);if(!J)aQ.toJS(z,null,Z),J=X.get(z);if(J?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(G>=0){if(J.count+=1,J.aliasCount===0)J.aliasCount=Y6(Y,z,X);if(J.count*J.aliasCount>G)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return J.res}toString($,Z,X){let Y=`*${this.source}`;if($){if(lQ.anchorIsValid(this.source),$.options.verifyAliasOrder&&!$.anchors.has(this.source)){let G=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(G)}if($.implicitKey)return`${Y} `}return Y}}function Y6($,Z,X){if(_1.isAlias(Z)){let Y=Z.resolve($),G=X&&Y&&X.get(Y);return G?G.count*G.aliasCount:0}else if(_1.isCollection(Z)){let Y=0;for(let G of Z.items){let z=Y6($,G,X);if(z>Y)Y=z}return Y}else if(_1.isPair(Z)){let Y=Y6($,Z.key,X),G=Y6($,Z.value,X);return Math.max(Y,G)}return 1}nQ.Alias=g3});var o=R(($W)=>{var sQ=m(),oQ=X6(),tQ=K$(),eQ=($)=>!$||typeof $!=="function"&&typeof $!=="object";class m$ extends oQ.NodeBase{constructor($){super(sQ.SCALAR);this.value=$}toJSON($,Z){return Z?.keep?this.value:tQ.toJS(this.value,$,Z)}toString(){return String(this.value)}}m$.BLOCK_FOLDED="BLOCK_FOLDED";m$.BLOCK_LITERAL="BLOCK_LITERAL";m$.PLAIN="PLAIN";m$.QUOTE_DOUBLE="QUOTE_DOUBLE";m$.QUOTE_SINGLE="QUOTE_SINGLE";$W.Scalar=m$;$W.isScalarValue=eQ});var b2=R((QW)=>{var YW=k2(),d$=m(),v3=o(),GW="tag:yaml.org,2002:";function zW($,Z,X){if(Z){let Y=X.filter((z)=>z.tag===Z),G=Y.find((z)=>!z.format)??Y[0];if(!G)throw Error(`Tag ${Z} not found`);return G}return X.find((Y)=>Y.identify?.($)&&!Y.format)}function JW($,Z,X){if(d$.isDocument($))$=$.contents;if(d$.isNode($))return $;if(d$.isPair($)){let H=X.schema[d$.MAP].createNode?.(X.schema,null,X);return H.items.push($),H}if($ instanceof String||$ instanceof Number||$ instanceof Boolean||typeof BigInt<"u"&&$ instanceof BigInt)$=$.valueOf();let{aliasDuplicateObjects:Y,onAnchor:G,onTagObj:z,schema:J,sourceObjects:Q}=X,W=void 0;if(Y&&$&&typeof $==="object")if(W=Q.get($),W)return W.anchor??(W.anchor=G($)),new YW.Alias(W.anchor);else W={anchor:null,node:null},Q.set($,W);if(Z?.startsWith("!!"))Z=GW+Z.slice(2);let V=zW($,Z,J.tags);if(!V){if($&&typeof $.toJSON==="function")$=$.toJSON();if(!$||typeof $!=="object"){let H=new v3.Scalar($);if(W)W.node=H;return H}V=$ instanceof Map?J[d$.MAP]:(Symbol.iterator in Object($))?J[d$.SEQ]:J[d$.MAP]}if(z)z(V),delete X.onTagObj;let K=V?.createNode?V.createNode(X.schema,$,X):typeof V?.nodeClass?.from==="function"?V.nodeClass.from(X.schema,$,X):new v3.Scalar($);if(Z)K.tag=Z;else if(!V.default)K.tag=V.tag;if(W)W.node=K;return K}QW.createNode=JW});var G6=R((KW)=>{var VW=b2(),m0=m(),HW=X6();function PX($,Z,X){let Y=X;for(let G=Z.length-1;G>=0;--G){let z=Z[G];if(typeof z==="number"&&Number.isInteger(z)&&z>=0){let J=[];J[z]=Y,Y=J}else Y=new Map([[z,Y]])}return VW.createNode(Y,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:$,sourceObjects:new Map})}var h3=($)=>$==null||typeof $==="object"&&!!$[Symbol.iterator]().next().done;class u3 extends HW.NodeBase{constructor($,Z){super($);Object.defineProperty(this,"schema",{value:Z,configurable:!0,enumerable:!1,writable:!0})}clone($){let Z=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if($)Z.schema=$;if(Z.items=Z.items.map((X)=>m0.isNode(X)||m0.isPair(X)?X.clone($):X),this.range)Z.range=this.range.slice();return Z}addIn($,Z){if(h3($))this.add(Z);else{let[X,...Y]=$,G=this.get(X,!0);if(m0.isCollection(G))G.addIn(Y,Z);else if(G===void 0&&this.schema)this.set(X,PX(this.schema,Y,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${Y}`)}}deleteIn($){let[Z,...X]=$;if(X.length===0)return this.delete(Z);let Y=this.get(Z,!0);if(m0.isCollection(Y))return Y.deleteIn(X);else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${X}`)}getIn($,Z){let[X,...Y]=$,G=this.get(X,!0);if(Y.length===0)return!Z&&m0.isScalar(G)?G.value:G;else return m0.isCollection(G)?G.getIn(Y,Z):void 0}hasAllNullValues($){return this.items.every((Z)=>{if(!m0.isPair(Z))return!1;let X=Z.value;return X==null||$&&m0.isScalar(X)&&X.value==null&&!X.commentBefore&&!X.comment&&!X.tag})}hasIn($){let[Z,...X]=$;if(X.length===0)return this.has(Z);let Y=this.get(Z,!0);return m0.isCollection(Y)?Y.hasIn(X):!1}setIn($,Z){let[X,...Y]=$;if(Y.length===0)this.set(X,Z);else{let G=this.get(X,!0);if(m0.isCollection(G))G.setIn(Y,Z);else if(G===void 0&&this.schema)this.set(X,PX(this.schema,Y,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${Y}`)}}}KW.Collection=u3;KW.collectionFromPath=PX;KW.isEmptyPath=h3});var f2=R((LW)=>{var TW=($)=>$.replace(/^(?!$)(?: $)?/gm,"#");function DX($,Z){if(/^\n+$/.test($))return $.substring(1);return Z?$.replace(/^(?! *$)/gm,Z):$}var FW=($,Z,X)=>$.endsWith(`
30
+ `)?DX(X,Z):X.includes(`
31
31
  `)?`
32
- `+S4(X,Z):($.endsWith(" ")?"":" ")+X;C3.indentComment=S4;C3.lineComment=S3;C3.stringifyComment=N3});var Y6=F((k3)=>{function x3($,Z,X="flow",{indentAtStart:z,lineWidth:q=80,minContentWidth:G=20,onFold:J,onOverflow:Q}={}){if(!q||q<0)return $;if(q<G)G=0;let Y=Math.max(1+G,1+q-Z.length);if($.length<=Y)return $;let H=[],W={},U=q-Z.length;if(typeof z==="number")if(z>q-Math.max(2,G))H.push(0);else U=q-z;let V=void 0,B=void 0,T=!1,K=-1,L=-1,D=-1;if(X==="block"){if(K=Q6($,K,Z.length),K!==-1)U=K+Y}for(let O;O=$[K+=1];){if(X==="quoted"&&O==="\\"){switch(L=K,$[K+1]){case"x":K+=3;break;case"u":K+=5;break;case"U":K+=9;break;default:K+=1}D=K}if(O===`
33
- `){if(X==="block")K=Q6($,K,Z.length);U=K+Z.length+Y,V=void 0}else{if(O===" "&&B&&B!==" "&&B!==`
34
- `&&B!=="\t"){let w=$[K+1];if(w&&w!==" "&&w!==`
35
- `&&w!=="\t")V=K}if(K>=U)if(V)H.push(V),U=V+Y,V=void 0;else if(X==="quoted"){while(B===" "||B==="\t")B=O,O=$[K+=1],T=!0;let w=K>D+1?K-2:L-1;if(W[w])return $;H.push(w),W[w]=!0,U=w+Y,V=void 0}else T=!0}B=O}if(T&&Q)Q();if(H.length===0)return $;if(J)J();let _=$.slice(0,H[0]);for(let O=0;O<H.length;++O){let w=H[O],R=H[O+1]||$.length;if(w===0)_=`
36
- ${Z}${$.slice(0,R)}`;else{if(X==="quoted"&&W[w])_+=`${$[w]}\\`;_+=`
37
- ${Z}${$.slice(w+1,R)}`}}return _}function Q6($,Z,X){let z=Z,q=Z+1,G=$[q];while(G===" "||G==="\t")if(Z<q+X)G=$[++Z];else{do G=$[++Z];while(G&&G!==`
38
- `);z=Z,q=Z+1,G=$[q]}return z}k3.FOLD_BLOCK="block";k3.FOLD_FLOW="flow";k3.FOLD_QUOTED="quoted";k3.foldFlowLines=x3});var p$=F((p3)=>{var Q0=g(),A0=Y6(),m1=($,Z)=>({indentAtStart:Z?$.indent.length:$.indentAtStart,lineWidth:$.options.lineWidth,minContentWidth:$.options.minContentWidth}),d1=($)=>/^(%|---|\.\.\.)/m.test($);function u3($,Z,X){if(!Z||Z<0)return!1;let z=Z-X,q=$.length;if(q<=z)return!1;for(let G=0,J=0;G<q;++G)if($[G]===`
39
- `){if(G-J>z)return!0;if(J=G+1,q-J<=z)return!1}return!0}function d$($,Z){let X=JSON.stringify($);if(Z.options.doubleQuotedAsJSON)return X;let{implicitKey:z}=Z,q=Z.options.doubleQuotedMinMultiLineLength,G=Z.indent||(d1($)?" ":""),J="",Q=0;for(let Y=0,H=X[Y];H;H=X[++Y]){if(H===" "&&X[Y+1]==="\\"&&X[Y+2]==="n")J+=X.slice(Q,Y)+"\\ ",Y+=1,Q=Y,H="\\";if(H==="\\")switch(X[Y+1]){case"u":{J+=X.slice(Q,Y);let W=X.substr(Y+2,4);switch(W){case"0000":J+="\\0";break;case"0007":J+="\\a";break;case"000b":J+="\\v";break;case"001b":J+="\\e";break;case"0085":J+="\\N";break;case"00a0":J+="\\_";break;case"2028":J+="\\L";break;case"2029":J+="\\P";break;default:if(W.substr(0,2)==="00")J+="\\x"+W.substr(2);else J+=X.substr(Y,6)}Y+=5,Q=Y+1}break;case"n":if(z||X[Y+2]==='"'||X.length<q)Y+=1;else{J+=X.slice(Q,Y)+`
32
+ `+DX(X,Z):($.endsWith(" ")?"":" ")+X;LW.indentComment=DX;LW.lineComment=FW;LW.stringifyComment=TW});var d3=R((_W)=>{function OW($,Z,X="flow",{indentAtStart:Y,lineWidth:G=80,minContentWidth:z=20,onFold:J,onOverflow:Q}={}){if(!G||G<0)return $;if(G<z)z=0;let W=Math.max(1+z,1+G-Z.length);if($.length<=W)return $;let V=[],K={},H=G-Z.length;if(typeof Y==="number")if(Y>G-Math.max(2,z))V.push(0);else H=G-Y;let B=void 0,U=void 0,F=!1,T=-1,w=-1,O=-1;if(X==="block"){if(T=m3($,T,Z.length),T!==-1)H=T+W}for(let P;P=$[T+=1];){if(X==="quoted"&&P==="\\"){switch(w=T,$[T+1]){case"x":T+=3;break;case"u":T+=5;break;case"U":T+=9;break;default:T+=1}O=T}if(P===`
33
+ `){if(X==="block")T=m3($,T,Z.length);H=T+Z.length+W,B=void 0}else{if(P===" "&&U&&U!==" "&&U!==`
34
+ `&&U!=="\t"){let E=$[T+1];if(E&&E!==" "&&E!==`
35
+ `&&E!=="\t")B=T}if(T>=H)if(B)V.push(B),H=B+W,B=void 0;else if(X==="quoted"){while(U===" "||U==="\t")U=P,P=$[T+=1],F=!0;let E=T>O+1?T-2:w-1;if(K[E])return $;V.push(E),K[E]=!0,H=E+W,B=void 0}else F=!0}U=P}if(F&&Q)Q();if(V.length===0)return $;if(J)J();let N=$.slice(0,V[0]);for(let P=0;P<V.length;++P){let E=V[P],I=V[P+1]||$.length;if(E===0)N=`
36
+ ${Z}${$.slice(0,I)}`;else{if(X==="quoted"&&K[E])N+=`${$[E]}\\`;N+=`
37
+ ${Z}${$.slice(E+1,I)}`}}return N}function m3($,Z,X){let Y=Z,G=Z+1,z=$[G];while(z===" "||z==="\t")if(Z<G+X)z=$[++Z];else{do z=$[++Z];while(z&&z!==`
38
+ `);Y=Z,G=Z+1,z=$[G]}return Y}_W.FOLD_BLOCK="block";_W.FOLD_FLOW="flow";_W.FOLD_QUOTED="quoted";_W.foldFlowLines=OW});var g2=R((IW)=>{var f0=o(),B$=d3(),J6=($,Z)=>({indentAtStart:Z?$.indent.length:$.indentAtStart,lineWidth:$.options.lineWidth,minContentWidth:$.options.minContentWidth}),Q6=($)=>/^(%|---|\.\.\.)/m.test($);function AW($,Z,X){if(!Z||Z<0)return!1;let Y=Z-X,G=$.length;if(G<=Y)return!1;for(let z=0,J=0;z<G;++z)if($[z]===`
39
+ `){if(z-J>Y)return!0;if(J=z+1,G-J<=Y)return!1}return!0}function y2($,Z){let X=JSON.stringify($);if(Z.options.doubleQuotedAsJSON)return X;let{implicitKey:Y}=Z,G=Z.options.doubleQuotedMinMultiLineLength,z=Z.indent||(Q6($)?" ":""),J="",Q=0;for(let W=0,V=X[W];V;V=X[++W]){if(V===" "&&X[W+1]==="\\"&&X[W+2]==="n")J+=X.slice(Q,W)+"\\ ",W+=1,Q=W,V="\\";if(V==="\\")switch(X[W+1]){case"u":{J+=X.slice(Q,W);let K=X.substr(W+2,4);switch(K){case"0000":J+="\\0";break;case"0007":J+="\\a";break;case"000b":J+="\\v";break;case"001b":J+="\\e";break;case"0085":J+="\\N";break;case"00a0":J+="\\_";break;case"2028":J+="\\L";break;case"2029":J+="\\P";break;default:if(K.substr(0,2)==="00")J+="\\x"+K.substr(2);else J+=X.substr(W,6)}W+=5,Q=W+1}break;case"n":if(Y||X[W+2]==='"'||X.length<G)W+=1;else{J+=X.slice(Q,W)+`
40
40
 
41
- `;while(X[Y+2]==="\\"&&X[Y+3]==="n"&&X[Y+4]!=='"')J+=`
42
- `,Y+=2;if(J+=G,X[Y+2]===" ")J+="\\";Y+=1,Q=Y+1}break;default:Y+=1}}return J=Q?J+X.slice(Q):X,z?J:A0.foldFlowLines(J,G,A0.FOLD_QUOTED,m1(Z,!1))}function C4($,Z){if(Z.options.singleQuote===!1||Z.implicitKey&&$.includes(`
43
- `)||/[ \t]\n|\n[ \t]/.test($))return d$($,Z);let X=Z.indent||(d1($)?" ":""),z="'"+$.replace(/'/g,"''").replace(/\n+/g,`$&
44
- ${X}`)+"'";return Z.implicitKey?z:A0.foldFlowLines(z,X,A0.FOLD_FLOW,m1(Z,!1))}function J$($,Z){let{singleQuote:X}=Z.options,z;if(X===!1)z=d$;else{let q=$.includes('"'),G=$.includes("'");if(q&&!G)z=C4;else if(G&&!q)z=d$;else z=X?C4:d$}return z($,Z)}var E4;try{E4=new RegExp(`(^|(?<!
41
+ `;while(X[W+2]==="\\"&&X[W+3]==="n"&&X[W+4]!=='"')J+=`
42
+ `,W+=2;if(J+=z,X[W+2]===" ")J+="\\";W+=1,Q=W+1}break;default:W+=1}}return J=Q?J+X.slice(Q):X,Y?J:B$.foldFlowLines(J,z,B$.FOLD_QUOTED,J6(Z,!1))}function EX($,Z){if(Z.options.singleQuote===!1||Z.implicitKey&&$.includes(`
43
+ `)||/[ \t]\n|\n[ \t]/.test($))return y2($,Z);let X=Z.indent||(Q6($)?" ":""),Y="'"+$.replace(/'/g,"''").replace(/\n+/g,`$&
44
+ ${X}`)+"'";return Z.implicitKey?Y:B$.foldFlowLines(Y,X,B$.FOLD_FLOW,J6(Z,!1))}function P1($,Z){let{singleQuote:X}=Z.options,Y;if(X===!1)Y=y2;else{let G=$.includes('"'),z=$.includes("'");if(G&&!z)Y=EX;else if(z&&!G)Y=y2;else Y=X?EX:y2}return Y($,Z)}var RX;try{RX=new RegExp(`(^|(?<!
45
45
  ))
46
46
  +(?!
47
- |$)`,"g")}catch{E4=/\n+(?!\n|$)/g}function u1({comment:$,type:Z,value:X},z,q,G){let{blockQuote:J,commentString:Q,lineWidth:Y}=z.options;if(!J||/\n[\t ]+$/.test(X))return J$(X,z);let H=z.indent||(z.forceBlockIndent||d1(X)?" ":""),W=J==="literal"?!0:J==="folded"||Z===Q0.Scalar.BLOCK_FOLDED?!1:Z===Q0.Scalar.BLOCK_LITERAL?!0:!u3(X,Y,H.length);if(!X)return W?`|
47
+ |$)`,"g")}catch{RX=/\n+(?!\n|$)/g}function z6({comment:$,type:Z,value:X},Y,G,z){let{blockQuote:J,commentString:Q,lineWidth:W}=Y.options;if(!J||/\n[\t ]+$/.test(X))return P1(X,Y);let V=Y.indent||(Y.forceBlockIndent||Q6(X)?" ":""),K=J==="literal"?!0:J==="folded"||Z===f0.Scalar.BLOCK_FOLDED?!1:Z===f0.Scalar.BLOCK_LITERAL?!0:!AW(X,W,V.length);if(!X)return K?`|
48
48
  `:`>
49
- `;let U,V;for(V=X.length;V>0;--V){let R=X[V-1];if(R!==`
50
- `&&R!=="\t"&&R!==" ")break}let B=X.substring(V),T=B.indexOf(`
51
- `);if(T===-1)U="-";else if(X===B||T!==B.length-1){if(U="+",G)G()}else U="";if(B){if(X=X.slice(0,-B.length),B[B.length-1]===`
52
- `)B=B.slice(0,-1);B=B.replace(E4,`$&${H}`)}let K=!1,L,D=-1;for(L=0;L<X.length;++L){let R=X[L];if(R===" ")K=!0;else if(R===`
53
- `)D=L;else break}let _=X.substring(0,D<L?D+1:L);if(_)X=X.substring(_.length),_=_.replace(/\n+/g,`$&${H}`);let w=(K?H?"2":"1":"")+U;if($){if(w+=" "+Q($.replace(/ ?[\r\n]+/g," ")),q)q()}if(!W){let R=X.replace(/\n+/g,`
54
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${H}`),I=!1,C=m1(z,!0);if(J!=="folded"&&Z!==Q0.Scalar.BLOCK_FOLDED)C.onOverflow=()=>{I=!0};let M=A0.foldFlowLines(`${_}${R}${B}`,H,A0.FOLD_BLOCK,C);if(!I)return`>${w}
55
- ${H}${M}`}return X=X.replace(/\n+/g,`$&${H}`),`|${w}
56
- ${H}${_}${X}${B}`}function m3($,Z,X,z){let{type:q,value:G}=$,{actualString:J,implicitKey:Q,indent:Y,indentStep:H,inFlow:W}=Z;if(Q&&G.includes(`
57
- `)||W&&/[[\]{},]/.test(G))return J$(G,Z);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return Q||W||!G.includes(`
58
- `)?J$(G,Z):u1($,Z,X,z);if(!Q&&!W&&q!==Q0.Scalar.PLAIN&&G.includes(`
59
- `))return u1($,Z,X,z);if(d1(G)){if(Y==="")return Z.forceBlockIndent=!0,u1($,Z,X,z);else if(Q&&Y===H)return J$(G,Z)}let U=G.replace(/\n+/g,`$&
60
- ${Y}`);if(J){let V=(K)=>K.default&&K.tag!=="tag:yaml.org,2002:str"&&K.test?.test(U),{compat:B,tags:T}=Z.doc.schema;if(T.some(V)||B?.some(V))return J$(G,Z)}return Q?U:A0.foldFlowLines(U,Y,A0.FOLD_FLOW,m1(Z,!1))}function d3($,Z,X,z){let{implicitKey:q,inFlow:G}=Z,J=typeof $.value==="string"?$:Object.assign({},$,{value:String($.value)}),{type:Q}=$;if(Q!==Q0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(J.value))Q=Q0.Scalar.QUOTE_DOUBLE}let Y=(W)=>{switch(W){case Q0.Scalar.BLOCK_FOLDED:case Q0.Scalar.BLOCK_LITERAL:return q||G?J$(J.value,Z):u1(J,Z,X,z);case Q0.Scalar.QUOTE_DOUBLE:return d$(J.value,Z);case Q0.Scalar.QUOTE_SINGLE:return C4(J.value,Z);case Q0.Scalar.PLAIN:return m3(J,Z,X,z);default:return null}},H=Y(Q);if(H===null){let{defaultKeyType:W,defaultStringType:U}=Z.options,V=q&&W||U;if(H=Y(V),H===null)throw Error(`Unsupported default string type ${V}`)}return H}p3.stringifyString=d3});var l$=F((t3)=>{var c3=f1(),j0=E(),i3=m$(),a3=p$();function n3($,Z){let X=Object.assign({blockQuote:!0,commentString:i3.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},$.schema.toStringOptions,Z),z;switch(X.collectionStyle){case"block":z=!1;break;case"flow":z=!0;break;default:z=null}return{anchors:new Set,doc:$,flowCollectionPadding:X.flowCollectionPadding?" ":"",indent:"",indentStep:typeof X.indent==="number"?" ".repeat(X.indent):" ",inFlow:z,options:X}}function s3($,Z){if(Z.tag){let q=$.filter((G)=>G.tag===Z.tag);if(q.length>0)return q.find((G)=>G.format===Z.format)??q[0]}let X=void 0,z;if(j0.isScalar(Z)){z=Z.value;let q=$.filter((G)=>G.identify?.(z));if(q.length>1){let G=q.filter((J)=>J.test);if(G.length>0)q=G}X=q.find((G)=>G.format===Z.format)??q.find((G)=>!G.format)}else z=Z,X=$.find((q)=>q.nodeClass&&z instanceof q.nodeClass);if(!X){let q=z?.constructor?.name??(z===null?"null":typeof z);throw Error(`Tag not resolved for ${q} value`)}return X}function r3($,Z,{anchors:X,doc:z}){if(!z.directives)return"";let q=[],G=(j0.isScalar($)||j0.isCollection($))&&$.anchor;if(G&&c3.anchorIsValid(G))X.add(G),q.push(`&${G}`);let J=$.tag??(Z.default?null:Z.tag);if(J)q.push(z.directives.tagString(J));return q.join(" ")}function o3($,Z,X,z){if(j0.isPair($))return $.toString(Z,X,z);if(j0.isAlias($)){if(Z.doc.directives)return $.toString(Z);if(Z.resolvedAliases?.has($))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(Z.resolvedAliases)Z.resolvedAliases.add($);else Z.resolvedAliases=new Set([$]);$=$.resolve(Z.doc)}}let q=void 0,G=j0.isNode($)?$:Z.doc.createNode($,{onTagObj:(Y)=>q=Y});q??(q=s3(Z.doc.schema.tags,G));let J=r3(G,q,Z);if(J.length>0)Z.indentAtStart=(Z.indentAtStart??0)+J.length+1;let Q=typeof q.stringify==="function"?q.stringify(G,Z,X,z):j0.isScalar(G)?a3.stringifyString(G,Z,X,z):G.toString(Z,X,z);if(!J)return Q;return j0.isScalar(G)||Q[0]==="{"||Q[0]==="["?`${J} ${Q}`:`${J}
61
- ${Z.indent}${Q}`}t3.createStringifyContext=n3;t3.stringify=o3});var W6=F((X7)=>{var _0=E(),H6=g(),U6=l$(),c$=m$();function Z7({key:$,value:Z},X,z,q){let{allNullValues:G,doc:J,indent:Q,indentStep:Y,options:{commentString:H,indentSeq:W,simpleKeys:U}}=X,V=_0.isNode($)&&$.comment||null;if(U){if(V)throw Error("With simple keys, key nodes cannot have comments");if(_0.isCollection($)||!_0.isNode($)&&typeof $==="object")throw Error("With simple keys, collection cannot be used as a key value")}let B=!U&&(!$||V&&Z==null&&!X.inFlow||_0.isCollection($)||(_0.isScalar($)?$.type===H6.Scalar.BLOCK_FOLDED||$.type===H6.Scalar.BLOCK_LITERAL:typeof $==="object"));X=Object.assign({},X,{allNullValues:!1,implicitKey:!B&&(U||!G),indent:Q+Y});let T=!1,K=!1,L=U6.stringify($,X,()=>T=!0,()=>K=!0);if(!B&&!X.inFlow&&L.length>1024){if(U)throw Error("With simple keys, single line scalar must not span more than 1024 characters");B=!0}if(X.inFlow){if(G||Z==null){if(T&&z)z();return L===""?"?":B?`? ${L}`:L}}else if(G&&!U||Z==null&&B){if(L=`? ${L}`,V&&!T)L+=c$.lineComment(L,X.indent,H(V));else if(K&&q)q();return L}if(T)V=null;if(B){if(V)L+=c$.lineComment(L,X.indent,H(V));L=`? ${L}
62
- ${Q}:`}else if(L=`${L}:`,V)L+=c$.lineComment(L,X.indent,H(V));let D,_,O;if(_0.isNode(Z))D=!!Z.spaceBefore,_=Z.commentBefore,O=Z.comment;else if(D=!1,_=null,O=null,Z&&typeof Z==="object")Z=J.createNode(Z);if(X.implicitKey=!1,!B&&!V&&_0.isScalar(Z))X.indentAtStart=L.length+1;if(K=!1,!W&&Y.length>=2&&!X.inFlow&&!B&&_0.isSeq(Z)&&!Z.flow&&!Z.tag&&!Z.anchor)X.indent=X.indent.substring(2);let w=!1,R=U6.stringify(Z,X,()=>w=!0,()=>K=!0),I=" ";if(V||D||_){if(I=D?`
63
- `:"",_){let C=H(_);I+=`
64
- ${c$.indentComment(C,X.indent)}`}if(R===""&&!X.inFlow){if(I===`
65
- `&&O)I=`
49
+ `;let H,B;for(B=X.length;B>0;--B){let I=X[B-1];if(I!==`
50
+ `&&I!=="\t"&&I!==" ")break}let U=X.substring(B),F=U.indexOf(`
51
+ `);if(F===-1)H="-";else if(X===U||F!==U.length-1){if(H="+",z)z()}else H="";if(U){if(X=X.slice(0,-U.length),U[U.length-1]===`
52
+ `)U=U.slice(0,-1);U=U.replace(RX,`$&${V}`)}let T=!1,w,O=-1;for(w=0;w<X.length;++w){let I=X[w];if(I===" ")T=!0;else if(I===`
53
+ `)O=w;else break}let N=X.substring(0,O<w?O+1:w);if(N)X=X.substring(N.length),N=N.replace(/\n+/g,`$&${V}`);let E=(T?V?"2":"1":"")+H;if($){if(E+=" "+Q($.replace(/ ?[\r\n]+/g," ")),G)G()}if(!K){let I=X.replace(/\n+/g,`
54
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${V}`),A=!1,C=J6(Y,!0);if(J!=="folded"&&Z!==f0.Scalar.BLOCK_FOLDED)C.onOverflow=()=>{A=!0};let D=B$.foldFlowLines(`${N}${I}${U}`,V,B$.FOLD_BLOCK,C);if(!A)return`>${E}
55
+ ${V}${D}`}return X=X.replace(/\n+/g,`$&${V}`),`|${E}
56
+ ${V}${N}${X}${U}`}function SW($,Z,X,Y){let{type:G,value:z}=$,{actualString:J,implicitKey:Q,indent:W,indentStep:V,inFlow:K}=Z;if(Q&&z.includes(`
57
+ `)||K&&/[[\]{},]/.test(z))return P1(z,Z);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(z))return Q||K||!z.includes(`
58
+ `)?P1(z,Z):z6($,Z,X,Y);if(!Q&&!K&&G!==f0.Scalar.PLAIN&&z.includes(`
59
+ `))return z6($,Z,X,Y);if(Q6(z)){if(W==="")return Z.forceBlockIndent=!0,z6($,Z,X,Y);else if(Q&&W===V)return P1(z,Z)}let H=z.replace(/\n+/g,`$&
60
+ ${W}`);if(J){let B=(T)=>T.default&&T.tag!=="tag:yaml.org,2002:str"&&T.test?.test(H),{compat:U,tags:F}=Z.doc.schema;if(F.some(B)||U?.some(B))return P1(z,Z)}return Q?H:B$.foldFlowLines(H,W,B$.FOLD_FLOW,J6(Z,!1))}function CW($,Z,X,Y){let{implicitKey:G,inFlow:z}=Z,J=typeof $.value==="string"?$:Object.assign({},$,{value:String($.value)}),{type:Q}=$;if(Q!==f0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(J.value))Q=f0.Scalar.QUOTE_DOUBLE}let W=(K)=>{switch(K){case f0.Scalar.BLOCK_FOLDED:case f0.Scalar.BLOCK_LITERAL:return G||z?P1(J.value,Z):z6(J,Z,X,Y);case f0.Scalar.QUOTE_DOUBLE:return y2(J.value,Z);case f0.Scalar.QUOTE_SINGLE:return EX(J.value,Z);case f0.Scalar.PLAIN:return SW(J,Z,X,Y);default:return null}},V=W(Q);if(V===null){let{defaultKeyType:K,defaultStringType:H}=Z.options,B=G&&K||H;if(V=W(B),V===null)throw Error(`Unsupported default string type ${B}`)}return V}IW.stringifyString=CW});var v2=R((hW)=>{var xW=Z6(),U$=m(),kW=f2(),bW=g2();function fW($,Z){let X=Object.assign({blockQuote:!0,commentString:kW.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},$.schema.toStringOptions,Z),Y;switch(X.collectionStyle){case"block":Y=!1;break;case"flow":Y=!0;break;default:Y=null}return{anchors:new Set,doc:$,flowCollectionPadding:X.flowCollectionPadding?" ":"",indent:"",indentStep:typeof X.indent==="number"?" ".repeat(X.indent):" ",inFlow:Y,options:X}}function yW($,Z){if(Z.tag){let G=$.filter((z)=>z.tag===Z.tag);if(G.length>0)return G.find((z)=>z.format===Z.format)??G[0]}let X=void 0,Y;if(U$.isScalar(Z)){Y=Z.value;let G=$.filter((z)=>z.identify?.(Y));if(G.length>1){let z=G.filter((J)=>J.test);if(z.length>0)G=z}X=G.find((z)=>z.format===Z.format)??G.find((z)=>!z.format)}else Y=Z,X=$.find((G)=>G.nodeClass&&Y instanceof G.nodeClass);if(!X){let G=Y?.constructor?.name??(Y===null?"null":typeof Y);throw Error(`Tag not resolved for ${G} value`)}return X}function gW($,Z,{anchors:X,doc:Y}){if(!Y.directives)return"";let G=[],z=(U$.isScalar($)||U$.isCollection($))&&$.anchor;if(z&&xW.anchorIsValid(z))X.add(z),G.push(`&${z}`);let J=$.tag??(Z.default?null:Z.tag);if(J)G.push(Y.directives.tagString(J));return G.join(" ")}function vW($,Z,X,Y){if(U$.isPair($))return $.toString(Z,X,Y);if(U$.isAlias($)){if(Z.doc.directives)return $.toString(Z);if(Z.resolvedAliases?.has($))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(Z.resolvedAliases)Z.resolvedAliases.add($);else Z.resolvedAliases=new Set([$]);$=$.resolve(Z.doc)}}let G=void 0,z=U$.isNode($)?$:Z.doc.createNode($,{onTagObj:(W)=>G=W});G??(G=yW(Z.doc.schema.tags,z));let J=gW(z,G,Z);if(J.length>0)Z.indentAtStart=(Z.indentAtStart??0)+J.length+1;let Q=typeof G.stringify==="function"?G.stringify(z,Z,X,Y):U$.isScalar(z)?bW.stringifyString(z,Z,X,Y):z.toString(Z,X,Y);if(!J)return Q;return U$.isScalar(z)||Q[0]==="{"||Q[0]==="["?`${J} ${Q}`:`${J}
61
+ ${Z.indent}${Q}`}hW.createStringifyContext=fW;hW.stringify=vW});var p3=R((cW)=>{var t0=m(),c3=o(),l3=v2(),h2=f2();function dW({key:$,value:Z},X,Y,G){let{allNullValues:z,doc:J,indent:Q,indentStep:W,options:{commentString:V,indentSeq:K,simpleKeys:H}}=X,B=t0.isNode($)&&$.comment||null;if(H){if(B)throw Error("With simple keys, key nodes cannot have comments");if(t0.isCollection($)||!t0.isNode($)&&typeof $==="object")throw Error("With simple keys, collection cannot be used as a key value")}let U=!H&&(!$||B&&Z==null&&!X.inFlow||t0.isCollection($)||(t0.isScalar($)?$.type===c3.Scalar.BLOCK_FOLDED||$.type===c3.Scalar.BLOCK_LITERAL:typeof $==="object"));X=Object.assign({},X,{allNullValues:!1,implicitKey:!U&&(H||!z),indent:Q+W});let F=!1,T=!1,w=l3.stringify($,X,()=>F=!0,()=>T=!0);if(!U&&!X.inFlow&&w.length>1024){if(H)throw Error("With simple keys, single line scalar must not span more than 1024 characters");U=!0}if(X.inFlow){if(z||Z==null){if(F&&Y)Y();return w===""?"?":U?`? ${w}`:w}}else if(z&&!H||Z==null&&U){if(w=`? ${w}`,B&&!F)w+=h2.lineComment(w,X.indent,V(B));else if(T&&G)G();return w}if(F)B=null;if(U){if(B)w+=h2.lineComment(w,X.indent,V(B));w=`? ${w}
62
+ ${Q}:`}else if(w=`${w}:`,B)w+=h2.lineComment(w,X.indent,V(B));let O,N,P;if(t0.isNode(Z))O=!!Z.spaceBefore,N=Z.commentBefore,P=Z.comment;else if(O=!1,N=null,P=null,Z&&typeof Z==="object")Z=J.createNode(Z);if(X.implicitKey=!1,!U&&!B&&t0.isScalar(Z))X.indentAtStart=w.length+1;if(T=!1,!K&&W.length>=2&&!X.inFlow&&!U&&t0.isSeq(Z)&&!Z.flow&&!Z.tag&&!Z.anchor)X.indent=X.indent.substring(2);let E=!1,I=l3.stringify(Z,X,()=>E=!0,()=>T=!0),A=" ";if(B||O||N){if(A=O?`
63
+ `:"",N){let C=V(N);A+=`
64
+ ${h2.indentComment(C,X.indent)}`}if(I===""&&!X.inFlow){if(A===`
65
+ `&&P)A=`
66
66
 
67
- `}else I+=`
68
- ${X.indent}`}else if(!B&&_0.isCollection(Z)){let C=R[0],M=R.indexOf(`
69
- `),y=M!==-1,p=X.inFlow??Z.flow??Z.items.length===0;if(y||!p){let s=!1;if(y&&(C==="&"||C==="!")){let k=R.indexOf(" ");if(C==="&"&&k!==-1&&k<M&&R[k+1]==="!")k=R.indexOf(" ",k+1);if(k===-1||M<k)s=!0}if(!s)I=`
70
- ${X.indent}`}}else if(R===""||R[0]===`
71
- `)I="";if(L+=I+R,X.inFlow){if(w&&z)z()}else if(O&&!w)L+=c$.lineComment(L,X.indent,H(O));else if(K&&q)q();return L}X7.stringifyPair=Z7});var b4=F((J7)=>{var V6=L0("process");function q7($,...Z){if($==="debug")console.log(...Z)}function G7($,Z){if($==="debug"||$==="warn")if(typeof V6.emitWarning==="function")V6.emitWarning(Z);else console.warn(Z)}J7.debug=q7;J7.warn=G7});var c1=F((U7)=>{var i$=E(),K6=g(),p1="<<",l1={identify:($)=>$===p1||typeof $==="symbol"&&$.description===p1,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new K6.Scalar(Symbol(p1)),{addToJSMap:B6}),stringify:()=>p1},H7=($,Z)=>(l1.identify(Z)||i$.isScalar(Z)&&(!Z.type||Z.type===K6.Scalar.PLAIN)&&l1.identify(Z.value))&&$?.doc.schema.tags.some((X)=>X.tag===l1.tag&&X.default);function B6($,Z,X){if(X=$&&i$.isAlias(X)?X.resolve($.doc):X,i$.isSeq(X))for(let z of X.items)y4($,Z,z);else if(Array.isArray(X))for(let z of X)y4($,Z,z);else y4($,Z,X)}function y4($,Z,X){let z=$&&i$.isAlias(X)?X.resolve($.doc):X;if(!i$.isMap(z))throw Error("Merge sources must be maps or map aliases");let q=z.toJSON(null,$,Map);for(let[G,J]of q)if(Z instanceof Map){if(!Z.has(G))Z.set(G,J)}else if(Z instanceof Set)Z.add(G);else if(!Object.prototype.hasOwnProperty.call(Z,G))Object.defineProperty(Z,G,{value:J,writable:!0,enumerable:!0,configurable:!0});return Z}U7.addMergeToJSMap=B6;U7.isMergeKey=H7;U7.merge=l1});var k4=F((_7)=>{var B7=b4(),L6=c1(),L7=l$(),T6=E(),x4=R0();function T7($,Z,{key:X,value:z}){if(T6.isNode(X)&&X.addToJSMap)X.addToJSMap($,Z,z);else if(L6.isMergeKey($,X))L6.addMergeToJSMap($,Z,z);else{let q=x4.toJS(X,"",$);if(Z instanceof Map)Z.set(q,x4.toJS(z,q,$));else if(Z instanceof Set)Z.add(q);else{let G=D7(X,q,$),J=x4.toJS(z,G,$);if(G in Z)Object.defineProperty(Z,G,{value:J,writable:!0,enumerable:!0,configurable:!0});else Z[G]=J}}return Z}function D7($,Z,X){if(Z===null)return"";if(typeof Z!=="object")return String(Z);if(T6.isNode($)&&X?.doc){let z=L7.createStringifyContext(X.doc,{});z.anchors=new Set;for(let G of X.anchors.keys())z.anchors.add(G.anchor);z.inFlow=!0,z.inStringifyKey=!0;let q=$.toString(z);if(!X.mapKeyWarned){let G=JSON.stringify(q);if(G.length>40)G=G.substring(0,36)+'..."';B7.warn(X.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),X.mapKeyWarned=!0}return q}return JSON.stringify(Z)}_7.addPairToJSMap=T7});var N0=F((P7)=>{var D6=u$(),M7=W6(),O7=k4(),i1=E();function w7($,Z,X){let z=D6.createNode($,void 0,X),q=D6.createNode(Z,void 0,X);return new a1(z,q)}class a1{constructor($,Z=null){Object.defineProperty(this,i1.NODE_TYPE,{value:i1.PAIR}),this.key=$,this.value=Z}clone($){let{key:Z,value:X}=this;if(i1.isNode(Z))Z=Z.clone($);if(i1.isNode(X))X=X.clone($);return new a1(Z,X)}toJSON($,Z){let X=Z?.mapAsMap?new Map:{};return O7.addPairToJSMap(Z,X,this)}toString($,Z,X){return $?.doc?M7.stringifyPair(this,$,Z,X):JSON.stringify(this)}}P7.Pair=a1;P7.createPair=w7});var f4=F((S7)=>{var l0=E(),_6=l$(),n1=m$();function A7($,Z,X){return(Z.inFlow??$.flow?N7:j7)($,Z,X)}function j7({comment:$,items:Z},X,{blockItemPrefix:z,flowChars:q,itemIndent:G,onChompKeep:J,onComment:Q}){let{indent:Y,options:{commentString:H}}=X,W=Object.assign({},X,{indent:G,type:null}),U=!1,V=[];for(let T=0;T<Z.length;++T){let K=Z[T],L=null;if(l0.isNode(K)){if(!U&&K.spaceBefore)V.push("");if(s1(X,V,K.commentBefore,U),K.comment)L=K.comment}else if(l0.isPair(K)){let _=l0.isNode(K.key)?K.key:null;if(_){if(!U&&_.spaceBefore)V.push("");s1(X,V,_.commentBefore,U)}}U=!1;let D=_6.stringify(K,W,()=>L=null,()=>U=!0);if(L)D+=n1.lineComment(D,G,H(L));if(U&&L)U=!1;V.push(z+D)}let B;if(V.length===0)B=q.start+q.end;else{B=V[0];for(let T=1;T<V.length;++T){let K=V[T];B+=K?`
72
- ${Y}${K}`:`
73
- `}}if($){if(B+=`
74
- `+n1.indentComment(H($),Y),Q)Q()}else if(U&&J)J();return B}function N7({items:$},Z,{flowChars:X,itemIndent:z}){let{indent:q,indentStep:G,flowCollectionPadding:J,options:{commentString:Q}}=Z;z+=G;let Y=Object.assign({},Z,{indent:z,inFlow:!0,type:null}),H=!1,W=0,U=[];for(let T=0;T<$.length;++T){let K=$[T],L=null;if(l0.isNode(K)){if(K.spaceBefore)U.push("");if(s1(Z,U,K.commentBefore,!1),K.comment)L=K.comment}else if(l0.isPair(K)){let _=l0.isNode(K.key)?K.key:null;if(_){if(_.spaceBefore)U.push("");if(s1(Z,U,_.commentBefore,!1),_.comment)H=!0}let O=l0.isNode(K.value)?K.value:null;if(O){if(O.comment)L=O.comment;if(O.commentBefore)H=!0}else if(K.value==null&&_?.comment)L=_.comment}if(L)H=!0;let D=_6.stringify(K,Y,()=>L=null);if(T<$.length-1)D+=",";if(L)D+=n1.lineComment(D,z,Q(L));if(!H&&(U.length>W||D.includes(`
75
- `)))H=!0;U.push(D),W=U.length}let{start:V,end:B}=X;if(U.length===0)return V+B;else{if(!H){let T=U.reduce((K,L)=>K+L.length+2,2);H=Z.options.lineWidth>0&&T>Z.options.lineWidth}if(H){let T=V;for(let K of U)T+=K?`
76
- ${G}${q}${K}`:`
77
- `;return`${T}
78
- ${q}${B}`}else return`${V}${J}${U.join(" ")}${J}${B}`}}function s1({indent:$,options:{commentString:Z}},X,z,q){if(z&&q)z=z.replace(/^\n+/,"");if(z){let G=n1.indentComment(Z(z),$);X.push(G.trimStart())}}S7.stringifyCollection=A7});var C0=F((k7)=>{var E7=f4(),b7=k4(),y7=v1(),S0=E(),r1=N0(),x7=g();function a$($,Z){let X=S0.isScalar(Z)?Z.value:Z;for(let z of $)if(S0.isPair(z)){if(z.key===Z||z.key===X)return z;if(S0.isScalar(z.key)&&z.key.value===X)return z}return}class F6 extends y7.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor($){super(S0.MAP,$);this.items=[]}static from($,Z,X){let{keepUndefined:z,replacer:q}=X,G=new this($),J=(Q,Y)=>{if(typeof q==="function")Y=q.call(Z,Q,Y);else if(Array.isArray(q)&&!q.includes(Q))return;if(Y!==void 0||z)G.items.push(r1.createPair(Q,Y,X))};if(Z instanceof Map)for(let[Q,Y]of Z)J(Q,Y);else if(Z&&typeof Z==="object")for(let Q of Object.keys(Z))J(Q,Z[Q]);if(typeof $.sortMapEntries==="function")G.items.sort($.sortMapEntries);return G}add($,Z){let X;if(S0.isPair($))X=$;else if(!$||typeof $!=="object"||!("key"in $))X=new r1.Pair($,$?.value);else X=new r1.Pair($.key,$.value);let z=a$(this.items,X.key),q=this.schema?.sortMapEntries;if(z){if(!Z)throw Error(`Key ${X.key} already set`);if(S0.isScalar(z.value)&&x7.isScalarValue(X.value))z.value.value=X.value;else z.value=X.value}else if(q){let G=this.items.findIndex((J)=>q(X,J)<0);if(G===-1)this.items.push(X);else this.items.splice(G,0,X)}else this.items.push(X)}delete($){let Z=a$(this.items,$);if(!Z)return!1;return this.items.splice(this.items.indexOf(Z),1).length>0}get($,Z){let z=a$(this.items,$)?.value;return(!Z&&S0.isScalar(z)?z.value:z)??void 0}has($){return!!a$(this.items,$)}set($,Z){this.add(new r1.Pair($,Z),!0)}toJSON($,Z,X){let z=X?new X:Z?.mapAsMap?new Map:{};if(Z?.onCreate)Z.onCreate(z);for(let q of this.items)b7.addPairToJSMap(Z,z,q);return z}toString($,Z,X){if(!$)return JSON.stringify(this);for(let z of this.items)if(!S0.isPair(z))throw Error(`Map items must all be pairs; found ${JSON.stringify(z)} instead`);if(!$.allNullValues&&this.hasAllNullValues(!1))$=Object.assign({},$,{allNullValues:!0});return E7.stringifyCollection(this,$,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:$.indent||"",onChompKeep:X,onComment:Z})}}k7.YAMLMap=F6;k7.findPair=a$});var Q$=F((u7)=>{var g7=E(),M6=C0(),v7={collection:"map",default:!0,nodeClass:M6.YAMLMap,tag:"tag:yaml.org,2002:map",resolve($,Z){if(!g7.isMap($))Z("Expected a mapping for this tag");return $},createNode:($,Z,X)=>M6.YAMLMap.from($,Z,X)};u7.map=v7});var E0=F((a7)=>{var d7=u$(),p7=f4(),l7=v1(),t1=E(),c7=g(),i7=R0();class O6 extends l7.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor($){super(t1.SEQ,$);this.items=[]}add($){this.items.push($)}delete($){let Z=o1($);if(typeof Z!=="number")return!1;return this.items.splice(Z,1).length>0}get($,Z){let X=o1($);if(typeof X!=="number")return;let z=this.items[X];return!Z&&t1.isScalar(z)?z.value:z}has($){let Z=o1($);return typeof Z==="number"&&Z<this.items.length}set($,Z){let X=o1($);if(typeof X!=="number")throw Error(`Expected a valid index, not ${$}.`);let z=this.items[X];if(t1.isScalar(z)&&c7.isScalarValue(Z))z.value=Z;else this.items[X]=Z}toJSON($,Z){let X=[];if(Z?.onCreate)Z.onCreate(X);let z=0;for(let q of this.items)X.push(i7.toJS(q,String(z++),Z));return X}toString($,Z,X){if(!$)return JSON.stringify(this);return p7.stringifyCollection(this,$,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:($.indent||"")+" ",onChompKeep:X,onComment:Z})}static from($,Z,X){let{replacer:z}=X,q=new this($);if(Z&&Symbol.iterator in Object(Z)){let G=0;for(let J of Z){if(typeof z==="function"){let Q=Z instanceof Set?J:String(G++);J=z.call(Z,Q,J)}q.items.push(d7.createNode(J,void 0,X))}}return q}}function o1($){let Z=t1.isScalar($)?$.value:$;if(Z&&typeof Z==="string")Z=Number(Z);return typeof Z==="number"&&Number.isInteger(Z)&&Z>=0?Z:null}a7.YAMLSeq=O6});var Y$=F((o7)=>{var s7=E(),w6=E0(),r7={collection:"seq",default:!0,nodeClass:w6.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve($,Z){if(!s7.isSeq($))Z("Expected a sequence for this tag");return $},createNode:($,Z,X)=>w6.YAMLSeq.from($,Z,X)};o7.seq=r7});var n$=F((Zq)=>{var e7=p$(),$q={identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify($,Z,X,z){return Z=Object.assign({actualString:!0},Z),e7.stringifyString($,Z,X,z)}};Zq.string=$q});var e1=F((zq)=>{var P6=g(),I6={identify:($)=>$==null,createNode:()=>new P6.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new P6.Scalar(null),stringify:({source:$},Z)=>typeof $==="string"&&I6.test.test($)?$:Z.options.nullStr};zq.nullTag=I6});var h4=F((Jq)=>{var Gq=g(),R6={identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:($)=>new Gq.Scalar($[0]==="t"||$[0]==="T"),stringify({source:$,value:Z},X){if($&&R6.test.test($)){let z=$[0]==="t"||$[0]==="T";if(Z===z)return $}return Z?X.options.trueStr:X.options.falseStr}};Jq.boolTag=R6});var H$=F((Hq)=>{function Yq({format:$,minFractionDigits:Z,tag:X,value:z}){if(typeof z==="bigint")return String(z);let q=typeof z==="number"?z:Number(z);if(!isFinite(q))return isNaN(q)?".nan":q<0?"-.inf":".inf";let G=Object.is(z,-0)?"-0":JSON.stringify(z);if(!$&&Z&&(!X||X==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let J=G.indexOf(".");if(J<0)J=G.length,G+=".";let Q=Z-(G.length-J-1);while(Q-- >0)G+="0"}return G}Hq.stringifyNumber=Yq});var v4=F((Lq)=>{var Wq=g(),g4=H$(),Vq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:g4.stringifyNumber},Kq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($),stringify($){let Z=Number($.value);return isFinite(Z)?Z.toExponential():g4.stringifyNumber($)}},Bq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve($){let Z=new Wq.Scalar(parseFloat($)),X=$.indexOf(".");if(X!==-1&&$[$.length-1]==="0")Z.minFractionDigits=$.length-X-1;return Z},stringify:g4.stringifyNumber};Lq.float=Bq;Lq.floatExp=Kq;Lq.floatNaN=Vq});var m4=F((wq)=>{var A6=H$(),$2=($)=>typeof $==="bigint"||Number.isInteger($),u4=($,Z,X,{intAsBigInt:z})=>z?BigInt($):parseInt($.substring(Z),X);function j6($,Z,X){let{value:z}=$;if($2(z)&&z>=0)return X+z.toString(Z);return A6.stringifyNumber($)}var Fq={identify:($)=>$2($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:($,Z,X)=>u4($,2,8,X),stringify:($)=>j6($,8,"0o")},Mq={identify:$2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:($,Z,X)=>u4($,0,10,X),stringify:A6.stringifyNumber},Oq={identify:($)=>$2($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:($,Z,X)=>u4($,2,16,X),stringify:($)=>j6($,16,"0x")};wq.int=Mq;wq.intHex=Oq;wq.intOct=Fq});var N6=F((bq)=>{var Aq=Q$(),jq=e1(),Nq=Y$(),Sq=n$(),Cq=h4(),d4=v4(),p4=m4(),Eq=[Aq.map,Nq.seq,Sq.string,jq.nullTag,Cq.boolTag,p4.intOct,p4.int,p4.intHex,d4.floatNaN,d4.floatExp,d4.float];bq.schema=Eq});var C6=F((uq)=>{var xq=g(),kq=Q$(),fq=Y$();function S6($){return typeof $==="bigint"||Number.isInteger($)}var Z2=({value:$})=>JSON.stringify($),hq=[{identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify:Z2},{identify:($)=>$==null,createNode:()=>new xq.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Z2},{identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:($)=>$==="true",stringify:Z2},{identify:S6,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:($,Z,{intAsBigInt:X})=>X?BigInt($):parseInt($,10),stringify:({value:$})=>S6($)?$.toString():JSON.stringify($)},{identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:($)=>parseFloat($),stringify:Z2}],gq={default:!0,tag:"",test:/^/,resolve($,Z){return Z(`Unresolved plain scalar ${JSON.stringify($)}`),$}},vq=[kq.map,fq.seq].concat(hq,gq);uq.schema=vq});var c4=F((lq)=>{var s$=L0("buffer"),l4=g(),dq=p$(),pq={identify:($)=>$ instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve($,Z){if(typeof s$.Buffer==="function")return s$.Buffer.from($,"base64");else if(typeof atob==="function"){let X=atob($.replace(/[\n\r]/g,"")),z=new Uint8Array(X.length);for(let q=0;q<X.length;++q)z[q]=X.charCodeAt(q);return z}else return Z("This environment does not support reading binary tags; either Buffer or atob is required"),$},stringify({comment:$,type:Z,value:X},z,q,G){if(!X)return"";let J=X,Q;if(typeof s$.Buffer==="function")Q=J instanceof s$.Buffer?J.toString("base64"):s$.Buffer.from(J.buffer).toString("base64");else if(typeof btoa==="function"){let Y="";for(let H=0;H<J.length;++H)Y+=String.fromCharCode(J[H]);Q=btoa(Y)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(Z??(Z=l4.Scalar.BLOCK_LITERAL),Z!==l4.Scalar.QUOTE_DOUBLE){let Y=Math.max(z.options.lineWidth-z.indent.length,z.options.minContentWidth),H=Math.ceil(Q.length/Y),W=Array(H);for(let U=0,V=0;U<H;++U,V+=Y)W[U]=Q.substr(V,Y);Q=W.join(Z===l4.Scalar.BLOCK_LITERAL?`
79
- `:" ")}return dq.stringifyString({comment:$,type:Z,value:Q},z,q,G)}};lq.binary=pq});var z2=F((sq)=>{var X2=E(),i4=N0(),iq=g(),aq=E0();function E6($,Z){if(X2.isSeq($))for(let X=0;X<$.items.length;++X){let z=$.items[X];if(X2.isPair(z))continue;else if(X2.isMap(z)){if(z.items.length>1)Z("Each pair must have its own sequence indicator");let q=z.items[0]||new i4.Pair(new iq.Scalar(null));if(z.commentBefore)q.key.commentBefore=q.key.commentBefore?`${z.commentBefore}
80
- ${q.key.commentBefore}`:z.commentBefore;if(z.comment){let G=q.value??q.key;G.comment=G.comment?`${z.comment}
81
- ${G.comment}`:z.comment}z=q}$.items[X]=X2.isPair(z)?z:new i4.Pair(z)}else Z("Expected a sequence for this tag");return $}function b6($,Z,X){let{replacer:z}=X,q=new aq.YAMLSeq($);q.tag="tag:yaml.org,2002:pairs";let G=0;if(Z&&Symbol.iterator in Object(Z))for(let J of Z){if(typeof z==="function")J=z.call(Z,String(G++),J);let Q,Y;if(Array.isArray(J))if(J.length===2)Q=J[0],Y=J[1];else throw TypeError(`Expected [key, value] tuple: ${J}`);else if(J&&J instanceof Object){let H=Object.keys(J);if(H.length===1)Q=H[0],Y=J[Q];else throw TypeError(`Expected tuple with one key, not ${H.length} keys`)}else Q=J;q.items.push(i4.createPair(Q,Y,X))}return q}var nq={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:E6,createNode:b6};sq.createPairs=b6;sq.pairs=nq;sq.resolvePairs=E6});var n4=F((ZG)=>{var y6=E(),a4=R0(),r$=C0(),eq=E0(),x6=z2();class c0 extends eq.YAMLSeq{constructor(){super();this.add=r$.YAMLMap.prototype.add.bind(this),this.delete=r$.YAMLMap.prototype.delete.bind(this),this.get=r$.YAMLMap.prototype.get.bind(this),this.has=r$.YAMLMap.prototype.has.bind(this),this.set=r$.YAMLMap.prototype.set.bind(this),this.tag=c0.tag}toJSON($,Z){if(!Z)return super.toJSON($);let X=new Map;if(Z?.onCreate)Z.onCreate(X);for(let z of this.items){let q,G;if(y6.isPair(z))q=a4.toJS(z.key,"",Z),G=a4.toJS(z.value,q,Z);else q=a4.toJS(z,"",Z);if(X.has(q))throw Error("Ordered maps must not include duplicate keys");X.set(q,G)}return X}static from($,Z,X){let z=x6.createPairs($,Z,X),q=new this;return q.items=z.items,q}}c0.tag="tag:yaml.org,2002:omap";var $G={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:c0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,Z){let X=x6.resolvePairs($,Z),z=[];for(let{key:q}of X.items)if(y6.isScalar(q))if(z.includes(q.value))Z(`Ordered maps must not include duplicate keys: ${q.value}`);else z.push(q.value);return Object.assign(new c0,X)},createNode:($,Z,X)=>c0.from($,Z,X)};ZG.YAMLOMap=c0;ZG.omap=$G});var v6=F((qG)=>{var k6=g();function f6({value:$,source:Z},X){if(Z&&($?h6:g6).test.test(Z))return Z;return $?X.options.trueStr:X.options.falseStr}var h6={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new k6.Scalar(!0),stringify:f6},g6={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new k6.Scalar(!1),stringify:f6};qG.falseTag=g6;qG.trueTag=h6});var u6=F((WG)=>{var QG=g(),s4=H$(),YG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:s4.stringifyNumber},HG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($.replace(/_/g,"")),stringify($){let Z=Number($.value);return isFinite(Z)?Z.toExponential():s4.stringifyNumber($)}},UG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let Z=new QG.Scalar(parseFloat($.replace(/_/g,""))),X=$.indexOf(".");if(X!==-1){let z=$.substring(X+1).replace(/_/g,"");if(z[z.length-1]==="0")Z.minFractionDigits=z.length}return Z},stringify:s4.stringifyNumber};WG.float=UG;WG.floatExp=HG;WG.floatNaN=YG});var d6=F((FG)=>{var m6=H$(),o$=($)=>typeof $==="bigint"||Number.isInteger($);function q2($,Z,X,{intAsBigInt:z}){let q=$[0];if(q==="-"||q==="+")Z+=1;if($=$.substring(Z).replace(/_/g,""),z){switch(X){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let J=BigInt($);return q==="-"?BigInt(-1)*J:J}let G=parseInt($,X);return q==="-"?-1*G:G}function r4($,Z,X){let{value:z}=$;if(o$(z)){let q=z.toString(Z);return z<0?"-"+X+q.substr(1):X+q}return m6.stringifyNumber($)}var LG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,Z,X)=>q2($,2,2,X),stringify:($)=>r4($,2,"0b")},TG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,Z,X)=>q2($,1,8,X),stringify:($)=>r4($,8,"0")},DG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,Z,X)=>q2($,0,10,X),stringify:m6.stringifyNumber},_G={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,Z,X)=>q2($,2,16,X),stringify:($)=>r4($,16,"0x")};FG.int=DG;FG.intBin=LG;FG.intHex=_G;FG.intOct=TG});var o4=F((RG)=>{var Q2=E(),G2=N0(),J2=C0();class i0 extends J2.YAMLMap{constructor($){super($);this.tag=i0.tag}add($){let Z;if(Q2.isPair($))Z=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)Z=new G2.Pair($.key,null);else Z=new G2.Pair($,null);if(!J2.findPair(this.items,Z.key))this.items.push(Z)}get($,Z){let X=J2.findPair(this.items,$);return!Z&&Q2.isPair(X)?Q2.isScalar(X.key)?X.key.value:X.key:X}set($,Z){if(typeof Z!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof Z}`);let X=J2.findPair(this.items,$);if(X&&!Z)this.items.splice(this.items.indexOf(X),1);else if(!X&&Z)this.items.push(new G2.Pair($))}toJSON($,Z){return super.toJSON($,Z,Set)}toString($,Z,X){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),Z,X);else throw Error("Set items must all have null values")}static from($,Z,X){let{replacer:z}=X,q=new this($);if(Z&&Symbol.iterator in Object(Z))for(let G of Z){if(typeof z==="function")G=z.call(Z,G,G);q.items.push(G2.createPair(G,null,X))}return q}}i0.tag="tag:yaml.org,2002:set";var IG={collection:"map",identify:($)=>$ instanceof Set,nodeClass:i0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,Z,X)=>i0.from($,Z,X),resolve($,Z){if(Q2.isMap($))if($.hasAllNullValues(!0))return Object.assign(new i0,$);else Z("Set items must all have null values");else Z("Expected a mapping for this tag");return $}};RG.YAMLSet=i0;RG.set=IG});var e4=F((EG)=>{var NG=H$();function t4($,Z){let X=$[0],z=X==="-"||X==="+"?$.substring(1):$,q=(J)=>Z?BigInt(J):Number(J),G=z.replace(/_/g,"").split(":").reduce((J,Q)=>J*q(60)+q(Q),q(0));return X==="-"?q(-1)*G:G}function p6($){let{value:Z}=$,X=(J)=>J;if(typeof Z==="bigint")X=(J)=>BigInt(J);else if(isNaN(Z)||!isFinite(Z))return NG.stringifyNumber($);let z="";if(Z<0)z="-",Z*=X(-1);let q=X(60),G=[Z%q];if(Z<60)G.unshift(0);else if(Z=(Z-G[0])/q,G.unshift(Z%q),Z>=60)Z=(Z-G[0])/q,G.unshift(Z);return z+G.map((J)=>String(J).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var SG={identify:($)=>typeof $==="bigint"||Number.isInteger($),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:($,Z,{intAsBigInt:X})=>t4($,X),stringify:p6},CG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:($)=>t4($,!1),stringify:p6},l6={identify:($)=>$ instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve($){let Z=$.match(l6.test);if(!Z)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,X,z,q,G,J,Q]=Z.map(Number),Y=Z[7]?Number((Z[7]+"00").substr(1,3)):0,H=Date.UTC(X,z-1,q,G||0,J||0,Q||0,Y),W=Z[8];if(W&&W!=="Z"){let U=t4(W,!1);if(Math.abs(U)<30)U*=60;H-=60000*U}return new Date(H)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};EG.floatTime=CG;EG.intTime=SG;EG.timestamp=l6});var i6=F((cG)=>{var kG=Q$(),fG=e1(),hG=Y$(),gG=n$(),vG=c4(),c6=v6(),$9=u6(),Y2=d6(),uG=c1(),mG=n4(),dG=z2(),pG=o4(),Z9=e4(),lG=[kG.map,hG.seq,gG.string,fG.nullTag,c6.trueTag,c6.falseTag,Y2.intBin,Y2.intOct,Y2.int,Y2.intHex,$9.floatNaN,$9.floatExp,$9.float,vG.binary,uG.merge,mG.omap,dG.pairs,pG.set,Z9.intTime,Z9.floatTime,Z9.timestamp];cG.schema=lG});var X8=F(($J)=>{var r6=Q$(),aG=e1(),o6=Y$(),nG=n$(),sG=h4(),X9=v4(),z9=m4(),rG=N6(),oG=C6(),t6=c4(),t$=c1(),e6=n4(),$8=z2(),a6=i6(),Z8=o4(),H2=e4(),n6=new Map([["core",rG.schema],["failsafe",[r6.map,o6.seq,nG.string]],["json",oG.schema],["yaml11",a6.schema],["yaml-1.1",a6.schema]]),s6={binary:t6.binary,bool:sG.boolTag,float:X9.float,floatExp:X9.floatExp,floatNaN:X9.floatNaN,floatTime:H2.floatTime,int:z9.int,intHex:z9.intHex,intOct:z9.intOct,intTime:H2.intTime,map:r6.map,merge:t$.merge,null:aG.nullTag,omap:e6.omap,pairs:$8.pairs,seq:o6.seq,set:Z8.set,timestamp:H2.timestamp},tG={"tag:yaml.org,2002:binary":t6.binary,"tag:yaml.org,2002:merge":t$.merge,"tag:yaml.org,2002:omap":e6.omap,"tag:yaml.org,2002:pairs":$8.pairs,"tag:yaml.org,2002:set":Z8.set,"tag:yaml.org,2002:timestamp":H2.timestamp};function eG($,Z,X){let z=n6.get(Z);if(z&&!$)return X&&!z.includes(t$.merge)?z.concat(t$.merge):z.slice();let q=z;if(!q)if(Array.isArray($))q=[];else{let G=Array.from(n6.keys()).filter((J)=>J!=="yaml11").map((J)=>JSON.stringify(J)).join(", ");throw Error(`Unknown schema "${Z}"; use one of ${G} or define customTags array`)}if(Array.isArray($))for(let G of $)q=q.concat(G);else if(typeof $==="function")q=$(q.slice());if(X)q=q.concat(t$.merge);return q.reduce((G,J)=>{let Q=typeof J==="string"?s6[J]:J;if(!Q){let Y=JSON.stringify(J),H=Object.keys(s6).map((W)=>JSON.stringify(W)).join(", ");throw Error(`Unknown custom tag ${Y}; use one of ${H}`)}if(!G.includes(Q))G.push(Q);return G},[])}$J.coreKnownTags=tG;$J.getTags=eG});var J9=F((QJ)=>{var q9=E(),zJ=Q$(),qJ=Y$(),GJ=n$(),U2=X8(),JJ=($,Z)=>$.key<Z.key?-1:$.key>Z.key?1:0;class G9{constructor({compat:$,customTags:Z,merge:X,resolveKnownTags:z,schema:q,sortMapEntries:G,toStringDefaults:J}){this.compat=Array.isArray($)?U2.getTags($,"compat"):$?U2.getTags(null,$):null,this.name=typeof q==="string"&&q||"core",this.knownTags=z?U2.coreKnownTags:{},this.tags=U2.getTags(Z,this.name,X),this.toStringOptions=J??null,Object.defineProperty(this,q9.MAP,{value:zJ.map}),Object.defineProperty(this,q9.SCALAR,{value:GJ.string}),Object.defineProperty(this,q9.SEQ,{value:qJ.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?JJ:null}clone(){let $=Object.create(G9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}QJ.Schema=G9});var z8=F((WJ)=>{var HJ=E(),Q9=l$(),e$=m$();function UJ($,Z){let X=[],z=Z.directives===!0;if(Z.directives!==!1&&$.directives){let Y=$.directives.toString($);if(Y)X.push(Y),z=!0;else if($.directives.docStart)z=!0}if(z)X.push("---");let q=Q9.createStringifyContext($,Z),{commentString:G}=q.options;if($.commentBefore){if(X.length!==1)X.unshift("");let Y=G($.commentBefore);X.unshift(e$.indentComment(Y,""))}let J=!1,Q=null;if($.contents){if(HJ.isNode($.contents)){if($.contents.spaceBefore&&z)X.push("");if($.contents.commentBefore){let W=G($.contents.commentBefore);X.push(e$.indentComment(W,""))}q.forceBlockIndent=!!$.comment,Q=$.contents.comment}let Y=Q?void 0:()=>J=!0,H=Q9.stringify($.contents,q,()=>Q=null,Y);if(Q)H+=e$.lineComment(H,"",G(Q));if((H[0]==="|"||H[0]===">")&&X[X.length-1]==="---")X[X.length-1]=`--- ${H}`;else X.push(H)}else X.push(Q9.stringify($.contents,q));if($.directives?.docEnd)if($.comment){let Y=G($.comment);if(Y.includes(`
82
- `))X.push("..."),X.push(e$.indentComment(Y,""));else X.push(`... ${Y}`)}else X.push("...");else{let Y=$.comment;if(Y&&J)Y=Y.replace(/^\n+/,"");if(Y){if((!J||Q)&&X[X.length-1]!=="")X.push("");X.push(e$.indentComment(G(Y),""))}}return X.join(`
67
+ `}else A+=`
68
+ ${X.indent}`}else if(!U&&t0.isCollection(Z)){let C=I[0],D=I.indexOf(`
69
+ `),v=D!==-1,k=X.inFlow??Z.flow??Z.items.length===0;if(v||!k){let i=!1;if(v&&(C==="&"||C==="!")){let l=I.indexOf(" ");if(C==="&"&&l!==-1&&l<D&&I[l+1]==="!")l=I.indexOf(" ",l+1);if(l===-1||D<l)i=!0}if(!i)A=`
70
+ ${X.indent}`}}else if(I===""||I[0]===`
71
+ `)A="";if(w+=A+I,X.inFlow){if(E&&Y)Y()}else if(P&&!E)w+=h2.lineComment(w,X.indent,V(P));else if(T&&G)G();return w}cW.stringifyPair=dW});var AX=R((aW)=>{var i3=r0("process");function pW($,...Z){if($==="debug")console.log(...Z)}function iW($,Z){if($==="debug"||$==="warn")if(typeof i3.emitWarning==="function")i3.emitWarning(Z);else console.warn(Z)}aW.debug=pW;aW.warn=iW});var H6=R((oW)=>{var u2=m(),a3=o(),W6="<<",V6={identify:($)=>$===W6||typeof $==="symbol"&&$.description===W6,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new a3.Scalar(Symbol(W6)),{addToJSMap:n3}),stringify:()=>W6},sW=($,Z)=>(V6.identify(Z)||u2.isScalar(Z)&&(!Z.type||Z.type===a3.Scalar.PLAIN)&&V6.identify(Z.value))&&$?.doc.schema.tags.some((X)=>X.tag===V6.tag&&X.default);function n3($,Z,X){if(X=$&&u2.isAlias(X)?X.resolve($.doc):X,u2.isSeq(X))for(let Y of X.items)SX($,Z,Y);else if(Array.isArray(X))for(let Y of X)SX($,Z,Y);else SX($,Z,X)}function SX($,Z,X){let Y=$&&u2.isAlias(X)?X.resolve($.doc):X;if(!u2.isMap(Y))throw Error("Merge sources must be maps or map aliases");let G=Y.toJSON(null,$,Map);for(let[z,J]of G)if(Z instanceof Map){if(!Z.has(z))Z.set(z,J)}else if(Z instanceof Set)Z.add(z);else if(!Object.prototype.hasOwnProperty.call(Z,z))Object.defineProperty(Z,z,{value:J,writable:!0,enumerable:!0,configurable:!0});return Z}oW.addMergeToJSMap=n3;oW.isMergeKey=sW;oW.merge=V6});var IX=R((zV)=>{var ZV=AX(),r3=H6(),XV=v2(),s3=m(),CX=K$();function YV($,Z,{key:X,value:Y}){if(s3.isNode(X)&&X.addToJSMap)X.addToJSMap($,Z,Y);else if(r3.isMergeKey($,X))r3.addMergeToJSMap($,Z,Y);else{let G=CX.toJS(X,"",$);if(Z instanceof Map)Z.set(G,CX.toJS(Y,G,$));else if(Z instanceof Set)Z.add(G);else{let z=GV(X,G,$),J=CX.toJS(Y,z,$);if(z in Z)Object.defineProperty(Z,z,{value:J,writable:!0,enumerable:!0,configurable:!0});else Z[z]=J}}return Z}function GV($,Z,X){if(Z===null)return"";if(typeof Z!=="object")return String(Z);if(s3.isNode($)&&X?.doc){let Y=XV.createStringifyContext(X.doc,{});Y.anchors=new Set;for(let z of X.anchors.keys())Y.anchors.add(z.anchor);Y.inFlow=!0,Y.inStringifyKey=!0;let G=$.toString(Y);if(!X.mapKeyWarned){let z=JSON.stringify(G);if(z.length>40)z=z.substring(0,36)+'..."';ZV.warn(X.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${z}. Set mapAsMap: true to use object keys.`),X.mapKeyWarned=!0}return G}return JSON.stringify(Z)}zV.addPairToJSMap=YV});var q$=R((HV)=>{var o3=b2(),QV=p3(),WV=IX(),K6=m();function VV($,Z,X){let Y=o3.createNode($,void 0,X),G=o3.createNode(Z,void 0,X);return new B6(Y,G)}class B6{constructor($,Z=null){Object.defineProperty(this,K6.NODE_TYPE,{value:K6.PAIR}),this.key=$,this.value=Z}clone($){let{key:Z,value:X}=this;if(K6.isNode(Z))Z=Z.clone($);if(K6.isNode(X))X=X.clone($);return new B6(Z,X)}toJSON($,Z){let X=Z?.mapAsMap?new Map:{};return WV.addPairToJSMap(Z,X,this)}toString($,Z,X){return $?.doc?QV.stringifyPair(this,$,Z,X):JSON.stringify(this)}}HV.Pair=B6;HV.createPair=VV});var jX=R((FV)=>{var c$=m(),t3=v2(),U6=f2();function UV($,Z,X){return(Z.inFlow??$.flow?TV:qV)($,Z,X)}function qV({comment:$,items:Z},X,{blockItemPrefix:Y,flowChars:G,itemIndent:z,onChompKeep:J,onComment:Q}){let{indent:W,options:{commentString:V}}=X,K=Object.assign({},X,{indent:z,type:null}),H=!1,B=[];for(let F=0;F<Z.length;++F){let T=Z[F],w=null;if(c$.isNode(T)){if(!H&&T.spaceBefore)B.push("");if(q6(X,B,T.commentBefore,H),T.comment)w=T.comment}else if(c$.isPair(T)){let N=c$.isNode(T.key)?T.key:null;if(N){if(!H&&N.spaceBefore)B.push("");q6(X,B,N.commentBefore,H)}}H=!1;let O=t3.stringify(T,K,()=>w=null,()=>H=!0);if(w)O+=U6.lineComment(O,z,V(w));if(H&&w)H=!1;B.push(Y+O)}let U;if(B.length===0)U=G.start+G.end;else{U=B[0];for(let F=1;F<B.length;++F){let T=B[F];U+=T?`
72
+ ${W}${T}`:`
73
+ `}}if($){if(U+=`
74
+ `+U6.indentComment(V($),W),Q)Q()}else if(H&&J)J();return U}function TV({items:$},Z,{flowChars:X,itemIndent:Y}){let{indent:G,indentStep:z,flowCollectionPadding:J,options:{commentString:Q}}=Z;Y+=z;let W=Object.assign({},Z,{indent:Y,inFlow:!0,type:null}),V=!1,K=0,H=[];for(let F=0;F<$.length;++F){let T=$[F],w=null;if(c$.isNode(T)){if(T.spaceBefore)H.push("");if(q6(Z,H,T.commentBefore,!1),T.comment)w=T.comment}else if(c$.isPair(T)){let N=c$.isNode(T.key)?T.key:null;if(N){if(N.spaceBefore)H.push("");if(q6(Z,H,N.commentBefore,!1),N.comment)V=!0}let P=c$.isNode(T.value)?T.value:null;if(P){if(P.comment)w=P.comment;if(P.commentBefore)V=!0}else if(T.value==null&&N?.comment)w=N.comment}if(w)V=!0;let O=t3.stringify(T,W,()=>w=null);if(F<$.length-1)O+=",";if(w)O+=U6.lineComment(O,Y,Q(w));if(!V&&(H.length>K||O.includes(`
75
+ `)))V=!0;H.push(O),K=H.length}let{start:B,end:U}=X;if(H.length===0)return B+U;else{if(!V){let F=H.reduce((T,w)=>T+w.length+2,2);V=Z.options.lineWidth>0&&F>Z.options.lineWidth}if(V){let F=B;for(let T of H)F+=T?`
76
+ ${z}${G}${T}`:`
77
+ `;return`${F}
78
+ ${G}${U}`}else return`${B}${J}${H.join(" ")}${J}${U}`}}function q6({indent:$,options:{commentString:Z}},X,Y,G){if(Y&&G)Y=Y.replace(/^\n+/,"");if(Y){let z=U6.indentComment(Z(Y),$);X.push(z.trimStart())}}FV.stringifyCollection=UV});var F$=R((_V)=>{var wV=jX(),MV=IX(),NV=G6(),T$=m(),T6=q$(),OV=o();function m2($,Z){let X=T$.isScalar(Z)?Z.value:Z;for(let Y of $)if(T$.isPair(Y)){if(Y.key===Z||Y.key===X)return Y;if(T$.isScalar(Y.key)&&Y.key.value===X)return Y}return}class e3 extends NV.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor($){super(T$.MAP,$);this.items=[]}static from($,Z,X){let{keepUndefined:Y,replacer:G}=X,z=new this($),J=(Q,W)=>{if(typeof G==="function")W=G.call(Z,Q,W);else if(Array.isArray(G)&&!G.includes(Q))return;if(W!==void 0||Y)z.items.push(T6.createPair(Q,W,X))};if(Z instanceof Map)for(let[Q,W]of Z)J(Q,W);else if(Z&&typeof Z==="object")for(let Q of Object.keys(Z))J(Q,Z[Q]);if(typeof $.sortMapEntries==="function")z.items.sort($.sortMapEntries);return z}add($,Z){let X;if(T$.isPair($))X=$;else if(!$||typeof $!=="object"||!("key"in $))X=new T6.Pair($,$?.value);else X=new T6.Pair($.key,$.value);let Y=m2(this.items,X.key),G=this.schema?.sortMapEntries;if(Y){if(!Z)throw Error(`Key ${X.key} already set`);if(T$.isScalar(Y.value)&&OV.isScalarValue(X.value))Y.value.value=X.value;else Y.value=X.value}else if(G){let z=this.items.findIndex((J)=>G(X,J)<0);if(z===-1)this.items.push(X);else this.items.splice(z,0,X)}else this.items.push(X)}delete($){let Z=m2(this.items,$);if(!Z)return!1;return this.items.splice(this.items.indexOf(Z),1).length>0}get($,Z){let Y=m2(this.items,$)?.value;return(!Z&&T$.isScalar(Y)?Y.value:Y)??void 0}has($){return!!m2(this.items,$)}set($,Z){this.add(new T6.Pair($,Z),!0)}toJSON($,Z,X){let Y=X?new X:Z?.mapAsMap?new Map:{};if(Z?.onCreate)Z.onCreate(Y);for(let G of this.items)MV.addPairToJSMap(Z,Y,G);return Y}toString($,Z,X){if(!$)return JSON.stringify(this);for(let Y of this.items)if(!T$.isPair(Y))throw Error(`Map items must all be pairs; found ${JSON.stringify(Y)} instead`);if(!$.allNullValues&&this.hasAllNullValues(!1))$=Object.assign({},$,{allNullValues:!0});return wV.stringifyCollection(this,$,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:$.indent||"",onChompKeep:X,onComment:Z})}}_V.YAMLMap=e3;_V.findPair=m2});var D1=R((AV)=>{var EV=m(),$7=F$(),RV={collection:"map",default:!0,nodeClass:$7.YAMLMap,tag:"tag:yaml.org,2002:map",resolve($,Z){if(!EV.isMap($))Z("Expected a mapping for this tag");return $},createNode:($,Z,X)=>$7.YAMLMap.from($,Z,X)};AV.map=RV});var L$=R((bV)=>{var CV=b2(),IV=jX(),jV=G6(),L6=m(),xV=o(),kV=K$();class Z7 extends jV.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor($){super(L6.SEQ,$);this.items=[]}add($){this.items.push($)}delete($){let Z=F6($);if(typeof Z!=="number")return!1;return this.items.splice(Z,1).length>0}get($,Z){let X=F6($);if(typeof X!=="number")return;let Y=this.items[X];return!Z&&L6.isScalar(Y)?Y.value:Y}has($){let Z=F6($);return typeof Z==="number"&&Z<this.items.length}set($,Z){let X=F6($);if(typeof X!=="number")throw Error(`Expected a valid index, not ${$}.`);let Y=this.items[X];if(L6.isScalar(Y)&&xV.isScalarValue(Z))Y.value=Z;else this.items[X]=Z}toJSON($,Z){let X=[];if(Z?.onCreate)Z.onCreate(X);let Y=0;for(let G of this.items)X.push(kV.toJS(G,String(Y++),Z));return X}toString($,Z,X){if(!$)return JSON.stringify(this);return IV.stringifyCollection(this,$,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:($.indent||"")+" ",onChompKeep:X,onComment:Z})}static from($,Z,X){let{replacer:Y}=X,G=new this($);if(Z&&Symbol.iterator in Object(Z)){let z=0;for(let J of Z){if(typeof Y==="function"){let Q=Z instanceof Set?J:String(z++);J=Y.call(Z,Q,J)}G.items.push(CV.createNode(J,void 0,X))}}return G}}function F6($){let Z=L6.isScalar($)?$.value:$;if(Z&&typeof Z==="string")Z=Number(Z);return typeof Z==="number"&&Number.isInteger(Z)&&Z>=0?Z:null}bV.YAMLSeq=Z7});var E1=R((vV)=>{var yV=m(),X7=L$(),gV={collection:"seq",default:!0,nodeClass:X7.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve($,Z){if(!yV.isSeq($))Z("Expected a sequence for this tag");return $},createNode:($,Z,X)=>X7.YAMLSeq.from($,Z,X)};vV.seq=gV});var d2=R((dV)=>{var uV=g2(),mV={identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify($,Z,X,Y){return Z=Object.assign({actualString:!0},Z),uV.stringifyString($,Z,X,Y)}};dV.string=mV});var w6=R((lV)=>{var Y7=o(),G7={identify:($)=>$==null,createNode:()=>new Y7.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Y7.Scalar(null),stringify:({source:$},Z)=>typeof $==="string"&&G7.test.test($)?$:Z.options.nullStr};lV.nullTag=G7});var xX=R((aV)=>{var iV=o(),z7={identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:($)=>new iV.Scalar($[0]==="t"||$[0]==="T"),stringify({source:$,value:Z},X){if($&&z7.test.test($)){let Y=$[0]==="t"||$[0]==="T";if(Z===Y)return $}return Z?X.options.trueStr:X.options.falseStr}};aV.boolTag=z7});var R1=R((sV)=>{function rV({format:$,minFractionDigits:Z,tag:X,value:Y}){if(typeof Y==="bigint")return String(Y);let G=typeof Y==="number"?Y:Number(Y);if(!isFinite(G))return isNaN(G)?".nan":G<0?"-.inf":".inf";let z=Object.is(Y,-0)?"-0":JSON.stringify(Y);if(!$&&Z&&(!X||X==="tag:yaml.org,2002:float")&&/^\d/.test(z)){let J=z.indexOf(".");if(J<0)J=z.length,z+=".";let Q=Z-(z.length-J-1);while(Q-- >0)z+="0"}return z}sV.stringifyNumber=rV});var bX=R((XH)=>{var tV=o(),kX=R1(),eV={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:kX.stringifyNumber},$H={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($),stringify($){let Z=Number($.value);return isFinite(Z)?Z.toExponential():kX.stringifyNumber($)}},ZH={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve($){let Z=new tV.Scalar(parseFloat($)),X=$.indexOf(".");if(X!==-1&&$[$.length-1]==="0")Z.minFractionDigits=$.length-X-1;return Z},stringify:kX.stringifyNumber};XH.float=ZH;XH.floatExp=$H;XH.floatNaN=eV});var yX=R((VH)=>{var J7=R1(),M6=($)=>typeof $==="bigint"||Number.isInteger($),fX=($,Z,X,{intAsBigInt:Y})=>Y?BigInt($):parseInt($.substring(Z),X);function Q7($,Z,X){let{value:Y}=$;if(M6(Y)&&Y>=0)return X+Y.toString(Z);return J7.stringifyNumber($)}var JH={identify:($)=>M6($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:($,Z,X)=>fX($,2,8,X),stringify:($)=>Q7($,8,"0o")},QH={identify:M6,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:($,Z,X)=>fX($,0,10,X),stringify:J7.stringifyNumber},WH={identify:($)=>M6($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:($,Z,X)=>fX($,2,16,X),stringify:($)=>Q7($,16,"0x")};VH.int=QH;VH.intHex=WH;VH.intOct=JH});var W7=R((MH)=>{var UH=D1(),qH=w6(),TH=E1(),FH=d2(),LH=xX(),gX=bX(),vX=yX(),wH=[UH.map,TH.seq,FH.string,qH.nullTag,LH.boolTag,vX.intOct,vX.int,vX.intHex,gX.floatNaN,gX.floatExp,gX.float];MH.schema=wH});var H7=R((AH)=>{var OH=o(),_H=D1(),PH=E1();function V7($){return typeof $==="bigint"||Number.isInteger($)}var N6=({value:$})=>JSON.stringify($),DH=[{identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify:N6},{identify:($)=>$==null,createNode:()=>new OH.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:N6},{identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:($)=>$==="true",stringify:N6},{identify:V7,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:($,Z,{intAsBigInt:X})=>X?BigInt($):parseInt($,10),stringify:({value:$})=>V7($)?$.toString():JSON.stringify($)},{identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:($)=>parseFloat($),stringify:N6}],EH={default:!0,tag:"",test:/^/,resolve($,Z){return Z(`Unresolved plain scalar ${JSON.stringify($)}`),$}},RH=[_H.map,PH.seq].concat(DH,EH);AH.schema=RH});var uX=R((jH)=>{var c2=r0("buffer"),hX=o(),CH=g2(),IH={identify:($)=>$ instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve($,Z){if(typeof c2.Buffer==="function")return c2.Buffer.from($,"base64");else if(typeof atob==="function"){let X=atob($.replace(/[\n\r]/g,"")),Y=new Uint8Array(X.length);for(let G=0;G<X.length;++G)Y[G]=X.charCodeAt(G);return Y}else return Z("This environment does not support reading binary tags; either Buffer or atob is required"),$},stringify({comment:$,type:Z,value:X},Y,G,z){if(!X)return"";let J=X,Q;if(typeof c2.Buffer==="function")Q=J instanceof c2.Buffer?J.toString("base64"):c2.Buffer.from(J.buffer).toString("base64");else if(typeof btoa==="function"){let W="";for(let V=0;V<J.length;++V)W+=String.fromCharCode(J[V]);Q=btoa(W)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(Z??(Z=hX.Scalar.BLOCK_LITERAL),Z!==hX.Scalar.QUOTE_DOUBLE){let W=Math.max(Y.options.lineWidth-Y.indent.length,Y.options.minContentWidth),V=Math.ceil(Q.length/W),K=Array(V);for(let H=0,B=0;H<V;++H,B+=W)K[H]=Q.substr(B,W);Q=K.join(Z===hX.Scalar.BLOCK_LITERAL?`
79
+ `:" ")}return CH.stringifyString({comment:$,type:Z,value:Q},Y,G,z)}};jH.binary=IH});var _6=R((yH)=>{var O6=m(),mX=q$(),kH=o(),bH=L$();function K7($,Z){if(O6.isSeq($))for(let X=0;X<$.items.length;++X){let Y=$.items[X];if(O6.isPair(Y))continue;else if(O6.isMap(Y)){if(Y.items.length>1)Z("Each pair must have its own sequence indicator");let G=Y.items[0]||new mX.Pair(new kH.Scalar(null));if(Y.commentBefore)G.key.commentBefore=G.key.commentBefore?`${Y.commentBefore}
80
+ ${G.key.commentBefore}`:Y.commentBefore;if(Y.comment){let z=G.value??G.key;z.comment=z.comment?`${Y.comment}
81
+ ${z.comment}`:Y.comment}Y=G}$.items[X]=O6.isPair(Y)?Y:new mX.Pair(Y)}else Z("Expected a sequence for this tag");return $}function B7($,Z,X){let{replacer:Y}=X,G=new bH.YAMLSeq($);G.tag="tag:yaml.org,2002:pairs";let z=0;if(Z&&Symbol.iterator in Object(Z))for(let J of Z){if(typeof Y==="function")J=Y.call(Z,String(z++),J);let Q,W;if(Array.isArray(J))if(J.length===2)Q=J[0],W=J[1];else throw TypeError(`Expected [key, value] tuple: ${J}`);else if(J&&J instanceof Object){let V=Object.keys(J);if(V.length===1)Q=V[0],W=J[Q];else throw TypeError(`Expected tuple with one key, not ${V.length} keys`)}else Q=J;G.items.push(mX.createPair(Q,W,X))}return G}var fH={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:K7,createNode:B7};yH.createPairs=B7;yH.pairs=fH;yH.resolvePairs=K7});var cX=R((dH)=>{var U7=m(),dX=K$(),l2=F$(),uH=L$(),q7=_6();class l$ extends uH.YAMLSeq{constructor(){super();this.add=l2.YAMLMap.prototype.add.bind(this),this.delete=l2.YAMLMap.prototype.delete.bind(this),this.get=l2.YAMLMap.prototype.get.bind(this),this.has=l2.YAMLMap.prototype.has.bind(this),this.set=l2.YAMLMap.prototype.set.bind(this),this.tag=l$.tag}toJSON($,Z){if(!Z)return super.toJSON($);let X=new Map;if(Z?.onCreate)Z.onCreate(X);for(let Y of this.items){let G,z;if(U7.isPair(Y))G=dX.toJS(Y.key,"",Z),z=dX.toJS(Y.value,G,Z);else G=dX.toJS(Y,"",Z);if(X.has(G))throw Error("Ordered maps must not include duplicate keys");X.set(G,z)}return X}static from($,Z,X){let Y=q7.createPairs($,Z,X),G=new this;return G.items=Y.items,G}}l$.tag="tag:yaml.org,2002:omap";var mH={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:l$,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,Z){let X=q7.resolvePairs($,Z),Y=[];for(let{key:G}of X.items)if(U7.isScalar(G))if(Y.includes(G.value))Z(`Ordered maps must not include duplicate keys: ${G.value}`);else Y.push(G.value);return Object.assign(new l$,X)},createNode:($,Z,X)=>l$.from($,Z,X)};dH.YAMLOMap=l$;dH.omap=mH});var M7=R((pH)=>{var T7=o();function F7({value:$,source:Z},X){if(Z&&($?L7:w7).test.test(Z))return Z;return $?X.options.trueStr:X.options.falseStr}var L7={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new T7.Scalar(!0),stringify:F7},w7={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new T7.Scalar(!1),stringify:F7};pH.falseTag=w7;pH.trueTag=L7});var N7=R((tH)=>{var nH=o(),lX=R1(),rH={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:lX.stringifyNumber},sH={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($.replace(/_/g,"")),stringify($){let Z=Number($.value);return isFinite(Z)?Z.toExponential():lX.stringifyNumber($)}},oH={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let Z=new nH.Scalar(parseFloat($.replace(/_/g,""))),X=$.indexOf(".");if(X!==-1){let Y=$.substring(X+1).replace(/_/g,"");if(Y[Y.length-1]==="0")Z.minFractionDigits=Y.length}return Z},stringify:lX.stringifyNumber};tH.float=oH;tH.floatExp=sH;tH.floatNaN=rH});var _7=R((JK)=>{var O7=R1(),p2=($)=>typeof $==="bigint"||Number.isInteger($);function P6($,Z,X,{intAsBigInt:Y}){let G=$[0];if(G==="-"||G==="+")Z+=1;if($=$.substring(Z).replace(/_/g,""),Y){switch(X){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let J=BigInt($);return G==="-"?BigInt(-1)*J:J}let z=parseInt($,X);return G==="-"?-1*z:z}function pX($,Z,X){let{value:Y}=$;if(p2(Y)){let G=Y.toString(Z);return Y<0?"-"+X+G.substr(1):X+G}return O7.stringifyNumber($)}var XK={identify:p2,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,Z,X)=>P6($,2,2,X),stringify:($)=>pX($,2,"0b")},YK={identify:p2,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,Z,X)=>P6($,1,8,X),stringify:($)=>pX($,8,"0")},GK={identify:p2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,Z,X)=>P6($,0,10,X),stringify:O7.stringifyNumber},zK={identify:p2,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,Z,X)=>P6($,2,16,X),stringify:($)=>pX($,16,"0x")};JK.int=GK;JK.intBin=XK;JK.intHex=zK;JK.intOct=YK});var iX=R((BK)=>{var R6=m(),D6=q$(),E6=F$();class p$ extends E6.YAMLMap{constructor($){super($);this.tag=p$.tag}add($){let Z;if(R6.isPair($))Z=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)Z=new D6.Pair($.key,null);else Z=new D6.Pair($,null);if(!E6.findPair(this.items,Z.key))this.items.push(Z)}get($,Z){let X=E6.findPair(this.items,$);return!Z&&R6.isPair(X)?R6.isScalar(X.key)?X.key.value:X.key:X}set($,Z){if(typeof Z!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof Z}`);let X=E6.findPair(this.items,$);if(X&&!Z)this.items.splice(this.items.indexOf(X),1);else if(!X&&Z)this.items.push(new D6.Pair($))}toJSON($,Z){return super.toJSON($,Z,Set)}toString($,Z,X){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),Z,X);else throw Error("Set items must all have null values")}static from($,Z,X){let{replacer:Y}=X,G=new this($);if(Z&&Symbol.iterator in Object(Z))for(let z of Z){if(typeof Y==="function")z=Y.call(Z,z,z);G.items.push(D6.createPair(z,null,X))}return G}}p$.tag="tag:yaml.org,2002:set";var KK={collection:"map",identify:($)=>$ instanceof Set,nodeClass:p$,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,Z,X)=>p$.from($,Z,X),resolve($,Z){if(R6.isMap($))if($.hasAllNullValues(!0))return Object.assign(new p$,$);else Z("Set items must all have null values");else Z("Expected a mapping for this tag");return $}};BK.YAMLSet=p$;BK.set=KK});var nX=R((wK)=>{var TK=R1();function aX($,Z){let X=$[0],Y=X==="-"||X==="+"?$.substring(1):$,G=(J)=>Z?BigInt(J):Number(J),z=Y.replace(/_/g,"").split(":").reduce((J,Q)=>J*G(60)+G(Q),G(0));return X==="-"?G(-1)*z:z}function P7($){let{value:Z}=$,X=(J)=>J;if(typeof Z==="bigint")X=(J)=>BigInt(J);else if(isNaN(Z)||!isFinite(Z))return TK.stringifyNumber($);let Y="";if(Z<0)Y="-",Z*=X(-1);let G=X(60),z=[Z%G];if(Z<60)z.unshift(0);else if(Z=(Z-z[0])/G,z.unshift(Z%G),Z>=60)Z=(Z-z[0])/G,z.unshift(Z);return Y+z.map((J)=>String(J).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var FK={identify:($)=>typeof $==="bigint"||Number.isInteger($),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:($,Z,{intAsBigInt:X})=>aX($,X),stringify:P7},LK={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:($)=>aX($,!1),stringify:P7},D7={identify:($)=>$ instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve($){let Z=$.match(D7.test);if(!Z)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,X,Y,G,z,J,Q]=Z.map(Number),W=Z[7]?Number((Z[7]+"00").substr(1,3)):0,V=Date.UTC(X,Y-1,G,z||0,J||0,Q||0,W),K=Z[8];if(K&&K!=="Z"){let H=aX(K,!1);if(Math.abs(H)<30)H*=60;V-=60000*H}return new Date(V)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};wK.floatTime=LK;wK.intTime=FK;wK.timestamp=D7});var R7=R((xK)=>{var _K=D1(),PK=w6(),DK=E1(),EK=d2(),RK=uX(),E7=M7(),rX=N7(),A6=_7(),AK=H6(),SK=cX(),CK=_6(),IK=iX(),sX=nX(),jK=[_K.map,DK.seq,EK.string,PK.nullTag,E7.trueTag,E7.falseTag,A6.intBin,A6.intOct,A6.int,A6.intHex,rX.floatNaN,rX.floatExp,rX.float,RK.binary,AK.merge,SK.omap,CK.pairs,IK.set,sX.intTime,sX.floatTime,sX.timestamp];xK.schema=jK});var y7=R((mK)=>{var I7=D1(),bK=w6(),j7=E1(),fK=d2(),yK=xX(),oX=bX(),tX=yX(),gK=W7(),vK=H7(),x7=uX(),i2=H6(),k7=cX(),b7=_6(),A7=R7(),f7=iX(),S6=nX(),S7=new Map([["core",gK.schema],["failsafe",[I7.map,j7.seq,fK.string]],["json",vK.schema],["yaml11",A7.schema],["yaml-1.1",A7.schema]]),C7={binary:x7.binary,bool:yK.boolTag,float:oX.float,floatExp:oX.floatExp,floatNaN:oX.floatNaN,floatTime:S6.floatTime,int:tX.int,intHex:tX.intHex,intOct:tX.intOct,intTime:S6.intTime,map:I7.map,merge:i2.merge,null:bK.nullTag,omap:k7.omap,pairs:b7.pairs,seq:j7.seq,set:f7.set,timestamp:S6.timestamp},hK={"tag:yaml.org,2002:binary":x7.binary,"tag:yaml.org,2002:merge":i2.merge,"tag:yaml.org,2002:omap":k7.omap,"tag:yaml.org,2002:pairs":b7.pairs,"tag:yaml.org,2002:set":f7.set,"tag:yaml.org,2002:timestamp":S6.timestamp};function uK($,Z,X){let Y=S7.get(Z);if(Y&&!$)return X&&!Y.includes(i2.merge)?Y.concat(i2.merge):Y.slice();let G=Y;if(!G)if(Array.isArray($))G=[];else{let z=Array.from(S7.keys()).filter((J)=>J!=="yaml11").map((J)=>JSON.stringify(J)).join(", ");throw Error(`Unknown schema "${Z}"; use one of ${z} or define customTags array`)}if(Array.isArray($))for(let z of $)G=G.concat(z);else if(typeof $==="function")G=$(G.slice());if(X)G=G.concat(i2.merge);return G.reduce((z,J)=>{let Q=typeof J==="string"?C7[J]:J;if(!Q){let W=JSON.stringify(J),V=Object.keys(C7).map((K)=>JSON.stringify(K)).join(", ");throw Error(`Unknown custom tag ${W}; use one of ${V}`)}if(!z.includes(Q))z.push(Q);return z},[])}mK.coreKnownTags=hK;mK.getTags=uK});var Z9=R((nK)=>{var eX=m(),lK=D1(),pK=E1(),iK=d2(),C6=y7(),aK=($,Z)=>$.key<Z.key?-1:$.key>Z.key?1:0;class $9{constructor({compat:$,customTags:Z,merge:X,resolveKnownTags:Y,schema:G,sortMapEntries:z,toStringDefaults:J}){this.compat=Array.isArray($)?C6.getTags($,"compat"):$?C6.getTags(null,$):null,this.name=typeof G==="string"&&G||"core",this.knownTags=Y?C6.coreKnownTags:{},this.tags=C6.getTags(Z,this.name,X),this.toStringOptions=J??null,Object.defineProperty(this,eX.MAP,{value:lK.map}),Object.defineProperty(this,eX.SCALAR,{value:iK.string}),Object.defineProperty(this,eX.SEQ,{value:pK.seq}),this.sortMapEntries=typeof z==="function"?z:z===!0?aK:null}clone(){let $=Object.create($9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}nK.Schema=$9});var g7=R((tK)=>{var sK=m(),X9=v2(),a2=f2();function oK($,Z){let X=[],Y=Z.directives===!0;if(Z.directives!==!1&&$.directives){let W=$.directives.toString($);if(W)X.push(W),Y=!0;else if($.directives.docStart)Y=!0}if(Y)X.push("---");let G=X9.createStringifyContext($,Z),{commentString:z}=G.options;if($.commentBefore){if(X.length!==1)X.unshift("");let W=z($.commentBefore);X.unshift(a2.indentComment(W,""))}let J=!1,Q=null;if($.contents){if(sK.isNode($.contents)){if($.contents.spaceBefore&&Y)X.push("");if($.contents.commentBefore){let K=z($.contents.commentBefore);X.push(a2.indentComment(K,""))}G.forceBlockIndent=!!$.comment,Q=$.contents.comment}let W=Q?void 0:()=>J=!0,V=X9.stringify($.contents,G,()=>Q=null,W);if(Q)V+=a2.lineComment(V,"",z(Q));if((V[0]==="|"||V[0]===">")&&X[X.length-1]==="---")X[X.length-1]=`--- ${V}`;else X.push(V)}else X.push(X9.stringify($.contents,G));if($.directives?.docEnd)if($.comment){let W=z($.comment);if(W.includes(`
82
+ `))X.push("..."),X.push(a2.indentComment(W,""));else X.push(`... ${W}`)}else X.push("...");else{let W=$.comment;if(W&&J)W=W.replace(/^\n+/,"");if(W){if((!J||Q)&&X[X.length-1]!=="")X.push("");X.push(a2.indentComment(z(W),""))}}return X.join(`
83
83
  `)+`
84
- `}WJ.stringifyDocument=UJ});var $1=F((MJ)=>{var KJ=v$(),U$=v1(),X0=E(),BJ=N0(),LJ=R0(),TJ=J9(),DJ=z8(),Y9=f1(),_J=j4(),FJ=u$(),H9=A4();class U9{constructor($,Z,X){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,X0.NODE_TYPE,{value:X0.DOC});let z=null;if(typeof Z==="function"||Array.isArray(Z))z=Z;else if(X===void 0&&Z)X=Z,Z=void 0;let q=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},X);this.options=q;let{version:G}=q;if(X?._directives){if(this.directives=X._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new H9.Directives({version:G});this.setSchema(G,X),this.contents=$===void 0?null:this.createNode($,z,X)}clone(){let $=Object.create(U9.prototype,{[X0.NODE_TYPE]:{value:X0.DOC}});if($.commentBefore=this.commentBefore,$.comment=this.comment,$.errors=this.errors.slice(),$.warnings=this.warnings.slice(),$.options=Object.assign({},this.options),this.directives)$.directives=this.directives.clone();if($.schema=this.schema.clone(),$.contents=X0.isNode(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(W$(this.contents))this.contents.add($)}addIn($,Z){if(W$(this.contents))this.contents.addIn($,Z)}createAlias($,Z){if(!$.anchor){let X=Y9.anchorNames(this);$.anchor=!Z||X.has(Z)?Y9.findNewAnchor(Z||"a",X):Z}return new KJ.Alias($.anchor)}createNode($,Z,X){let z=void 0;if(typeof Z==="function")$=Z.call({"":$},"",$),z=Z;else if(Array.isArray(Z)){let K=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,L=Z.filter(K).map(String);if(L.length>0)Z=Z.concat(L);z=Z}else if(X===void 0&&Z)X=Z,Z=void 0;let{aliasDuplicateObjects:q,anchorPrefix:G,flow:J,keepUndefined:Q,onTagObj:Y,tag:H}=X??{},{onAnchor:W,setAnchors:U,sourceObjects:V}=Y9.createNodeAnchors(this,G||"a"),B={aliasDuplicateObjects:q??!0,keepUndefined:Q??!1,onAnchor:W,onTagObj:Y,replacer:z,schema:this.schema,sourceObjects:V},T=FJ.createNode($,H,B);if(J&&X0.isCollection(T))T.flow=!0;return U(),T}createPair($,Z,X={}){let z=this.createNode($,null,X),q=this.createNode(Z,null,X);return new BJ.Pair(z,q)}delete($){return W$(this.contents)?this.contents.delete($):!1}deleteIn($){if(U$.isEmptyPath($)){if(this.contents==null)return!1;return this.contents=null,!0}return W$(this.contents)?this.contents.deleteIn($):!1}get($,Z){return X0.isCollection(this.contents)?this.contents.get($,Z):void 0}getIn($,Z){if(U$.isEmptyPath($))return!Z&&X0.isScalar(this.contents)?this.contents.value:this.contents;return X0.isCollection(this.contents)?this.contents.getIn($,Z):void 0}has($){return X0.isCollection(this.contents)?this.contents.has($):!1}hasIn($){if(U$.isEmptyPath($))return this.contents!==void 0;return X0.isCollection(this.contents)?this.contents.hasIn($):!1}set($,Z){if(this.contents==null)this.contents=U$.collectionFromPath(this.schema,[$],Z);else if(W$(this.contents))this.contents.set($,Z)}setIn($,Z){if(U$.isEmptyPath($))this.contents=Z;else if(this.contents==null)this.contents=U$.collectionFromPath(this.schema,Array.from($),Z);else if(W$(this.contents))this.contents.setIn($,Z)}setSchema($,Z={}){if(typeof $==="number")$=String($);let X;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new H9.Directives({version:"1.1"});X={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new H9.Directives({version:$});X={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;X=null;break;default:{let z=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${z}`)}}if(Z.schema instanceof Object)this.schema=Z.schema;else if(X)this.schema=new TJ.Schema(Object.assign(X,Z));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:Z,mapAsMap:X,maxAliasCount:z,onAnchor:q,reviver:G}={}){let J={anchors:new Map,doc:this,keep:!$,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof z==="number"?z:100},Q=LJ.toJS(this.contents,Z??"",J);if(typeof q==="function")for(let{count:Y,res:H}of J.anchors.values())q(H,Y);return typeof G==="function"?_J.applyReviver(G,{"":Q},"",Q):Q}toJSON($,Z){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:Z})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let Z=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${Z}`)}return DJ.stringifyDocument(this,$)}}function W$($){if(X0.isCollection($))return!0;throw Error("Expected a YAML collection as document contents")}MJ.Document=U9});var Z1=F((PJ)=>{class W2 extends Error{constructor($,Z,X,z){super();this.name=$,this.code=X,this.message=z,this.pos=Z}}class q8 extends W2{constructor($,Z,X){super("YAMLParseError",$,Z,X)}}class G8 extends W2{constructor($,Z,X){super("YAMLWarning",$,Z,X)}}var wJ=($,Z)=>(X)=>{if(X.pos[0]===-1)return;X.linePos=X.pos.map((Q)=>Z.linePos(Q));let{line:z,col:q}=X.linePos[0];X.message+=` at line ${z}, column ${q}`;let G=q-1,J=$.substring(Z.lineStarts[z-1],Z.lineStarts[z]).replace(/[\n\r]+$/,"");if(G>=60&&J.length>80){let Q=Math.min(G-39,J.length-79);J="\u2026"+J.substring(Q),G-=Q-1}if(J.length>80)J=J.substring(0,79)+"\u2026";if(z>1&&/^ *$/.test(J.substring(0,G))){let Q=$.substring(Z.lineStarts[z-2],Z.lineStarts[z-1]);if(Q.length>80)Q=Q.substring(0,79)+`\u2026
85
- `;J=Q+J}if(/[^ ]/.test(J)){let Q=1,Y=X.linePos[1];if(Y?.line===z&&Y.col>q)Q=Math.max(1,Math.min(Y.col-q,80-G));let H=" ".repeat(G)+"^".repeat(Q);X.message+=`:
84
+ `}tK.stringifyDocument=oK});var n2=R((QB)=>{var $B=k2(),A1=G6(),I0=m(),ZB=q$(),XB=K$(),YB=Z9(),GB=g7(),Y9=Z6(),zB=_X(),JB=b2(),G9=OX();class z9{constructor($,Z,X){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,I0.NODE_TYPE,{value:I0.DOC});let Y=null;if(typeof Z==="function"||Array.isArray(Z))Y=Z;else if(X===void 0&&Z)X=Z,Z=void 0;let G=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},X);this.options=G;let{version:z}=G;if(X?._directives){if(this.directives=X._directives.atDocument(),this.directives.yaml.explicit)z=this.directives.yaml.version}else this.directives=new G9.Directives({version:z});this.setSchema(z,X),this.contents=$===void 0?null:this.createNode($,Y,X)}clone(){let $=Object.create(z9.prototype,{[I0.NODE_TYPE]:{value:I0.DOC}});if($.commentBefore=this.commentBefore,$.comment=this.comment,$.errors=this.errors.slice(),$.warnings=this.warnings.slice(),$.options=Object.assign({},this.options),this.directives)$.directives=this.directives.clone();if($.schema=this.schema.clone(),$.contents=I0.isNode(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(S1(this.contents))this.contents.add($)}addIn($,Z){if(S1(this.contents))this.contents.addIn($,Z)}createAlias($,Z){if(!$.anchor){let X=Y9.anchorNames(this);$.anchor=!Z||X.has(Z)?Y9.findNewAnchor(Z||"a",X):Z}return new $B.Alias($.anchor)}createNode($,Z,X){let Y=void 0;if(typeof Z==="function")$=Z.call({"":$},"",$),Y=Z;else if(Array.isArray(Z)){let T=(O)=>typeof O==="number"||O instanceof String||O instanceof Number,w=Z.filter(T).map(String);if(w.length>0)Z=Z.concat(w);Y=Z}else if(X===void 0&&Z)X=Z,Z=void 0;let{aliasDuplicateObjects:G,anchorPrefix:z,flow:J,keepUndefined:Q,onTagObj:W,tag:V}=X??{},{onAnchor:K,setAnchors:H,sourceObjects:B}=Y9.createNodeAnchors(this,z||"a"),U={aliasDuplicateObjects:G??!0,keepUndefined:Q??!1,onAnchor:K,onTagObj:W,replacer:Y,schema:this.schema,sourceObjects:B},F=JB.createNode($,V,U);if(J&&I0.isCollection(F))F.flow=!0;return H(),F}createPair($,Z,X={}){let Y=this.createNode($,null,X),G=this.createNode(Z,null,X);return new ZB.Pair(Y,G)}delete($){return S1(this.contents)?this.contents.delete($):!1}deleteIn($){if(A1.isEmptyPath($)){if(this.contents==null)return!1;return this.contents=null,!0}return S1(this.contents)?this.contents.deleteIn($):!1}get($,Z){return I0.isCollection(this.contents)?this.contents.get($,Z):void 0}getIn($,Z){if(A1.isEmptyPath($))return!Z&&I0.isScalar(this.contents)?this.contents.value:this.contents;return I0.isCollection(this.contents)?this.contents.getIn($,Z):void 0}has($){return I0.isCollection(this.contents)?this.contents.has($):!1}hasIn($){if(A1.isEmptyPath($))return this.contents!==void 0;return I0.isCollection(this.contents)?this.contents.hasIn($):!1}set($,Z){if(this.contents==null)this.contents=A1.collectionFromPath(this.schema,[$],Z);else if(S1(this.contents))this.contents.set($,Z)}setIn($,Z){if(A1.isEmptyPath($))this.contents=Z;else if(this.contents==null)this.contents=A1.collectionFromPath(this.schema,Array.from($),Z);else if(S1(this.contents))this.contents.setIn($,Z)}setSchema($,Z={}){if(typeof $==="number")$=String($);let X;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new G9.Directives({version:"1.1"});X={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new G9.Directives({version:$});X={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;X=null;break;default:{let Y=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${Y}`)}}if(Z.schema instanceof Object)this.schema=Z.schema;else if(X)this.schema=new YB.Schema(Object.assign(X,Z));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:Z,mapAsMap:X,maxAliasCount:Y,onAnchor:G,reviver:z}={}){let J={anchors:new Map,doc:this,keep:!$,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof Y==="number"?Y:100},Q=XB.toJS(this.contents,Z??"",J);if(typeof G==="function")for(let{count:W,res:V}of J.anchors.values())G(V,W);return typeof z==="function"?zB.applyReviver(z,{"":Q},"",Q):Q}toJSON($,Z){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:Z})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let Z=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${Z}`)}return GB.stringifyDocument(this,$)}}function S1($){if(I0.isCollection($))return!0;throw Error("Expected a YAML collection as document contents")}QB.Document=z9});var r2=R((HB)=>{class I6 extends Error{constructor($,Z,X,Y){super();this.name=$,this.code=X,this.message=Y,this.pos=Z}}class v7 extends I6{constructor($,Z,X){super("YAMLParseError",$,Z,X)}}class h7 extends I6{constructor($,Z,X){super("YAMLWarning",$,Z,X)}}var VB=($,Z)=>(X)=>{if(X.pos[0]===-1)return;X.linePos=X.pos.map((Q)=>Z.linePos(Q));let{line:Y,col:G}=X.linePos[0];X.message+=` at line ${Y}, column ${G}`;let z=G-1,J=$.substring(Z.lineStarts[Y-1],Z.lineStarts[Y]).replace(/[\n\r]+$/,"");if(z>=60&&J.length>80){let Q=Math.min(z-39,J.length-79);J="\u2026"+J.substring(Q),z-=Q-1}if(J.length>80)J=J.substring(0,79)+"\u2026";if(Y>1&&/^ *$/.test(J.substring(0,z))){let Q=$.substring(Z.lineStarts[Y-2],Z.lineStarts[Y-1]);if(Q.length>80)Q=Q.substring(0,79)+`\u2026
85
+ `;J=Q+J}if(/[^ ]/.test(J)){let Q=1,W=X.linePos[1];if(W?.line===Y&&W.col>G)Q=Math.max(1,Math.min(W.col-G,80-z));let V=" ".repeat(z)+"^".repeat(Q);X.message+=`:
86
86
 
87
87
  ${J}
88
- ${H}
89
- `}};PJ.YAMLError=W2;PJ.YAMLParseError=q8;PJ.YAMLWarning=G8;PJ.prettifyError=wJ});var X1=F((SJ)=>{function NJ($,{flow:Z,indicator:X,next:z,offset:q,onError:G,parentIndent:J,startOnNewline:Q}){let Y=!1,H=Q,W=Q,U="",V="",B=!1,T=!1,K=null,L=null,D=null,_=null,O=null,w=null,R=null;for(let M of $){if(T){if(M.type!=="space"&&M.type!=="newline"&&M.type!=="comma")G(M.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");T=!1}if(K){if(H&&M.type!=="comment"&&M.type!=="newline")G(K,"TAB_AS_INDENT","Tabs are not allowed as indentation");K=null}switch(M.type){case"space":if(!Z&&(X!=="doc-start"||z?.type!=="flow-collection")&&M.source.includes("\t"))K=M;W=!0;break;case"comment":{if(!W)G(M,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let y=M.source.substring(1)||" ";if(!U)U=y;else U+=V+y;V="",H=!1;break}case"newline":if(H){if(U)U+=M.source;else if(!w||X!=="seq-item-ind")Y=!0}else V+=M.source;if(H=!0,B=!0,L||D)_=M;W=!0;break;case"anchor":if(L)G(M,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(M.source.endsWith(":"))G(M.offset+M.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);L=M,R??(R=M.offset),H=!1,W=!1,T=!0;break;case"tag":{if(D)G(M,"MULTIPLE_TAGS","A node can have at most one tag");D=M,R??(R=M.offset),H=!1,W=!1,T=!0;break}case X:if(L||D)G(M,"BAD_PROP_ORDER",`Anchors and tags must be after the ${M.source} indicator`);if(w)G(M,"UNEXPECTED_TOKEN",`Unexpected ${M.source} in ${Z??"collection"}`);w=M,H=X==="seq-item-ind"||X==="explicit-key-ind",W=!1;break;case"comma":if(Z){if(O)G(M,"UNEXPECTED_TOKEN",`Unexpected , in ${Z}`);O=M,H=!1,W=!1;break}default:G(M,"UNEXPECTED_TOKEN",`Unexpected ${M.type} token`),H=!1,W=!1}}let I=$[$.length-1],C=I?I.offset+I.source.length:q;if(T&&z&&z.type!=="space"&&z.type!=="newline"&&z.type!=="comma"&&(z.type!=="scalar"||z.source!==""))G(z.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(K&&(H&&K.indent<=J||z?.type==="block-map"||z?.type==="block-seq"))G(K,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:O,found:w,spaceBefore:Y,comment:U,hasNewline:B,anchor:L,tag:D,newlineAfterProp:_,end:C,start:R??C}}SJ.resolveProps=NJ});var V2=F((EJ)=>{function W9($){if(!$)return null;switch($.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if($.source.includes(`
90
- `))return!0;if($.end){for(let Z of $.end)if(Z.type==="newline")return!0}return!1;case"flow-collection":for(let Z of $.items){for(let X of Z.start)if(X.type==="newline")return!0;if(Z.sep){for(let X of Z.sep)if(X.type==="newline")return!0}if(W9(Z.key)||W9(Z.value))return!0}return!1;default:return!0}}EJ.containsNewline=W9});var V9=F((kJ)=>{var yJ=V2();function xJ($,Z,X){if(Z?.type==="flow-collection"){let z=Z.end[0];if(z.indent===$&&(z.source==="]"||z.source==="}")&&yJ.containsNewline(Z))X(z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}kJ.flowIndentCheck=xJ});var K9=F((gJ)=>{var J8=E();function hJ($,Z,X){let{uniqueKeys:z}=$.options;if(z===!1)return!1;let q=typeof z==="function"?z:(G,J)=>G===J||J8.isScalar(G)&&J8.isScalar(J)&&G.value===J.value;return Z.some((G)=>q(G.key,X))}gJ.mapIncludes=hJ});var W8=F((lJ)=>{var Q8=N0(),uJ=C0(),Y8=X1(),mJ=V2(),H8=V9(),dJ=K9(),U8="All mapping items must start at the same column";function pJ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let Q=new(G?.nodeClass??uJ.YAMLMap)(X.schema);if(X.atRoot)X.atRoot=!1;let Y=z.offset,H=null;for(let W of z.items){let{start:U,key:V,sep:B,value:T}=W,K=Y8.resolveProps(U,{indicator:"explicit-key-ind",next:V??B?.[0],offset:Y,onError:q,parentIndent:z.indent,startOnNewline:!0}),L=!K.found;if(L){if(V){if(V.type==="block-seq")q(Y,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in V&&V.indent!==z.indent)q(Y,"BAD_INDENT",U8)}if(!K.anchor&&!K.tag&&!B){if(H=K.end,K.comment)if(Q.comment)Q.comment+=`
91
- `+K.comment;else Q.comment=K.comment;continue}if(K.newlineAfterProp||mJ.containsNewline(V))q(V??U[U.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(K.found?.indent!==z.indent)q(Y,"BAD_INDENT",U8);X.atKey=!0;let D=K.end,_=V?$(X,V,K,q):Z(X,D,U,null,K,q);if(X.schema.compat)H8.flowIndentCheck(z.indent,V,q);if(X.atKey=!1,dJ.mapIncludes(X,Q.items,_))q(D,"DUPLICATE_KEY","Map keys must be unique");let O=Y8.resolveProps(B??[],{indicator:"map-value-ind",next:T,offset:_.range[2],onError:q,parentIndent:z.indent,startOnNewline:!V||V.type==="block-scalar"});if(Y=O.end,O.found){if(L){if(T?.type==="block-map"&&!O.hasNewline)q(Y,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(X.options.strict&&K.start<O.found.offset-1024)q(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let w=T?$(X,T,O,q):Z(X,Y,B,null,O,q);if(X.schema.compat)H8.flowIndentCheck(z.indent,T,q);Y=w.range[2];let R=new Q8.Pair(_,w);if(X.options.keepSourceTokens)R.srcToken=W;Q.items.push(R)}else{if(L)q(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(O.comment)if(_.comment)_.comment+=`
92
- `+O.comment;else _.comment=O.comment;let w=new Q8.Pair(_);if(X.options.keepSourceTokens)w.srcToken=W;Q.items.push(w)}}if(H&&H<Y)q(H,"IMPOSSIBLE","Map comment with trailing content");return Q.range=[z.offset,Y,H??Y],Q}lJ.resolveBlockMap=pJ});var V8=F((rJ)=>{var iJ=E0(),aJ=X1(),nJ=V9();function sJ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let Q=new(G?.nodeClass??iJ.YAMLSeq)(X.schema);if(X.atRoot)X.atRoot=!1;if(X.atKey)X.atKey=!1;let Y=z.offset,H=null;for(let{start:W,value:U}of z.items){let V=aJ.resolveProps(W,{indicator:"seq-item-ind",next:U,offset:Y,onError:q,parentIndent:z.indent,startOnNewline:!0});if(!V.found)if(V.anchor||V.tag||U)if(U?.type==="block-seq")q(V.end,"BAD_INDENT","All sequence items must start at the same column");else q(Y,"MISSING_CHAR","Sequence item without - indicator");else{if(H=V.end,V.comment)Q.comment=V.comment;continue}let B=U?$(X,U,V,q):Z(X,V.end,W,null,V,q);if(X.schema.compat)nJ.flowIndentCheck(z.indent,U,q);Y=B.range[2],Q.items.push(B)}return Q.range=[z.offset,Y,H??Y],Q}rJ.resolveBlockSeq=sJ});var V$=F((eJ)=>{function tJ($,Z,X,z){let q="";if($){let G=!1,J="";for(let Q of $){let{source:Y,type:H}=Q;switch(H){case"space":G=!0;break;case"comment":{if(X&&!G)z(Q,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=Y.substring(1)||" ";if(!q)q=W;else q+=J+W;J="";break}case"newline":if(q)J+=Y;G=!0;break;default:z(Q,"UNEXPECTED_TOKEN",`Unexpected ${H} at node end`)}Z+=Y.length}}return{comment:q,offset:Z}}eJ.resolveEnd=tJ});var L8=F((YQ)=>{var ZQ=E(),XQ=N0(),K8=C0(),zQ=E0(),qQ=V$(),B8=X1(),GQ=V2(),JQ=K9(),B9="Block collections are not allowed within flow collections",L9=($)=>$&&($.type==="block-map"||$.type==="block-seq");function QQ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let J=z.start.source==="{",Q=J?"flow map":"flow sequence",H=new(G?.nodeClass??(J?K8.YAMLMap:zQ.YAMLSeq))(X.schema);H.flow=!0;let W=X.atRoot;if(W)X.atRoot=!1;if(X.atKey)X.atKey=!1;let U=z.offset+z.start.source.length;for(let L=0;L<z.items.length;++L){let D=z.items[L],{start:_,key:O,sep:w,value:R}=D,I=B8.resolveProps(_,{flow:Q,indicator:"explicit-key-ind",next:O??w?.[0],offset:U,onError:q,parentIndent:z.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!w&&!R){if(L===0&&I.comma)q(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`);else if(L<z.items.length-1)q(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${Q}`);if(I.comment)if(H.comment)H.comment+=`
93
- `+I.comment;else H.comment=I.comment;U=I.end;continue}if(!J&&X.options.strict&&GQ.containsNewline(O))q(O,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(L===0){if(I.comma)q(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`)}else{if(!I.comma)q(I.start,"MISSING_CHAR",`Missing , between ${Q} items`);if(I.comment){let C="";$:for(let M of _)switch(M.type){case"comma":case"space":break;case"comment":C=M.source.substring(1);break $;default:break $}if(C){let M=H.items[H.items.length-1];if(ZQ.isPair(M))M=M.value??M.key;if(M.comment)M.comment+=`
94
- `+C;else M.comment=C;I.comment=I.comment.substring(C.length+1)}}}if(!J&&!w&&!I.found){let C=R?$(X,R,I,q):Z(X,I.end,w,null,I,q);if(H.items.push(C),U=C.range[2],L9(R))q(C.range,"BLOCK_IN_FLOW",B9)}else{X.atKey=!0;let C=I.end,M=O?$(X,O,I,q):Z(X,C,_,null,I,q);if(L9(O))q(M.range,"BLOCK_IN_FLOW",B9);X.atKey=!1;let y=B8.resolveProps(w??[],{flow:Q,indicator:"map-value-ind",next:R,offset:M.range[2],onError:q,parentIndent:z.indent,startOnNewline:!1});if(y.found){if(!J&&!I.found&&X.options.strict){if(w)for(let k of w){if(k===y.found)break;if(k.type==="newline"){q(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(I.start<y.found.offset-1024)q(y.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(R)if("source"in R&&R.source?.[0]===":")q(R,"MISSING_CHAR",`Missing space after : in ${Q}`);else q(y.start,"MISSING_CHAR",`Missing , or : between ${Q} items`);let p=R?$(X,R,y,q):y.found?Z(X,y.end,w,null,y,q):null;if(p){if(L9(R))q(p.range,"BLOCK_IN_FLOW",B9)}else if(y.comment)if(M.comment)M.comment+=`
95
- `+y.comment;else M.comment=y.comment;let s=new XQ.Pair(M,p);if(X.options.keepSourceTokens)s.srcToken=D;if(J){let k=H;if(JQ.mapIncludes(X,k.items,M))q(C,"DUPLICATE_KEY","Map keys must be unique");k.items.push(s)}else{let k=new K8.YAMLMap(X.schema);k.flow=!0,k.items.push(s);let o=(p??M).range;k.range=[M.range[0],o[1],o[2]],H.items.push(k)}U=p?p.range[2]:y.end}}let V=J?"}":"]",[B,...T]=z.end,K=U;if(B?.source===V)K=B.offset+B.source.length;else{let L=Q[0].toUpperCase()+Q.substring(1),D=W?`${L} must end with a ${V}`:`${L} in block collection must be sufficiently indented and end with a ${V}`;if(q(U,W?"MISSING_CHAR":"BAD_INDENT",D),B&&B.source.length!==1)T.unshift(B)}if(T.length>0){let L=qQ.resolveEnd(T,K,X.options.strict,q);if(L.comment)if(H.comment)H.comment+=`
96
- `+L.comment;else H.comment=L.comment;H.range=[z.offset,K,L.offset]}else H.range=[z.offset,K,K];return H}YQ.resolveFlowCollection=QQ});var T8=F((_Q)=>{var UQ=E(),WQ=g(),VQ=C0(),KQ=E0(),BQ=W8(),LQ=V8(),TQ=L8();function T9($,Z,X,z,q,G){let J=X.type==="block-map"?BQ.resolveBlockMap($,Z,X,z,G):X.type==="block-seq"?LQ.resolveBlockSeq($,Z,X,z,G):TQ.resolveFlowCollection($,Z,X,z,G),Q=J.constructor;if(q==="!"||q===Q.tagName)return J.tag=Q.tagName,J;if(q)J.tag=q;return J}function DQ($,Z,X,z,q){let G=z.tag,J=!G?null:Z.directives.tagName(G.source,(V)=>q(G,"TAG_RESOLVE_FAILED",V));if(X.type==="block-seq"){let{anchor:V,newlineAfterProp:B}=z,T=V&&G?V.offset>G.offset?V:G:V??G;if(T&&(!B||B.offset<T.offset))q(T,"MISSING_CHAR","Missing newline after block sequence props")}let Q=X.type==="block-map"?"map":X.type==="block-seq"?"seq":X.start.source==="{"?"map":"seq";if(!G||!J||J==="!"||J===VQ.YAMLMap.tagName&&Q==="map"||J===KQ.YAMLSeq.tagName&&Q==="seq")return T9($,Z,X,q,J);let Y=Z.schema.tags.find((V)=>V.tag===J&&V.collection===Q);if(!Y){let V=Z.schema.knownTags[J];if(V?.collection===Q)Z.schema.tags.push(Object.assign({},V,{default:!1})),Y=V;else{if(V)q(G,"BAD_COLLECTION_TYPE",`${V.tag} used for ${Q} collection, but expects ${V.collection??"scalar"}`,!0);else q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${J}`,!0);return T9($,Z,X,q,J)}}let H=T9($,Z,X,q,J,Y),W=Y.resolve?.(H,(V)=>q(G,"TAG_RESOLVE_FAILED",V),Z.options)??H,U=UQ.isNode(W)?W:new WQ.Scalar(W);if(U.range=H.range,U.tag=J,Y?.format)U.format=Y.format;return U}_Q.composeCollection=DQ});var _9=F((PQ)=>{var D9=g();function MQ($,Z,X){let z=Z.offset,q=OQ(Z,$.options.strict,X);if(!q)return{value:"",type:null,comment:"",range:[z,z,z]};let G=q.mode===">"?D9.Scalar.BLOCK_FOLDED:D9.Scalar.BLOCK_LITERAL,J=Z.source?wQ(Z.source):[],Q=J.length;for(let K=J.length-1;K>=0;--K){let L=J[K][1];if(L===""||L==="\r")Q=K;else break}if(Q===0){let K=q.chomp==="+"&&J.length>0?`
97
- `.repeat(Math.max(1,J.length-1)):"",L=z+q.length;if(Z.source)L+=Z.source.length;return{value:K,type:G,comment:q.comment,range:[z,L,L]}}let Y=Z.indent+q.indent,H=Z.offset+q.length,W=0;for(let K=0;K<Q;++K){let[L,D]=J[K];if(D===""||D==="\r"){if(q.indent===0&&L.length>Y)Y=L.length}else{if(L.length<Y)X(H+L.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(q.indent===0)Y=L.length;if(W=K,Y===0&&!$.atRoot)X(H,"BAD_INDENT","Block scalar values in collections must be indented");break}H+=L.length+D.length+1}for(let K=J.length-1;K>=Q;--K)if(J[K][0].length>Y)Q=K+1;let U="",V="",B=!1;for(let K=0;K<W;++K)U+=J[K][0].slice(Y)+`
98
- `;for(let K=W;K<Q;++K){let[L,D]=J[K];H+=L.length+D.length+1;let _=D[D.length-1]==="\r";if(_)D=D.slice(0,-1);if(D&&L.length<Y){let w=`Block scalar lines must not be less indented than their ${q.indent?"explicit indentation indicator":"first line"}`;X(H-D.length-(_?2:1),"BAD_INDENT",w),L=""}if(G===D9.Scalar.BLOCK_LITERAL)U+=V+L.slice(Y)+D,V=`
99
- `;else if(L.length>Y||D[0]==="\t"){if(V===" ")V=`
100
- `;else if(!B&&V===`
101
- `)V=`
88
+ ${V}
89
+ `}};HB.YAMLError=I6;HB.YAMLParseError=v7;HB.YAMLWarning=h7;HB.prettifyError=VB});var s2=R((FB)=>{function TB($,{flow:Z,indicator:X,next:Y,offset:G,onError:z,parentIndent:J,startOnNewline:Q}){let W=!1,V=Q,K=Q,H="",B="",U=!1,F=!1,T=null,w=null,O=null,N=null,P=null,E=null,I=null;for(let D of $){if(F){if(D.type!=="space"&&D.type!=="newline"&&D.type!=="comma")z(D.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");F=!1}if(T){if(V&&D.type!=="comment"&&D.type!=="newline")z(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");T=null}switch(D.type){case"space":if(!Z&&(X!=="doc-start"||Y?.type!=="flow-collection")&&D.source.includes("\t"))T=D;K=!0;break;case"comment":{if(!K)z(D,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let v=D.source.substring(1)||" ";if(!H)H=v;else H+=B+v;B="",V=!1;break}case"newline":if(V){if(H)H+=D.source;else if(!E||X!=="seq-item-ind")W=!0}else B+=D.source;if(V=!0,U=!0,w||O)N=D;K=!0;break;case"anchor":if(w)z(D,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(D.source.endsWith(":"))z(D.offset+D.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);w=D,I??(I=D.offset),V=!1,K=!1,F=!0;break;case"tag":{if(O)z(D,"MULTIPLE_TAGS","A node can have at most one tag");O=D,I??(I=D.offset),V=!1,K=!1,F=!0;break}case X:if(w||O)z(D,"BAD_PROP_ORDER",`Anchors and tags must be after the ${D.source} indicator`);if(E)z(D,"UNEXPECTED_TOKEN",`Unexpected ${D.source} in ${Z??"collection"}`);E=D,V=X==="seq-item-ind"||X==="explicit-key-ind",K=!1;break;case"comma":if(Z){if(P)z(D,"UNEXPECTED_TOKEN",`Unexpected , in ${Z}`);P=D,V=!1,K=!1;break}default:z(D,"UNEXPECTED_TOKEN",`Unexpected ${D.type} token`),V=!1,K=!1}}let A=$[$.length-1],C=A?A.offset+A.source.length:G;if(F&&Y&&Y.type!=="space"&&Y.type!=="newline"&&Y.type!=="comma"&&(Y.type!=="scalar"||Y.source!==""))z(Y.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(T&&(V&&T.indent<=J||Y?.type==="block-map"||Y?.type==="block-seq"))z(T,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:P,found:E,spaceBefore:W,comment:H,hasNewline:U,anchor:w,tag:O,newlineAfterProp:N,end:C,start:I??C}}FB.resolveProps=TB});var j6=R((wB)=>{function J9($){if(!$)return null;switch($.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if($.source.includes(`
90
+ `))return!0;if($.end){for(let Z of $.end)if(Z.type==="newline")return!0}return!1;case"flow-collection":for(let Z of $.items){for(let X of Z.start)if(X.type==="newline")return!0;if(Z.sep){for(let X of Z.sep)if(X.type==="newline")return!0}if(J9(Z.key)||J9(Z.value))return!0}return!1;default:return!0}}wB.containsNewline=J9});var Q9=R((_B)=>{var NB=j6();function OB($,Z,X){if(Z?.type==="flow-collection"){let Y=Z.end[0];if(Y.indent===$&&(Y.source==="]"||Y.source==="}")&&NB.containsNewline(Z))X(Y,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}_B.flowIndentCheck=OB});var W9=R((EB)=>{var u7=m();function DB($,Z,X){let{uniqueKeys:Y}=$.options;if(Y===!1)return!1;let G=typeof Y==="function"?Y:(z,J)=>z===J||u7.isScalar(z)&&u7.isScalar(J)&&z.value===J.value;return Z.some((z)=>G(z.key,X))}EB.mapIncludes=DB});var p7=R((jB)=>{var m7=q$(),AB=F$(),d7=s2(),SB=j6(),c7=Q9(),CB=W9(),l7="All mapping items must start at the same column";function IB({composeNode:$,composeEmptyNode:Z},X,Y,G,z){let Q=new(z?.nodeClass??AB.YAMLMap)(X.schema);if(X.atRoot)X.atRoot=!1;let W=Y.offset,V=null;for(let K of Y.items){let{start:H,key:B,sep:U,value:F}=K,T=d7.resolveProps(H,{indicator:"explicit-key-ind",next:B??U?.[0],offset:W,onError:G,parentIndent:Y.indent,startOnNewline:!0}),w=!T.found;if(w){if(B){if(B.type==="block-seq")G(W,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in B&&B.indent!==Y.indent)G(W,"BAD_INDENT",l7)}if(!T.anchor&&!T.tag&&!U){if(V=T.end,T.comment)if(Q.comment)Q.comment+=`
91
+ `+T.comment;else Q.comment=T.comment;continue}if(T.newlineAfterProp||SB.containsNewline(B))G(B??H[H.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(T.found?.indent!==Y.indent)G(W,"BAD_INDENT",l7);X.atKey=!0;let O=T.end,N=B?$(X,B,T,G):Z(X,O,H,null,T,G);if(X.schema.compat)c7.flowIndentCheck(Y.indent,B,G);if(X.atKey=!1,CB.mapIncludes(X,Q.items,N))G(O,"DUPLICATE_KEY","Map keys must be unique");let P=d7.resolveProps(U??[],{indicator:"map-value-ind",next:F,offset:N.range[2],onError:G,parentIndent:Y.indent,startOnNewline:!B||B.type==="block-scalar"});if(W=P.end,P.found){if(w){if(F?.type==="block-map"&&!P.hasNewline)G(W,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(X.options.strict&&T.start<P.found.offset-1024)G(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let E=F?$(X,F,P,G):Z(X,W,U,null,P,G);if(X.schema.compat)c7.flowIndentCheck(Y.indent,F,G);W=E.range[2];let I=new m7.Pair(N,E);if(X.options.keepSourceTokens)I.srcToken=K;Q.items.push(I)}else{if(w)G(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(P.comment)if(N.comment)N.comment+=`
92
+ `+P.comment;else N.comment=P.comment;let E=new m7.Pair(N);if(X.options.keepSourceTokens)E.srcToken=K;Q.items.push(E)}}if(V&&V<W)G(V,"IMPOSSIBLE","Map comment with trailing content");return Q.range=[Y.offset,W,V??W],Q}jB.resolveBlockMap=IB});var i7=R((gB)=>{var kB=L$(),bB=s2(),fB=Q9();function yB({composeNode:$,composeEmptyNode:Z},X,Y,G,z){let Q=new(z?.nodeClass??kB.YAMLSeq)(X.schema);if(X.atRoot)X.atRoot=!1;if(X.atKey)X.atKey=!1;let W=Y.offset,V=null;for(let{start:K,value:H}of Y.items){let B=bB.resolveProps(K,{indicator:"seq-item-ind",next:H,offset:W,onError:G,parentIndent:Y.indent,startOnNewline:!0});if(!B.found)if(B.anchor||B.tag||H)if(H?.type==="block-seq")G(B.end,"BAD_INDENT","All sequence items must start at the same column");else G(W,"MISSING_CHAR","Sequence item without - indicator");else{if(V=B.end,B.comment)Q.comment=B.comment;continue}let U=H?$(X,H,B,G):Z(X,B.end,K,null,B,G);if(X.schema.compat)fB.flowIndentCheck(Y.indent,H,G);W=U.range[2],Q.items.push(U)}return Q.range=[Y.offset,W,V??W],Q}gB.resolveBlockSeq=yB});var C1=R((uB)=>{function hB($,Z,X,Y){let G="";if($){let z=!1,J="";for(let Q of $){let{source:W,type:V}=Q;switch(V){case"space":z=!0;break;case"comment":{if(X&&!z)Y(Q,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let K=W.substring(1)||" ";if(!G)G=K;else G+=J+K;J="";break}case"newline":if(G)J+=W;z=!0;break;default:Y(Q,"UNEXPECTED_TOKEN",`Unexpected ${V} at node end`)}Z+=W.length}}return{comment:G,offset:Z}}uB.resolveEnd=hB});var r7=R((rB)=>{var dB=m(),cB=q$(),a7=F$(),lB=L$(),pB=C1(),n7=s2(),iB=j6(),aB=W9(),V9="Block collections are not allowed within flow collections",H9=($)=>$&&($.type==="block-map"||$.type==="block-seq");function nB({composeNode:$,composeEmptyNode:Z},X,Y,G,z){let J=Y.start.source==="{",Q=J?"flow map":"flow sequence",V=new(z?.nodeClass??(J?a7.YAMLMap:lB.YAMLSeq))(X.schema);V.flow=!0;let K=X.atRoot;if(K)X.atRoot=!1;if(X.atKey)X.atKey=!1;let H=Y.offset+Y.start.source.length;for(let w=0;w<Y.items.length;++w){let O=Y.items[w],{start:N,key:P,sep:E,value:I}=O,A=n7.resolveProps(N,{flow:Q,indicator:"explicit-key-ind",next:P??E?.[0],offset:H,onError:G,parentIndent:Y.indent,startOnNewline:!1});if(!A.found){if(!A.anchor&&!A.tag&&!E&&!I){if(w===0&&A.comma)G(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`);else if(w<Y.items.length-1)G(A.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${Q}`);if(A.comment)if(V.comment)V.comment+=`
93
+ `+A.comment;else V.comment=A.comment;H=A.end;continue}if(!J&&X.options.strict&&iB.containsNewline(P))G(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(w===0){if(A.comma)G(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`)}else{if(!A.comma)G(A.start,"MISSING_CHAR",`Missing , between ${Q} items`);if(A.comment){let C="";$:for(let D of N)switch(D.type){case"comma":case"space":break;case"comment":C=D.source.substring(1);break $;default:break $}if(C){let D=V.items[V.items.length-1];if(dB.isPair(D))D=D.value??D.key;if(D.comment)D.comment+=`
94
+ `+C;else D.comment=C;A.comment=A.comment.substring(C.length+1)}}}if(!J&&!E&&!A.found){let C=I?$(X,I,A,G):Z(X,A.end,E,null,A,G);if(V.items.push(C),H=C.range[2],H9(I))G(C.range,"BLOCK_IN_FLOW",V9)}else{X.atKey=!0;let C=A.end,D=P?$(X,P,A,G):Z(X,C,N,null,A,G);if(H9(P))G(D.range,"BLOCK_IN_FLOW",V9);X.atKey=!1;let v=n7.resolveProps(E??[],{flow:Q,indicator:"map-value-ind",next:I,offset:D.range[2],onError:G,parentIndent:Y.indent,startOnNewline:!1});if(v.found){if(!J&&!A.found&&X.options.strict){if(E)for(let l of E){if(l===v.found)break;if(l.type==="newline"){G(l,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(A.start<v.found.offset-1024)G(v.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(I)if("source"in I&&I.source?.[0]===":")G(I,"MISSING_CHAR",`Missing space after : in ${Q}`);else G(v.start,"MISSING_CHAR",`Missing , or : between ${Q} items`);let k=I?$(X,I,v,G):v.found?Z(X,v.end,E,null,v,G):null;if(k){if(H9(I))G(k.range,"BLOCK_IN_FLOW",V9)}else if(v.comment)if(D.comment)D.comment+=`
95
+ `+v.comment;else D.comment=v.comment;let i=new cB.Pair(D,k);if(X.options.keepSourceTokens)i.srcToken=O;if(J){let l=V;if(aB.mapIncludes(X,l.items,D))G(C,"DUPLICATE_KEY","Map keys must be unique");l.items.push(i)}else{let l=new a7.YAMLMap(X.schema);l.flow=!0,l.items.push(i);let R0=(k??D).range;l.range=[D.range[0],R0[1],R0[2]],V.items.push(l)}H=k?k.range[2]:v.end}}let B=J?"}":"]",[U,...F]=Y.end,T=H;if(U?.source===B)T=U.offset+U.source.length;else{let w=Q[0].toUpperCase()+Q.substring(1),O=K?`${w} must end with a ${B}`:`${w} in block collection must be sufficiently indented and end with a ${B}`;if(G(H,K?"MISSING_CHAR":"BAD_INDENT",O),U&&U.source.length!==1)F.unshift(U)}if(F.length>0){let w=pB.resolveEnd(F,T,X.options.strict,G);if(w.comment)if(V.comment)V.comment+=`
96
+ `+w.comment;else V.comment=w.comment;V.range=[Y.offset,T,w.offset]}else V.range=[Y.offset,T,T];return V}rB.resolveFlowCollection=nB});var s7=R((zU)=>{var oB=m(),tB=o(),eB=F$(),$U=L$(),ZU=p7(),XU=i7(),YU=r7();function K9($,Z,X,Y,G,z){let J=X.type==="block-map"?ZU.resolveBlockMap($,Z,X,Y,z):X.type==="block-seq"?XU.resolveBlockSeq($,Z,X,Y,z):YU.resolveFlowCollection($,Z,X,Y,z),Q=J.constructor;if(G==="!"||G===Q.tagName)return J.tag=Q.tagName,J;if(G)J.tag=G;return J}function GU($,Z,X,Y,G){let z=Y.tag,J=!z?null:Z.directives.tagName(z.source,(B)=>G(z,"TAG_RESOLVE_FAILED",B));if(X.type==="block-seq"){let{anchor:B,newlineAfterProp:U}=Y,F=B&&z?B.offset>z.offset?B:z:B??z;if(F&&(!U||U.offset<F.offset))G(F,"MISSING_CHAR","Missing newline after block sequence props")}let Q=X.type==="block-map"?"map":X.type==="block-seq"?"seq":X.start.source==="{"?"map":"seq";if(!z||!J||J==="!"||J===eB.YAMLMap.tagName&&Q==="map"||J===$U.YAMLSeq.tagName&&Q==="seq")return K9($,Z,X,G,J);let W=Z.schema.tags.find((B)=>B.tag===J&&B.collection===Q);if(!W){let B=Z.schema.knownTags[J];if(B?.collection===Q)Z.schema.tags.push(Object.assign({},B,{default:!1})),W=B;else{if(B)G(z,"BAD_COLLECTION_TYPE",`${B.tag} used for ${Q} collection, but expects ${B.collection??"scalar"}`,!0);else G(z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${J}`,!0);return K9($,Z,X,G,J)}}let V=K9($,Z,X,G,J,W),K=W.resolve?.(V,(B)=>G(z,"TAG_RESOLVE_FAILED",B),Z.options)??V,H=oB.isNode(K)?K:new tB.Scalar(K);if(H.range=V.range,H.tag=J,W?.format)H.format=W.format;return H}zU.composeCollection=GU});var U9=R((HU)=>{var B9=o();function QU($,Z,X){let Y=Z.offset,G=WU(Z,$.options.strict,X);if(!G)return{value:"",type:null,comment:"",range:[Y,Y,Y]};let z=G.mode===">"?B9.Scalar.BLOCK_FOLDED:B9.Scalar.BLOCK_LITERAL,J=Z.source?VU(Z.source):[],Q=J.length;for(let T=J.length-1;T>=0;--T){let w=J[T][1];if(w===""||w==="\r")Q=T;else break}if(Q===0){let T=G.chomp==="+"&&J.length>0?`
97
+ `.repeat(Math.max(1,J.length-1)):"",w=Y+G.length;if(Z.source)w+=Z.source.length;return{value:T,type:z,comment:G.comment,range:[Y,w,w]}}let W=Z.indent+G.indent,V=Z.offset+G.length,K=0;for(let T=0;T<Q;++T){let[w,O]=J[T];if(O===""||O==="\r"){if(G.indent===0&&w.length>W)W=w.length}else{if(w.length<W)X(V+w.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(G.indent===0)W=w.length;if(K=T,W===0&&!$.atRoot)X(V,"BAD_INDENT","Block scalar values in collections must be indented");break}V+=w.length+O.length+1}for(let T=J.length-1;T>=Q;--T)if(J[T][0].length>W)Q=T+1;let H="",B="",U=!1;for(let T=0;T<K;++T)H+=J[T][0].slice(W)+`
98
+ `;for(let T=K;T<Q;++T){let[w,O]=J[T];V+=w.length+O.length+1;let N=O[O.length-1]==="\r";if(N)O=O.slice(0,-1);if(O&&w.length<W){let E=`Block scalar lines must not be less indented than their ${G.indent?"explicit indentation indicator":"first line"}`;X(V-O.length-(N?2:1),"BAD_INDENT",E),w=""}if(z===B9.Scalar.BLOCK_LITERAL)H+=B+w.slice(W)+O,B=`
99
+ `;else if(w.length>W||O[0]==="\t"){if(B===" ")B=`
100
+ `;else if(!U&&B===`
101
+ `)B=`
102
102
 
103
- `;U+=V+L.slice(Y)+D,V=`
104
- `,B=!0}else if(D==="")if(V===`
105
- `)U+=`
106
- `;else V=`
107
- `;else U+=V+D,V=" ",B=!1}switch(q.chomp){case"-":break;case"+":for(let K=Q;K<J.length;++K)U+=`
108
- `+J[K][0].slice(Y);if(U[U.length-1]!==`
109
- `)U+=`
110
- `;break;default:U+=`
111
- `}let T=z+q.length+Z.source.length;return{value:U,type:G,comment:q.comment,range:[z,T,T]}}function OQ({offset:$,props:Z},X,z){if(Z[0].type!=="block-scalar-header")return z(Z[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:q}=Z[0],G=q[0],J=0,Q="",Y=-1;for(let V=1;V<q.length;++V){let B=q[V];if(!Q&&(B==="-"||B==="+"))Q=B;else{let T=Number(B);if(!J&&T)J=T;else if(Y===-1)Y=$+V}}if(Y!==-1)z(Y,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${q}`);let H=!1,W="",U=q.length;for(let V=1;V<Z.length;++V){let B=Z[V];switch(B.type){case"space":H=!0;case"newline":U+=B.source.length;break;case"comment":if(X&&!H)z(B,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");U+=B.source.length,W=B.source.substring(1);break;case"error":z(B,"UNEXPECTED_TOKEN",B.message),U+=B.source.length;break;default:{let T=`Unexpected token in block scalar header: ${B.type}`;z(B,"UNEXPECTED_TOKEN",T);let K=B.source;if(K&&typeof K==="string")U+=K.length}}}return{mode:G,indent:J,chomp:Q,comment:W,length:U}}function wQ($){let Z=$.split(/\n( *)/),X=Z[0],z=X.match(/^( *)/),G=[z?.[1]?[z[1],X.slice(z[1].length)]:["",X]];for(let J=1;J<Z.length;J+=2)G.push([Z[J],Z[J+1]]);return G}PQ.resolveBlockScalar=MQ});var M9=F((yQ)=>{var F9=g(),RQ=V$();function AQ($,Z,X){let{offset:z,type:q,source:G,end:J}=$,Q,Y,H=(V,B,T)=>X(z+V,B,T);switch(q){case"scalar":Q=F9.Scalar.PLAIN,Y=jQ(G,H);break;case"single-quoted-scalar":Q=F9.Scalar.QUOTE_SINGLE,Y=NQ(G,H);break;case"double-quoted-scalar":Q=F9.Scalar.QUOTE_DOUBLE,Y=SQ(G,H);break;default:return X($,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${q}`),{value:"",type:null,comment:"",range:[z,z+G.length,z+G.length]}}let W=z+G.length,U=RQ.resolveEnd(J,W,Z,X);return{value:Y,type:Q,comment:U.comment,range:[z,W,U.offset]}}function jQ($,Z){let X="";switch($[0]){case"\t":X="a tab character";break;case",":X="flow indicator character ,";break;case"%":X="directive indicator character %";break;case"|":case">":{X=`block scalar indicator ${$[0]}`;break}case"@":case"`":{X=`reserved character ${$[0]}`;break}}if(X)Z(0,"BAD_SCALAR_START",`Plain value cannot start with ${X}`);return D8($)}function NQ($,Z){if($[$.length-1]!=="'"||$.length===1)Z($.length,"MISSING_CHAR","Missing closing 'quote");return D8($.slice(1,-1)).replace(/''/g,"'")}function D8($){let Z,X;try{Z=new RegExp(`(.*?)(?<![ ])[ ]*\r?
103
+ `;H+=B+w.slice(W)+O,B=`
104
+ `,U=!0}else if(O==="")if(B===`
105
+ `)H+=`
106
+ `;else B=`
107
+ `;else H+=B+O,B=" ",U=!1}switch(G.chomp){case"-":break;case"+":for(let T=Q;T<J.length;++T)H+=`
108
+ `+J[T][0].slice(W);if(H[H.length-1]!==`
109
+ `)H+=`
110
+ `;break;default:H+=`
111
+ `}let F=Y+G.length+Z.source.length;return{value:H,type:z,comment:G.comment,range:[Y,F,F]}}function WU({offset:$,props:Z},X,Y){if(Z[0].type!=="block-scalar-header")return Y(Z[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:G}=Z[0],z=G[0],J=0,Q="",W=-1;for(let B=1;B<G.length;++B){let U=G[B];if(!Q&&(U==="-"||U==="+"))Q=U;else{let F=Number(U);if(!J&&F)J=F;else if(W===-1)W=$+B}}if(W!==-1)Y(W,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${G}`);let V=!1,K="",H=G.length;for(let B=1;B<Z.length;++B){let U=Z[B];switch(U.type){case"space":V=!0;case"newline":H+=U.source.length;break;case"comment":if(X&&!V)Y(U,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");H+=U.source.length,K=U.source.substring(1);break;case"error":Y(U,"UNEXPECTED_TOKEN",U.message),H+=U.source.length;break;default:{let F=`Unexpected token in block scalar header: ${U.type}`;Y(U,"UNEXPECTED_TOKEN",F);let T=U.source;if(T&&typeof T==="string")H+=T.length}}}return{mode:z,indent:J,chomp:Q,comment:K,length:H}}function VU($){let Z=$.split(/\n( *)/),X=Z[0],Y=X.match(/^( *)/),z=[Y?.[1]?[Y[1],X.slice(Y[1].length)]:["",X]];for(let J=1;J<Z.length;J+=2)z.push([Z[J],Z[J+1]]);return z}HU.resolveBlockScalar=QU});var T9=R((NU)=>{var q9=o(),BU=C1();function UU($,Z,X){let{offset:Y,type:G,source:z,end:J}=$,Q,W,V=(B,U,F)=>X(Y+B,U,F);switch(G){case"scalar":Q=q9.Scalar.PLAIN,W=qU(z,V);break;case"single-quoted-scalar":Q=q9.Scalar.QUOTE_SINGLE,W=TU(z,V);break;case"double-quoted-scalar":Q=q9.Scalar.QUOTE_DOUBLE,W=FU(z,V);break;default:return X($,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${G}`),{value:"",type:null,comment:"",range:[Y,Y+z.length,Y+z.length]}}let K=Y+z.length,H=BU.resolveEnd(J,K,Z,X);return{value:W,type:Q,comment:H.comment,range:[Y,K,H.offset]}}function qU($,Z){let X="";switch($[0]){case"\t":X="a tab character";break;case",":X="flow indicator character ,";break;case"%":X="directive indicator character %";break;case"|":case">":{X=`block scalar indicator ${$[0]}`;break}case"@":case"`":{X=`reserved character ${$[0]}`;break}}if(X)Z(0,"BAD_SCALAR_START",`Plain value cannot start with ${X}`);return o7($)}function TU($,Z){if($[$.length-1]!=="'"||$.length===1)Z($.length,"MISSING_CHAR","Missing closing 'quote");return o7($.slice(1,-1)).replace(/''/g,"'")}function o7($){let Z,X;try{Z=new RegExp(`(.*?)(?<![ ])[ ]*\r?
112
112
  `,"sy"),X=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
113
- `,"sy")}catch{Z=/(.*?)[ \t]*\r?\n/sy,X=/[ \t]*(.*?)[ \t]*\r?\n/sy}let z=Z.exec($);if(!z)return $;let q=z[1],G=" ",J=Z.lastIndex;X.lastIndex=J;while(z=X.exec($)){if(z[1]==="")if(G===`
114
- `)q+=G;else G=`
115
- `;else q+=G+z[1],G=" ";J=X.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=J,z=Q.exec($),q+G+(z?.[1]??"")}function SQ($,Z){let X="";for(let z=1;z<$.length-1;++z){let q=$[z];if(q==="\r"&&$[z+1]===`
116
- `)continue;if(q===`
117
- `){let{fold:G,offset:J}=CQ($,z);X+=G,z=J}else if(q==="\\"){let G=$[++z],J=EQ[G];if(J)X+=J;else if(G===`
118
- `){G=$[z+1];while(G===" "||G==="\t")G=$[++z+1]}else if(G==="\r"&&$[z+1]===`
119
- `){G=$[++z+1];while(G===" "||G==="\t")G=$[++z+1]}else if(G==="x"||G==="u"||G==="U"){let Q={x:2,u:4,U:8}[G];X+=bQ($,z+1,Q,Z),z+=Q}else{let Q=$.substr(z-1,2);Z(z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),X+=Q}}else if(q===" "||q==="\t"){let G=z,J=$[z+1];while(J===" "||J==="\t")J=$[++z+1];if(J!==`
120
- `&&!(J==="\r"&&$[z+2]===`
121
- `))X+=z>G?$.slice(G,z+1):q}else X+=q}if($[$.length-1]!=='"'||$.length===1)Z($.length,"MISSING_CHAR",'Missing closing "quote');return X}function CQ($,Z){let X="",z=$[Z+1];while(z===" "||z==="\t"||z===`
122
- `||z==="\r"){if(z==="\r"&&$[Z+2]!==`
123
- `)break;if(z===`
113
+ `,"sy")}catch{Z=/(.*?)[ \t]*\r?\n/sy,X=/[ \t]*(.*?)[ \t]*\r?\n/sy}let Y=Z.exec($);if(!Y)return $;let G=Y[1],z=" ",J=Z.lastIndex;X.lastIndex=J;while(Y=X.exec($)){if(Y[1]==="")if(z===`
114
+ `)G+=z;else z=`
115
+ `;else G+=z+Y[1],z=" ";J=X.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=J,Y=Q.exec($),G+z+(Y?.[1]??"")}function FU($,Z){let X="";for(let Y=1;Y<$.length-1;++Y){let G=$[Y];if(G==="\r"&&$[Y+1]===`
116
+ `)continue;if(G===`
117
+ `){let{fold:z,offset:J}=LU($,Y);X+=z,Y=J}else if(G==="\\"){let z=$[++Y],J=wU[z];if(J)X+=J;else if(z===`
118
+ `){z=$[Y+1];while(z===" "||z==="\t")z=$[++Y+1]}else if(z==="\r"&&$[Y+1]===`
119
+ `){z=$[++Y+1];while(z===" "||z==="\t")z=$[++Y+1]}else if(z==="x"||z==="u"||z==="U"){let Q={x:2,u:4,U:8}[z];X+=MU($,Y+1,Q,Z),Y+=Q}else{let Q=$.substr(Y-1,2);Z(Y-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),X+=Q}}else if(G===" "||G==="\t"){let z=Y,J=$[Y+1];while(J===" "||J==="\t")J=$[++Y+1];if(J!==`
120
+ `&&!(J==="\r"&&$[Y+2]===`
121
+ `))X+=Y>z?$.slice(z,Y+1):G}else X+=G}if($[$.length-1]!=='"'||$.length===1)Z($.length,"MISSING_CHAR",'Missing closing "quote');return X}function LU($,Z){let X="",Y=$[Z+1];while(Y===" "||Y==="\t"||Y===`
122
+ `||Y==="\r"){if(Y==="\r"&&$[Z+2]!==`
123
+ `)break;if(Y===`
124
124
  `)X+=`
125
- `;Z+=1,z=$[Z+1]}if(!X)X=" ";return{fold:X,offset:Z}}var EQ={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
126
- `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function bQ($,Z,X,z){let q=$.substr(Z,X),J=q.length===X&&/^[0-9a-fA-F]+$/.test(q)?parseInt(q,16):NaN;if(isNaN(J)){let Q=$.substr(Z-2,X+2);return z(Z-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Q}return String.fromCodePoint(J)}yQ.resolveFlowScalar=AQ});var F8=F((uQ)=>{var a0=E(),_8=g(),kQ=_9(),fQ=M9();function hQ($,Z,X,z){let{value:q,type:G,comment:J,range:Q}=Z.type==="block-scalar"?kQ.resolveBlockScalar($,Z,z):fQ.resolveFlowScalar(Z,$.options.strict,z),Y=X?$.directives.tagName(X.source,(U)=>z(X,"TAG_RESOLVE_FAILED",U)):null,H;if($.options.stringKeys&&$.atKey)H=$.schema[a0.SCALAR];else if(Y)H=gQ($.schema,q,Y,X,z);else if(Z.type==="scalar")H=vQ($,q,Z,z);else H=$.schema[a0.SCALAR];let W;try{let U=H.resolve(q,(V)=>z(X??Z,"TAG_RESOLVE_FAILED",V),$.options);W=a0.isScalar(U)?U:new _8.Scalar(U)}catch(U){let V=U instanceof Error?U.message:String(U);z(X??Z,"TAG_RESOLVE_FAILED",V),W=new _8.Scalar(q)}if(W.range=Q,W.source=q,G)W.type=G;if(Y)W.tag=Y;if(H.format)W.format=H.format;if(J)W.comment=J;return W}function gQ($,Z,X,z,q){if(X==="!")return $[a0.SCALAR];let G=[];for(let Q of $.tags)if(!Q.collection&&Q.tag===X)if(Q.default&&Q.test)G.push(Q);else return Q;for(let Q of G)if(Q.test?.test(Z))return Q;let J=$.knownTags[X];if(J&&!J.collection)return $.tags.push(Object.assign({},J,{default:!1,test:void 0})),J;return q(z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${X}`,X!=="tag:yaml.org,2002:str"),$[a0.SCALAR]}function vQ({atKey:$,directives:Z,schema:X},z,q,G){let J=X.tags.find((Q)=>(Q.default===!0||$&&Q.default==="key")&&Q.test?.test(z))||X[a0.SCALAR];if(X.compat){let Q=X.compat.find((Y)=>Y.default&&Y.test?.test(z))??X[a0.SCALAR];if(J.tag!==Q.tag){let Y=Z.tagString(J.tag),H=Z.tagString(Q.tag),W=`Value may be parsed as either ${Y} or ${H}`;G(q,"TAG_RESOLVE_FAILED",W,!0)}}return J}uQ.composeScalar=hQ});var M8=F((pQ)=>{function dQ($,Z,X){if(Z){X??(X=Z.length);for(let z=X-1;z>=0;--z){let q=Z[z];switch(q.type){case"space":case"comment":case"newline":$-=q.source.length;continue}q=Z[++z];while(q?.type==="space")$+=q.source.length,q=Z[++z];break}}return $}pQ.emptyScalarPosition=dQ});var P8=F((tQ)=>{var cQ=v$(),iQ=E(),aQ=T8(),O8=F8(),nQ=V$(),sQ=M8(),rQ={composeNode:w8,composeEmptyNode:O9};function w8($,Z,X,z){let q=$.atKey,{spaceBefore:G,comment:J,anchor:Q,tag:Y}=X,H,W=!0;switch(Z.type){case"alias":if(H=oQ($,Z,z),Q||Y)z(Z,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(H=O8.composeScalar($,Z,Y,z),Q)H.anchor=Q.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(H=aQ.composeCollection(rQ,$,Z,X,z),Q)H.anchor=Q.source.substring(1);break;default:{let U=Z.type==="error"?Z.message:`Unsupported token (type: ${Z.type})`;z(Z,"UNEXPECTED_TOKEN",U),H=O9($,Z.offset,void 0,null,X,z),W=!1}}if(Q&&H.anchor==="")z(Q,"BAD_ALIAS","Anchor cannot be an empty string");if(q&&$.options.stringKeys&&(!iQ.isScalar(H)||typeof H.value!=="string"||H.tag&&H.tag!=="tag:yaml.org,2002:str"))z(Y??Z,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)H.spaceBefore=!0;if(J)if(Z.type==="scalar"&&Z.source==="")H.comment=J;else H.commentBefore=J;if($.options.keepSourceTokens&&W)H.srcToken=Z;return H}function O9($,Z,X,z,{spaceBefore:q,comment:G,anchor:J,tag:Q,end:Y},H){let W={type:"scalar",offset:sQ.emptyScalarPosition(Z,X,z),indent:-1,source:""},U=O8.composeScalar($,W,Q,H);if(J){if(U.anchor=J.source.substring(1),U.anchor==="")H(J,"BAD_ALIAS","Anchor cannot be an empty string")}if(q)U.spaceBefore=!0;if(G)U.comment=G,U.range[2]=Y;return U}function oQ({options:$},{offset:Z,source:X,end:z},q){let G=new cQ.Alias(X.substring(1));if(G.source==="")q(Z,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))q(Z+X.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let J=Z+X.length,Q=nQ.resolveEnd(z,J,$.strict,q);if(G.range=[Z,J,Q.offset],Q.comment)G.comment=Q.comment;return G}tQ.composeEmptyNode=O9;tQ.composeNode=w8});var R8=F((GY)=>{var ZY=$1(),I8=P8(),XY=V$(),zY=X1();function qY($,Z,{offset:X,start:z,value:q,end:G},J){let Q=Object.assign({_directives:Z},$),Y=new ZY.Document(void 0,Q),H={atKey:!1,atRoot:!0,directives:Y.directives,options:Y.options,schema:Y.schema},W=zY.resolveProps(z,{indicator:"doc-start",next:q??G?.[0],offset:X,onError:J,parentIndent:0,startOnNewline:!0});if(W.found){if(Y.directives.docStart=!0,q&&(q.type==="block-map"||q.type==="block-seq")&&!W.hasNewline)J(W.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}Y.contents=q?I8.composeNode(H,q,W,J):I8.composeEmptyNode(H,W.end,z,null,W,J);let U=Y.contents.range[2],V=XY.resolveEnd(G,U,!1,J);if(V.comment)Y.comment=V.comment;return Y.range=[X,U,V.offset],Y}GY.composeDoc=qY});var w9=F((VY)=>{var QY=L0("process"),YY=A4(),HY=$1(),z1=Z1(),A8=E(),UY=R8(),WY=V$();function q1($){if(typeof $==="number")return[$,$+1];if(Array.isArray($))return $.length===2?$:[$[0],$[1]];let{offset:Z,source:X}=$;return[Z,Z+(typeof X==="string"?X.length:1)]}function j8($){let Z="",X=!1,z=!1;for(let q=0;q<$.length;++q){let G=$[q];switch(G[0]){case"#":Z+=(Z===""?"":z?`
125
+ `;Z+=1,Y=$[Z+1]}if(!X)X=" ";return{fold:X,offset:Z}}var wU={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
126
+ `,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function MU($,Z,X,Y){let G=$.substr(Z,X),J=G.length===X&&/^[0-9a-fA-F]+$/.test(G)?parseInt(G,16):NaN;if(isNaN(J)){let Q=$.substr(Z-2,X+2);return Y(Z-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Q}return String.fromCodePoint(J)}NU.resolveFlowScalar=UU});var e7=R((AU)=>{var i$=m(),t7=o(),_U=U9(),PU=T9();function DU($,Z,X,Y){let{value:G,type:z,comment:J,range:Q}=Z.type==="block-scalar"?_U.resolveBlockScalar($,Z,Y):PU.resolveFlowScalar(Z,$.options.strict,Y),W=X?$.directives.tagName(X.source,(H)=>Y(X,"TAG_RESOLVE_FAILED",H)):null,V;if($.options.stringKeys&&$.atKey)V=$.schema[i$.SCALAR];else if(W)V=EU($.schema,G,W,X,Y);else if(Z.type==="scalar")V=RU($,G,Z,Y);else V=$.schema[i$.SCALAR];let K;try{let H=V.resolve(G,(B)=>Y(X??Z,"TAG_RESOLVE_FAILED",B),$.options);K=i$.isScalar(H)?H:new t7.Scalar(H)}catch(H){let B=H instanceof Error?H.message:String(H);Y(X??Z,"TAG_RESOLVE_FAILED",B),K=new t7.Scalar(G)}if(K.range=Q,K.source=G,z)K.type=z;if(W)K.tag=W;if(V.format)K.format=V.format;if(J)K.comment=J;return K}function EU($,Z,X,Y,G){if(X==="!")return $[i$.SCALAR];let z=[];for(let Q of $.tags)if(!Q.collection&&Q.tag===X)if(Q.default&&Q.test)z.push(Q);else return Q;for(let Q of z)if(Q.test?.test(Z))return Q;let J=$.knownTags[X];if(J&&!J.collection)return $.tags.push(Object.assign({},J,{default:!1,test:void 0})),J;return G(Y,"TAG_RESOLVE_FAILED",`Unresolved tag: ${X}`,X!=="tag:yaml.org,2002:str"),$[i$.SCALAR]}function RU({atKey:$,directives:Z,schema:X},Y,G,z){let J=X.tags.find((Q)=>(Q.default===!0||$&&Q.default==="key")&&Q.test?.test(Y))||X[i$.SCALAR];if(X.compat){let Q=X.compat.find((W)=>W.default&&W.test?.test(Y))??X[i$.SCALAR];if(J.tag!==Q.tag){let W=Z.tagString(J.tag),V=Z.tagString(Q.tag),K=`Value may be parsed as either ${W} or ${V}`;z(G,"TAG_RESOLVE_FAILED",K,!0)}}return J}AU.composeScalar=DU});var $Y=R((IU)=>{function CU($,Z,X){if(Z){X??(X=Z.length);for(let Y=X-1;Y>=0;--Y){let G=Z[Y];switch(G.type){case"space":case"comment":case"newline":$-=G.source.length;continue}G=Z[++Y];while(G?.type==="space")$+=G.source.length,G=Z[++Y];break}}return $}IU.emptyScalarPosition=CU});var YY=R((hU)=>{var xU=k2(),kU=m(),bU=s7(),ZY=e7(),fU=C1(),yU=$Y(),gU={composeNode:XY,composeEmptyNode:F9};function XY($,Z,X,Y){let G=$.atKey,{spaceBefore:z,comment:J,anchor:Q,tag:W}=X,V,K=!0;switch(Z.type){case"alias":if(V=vU($,Z,Y),Q||W)Y(Z,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(V=ZY.composeScalar($,Z,W,Y),Q)V.anchor=Q.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(V=bU.composeCollection(gU,$,Z,X,Y),Q)V.anchor=Q.source.substring(1);break;default:{let H=Z.type==="error"?Z.message:`Unsupported token (type: ${Z.type})`;Y(Z,"UNEXPECTED_TOKEN",H),V=F9($,Z.offset,void 0,null,X,Y),K=!1}}if(Q&&V.anchor==="")Y(Q,"BAD_ALIAS","Anchor cannot be an empty string");if(G&&$.options.stringKeys&&(!kU.isScalar(V)||typeof V.value!=="string"||V.tag&&V.tag!=="tag:yaml.org,2002:str"))Y(W??Z,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(z)V.spaceBefore=!0;if(J)if(Z.type==="scalar"&&Z.source==="")V.comment=J;else V.commentBefore=J;if($.options.keepSourceTokens&&K)V.srcToken=Z;return V}function F9($,Z,X,Y,{spaceBefore:G,comment:z,anchor:J,tag:Q,end:W},V){let K={type:"scalar",offset:yU.emptyScalarPosition(Z,X,Y),indent:-1,source:""},H=ZY.composeScalar($,K,Q,V);if(J){if(H.anchor=J.source.substring(1),H.anchor==="")V(J,"BAD_ALIAS","Anchor cannot be an empty string")}if(G)H.spaceBefore=!0;if(z)H.comment=z,H.range[2]=W;return H}function vU({options:$},{offset:Z,source:X,end:Y},G){let z=new xU.Alias(X.substring(1));if(z.source==="")G(Z,"BAD_ALIAS","Alias cannot be an empty string");if(z.source.endsWith(":"))G(Z+X.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let J=Z+X.length,Q=fU.resolveEnd(Y,J,$.strict,G);if(z.range=[Z,J,Q.offset],Q.comment)z.comment=Q.comment;return z}hU.composeEmptyNode=F9;hU.composeNode=XY});var zY=R((iU)=>{var dU=n2(),GY=YY(),cU=C1(),lU=s2();function pU($,Z,{offset:X,start:Y,value:G,end:z},J){let Q=Object.assign({_directives:Z},$),W=new dU.Document(void 0,Q),V={atKey:!1,atRoot:!0,directives:W.directives,options:W.options,schema:W.schema},K=lU.resolveProps(Y,{indicator:"doc-start",next:G??z?.[0],offset:X,onError:J,parentIndent:0,startOnNewline:!0});if(K.found){if(W.directives.docStart=!0,G&&(G.type==="block-map"||G.type==="block-seq")&&!K.hasNewline)J(K.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}W.contents=G?GY.composeNode(V,G,K,J):GY.composeEmptyNode(V,K.end,Y,null,K,J);let H=W.contents.range[2],B=cU.resolveEnd(z,H,!1,J);if(B.comment)W.comment=B.comment;return W.range=[X,H,B.offset],W}iU.composeDoc=pU});var L9=R((eU)=>{var nU=r0("process"),rU=OX(),sU=n2(),o2=r2(),JY=m(),oU=zY(),tU=C1();function t2($){if(typeof $==="number")return[$,$+1];if(Array.isArray($))return $.length===2?$:[$[0],$[1]];let{offset:Z,source:X}=$;return[Z,Z+(typeof X==="string"?X.length:1)]}function QY($){let Z="",X=!1,Y=!1;for(let G=0;G<$.length;++G){let z=$[G];switch(z[0]){case"#":Z+=(Z===""?"":Y?`
127
127
 
128
128
  `:`
129
- `)+(G.substring(1)||" "),X=!0,z=!1;break;case"%":if($[q+1]?.[0]!=="#")q+=1;X=!1;break;default:if(!X)z=!0;X=!1}}return{comment:Z,afterEmptyLine:z}}class N8{constructor($={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(Z,X,z,q)=>{let G=q1(Z);if(q)this.warnings.push(new z1.YAMLWarning(G,X,z));else this.errors.push(new z1.YAMLParseError(G,X,z))},this.directives=new YY.Directives({version:$.version||"1.2"}),this.options=$}decorate($,Z){let{comment:X,afterEmptyLine:z}=j8(this.prelude);if(X){let q=$.contents;if(Z)$.comment=$.comment?`${$.comment}
130
- ${X}`:X;else if(z||$.directives.docStart||!q)$.commentBefore=X;else if(A8.isCollection(q)&&!q.flow&&q.items.length>0){let G=q.items[0];if(A8.isPair(G))G=G.key;let J=G.commentBefore;G.commentBefore=J?`${X}
131
- ${J}`:X}else{let G=q.commentBefore;q.commentBefore=G?`${X}
132
- ${G}`:X}}if(Z)Array.prototype.push.apply($.errors,this.errors),Array.prototype.push.apply($.warnings,this.warnings);else $.errors=this.errors,$.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:j8(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose($,Z=!1,X=-1){for(let z of $)yield*this.next(z);yield*this.end(Z,X)}*next($){if(QY.env.LOG_STREAM)console.dir($,{depth:null});switch($.type){case"directive":this.directives.add($.source,(Z,X,z)=>{let q=q1($);q[0]+=Z,this.onError(q,"BAD_DIRECTIVE",X,z)}),this.prelude.push($.source),this.atDirectives=!0;break;case"document":{let Z=UY.composeDoc(this.options,this.directives,$,this.onError);if(this.atDirectives&&!Z.directives.docStart)this.onError($,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(Z,!1),this.doc)yield this.doc;this.doc=Z,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push($.source);break;case"error":{let Z=$.source?`${$.message}: ${JSON.stringify($.source)}`:$.message,X=new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN",Z);if(this.atDirectives||!this.doc)this.errors.push(X);else this.doc.errors.push(X);break}case"doc-end":{if(!this.doc){this.errors.push(new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let Z=WY.resolveEnd($.end,$.offset+$.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),Z.comment){let X=this.doc.comment;this.doc.comment=X?`${X}
133
- ${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.push(new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN",`Unsupported token ${$.type}`))}}*end($=!1,Z=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if($){let X=Object.assign({_directives:this.directives},this.options),z=new HY.Document(void 0,X);if(this.atDirectives)this.onError(Z,"MISSING_CHAR","Missing directives-end indicator line");z.range=[0,Z,Z],this.decorate(z,!1),yield z}}}VY.Composer=N8});var E8=F((OY)=>{var BY=_9(),LY=M9(),TY=Z1(),S8=p$();function DY($,Z=!0,X){if($){let z=(q,G,J)=>{let Q=typeof q==="number"?q:Array.isArray(q)?q[0]:q.offset;if(X)X(Q,G,J);else throw new TY.YAMLParseError([Q,Q+1],G,J)};switch($.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return LY.resolveFlowScalar($,Z,z);case"block-scalar":return BY.resolveBlockScalar({options:{strict:Z}},$,z)}}return null}function _Y($,Z){let{implicitKey:X=!1,indent:z,inFlow:q=!1,offset:G=-1,type:J="PLAIN"}=Z,Q=S8.stringifyString({type:J,value:$},{implicitKey:X,indent:z>0?" ".repeat(z):"",inFlow:q,options:{blockQuote:!0,lineWidth:-1}}),Y=Z.end??[{type:"newline",offset:-1,indent:z,source:`
134
- `}];switch(Q[0]){case"|":case">":{let H=Q.indexOf(`
135
- `),W=Q.substring(0,H),U=Q.substring(H+1)+`
136
- `,V=[{type:"block-scalar-header",offset:G,indent:z,source:W}];if(!C8(V,Y))V.push({type:"newline",offset:-1,indent:z,source:`
137
- `});return{type:"block-scalar",offset:G,indent:z,props:V,source:U}}case'"':return{type:"double-quoted-scalar",offset:G,indent:z,source:Q,end:Y};case"'":return{type:"single-quoted-scalar",offset:G,indent:z,source:Q,end:Y};default:return{type:"scalar",offset:G,indent:z,source:Q,end:Y}}}function FY($,Z,X={}){let{afterKey:z=!1,implicitKey:q=!1,inFlow:G=!1,type:J}=X,Q="indent"in $?$.indent:null;if(z&&typeof Q==="number")Q+=2;if(!J)switch($.type){case"single-quoted-scalar":J="QUOTE_SINGLE";break;case"double-quoted-scalar":J="QUOTE_DOUBLE";break;case"block-scalar":{let H=$.props[0];if(H.type!=="block-scalar-header")throw Error("Invalid block scalar header");J=H.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:J="PLAIN"}let Y=S8.stringifyString({type:J,value:Z},{implicitKey:q||Q===null,indent:Q!==null&&Q>0?" ".repeat(Q):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(Y[0]){case"|":case">":MY($,Y);break;case'"':P9($,Y,"double-quoted-scalar");break;case"'":P9($,Y,"single-quoted-scalar");break;default:P9($,Y,"scalar")}}function MY($,Z){let X=Z.indexOf(`
138
- `),z=Z.substring(0,X),q=Z.substring(X+1)+`
139
- `;if($.type==="block-scalar"){let G=$.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=z,$.source=q}else{let{offset:G}=$,J="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:G,indent:J,source:z}];if(!C8(Q,"end"in $?$.end:void 0))Q.push({type:"newline",offset:-1,indent:J,source:`
140
- `});for(let Y of Object.keys($))if(Y!=="type"&&Y!=="offset")delete $[Y];Object.assign($,{type:"block-scalar",indent:J,props:Q,source:q})}}function C8($,Z){if(Z)for(let X of Z)switch(X.type){case"space":case"comment":$.push(X);break;case"newline":return $.push(X),!0}return!1}function P9($,Z,X){switch($.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":$.type=X,$.source=Z;break;case"block-scalar":{let z=$.props.slice(1),q=Z.length;if($.props[0].type==="block-scalar-header")q-=$.props[0].source.length;for(let G of z)G.offset+=q;delete $.props,Object.assign($,{type:X,source:Z,end:z});break}case"block-map":case"block-seq":{let q={type:"newline",offset:$.offset+Z.length,indent:$.indent,source:`
141
- `};delete $.items,Object.assign($,{type:X,source:Z,end:[q]});break}default:{let z="indent"in $?$.indent:-1,q="end"in $&&Array.isArray($.end)?$.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys($))if(G!=="type"&&G!=="offset")delete $[G];Object.assign($,{type:X,indent:z,source:Z,end:q})}}}OY.createScalarToken=_Y;OY.resolveAsScalar=DY;OY.setScalarValue=FY});var b8=F((AY)=>{var RY=($)=>("type"in $)?B2($):K2($);function B2($){switch($.type){case"block-scalar":{let Z="";for(let X of $.props)Z+=B2(X);return Z+$.source}case"block-map":case"block-seq":{let Z="";for(let X of $.items)Z+=K2(X);return Z}case"flow-collection":{let Z=$.start.source;for(let X of $.items)Z+=K2(X);for(let X of $.end)Z+=X.source;return Z}case"document":{let Z=K2($);if($.end)for(let X of $.end)Z+=X.source;return Z}default:{let Z=$.source;if("end"in $&&$.end)for(let X of $.end)Z+=X.source;return Z}}}function K2({start:$,key:Z,sep:X,value:z}){let q="";for(let G of $)q+=G.source;if(Z)q+=B2(Z);if(X)for(let G of X)q+=G.source;if(z)q+=B2(z);return q}AY.stringify=RY});var k8=F((SY)=>{var I9=Symbol("break visit"),NY=Symbol("skip children"),y8=Symbol("remove item");function n0($,Z){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};x8(Object.freeze([]),$,Z)}n0.BREAK=I9;n0.SKIP=NY;n0.REMOVE=y8;n0.itemAtPath=($,Z)=>{let X=$;for(let[z,q]of Z){let G=X?.[z];if(G&&"items"in G)X=G.items[q];else return}return X};n0.parentCollection=($,Z)=>{let X=n0.itemAtPath($,Z.slice(0,-1)),z=Z[Z.length-1][0],q=X?.[z];if(q&&"items"in q)return q;throw Error("Parent collection not found")};function x8($,Z,X){let z=X(Z,$);if(typeof z==="symbol")return z;for(let q of["key","value"]){let G=Z[q];if(G&&"items"in G){for(let J=0;J<G.items.length;++J){let Q=x8(Object.freeze($.concat([[q,J]])),G.items[J],X);if(typeof Q==="number")J=Q-1;else if(Q===I9)return I9;else if(Q===y8)G.items.splice(J,1),J-=1}if(typeof z==="function"&&q==="key")z=z(Z,$)}}return typeof z==="function"?z(Z,$):z}SY.visit=n0});var L2=F((hY)=>{var R9=E8(),EY=b8(),bY=k8(),A9="\uFEFF",j9="\x02",N9="\x18",S9="\x1F",yY=($)=>!!$&&("items"in $),xY=($)=>!!$&&($.type==="scalar"||$.type==="single-quoted-scalar"||$.type==="double-quoted-scalar"||$.type==="block-scalar");function kY($){switch($){case A9:return"<BOM>";case j9:return"<DOC>";case N9:return"<FLOW_END>";case S9:return"<SCALAR>";default:return JSON.stringify($)}}function fY($){switch($){case A9:return"byte-order-mark";case j9:return"doc-mode";case N9:return"flow-error-end";case S9:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
129
+ `)+(z.substring(1)||" "),X=!0,Y=!1;break;case"%":if($[G+1]?.[0]!=="#")G+=1;X=!1;break;default:if(!X)Y=!0;X=!1}}return{comment:Z,afterEmptyLine:Y}}class WY{constructor($={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(Z,X,Y,G)=>{let z=t2(Z);if(G)this.warnings.push(new o2.YAMLWarning(z,X,Y));else this.errors.push(new o2.YAMLParseError(z,X,Y))},this.directives=new rU.Directives({version:$.version||"1.2"}),this.options=$}decorate($,Z){let{comment:X,afterEmptyLine:Y}=QY(this.prelude);if(X){let G=$.contents;if(Z)$.comment=$.comment?`${$.comment}
130
+ ${X}`:X;else if(Y||$.directives.docStart||!G)$.commentBefore=X;else if(JY.isCollection(G)&&!G.flow&&G.items.length>0){let z=G.items[0];if(JY.isPair(z))z=z.key;let J=z.commentBefore;z.commentBefore=J?`${X}
131
+ ${J}`:X}else{let z=G.commentBefore;G.commentBefore=z?`${X}
132
+ ${z}`:X}}if(Z)Array.prototype.push.apply($.errors,this.errors),Array.prototype.push.apply($.warnings,this.warnings);else $.errors=this.errors,$.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:QY(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose($,Z=!1,X=-1){for(let Y of $)yield*this.next(Y);yield*this.end(Z,X)}*next($){if(nU.env.LOG_STREAM)console.dir($,{depth:null});switch($.type){case"directive":this.directives.add($.source,(Z,X,Y)=>{let G=t2($);G[0]+=Z,this.onError(G,"BAD_DIRECTIVE",X,Y)}),this.prelude.push($.source),this.atDirectives=!0;break;case"document":{let Z=oU.composeDoc(this.options,this.directives,$,this.onError);if(this.atDirectives&&!Z.directives.docStart)this.onError($,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(Z,!1),this.doc)yield this.doc;this.doc=Z,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push($.source);break;case"error":{let Z=$.source?`${$.message}: ${JSON.stringify($.source)}`:$.message,X=new o2.YAMLParseError(t2($),"UNEXPECTED_TOKEN",Z);if(this.atDirectives||!this.doc)this.errors.push(X);else this.doc.errors.push(X);break}case"doc-end":{if(!this.doc){this.errors.push(new o2.YAMLParseError(t2($),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let Z=tU.resolveEnd($.end,$.offset+$.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),Z.comment){let X=this.doc.comment;this.doc.comment=X?`${X}
133
+ ${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.push(new o2.YAMLParseError(t2($),"UNEXPECTED_TOKEN",`Unsupported token ${$.type}`))}}*end($=!1,Z=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if($){let X=Object.assign({_directives:this.directives},this.options),Y=new sU.Document(void 0,X);if(this.atDirectives)this.onError(Z,"MISSING_CHAR","Missing directives-end indicator line");Y.range=[0,Z,Z],this.decorate(Y,!1),yield Y}}}eU.Composer=WY});var KY=R((Wq)=>{var Zq=U9(),Xq=T9(),Yq=r2(),VY=g2();function Gq($,Z=!0,X){if($){let Y=(G,z,J)=>{let Q=typeof G==="number"?G:Array.isArray(G)?G[0]:G.offset;if(X)X(Q,z,J);else throw new Yq.YAMLParseError([Q,Q+1],z,J)};switch($.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Xq.resolveFlowScalar($,Z,Y);case"block-scalar":return Zq.resolveBlockScalar({options:{strict:Z}},$,Y)}}return null}function zq($,Z){let{implicitKey:X=!1,indent:Y,inFlow:G=!1,offset:z=-1,type:J="PLAIN"}=Z,Q=VY.stringifyString({type:J,value:$},{implicitKey:X,indent:Y>0?" ".repeat(Y):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}}),W=Z.end??[{type:"newline",offset:-1,indent:Y,source:`
134
+ `}];switch(Q[0]){case"|":case">":{let V=Q.indexOf(`
135
+ `),K=Q.substring(0,V),H=Q.substring(V+1)+`
136
+ `,B=[{type:"block-scalar-header",offset:z,indent:Y,source:K}];if(!HY(B,W))B.push({type:"newline",offset:-1,indent:Y,source:`
137
+ `});return{type:"block-scalar",offset:z,indent:Y,props:B,source:H}}case'"':return{type:"double-quoted-scalar",offset:z,indent:Y,source:Q,end:W};case"'":return{type:"single-quoted-scalar",offset:z,indent:Y,source:Q,end:W};default:return{type:"scalar",offset:z,indent:Y,source:Q,end:W}}}function Jq($,Z,X={}){let{afterKey:Y=!1,implicitKey:G=!1,inFlow:z=!1,type:J}=X,Q="indent"in $?$.indent:null;if(Y&&typeof Q==="number")Q+=2;if(!J)switch($.type){case"single-quoted-scalar":J="QUOTE_SINGLE";break;case"double-quoted-scalar":J="QUOTE_DOUBLE";break;case"block-scalar":{let V=$.props[0];if(V.type!=="block-scalar-header")throw Error("Invalid block scalar header");J=V.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:J="PLAIN"}let W=VY.stringifyString({type:J,value:Z},{implicitKey:G||Q===null,indent:Q!==null&&Q>0?" ".repeat(Q):"",inFlow:z,options:{blockQuote:!0,lineWidth:-1}});switch(W[0]){case"|":case">":Qq($,W);break;case'"':w9($,W,"double-quoted-scalar");break;case"'":w9($,W,"single-quoted-scalar");break;default:w9($,W,"scalar")}}function Qq($,Z){let X=Z.indexOf(`
138
+ `),Y=Z.substring(0,X),G=Z.substring(X+1)+`
139
+ `;if($.type==="block-scalar"){let z=$.props[0];if(z.type!=="block-scalar-header")throw Error("Invalid block scalar header");z.source=Y,$.source=G}else{let{offset:z}=$,J="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:z,indent:J,source:Y}];if(!HY(Q,"end"in $?$.end:void 0))Q.push({type:"newline",offset:-1,indent:J,source:`
140
+ `});for(let W of Object.keys($))if(W!=="type"&&W!=="offset")delete $[W];Object.assign($,{type:"block-scalar",indent:J,props:Q,source:G})}}function HY($,Z){if(Z)for(let X of Z)switch(X.type){case"space":case"comment":$.push(X);break;case"newline":return $.push(X),!0}return!1}function w9($,Z,X){switch($.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":$.type=X,$.source=Z;break;case"block-scalar":{let Y=$.props.slice(1),G=Z.length;if($.props[0].type==="block-scalar-header")G-=$.props[0].source.length;for(let z of Y)z.offset+=G;delete $.props,Object.assign($,{type:X,source:Z,end:Y});break}case"block-map":case"block-seq":{let G={type:"newline",offset:$.offset+Z.length,indent:$.indent,source:`
141
+ `};delete $.items,Object.assign($,{type:X,source:Z,end:[G]});break}default:{let Y="indent"in $?$.indent:-1,G="end"in $&&Array.isArray($.end)?$.end.filter((z)=>z.type==="space"||z.type==="comment"||z.type==="newline"):[];for(let z of Object.keys($))if(z!=="type"&&z!=="offset")delete $[z];Object.assign($,{type:X,indent:Y,source:Z,end:G})}}}Wq.createScalarToken=zq;Wq.resolveAsScalar=Gq;Wq.setScalarValue=Jq});var BY=R((Uq)=>{var Bq=($)=>("type"in $)?k6($):x6($);function k6($){switch($.type){case"block-scalar":{let Z="";for(let X of $.props)Z+=k6(X);return Z+$.source}case"block-map":case"block-seq":{let Z="";for(let X of $.items)Z+=x6(X);return Z}case"flow-collection":{let Z=$.start.source;for(let X of $.items)Z+=x6(X);for(let X of $.end)Z+=X.source;return Z}case"document":{let Z=x6($);if($.end)for(let X of $.end)Z+=X.source;return Z}default:{let Z=$.source;if("end"in $&&$.end)for(let X of $.end)Z+=X.source;return Z}}}function x6({start:$,key:Z,sep:X,value:Y}){let G="";for(let z of $)G+=z.source;if(Z)G+=k6(Z);if(X)for(let z of X)G+=z.source;if(Y)G+=k6(Y);return G}Uq.stringify=Bq});var TY=R((Fq)=>{var M9=Symbol("break visit"),Tq=Symbol("skip children"),UY=Symbol("remove item");function a$($,Z){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};qY(Object.freeze([]),$,Z)}a$.BREAK=M9;a$.SKIP=Tq;a$.REMOVE=UY;a$.itemAtPath=($,Z)=>{let X=$;for(let[Y,G]of Z){let z=X?.[Y];if(z&&"items"in z)X=z.items[G];else return}return X};a$.parentCollection=($,Z)=>{let X=a$.itemAtPath($,Z.slice(0,-1)),Y=Z[Z.length-1][0],G=X?.[Y];if(G&&"items"in G)return G;throw Error("Parent collection not found")};function qY($,Z,X){let Y=X(Z,$);if(typeof Y==="symbol")return Y;for(let G of["key","value"]){let z=Z[G];if(z&&"items"in z){for(let J=0;J<z.items.length;++J){let Q=qY(Object.freeze($.concat([[G,J]])),z.items[J],X);if(typeof Q==="number")J=Q-1;else if(Q===M9)return M9;else if(Q===UY)z.items.splice(J,1),J-=1}if(typeof Y==="function"&&G==="key")Y=Y(Z,$)}}return typeof Y==="function"?Y(Z,$):Y}Fq.visit=a$});var b6=R((Dq)=>{var N9=KY(),wq=BY(),Mq=TY(),O9="\uFEFF",_9="\x02",P9="\x18",D9="\x1F",Nq=($)=>!!$&&("items"in $),Oq=($)=>!!$&&($.type==="scalar"||$.type==="single-quoted-scalar"||$.type==="double-quoted-scalar"||$.type==="block-scalar");function _q($){switch($){case O9:return"<BOM>";case _9:return"<DOC>";case P9:return"<FLOW_END>";case D9:return"<SCALAR>";default:return JSON.stringify($)}}function Pq($){switch($){case O9:return"byte-order-mark";case _9:return"doc-mode";case P9:return"flow-error-end";case D9:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
142
142
  `:case`\r
143
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}hY.createScalarToken=R9.createScalarToken;hY.resolveAsScalar=R9.resolveAsScalar;hY.setScalarValue=R9.setScalarValue;hY.stringify=EY.stringify;hY.visit=bY.visit;hY.BOM=A9;hY.DOCUMENT=j9;hY.FLOW_END=N9;hY.SCALAR=S9;hY.isCollection=yY;hY.isScalar=xY;hY.prettyToken=kY;hY.tokenType=fY});var E9=F((eY)=>{var G1=L2();function Y0($){switch($){case void 0:case" ":case`
144
- `:case"\r":case"\t":return!0;default:return!1}}var f8=new Set("0123456789ABCDEFabcdef"),oY=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),T2=new Set(",[]{}"),tY=new Set(` ,[]{}
145
- \r `),C9=($)=>!$||tY.has($);class h8{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex($,Z=!1){if($){if(typeof $!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+$:$,this.lineEndPos=null}this.atEnd=!Z;let X=this.next??"stream";while(X&&(Z||this.hasChars(1)))X=yield*this.parseNext(X)}atLineEnd(){let $=this.pos,Z=this.buffer[$];while(Z===" "||Z==="\t")Z=this.buffer[++$];if(!Z||Z==="#"||Z===`
143
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Dq.createScalarToken=N9.createScalarToken;Dq.resolveAsScalar=N9.resolveAsScalar;Dq.setScalarValue=N9.setScalarValue;Dq.stringify=wq.stringify;Dq.visit=Mq.visit;Dq.BOM=O9;Dq.DOCUMENT=_9;Dq.FLOW_END=P9;Dq.SCALAR=D9;Dq.isCollection=Nq;Dq.isScalar=Oq;Dq.prettyToken=_q;Dq.tokenType=Pq});var R9=R((uq)=>{var e2=b6();function y0($){switch($){case void 0:case" ":case`
144
+ `:case"\r":case"\t":return!0;default:return!1}}var FY=new Set("0123456789ABCDEFabcdef"),vq=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),f6=new Set(",[]{}"),hq=new Set(` ,[]{}
145
+ \r `),E9=($)=>!$||hq.has($);class LY{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex($,Z=!1){if($){if(typeof $!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+$:$,this.lineEndPos=null}this.atEnd=!Z;let X=this.next??"stream";while(X&&(Z||this.hasChars(1)))X=yield*this.parseNext(X)}atLineEnd(){let $=this.pos,Z=this.buffer[$];while(Z===" "||Z==="\t")Z=this.buffer[++$];if(!Z||Z==="#"||Z===`
146
146
  `)return!0;if(Z==="\r")return this.buffer[$+1]===`
147
- `;return!1}charAt($){return this.buffer[this.pos+$]}continueScalar($){let Z=this.buffer[$];if(this.indentNext>0){let X=0;while(Z===" ")Z=this.buffer[++X+$];if(Z==="\r"){let z=this.buffer[X+$+1];if(z===`
148
- `||!z&&!this.atEnd)return $+X+1}return Z===`
149
- `||X>=this.indentNext||!Z&&!this.atEnd?$+X:-1}if(Z==="-"||Z==="."){let X=this.buffer.substr($,3);if((X==="---"||X==="...")&&Y0(this.buffer[$+3]))return-1}return $}getLine(){let $=this.lineEndPos;if(typeof $!=="number"||$!==-1&&$<this.pos)$=this.buffer.indexOf(`
150
- `,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===G1.BOM)yield*this.pushCount(1),$=$.substring(1);if($[0]==="%"){let Z=$.length,X=$.indexOf("#");while(X!==-1){let q=$[X-1];if(q===" "||q==="\t"){Z=X-1;break}else X=$.indexOf("#",X+1)}while(!0){let q=$[Z-1];if(q===" "||q==="\t")Z-=1;else break}let z=(yield*this.pushCount(Z))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-z),this.pushNewline(),"stream"}if(this.atLineEnd()){let Z=yield*this.pushSpaces(!0);return yield*this.pushCount($.length-Z),yield*this.pushNewline(),"stream"}return yield G1.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let $=this.charAt(0);if(!$&&!this.atEnd)return this.setNext("line-start");if($==="-"||$==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let Z=this.peek(3);if((Z==="---"||Z==="...")&&Y0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,Z==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Y0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[$,Z]=this.peek(2);if(!Z&&!this.atEnd)return this.setNext("block-start");if(($==="-"||$==="?"||$===":")&&Y0(Z)){let X=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=X,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let $=this.getLine();if($===null)return this.setNext("doc");let Z=yield*this.pushIndicators();switch($[Z]){case"#":yield*this.pushCount($.length-Z);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(C9),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return Z+=yield*this.parseBlockScalarHeader(),Z+=yield*this.pushSpaces(!0),yield*this.pushCount($.length-Z),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let $,Z,X=-1;do{if($=yield*this.pushNewline(),$>0)Z=yield*this.pushSpaces(!1),this.indentValue=X=Z;else Z=0;Z+=yield*this.pushSpaces(!0)}while($+Z>0);let z=this.getLine();if(z===null)return this.setNext("flow");if(X!==-1&&X<this.indentNext&&z[0]!=="#"||X===0&&(z.startsWith("---")||z.startsWith("..."))&&Y0(z[3])){if(!(X===this.indentNext-1&&this.flowLevel===1&&(z[0]==="]"||z[0]==="}")))return this.flowLevel=0,yield G1.FLOW_END,yield*this.parseLineStart()}let q=0;while(z[q]===",")q+=yield*this.pushCount(1),q+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(q+=yield*this.pushIndicators(),z[q]){case void 0:return"flow";case"#":return yield*this.pushCount(z.length-q),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(C9),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let G=this.charAt(1);if(this.flowKey||Y0(G)||G===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let $=this.charAt(0),Z=this.buffer.indexOf($,this.pos+1);if($==="'")while(Z!==-1&&this.buffer[Z+1]==="'")Z=this.buffer.indexOf("'",Z+2);else while(Z!==-1){let q=0;while(this.buffer[Z-1-q]==="\\")q+=1;if(q%2===0)break;Z=this.buffer.indexOf('"',Z+1)}let X=this.buffer.substring(0,Z),z=X.indexOf(`
151
- `,this.pos);if(z!==-1){while(z!==-1){let q=this.continueScalar(z+1);if(q===-1)break;z=X.indexOf(`
152
- `,q)}if(z!==-1)Z=z-(X[z-1]==="\r"?2:1)}if(Z===-1){if(!this.atEnd)return this.setNext("quoted-scalar");Z=this.buffer.length}return yield*this.pushToIndex(Z+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let $=this.pos;while(!0){let Z=this.buffer[++$];if(Z==="+")this.blockScalarKeep=!0;else if(Z>"0"&&Z<="9")this.blockScalarIndent=Number(Z)-1;else if(Z!=="-")break}return yield*this.pushUntil((Z)=>Y0(Z)||Z==="#")}*parseBlockScalar(){let $=this.pos-1,Z=0,X;$:for(let q=this.pos;X=this.buffer[q];++q)switch(X){case" ":Z+=1;break;case`
153
- `:$=q,Z=0;break;case"\r":{let G=this.buffer[q+1];if(!G&&!this.atEnd)return this.setNext("block-scalar");if(G===`
154
- `)break}default:break $}if(!X&&!this.atEnd)return this.setNext("block-scalar");if(Z>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=Z;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let q=this.continueScalar($+1);if(q===-1)break;$=this.buffer.indexOf(`
155
- `,q)}while($!==-1);if($===-1){if(!this.atEnd)return this.setNext("block-scalar");$=this.buffer.length}}let z=$+1;X=this.buffer[z];while(X===" ")X=this.buffer[++z];if(X==="\t"){while(X==="\t"||X===" "||X==="\r"||X===`
156
- `)X=this.buffer[++z];$=z-1}else if(!this.blockScalarKeep)do{let q=$-1,G=this.buffer[q];if(G==="\r")G=this.buffer[--q];let J=q;while(G===" ")G=this.buffer[--q];if(G===`
157
- `&&q>=this.pos&&q+1+Z>J)$=q;else break}while(!0);return yield G1.SCALAR,yield*this.pushToIndex($+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let $=this.flowLevel>0,Z=this.pos-1,X=this.pos-1,z;while(z=this.buffer[++X])if(z===":"){let q=this.buffer[X+1];if(Y0(q)||$&&T2.has(q))break;Z=X}else if(Y0(z)){let q=this.buffer[X+1];if(z==="\r")if(q===`
158
- `)X+=1,z=`
159
- `,q=this.buffer[X+1];else Z=X;if(q==="#"||$&&T2.has(q))break;if(z===`
160
- `){let G=this.continueScalar(X+1);if(G===-1)break;X=Math.max(X,G-2)}}else{if($&&T2.has(z))break;Z=X}if(!z&&!this.atEnd)return this.setNext("plain-scalar");return yield G1.SCALAR,yield*this.pushToIndex(Z+1,!0),$?"flow":"doc"}*pushCount($){if($>0)return yield this.buffer.substr(this.pos,$),this.pos+=$,$;return 0}*pushToIndex($,Z){let X=this.buffer.slice(this.pos,$);if(X)return yield X,this.pos+=X.length,X.length;else if(Z)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(C9))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let $=this.flowLevel>0,Z=this.charAt(1);if(Y0(Z)||$&&T2.has(Z)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let $=this.pos+2,Z=this.buffer[$];while(!Y0(Z)&&Z!==">")Z=this.buffer[++$];return yield*this.pushToIndex(Z===">"?$+1:$,!1)}else{let $=this.pos+1,Z=this.buffer[$];while(Z)if(oY.has(Z))Z=this.buffer[++$];else if(Z==="%"&&f8.has(this.buffer[$+1])&&f8.has(this.buffer[$+2]))Z=this.buffer[$+=3];else break;return yield*this.pushToIndex($,!1)}}*pushNewline(){let $=this.buffer[this.pos];if($===`
147
+ `;return!1}charAt($){return this.buffer[this.pos+$]}continueScalar($){let Z=this.buffer[$];if(this.indentNext>0){let X=0;while(Z===" ")Z=this.buffer[++X+$];if(Z==="\r"){let Y=this.buffer[X+$+1];if(Y===`
148
+ `||!Y&&!this.atEnd)return $+X+1}return Z===`
149
+ `||X>=this.indentNext||!Z&&!this.atEnd?$+X:-1}if(Z==="-"||Z==="."){let X=this.buffer.substr($,3);if((X==="---"||X==="...")&&y0(this.buffer[$+3]))return-1}return $}getLine(){let $=this.lineEndPos;if(typeof $!=="number"||$!==-1&&$<this.pos)$=this.buffer.indexOf(`
150
+ `,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===e2.BOM)yield*this.pushCount(1),$=$.substring(1);if($[0]==="%"){let Z=$.length,X=$.indexOf("#");while(X!==-1){let G=$[X-1];if(G===" "||G==="\t"){Z=X-1;break}else X=$.indexOf("#",X+1)}while(!0){let G=$[Z-1];if(G===" "||G==="\t")Z-=1;else break}let Y=(yield*this.pushCount(Z))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-Y),this.pushNewline(),"stream"}if(this.atLineEnd()){let Z=yield*this.pushSpaces(!0);return yield*this.pushCount($.length-Z),yield*this.pushNewline(),"stream"}return yield e2.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let $=this.charAt(0);if(!$&&!this.atEnd)return this.setNext("line-start");if($==="-"||$==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let Z=this.peek(3);if((Z==="---"||Z==="...")&&y0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,Z==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!y0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[$,Z]=this.peek(2);if(!Z&&!this.atEnd)return this.setNext("block-start");if(($==="-"||$==="?"||$===":")&&y0(Z)){let X=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=X,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let $=this.getLine();if($===null)return this.setNext("doc");let Z=yield*this.pushIndicators();switch($[Z]){case"#":yield*this.pushCount($.length-Z);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(E9),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return Z+=yield*this.parseBlockScalarHeader(),Z+=yield*this.pushSpaces(!0),yield*this.pushCount($.length-Z),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let $,Z,X=-1;do{if($=yield*this.pushNewline(),$>0)Z=yield*this.pushSpaces(!1),this.indentValue=X=Z;else Z=0;Z+=yield*this.pushSpaces(!0)}while($+Z>0);let Y=this.getLine();if(Y===null)return this.setNext("flow");if(X!==-1&&X<this.indentNext&&Y[0]!=="#"||X===0&&(Y.startsWith("---")||Y.startsWith("..."))&&y0(Y[3])){if(!(X===this.indentNext-1&&this.flowLevel===1&&(Y[0]==="]"||Y[0]==="}")))return this.flowLevel=0,yield e2.FLOW_END,yield*this.parseLineStart()}let G=0;while(Y[G]===",")G+=yield*this.pushCount(1),G+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(G+=yield*this.pushIndicators(),Y[G]){case void 0:return"flow";case"#":return yield*this.pushCount(Y.length-G),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(E9),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let z=this.charAt(1);if(this.flowKey||y0(z)||z===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let $=this.charAt(0),Z=this.buffer.indexOf($,this.pos+1);if($==="'")while(Z!==-1&&this.buffer[Z+1]==="'")Z=this.buffer.indexOf("'",Z+2);else while(Z!==-1){let G=0;while(this.buffer[Z-1-G]==="\\")G+=1;if(G%2===0)break;Z=this.buffer.indexOf('"',Z+1)}let X=this.buffer.substring(0,Z),Y=X.indexOf(`
151
+ `,this.pos);if(Y!==-1){while(Y!==-1){let G=this.continueScalar(Y+1);if(G===-1)break;Y=X.indexOf(`
152
+ `,G)}if(Y!==-1)Z=Y-(X[Y-1]==="\r"?2:1)}if(Z===-1){if(!this.atEnd)return this.setNext("quoted-scalar");Z=this.buffer.length}return yield*this.pushToIndex(Z+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let $=this.pos;while(!0){let Z=this.buffer[++$];if(Z==="+")this.blockScalarKeep=!0;else if(Z>"0"&&Z<="9")this.blockScalarIndent=Number(Z)-1;else if(Z!=="-")break}return yield*this.pushUntil((Z)=>y0(Z)||Z==="#")}*parseBlockScalar(){let $=this.pos-1,Z=0,X;$:for(let G=this.pos;X=this.buffer[G];++G)switch(X){case" ":Z+=1;break;case`
153
+ `:$=G,Z=0;break;case"\r":{let z=this.buffer[G+1];if(!z&&!this.atEnd)return this.setNext("block-scalar");if(z===`
154
+ `)break}default:break $}if(!X&&!this.atEnd)return this.setNext("block-scalar");if(Z>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=Z;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let G=this.continueScalar($+1);if(G===-1)break;$=this.buffer.indexOf(`
155
+ `,G)}while($!==-1);if($===-1){if(!this.atEnd)return this.setNext("block-scalar");$=this.buffer.length}}let Y=$+1;X=this.buffer[Y];while(X===" ")X=this.buffer[++Y];if(X==="\t"){while(X==="\t"||X===" "||X==="\r"||X===`
156
+ `)X=this.buffer[++Y];$=Y-1}else if(!this.blockScalarKeep)do{let G=$-1,z=this.buffer[G];if(z==="\r")z=this.buffer[--G];let J=G;while(z===" ")z=this.buffer[--G];if(z===`
157
+ `&&G>=this.pos&&G+1+Z>J)$=G;else break}while(!0);return yield e2.SCALAR,yield*this.pushToIndex($+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let $=this.flowLevel>0,Z=this.pos-1,X=this.pos-1,Y;while(Y=this.buffer[++X])if(Y===":"){let G=this.buffer[X+1];if(y0(G)||$&&f6.has(G))break;Z=X}else if(y0(Y)){let G=this.buffer[X+1];if(Y==="\r")if(G===`
158
+ `)X+=1,Y=`
159
+ `,G=this.buffer[X+1];else Z=X;if(G==="#"||$&&f6.has(G))break;if(Y===`
160
+ `){let z=this.continueScalar(X+1);if(z===-1)break;X=Math.max(X,z-2)}}else{if($&&f6.has(Y))break;Z=X}if(!Y&&!this.atEnd)return this.setNext("plain-scalar");return yield e2.SCALAR,yield*this.pushToIndex(Z+1,!0),$?"flow":"doc"}*pushCount($){if($>0)return yield this.buffer.substr(this.pos,$),this.pos+=$,$;return 0}*pushToIndex($,Z){let X=this.buffer.slice(this.pos,$);if(X)return yield X,this.pos+=X.length,X.length;else if(Z)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(E9))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let $=this.flowLevel>0,Z=this.charAt(1);if(y0(Z)||$&&f6.has(Z)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let $=this.pos+2,Z=this.buffer[$];while(!y0(Z)&&Z!==">")Z=this.buffer[++$];return yield*this.pushToIndex(Z===">"?$+1:$,!1)}else{let $=this.pos+1,Z=this.buffer[$];while(Z)if(vq.has(Z))Z=this.buffer[++$];else if(Z==="%"&&FY.has(this.buffer[$+1])&&FY.has(this.buffer[$+2]))Z=this.buffer[$+=3];else break;return yield*this.pushToIndex($,!1)}}*pushNewline(){let $=this.buffer[this.pos];if($===`
161
161
  `)return yield*this.pushCount(1);else if($==="\r"&&this.charAt(1)===`
162
- `)return yield*this.pushCount(2);else return 0}*pushSpaces($){let Z=this.pos-1,X;do X=this.buffer[++Z];while(X===" "||$&&X==="\t");let z=Z-this.pos;if(z>0)yield this.buffer.substr(this.pos,z),this.pos=Z;return z}*pushUntil($){let Z=this.pos,X=this.buffer[Z];while(!$(X))X=this.buffer[++Z];return yield*this.pushToIndex(Z,!1)}}eY.Lexer=h8});var b9=F((ZH)=>{class g8{constructor(){this.lineStarts=[],this.addNewLine=($)=>this.lineStarts.push($),this.linePos=($)=>{let Z=0,X=this.lineStarts.length;while(Z<X){let q=Z+X>>1;if(this.lineStarts[q]<$)Z=q+1;else X=q}if(this.lineStarts[Z]===$)return{line:Z+1,col:1};if(Z===0)return{line:0,col:$};let z=this.lineStarts[Z-1];return{line:Z,col:$-z+1}}}}ZH.LineCounter=g8});var y9=F((GH)=>{var zH=L0("process"),v8=L2(),qH=E9();function b0($,Z){for(let X=0;X<$.length;++X)if($[X].type===Z)return!0;return!1}function u8($){for(let Z=0;Z<$.length;++Z)switch($[Z].type){case"space":case"comment":case"newline":break;default:return Z}return-1}function d8($){switch($?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function D2($){switch($.type){case"document":return $.start;case"block-map":{let Z=$.items[$.items.length-1];return Z.sep??Z.start}case"block-seq":return $.items[$.items.length-1].start;default:return[]}}function K$($){if($.length===0)return[];let Z=$.length;$:while(--Z>=0)switch($[Z].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break $}while($[++Z]?.type==="space");return $.splice(Z,$.length)}function m8($){if($.start.type==="flow-seq-start"){for(let Z of $.items)if(Z.sep&&!Z.value&&!b0(Z.start,"explicit-key-ind")&&!b0(Z.sep,"map-value-ind")){if(Z.key)Z.value=Z.key;if(delete Z.key,d8(Z.value))if(Z.value.end)Array.prototype.push.apply(Z.value.end,Z.sep);else Z.value.end=Z.sep;else Array.prototype.push.apply(Z.start,Z.sep);delete Z.sep}}}class p8{constructor($){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new qH.Lexer,this.onNewLine=$}*parse($,Z=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let X of this.lexer.lex($,Z))yield*this.next(X);if(!Z)yield*this.end()}*next($){if(this.source=$,zH.env.LOG_TOKENS)console.log("|",v8.prettyToken($));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=$.length;return}let Z=v8.tokenType($);if(!Z){let X=`Not a YAML token: ${$}`;yield*this.pop({type:"error",offset:this.offset,message:X,source:$}),this.offset+=$.length}else if(Z==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=Z,yield*this.step(),Z){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+$.length);break;case"space":if(this.atNewLine&&$[0]===" ")this.indent+=$.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=$.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=$.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let $=this.peek(1);if(this.type==="doc-end"&&$?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!$)return yield*this.stream();switch($.type){case"document":return yield*this.document($);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar($);case"block-scalar":return yield*this.blockScalar($);case"block-map":return yield*this.blockMap($);case"block-seq":return yield*this.blockSequence($);case"flow-collection":return yield*this.flowCollection($);case"doc-end":return yield*this.documentEnd($)}yield*this.pop()}peek($){return this.stack[this.stack.length-$]}*pop($){let Z=$??this.stack.pop();if(!Z)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield Z;else{let X=this.peek(1);if(Z.type==="block-scalar")Z.indent="indent"in X?X.indent:0;else if(Z.type==="flow-collection"&&X.type==="document")Z.indent=0;if(Z.type==="flow-collection")m8(Z);switch(X.type){case"document":X.value=Z;break;case"block-scalar":X.props.push(Z);break;case"block-map":{let z=X.items[X.items.length-1];if(z.value){X.items.push({start:[],key:Z,sep:[]}),this.onKeyLine=!0;return}else if(z.sep)z.value=Z;else{Object.assign(z,{key:Z,sep:[]}),this.onKeyLine=!z.explicitKey;return}break}case"block-seq":{let z=X.items[X.items.length-1];if(z.value)X.items.push({start:[],value:Z});else z.value=Z;break}case"flow-collection":{let z=X.items[X.items.length-1];if(!z||z.value)X.items.push({start:[],key:Z,sep:[]});else if(z.sep)z.value=Z;else Object.assign(z,{key:Z,sep:[]});return}default:yield*this.pop(),yield*this.pop(Z)}if((X.type==="document"||X.type==="block-map"||X.type==="block-seq")&&(Z.type==="block-map"||Z.type==="block-seq")){let z=Z.items[Z.items.length-1];if(z&&!z.sep&&!z.value&&z.start.length>0&&u8(z.start)===-1&&(Z.indent===0||z.start.every((q)=>q.type!=="comment"||q.indent<Z.indent))){if(X.type==="document")X.end=z.start;else X.items.push({start:z.start});Z.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let $={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")$.start.push(this.sourceToken);this.stack.push($);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document($){if($.value)return yield*this.lineEnd($);switch(this.type){case"doc-start":{if(u8($.start)!==-1)yield*this.pop(),yield*this.step();else $.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":$.start.push(this.sourceToken);return}let Z=this.startBlockValue($);if(Z)this.stack.push(Z);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar($){if(this.type==="map-value-ind"){let Z=D2(this.peek(2)),X=K$(Z),z;if($.end)z=$.end,z.push(this.sourceToken),delete $.end;else z=[this.sourceToken];let q={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:X,key:$,sep:z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=q}else yield*this.lineEnd($)}*blockScalar($){switch(this.type){case"space":case"comment":case"newline":$.props.push(this.sourceToken);return;case"scalar":if($.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let Z=this.source.indexOf(`
162
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces($){let Z=this.pos-1,X;do X=this.buffer[++Z];while(X===" "||$&&X==="\t");let Y=Z-this.pos;if(Y>0)yield this.buffer.substr(this.pos,Y),this.pos=Z;return Y}*pushUntil($){let Z=this.pos,X=this.buffer[Z];while(!$(X))X=this.buffer[++Z];return yield*this.pushToIndex(Z,!1)}}uq.Lexer=LY});var A9=R((dq)=>{class wY{constructor(){this.lineStarts=[],this.addNewLine=($)=>this.lineStarts.push($),this.linePos=($)=>{let Z=0,X=this.lineStarts.length;while(Z<X){let G=Z+X>>1;if(this.lineStarts[G]<$)Z=G+1;else X=G}if(this.lineStarts[Z]===$)return{line:Z+1,col:1};if(Z===0)return{line:0,col:$};let Y=this.lineStarts[Z-1];return{line:Z,col:$-Y+1}}}}dq.LineCounter=wY});var S9=R((iq)=>{var lq=r0("process"),MY=b6(),pq=R9();function w$($,Z){for(let X=0;X<$.length;++X)if($[X].type===Z)return!0;return!1}function NY($){for(let Z=0;Z<$.length;++Z)switch($[Z].type){case"space":case"comment":case"newline":break;default:return Z}return-1}function _Y($){switch($?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function y6($){switch($.type){case"document":return $.start;case"block-map":{let Z=$.items[$.items.length-1];return Z.sep??Z.start}case"block-seq":return $.items[$.items.length-1].start;default:return[]}}function I1($){if($.length===0)return[];let Z=$.length;$:while(--Z>=0)switch($[Z].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break $}while($[++Z]?.type==="space");return $.splice(Z,$.length)}function OY($){if($.start.type==="flow-seq-start"){for(let Z of $.items)if(Z.sep&&!Z.value&&!w$(Z.start,"explicit-key-ind")&&!w$(Z.sep,"map-value-ind")){if(Z.key)Z.value=Z.key;if(delete Z.key,_Y(Z.value))if(Z.value.end)Array.prototype.push.apply(Z.value.end,Z.sep);else Z.value.end=Z.sep;else Array.prototype.push.apply(Z.start,Z.sep);delete Z.sep}}}class PY{constructor($){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new pq.Lexer,this.onNewLine=$}*parse($,Z=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let X of this.lexer.lex($,Z))yield*this.next(X);if(!Z)yield*this.end()}*next($){if(this.source=$,lq.env.LOG_TOKENS)console.log("|",MY.prettyToken($));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=$.length;return}let Z=MY.tokenType($);if(!Z){let X=`Not a YAML token: ${$}`;yield*this.pop({type:"error",offset:this.offset,message:X,source:$}),this.offset+=$.length}else if(Z==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=Z,yield*this.step(),Z){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+$.length);break;case"space":if(this.atNewLine&&$[0]===" ")this.indent+=$.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=$.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=$.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let $=this.peek(1);if(this.type==="doc-end"&&$?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!$)return yield*this.stream();switch($.type){case"document":return yield*this.document($);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar($);case"block-scalar":return yield*this.blockScalar($);case"block-map":return yield*this.blockMap($);case"block-seq":return yield*this.blockSequence($);case"flow-collection":return yield*this.flowCollection($);case"doc-end":return yield*this.documentEnd($)}yield*this.pop()}peek($){return this.stack[this.stack.length-$]}*pop($){let Z=$??this.stack.pop();if(!Z)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield Z;else{let X=this.peek(1);if(Z.type==="block-scalar")Z.indent="indent"in X?X.indent:0;else if(Z.type==="flow-collection"&&X.type==="document")Z.indent=0;if(Z.type==="flow-collection")OY(Z);switch(X.type){case"document":X.value=Z;break;case"block-scalar":X.props.push(Z);break;case"block-map":{let Y=X.items[X.items.length-1];if(Y.value){X.items.push({start:[],key:Z,sep:[]}),this.onKeyLine=!0;return}else if(Y.sep)Y.value=Z;else{Object.assign(Y,{key:Z,sep:[]}),this.onKeyLine=!Y.explicitKey;return}break}case"block-seq":{let Y=X.items[X.items.length-1];if(Y.value)X.items.push({start:[],value:Z});else Y.value=Z;break}case"flow-collection":{let Y=X.items[X.items.length-1];if(!Y||Y.value)X.items.push({start:[],key:Z,sep:[]});else if(Y.sep)Y.value=Z;else Object.assign(Y,{key:Z,sep:[]});return}default:yield*this.pop(),yield*this.pop(Z)}if((X.type==="document"||X.type==="block-map"||X.type==="block-seq")&&(Z.type==="block-map"||Z.type==="block-seq")){let Y=Z.items[Z.items.length-1];if(Y&&!Y.sep&&!Y.value&&Y.start.length>0&&NY(Y.start)===-1&&(Z.indent===0||Y.start.every((G)=>G.type!=="comment"||G.indent<Z.indent))){if(X.type==="document")X.end=Y.start;else X.items.push({start:Y.start});Z.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let $={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")$.start.push(this.sourceToken);this.stack.push($);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document($){if($.value)return yield*this.lineEnd($);switch(this.type){case"doc-start":{if(NY($.start)!==-1)yield*this.pop(),yield*this.step();else $.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":$.start.push(this.sourceToken);return}let Z=this.startBlockValue($);if(Z)this.stack.push(Z);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar($){if(this.type==="map-value-ind"){let Z=y6(this.peek(2)),X=I1(Z),Y;if($.end)Y=$.end,Y.push(this.sourceToken),delete $.end;else Y=[this.sourceToken];let G={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:X,key:$,sep:Y}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=G}else yield*this.lineEnd($)}*blockScalar($){switch(this.type){case"space":case"comment":case"newline":$.props.push(this.sourceToken);return;case"scalar":if($.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let Z=this.source.indexOf(`
163
163
  `)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
164
- `,Z)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,Z.value){let X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else{if(this.atIndentedComment(Z.start,$.indent)){let z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,Z.start),z.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let X=!this.onKeyLine&&this.indent===$.indent,z=X&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",q=[];if(z&&Z.sep&&!Z.value){let G=[];for(let J=0;J<Z.sep.length;++J){let Q=Z.sep[J];switch(Q.type){case"newline":G.push(J);break;case"space":break;case"comment":if(Q.indent>$.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)q=Z.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(z||Z.value)q.push(this.sourceToken),$.items.push({start:q}),this.onKeyLine=!0;else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"explicit-key-ind":if(!Z.sep&&!Z.explicitKey)Z.start.push(this.sourceToken),Z.explicitKey=!0;else if(z||Z.value)q.push(this.sourceToken),$.items.push({start:q,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(Z.explicitKey)if(!Z.sep)if(b0(Z.start,"newline"))Object.assign(Z,{key:null,sep:[this.sourceToken]});else{let G=K$(Z.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(b0(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]});else if(d8(Z.key)&&!b0(Z.sep,"newline")){let G=K$(Z.start),J=Z.key,Q=Z.sep;Q.push(this.sourceToken),delete Z.key,delete Z.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:J,sep:Q}]})}else if(q.length>0)Z.sep=Z.sep.concat(q,this.sourceToken);else Z.sep.push(this.sourceToken);else if(!Z.sep)Object.assign(Z,{key:null,sep:[this.sourceToken]});else if(Z.value||z)$.items.push({start:q,key:null,sep:[this.sourceToken]});else if(b0(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else Z.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let G=this.flowScalar(this.type);if(z||Z.value)$.items.push({start:q,key:G,sep:[]}),this.onKeyLine=!0;else if(Z.sep)this.stack.push(G);else Object.assign(Z,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue($);if(G){if(G.type==="block-seq"){if(!Z.explicitKey&&Z.sep&&!b0(Z.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(X)$.items.push({start:q});this.stack.push(G);return}}}}yield*this.pop(),yield*this.step()}*blockSequence($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(Z.value){let X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(Z.start,$.indent)){let z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,Z.start),z.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return;case"anchor":case"tag":if(Z.value||this.indent<=$.indent)break;Z.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==$.indent)break;if(Z.value||b0(Z.start,"seq-item-ind"))$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return}if(this.indent>$.indent){let X=this.startBlockValue($);if(X){this.stack.push(X);return}}yield*this.pop(),yield*this.step()}*flowCollection($){let Z=$.items[$.items.length-1];if(this.type==="flow-error-end"){let X;do yield*this.pop(),X=this.peek(1);while(X?.type==="flow-collection")}else if($.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!Z||Z.sep)$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return;case"map-value-ind":if(!Z||Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Object.assign(Z,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!Z||Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let z=this.flowScalar(this.type);if(!Z||Z.value)$.items.push({start:[],key:z,sep:[]});else if(Z.sep)this.stack.push(z);else Object.assign(Z,{key:z,sep:[]});return}case"flow-map-end":case"flow-seq-end":$.end.push(this.sourceToken);return}let X=this.startBlockValue($);if(X)this.stack.push(X);else yield*this.pop(),yield*this.step()}else{let X=this.peek(2);if(X.type==="block-map"&&(this.type==="map-value-ind"&&X.indent===$.indent||this.type==="newline"&&!X.items[X.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&X.type!=="flow-collection"){let z=D2(X),q=K$(z);m8($);let G=$.end.splice(1,$.end.length);G.push(this.sourceToken);let J={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:q,key:$,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=J}else yield*this.lineEnd($)}}flowScalar($){if(this.onNewLine){let Z=this.source.indexOf(`
164
+ `,Z)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,Z.value){let X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else{if(this.atIndentedComment(Z.start,$.indent)){let Y=$.items[$.items.length-2]?.value?.end;if(Array.isArray(Y)){Array.prototype.push.apply(Y,Z.start),Y.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let X=!this.onKeyLine&&this.indent===$.indent,Y=X&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",G=[];if(Y&&Z.sep&&!Z.value){let z=[];for(let J=0;J<Z.sep.length;++J){let Q=Z.sep[J];switch(Q.type){case"newline":z.push(J);break;case"space":break;case"comment":if(Q.indent>$.indent)z.length=0;break;default:z.length=0}}if(z.length>=2)G=Z.sep.splice(z[1])}switch(this.type){case"anchor":case"tag":if(Y||Z.value)G.push(this.sourceToken),$.items.push({start:G}),this.onKeyLine=!0;else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"explicit-key-ind":if(!Z.sep&&!Z.explicitKey)Z.start.push(this.sourceToken),Z.explicitKey=!0;else if(Y||Z.value)G.push(this.sourceToken),$.items.push({start:G,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(Z.explicitKey)if(!Z.sep)if(w$(Z.start,"newline"))Object.assign(Z,{key:null,sep:[this.sourceToken]});else{let z=I1(Z.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:null,sep:[this.sourceToken]}]})}else if(Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(w$(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]});else if(_Y(Z.key)&&!w$(Z.sep,"newline")){let z=I1(Z.start),J=Z.key,Q=Z.sep;Q.push(this.sourceToken),delete Z.key,delete Z.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:J,sep:Q}]})}else if(G.length>0)Z.sep=Z.sep.concat(G,this.sourceToken);else Z.sep.push(this.sourceToken);else if(!Z.sep)Object.assign(Z,{key:null,sep:[this.sourceToken]});else if(Z.value||Y)$.items.push({start:G,key:null,sep:[this.sourceToken]});else if(w$(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else Z.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let z=this.flowScalar(this.type);if(Y||Z.value)$.items.push({start:G,key:z,sep:[]}),this.onKeyLine=!0;else if(Z.sep)this.stack.push(z);else Object.assign(Z,{key:z,sep:[]}),this.onKeyLine=!0;return}default:{let z=this.startBlockValue($);if(z){if(z.type==="block-seq"){if(!Z.explicitKey&&Z.sep&&!w$(Z.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(X)$.items.push({start:G});this.stack.push(z);return}}}}yield*this.pop(),yield*this.step()}*blockSequence($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(Z.value){let X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(Z.start,$.indent)){let Y=$.items[$.items.length-2]?.value?.end;if(Array.isArray(Y)){Array.prototype.push.apply(Y,Z.start),Y.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return;case"anchor":case"tag":if(Z.value||this.indent<=$.indent)break;Z.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==$.indent)break;if(Z.value||w$(Z.start,"seq-item-ind"))$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return}if(this.indent>$.indent){let X=this.startBlockValue($);if(X){this.stack.push(X);return}}yield*this.pop(),yield*this.step()}*flowCollection($){let Z=$.items[$.items.length-1];if(this.type==="flow-error-end"){let X;do yield*this.pop(),X=this.peek(1);while(X?.type==="flow-collection")}else if($.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!Z||Z.sep)$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return;case"map-value-ind":if(!Z||Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Object.assign(Z,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!Z||Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Y=this.flowScalar(this.type);if(!Z||Z.value)$.items.push({start:[],key:Y,sep:[]});else if(Z.sep)this.stack.push(Y);else Object.assign(Z,{key:Y,sep:[]});return}case"flow-map-end":case"flow-seq-end":$.end.push(this.sourceToken);return}let X=this.startBlockValue($);if(X)this.stack.push(X);else yield*this.pop(),yield*this.step()}else{let X=this.peek(2);if(X.type==="block-map"&&(this.type==="map-value-ind"&&X.indent===$.indent||this.type==="newline"&&!X.items[X.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&X.type!=="flow-collection"){let Y=y6(X),G=I1(Y);OY($);let z=$.end.splice(1,$.end.length);z.push(this.sourceToken);let J={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:G,key:$,sep:z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=J}else yield*this.lineEnd($)}}flowScalar($){if(this.onNewLine){let Z=this.source.indexOf(`
165
165
  `)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
166
- `,Z)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let Z=D2($),X=K$(Z);return X.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=D2($),X=K$(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((X)=>X.type==="newline"||X.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}GH.Parser=p8});var n8=F((BH)=>{var l8=w9(),QH=$1(),J1=Z1(),YH=b4(),HH=E(),UH=b9(),c8=y9();function i8($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new UH.LineCounter||null,prettyErrors:Z}}function WH($,Z={}){let{lineCounter:X,prettyErrors:z}=i8(Z),q=new c8.Parser(X?.addNewLine),G=new l8.Composer(Z),J=Array.from(G.compose(q.parse($)));if(z&&X)for(let Q of J)Q.errors.forEach(J1.prettifyError($,X)),Q.warnings.forEach(J1.prettifyError($,X));if(J.length>0)return J;return Object.assign([],{empty:!0},G.streamInfo())}function a8($,Z={}){let{lineCounter:X,prettyErrors:z}=i8(Z),q=new c8.Parser(X?.addNewLine),G=new l8.Composer(Z),J=null;for(let Q of G.compose(q.parse($),!0,$.length))if(!J)J=Q;else if(J.options.logLevel!=="silent"){J.errors.push(new J1.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(z&&X)J.errors.forEach(J1.prettifyError($,X)),J.warnings.forEach(J1.prettifyError($,X));return J}function VH($,Z,X){let z=void 0;if(typeof Z==="function")z=Z;else if(X===void 0&&Z&&typeof Z==="object")X=Z;let q=a8($,X);if(!q)return null;if(q.warnings.forEach((G)=>YH.warn(q.options.logLevel,G)),q.errors.length>0)if(q.options.logLevel!=="silent")throw q.errors[0];else q.errors=[];return q.toJS(Object.assign({reviver:z},X))}function KH($,Z,X){let z=null;if(typeof Z==="function"||Array.isArray(Z))z=Z;else if(X===void 0&&Z)X=Z;if(typeof X==="string")X=X.length;if(typeof X==="number"){let q=Math.round(X);X=q<1?void 0:q>8?{indent:8}:{indent:q}}if($===void 0){let{keepUndefined:q}=X??Z??{};if(!q)return}if(HH.isDocument($)&&!z)return $.toString(X);return new QH.Document($,z,X).toString(X)}BH.parse=VH;BH.parseAllDocuments=WH;BH.parseDocument=a8;BH.stringify=KH});var r8=F((EH)=>{var FH=w9(),MH=$1(),OH=J9(),x9=Z1(),wH=v$(),y0=E(),PH=N0(),IH=g(),RH=C0(),AH=E0(),jH=L2(),NH=E9(),SH=b9(),CH=y9(),_2=n8(),s8=h$();EH.Composer=FH.Composer;EH.Document=MH.Document;EH.Schema=OH.Schema;EH.YAMLError=x9.YAMLError;EH.YAMLParseError=x9.YAMLParseError;EH.YAMLWarning=x9.YAMLWarning;EH.Alias=wH.Alias;EH.isAlias=y0.isAlias;EH.isCollection=y0.isCollection;EH.isDocument=y0.isDocument;EH.isMap=y0.isMap;EH.isNode=y0.isNode;EH.isPair=y0.isPair;EH.isScalar=y0.isScalar;EH.isSeq=y0.isSeq;EH.Pair=PH.Pair;EH.Scalar=IH.Scalar;EH.YAMLMap=RH.YAMLMap;EH.YAMLSeq=AH.YAMLSeq;EH.CST=jH;EH.Lexer=NH.Lexer;EH.LineCounter=SH.LineCounter;EH.Parser=CH.Parser;EH.parse=_2.parse;EH.parseAllDocuments=_2.parseAllDocuments;EH.parseDocument=_2.parseDocument;EH.stringify=_2.stringify;EH.visit=s8.visit;EH.visitAsync=s8.visitAsync});var u5=P5(v5(),1),{program:X$,createCommand:mV,createArgument:dV,createOption:pV,CommanderError:lV,InvalidArgumentError:cV,InvalidOptionArgumentError:iV,Command:aV,Argument:nV,Option:O4,Help:sV}=u5.default;var m5={name:"@pickled-dev/cli",version:"0.19.1",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","@semantic-release/release-notes-generator":"^14.0.3"}};import RV from"path";var U0={category:"cli",provider:"claude-code",model:"sonnet"},w4=["Read","Glob","Grep","Bash"],P4=["Edit","MultiEdit","Write","NotebookEdit"];var o8=P5(r8(),1);async function B$($){let Z=`${$}/pickled.yml`,X=Bun.file(Z);if(!await X.exists())throw Error(`pickled.yml not found in ${$}`);let z;try{let q=await X.text();z=o8.default.parse(q)}catch(q){throw Error(`Failed to parse pickled.yml: ${q}`)}return z=k9(z),YU(z),z}var QU=/\$\{([A-Z_][A-Z0-9_]*)\}/g;function k9($){if(typeof $==="string")return $.replace(QU,(Z,X)=>process.env[X]??"");if(Array.isArray($))return $.map(k9);if($!==null&&typeof $==="object"){let Z={};for(let[X,z]of Object.entries($))Z[X]=k9(z);return Z}return $}function YU($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[X,z]of Object.entries($.docs.sources)){if(X==="none")throw Error('pickled.yml: docs.sources cannot use the reserved id "none". That name represents the no-context matrix cell (model prior with toolset:none, or open discovery with toolset:web). Rename this source.');LU(X,z)}if($.toolsets){if(typeof $.toolsets!=="object"||Array.isArray($.toolsets))throw Error("pickled.yml: 'toolsets' must be an object mapping name to configuration");for(let[X,z]of Object.entries($.toolsets))if(typeof z!=="object"||z===null||Array.isArray(z))throw Error(`pickled.yml: toolsets["${X}"] must be an object`)}if($.targets)for(let[X,z]of Object.entries($.targets)){if(z.systemPrompt!==void 0)throw Error(`pickled.yml: target "${X}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(z.provider==="codex-cli"){if(!z.model)throw Error(`pickled.yml: target "${X}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(z.maxTurns!==void 0)throw Error(`pickled.yml: target "${X}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}if(z.category==="api"){if(!z.model)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let q=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let G of q)if(z[G]!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets '${G}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(z.workspaceContext!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets 'workspaceContext', which only applies to IDE targets. Remove the field.`)}}let Z=new Set(Object.keys($.docs?.sources??{}));for(let X of $.scenarios){if(!X.name||!X.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(X.requiredSources!==void 0){if(!Array.isArray(X.requiredSources))throw Error(`pickled.yml: scenario "${X.name}" has non-array 'requiredSources'. Omit the field to skip citation scoring, or set [] for "any cited source counts".`);for(let z of X.requiredSources)if(!Z.has(z))throw Error(`pickled.yml: scenario "${X.name}" references unknown source "${z}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}_U(X.name,X.traps),BU(X.name,X.compareSurfaces,Z),UU(X.name,X.matrix,Z,new Set(Object.keys($.targets??{})),new Set(Object.keys($.toolsets??{none:{}}))),WU(X.name,X.expected),VU(X.name,X.verifiers,Z),KU(X)}HU($)}function HU($){if(!$.docs?.sources)return;let Z=[];for(let[z,q]of Object.entries($.docs.sources)){if(typeof q==="string")continue;let G=q.audit?.traps;if(Array.isArray(G))Z.push({id:z,list:G})}if(Z.length===0)return;let X=new Map;for(let z of $.scenarios)for(let q of z.traps??[]){let G=X.get(q.id);if(G!==void 0)throw Error(`pickled.yml: trap id "${q.id}" is declared in both scenario "${G}" and scenario "${z.name}". Globally unique trap ids are required when any source uses list-form audit.traps suppression. Rename one of the traps.`);X.set(q.id,z.name)}for(let{id:z,list:q}of Z)for(let G of q)if(!X.has(G)){let J=[...X.keys()].join(", ")||"(none)";throw Error(`pickled.yml: docs.sources["${z}"].audit.traps lists unknown trap id "${G}". Declared trap ids: ${J}`)}}function UU($,Z,X,z,q){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" matrix must be an object with optional interfaces/sources/toolsets arrays`);let G=(J,Q,Y)=>{let H=Z[J];if(H===void 0)return;if(!Array.isArray(H))throw Error(`pickled.yml: scenario "${$}" matrix.${J} must be an array of ${Y} names`);if(H.length===0)throw Error(`pickled.yml: scenario "${$}" matrix.${J} cannot be empty (omit the field to use defaults)`);for(let W of H){if(typeof W!=="string")throw Error(`pickled.yml: scenario "${$}" matrix.${J} entries must be strings`);if(!Q.has(W))throw Error(`pickled.yml: scenario "${$}" matrix.${J} references unknown ${Y} "${W}". Declared: ${[...Q].join(", ")||"(none)"}`)}};G("interfaces",z,"target"),G("sources",new Set([...X,"none"]),"source"),G("toolsets",q,"toolset")}function WU($,Z){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" expected must be an object with optional includes/excludes arrays`);let X=(z)=>{let q=Z[z];if(q===void 0)return;if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" expected.${z} must be an array of strings`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z} cannot be empty (omit the field instead)`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string"||q[G].length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z}[${G}] must be a non-empty string`)};X("includes"),X("excludes")}function VU($,Z,X){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" verifiers must be an object`);let z=Z.sources;if(z===void 0)return;if(!Array.isArray(z))throw Error(`pickled.yml: scenario "${$}" verifiers.sources must be an array of source IDs`);for(let q of z){if(typeof q!=="string")throw Error(`pickled.yml: scenario "${$}" verifiers.sources entries must be strings`);if(!X.has(q))throw Error(`pickled.yml: scenario "${$}" verifiers.sources references unknown source "${q}"`)}}function KU($){let Z=$.requiredSources!==void 0,X=$.expected!==void 0&&($.expected.includes!==void 0&&$.expected.includes.length>0||$.expected.excludes!==void 0&&$.expected.excludes.length>0),z=$.traps!==void 0&&$.traps.length>0;if(!Z&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" must declare at least one of requiredSources, expected.includes/excludes, or traps. A scenario with nothing to check has no verdict.`);let q=($.matrix?.toolsets??[]).filter((G)=>G!=="none");if(q.length>0&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" declares non-none toolsets [${q.join(", ")}] but has neither expected.includes/excludes nor traps. Non-none cells skip the citation contract because the source is not injected, so requiredSources alone leaves them with no actionable answer contract. Add expected or traps, or restrict matrix.toolsets to ["none"].`)}function BU($,Z,X){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(Z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let z=0;z<Z.length;z++){let q=Z[z];if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be an array of source ids`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be a non-empty list of source ids`);for(let G of q){if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] entries must be string source ids`);if(!X.has(G))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] references unknown source "${G}". Declared sources: ${[...X].join(", ")||"(none)"}`)}}}function LU($,Z){if(typeof Z==="string"){if(Z.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!Z||typeof Z!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let X=Z;if(typeof X.path!=="string"||X.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(X.audit!==void 0){if(typeof X.audit!=="object"||X.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let z=X.audit;if(z.traps!==void 0){let q=z.traps;if(typeof q==="boolean");else if(Array.isArray(q)){if(q.length===0)throw Error(`pickled.yml: docs.sources["${$}"].audit.traps cannot be an empty array; use true (scan all) or false (skip all) instead`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps[${G}] must be a string trap id`)}else throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean or an array of trap ids`)}for(let q of Object.keys(z))if(q!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${q}"`)}if(X.type!==void 0){if(X.type!=="file"&&X.type!=="url"&&X.type!=="codebase")throw Error(`pickled.yml: docs.sources["${$}"].type must be "file", "url", or "codebase"`)}if(X.type==="codebase"){if(typeof X.path==="string"&&X.path.split("/").includes(".."))throw Error(`pickled.yml: docs.sources["${$}"].path must not contain ".." segments. Codebase loader stays within the project root.`);if(X.exclude!==void 0){if(!Array.isArray(X.exclude))throw Error(`pickled.yml: docs.sources["${$}"].exclude must be an array of glob patterns`);for(let z=0;z<X.exclude.length;z++)if(typeof X.exclude[z]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].exclude[${z}] must be a string glob pattern`)}if(X.maxBytes!==void 0){if(typeof X.maxBytes!=="number"||!Number.isFinite(X.maxBytes)||X.maxBytes<=0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes must be a positive number of bytes`)}}else{if(X.exclude!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].exclude only applies to type: codebase sources`);if(X.maxBytes!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes only applies to type: codebase sources`)}for(let z of Object.keys(X))if(z!=="path"&&z!=="audit"&&z!=="type"&&z!=="exclude"&&z!=="maxBytes")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${z}"`)}var TU=new Set(["g","y"]),DU=new Set(["i","m","s","u","v"]);function _U($,Z){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let X=new Set;for(let z of Z){if(!z.id||typeof z.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(X.has(z.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${z.id}"`);if(X.add(z.id),!z.reason||typeof z.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" requires non-empty 'reason'`);if(z.auditSeverity!==void 0&&z.auditSeverity!=="warning"&&z.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" auditSeverity must be "warning" or "error"`);let q=typeof z.match==="string",G=typeof z.pattern==="string";if(q===G)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set exactly one of 'match' or 'pattern'`);if(q){if(z.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'match'`);if(z.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" sets 'flags' without 'pattern'`)}else{let J=z.pattern;if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set 'pattern'`);if(J==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'pattern'`);if(z.flags!==void 0){if(typeof z.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has non-string 'flags'`);for(let Q of z.flags){if(TU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!DU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(J,z.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has invalid regex pattern: ${Q instanceof Error?Q.message:Q}`)}}}}function f9($,Z){let X=new Set([...Object.keys($.targets??{}),"default"]);if(!X.has(Z)){let z=[...X].sort().join(", ");throw Error(`Unknown target: "${Z}". Available targets: ${z}`)}return{...$,matrix:{...$.matrix,target:[Z]},scenarios:$.scenarios.filter((z)=>!z.target||z.target===Z)}}function h9($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function F2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push(`# Agent-context audit
167
- `),G.push(`Target: \`${Z.targetRepo}\``),G.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),G.push(`Found ${X.length} agent-doc files. ${J} error(s), ${Q} warning(s).
168
- `),G.push(`## Inventory
169
- `),X.length===0)G.push(`No agent-doc files found.
170
- `);else{G.push("| File | Lines | Kind | Notes |"),G.push("|---|---|---|---|");let U=[...X].sort((V,B)=>B.lineCount-V.lineCount);for(let V of U){let B=!V.relPath.includes("/"),T=t8(V.lineCount,B,Z),K=V.isSymlink?`symlink \u2192 ${V.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file";G.push(`| \`${V.relPath}\` | ${V.lineCount} | ${K} | ${T} |`)}G.push("")}if(G.push(`## AGENTS.md / CLAUDE.md pairs
171
- `),z.length===0)G.push(`No pairs found.
172
- `);else{G.push("| Directory | A | C | Class | Detail |"),G.push("|---|---|---|---|---|");for(let U of z)G.push(`| \`${U.dir||"(root)"}\` | ${U.agentsExists?"\u2713":"\xB7"} | ${U.claudeExists?"\u2713":"\xB7"} | ${U.classification} | ${U.detail} |`);G.push("")}let Y=X.filter((U)=>!U.isSymlink&&U.brokenPathRefs.length+U.brokenImports.length>0);if(G.push(`## Broken references
173
- `),Y.length===0)G.push(`None detected.
174
- `);else for(let U of Y){if(G.push(`### \`${U.relPath}\`
175
- `),U.brokenPathRefs.length>0){G.push("Broken path references:");for(let V of U.brokenPathRefs)G.push(` - \`${V}\``);G.push("")}if(U.brokenImports.length>0){G.push("Broken `@`-imports:");for(let V of U.brokenImports)G.push(` - \`${V}\``);G.push("")}}let H=X.filter((U)=>!U.isSymlink&&U.unresolvedCommands.length>0);if(G.push(`## Unresolved package-manager commands (advisory)
176
- `),G.push("Looks like a script command in markdown that did not match anything in the target `package.json` `scripts` or the `knownCommands` allowlist. Workspace-filtered commands check against root scripts, so false positives are expected. Review, do not fail CI on this.\n"),H.length===0)G.push(`None flagged.
177
- `);else for(let U of H){G.push(`### \`${U.relPath}\`
178
- `);for(let V of U.unresolvedCommands)G.push(` - \`${V}\``);G.push("")}let W=X.filter((U)=>{if(U.isSymlink)return!1;return!U.relPath.includes("/")?U.lineCount>Z.budgets.rootLines:U.lineCount>Z.budgets.nestedWarnLines});if(G.push(`## Section breakdown for files over budget
179
- `),W.length===0)G.push(`All files within budget.
180
- `);else for(let U of W){G.push(`### \`${U.relPath}\` (${U.lineCount} lines)
181
- `),G.push(`Largest H2 sections (lines including any subsections):
182
- `),G.push("| Section | Lines |"),G.push("|---|---|");for(let V of U.sections.slice(0,10))G.push(`| ${V.header} | ${V.lines} |`);G.push("")}if(G.push(`## Registered-source trap matches
183
- `),G.push("Catches stale claims in `docs.sources` against declared traps. Per-source suppression: `audit.traps: false` skips all traps; `audit.traps: [<trap_id>, ...]` skips only the listed traps and keeps scanning the rest.\n"),$.sourceTrapMatches.length===0)G.push(`None.
184
- `);else{for(let U of $.sourceTrapMatches)G.push(`- **${U.sourceId}** (\`${U.sourcePath}:L${U.line}\`) \u2014 trap \`${U.trapId}\` matched \`${U.matched}\` (${U.severity})`),G.push(` - reason: ${U.trapReason}`),G.push(` - fix: remove the stale claim, retire the trap, set \`audit.traps: ['${U.trapId}']\` to suppress just this one (other traps still apply), or set \`audit.traps: false\` if the source is deliberately stale`);G.push("")}return G.join(`
185
- `)}function M2($){return JSON.stringify($,null,2)}function O2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push("pickled audit"),G.push(`Target: ${Z.targetRepo}`),G.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),G.push(`Found: ${X.length} agent-doc file(s) \xB7 ${J} error(s) \xB7 ${Q} warning(s)`),G.push(""),G.push("Inventory"),X.length===0)G.push(" none");else{let U=[...X].sort((B,T)=>T.lineCount-B.lineCount),V=Math.max(...U.map((B)=>B.relPath.length));for(let B of U){let T=!B.relPath.includes("/"),K=t8(B.lineCount,T,Z),L=B.isSymlink?`symlink \u2192 ${B.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file",D=`${B.lineCount}`.padStart(4),_=B.relPath.padEnd(V),O=K?` (${K})`:"";G.push(` ${_} ${D} lines ${L}${O}`)}}if(G.push(""),G.push("AGENTS.md / CLAUDE.md pairs"),z.length===0)G.push(" none");else for(let U of z){let V=U.dir||"(root)";G.push(` ${V}: ${U.classification} \xB7 ${U.detail}`)}G.push("");let Y=X.filter((U)=>!U.isSymlink&&U.brokenPathRefs.length+U.brokenImports.length>0);if(G.push("Broken references"),Y.length===0)G.push(" none");else for(let U of Y){G.push(` ${U.relPath}:`);for(let V of U.brokenPathRefs)G.push(` path: ${V}`);for(let V of U.brokenImports)G.push(` @-import: ${V}`)}G.push("");let H=X.filter((U)=>!U.isSymlink&&U.unresolvedCommands.length>0);if(G.push("Unresolved package-manager commands (advisory)"),H.length===0)G.push(" none");else for(let U of H){G.push(` ${U.relPath}:`);for(let V of U.unresolvedCommands)G.push(` ${V}`)}G.push("");let W=X.filter((U)=>{if(U.isSymlink)return!1;return!U.relPath.includes("/")?U.lineCount>Z.budgets.rootLines:U.lineCount>Z.budgets.nestedWarnLines});if(G.push("Section breakdown for files over budget"),W.length===0)G.push(" all files within budget");else for(let U of W){G.push(` ${U.relPath} (${U.lineCount} lines):`);for(let V of U.sections.slice(0,10))G.push(` ${V.header.padEnd(40)} ${V.lines} lines`)}if(G.push(""),G.push("Registered-source trap matches"),$.sourceTrapMatches.length===0)G.push(" none");else for(let U of $.sourceTrapMatches){let V=U.severity==="error"?"error":"warning";G.push(` [${V}] ${U.sourceId} (${U.sourcePath}:L${U.line}): trap ${U.trapId} matched "${U.matched}"`),G.push(` reason: ${U.trapReason}`),G.push(` fix: remove the stale claim, retire the trap, set audit.traps: ['${U.trapId}'] to suppress just this trap (others still apply), or set audit.traps: false if deliberately stale`)}return G.join(`
186
- `)}function t8($,Z,X){if(Z&&$>X.budgets.rootLines)return`over root budget (${$} > ${X.budgets.rootLines})`;if(!Z&&$>X.budgets.nestedWarnLines)return`over nested-warn (${$} > ${X.budgets.nestedWarnLines})`;return""}import{existsSync as T$,lstatSync as qZ,readFileSync as R2,readlinkSync as EU,statSync as bU}from"fs";import{dirname as A2,isAbsolute as yU,join as g9,relative as xU,resolve as v9}from"path";var{Glob:zZ}=globalThis.Bun;var w2=["node_modules/**","**/node_modules/**",".git/**","**/.git/**","dist/**","**/dist/**","build/**","**/build/**",".next/**","**/.next/**",".source/**","**/.source/**","out/**","**/out/**",".turbo/**","**/.turbo/**",".cache/**","**/.cache/**",".runs/**","**/.runs/**","coverage/**","**/coverage/**","**/__fixtures__/**","**/tests/**/fixture/**","**/tests/**/fixtures/**","**/test/**/fixture/**","**/test/**/fixtures/**"],L$={targetRepo:".",budgets:{rootLines:120,nestedWarnLines:200},ignore:w2,intentionalDifferentPairs:[],knownCommands:[]};function P2($){if(!$)return L$;return{targetRepo:$.targetRepo??L$.targetRepo,budgets:{rootLines:$.budgets?.rootLines??L$.budgets.rootLines,nestedWarnLines:$.budgets?.nestedWarnLines??L$.budgets.nestedWarnLines},ignore:$.ignore??w2,intentionalDifferentPairs:$.intentionalDifferentPairs??[],knownCommands:$.knownCommands??[]}}import{existsSync as AU}from"fs";import{join as jU,resolve as NU}from"path";function x0($){let Z=[],X=[];for(let z of $.traps){let q=FU($.response,z);if(q)Z.push(q);else X.push(z.id)}return{fired:Z,avoided:X}}function FU($,Z){if(Z.match!==void 0){let X=$.indexOf(Z.match);if(X===-1)return null;return{id:Z.id,reason:Z.reason,matched:Z.match,snippet:e8($,X,Z.match.length),index:X}}if(Z.pattern!==void 0){let z=new RegExp(Z.pattern,Z.flags??"").exec($);if(!z)return null;return{id:Z.id,reason:Z.reason,matched:z[0],snippet:e8($,z.index,z[0].length),index:z.index}}return null}function e8($,Z,X){let z=Math.max(0,Z-40),q=Math.min($.length,Z+X+40),G=$.slice(z,q).replace(/\s+/g," ").trim();if(z>0)G=`...${G}`;if(q<$.length)G=`${G}...`;return G}import I2 from"path";var{Glob:$Z}=globalThis.Bun;var MU=262144,OU=4194304;function wU($){return $.startsWith("http://")||$.startsWith("https://")}async function PU($,Z,X){let z=await fetch(Z);if(!z.ok)throw Error(`Failed to fetch source "${$}" from ${Z}: ${z.status} ${z.statusText}`);let q=await z.text();return{id:$,source:Z,content:q,name:new URL(Z).hostname+new URL(Z).pathname,type:"url",auditTraps:X}}async function IU($,Z,X,z){let q=I2.isAbsolute(Z)?Z:I2.resolve(X,Z),G=Bun.file(q);if(!await G.exists())throw Error(`Source "${$}" not found at ${q}`);let J=await G.text();return{id:$,source:Z,content:J,name:I2.basename(q),type:"file",auditTraps:z}}async function RU($,Z,X,z,q){let G=new $Z(Z.path),J=(Z.exclude??[]).map((B)=>new $Z(B)),Q=[];for await(let B of G.scan({cwd:X,onlyFiles:!0,followSymlinks:!1})){if(J.some((T)=>T.match(B)))continue;Q.push(B)}Q.sort();let Y=Z.maxBytes??MU,H=Math.max(Y,OU),W=[],U=0;for(let B of Q){let T=I2.resolve(X,B),K=await Bun.file(T).text(),L=`// === ${B} ===
187
- `;if(W.push(L,K),!K.endsWith(`
188
- `))W.push(`
189
- `);if(U+=L.length+K.length,U>H)throw Error(`Codebase source "${$}" exceeded hard cap of ${H} bytes (matched glob ${Z.path}). Tighten the glob or raise the limit via maxBytes (and accept the request-size risk).`)}if(U>Y)q?.(` warn: codebase source [${$}] is ${U} bytes (soft cap ${Y}); consider tightening the glob`);let V=W.join("");return{id:$,source:Z.path,content:V,name:`${Q.length} file${Q.length===1?"":"s"} in ${Z.path}`,type:"codebase",auditTraps:z,matchedFiles:Q}}async function ZZ($,Z,X,z){let{path:q,auditTraps:G}=h9(Z);if(typeof Z!=="string"&&Z.type==="codebase")return RU($,Z,X,G,z);if(wU(q))return PU($,q,G);return IU($,q,X,G)}async function Q1($,Z,X){let z=Object.entries($);return await Promise.all(z.map(([G,J])=>ZZ(G,J,Z,X)))}async function XZ($){if(!AU(jU($,"pickled.yml")))return{matches:[],findings:[]};let Z=await B$($),X=Z.docs?.sources;if(!X||Object.keys(X).length===0)return{matches:[],findings:[]};let z={};for(let[H,W]of Object.entries(X)){let U=typeof W==="string"?W:W.path;if(U.startsWith("http://")||U.startsWith("https://"))continue;z[H]=W}if(Object.keys(z).length===0)return{matches:[],findings:[]};let q=[],G=new Map;for(let H of Z.scenarios)for(let W of H.traps??[])q.push(W),G.set(W,W.auditSeverity??"warning");if(q.length===0)return{matches:[],findings:[]};let J=await Q1(z,$),Q=[],Y=[];for(let H of J){let W=H.auditTraps;if(W===!1)continue;let U=Array.isArray(W)?new Set(W):null,V=H.type==="codebase"&&H.matchedFiles?await SU(H.matchedFiles,$,H.source):[{path:H.source,content:H.content}];for(let B of V)for(let T of q){if(U?.has(T.id))continue;let{fired:K}=x0({response:B.content,traps:[T]}),L=K[0];if(!L)continue;let D=CU(B.content,L.index),_=G.get(T)??"warning";Q.push({sourceId:H.id,sourcePath:B.path,trapId:L.id,trapReason:L.reason,matched:L.matched,snippet:L.snippet,line:D,severity:_}),Y.push({severity:_,category:"trap-source-match",file:B.path,message:`source [${H.id}] matches trap '${L.id}' ("${L.matched}") in ${B.path}. ${L.reason} Fix: remove the stale claim from the source, retire the trap if no longer relevant, set audit.traps: ['${L.id}'] on the source to suppress just this trap (other traps still apply), or set audit.traps: false if the source is deliberately stale or test-only.`})}}return{matches:Q,findings:Y}}async function SU($,Z,X){let z=[];for(let q of $)try{let G=await Bun.file(NU(Z,q)).text();z.push({path:q,content:G})}catch{}return z}function CU($,Z){let X=1,z=Math.min(Z,$.length);for(let q=0;q<z;q++)if($[q]===`
190
- `)X++;return X}var kU=["AGENTS.md","CLAUDE.md","CLAUDE.local.md","llms.txt","llms-full.txt",".claude/CLAUDE.md",".claude/rules/*.md","**/AGENTS.md","**/CLAUDE.md","**/CLAUDE.local.md","**/llms.txt","**/llms-full.txt","**/.claude/CLAUDE.md","**/.claude/rules/*.md"];async function j2($){let Z=P2($),X=v9(Z.targetRepo);if(!T$(X))throw Error(`targetRepo does not exist: ${X}`);let z=new Set;for(let H of kU){let W=new zZ(H);for await(let U of W.scan({cwd:X,dot:!0,onlyFiles:!1,followSymlinks:!1})){if(Z.ignore.some((T)=>new zZ(T).match(U)))continue;let V=g9(X,U),B=qZ(V);if(B.isFile()){z.add(U);continue}if(B.isSymbolicLink())try{if(bU(V).isFile())z.add(U)}catch{}}}let q=[];for(let H of[...z].sort())q.push(await fU(X,H,g9(X,H),Z));let G=nU(q,Z),J=sU(q,G,Z),{matches:Q,findings:Y}=await XZ(X);return{config:Z,files:q,pairs:G,findings:[...J,...Y],sourceTrapMatches:Q}}async function fU($,Z,X,z){let G=qZ(X).isSymbolicLink(),J=null,Q=Z;if(G){let V=EU(X),B=yU(V)?V:v9(A2(X),V);if(J=B,T$(B))Q=xU($,B)}let Y=G&&J&&T$(J)?J:X,H=R2(Y,"utf8"),W=(H.match(/\n/g)??[]).length,U=H.endsWith(`
191
- `)?W:W+1;return{relPath:Z,absPath:X,isSymlink:G,symlinkTarget:J,realRelPath:Q,lineCount:U,brokenPathRefs:gU(H,$,Z),brokenImports:uU(H,A2(X)),unresolvedCommands:lU(H,$,z.knownCommands),sections:cU(H)}}function hU($){let Z=$.split("/");if(Z.length<2)return null;if(Z[0]==="packages"||Z[0]==="apps"||Z[0]==="shared")return`${Z[0]}/${Z[1]}`;if(Z[0]==="tests")return Z.slice(0,2).join("/");return null}function gU($,Z,X){let z=aU($),q=A2(X),G=hU(X),J=new Set,Q=/`([^`\n]{2,200})`/g,Y;Y=Q.exec(z);while(Y!==null){let H=Y[1].trim().replace(/[#?].*$/,"");if(iU(H)&&!vU(Z,H,q,G).found)J.add(H);Y=Q.exec(z)}return[...J].sort()}function vU($,Z,X,z){let q=[Z];if(X&&X!==".")q.push(`${X}/${Z}`);if(z)q.push(`${z}/${Z}`);q.push(`packages/${Z}`,`apps/${Z}`,`shared/${Z}`);for(let G of q){let J=G.replace(/\/+/g,"/");if(T$(`${$}/${J}`))return{found:!0,resolvedAs:J}}return{found:!1}}function uU($,Z){let X=new Set,z=/@([\w./@~-]+\.md)/g,q;q=z.exec($);while(q!==null){let G=q[1];if(G.startsWith("~/")){q=z.exec($);continue}let J=G.startsWith("/")?G:v9(Z,G);if(!T$(J))X.add(G);q=z.exec($)}return[...X].sort()}var mU=["bun","pnpm","npm","yarn"],dU=new Set(["install","add","remove","update","i","audit","list","ls","why","outdated","exec","run","create","init","x"]),pU={bun:new Set(["build","test","link","unlink","upgrade"])};function lU($,Z,X){let z=new Set,q=g9(Z,"package.json"),G=new Set;if(T$(q))try{let Q=JSON.parse(R2(q,"utf8"));G=new Set(Object.keys(Q.scripts??{}))}catch{}let J=new Set(X.map((Q)=>Q.trim()));for(let Q of mU){let Y=new RegExp(`\\b${Q}\\s+(?:run\\s+|--filter\\s+\\S+\\s+(?:run\\s+)?)?([a-zA-Z][\\w:.\\-]*)`,"g"),H;H=Y.exec($);while(H!==null){let W=H[1];if(!G.has(W)&&!J.has(`${Q} ${W}`)&&!J.has(`${Q} run ${W}`)&&!dU.has(W)&&!pU[Q]?.has(W))z.add(`${Q} ${W}`);H=Y.exec($)}}return[...z].sort()}function cU($){let Z=$.split(`
192
- `),X=[],z=null;if(Z.forEach((q,G)=>{if(/^##\s+/.test(q)){if(z)X.push({header:z.header,lines:G-z.start});z={header:q.replace(/^##\s+/,"").trim(),start:G}}}),z){let q=z;X.push({header:q.header,lines:Z.length-q.start})}return X.sort((q,G)=>G.lines-q.lines)}function iU($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function aU($){return $.replace(/```[\s\S]*?```/g,"")}function nU($,Z){let X=new Map;for(let G of $){let J=G.relPath.split("/").pop()??"";if(J!=="AGENTS.md"&&J!=="CLAUDE.md")continue;let Q=A2(G.relPath),Y=X.get(Q)??{};if(J==="AGENTS.md")Y.agents=G;if(J==="CLAUDE.md")Y.claude=G;X.set(Q,Y)}let z=new Set(Z.intentionalDifferentPairs),q=[];for(let[G,J]of X){let Q=!!J.agents,Y=!!J.claude;if(!Q&&!Y)continue;if(!Q||!Y){q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:H,claude:W}=J,U=`${H.relPath}:${W.relPath}`,V=`${W.relPath}:${H.relPath}`;if(z.has(U)||z.has(V)){q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"intentional-different",detail:`allowlisted: ${H.lineCount}L vs ${W.lineCount}L`});continue}if(H.isSymlink&&H.symlinkTarget===W.absPath||W.isSymlink&&W.symlinkTarget===H.absPath){let L=H.isSymlink?"CLAUDE.md":"AGENTS.md";q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"linked",detail:`canonical: ${L}`});continue}let T=R2(H.absPath,"utf8"),K=R2(W.absPath,"utf8");if(T===K)q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${H.lineCount}L), not symlinked`});else q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`divergent (${H.lineCount}L vs ${W.lineCount}L), not in intentional-different allowlist`})}return q.sort((G,J)=>G.dir.localeCompare(J.dir)),q}function sU($,Z,X){let z=[];for(let q of $){if(q.isSymlink)continue;for(let Q of q.brokenImports)z.push({severity:"error",category:"broken-import",file:q.relPath,message:`broken @-import: ${Q}`});for(let Q of q.brokenPathRefs)z.push({severity:"error",category:"broken-path-ref",file:q.relPath,message:`broken path reference: ${Q}`});for(let Q of q.unresolvedCommands)z.push({severity:"warning",category:"unresolved-command",file:q.relPath,message:`unresolved command: ${Q}`});let G=!q.relPath.includes("/"),J=G?X.budgets.rootLines:X.budgets.nestedWarnLines;if(q.lineCount>J)z.push({severity:"warning",category:"over-budget",file:q.relPath,message:`${q.lineCount} lines exceeds ${G?"root":"nested"} budget of ${J}`})}for(let q of Z)if(q.classification==="unexpected-duplicate"){let G=q.detail.startsWith("divergent")?"error":"warning";z.push({severity:G,category:G==="error"?"divergent-pair":"duplicate-pair",file:q.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${q.detail}`})}return z}function F0($){let Z=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:Z,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:Z,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:Z>=90?"Well grounded":"Grounded",confidence:Z,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:Z,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:Z,tone:"error"}}function u9($){let Z=rU($);if(Z===null)return[];let X=[],z=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,q=z.exec(Z);while(q!==null)X.push({id:q[1].trim(),note:q[2].trim()||void 0}),q=z.exec(Z);return X}function rU($){let X=/^##\s+Sources\s*$/im.exec($);if(!X)return null;let z=X.index+X[0].length,q=$.slice(z),G=/^##\s+/m.exec(q);return G?q.slice(0,G.index):q}function D$($){let Z=u9($.response),X=new Set(Z.map((V)=>V.id)),z=new Set($.registeredIds),q=new Set($.requiredSources),G=[...X],J=[...q].filter((V)=>!X.has(V)),Q=[...X].filter((V)=>!z.has(V)),Y=[...q],H,W,U;if(G.length===0)H="NO",W=0,U="No citations in response";else if(Q.length===G.length)H="NO",W=0,U=`All cited sources are unknown: ${Q.join(", ")}`;else if(J.length===0&&Q.length===0)H="YES",W=100,U=Y.length>0?`All required sources cited: ${Y.join(", ")}`:`Cited registered sources: ${G.join(", ")}`;else{H="PARTIAL";let V=Y.length>0?Y.length:1,B=Y.length-J.length,T=Y.length>0?B/V*100:60,K=Q.length*15;W=Math.max(0,Math.min(100,Math.round(T-K)));let L=[];if(J.length>0)L.push(`missing: ${J.join(", ")}`);if(Q.length>0)L.push(`unknown: ${Q.join(", ")}`);U=L.join("; ")}return{answerable:H,confidence:W,reason:U,citations:{cited:G,required:Y,missing:J,unknown:Q}}}function N2($){let Z=$.expected,X=(Z?.includes??[]).map((J)=>({value:J,satisfied:$.response.includes(J)})),z=(Z?.excludes??[]).map((J)=>({value:J,satisfied:!$.response.includes(J)})),q=X.filter((J)=>J.satisfied).length+z.filter((J)=>J.satisfied).length,G=X.length+z.length;return{includes:X,excludes:z,satisfied:q,total:G}}var s0="0.40.1";var GZ=!1,r0=void 0,m9=void 0,oU=void 0,tU=void 0,eU=void 0,JZ=void 0,$W=void 0,S2=void 0,d9=void 0,QZ=void 0,p9=void 0,C2=void 0,YZ=void 0;function HZ($,Z={auto:!1}){if(GZ)throw Error(`you must \`import '@anthropic-ai/sdk/shims/${$.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(r0)throw Error(`can't \`import '@anthropic-ai/sdk/shims/${$.kind}'\` after \`import '@anthropic-ai/sdk/shims/${r0}'\``);GZ=Z.auto,r0=$.kind,m9=$.fetch,oU=$.Request,tU=$.Response,eU=$.Headers,JZ=$.FormData,$W=$.Blob,S2=$.File,d9=$.ReadableStream,QZ=$.getMultipartRequestOptions,p9=$.getDefaultAgent,C2=$.fileFromPath,YZ=$.isFsReadStream}class l9{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function UZ({manuallyImported:$}={}){let Z=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",X,z,q,G;try{X=fetch,z=Request,q=Response,G=Headers}catch(J){throw Error(`this environment is missing the following Web Fetch API type: ${J.message}. ${Z}`)}return{kind:"web",fetch:X,Request:z,Response:q,Headers:G,FormData:typeof FormData<"u"?FormData:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${Z}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${Z}`)}},File:typeof File<"u"?File:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${Z}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${Z}`)}},getMultipartRequestOptions:async(J,Q)=>({...Q,body:new l9(J)}),getDefaultAgent:(J)=>{return},fileFromPath:()=>{throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:(J)=>!1}}import{ReadStream as XW}from"fs";function WZ(){let $=UZ();function Z(X){return X instanceof XW}return{...$,isFsReadStream:Z}}var c9=()=>{if(!r0)HZ(WZ(),{auto:!0})};c9();class A extends Error{}class u extends A{constructor($,Z,X,z){super(`${u.makeMessage($,Z,X)}`);this.status=$,this.headers=z,this.request_id=z?.["request-id"],this.error=Z}static makeMessage($,Z,X){let z=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):X;if($&&z)return`${$} ${z}`;if($)return`${$} status code (no body)`;if(z)return z;return"(no status code or body)"}static generate($,Z,X,z){if(!$||!z)return new o0({message:X,cause:v2(Z)});let q=Z;if($===400)return new E2($,q,X,z);if($===401)return new b2($,q,X,z);if($===403)return new y2($,q,X,z);if($===404)return new x2($,q,X,z);if($===409)return new k2($,q,X,z);if($===422)return new f2($,q,X,z);if($===429)return new h2($,q,X,z);if($>=500)return new g2($,q,X,z);return new u($,q,X,z)}}class i extends u{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class o0 extends u{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}}class Y1 extends o0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class E2 extends u{}class b2 extends u{}class y2 extends u{}class x2 extends u{}class k2 extends u{}class f2 extends u{}class h2 extends u{}class g2 extends u{}var u2=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},t0=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},t;class k0{constructor(){t.set(this,void 0),this.buffer=new Uint8Array,u2(this,t,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,X=new Uint8Array(this.buffer.length+Z.length);X.set(this.buffer),X.set(Z,this.buffer.length),this.buffer=X;let z=[],q;while((q=qW(this.buffer,t0(this,t,"f")))!=null){if(q.carriage&&t0(this,t,"f")==null){u2(this,t,q.index,"f");continue}if(t0(this,t,"f")!=null&&(q.index!==t0(this,t,"f")+1||q.carriage)){z.push(this.decodeText(this.buffer.slice(0,t0(this,t,"f")-1))),this.buffer=this.buffer.slice(t0(this,t,"f")),u2(this,t,null,"f");continue}let G=t0(this,t,"f")!==null?q.preceding-1:q.preceding,J=this.decodeText(this.buffer.slice(0,G));z.push(J),this.buffer=this.buffer.slice(q.index),u2(this,t,null,"f")}return z}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer<"u"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new A(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new A(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new A("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
193
- `)}}t=new WeakMap;k0.NEWLINE_CHARS=new Set([`
194
- `,"\r"]);k0.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function qW($,Z){for(let q=Z??0;q<$.length;q++){if($[q]===10)return{preceding:q,index:q+1,carriage:!1};if($[q]===13)return{preceding:q,index:q+1,carriage:!0}}return null}function VZ($){for(let z=0;z<$.length-1;z++){if($[z]===10&&$[z+1]===10)return z+2;if($[z]===13&&$[z+1]===13)return z+2;if($[z]===13&&$[z+1]===10&&z+3<$.length&&$[z+2]===13&&$[z+3]===10)return z+4}return-1}function H1($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let X=await Z.read();if(X?.done)Z.releaseLock();return X}catch(X){throw Z.releaseLock(),X}},async return(){let X=Z.cancel();return Z.releaseLock(),await X,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class e{constructor($,Z){this.iterator=$,this.controller=Z}static fromSSEResponse($,Z){let X=!1;async function*z(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let q=!1;try{for await(let G of GW($,Z)){if(G.event==="completion")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="message_start"||G.event==="message_delta"||G.event==="message_stop"||G.event==="content_block_start"||G.event==="content_block_delta"||G.event==="content_block_stop")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="ping")continue;if(G.event==="error")throw u.generate(void 0,`SSE Error: ${G.data}`,G.data,i9($.headers))}q=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!q)Z.abort()}}return new e(z,Z)}static fromReadableStream($,Z){let X=!1;async function*z(){let G=new k0,J=H1($);for await(let Q of J)for(let Y of G.decode(Q))yield Y;for(let Q of G.flush())yield Q}async function*q(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let G=!1;try{for await(let J of z()){if(G)continue;if(J)yield JSON.parse(J)}G=!0}catch(J){if(J instanceof Error&&J.name==="AbortError")return;throw J}finally{if(!G)Z.abort()}}return new e(q,Z)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],Z=[],X=this.iterator(),z=(q)=>{return{next:()=>{if(q.length===0){let G=X.next();$.push(G),Z.push(G)}return q.shift()}}};return[new e(()=>z($),this.controller),new e(()=>z(Z),this.controller)]}toReadableStream(){let $=this,Z,X=new TextEncoder;return new d9({async start(){Z=$[Symbol.asyncIterator]()},async pull(z){try{let{value:q,done:G}=await Z.next();if(G)return z.close();let J=X.encode(JSON.stringify(q)+`
195
- `);z.enqueue(J)}catch(q){z.error(q)}},async cancel(){await Z.return?.()}})}}async function*GW($,Z){if(!$.body)throw Z.abort(),new A("Attempted to iterate over a response with no body");let X=new KZ,z=new k0,q=H1($.body);for await(let G of JW(q))for(let J of z.decode(G)){let Q=X.decode(J);if(Q)yield Q}for(let G of z.flush()){let J=X.decode(G);if(J)yield J}}async function*JW($){let Z=new Uint8Array;for await(let X of $){if(X==null)continue;let z=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?new TextEncoder().encode(X):X,q=new Uint8Array(Z.length+z.length);q.set(Z),q.set(z,Z.length),Z=q;let G;while((G=VZ(Z))!==-1)yield Z.slice(0,G),Z=Z.slice(G)}if(Z.length>0)yield Z}class KZ{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let q={event:this.event,data:this.data.join(`
196
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],q}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,X,z]=QW($,":");if(z.startsWith(" "))z=z.substring(1);if(Z==="event")this.event=z;else if(Z==="data")this.data.push(z);return null}}function QW($,Z){let X=$.indexOf(Z);if(X!==-1)return[$.substring(0,X),Z,$.substring(X+Z.length)];return[$,"",""]}var YW=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",HW=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&U1($),U1=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function";async function BZ($,Z,X){if($=await $,HW($))return $;if(YW($)){let q=await $.blob();Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let G=U1(q)?[await q.arrayBuffer()]:[q];return new S2(G,Z,X)}let z=await UW($);if(Z||(Z=VW($)??"unknown_file"),!X?.type){let q=z[0]?.type;if(typeof q==="string")X={...X,type:q}}return new S2(z,Z,X)}async function UW($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(U1($))Z.push(await $.arrayBuffer());else if(KW($))for await(let X of $)Z.push(X);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${WW($)}`);return Z}function WW($){return`[${Object.getOwnPropertyNames($).map((X)=>`"${X}"`).join(", ")}]`}function VW($){return a9($.name)||a9($.filename)||a9($.path)?.split(/[\\/]/).pop()}var a9=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},KW=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",n9=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var LW=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},TW=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},m2;c9();async function FZ($){let{response:Z}=$;if($.options.stream){if(_$("response",Z.status,Z.url,Z.headers,Z.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(Z,$.controller);return e.fromSSEResponse(Z,$.controller)}if(Z.status===204)return null;if($.options.__binaryResponse)return Z;let z=Z.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json")){let J=await Z.json();return _$("response",Z.status,Z.url,Z.headers,J),MZ(J,Z)}let G=await Z.text();return _$("response",Z.status,Z.url,Z.headers,G),G}function MZ($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}class p2 extends Promise{constructor($,Z=FZ){super((X)=>{X(null)});this.responsePromise=$,this.parseResponse=Z}_thenUnwrap($){return new p2(this.responsePromise,async(Z)=>MZ($(await this.parseResponse(Z),Z),Z.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:Z,request_id:Z.headers.get("request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class r9{constructor({baseURL:$,maxRetries:Z=2,timeout:X=600000,httpAgent:z,fetch:q}){this.baseURL=$,this.maxRetries=s9("maxRetries",Z),this.timeout=s9("timeout",X),this.httpAgent=z,this.fetch=q??m9}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...MW(),...this.authHeaders($)}}validateHeaders($,Z){}defaultIdempotencyKey(){return`stainless-node-retry-${RW()}`}get($,Z){return this.methodRequest("get",$,Z)}post($,Z){return this.methodRequest("post",$,Z)}patch($,Z){return this.methodRequest("patch",$,Z)}put($,Z){return this.methodRequest("put",$,Z)}delete($,Z){return this.methodRequest("delete",$,Z)}methodRequest($,Z,X){return this.request(Promise.resolve(X).then(async(z)=>{let q=z&&U1(z?.body)?new DataView(await z.body.arrayBuffer()):z?.body instanceof DataView?z.body:z?.body instanceof ArrayBuffer?new DataView(z.body):z&&ArrayBuffer.isView(z?.body)?new DataView(z.body.buffer):z?.body;return{method:$,path:Z,...z,body:q}}))}getAPIList($,Z,X){return this.requestAPIList(Z,{method:"get",path:$,...X})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer<"u")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:Z=0}={}){let X={...$},{method:z,path:q,query:G,headers:J={}}=X,Q=ArrayBuffer.isView(X.body)||X.__binaryRequest&&typeof X.body==="string"?X.body:n9(X.body)?X.body.body:X.body?JSON.stringify(X.body,null,2):null,Y=this.calculateContentLength(Q),H=this.buildURL(q,G);if("timeout"in X)s9("timeout",X.timeout);X.timeout=X.timeout??this.timeout;let W=X.httpAgent??this.httpAgent??p9(H),U=X.timeout+1000;if(typeof W?.options?.timeout==="number"&&U>(W.options.timeout??0))W.options.timeout=U;if(this.idempotencyHeader&&z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let V=this.buildHeaders({options:X,headers:J,contentLength:Y,retryCount:Z});return{req:{method:z,...Q&&{body:Q},headers:V,...W&&{agent:W},signal:X.signal??null},url:H,timeout:X.timeout}}buildHeaders({options:$,headers:Z,contentLength:X,retryCount:z}){let q={};if(X)q["content-length"]=X;let G=this.defaultHeaders($);if(_Z(q,G),_Z(q,Z),n9($.body)&&r0!=="node")delete q["content-type"];if(d2(G,"x-stainless-retry-count")===void 0&&d2(Z,"x-stainless-retry-count")===void 0)q["x-stainless-retry-count"]=String(z);if(d2(G,"x-stainless-timeout")===void 0&&d2(Z,"x-stainless-timeout")===void 0&&$.timeout)q["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(q,Z),q}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new A("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:X}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((Z)=>[...Z])):{...$}}makeStatusError($,Z,X,z){return u.generate($,Z,X,z)}request($,Z=null){return new p2(this.makeRequest($,Z))}async makeRequest($,Z){let X=await $,z=X.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(X);let{req:q,url:G,timeout:J}=this.buildRequest(X,{retryCount:z-Z});if(await this.prepareRequest(q,{url:G,options:X}),_$("request",G,X,q.headers),X.signal?.aborted)throw new i;let Q=new AbortController,Y=await this.fetchWithTimeout(G,q,J,Q).catch(v2);if(Y instanceof Error){if(X.signal?.aborted)throw new i;if(Z)return this.retryRequest(X,Z);if(Y.name==="AbortError")throw new Y1;throw new o0({cause:Y})}let H=i9(Y.headers);if(!Y.ok){if(Z&&this.shouldRetry(Y)){let K=`retrying, ${Z} attempts remaining`;return _$(`response (error; ${K})`,Y.status,G,H),this.retryRequest(X,Z,H)}let W=await Y.text().catch((K)=>v2(K).message),U=OW(W),V=U?void 0:W;throw _$(`response (error; ${Z?"(error; no more retries left)":"(error; not retryable)"})`,Y.status,G,H,V),this.makeStatusError(Y.status,U,V,H)}return{response:Y,options:X,controller:Q}}requestAPIList($,Z){let X=this.makeRequest(Z,null);return new OZ(this,X,$)}buildURL($,Z){let X=PW($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),z=this.defaultQuery();if(!wZ(z))Z={...z,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))X.search=this.stringifyQuery(Z);return X.toString()}stringifyQuery($){return Object.entries($).filter(([Z,X])=>typeof X<"u").map(([Z,X])=>{if(typeof X==="string"||typeof X==="number"||typeof X==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(X)}`;if(X===null)return`${encodeURIComponent(Z)}=`;throw new A(`Cannot stringify type ${typeof X}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,Z,X,z){let{signal:q,...G}=Z||{};if(q)q.addEventListener("abort",()=>z.abort());let J=setTimeout(()=>z.abort(),X),Q={signal:z.signal,...G};if(Q.method)Q.method=Q.method.toUpperCase();let Y=60000,H=setTimeout(()=>{if(Q&&Q?.agent?.sockets){for(let W of Object.values(Q?.agent?.sockets).flat())if(W?.setKeepAlive)W.setKeepAlive(!0,Y)}},Y);return this.fetch.call(void 0,$,Q).finally(()=>{clearTimeout(J),clearTimeout(H)})}shouldRetry($){let Z=$.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,Z,X){let z,q=X?.["retry-after-ms"];if(q){let J=parseFloat(q);if(!Number.isNaN(J))z=J}let G=X?.["retry-after"];if(G&&!z){let J=parseFloat(G);if(!Number.isNaN(J))z=J*1000;else z=Date.parse(G)-Date.now()}if(!(z&&0<=z&&z<60000)){let J=$.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,J)}return await IW(z),this.makeRequest($,Z-1)}calculateDefaultRetryTimeoutMillis($,Z){let q=Z-$,G=Math.min(0.5*Math.pow(2,q),8),J=1-Math.random()*0.25;return G*J*1000}getUserAgent(){return`${this.constructor.name}/JS ${s0}`}}class o9{constructor($,Z,X,z){m2.set(this,void 0),LW(this,m2,$,"f"),this.options=z,this.response=Z,this.body=X}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new A("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let Z={...this.options};if("params"in $&&typeof Z.query==="object")Z.query={...Z.query,...$.params};else if("url"in $){let X=[...Object.entries(Z.query||{}),...$.url.searchParams.entries()];for(let[z,q]of X)$.url.searchParams.set(z,q);Z.query=void 0,Z.path=$.url.toString()}return await TW(this,m2,"f").requestAPIList(this.constructor,Z)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(m2=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}}class OZ extends p2{constructor($,Z,X){super(Z,async(z)=>new X($,z.response,await FZ(z),z.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}}var i9=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(Z,X){let z=X.toString();return Z[z.toLowerCase()]||Z[z]}})},DW={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},z0=($)=>{return typeof $==="object"&&$!==null&&!wZ($)&&Object.keys($).every((Z)=>PZ(DW,Z))},_W=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":TZ(Deno.build.os),"X-Stainless-Arch":LZ(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":TZ(process.platform),"X-Stainless-Arch":LZ(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=FW();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function FW(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:X}of $){let z=X.exec(navigator.userAgent);if(z){let q=z[1]||0,G=z[2]||0,J=z[3]||0;return{browser:Z,version:`${q}.${G}.${J}`}}}return null}var LZ=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},TZ=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},DZ,MW=()=>{return DZ??(DZ=_W())},OW=($)=>{try{return JSON.parse($)}catch(Z){return}},wW=/^[a-z][a-z0-9+.-]*:/i,PW=($)=>{return wW.test($)},IW=($)=>new Promise((Z)=>setTimeout(Z,$)),s9=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new A(`${$} must be an integer`);if(Z<0)throw new A(`${$} must be a positive integer`);return Z},v2=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return Error(JSON.stringify($))}catch{}return Error(String($))};var l2=($)=>{if(typeof process<"u")return process.env?.[$]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.($)?.trim();return};function wZ($){if(!$)return!0;for(let Z in $)return!1;return!0}function PZ($,Z){return Object.prototype.hasOwnProperty.call($,Z)}function _Z($,Z){for(let X in Z){if(!PZ(Z,X))continue;let z=X.toLowerCase();if(!z)continue;let q=Z[X];if(q===null)delete $[z];else if(q!==void 0)$[z]=q}}function _$($,...Z){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...Z)}var RW=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let Z=Math.random()*16|0;return($==="x"?Z:Z&3|8).toString(16)})},IZ=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},AW=($)=>{return typeof $?.get==="function"};var d2=($,Z)=>{let X=Z.toLowerCase();if(AW($)){let z=Z[0]?.toUpperCase()+Z.substring(1).replace(/([^\w])(\w)/g,(q,G,J)=>G+J.toUpperCase());for(let q of[Z,X,Z.toUpperCase(),z]){let G=$.get(q);if(G)return G}}for(let[z,q]of Object.entries($))if(z.toLowerCase()===X){if(Array.isArray(q)){if(q.length<=1)return q[0];return console.warn(`Received ${q.length} entries for the ${Z} header, using the first entry.`),q[0]}return q}return};class M0 extends o9{constructor($,Z,X,z){super($,Z,X,z);this.data=X.data||[],this.has_more=X.has_more||!1,this.first_id=X.first_id||null,this.last_id=X.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let Z=Object.fromEntries($.url.searchParams);if(!Object.keys(Z).length)return null;return Z}nextPageInfo(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{params:{before_id:Z}}}let $=this.last_id;if(!$)return null;return{params:{after_id:$}}}}class c{constructor($){this._client=$}}class F$ extends c{retrieve($,Z){return this._client.get(`/v1/models/${$}?beta=true`,Z)}list($={},Z){if(z0($))return this.list({},$);return this._client.getAPIList("/v1/models?beta=true",W1,{query:$,...Z})}}class W1 extends M0{}F$.BetaModelInfosPage=W1;class M${constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new k0;for await(let Z of this.iterator)for(let X of $.decode(Z))yield JSON.parse(X);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body)throw Z.abort(),new A("Attempted to iterate over a response with no body");return new M$(H1($.body),Z)}}class O$ extends c{create($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/batches?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}retrieve($,Z={},X){if(z0(Z))return this.retrieve($,{},Z);let{betas:z}=Z;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}list($={},Z){if(z0($))return this.list({},$);let{betas:X,...z}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",V1,{query:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}delete($,Z={},X){if(z0(Z))return this.delete($,{},Z);let{betas:z}=Z;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}cancel($,Z={},X){if(z0(Z))return this.cancel($,{},Z);let{betas:z}=Z;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}async results($,Z={},X){if(z0(Z))return this.results($,{},Z);let z=await this.retrieve($);if(!z.results_url)throw new A(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);let{betas:q}=Z;return this._client.get(z.results_url,{...X,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...X?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((G,J)=>M$.fromResponse(J.response,J.controller))}}class V1 extends M0{}O$.BetaMessageBatchesPage=V1;var CW=($)=>{let Z=0,X=[];while(Z<$.length){let z=$[Z];if(z==="\\"){Z++;continue}if(z==="{"){X.push({type:"brace",value:"{"}),Z++;continue}if(z==="}"){X.push({type:"brace",value:"}"}),Z++;continue}if(z==="["){X.push({type:"paren",value:"["}),Z++;continue}if(z==="]"){X.push({type:"paren",value:"]"}),Z++;continue}if(z===":"){X.push({type:"separator",value:":"}),Z++;continue}if(z===","){X.push({type:"delimiter",value:","}),Z++;continue}if(z==='"'){let Q="",Y=!1;z=$[++Z];while(z!=='"'){if(Z===$.length){Y=!0;break}if(z==="\\"){if(Z++,Z===$.length){Y=!0;break}Q+=z+$[Z],z=$[++Z]}else Q+=z,z=$[++Z]}if(z=$[++Z],!Y)X.push({type:"string",value:Q});continue}if(z&&/\s/.test(z)){Z++;continue}let G=/[0-9]/;if(z&&G.test(z)||z==="-"||z==="."){let Q="";if(z==="-")Q+=z,z=$[++Z];while(z&&G.test(z)||z===".")Q+=z,z=$[++Z];X.push({type:"number",value:Q});continue}let J=/[a-z]/i;if(z&&J.test(z)){let Q="";while(z&&J.test(z)){if(Z===$.length)break;Q+=z,z=$[++Z]}if(Q=="true"||Q=="false"||Q==="null")X.push({type:"name",value:Q});else{Z++;continue}continue}Z++}return X},w$=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),w$($);break;case"number":let X=Z.value[Z.value.length-1];if(X==="."||X==="-")return $=$.slice(0,$.length-1),w$($);case"string":let z=$[$.length-2];if(z?.type==="delimiter")return $=$.slice(0,$.length-1),w$($);else if(z?.type==="brace"&&z.value==="{")return $=$.slice(0,$.length-1),w$($);break;case"delimiter":return $=$.slice(0,$.length-1),w$($);break}return $},EW=($)=>{let Z=[];if($.map((X)=>{if(X.type==="brace")if(X.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(X.type==="paren")if(X.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((X)=>{if(X==="}")$.push({type:"brace",value:"}"});else if(X==="]")$.push({type:"paren",value:"]"})});return $},bW=($)=>{let Z="";return $.map((X)=>{switch(X.type){case"string":Z+='"'+X.value+'"';break;default:Z+=X.value;break}}),Z},c2=($)=>JSON.parse(bW(EW(w$(CW($)))));var a=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},N=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},q0,f0,K1,i2,B1,L1,a2,T1,O0,D1,n2,s2,P$,r2,o2,t9,RZ,e9,$5,Z5,X5,AZ,jZ="__json_buf";class _1{constructor(){q0.add(this),this.messages=[],this.receivedMessages=[],f0.set(this,void 0),this.controller=new AbortController,K1.set(this,void 0),i2.set(this,()=>{}),B1.set(this,()=>{}),L1.set(this,void 0),a2.set(this,()=>{}),T1.set(this,()=>{}),O0.set(this,{}),D1.set(this,!1),n2.set(this,!1),s2.set(this,!1),P$.set(this,!1),r2.set(this,void 0),o2.set(this,void 0),e9.set(this,($)=>{if(a(this,n2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new i;if($ instanceof i)return a(this,s2,!0,"f"),this._emit("abort",$);if($ instanceof A)return this._emit("error",$);if($ instanceof Error){let Z=new A($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new A(String($)))}),a(this,K1,new Promise(($,Z)=>{a(this,i2,$,"f"),a(this,B1,Z,"f")}),"f"),a(this,L1,new Promise(($,Z)=>{a(this,a2,$,"f"),a(this,T1,Z,"f")}),"f"),N(this,K1,"f").catch(()=>{}),N(this,L1,"f").catch(()=>{})}get response(){return N(this,r2,"f")}get request_id(){return N(this,o2,"f")}async withResponse(){let $=await N(this,K1,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new _1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new _1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},N(this,e9,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}N(this,q0,"m",$5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)N(this,q0,"m",Z5).call(this,J);if(G.controller.signal?.aborted)throw new i;N(this,q0,"m",X5).call(this)}_connected($){if(this.ended)return;a(this,r2,$,"f"),a(this,o2,$?.headers.get("request-id"),"f"),N(this,i2,"f").call(this,$),this._emit("connect")}get ended(){return N(this,D1,"f")}get errored(){return N(this,n2,"f")}get aborted(){return N(this,s2,"f")}abort(){this.controller.abort()}on($,Z){return(N(this,O0,"f")[$]||(N(this,O0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=N(this,O0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(N(this,O0,"f")[$]||(N(this,O0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(a(this,P$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){a(this,P$,!0,"f"),await N(this,L1,"f")}get currentMessage(){return N(this,f0,"f")}async finalMessage(){return await this.done(),N(this,q0,"m",t9).call(this)}async finalText(){return await this.done(),N(this,q0,"m",RZ).call(this)}_emit($,...Z){if(N(this,D1,"f"))return;if($==="end")a(this,D1,!0,"f"),N(this,a2,"f").call(this);let X=N(this,O0,"f")[$];if(X)N(this,O0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!N(this,P$,"f")&&!X?.length)Promise.reject(z);N(this,B1,"f").call(this,z),N(this,T1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!N(this,P$,"f")&&!X?.length)Promise.reject(z);N(this,B1,"f").call(this,z),N(this,T1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",N(this,q0,"m",t9).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}N(this,q0,"m",$5).call(this),this._connected(null);let z=e.fromReadableStream($,this.controller);for await(let q of z)N(this,q0,"m",Z5).call(this,q);if(z.controller.signal?.aborted)throw new i;N(this,q0,"m",X5).call(this)}[(f0=new WeakMap,K1=new WeakMap,i2=new WeakMap,B1=new WeakMap,L1=new WeakMap,a2=new WeakMap,T1=new WeakMap,O0=new WeakMap,D1=new WeakMap,n2=new WeakMap,s2=new WeakMap,P$=new WeakMap,r2=new WeakMap,o2=new WeakMap,e9=new WeakMap,q0=new WeakSet,t9=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},RZ=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new A("stream ended without producing a content block with type=text");return Z.join(" ")},$5=function(){if(this.ended)return;a(this,f0,void 0,"f")},Z5=function(Z){if(this.ended)return;let X=N(this,q0,"m",AZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:NZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{a(this,f0,X,"f");break}case"content_block_start":case"message_delta":break}},X5=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let Z=N(this,f0,"f");if(!Z)throw new A("request ended without sending any chunks");return a(this,f0,void 0,"f"),Z},AZ=function(Z){let X=N(this,f0,"f");if(Z.type==="message_start"){if(X)throw new A(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new A(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[jZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,jZ,{value:q,enumerable:!1,writable:!0}),q)z.input=c2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:NZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new e(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function NZ($){}var SZ={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class e0 extends c{constructor(){super(...arguments);this.batches=new O$(this._client)}create($,Z){let{betas:X,...z}=$;if(z.model in SZ)console.warn(`The model '${z.model}' is deprecated and will reach end-of-life on ${SZ[z.model]}
197
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages?beta=true",{body:z,timeout:this._client._options.timeout??(z.stream?600000:this._client._calculateNonstreamingTimeout(z.max_tokens)),...Z,headers:{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0,...Z?.headers},stream:$.stream??!1})}stream($,Z){return _1.createMessage(this,$,Z)}countTokens($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString(),...Z?.headers}})}}e0.Batches=O$;e0.BetaMessageBatchesPage=V1;class w0 extends c{constructor(){super(...arguments);this.models=new F$(this._client),this.messages=new e0(this._client)}}w0.Models=F$;w0.BetaModelInfosPage=W1;w0.Messages=e0;class I$ extends c{create($,Z){return this._client.post("/v1/complete",{body:$,timeout:this._client._options.timeout??600000,...Z,stream:$.stream??!1})}}class R$ extends c{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(`/v1/messages/batches/${$}`,Z)}list($={},Z){if(z0($))return this.list({},$);return this._client.getAPIList("/v1/messages/batches",F1,{query:$,...Z})}delete($,Z){return this._client.delete(`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let X=await this.retrieve($);if(!X.results_url)throw new A(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);return this._client.get(X.results_url,{...Z,headers:{Accept:"application/binary",...Z?.headers},__binaryResponse:!0})._thenUnwrap((z,q)=>M$.fromResponse(q.response,q.controller))}}class F1 extends M0{}R$.MessageBatchesPage=F1;var n=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},S=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},G0,h0,M1,t2,O1,w1,e2,P1,P0,I1,$4,Z4,A$,X4,z4,z5,CZ,q5,G5,J5,Q5,EZ,bZ="__json_buf";class R1{constructor(){G0.add(this),this.messages=[],this.receivedMessages=[],h0.set(this,void 0),this.controller=new AbortController,M1.set(this,void 0),t2.set(this,()=>{}),O1.set(this,()=>{}),w1.set(this,void 0),e2.set(this,()=>{}),P1.set(this,()=>{}),P0.set(this,{}),I1.set(this,!1),$4.set(this,!1),Z4.set(this,!1),A$.set(this,!1),X4.set(this,void 0),z4.set(this,void 0),q5.set(this,($)=>{if(n(this,$4,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new i;if($ instanceof i)return n(this,Z4,!0,"f"),this._emit("abort",$);if($ instanceof A)return this._emit("error",$);if($ instanceof Error){let Z=new A($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new A(String($)))}),n(this,M1,new Promise(($,Z)=>{n(this,t2,$,"f"),n(this,O1,Z,"f")}),"f"),n(this,w1,new Promise(($,Z)=>{n(this,e2,$,"f"),n(this,P1,Z,"f")}),"f"),S(this,M1,"f").catch(()=>{}),S(this,w1,"f").catch(()=>{})}get response(){return S(this,X4,"f")}get request_id(){return S(this,z4,"f")}async withResponse(){let $=await S(this,M1,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new R1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new R1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},S(this,q5,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}S(this,G0,"m",G5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)S(this,G0,"m",J5).call(this,J);if(G.controller.signal?.aborted)throw new i;S(this,G0,"m",Q5).call(this)}_connected($){if(this.ended)return;n(this,X4,$,"f"),n(this,z4,$?.headers.get("request-id"),"f"),S(this,t2,"f").call(this,$),this._emit("connect")}get ended(){return S(this,I1,"f")}get errored(){return S(this,$4,"f")}get aborted(){return S(this,Z4,"f")}abort(){this.controller.abort()}on($,Z){return(S(this,P0,"f")[$]||(S(this,P0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=S(this,P0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(S(this,P0,"f")[$]||(S(this,P0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(n(this,A$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){n(this,A$,!0,"f"),await S(this,w1,"f")}get currentMessage(){return S(this,h0,"f")}async finalMessage(){return await this.done(),S(this,G0,"m",z5).call(this)}async finalText(){return await this.done(),S(this,G0,"m",CZ).call(this)}_emit($,...Z){if(S(this,I1,"f"))return;if($==="end")n(this,I1,!0,"f"),S(this,e2,"f").call(this);let X=S(this,P0,"f")[$];if(X)S(this,P0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!S(this,A$,"f")&&!X?.length)Promise.reject(z);S(this,O1,"f").call(this,z),S(this,P1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!S(this,A$,"f")&&!X?.length)Promise.reject(z);S(this,O1,"f").call(this,z),S(this,P1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",S(this,G0,"m",z5).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}S(this,G0,"m",G5).call(this),this._connected(null);let z=e.fromReadableStream($,this.controller);for await(let q of z)S(this,G0,"m",J5).call(this,q);if(z.controller.signal?.aborted)throw new i;S(this,G0,"m",Q5).call(this)}[(h0=new WeakMap,M1=new WeakMap,t2=new WeakMap,O1=new WeakMap,w1=new WeakMap,e2=new WeakMap,P1=new WeakMap,P0=new WeakMap,I1=new WeakMap,$4=new WeakMap,Z4=new WeakMap,A$=new WeakMap,X4=new WeakMap,z4=new WeakMap,q5=new WeakMap,G0=new WeakSet,z5=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},CZ=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new A("stream ended without producing a content block with type=text");return Z.join(" ")},G5=function(){if(this.ended)return;n(this,h0,void 0,"f")},J5=function(Z){if(this.ended)return;let X=S(this,G0,"m",EZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:yZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{n(this,h0,X,"f");break}case"content_block_start":case"message_delta":break}},Q5=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let Z=S(this,h0,"f");if(!Z)throw new A("request ended without sending any chunks");return n(this,h0,void 0,"f"),Z},EZ=function(Z){let X=S(this,h0,"f");if(Z.type==="message_start"){if(X)throw new A(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new A(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[bZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,bZ,{value:q,enumerable:!1,writable:!0}),q)z.input=c2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:yZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new e(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function yZ($){}class g0 extends c{constructor(){super(...arguments);this.batches=new R$(this._client)}create($,Z){if($.model in xZ)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${xZ[$.model]}
198
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages",{body:$,timeout:this._client._options.timeout??($.stream?600000:this._client._calculateNonstreamingTimeout($.max_tokens)),...Z,stream:$.stream??!1})}stream($,Z){return R1.createMessage(this,$,Z)}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}}var xZ={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};g0.Batches=R$;g0.MessageBatchesPage=F1;class $$ extends c{retrieve($,Z){return this._client.get(`/v1/models/${$}`,Z)}list($={},Z){if(z0($))return this.list({},$);return this._client.getAPIList("/v1/models",j$,{query:$,...Z})}}class j$ extends M0{}$$.ModelInfosPage=j$;var kZ;class x extends r9{constructor({baseURL:$=l2("ANTHROPIC_BASE_URL"),apiKey:Z=l2("ANTHROPIC_API_KEY")??null,authToken:X=l2("ANTHROPIC_AUTH_TOKEN")??null,...z}={}){let q={apiKey:Z,authToken:X,...z,baseURL:$||"https://api.anthropic.com"};if(!q.dangerouslyAllowBrowser&&IZ())throw new A(`It looks like you're running in a browser-like environment.
166
+ `,Z)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let Z=y6($),X=I1(Z);return X.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=y6($),X=I1(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((X)=>X.type==="newline"||X.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}iq.Parser=PY});var SY=R((ZT)=>{var DY=L9(),nq=n2(),$4=r2(),rq=AX(),sq=m(),oq=A9(),EY=S9();function RY($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new oq.LineCounter||null,prettyErrors:Z}}function tq($,Z={}){let{lineCounter:X,prettyErrors:Y}=RY(Z),G=new EY.Parser(X?.addNewLine),z=new DY.Composer(Z),J=Array.from(z.compose(G.parse($)));if(Y&&X)for(let Q of J)Q.errors.forEach($4.prettifyError($,X)),Q.warnings.forEach($4.prettifyError($,X));if(J.length>0)return J;return Object.assign([],{empty:!0},z.streamInfo())}function AY($,Z={}){let{lineCounter:X,prettyErrors:Y}=RY(Z),G=new EY.Parser(X?.addNewLine),z=new DY.Composer(Z),J=null;for(let Q of z.compose(G.parse($),!0,$.length))if(!J)J=Q;else if(J.options.logLevel!=="silent"){J.errors.push(new $4.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Y&&X)J.errors.forEach($4.prettifyError($,X)),J.warnings.forEach($4.prettifyError($,X));return J}function eq($,Z,X){let Y=void 0;if(typeof Z==="function")Y=Z;else if(X===void 0&&Z&&typeof Z==="object")X=Z;let G=AY($,X);if(!G)return null;if(G.warnings.forEach((z)=>rq.warn(G.options.logLevel,z)),G.errors.length>0)if(G.options.logLevel!=="silent")throw G.errors[0];else G.errors=[];return G.toJS(Object.assign({reviver:Y},X))}function $T($,Z,X){let Y=null;if(typeof Z==="function"||Array.isArray(Z))Y=Z;else if(X===void 0&&Z)X=Z;if(typeof X==="string")X=X.length;if(typeof X==="number"){let G=Math.round(X);X=G<1?void 0:G>8?{indent:8}:{indent:G}}if($===void 0){let{keepUndefined:G}=X??Z??{};if(!G)return}if(sq.isDocument($)&&!Y)return $.toString(X);return new nq.Document($,Y,X).toString(X)}ZT.parse=eq;ZT.parseAllDocuments=tq;ZT.parseDocument=AY;ZT.stringify=$T});var IY=R((wT)=>{var JT=L9(),QT=n2(),WT=Z9(),C9=r2(),VT=k2(),M$=m(),HT=q$(),KT=o(),BT=F$(),UT=L$(),qT=b6(),TT=R9(),FT=A9(),LT=S9(),g6=SY(),CY=j2();wT.Composer=JT.Composer;wT.Document=QT.Document;wT.Schema=WT.Schema;wT.YAMLError=C9.YAMLError;wT.YAMLParseError=C9.YAMLParseError;wT.YAMLWarning=C9.YAMLWarning;wT.Alias=VT.Alias;wT.isAlias=M$.isAlias;wT.isCollection=M$.isCollection;wT.isDocument=M$.isDocument;wT.isMap=M$.isMap;wT.isNode=M$.isNode;wT.isPair=M$.isPair;wT.isScalar=M$.isScalar;wT.isSeq=M$.isSeq;wT.Pair=HT.Pair;wT.Scalar=KT.Scalar;wT.YAMLMap=BT.YAMLMap;wT.YAMLSeq=UT.YAMLSeq;wT.CST=qT;wT.Lexer=TT.Lexer;wT.LineCounter=FT.LineCounter;wT.Parser=LT.Parser;wT.parse=g6.parse;wT.parseAllDocuments=g6.parseAllDocuments;wT.parseDocument=g6.parseDocument;wT.stringify=g6.stringify;wT.visit=CY.visit;wT.visitAsync=CY.visitAsync});var N3=Y3(M3(),1),{program:M1,createCommand:CN,createArgument:IN,createOption:jN,CommanderError:xN,InvalidArgumentError:kN,InvalidOptionArgumentError:bN,Command:fN,Argument:yN,Option:FX,Help:gN}=N3.default;var O3={name:"@pickled-dev/cli",version:"0.21.0",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","@semantic-release/release-notes-generator":"^14.0.3"}};import UN from"path";var h0={category:"cli",provider:"claude-code",model:"sonnet"},LX=["Read","Glob","Grep","Bash"],wX=["Edit","MultiEdit","Write","NotebookEdit"];var jY=Y3(IY(),1);async function j1($){let Z=`${$}/pickled.yml`,X=Bun.file(Z);if(!await X.exists())throw Error(`pickled.yml not found in ${$}`);let Y;try{let G=await X.text();Y=jY.default.parse(G)}catch(G){throw Error(`Failed to parse pickled.yml: ${G}`)}return Y=I9(Y),rT(Y),Y}var nT=/\$\{([A-Z_][A-Z0-9_]*)\}/g;function I9($){if(typeof $==="string")return $.replace(nT,(Z,X)=>process.env[X]??"");if(Array.isArray($))return $.map(I9);if($!==null&&typeof $==="object"){let Z={};for(let[X,Y]of Object.entries($))Z[X]=I9(Y);return Z}return $}function rT($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[X,Y]of Object.entries($.docs.sources)){if(X==="none")throw Error('pickled.yml: docs.sources cannot use the reserved id "none". That name represents the no-context matrix cell (model prior with toolset:none, or open discovery with toolset:web). Rename this source.');XF(X,Y)}if($.toolsets){if(typeof $.toolsets!=="object"||Array.isArray($.toolsets))throw Error("pickled.yml: 'toolsets' must be an object mapping name to configuration");for(let[X,Y]of Object.entries($.toolsets))if(typeof Y!=="object"||Y===null||Array.isArray(Y))throw Error(`pickled.yml: toolsets["${X}"] must be an object`)}if($.targets)for(let[X,Y]of Object.entries($.targets)){if(Y.systemPrompt!==void 0)throw Error(`pickled.yml: target "${X}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(Y.provider==="codex-cli"){if(!Y.model)throw Error(`pickled.yml: target "${X}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(Y.maxTurns!==void 0)throw Error(`pickled.yml: target "${X}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}if(Y.category==="api"){if(!Y.model)throw Error(`pickled.yml: target "${X}" (api/${Y.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let G=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let z of G)if(Y[z]!==void 0)throw Error(`pickled.yml: target "${X}" (api/${Y.provider}) sets '${z}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(Y.workspaceContext!==void 0)throw Error(`pickled.yml: target "${X}" (api/${Y.provider}) sets 'workspaceContext', which only applies to IDE targets. Remove the field.`)}}let Z=new Set(Object.keys($.docs?.sources??{}));for(let X of $.scenarios){if(!X.name||!X.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(X.requiredSources!==void 0){if(!Array.isArray(X.requiredSources))throw Error(`pickled.yml: scenario "${X.name}" has non-array 'requiredSources'. Omit the field to skip citation scoring, or set [] for "any cited source counts".`);for(let Y of X.requiredSources)if(!Z.has(Y))throw Error(`pickled.yml: scenario "${X.name}" references unknown source "${Y}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}zF(X.name,X.traps),ZF(X.name,X.compareSurfaces,Z),oT(X.name,X.matrix,Z,new Set(Object.keys($.targets??{})),new Set(Object.keys($.toolsets??{none:{}}))),tT(X.name,X.expected),eT(X.name,X.verifiers,Z),$F(X)}sT($)}function sT($){if(!$.docs?.sources)return;let Z=[];for(let[Y,G]of Object.entries($.docs.sources)){if(typeof G==="string")continue;let z=G.audit?.traps;if(Array.isArray(z))Z.push({id:Y,list:z})}if(Z.length===0)return;let X=new Map;for(let Y of $.scenarios)for(let G of Y.traps??[]){let z=X.get(G.id);if(z!==void 0)throw Error(`pickled.yml: trap id "${G.id}" is declared in both scenario "${z}" and scenario "${Y.name}". Globally unique trap ids are required when any source uses list-form audit.traps suppression. Rename one of the traps.`);X.set(G.id,Y.name)}for(let{id:Y,list:G}of Z)for(let z of G)if(!X.has(z)){let J=[...X.keys()].join(", ")||"(none)";throw Error(`pickled.yml: docs.sources["${Y}"].audit.traps lists unknown trap id "${z}". Declared trap ids: ${J}`)}}function oT($,Z,X,Y,G){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" matrix must be an object with optional interfaces/sources/toolsets arrays`);let z=(J,Q,W)=>{let V=Z[J];if(V===void 0)return;if(!Array.isArray(V))throw Error(`pickled.yml: scenario "${$}" matrix.${J} must be an array of ${W} names`);if(V.length===0)throw Error(`pickled.yml: scenario "${$}" matrix.${J} cannot be empty (omit the field to use defaults)`);for(let K of V){if(typeof K!=="string")throw Error(`pickled.yml: scenario "${$}" matrix.${J} entries must be strings`);if(!Q.has(K))throw Error(`pickled.yml: scenario "${$}" matrix.${J} references unknown ${W} "${K}". Declared: ${[...Q].join(", ")||"(none)"}`)}};z("interfaces",Y,"target"),z("sources",new Set([...X,"none"]),"source"),z("toolsets",G,"toolset")}function tT($,Z){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" expected must be an object with optional includes/excludes arrays`);let X=(Y)=>{let G=Z[Y];if(G===void 0)return;if(!Array.isArray(G))throw Error(`pickled.yml: scenario "${$}" expected.${Y} must be an array of strings`);if(G.length===0)throw Error(`pickled.yml: scenario "${$}" expected.${Y} cannot be empty (omit the field instead)`);for(let z=0;z<G.length;z++)if(typeof G[z]!=="string"||G[z].length===0)throw Error(`pickled.yml: scenario "${$}" expected.${Y}[${z}] must be a non-empty string`)};X("includes"),X("excludes")}function eT($,Z,X){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" verifiers must be an object`);let Y=Z.sources;if(Y===void 0)return;if(!Array.isArray(Y))throw Error(`pickled.yml: scenario "${$}" verifiers.sources must be an array of source IDs`);for(let G of Y){if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" verifiers.sources entries must be strings`);if(!X.has(G))throw Error(`pickled.yml: scenario "${$}" verifiers.sources references unknown source "${G}"`)}}function $F($){let Z=$.requiredSources!==void 0,X=$.expected!==void 0&&($.expected.includes!==void 0&&$.expected.includes.length>0||$.expected.excludes!==void 0&&$.expected.excludes.length>0),Y=$.traps!==void 0&&$.traps.length>0;if(!Z&&!X&&!Y)throw Error(`pickled.yml: scenario "${$.name}" must declare at least one of requiredSources, expected.includes/excludes, or traps. A scenario with nothing to check has no verdict.`);let G=($.matrix?.toolsets??[]).filter((z)=>z!=="none");if(G.length>0&&!X&&!Y)throw Error(`pickled.yml: scenario "${$.name}" declares non-none toolsets [${G.join(", ")}] but has neither expected.includes/excludes nor traps. Non-none cells skip the citation contract because the source is not injected, so requiredSources alone leaves them with no actionable answer contract. Add expected or traps, or restrict matrix.toolsets to ["none"].`)}function ZF($,Z,X){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(Z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let Y=0;Y<Z.length;Y++){let G=Z[Y];if(!Array.isArray(G))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${Y}] must be an array of source ids`);if(G.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${Y}] must be a non-empty list of source ids`);for(let z of G){if(typeof z!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${Y}] entries must be string source ids`);if(!X.has(z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${Y}] references unknown source "${z}". Declared sources: ${[...X].join(", ")||"(none)"}`)}}}function XF($,Z){if(typeof Z==="string"){if(Z.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!Z||typeof Z!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let X=Z;if(typeof X.path!=="string"||X.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(X.audit!==void 0){if(typeof X.audit!=="object"||X.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let Y=X.audit;if(Y.traps!==void 0){let G=Y.traps;if(typeof G==="boolean");else if(Array.isArray(G)){if(G.length===0)throw Error(`pickled.yml: docs.sources["${$}"].audit.traps cannot be an empty array; use true (scan all) or false (skip all) instead`);for(let z=0;z<G.length;z++)if(typeof G[z]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps[${z}] must be a string trap id`)}else throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean or an array of trap ids`)}for(let G of Object.keys(Y))if(G!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${G}"`)}if(X.type!==void 0){if(X.type!=="file"&&X.type!=="url"&&X.type!=="codebase")throw Error(`pickled.yml: docs.sources["${$}"].type must be "file", "url", or "codebase"`)}if(X.type==="codebase"){if(typeof X.path==="string"&&X.path.split("/").includes(".."))throw Error(`pickled.yml: docs.sources["${$}"].path must not contain ".." segments. Codebase loader stays within the project root.`);if(X.exclude!==void 0){if(!Array.isArray(X.exclude))throw Error(`pickled.yml: docs.sources["${$}"].exclude must be an array of glob patterns`);for(let Y=0;Y<X.exclude.length;Y++)if(typeof X.exclude[Y]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].exclude[${Y}] must be a string glob pattern`)}if(X.maxBytes!==void 0){if(typeof X.maxBytes!=="number"||!Number.isFinite(X.maxBytes)||X.maxBytes<=0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes must be a positive number of bytes`)}}else{if(X.exclude!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].exclude only applies to type: codebase sources`);if(X.maxBytes!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes only applies to type: codebase sources`)}for(let Y of Object.keys(X))if(Y!=="path"&&Y!=="audit"&&Y!=="type"&&Y!=="exclude"&&Y!=="maxBytes")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${Y}"`)}var YF=new Set(["g","y"]),GF=new Set(["i","m","s","u","v"]);function zF($,Z){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let X=new Set;for(let Y of Z){if(!Y.id||typeof Y.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(X.has(Y.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${Y.id}"`);if(X.add(Y.id),!Y.reason||typeof Y.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" requires non-empty 'reason'`);if(Y.auditSeverity!==void 0&&Y.auditSeverity!=="warning"&&Y.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" auditSeverity must be "warning" or "error"`);let G=typeof Y.match==="string",z=typeof Y.pattern==="string";if(G===z)throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" must set exactly one of 'match' or 'pattern'`);if(G){if(Y.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" has empty 'match'`);if(Y.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" sets 'flags' without 'pattern'`)}else{let J=Y.pattern;if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" must set 'pattern'`);if(J==="")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" has empty 'pattern'`);if(Y.flags!==void 0){if(typeof Y.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" has non-string 'flags'`);for(let Q of Y.flags){if(YF.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!GF.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(J,Y.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${Y.id}" has invalid regex pattern: ${Q instanceof Error?Q.message:Q}`)}}}}function j9($,Z){let X=new Set([...Object.keys($.targets??{}),"default"]);if(!X.has(Z)){let Y=[...X].sort().join(", ");throw Error(`Unknown target: "${Z}". Available targets: ${Y}`)}return{...$,matrix:{...$.matrix,target:[Z]},scenarios:$.scenarios.filter((Y)=>!Y.target||Y.target===Z)}}function x9($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function v6($){let{config:Z,files:X,pairs:Y,findings:G}=$,z=[],J=G.filter((H)=>H.severity==="error").length,Q=G.filter((H)=>H.severity==="warning").length;if(z.push(`# Agent-context audit
167
+ `),z.push(`Target: \`${Z.targetRepo}\``),z.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),z.push(`Found ${X.length} agent-doc files. ${J} error(s), ${Q} warning(s).
168
+ `),z.push(`## Inventory
169
+ `),X.length===0)z.push(`No agent-doc files found.
170
+ `);else{z.push("| File | Lines | Kind | Notes |"),z.push("|---|---|---|---|");let H=[...X].sort((B,U)=>U.lineCount-B.lineCount);for(let B of H){let U=!B.relPath.includes("/"),F=xY(B.lineCount,U,Z),T=B.isSymlink?`symlink \u2192 ${B.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file";z.push(`| \`${B.relPath}\` | ${B.lineCount} | ${T} | ${F} |`)}z.push("")}if(z.push(`## AGENTS.md / CLAUDE.md pairs
171
+ `),Y.length===0)z.push(`No pairs found.
172
+ `);else{z.push("| Directory | A | C | Class | Detail |"),z.push("|---|---|---|---|---|");for(let H of Y)z.push(`| \`${H.dir||"(root)"}\` | ${H.agentsExists?"\u2713":"\xB7"} | ${H.claudeExists?"\u2713":"\xB7"} | ${H.classification} | ${H.detail} |`);z.push("")}let W=X.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(z.push(`## Broken references
173
+ `),W.length===0)z.push(`None detected.
174
+ `);else for(let H of W){if(z.push(`### \`${H.relPath}\`
175
+ `),H.brokenPathRefs.length>0){z.push("Broken path references:");for(let B of H.brokenPathRefs)z.push(` - \`${B}\``);z.push("")}if(H.brokenImports.length>0){z.push("Broken `@`-imports:");for(let B of H.brokenImports)z.push(` - \`${B}\``);z.push("")}}let V=X.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(z.push(`## Unresolved package-manager commands (advisory)
176
+ `),z.push("Looks like a script command in markdown that did not match anything in the target `package.json` `scripts` or the `knownCommands` allowlist. Workspace-filtered commands check against root scripts, so false positives are expected. Review, do not fail CI on this.\n"),V.length===0)z.push(`None flagged.
177
+ `);else for(let H of V){z.push(`### \`${H.relPath}\`
178
+ `);for(let B of H.unresolvedCommands)z.push(` - \`${B}\``);z.push("")}let K=X.filter((H)=>{if(H.isSymlink)return!1;return!H.relPath.includes("/")?H.lineCount>Z.budgets.rootLines:H.lineCount>Z.budgets.nestedWarnLines});if(z.push(`## Section breakdown for files over budget
179
+ `),K.length===0)z.push(`All files within budget.
180
+ `);else for(let H of K){z.push(`### \`${H.relPath}\` (${H.lineCount} lines)
181
+ `),z.push(`Largest H2 sections (lines including any subsections):
182
+ `),z.push("| Section | Lines |"),z.push("|---|---|");for(let B of H.sections.slice(0,10))z.push(`| ${B.header} | ${B.lines} |`);z.push("")}if(z.push(`## Registered-source trap matches
183
+ `),z.push("Catches stale claims in `docs.sources` against declared traps. Per-source suppression: `audit.traps: false` skips all traps; `audit.traps: [<trap_id>, ...]` skips only the listed traps and keeps scanning the rest.\n"),$.sourceTrapMatches.length===0)z.push(`None.
184
+ `);else{for(let H of $.sourceTrapMatches)z.push(`- **${H.sourceId}** (\`${H.sourcePath}:L${H.line}\`) \u2014 trap \`${H.trapId}\` matched \`${H.matched}\` (${H.severity})`),z.push(` - reason: ${H.trapReason}`),z.push(` - fix: remove the stale claim, retire the trap, set \`audit.traps: ['${H.trapId}']\` to suppress just this one (other traps still apply), or set \`audit.traps: false\` if the source is deliberately stale`);z.push("")}return z.join(`
185
+ `)}function h6($){return JSON.stringify($,null,2)}function u6($){let{config:Z,files:X,pairs:Y,findings:G}=$,z=[],J=G.filter((H)=>H.severity==="error").length,Q=G.filter((H)=>H.severity==="warning").length;if(z.push("pickled audit"),z.push(`Target: ${Z.targetRepo}`),z.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),z.push(`Found: ${X.length} agent-doc file(s) \xB7 ${J} error(s) \xB7 ${Q} warning(s)`),z.push(""),z.push("Inventory"),X.length===0)z.push(" none");else{let H=[...X].sort((U,F)=>F.lineCount-U.lineCount),B=Math.max(...H.map((U)=>U.relPath.length));for(let U of H){let F=!U.relPath.includes("/"),T=xY(U.lineCount,F,Z),w=U.isSymlink?`symlink \u2192 ${U.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file",O=`${U.lineCount}`.padStart(4),N=U.relPath.padEnd(B),P=T?` (${T})`:"";z.push(` ${N} ${O} lines ${w}${P}`)}}if(z.push(""),z.push("AGENTS.md / CLAUDE.md pairs"),Y.length===0)z.push(" none");else for(let H of Y){let B=H.dir||"(root)";z.push(` ${B}: ${H.classification} \xB7 ${H.detail}`)}z.push("");let W=X.filter((H)=>!H.isSymlink&&H.brokenPathRefs.length+H.brokenImports.length>0);if(z.push("Broken references"),W.length===0)z.push(" none");else for(let H of W){z.push(` ${H.relPath}:`);for(let B of H.brokenPathRefs)z.push(` path: ${B}`);for(let B of H.brokenImports)z.push(` @-import: ${B}`)}z.push("");let V=X.filter((H)=>!H.isSymlink&&H.unresolvedCommands.length>0);if(z.push("Unresolved package-manager commands (advisory)"),V.length===0)z.push(" none");else for(let H of V){z.push(` ${H.relPath}:`);for(let B of H.unresolvedCommands)z.push(` ${B}`)}z.push("");let K=X.filter((H)=>{if(H.isSymlink)return!1;return!H.relPath.includes("/")?H.lineCount>Z.budgets.rootLines:H.lineCount>Z.budgets.nestedWarnLines});if(z.push("Section breakdown for files over budget"),K.length===0)z.push(" all files within budget");else for(let H of K){z.push(` ${H.relPath} (${H.lineCount} lines):`);for(let B of H.sections.slice(0,10))z.push(` ${B.header.padEnd(40)} ${B.lines} lines`)}if(z.push(""),z.push("Registered-source trap matches"),$.sourceTrapMatches.length===0)z.push(" none");else for(let H of $.sourceTrapMatches){let B=H.severity==="error"?"error":"warning";z.push(` [${B}] ${H.sourceId} (${H.sourcePath}:L${H.line}): trap ${H.trapId} matched "${H.matched}"`),z.push(` reason: ${H.trapReason}`),z.push(` fix: remove the stale claim, retire the trap, set audit.traps: ['${H.trapId}'] to suppress just this trap (others still apply), or set audit.traps: false if deliberately stale`)}return z.join(`
186
+ `)}function xY($,Z,X){if(Z&&$>X.budgets.rootLines)return`over root budget (${$} > ${X.budgets.rootLines})`;if(!Z&&$>X.budgets.nestedWarnLines)return`over nested-warn (${$} > ${X.budgets.nestedWarnLines})`;return""}import{existsSync as k1,lstatSync as vY,readFileSync as l6,readlinkSync as wF,statSync as MF}from"fs";import{dirname as p6,isAbsolute as NF,join as k9,relative as OF,resolve as b9}from"path";var{Glob:gY}=globalThis.Bun;var m6=["node_modules/**","**/node_modules/**",".git/**","**/.git/**","dist/**","**/dist/**","build/**","**/build/**",".next/**","**/.next/**",".source/**","**/.source/**","out/**","**/out/**",".turbo/**","**/.turbo/**",".cache/**","**/.cache/**",".runs/**","**/.runs/**","coverage/**","**/coverage/**","**/__fixtures__/**","**/tests/**/fixture/**","**/tests/**/fixtures/**","**/test/**/fixture/**","**/test/**/fixtures/**"],x1={targetRepo:".",budgets:{rootLines:120,nestedWarnLines:200},ignore:m6,intentionalDifferentPairs:[],knownCommands:[]};function d6($){if(!$)return x1;return{targetRepo:$.targetRepo??x1.targetRepo,budgets:{rootLines:$.budgets?.rootLines??x1.budgets.rootLines,nestedWarnLines:$.budgets?.nestedWarnLines??x1.budgets.nestedWarnLines},ignore:$.ignore??m6,intentionalDifferentPairs:$.intentionalDifferentPairs??[],knownCommands:$.knownCommands??[]}}import{existsSync as UF}from"fs";import{join as qF,resolve as TF}from"path";function N$($){let Z=[],X=[];for(let Y of $.traps){let G=JF($.response,Y);if(G)Z.push(G);else X.push(Y.id)}return{fired:Z,avoided:X}}function JF($,Z){if(Z.match!==void 0){let X=$.indexOf(Z.match);if(X===-1)return null;return{id:Z.id,reason:Z.reason,matched:Z.match,snippet:kY($,X,Z.match.length),index:X}}if(Z.pattern!==void 0){let Y=new RegExp(Z.pattern,Z.flags??"").exec($);if(!Y)return null;return{id:Z.id,reason:Z.reason,matched:Y[0],snippet:kY($,Y.index,Y[0].length),index:Y.index}}return null}function kY($,Z,X){let Y=Math.max(0,Z-40),G=Math.min($.length,Z+X+40),z=$.slice(Y,G).replace(/\s+/g," ").trim();if(Y>0)z=`...${z}`;if(G<$.length)z=`${z}...`;return z}import c6 from"path";var{Glob:bY}=globalThis.Bun;var QF=262144,WF=4194304;function VF($){return $.startsWith("http://")||$.startsWith("https://")}async function HF($,Z,X){let Y=await fetch(Z);if(!Y.ok)throw Error(`Failed to fetch source "${$}" from ${Z}: ${Y.status} ${Y.statusText}`);let G=await Y.text();return{id:$,source:Z,content:G,name:new URL(Z).hostname+new URL(Z).pathname,type:"url",auditTraps:X}}async function KF($,Z,X,Y){let G=c6.isAbsolute(Z)?Z:c6.resolve(X,Z),z=Bun.file(G);if(!await z.exists())throw Error(`Source "${$}" not found at ${G}`);let J=await z.text();return{id:$,source:Z,content:J,name:c6.basename(G),type:"file",auditTraps:Y}}async function BF($,Z,X,Y,G){let z=new bY(Z.path),J=(Z.exclude??[]).map((U)=>new bY(U)),Q=[];for await(let U of z.scan({cwd:X,onlyFiles:!0,followSymlinks:!1})){if(J.some((F)=>F.match(U)))continue;Q.push(U)}Q.sort();let W=Z.maxBytes??QF,V=Math.max(W,WF),K=[],H=0;for(let U of Q){let F=c6.resolve(X,U),T=await Bun.file(F).text(),w=`// === ${U} ===
187
+ `;if(K.push(w,T),!T.endsWith(`
188
+ `))K.push(`
189
+ `);if(H+=w.length+T.length,H>V)throw Error(`Codebase source "${$}" exceeded hard cap of ${V} bytes (matched glob ${Z.path}). Tighten the glob or raise the limit via maxBytes (and accept the request-size risk).`)}if(H>W)G?.(` warn: codebase source [${$}] is ${H} bytes (soft cap ${W}); consider tightening the glob`);let B=K.join("");return{id:$,source:Z.path,content:B,name:`${Q.length} file${Q.length===1?"":"s"} in ${Z.path}`,type:"codebase",auditTraps:Y,matchedFiles:Q}}async function fY($,Z,X,Y){let{path:G,auditTraps:z}=x9(Z);if(typeof Z!=="string"&&Z.type==="codebase")return BF($,Z,X,z,Y);if(VF(G))return HF($,G,z);return KF($,G,X,z)}async function Z4($,Z,X){let Y=Object.entries($);return await Promise.all(Y.map(([z,J])=>fY(z,J,Z,X)))}async function yY($){if(!UF(qF($,"pickled.yml")))return{matches:[],findings:[]};let Z=await j1($),X=Z.docs?.sources;if(!X||Object.keys(X).length===0)return{matches:[],findings:[]};let Y={};for(let[V,K]of Object.entries(X)){let H=typeof K==="string"?K:K.path;if(H.startsWith("http://")||H.startsWith("https://"))continue;Y[V]=K}if(Object.keys(Y).length===0)return{matches:[],findings:[]};let G=[],z=new Map;for(let V of Z.scenarios)for(let K of V.traps??[])G.push(K),z.set(K,K.auditSeverity??"warning");if(G.length===0)return{matches:[],findings:[]};let J=await Z4(Y,$),Q=[],W=[];for(let V of J){let K=V.auditTraps;if(K===!1)continue;let H=Array.isArray(K)?new Set(K):null,B=V.type==="codebase"&&V.matchedFiles?await FF(V.matchedFiles,$,V.source):[{path:V.source,content:V.content}];for(let U of B)for(let F of G){if(H?.has(F.id))continue;let{fired:T}=N$({response:U.content,traps:[F]}),w=T[0];if(!w)continue;let O=LF(U.content,w.index),N=z.get(F)??"warning";Q.push({sourceId:V.id,sourcePath:U.path,trapId:w.id,trapReason:w.reason,matched:w.matched,snippet:w.snippet,line:O,severity:N}),W.push({severity:N,category:"trap-source-match",file:U.path,message:`source [${V.id}] matches trap '${w.id}' ("${w.matched}") in ${U.path}. ${w.reason} Fix: remove the stale claim from the source, retire the trap if no longer relevant, set audit.traps: ['${w.id}'] on the source to suppress just this trap (other traps still apply), or set audit.traps: false if the source is deliberately stale or test-only.`})}}return{matches:Q,findings:W}}async function FF($,Z,X){let Y=[];for(let G of $)try{let z=await Bun.file(TF(Z,G)).text();Y.push({path:G,content:z})}catch{}return Y}function LF($,Z){let X=1,Y=Math.min(Z,$.length);for(let G=0;G<Y;G++)if($[G]===`
190
+ `)X++;return X}var _F=["AGENTS.md","CLAUDE.md","CLAUDE.local.md","llms.txt","llms-full.txt",".claude/CLAUDE.md",".claude/rules/*.md","**/AGENTS.md","**/CLAUDE.md","**/CLAUDE.local.md","**/llms.txt","**/llms-full.txt","**/.claude/CLAUDE.md","**/.claude/rules/*.md"];async function i6($){let Z=d6($),X=b9(Z.targetRepo);if(!k1(X))throw Error(`targetRepo does not exist: ${X}`);let Y=new Set;for(let V of _F){let K=new gY(V);for await(let H of K.scan({cwd:X,dot:!0,onlyFiles:!1,followSymlinks:!1})){if(Z.ignore.some((F)=>new gY(F).match(H)))continue;let B=k9(X,H),U=vY(B);if(U.isFile()){Y.add(H);continue}if(U.isSymbolicLink())try{if(MF(B).isFile())Y.add(H)}catch{}}}let G=[];for(let V of[...Y].sort())G.push(await PF(X,V,k9(X,V),Z));let z=fF(G,Z),J=yF(G,z,Z),{matches:Q,findings:W}=await yY(X);return{config:Z,files:G,pairs:z,findings:[...J,...W],sourceTrapMatches:Q}}async function PF($,Z,X,Y){let z=vY(X).isSymbolicLink(),J=null,Q=Z;if(z){let B=wF(X),U=NF(B)?B:b9(p6(X),B);if(J=U,k1(U))Q=OF($,U)}let W=z&&J&&k1(J)?J:X,V=l6(W,"utf8"),K=(V.match(/\n/g)??[]).length,H=V.endsWith(`
191
+ `)?K:K+1;return{relPath:Z,absPath:X,isSymlink:z,symlinkTarget:J,realRelPath:Q,lineCount:H,brokenPathRefs:EF(V,$,Z),brokenImports:AF(V,p6(X)),unresolvedCommands:jF(V,$,Y.knownCommands),sections:xF(V)}}function DF($){let Z=$.split("/");if(Z.length<2)return null;if(Z[0]==="packages"||Z[0]==="apps"||Z[0]==="shared")return`${Z[0]}/${Z[1]}`;if(Z[0]==="tests")return Z.slice(0,2).join("/");return null}function EF($,Z,X){let Y=bF($),G=p6(X),z=DF(X),J=new Set,Q=/`([^`\n]{2,200})`/g,W;W=Q.exec(Y);while(W!==null){let V=W[1].trim().replace(/[#?].*$/,"");if(kF(V)&&!RF(Z,V,G,z).found)J.add(V);W=Q.exec(Y)}return[...J].sort()}function RF($,Z,X,Y){let G=[Z];if(X&&X!==".")G.push(`${X}/${Z}`);if(Y)G.push(`${Y}/${Z}`);G.push(`packages/${Z}`,`apps/${Z}`,`shared/${Z}`);for(let z of G){let J=z.replace(/\/+/g,"/");if(k1(`${$}/${J}`))return{found:!0,resolvedAs:J}}return{found:!1}}function AF($,Z){let X=new Set,Y=/@([\w./@~-]+\.md)/g,G;G=Y.exec($);while(G!==null){let z=G[1];if(z.startsWith("~/")){G=Y.exec($);continue}let J=z.startsWith("/")?z:b9(Z,z);if(!k1(J))X.add(z);G=Y.exec($)}return[...X].sort()}var SF=["bun","pnpm","npm","yarn"],CF=new Set(["install","add","remove","update","i","audit","list","ls","why","outdated","exec","run","create","init","x"]),IF={bun:new Set(["build","test","link","unlink","upgrade"])};function jF($,Z,X){let Y=new Set,G=k9(Z,"package.json"),z=new Set;if(k1(G))try{let Q=JSON.parse(l6(G,"utf8"));z=new Set(Object.keys(Q.scripts??{}))}catch{}let J=new Set(X.map((Q)=>Q.trim()));for(let Q of SF){let W=new RegExp(`\\b${Q}\\s+(?:run\\s+|--filter\\s+\\S+\\s+(?:run\\s+)?)?([a-zA-Z][\\w:.\\-]*)`,"g"),V;V=W.exec($);while(V!==null){let K=V[1];if(!z.has(K)&&!J.has(`${Q} ${K}`)&&!J.has(`${Q} run ${K}`)&&!CF.has(K)&&!IF[Q]?.has(K))Y.add(`${Q} ${K}`);V=W.exec($)}}return[...Y].sort()}function xF($){let Z=$.split(`
192
+ `),X=[],Y=null;if(Z.forEach((G,z)=>{if(/^##\s+/.test(G)){if(Y)X.push({header:Y.header,lines:z-Y.start});Y={header:G.replace(/^##\s+/,"").trim(),start:z}}}),Y){let G=Y;X.push({header:G.header,lines:Z.length-G.start})}return X.sort((G,z)=>z.lines-G.lines)}function kF($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function bF($){return $.replace(/```[\s\S]*?```/g,"")}function fF($,Z){let X=new Map;for(let z of $){let J=z.relPath.split("/").pop()??"";if(J!=="AGENTS.md"&&J!=="CLAUDE.md")continue;let Q=p6(z.relPath),W=X.get(Q)??{};if(J==="AGENTS.md")W.agents=z;if(J==="CLAUDE.md")W.claude=z;X.set(Q,W)}let Y=new Set(Z.intentionalDifferentPairs),G=[];for(let[z,J]of X){let Q=!!J.agents,W=!!J.claude;if(!Q&&!W)continue;if(!Q||!W){G.push({dir:z,agentsExists:Q,claudeExists:W,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:V,claude:K}=J,H=`${V.relPath}:${K.relPath}`,B=`${K.relPath}:${V.relPath}`;if(Y.has(H)||Y.has(B)){G.push({dir:z,agentsExists:Q,claudeExists:W,classification:"intentional-different",detail:`allowlisted: ${V.lineCount}L vs ${K.lineCount}L`});continue}if(V.isSymlink&&V.symlinkTarget===K.absPath||K.isSymlink&&K.symlinkTarget===V.absPath){let w=V.isSymlink?"CLAUDE.md":"AGENTS.md";G.push({dir:z,agentsExists:Q,claudeExists:W,classification:"linked",detail:`canonical: ${w}`});continue}let F=l6(V.absPath,"utf8"),T=l6(K.absPath,"utf8");if(F===T)G.push({dir:z,agentsExists:Q,claudeExists:W,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${V.lineCount}L), not symlinked`});else G.push({dir:z,agentsExists:Q,claudeExists:W,classification:"unexpected-duplicate",detail:`divergent (${V.lineCount}L vs ${K.lineCount}L), not in intentional-different allowlist`})}return G.sort((z,J)=>z.dir.localeCompare(J.dir)),G}function yF($,Z,X){let Y=[];for(let G of $){if(G.isSymlink)continue;for(let Q of G.brokenImports)Y.push({severity:"error",category:"broken-import",file:G.relPath,message:`broken @-import: ${Q}`});for(let Q of G.brokenPathRefs)Y.push({severity:"error",category:"broken-path-ref",file:G.relPath,message:`broken path reference: ${Q}`});for(let Q of G.unresolvedCommands)Y.push({severity:"warning",category:"unresolved-command",file:G.relPath,message:`unresolved command: ${Q}`});let z=!G.relPath.includes("/"),J=z?X.budgets.rootLines:X.budgets.nestedWarnLines;if(G.lineCount>J)Y.push({severity:"warning",category:"over-budget",file:G.relPath,message:`${G.lineCount} lines exceeds ${z?"root":"nested"} budget of ${J}`})}for(let G of Z)if(G.classification==="unexpected-duplicate"){let z=G.detail.startsWith("divergent")?"error":"warning";Y.push({severity:z,category:z==="error"?"divergent-pair":"duplicate-pair",file:G.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${G.detail}`})}return Y}function e0($){let Z=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:Z,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:Z,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:Z>=90?"Well grounded":"Grounded",confidence:Z,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:Z,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:Z,tone:"error"}}function f9($){let Z=gF($);if(Z===null)return[];let X=[],Y=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,G=Y.exec(Z);while(G!==null)X.push({id:G[1].trim(),note:G[2].trim()||void 0}),G=Y.exec(Z);return X}function gF($){let X=/^##\s+Sources\s*$/im.exec($);if(!X)return null;let Y=X.index+X[0].length,G=$.slice(Y),z=/^##\s+/m.exec(G);return z?G.slice(0,z.index):G}function b1($){let Z=f9($.response),X=new Set(Z.map((B)=>B.id)),Y=new Set($.registeredIds),G=new Set($.requiredSources),z=[...X],J=[...G].filter((B)=>!X.has(B)),Q=[...X].filter((B)=>!Y.has(B)),W=[...G],V,K,H;if(z.length===0)V="NO",K=0,H="No citations in response";else if(Q.length===z.length)V="NO",K=0,H=`All cited sources are unknown: ${Q.join(", ")}`;else if(J.length===0&&Q.length===0)V="YES",K=100,H=W.length>0?`All required sources cited: ${W.join(", ")}`:`Cited registered sources: ${z.join(", ")}`;else{V="PARTIAL";let B=W.length>0?W.length:1,U=W.length-J.length,F=W.length>0?U/B*100:60,T=Q.length*15;K=Math.max(0,Math.min(100,Math.round(F-T)));let w=[];if(J.length>0)w.push(`missing: ${J.join(", ")}`);if(Q.length>0)w.push(`unknown: ${Q.join(", ")}`);H=w.join("; ")}return{answerable:V,confidence:K,reason:H,citations:{cited:z,required:W,missing:J,unknown:Q}}}function a6($){let Z=$.expected,X=(Z?.includes??[]).map((J)=>({value:J,satisfied:$.response.includes(J)})),Y=(Z?.excludes??[]).map((J)=>({value:J,satisfied:!$.response.includes(J)})),G=X.filter((J)=>J.satisfied).length+Y.filter((J)=>J.satisfied).length,z=X.length+Y.length;return{includes:X,excludes:Y,satisfied:G,total:z}}var n$="0.40.1";var hY=!1,r$=void 0,y9=void 0,vF=void 0,hF=void 0,uF=void 0,uY=void 0,mF=void 0,n6=void 0,g9=void 0,mY=void 0,v9=void 0,r6=void 0,dY=void 0;function cY($,Z={auto:!1}){if(hY)throw Error(`you must \`import '@anthropic-ai/sdk/shims/${$.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(r$)throw Error(`can't \`import '@anthropic-ai/sdk/shims/${$.kind}'\` after \`import '@anthropic-ai/sdk/shims/${r$}'\``);hY=Z.auto,r$=$.kind,y9=$.fetch,vF=$.Request,hF=$.Response,uF=$.Headers,uY=$.FormData,mF=$.Blob,n6=$.File,g9=$.ReadableStream,mY=$.getMultipartRequestOptions,v9=$.getDefaultAgent,r6=$.fileFromPath,dY=$.isFsReadStream}class h9{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function lY({manuallyImported:$}={}){let Z=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",X,Y,G,z;try{X=fetch,Y=Request,G=Response,z=Headers}catch(J){throw Error(`this environment is missing the following Web Fetch API type: ${J.message}. ${Z}`)}return{kind:"web",fetch:X,Request:Y,Response:G,Headers:z,FormData:typeof FormData<"u"?FormData:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${Z}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${Z}`)}},File:typeof File<"u"?File:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${Z}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${Z}`)}},getMultipartRequestOptions:async(J,Q)=>({...Q,body:new h9(J)}),getDefaultAgent:(J)=>{return},fileFromPath:()=>{throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:(J)=>!1}}import{ReadStream as cF}from"fs";function pY(){let $=lY();function Z(X){return X instanceof cF}return{...$,isFsReadStream:Z}}var u9=()=>{if(!r$)cY(pY(),{auto:!0})};u9();class y extends Error{}class e extends y{constructor($,Z,X,Y){super(`${e.makeMessage($,Z,X)}`);this.status=$,this.headers=Y,this.request_id=Y?.["request-id"],this.error=Z}static makeMessage($,Z,X){let Y=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):X;if($&&Y)return`${$} ${Y}`;if($)return`${$} status code (no body)`;if(Y)return Y;return"(no status code or body)"}static generate($,Z,X,Y){if(!$||!Y)return new s$({message:X,cause:G8(Z)});let G=Z;if($===400)return new s6($,G,X,Y);if($===401)return new o6($,G,X,Y);if($===403)return new t6($,G,X,Y);if($===404)return new e6($,G,X,Y);if($===409)return new $8($,G,X,Y);if($===422)return new Z8($,G,X,Y);if($===429)return new X8($,G,X,Y);if($>=500)return new Y8($,G,X,Y);return new e($,G,X,Y)}}class H0 extends e{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class s$ extends e{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}}class X4 extends s${constructor({message:$}={}){super({message:$??"Request timed out."})}}class s6 extends e{}class o6 extends e{}class t6 extends e{}class e6 extends e{}class $8 extends e{}class Z8 extends e{}class X8 extends e{}class Y8 extends e{}var z8=function($,Z,X,Y,G){if(Y==="m")throw TypeError("Private method is not writable");if(Y==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!G:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call($,X):G?G.value=X:Z.set($,X),X},o$=function($,Z,X,Y){if(X==="a"&&!Y)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!Y:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call($):Y?Y.value:Z.get($)},N0;class O${constructor(){N0.set(this,void 0),this.buffer=new Uint8Array,z8(this,N0,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,X=new Uint8Array(this.buffer.length+Z.length);X.set(this.buffer),X.set(Z,this.buffer.length),this.buffer=X;let Y=[],G;while((G=pF(this.buffer,o$(this,N0,"f")))!=null){if(G.carriage&&o$(this,N0,"f")==null){z8(this,N0,G.index,"f");continue}if(o$(this,N0,"f")!=null&&(G.index!==o$(this,N0,"f")+1||G.carriage)){Y.push(this.decodeText(this.buffer.slice(0,o$(this,N0,"f")-1))),this.buffer=this.buffer.slice(o$(this,N0,"f")),z8(this,N0,null,"f");continue}let z=o$(this,N0,"f")!==null?G.preceding-1:G.preceding,J=this.decodeText(this.buffer.slice(0,z));Y.push(J),this.buffer=this.buffer.slice(G.index),z8(this,N0,null,"f")}return Y}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer<"u"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new y(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new y(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new y("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
193
+ `)}}N0=new WeakMap;O$.NEWLINE_CHARS=new Set([`
194
+ `,"\r"]);O$.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function pF($,Z){for(let G=Z??0;G<$.length;G++){if($[G]===10)return{preceding:G,index:G+1,carriage:!1};if($[G]===13)return{preceding:G,index:G+1,carriage:!0}}return null}function iY($){for(let Y=0;Y<$.length-1;Y++){if($[Y]===10&&$[Y+1]===10)return Y+2;if($[Y]===13&&$[Y+1]===13)return Y+2;if($[Y]===13&&$[Y+1]===10&&Y+3<$.length&&$[Y+2]===13&&$[Y+3]===10)return Y+4}return-1}function Y4($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let X=await Z.read();if(X?.done)Z.releaseLock();return X}catch(X){throw Z.releaseLock(),X}},async return(){let X=Z.cancel();return Z.releaseLock(),await X,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class O0{constructor($,Z){this.iterator=$,this.controller=Z}static fromSSEResponse($,Z){let X=!1;async function*Y(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let G=!1;try{for await(let z of iF($,Z)){if(z.event==="completion")try{yield JSON.parse(z.data)}catch(J){throw console.error("Could not parse message into JSON:",z.data),console.error("From chunk:",z.raw),J}if(z.event==="message_start"||z.event==="message_delta"||z.event==="message_stop"||z.event==="content_block_start"||z.event==="content_block_delta"||z.event==="content_block_stop")try{yield JSON.parse(z.data)}catch(J){throw console.error("Could not parse message into JSON:",z.data),console.error("From chunk:",z.raw),J}if(z.event==="ping")continue;if(z.event==="error")throw e.generate(void 0,`SSE Error: ${z.data}`,z.data,m9($.headers))}G=!0}catch(z){if(z instanceof Error&&z.name==="AbortError")return;throw z}finally{if(!G)Z.abort()}}return new O0(Y,Z)}static fromReadableStream($,Z){let X=!1;async function*Y(){let z=new O$,J=Y4($);for await(let Q of J)for(let W of z.decode(Q))yield W;for(let Q of z.flush())yield Q}async function*G(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let z=!1;try{for await(let J of Y()){if(z)continue;if(J)yield JSON.parse(J)}z=!0}catch(J){if(J instanceof Error&&J.name==="AbortError")return;throw J}finally{if(!z)Z.abort()}}return new O0(G,Z)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],Z=[],X=this.iterator(),Y=(G)=>{return{next:()=>{if(G.length===0){let z=X.next();$.push(z),Z.push(z)}return G.shift()}}};return[new O0(()=>Y($),this.controller),new O0(()=>Y(Z),this.controller)]}toReadableStream(){let $=this,Z,X=new TextEncoder;return new g9({async start(){Z=$[Symbol.asyncIterator]()},async pull(Y){try{let{value:G,done:z}=await Z.next();if(z)return Y.close();let J=X.encode(JSON.stringify(G)+`
195
+ `);Y.enqueue(J)}catch(G){Y.error(G)}},async cancel(){await Z.return?.()}})}}async function*iF($,Z){if(!$.body)throw Z.abort(),new y("Attempted to iterate over a response with no body");let X=new aY,Y=new O$,G=Y4($.body);for await(let z of aF(G))for(let J of Y.decode(z)){let Q=X.decode(J);if(Q)yield Q}for(let z of Y.flush()){let J=X.decode(z);if(J)yield J}}async function*aF($){let Z=new Uint8Array;for await(let X of $){if(X==null)continue;let Y=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?new TextEncoder().encode(X):X,G=new Uint8Array(Z.length+Y.length);G.set(Z),G.set(Y,Z.length),Z=G;let z;while((z=iY(Z))!==-1)yield Z.slice(0,z),Z=Z.slice(z)}if(Z.length>0)yield Z}class aY{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let G={event:this.event,data:this.data.join(`
196
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],G}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,X,Y]=nF($,":");if(Y.startsWith(" "))Y=Y.substring(1);if(Z==="event")this.event=Y;else if(Z==="data")this.data.push(Y);return null}}function nF($,Z){let X=$.indexOf(Z);if(X!==-1)return[$.substring(0,X),Z,$.substring(X+Z.length)];return[$,"",""]}var rF=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",sF=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&G4($),G4=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function";async function nY($,Z,X){if($=await $,sF($))return $;if(rF($)){let G=await $.blob();Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let z=G4(G)?[await G.arrayBuffer()]:[G];return new n6(z,Z,X)}let Y=await oF($);if(Z||(Z=eF($)??"unknown_file"),!X?.type){let G=Y[0]?.type;if(typeof G==="string")X={...X,type:G}}return new n6(Y,Z,X)}async function oF($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(G4($))Z.push(await $.arrayBuffer());else if($L($))for await(let X of $)Z.push(X);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${tF($)}`);return Z}function tF($){return`[${Object.getOwnPropertyNames($).map((X)=>`"${X}"`).join(", ")}]`}function eF($){return d9($.name)||d9($.filename)||d9($.path)?.split(/[\\/]/).pop()}var d9=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},$L=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",c9=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var XL=function($,Z,X,Y,G){if(Y==="m")throw TypeError("Private method is not writable");if(Y==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!G:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call($,X):G?G.value=X:Z.set($,X),X},YL=function($,Z,X,Y){if(X==="a"&&!Y)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!Y:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call($):Y?Y.value:Z.get($)},J8;u9();async function eY($){let{response:Z}=$;if($.options.stream){if(f1("response",Z.status,Z.url,Z.headers,Z.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(Z,$.controller);return O0.fromSSEResponse(Z,$.controller)}if(Z.status===204)return null;if($.options.__binaryResponse)return Z;let Y=Z.headers.get("content-type")?.split(";")[0]?.trim();if(Y?.includes("application/json")||Y?.endsWith("+json")){let J=await Z.json();return f1("response",Z.status,Z.url,Z.headers,J),$G(J,Z)}let z=await Z.text();return f1("response",Z.status,Z.url,Z.headers,z),z}function $G($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}class W8 extends Promise{constructor($,Z=eY){super((X)=>{X(null)});this.responsePromise=$,this.parseResponse=Z}_thenUnwrap($){return new W8(this.responsePromise,async(Z)=>$G($(await this.parseResponse(Z),Z),Z.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:Z,request_id:Z.headers.get("request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(this.parseResponse);return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class p9{constructor({baseURL:$,maxRetries:Z=2,timeout:X=600000,httpAgent:Y,fetch:G}){this.baseURL=$,this.maxRetries=l9("maxRetries",Z),this.timeout=l9("timeout",X),this.httpAgent=Y,this.fetch=G??y9}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...QL(),...this.authHeaders($)}}validateHeaders($,Z){}defaultIdempotencyKey(){return`stainless-node-retry-${BL()}`}get($,Z){return this.methodRequest("get",$,Z)}post($,Z){return this.methodRequest("post",$,Z)}patch($,Z){return this.methodRequest("patch",$,Z)}put($,Z){return this.methodRequest("put",$,Z)}delete($,Z){return this.methodRequest("delete",$,Z)}methodRequest($,Z,X){return this.request(Promise.resolve(X).then(async(Y)=>{let G=Y&&G4(Y?.body)?new DataView(await Y.body.arrayBuffer()):Y?.body instanceof DataView?Y.body:Y?.body instanceof ArrayBuffer?new DataView(Y.body):Y&&ArrayBuffer.isView(Y?.body)?new DataView(Y.body.buffer):Y?.body;return{method:$,path:Z,...Y,body:G}}))}getAPIList($,Z,X){return this.requestAPIList(Z,{method:"get",path:$,...X})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer<"u")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:Z=0}={}){let X={...$},{method:Y,path:G,query:z,headers:J={}}=X,Q=ArrayBuffer.isView(X.body)||X.__binaryRequest&&typeof X.body==="string"?X.body:c9(X.body)?X.body.body:X.body?JSON.stringify(X.body,null,2):null,W=this.calculateContentLength(Q),V=this.buildURL(G,z);if("timeout"in X)l9("timeout",X.timeout);X.timeout=X.timeout??this.timeout;let K=X.httpAgent??this.httpAgent??v9(V),H=X.timeout+1000;if(typeof K?.options?.timeout==="number"&&H>(K.options.timeout??0))K.options.timeout=H;if(this.idempotencyHeader&&Y!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let B=this.buildHeaders({options:X,headers:J,contentLength:W,retryCount:Z});return{req:{method:Y,...Q&&{body:Q},headers:B,...K&&{agent:K},signal:X.signal??null},url:V,timeout:X.timeout}}buildHeaders({options:$,headers:Z,contentLength:X,retryCount:Y}){let G={};if(X)G["content-length"]=X;let z=this.defaultHeaders($);if(tY(G,z),tY(G,Z),c9($.body)&&r$!=="node")delete G["content-type"];if(Q8(z,"x-stainless-retry-count")===void 0&&Q8(Z,"x-stainless-retry-count")===void 0)G["x-stainless-retry-count"]=String(Y);if(Q8(z,"x-stainless-timeout")===void 0&&Q8(Z,"x-stainless-timeout")===void 0&&$.timeout)G["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(G,Z),G}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new y("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:X}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((Z)=>[...Z])):{...$}}makeStatusError($,Z,X,Y){return e.generate($,Z,X,Y)}request($,Z=null){return new W8(this.makeRequest($,Z))}async makeRequest($,Z){let X=await $,Y=X.maxRetries??this.maxRetries;if(Z==null)Z=Y;await this.prepareOptions(X);let{req:G,url:z,timeout:J}=this.buildRequest(X,{retryCount:Y-Z});if(await this.prepareRequest(G,{url:z,options:X}),f1("request",z,X,G.headers),X.signal?.aborted)throw new H0;let Q=new AbortController,W=await this.fetchWithTimeout(z,G,J,Q).catch(G8);if(W instanceof Error){if(X.signal?.aborted)throw new H0;if(Z)return this.retryRequest(X,Z);if(W.name==="AbortError")throw new X4;throw new s$({cause:W})}let V=m9(W.headers);if(!W.ok){if(Z&&this.shouldRetry(W)){let T=`retrying, ${Z} attempts remaining`;return f1(`response (error; ${T})`,W.status,z,V),this.retryRequest(X,Z,V)}let K=await W.text().catch((T)=>G8(T).message),H=WL(K),B=H?void 0:K;throw f1(`response (error; ${Z?"(error; no more retries left)":"(error; not retryable)"})`,W.status,z,V,B),this.makeStatusError(W.status,H,B,V)}return{response:W,options:X,controller:Q}}requestAPIList($,Z){let X=this.makeRequest(Z,null);return new ZG(this,X,$)}buildURL($,Z){let X=HL($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),Y=this.defaultQuery();if(!XG(Y))Z={...Y,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))X.search=this.stringifyQuery(Z);return X.toString()}stringifyQuery($){return Object.entries($).filter(([Z,X])=>typeof X<"u").map(([Z,X])=>{if(typeof X==="string"||typeof X==="number"||typeof X==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(X)}`;if(X===null)return`${encodeURIComponent(Z)}=`;throw new y(`Cannot stringify type ${typeof X}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}async fetchWithTimeout($,Z,X,Y){let{signal:G,...z}=Z||{};if(G)G.addEventListener("abort",()=>Y.abort());let J=setTimeout(()=>Y.abort(),X),Q={signal:Y.signal,...z};if(Q.method)Q.method=Q.method.toUpperCase();let W=60000,V=setTimeout(()=>{if(Q&&Q?.agent?.sockets){for(let K of Object.values(Q?.agent?.sockets).flat())if(K?.setKeepAlive)K.setKeepAlive(!0,W)}},W);return this.fetch.call(void 0,$,Q).finally(()=>{clearTimeout(J),clearTimeout(V)})}shouldRetry($){let Z=$.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,Z,X){let Y,G=X?.["retry-after-ms"];if(G){let J=parseFloat(G);if(!Number.isNaN(J))Y=J}let z=X?.["retry-after"];if(z&&!Y){let J=parseFloat(z);if(!Number.isNaN(J))Y=J*1000;else Y=Date.parse(z)-Date.now()}if(!(Y&&0<=Y&&Y<60000)){let J=$.maxRetries??this.maxRetries;Y=this.calculateDefaultRetryTimeoutMillis(Z,J)}return await KL(Y),this.makeRequest($,Z-1)}calculateDefaultRetryTimeoutMillis($,Z){let G=Z-$,z=Math.min(0.5*Math.pow(2,G),8),J=1-Math.random()*0.25;return z*J*1000}getUserAgent(){return`${this.constructor.name}/JS ${n$}`}}class i9{constructor($,Z,X,Y){J8.set(this,void 0),XL(this,J8,$,"f"),this.options=Y,this.response=Z,this.body=X}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let Z={...this.options};if("params"in $&&typeof Z.query==="object")Z.query={...Z.query,...$.params};else if("url"in $){let X=[...Object.entries(Z.query||{}),...$.url.searchParams.entries()];for(let[Y,G]of X)$.url.searchParams.set(Y,G);Z.query=void 0,Z.path=$.url.toString()}return await YL(this,J8,"f").requestAPIList(this.constructor,Z)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(J8=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}}class ZG extends W8{constructor($,Z,X){super(Z,async(Y)=>new X($,Y.response,await eY(Y),Y.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}}var m9=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(Z,X){let Y=X.toString();return Z[Y.toLowerCase()]||Z[Y]}})},GL={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},j0=($)=>{return typeof $==="object"&&$!==null&&!XG($)&&Object.keys($).every((Z)=>YG(GL,Z))},zL=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":n$,"X-Stainless-OS":sY(Deno.build.os),"X-Stainless-Arch":rY(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":n$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":n$,"X-Stainless-OS":sY(process.platform),"X-Stainless-Arch":rY(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=JL();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":n$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":n$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function JL(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:X}of $){let Y=X.exec(navigator.userAgent);if(Y){let G=Y[1]||0,z=Y[2]||0,J=Y[3]||0;return{browser:Z,version:`${G}.${z}.${J}`}}}return null}var rY=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},sY=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},oY,QL=()=>{return oY??(oY=zL())},WL=($)=>{try{return JSON.parse($)}catch(Z){return}},VL=/^[a-z][a-z0-9+.-]*:/i,HL=($)=>{return VL.test($)},KL=($)=>new Promise((Z)=>setTimeout(Z,$)),l9=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new y(`${$} must be an integer`);if(Z<0)throw new y(`${$} must be a positive integer`);return Z},G8=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return Error(JSON.stringify($))}catch{}return Error(String($))};var V8=($)=>{if(typeof process<"u")return process.env?.[$]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.($)?.trim();return};function XG($){if(!$)return!0;for(let Z in $)return!1;return!0}function YG($,Z){return Object.prototype.hasOwnProperty.call($,Z)}function tY($,Z){for(let X in Z){if(!YG(Z,X))continue;let Y=X.toLowerCase();if(!Y)continue;let G=Z[X];if(G===null)delete $[Y];else if(G!==void 0)$[Y]=G}}function f1($,...Z){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...Z)}var BL=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let Z=Math.random()*16|0;return($==="x"?Z:Z&3|8).toString(16)})},GG=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},UL=($)=>{return typeof $?.get==="function"};var Q8=($,Z)=>{let X=Z.toLowerCase();if(UL($)){let Y=Z[0]?.toUpperCase()+Z.substring(1).replace(/([^\w])(\w)/g,(G,z,J)=>z+J.toUpperCase());for(let G of[Z,X,Z.toUpperCase(),Y]){let z=$.get(G);if(z)return z}}for(let[Y,G]of Object.entries($))if(Y.toLowerCase()===X){if(Array.isArray(G)){if(G.length<=1)return G[0];return console.warn(`Received ${G.length} entries for the ${Z} header, using the first entry.`),G[0]}return G}return};class $$ extends i9{constructor($,Z,X,Y){super($,Z,X,Y);this.data=X.data||[],this.has_more=X.has_more||!1,this.first_id=X.first_id||null,this.last_id=X.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let Z=Object.fromEntries($.url.searchParams);if(!Object.keys(Z).length)return null;return Z}nextPageInfo(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{params:{before_id:Z}}}let $=this.last_id;if(!$)return null;return{params:{after_id:$}}}}class W0{constructor($){this._client=$}}class y1 extends W0{retrieve($,Z){return this._client.get(`/v1/models/${$}?beta=true`,Z)}list($={},Z){if(j0($))return this.list({},$);return this._client.getAPIList("/v1/models?beta=true",z4,{query:$,...Z})}}class z4 extends $${}y1.BetaModelInfosPage=z4;class g1{constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new O$;for await(let Z of this.iterator)for(let X of $.decode(Z))yield JSON.parse(X);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body)throw Z.abort(),new y("Attempted to iterate over a response with no body");return new g1(Y4($.body),Z)}}class v1 extends W0{create($,Z){let{betas:X,...Y}=$;return this._client.post("/v1/messages/batches?beta=true",{body:Y,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}retrieve($,Z={},X){if(j0(Z))return this.retrieve($,{},Z);let{betas:Y}=Z;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...Y??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}list($={},Z){if(j0($))return this.list({},$);let{betas:X,...Y}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",J4,{query:Y,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}delete($,Z={},X){if(j0(Z))return this.delete($,{},Z);let{betas:Y}=Z;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...Y??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}cancel($,Z={},X){if(j0(Z))return this.cancel($,{},Z);let{betas:Y}=Z;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...X,headers:{"anthropic-beta":[...Y??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}async results($,Z={},X){if(j0(Z))return this.results($,{},Z);let Y=await this.retrieve($);if(!Y.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${Y.processing_status} - ${Y.id}`);let{betas:G}=Z;return this._client.get(Y.results_url,{...X,headers:{"anthropic-beta":[...G??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...X?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((z,J)=>g1.fromResponse(J.response,J.controller))}}class J4 extends $${}v1.BetaMessageBatchesPage=J4;var LL=($)=>{let Z=0,X=[];while(Z<$.length){let Y=$[Z];if(Y==="\\"){Z++;continue}if(Y==="{"){X.push({type:"brace",value:"{"}),Z++;continue}if(Y==="}"){X.push({type:"brace",value:"}"}),Z++;continue}if(Y==="["){X.push({type:"paren",value:"["}),Z++;continue}if(Y==="]"){X.push({type:"paren",value:"]"}),Z++;continue}if(Y===":"){X.push({type:"separator",value:":"}),Z++;continue}if(Y===","){X.push({type:"delimiter",value:","}),Z++;continue}if(Y==='"'){let Q="",W=!1;Y=$[++Z];while(Y!=='"'){if(Z===$.length){W=!0;break}if(Y==="\\"){if(Z++,Z===$.length){W=!0;break}Q+=Y+$[Z],Y=$[++Z]}else Q+=Y,Y=$[++Z]}if(Y=$[++Z],!W)X.push({type:"string",value:Q});continue}if(Y&&/\s/.test(Y)){Z++;continue}let z=/[0-9]/;if(Y&&z.test(Y)||Y==="-"||Y==="."){let Q="";if(Y==="-")Q+=Y,Y=$[++Z];while(Y&&z.test(Y)||Y===".")Q+=Y,Y=$[++Z];X.push({type:"number",value:Q});continue}let J=/[a-z]/i;if(Y&&J.test(Y)){let Q="";while(Y&&J.test(Y)){if(Z===$.length)break;Q+=Y,Y=$[++Z]}if(Q=="true"||Q=="false"||Q==="null")X.push({type:"name",value:Q});else{Z++;continue}continue}Z++}return X},h1=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),h1($);break;case"number":let X=Z.value[Z.value.length-1];if(X==="."||X==="-")return $=$.slice(0,$.length-1),h1($);case"string":let Y=$[$.length-2];if(Y?.type==="delimiter")return $=$.slice(0,$.length-1),h1($);else if(Y?.type==="brace"&&Y.value==="{")return $=$.slice(0,$.length-1),h1($);break;case"delimiter":return $=$.slice(0,$.length-1),h1($);break}return $},wL=($)=>{let Z=[];if($.map((X)=>{if(X.type==="brace")if(X.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(X.type==="paren")if(X.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((X)=>{if(X==="}")$.push({type:"brace",value:"}"});else if(X==="]")$.push({type:"paren",value:"]"})});return $},ML=($)=>{let Z="";return $.map((X)=>{switch(X.type){case"string":Z+='"'+X.value+'"';break;default:Z+=X.value;break}}),Z},H8=($)=>JSON.parse(ML(wL(h1(LL($)))));var K0=function($,Z,X,Y,G){if(Y==="m")throw TypeError("Private method is not writable");if(Y==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!G:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call($,X):G?G.value=X:Z.set($,X),X},h=function($,Z,X,Y){if(X==="a"&&!Y)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!Y:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call($):Y?Y.value:Z.get($)},x0,_$,Q4,K8,W4,V4,B8,H4,Z$,K4,U8,q8,u1,T8,F8,a9,zG,n9,r9,s9,o9,JG,QG="__json_buf";class B4{constructor(){x0.add(this),this.messages=[],this.receivedMessages=[],_$.set(this,void 0),this.controller=new AbortController,Q4.set(this,void 0),K8.set(this,()=>{}),W4.set(this,()=>{}),V4.set(this,void 0),B8.set(this,()=>{}),H4.set(this,()=>{}),Z$.set(this,{}),K4.set(this,!1),U8.set(this,!1),q8.set(this,!1),u1.set(this,!1),T8.set(this,void 0),F8.set(this,void 0),n9.set(this,($)=>{if(K0(this,U8,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new H0;if($ instanceof H0)return K0(this,q8,!0,"f"),this._emit("abort",$);if($ instanceof y)return this._emit("error",$);if($ instanceof Error){let Z=new y($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new y(String($)))}),K0(this,Q4,new Promise(($,Z)=>{K0(this,K8,$,"f"),K0(this,W4,Z,"f")}),"f"),K0(this,V4,new Promise(($,Z)=>{K0(this,B8,$,"f"),K0(this,H4,Z,"f")}),"f"),h(this,Q4,"f").catch(()=>{}),h(this,V4,"f").catch(()=>{})}get response(){return h(this,T8,"f")}get request_id(){return h(this,F8,"f")}async withResponse(){let $=await h(this,Q4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new B4;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let Y=new B4;for(let G of Z.messages)Y._addMessageParam(G);return Y._run(()=>Y._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},h(this,n9,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}h(this,x0,"m",r9).call(this);let{response:G,data:z}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(G);for await(let J of z)h(this,x0,"m",s9).call(this,J);if(z.controller.signal?.aborted)throw new H0;h(this,x0,"m",o9).call(this)}_connected($){if(this.ended)return;K0(this,T8,$,"f"),K0(this,F8,$?.headers.get("request-id"),"f"),h(this,K8,"f").call(this,$),this._emit("connect")}get ended(){return h(this,K4,"f")}get errored(){return h(this,U8,"f")}get aborted(){return h(this,q8,"f")}abort(){this.controller.abort()}on($,Z){return(h(this,Z$,"f")[$]||(h(this,Z$,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=h(this,Z$,"f")[$];if(!X)return this;let Y=X.findIndex((G)=>G.listener===Z);if(Y>=0)X.splice(Y,1);return this}once($,Z){return(h(this,Z$,"f")[$]||(h(this,Z$,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(K0(this,u1,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){K0(this,u1,!0,"f"),await h(this,V4,"f")}get currentMessage(){return h(this,_$,"f")}async finalMessage(){return await this.done(),h(this,x0,"m",a9).call(this)}async finalText(){return await this.done(),h(this,x0,"m",zG).call(this)}_emit($,...Z){if(h(this,K4,"f"))return;if($==="end")K0(this,K4,!0,"f"),h(this,B8,"f").call(this);let X=h(this,Z$,"f")[$];if(X)h(this,Z$,"f")[$]=X.filter((Y)=>!Y.once),X.forEach(({listener:Y})=>Y(...Z));if($==="abort"){let Y=Z[0];if(!h(this,u1,"f")&&!X?.length)Promise.reject(Y);h(this,W4,"f").call(this,Y),h(this,H4,"f").call(this,Y),this._emit("end");return}if($==="error"){let Y=Z[0];if(!h(this,u1,"f")&&!X?.length)Promise.reject(Y);h(this,W4,"f").call(this,Y),h(this,H4,"f").call(this,Y),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",h(this,x0,"m",a9).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}h(this,x0,"m",r9).call(this),this._connected(null);let Y=O0.fromReadableStream($,this.controller);for await(let G of Y)h(this,x0,"m",s9).call(this,G);if(Y.controller.signal?.aborted)throw new H0;h(this,x0,"m",o9).call(this)}[(_$=new WeakMap,Q4=new WeakMap,K8=new WeakMap,W4=new WeakMap,V4=new WeakMap,B8=new WeakMap,H4=new WeakMap,Z$=new WeakMap,K4=new WeakMap,U8=new WeakMap,q8=new WeakMap,u1=new WeakMap,T8=new WeakMap,F8=new WeakMap,n9=new WeakMap,x0=new WeakSet,a9=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},zG=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new y("stream ended without producing a content block with type=text");return Z.join(" ")},r9=function(){if(this.ended)return;K0(this,_$,void 0,"f")},s9=function(Z){if(this.ended)return;let X=h(this,x0,"m",JG).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let Y=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(Y.type==="text")this._emit("text",Z.delta.text,Y.text||"");break}case"citations_delta":{if(Y.type==="text")this._emit("citation",Z.delta.citation,Y.citations??[]);break}case"input_json_delta":{if(Y.type==="tool_use"&&Y.input)this._emit("inputJson",Z.delta.partial_json,Y.input);break}case"thinking_delta":{if(Y.type==="thinking")this._emit("thinking",Z.delta.thinking,Y.thinking);break}case"signature_delta":{if(Y.type==="thinking")this._emit("signature",Y.signature);break}default:WG(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{K0(this,_$,X,"f");break}case"content_block_start":case"message_delta":break}},o9=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");let Z=h(this,_$,"f");if(!Z)throw new y("request ended without sending any chunks");return K0(this,_$,void 0,"f"),Z},JG=function(Z){let X=h(this,_$,"f");if(Z.type==="message_start"){if(X)throw new y(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new y(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let Y=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(Y?.type==="text")Y.text+=Z.delta.text;break}case"citations_delta":{if(Y?.type==="text")Y.citations??(Y.citations=[]),Y.citations.push(Z.delta.citation);break}case"input_json_delta":{if(Y?.type==="tool_use"){let G=Y[QG]||"";if(G+=Z.delta.partial_json,Object.defineProperty(Y,QG,{value:G,enumerable:!1,writable:!0}),G)Y.input=H8(G)}break}case"thinking_delta":{if(Y?.type==="thinking")Y.thinking+=Z.delta.thinking;break}case"signature_delta":{if(Y?.type==="thinking")Y.signature=Z.delta.signature;break}default:WG(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(Y)=>{let G=Z.shift();if(G)G.resolve(Y);else $.push(Y)}),this.on("end",()=>{X=!0;for(let Y of Z)Y.resolve(void 0);Z.length=0}),this.on("abort",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),this.on("error",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((G,z)=>Z.push({resolve:G,reject:z})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new O0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function WG($){}var VG={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class t$ extends W0{constructor(){super(...arguments);this.batches=new v1(this._client)}create($,Z){let{betas:X,...Y}=$;if(Y.model in VG)console.warn(`The model '${Y.model}' is deprecated and will reach end-of-life on ${VG[Y.model]}
197
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages?beta=true",{body:Y,timeout:this._client._options.timeout??(Y.stream?600000:this._client._calculateNonstreamingTimeout(Y.max_tokens)),...Z,headers:{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0,...Z?.headers},stream:$.stream??!1})}stream($,Z){return B4.createMessage(this,$,Z)}countTokens($,Z){let{betas:X,...Y}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:Y,...Z,headers:{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString(),...Z?.headers}})}}t$.Batches=v1;t$.BetaMessageBatchesPage=J4;class X$ extends W0{constructor(){super(...arguments);this.models=new y1(this._client),this.messages=new t$(this._client)}}X$.Models=y1;X$.BetaModelInfosPage=z4;X$.Messages=t$;class m1 extends W0{create($,Z){return this._client.post("/v1/complete",{body:$,timeout:this._client._options.timeout??600000,...Z,stream:$.stream??!1})}}class d1 extends W0{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(`/v1/messages/batches/${$}`,Z)}list($={},Z){if(j0($))return this.list({},$);return this._client.getAPIList("/v1/messages/batches",U4,{query:$,...Z})}delete($,Z){return this._client.delete(`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let X=await this.retrieve($);if(!X.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);return this._client.get(X.results_url,{...Z,headers:{Accept:"application/binary",...Z?.headers},__binaryResponse:!0})._thenUnwrap((Y,G)=>g1.fromResponse(G.response,G.controller))}}class U4 extends $${}d1.MessageBatchesPage=U4;var B0=function($,Z,X,Y,G){if(Y==="m")throw TypeError("Private method is not writable");if(Y==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!G:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call($,X):G?G.value=X:Z.set($,X),X},u=function($,Z,X,Y){if(X==="a"&&!Y)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!Y:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call($):Y?Y.value:Z.get($)},k0,P$,q4,L8,T4,F4,w8,L4,Y$,w4,M8,N8,c1,O8,_8,t9,HG,e9,$5,Z5,X5,KG,BG="__json_buf";class M4{constructor(){k0.add(this),this.messages=[],this.receivedMessages=[],P$.set(this,void 0),this.controller=new AbortController,q4.set(this,void 0),L8.set(this,()=>{}),T4.set(this,()=>{}),F4.set(this,void 0),w8.set(this,()=>{}),L4.set(this,()=>{}),Y$.set(this,{}),w4.set(this,!1),M8.set(this,!1),N8.set(this,!1),c1.set(this,!1),O8.set(this,void 0),_8.set(this,void 0),e9.set(this,($)=>{if(B0(this,M8,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new H0;if($ instanceof H0)return B0(this,N8,!0,"f"),this._emit("abort",$);if($ instanceof y)return this._emit("error",$);if($ instanceof Error){let Z=new y($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new y(String($)))}),B0(this,q4,new Promise(($,Z)=>{B0(this,L8,$,"f"),B0(this,T4,Z,"f")}),"f"),B0(this,F4,new Promise(($,Z)=>{B0(this,w8,$,"f"),B0(this,L4,Z,"f")}),"f"),u(this,q4,"f").catch(()=>{}),u(this,F4,"f").catch(()=>{})}get response(){return u(this,O8,"f")}get request_id(){return u(this,_8,"f")}async withResponse(){let $=await u(this,q4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new M4;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let Y=new M4;for(let G of Z.messages)Y._addMessageParam(G);return Y._run(()=>Y._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},u(this,e9,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}u(this,k0,"m",$5).call(this);let{response:G,data:z}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(G);for await(let J of z)u(this,k0,"m",Z5).call(this,J);if(z.controller.signal?.aborted)throw new H0;u(this,k0,"m",X5).call(this)}_connected($){if(this.ended)return;B0(this,O8,$,"f"),B0(this,_8,$?.headers.get("request-id"),"f"),u(this,L8,"f").call(this,$),this._emit("connect")}get ended(){return u(this,w4,"f")}get errored(){return u(this,M8,"f")}get aborted(){return u(this,N8,"f")}abort(){this.controller.abort()}on($,Z){return(u(this,Y$,"f")[$]||(u(this,Y$,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=u(this,Y$,"f")[$];if(!X)return this;let Y=X.findIndex((G)=>G.listener===Z);if(Y>=0)X.splice(Y,1);return this}once($,Z){return(u(this,Y$,"f")[$]||(u(this,Y$,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(B0(this,c1,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){B0(this,c1,!0,"f"),await u(this,F4,"f")}get currentMessage(){return u(this,P$,"f")}async finalMessage(){return await this.done(),u(this,k0,"m",t9).call(this)}async finalText(){return await this.done(),u(this,k0,"m",HG).call(this)}_emit($,...Z){if(u(this,w4,"f"))return;if($==="end")B0(this,w4,!0,"f"),u(this,w8,"f").call(this);let X=u(this,Y$,"f")[$];if(X)u(this,Y$,"f")[$]=X.filter((Y)=>!Y.once),X.forEach(({listener:Y})=>Y(...Z));if($==="abort"){let Y=Z[0];if(!u(this,c1,"f")&&!X?.length)Promise.reject(Y);u(this,T4,"f").call(this,Y),u(this,L4,"f").call(this,Y),this._emit("end");return}if($==="error"){let Y=Z[0];if(!u(this,c1,"f")&&!X?.length)Promise.reject(Y);u(this,T4,"f").call(this,Y),u(this,L4,"f").call(this,Y),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",u(this,k0,"m",t9).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}u(this,k0,"m",$5).call(this),this._connected(null);let Y=O0.fromReadableStream($,this.controller);for await(let G of Y)u(this,k0,"m",Z5).call(this,G);if(Y.controller.signal?.aborted)throw new H0;u(this,k0,"m",X5).call(this)}[(P$=new WeakMap,q4=new WeakMap,L8=new WeakMap,T4=new WeakMap,F4=new WeakMap,w8=new WeakMap,L4=new WeakMap,Y$=new WeakMap,w4=new WeakMap,M8=new WeakMap,N8=new WeakMap,c1=new WeakMap,O8=new WeakMap,_8=new WeakMap,e9=new WeakMap,k0=new WeakSet,t9=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},HG=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new y("stream ended without producing a content block with type=text");return Z.join(" ")},$5=function(){if(this.ended)return;B0(this,P$,void 0,"f")},Z5=function(Z){if(this.ended)return;let X=u(this,k0,"m",KG).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let Y=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(Y.type==="text")this._emit("text",Z.delta.text,Y.text||"");break}case"citations_delta":{if(Y.type==="text")this._emit("citation",Z.delta.citation,Y.citations??[]);break}case"input_json_delta":{if(Y.type==="tool_use"&&Y.input)this._emit("inputJson",Z.delta.partial_json,Y.input);break}case"thinking_delta":{if(Y.type==="thinking")this._emit("thinking",Z.delta.thinking,Y.thinking);break}case"signature_delta":{if(Y.type==="thinking")this._emit("signature",Y.signature);break}default:UG(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{B0(this,P$,X,"f");break}case"content_block_start":case"message_delta":break}},X5=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");let Z=u(this,P$,"f");if(!Z)throw new y("request ended without sending any chunks");return B0(this,P$,void 0,"f"),Z},KG=function(Z){let X=u(this,P$,"f");if(Z.type==="message_start"){if(X)throw new y(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new y(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let Y=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(Y?.type==="text")Y.text+=Z.delta.text;break}case"citations_delta":{if(Y?.type==="text")Y.citations??(Y.citations=[]),Y.citations.push(Z.delta.citation);break}case"input_json_delta":{if(Y?.type==="tool_use"){let G=Y[BG]||"";if(G+=Z.delta.partial_json,Object.defineProperty(Y,BG,{value:G,enumerable:!1,writable:!0}),G)Y.input=H8(G)}break}case"thinking_delta":{if(Y?.type==="thinking")Y.thinking+=Z.delta.thinking;break}case"signature_delta":{if(Y?.type==="thinking")Y.signature=Z.delta.signature;break}default:UG(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(Y)=>{let G=Z.shift();if(G)G.resolve(Y);else $.push(Y)}),this.on("end",()=>{X=!0;for(let Y of Z)Y.resolve(void 0);Z.length=0}),this.on("abort",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),this.on("error",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((G,z)=>Z.push({resolve:G,reject:z})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new O0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function UG($){}class D$ extends W0{constructor(){super(...arguments);this.batches=new d1(this._client)}create($,Z){if($.model in qG)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${qG[$.model]}
198
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages",{body:$,timeout:this._client._options.timeout??($.stream?600000:this._client._calculateNonstreamingTimeout($.max_tokens)),...Z,stream:$.stream??!1})}stream($,Z){return M4.createMessage(this,$,Z)}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}}var qG={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};D$.Batches=d1;D$.MessageBatchesPage=U4;class e$ extends W0{retrieve($,Z){return this._client.get(`/v1/models/${$}`,Z)}list($={},Z){if(j0($))return this.list({},$);return this._client.getAPIList("/v1/models",l1,{query:$,...Z})}}class l1 extends $${}e$.ModelInfosPage=l1;var TG;class p extends p9{constructor({baseURL:$=V8("ANTHROPIC_BASE_URL"),apiKey:Z=V8("ANTHROPIC_API_KEY")??null,authToken:X=V8("ANTHROPIC_AUTH_TOKEN")??null,...Y}={}){let G={apiKey:Z,authToken:X,...Y,baseURL:$||"https://api.anthropic.com"};if(!G.dangerouslyAllowBrowser&&GG())throw new y(`It looks like you're running in a browser-like environment.
199
199
 
200
200
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
201
201
  If you understand the risks and have appropriate mitigations in place,
202
202
  you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
203
203
 
204
204
  new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
205
- `);super({baseURL:q.baseURL,timeout:q.timeout??600000,httpAgent:q.httpAgent,maxRetries:q.maxRetries,fetch:q.fetch});this.completions=new I$(this),this.messages=new g0(this),this.models=new $$(this),this.beta=new w0(this),this._options=q,this.apiKey=Z,this.authToken=X}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01",...this._options.defaultHeaders}}validateHeaders($,Z){if(this.apiKey&&$["x-api-key"])return;if(Z["x-api-key"]===null)return;if(this.authToken&&$.authorization)return;if(Z.authorization===null)return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}authHeaders($){return{...this.apiKeyAuth($),...this.bearerAuth($)}}apiKeyAuth($){if(this.apiKey==null)return{};return{"X-Api-Key":this.apiKey}}bearerAuth($){if(this.authToken==null)return{};return{Authorization:`Bearer ${this.authToken}`}}}kZ=x;x.Anthropic=kZ;x.HUMAN_PROMPT=`
205
+ `);super({baseURL:G.baseURL,timeout:G.timeout??600000,httpAgent:G.httpAgent,maxRetries:G.maxRetries,fetch:G.fetch});this.completions=new m1(this),this.messages=new D$(this),this.models=new e$(this),this.beta=new X$(this),this._options=G,this.apiKey=Z,this.authToken=X}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01",...this._options.defaultHeaders}}validateHeaders($,Z){if(this.apiKey&&$["x-api-key"])return;if(Z["x-api-key"]===null)return;if(this.authToken&&$.authorization)return;if(Z.authorization===null)return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}authHeaders($){return{...this.apiKeyAuth($),...this.bearerAuth($)}}apiKeyAuth($){if(this.apiKey==null)return{};return{"X-Api-Key":this.apiKey}}bearerAuth($){if(this.authToken==null)return{};return{Authorization:`Bearer ${this.authToken}`}}}TG=p;p.Anthropic=TG;p.HUMAN_PROMPT=`
206
206
 
207
- Human:`;x.AI_PROMPT=`
207
+ Human:`;p.AI_PROMPT=`
208
208
 
209
- Assistant:`;x.DEFAULT_TIMEOUT=600000;x.AnthropicError=A;x.APIError=u;x.APIConnectionError=o0;x.APIConnectionTimeoutError=Y1;x.APIUserAbortError=i;x.NotFoundError=x2;x.ConflictError=k2;x.RateLimitError=h2;x.BadRequestError=E2;x.AuthenticationError=b2;x.InternalServerError=g2;x.PermissionDeniedError=y2;x.UnprocessableEntityError=f2;x.toFile=BZ;x.fileFromPath=C2;x.Completions=I$;x.Messages=g0;x.Models=$$;x.ModelInfosPage=j$;x.Beta=w0;var fZ=x;function N$($,Z,X){let z=Z.length>0?Z.map((J)=>`- ${J.id}: ${J.name} (${J.source})`).join(`
210
- `):"(no sources provided)",q=Z.map((J)=>`<source id="${J.id}">
209
+ Assistant:`;p.DEFAULT_TIMEOUT=600000;p.AnthropicError=y;p.APIError=e;p.APIConnectionError=s$;p.APIConnectionTimeoutError=X4;p.APIUserAbortError=H0;p.NotFoundError=e6;p.ConflictError=$8;p.RateLimitError=X8;p.BadRequestError=s6;p.AuthenticationError=o6;p.InternalServerError=Y8;p.PermissionDeniedError=t6;p.UnprocessableEntityError=Z8;p.toFile=nY;p.fileFromPath=r6;p.Completions=m1;p.Messages=D$;p.Models=e$;p.ModelInfosPage=l1;p.Beta=X$;var FG=p;function E$($,Z,X){let Y=Z.length>0?Z.map((J)=>`- ${J.id}: ${J.name} (${J.source})`).join(`
210
+ `):"(no sources provided)",G=Z.map((J)=>`<source id="${J.id}">
211
211
  ${J.content.trimEnd()}
212
212
  </source>`).join(`
213
213
 
214
- `),G=X.length>0?`The scenario REQUIRES citations from: ${X.join(", ")}.`:"No specific source is required, but every claim must cite a registered source.";return`You are answering a question about the tool "${$.name}": ${$.description}.
214
+ `),z=X.length>0?`The scenario REQUIRES citations from: ${X.join(", ")}.`:"No specific source is required, but every claim must cite a registered source.";return`You are answering a question about the tool "${$.name}": ${$.description}.
215
215
 
216
216
  Answer using ONLY information from the provided sources below. Do not draw on general knowledge.
217
217
 
218
218
  Available sources:
219
- ${z}
220
-
221
- ${q}
219
+ ${Y}
222
220
 
223
221
  ${G}
224
222
 
223
+ ${z}
224
+
225
225
  End your response with a "## Sources" section that lists every source you actually used. Use this exact format:
226
226
 
227
227
  ## Sources
@@ -231,28 +231,51 @@ End your response with a "## Sources" section that lists every source you actual
231
231
  Rules:
232
232
  - Only cite IDs that appear in the inventory above. Do not invent IDs.
233
233
  - If you cannot answer from the provided sources, say so explicitly and write an empty "## Sources" section (just the heading, no bullets).
234
- - The "## Sources" heading must be the last heading in your response.`}class Y5{category="api";provider="anthropic";name;config;clientFactory;constructor($,Z,X){this.name=$,this.config=Z,this.clientFactory=X??(()=>new fZ)}async run($,Z){let{tool:X,docs:z,requiredSources:q}=Z;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let G=N$(X,z,q),Q=await this.clientFactory().messages.create({model:this.config.model,max_tokens:this.config.maxTokens??4096,temperature:this.config.temperature??0,system:G,messages:[{role:"user",content:$}]}),Y=fW(Q.content);return{response:Y,allResponses:Y?[{type:"final",text:Y}]:[],toolsUsed:[],sources:[],metadata:{model:this.config.model,category:this.category,provider:this.provider,target:this.name}}}}function fW($){if(!Array.isArray($))return"";let Z=[];for(let X of $)if(X.type==="text"&&typeof X.text==="string")Z.push(X.text);return Z.join("")}import{query as hW}from"@anthropic-ai/claude-agent-sdk";function hZ($,Z){let X=Z&&Z.length>0?`
234
+ - The "## Sources" heading must be the last heading in your response.`}function p1($,Z){let X=Z&&Z.length>0?`
235
235
  The canonical source for this question is: ${Z}
236
236
  Use it as the primary reference; consult related authoritative sources if needed.`:`
237
237
  Research the answer using authoritative sources you can reach with your tools.`;return`You are answering a question about the tool "${$.name}": ${$.description}.
238
238
 
239
239
  Use the tools available to you to research the answer. Be specific and accurate; do not invent facts.${X}
240
240
 
241
- If you cannot find the answer with the available tools, say so explicitly rather than guessing.`}class H5{category="cli";provider="claude-code";name;config;constructor($,Z){this.name=$,this.config=Z}async run($,Z){let{tool:X,cwd:z,context:q,docs:G,requiredSources:J,discovery:Q,restrictBuiltinTools:Y}=Z,H=[],W=[],U=Q?hZ(X,Q.sourceHint):N$(X,G,J),V={cwd:z,model:this.config.model??"sonnet",systemPrompt:U,allowedTools:q?.allowedTools??this.config.allowedTools??w4,disallowedTools:q?.disallowedTools??this.config.disallowedTools??P4,permissionMode:this.config.permissionMode??"acceptEdits",maxTurns:this.config.maxTurns??10,maxThinkingTokens:this.config.maxThinkingTokens,maxBudgetUsd:this.config.maxBudgetUsd,mcpServers:q?.mcpServers??this.config.mcpServers,settingSources:[]};if(Y!==void 0)V.tools=Y;let B=[],T="",K="";for await(let L of hW({prompt:$,options:V})){if(L.type==="assistant"){let D=L.message?.content;if(Array.isArray(D)){let _="";for(let O of D){if(O.type==="text")_+=O.text;if(O.type==="tool_use"){let w=O;if(!H.includes(w.name))H.push(w.name)}}if(_){let O=B.length===0?"initial":"intermediate";B.push({type:O,text:_}),T=_}}}if(L.type==="result"){let D=L;if(D.result)K=D.result}}if(B.length>0)B[B.length-1].type="final";return{response:K||T,allResponses:B,toolsUsed:H,sources:W,metadata:{model:this.config.model??"sonnet",category:this.category,provider:this.provider,target:this.name}}}}import{randomUUID as gW}from"crypto";import{rm as vW}from"fs/promises";import{tmpdir as uW}from"os";import{join as mW}from"path";var dW="codex";class U5{category="cli";provider="codex-cli";name;config;spawnFn;readFileFn;binary;constructor($,Z,X={}){this.name=$,this.config=Z,this.spawnFn=X.spawn??iW,this.readFileFn=X.readFile??aW,this.binary=X.binary??dW}async run($,Z){let{tool:X,cwd:z,docs:q,requiredSources:G}=Z,J=this.config.model;if(!J)throw Error(`CodexCliTarget "${this.name}" requires an explicit model. Validation should have caught this at config load.`);let Y=`${N$(X,q,G)}
241
+ If you cannot find the answer with the available tools, say so explicitly rather than guessing.`}class Y5{category="api";provider="anthropic";name;config;clientFactory;constructor($,Z,X){this.name=$,this.config=Z,this.clientFactory=X??(()=>new FG)}async run($,Z){let{tool:X,docs:Y,requiredSources:G,discovery:z,webTools:J}=Z;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let Q=z?p1(X,z.sourceHint):E$(X,Y,G),W=this.clientFactory(),V=J?.search?[{type:"web_search_20250305",name:"web_search"}]:void 0,K=await W.messages.create({model:this.config.model,max_tokens:this.config.maxTokens??4096,temperature:this.config.temperature??0,system:Q,messages:[{role:"user",content:$}],...V?{tools:V}:{}}),H=PL(K.content),B=DL(K.content);return{response:H,allResponses:H?[{type:"final",text:H}]:[],toolsUsed:B,sources:[],metadata:{model:this.config.model,category:this.category,provider:this.provider,target:this.name}}}}function PL($){if(!Array.isArray($))return"";let Z=[];for(let X of $)if(X.type==="text"&&typeof X.text==="string")Z.push(X.text);return Z.join("")}function DL($){if(!Array.isArray($))return[];let Z=new Set;for(let X of $)if(X.type==="server_tool_use"&&typeof X.name==="string")Z.add(X.name);return Array.from(Z)}function x($,Z,X,Y,G){if(Y==="m")throw TypeError("Private method is not writable");if(Y==="a"&&!G)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!G:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call($,X):G?G.value=X:Z.set($,X),X}function M($,Z,X,Y){if(X==="a"&&!Y)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!Y:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Y:X==="a"?Y.call($):Y?Y.value:Z.get($)}var G5=function(){let{crypto:$}=globalThis;if($?.randomUUID)return G5=$.randomUUID.bind($),$.randomUUID();let Z=new Uint8Array(1),X=$?()=>$.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(Y)=>(+Y^X()&15>>+Y/4).toString(16))};function N4($){return typeof $==="object"&&$!==null&&(("name"in $)&&$.name==="AbortError"||("message"in $)&&String($.message).includes("FetchRequestCanceledException"))}var O4=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null){try{if(Object.prototype.toString.call($)==="[object Error]"){let Z=Error($.message,$.cause?{cause:$.cause}:{});if($.stack)Z.stack=$.stack;if($.cause&&!Z.cause)Z.cause=$.cause;if($.name)Z.name=$.name;return Z}}catch{}try{return Error(JSON.stringify($))}catch{}}return Error($)};class S extends Error{}class r extends S{constructor($,Z,X,Y){super(`${r.makeMessage($,Z,X)}`);this.status=$,this.headers=Y,this.requestID=Y?.get("x-request-id"),this.error=Z;let G=Z;this.code=G?.code,this.param=G?.param,this.type=G?.type}static makeMessage($,Z,X){let Y=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):X;if($&&Y)return`${$} ${Y}`;if($)return`${$} status code (no body)`;if(Y)return Y;return"(no status code or body)"}static generate($,Z,X,Y){if(!$||!Y)return new $1({message:X,cause:O4(Z)});let G=Z?.error;if($===400)return new _4($,G,X,Y);if($===401)return new P4($,G,X,Y);if($===403)return new D4($,G,X,Y);if($===404)return new E4($,G,X,Y);if($===409)return new R4($,G,X,Y);if($===422)return new A4($,G,X,Y);if($===429)return new S4($,G,X,Y);if($>=500)return new C4($,G,X,Y);return new r($,G,X,Y)}}class $0 extends r{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class $1 extends r{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}}class Z1 extends $1{constructor({message:$}={}){super({message:$??"Request timed out."})}}class _4 extends r{}class P4 extends r{}class D4 extends r{}class E4 extends r{}class R4 extends r{}class A4 extends r{}class S4 extends r{}class C4 extends r{}class I4 extends S{constructor(){super("Could not parse response content as the length limit was reached")}}class j4 extends S{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}class G$ extends Error{constructor($){super($)}}class i1 extends r{constructor($,Z,X){let Y="OAuth2 authentication error",G=void 0;if(Z&&typeof Z==="object"){let z=Z;G=z.error;let J=z.error_description;if(J&&typeof J==="string")Y=J;else if(G)Y=G}super($,Z,Y,X);this.error_code=G}}class P8 extends S{constructor($,Z,X){super($);this.provider=Z,this.cause=X}}var RL=/^[a-z][a-z0-9+.-]*:/i,LG=($)=>{return RL.test($)},U0=($)=>(U0=Array.isArray,U0($)),z5=U0;function D8($){if(typeof $!=="object")return{};return $??{}}function J5($){if(!$)return!0;for(let Z in $)return!1;return!0}function wG($,Z){return Object.prototype.hasOwnProperty.call($,Z)}function x4($){return $!=null&&typeof $==="object"&&!Array.isArray($)}var MG=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new S(`${$} must be an integer`);if(Z<0)throw new S(`${$} must be a positive integer`);return Z};var NG=($)=>{try{return JSON.parse($)}catch(Z){return}};var d0=($)=>new Promise((Z)=>setTimeout(Z,$));var R$="6.39.0";var DG=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"};function AL(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}var SL=()=>{let $=AL();if($==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":R$,"X-Stainless-OS":_G(Deno.build.os),"X-Stainless-Arch":OG(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":R$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if($==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":R$,"X-Stainless-OS":_G(globalThis.process.platform??"unknown"),"X-Stainless-Arch":OG(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=CL();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":R$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":R$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function CL(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:X}of $){let Y=X.exec(navigator.userAgent);if(Y){let G=Y[1]||0,z=Y[2]||0,J=Y[3]||0;return{browser:Z,version:`${G}.${z}.${J}`}}}return null}var OG=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},_G=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},PG,EG=()=>{return PG??(PG=SL())};function E8(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function Q5(...$){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...$)}function R8($){let Z=Symbol.asyncIterator in $?$[Symbol.asyncIterator]():$[Symbol.iterator]();return Q5({start(){},async pull(X){let{done:Y,value:G}=await Z.next();if(Y)X.close();else X.enqueue(G)},async cancel(){await Z.return?.()}})}function W5($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let X=await Z.read();if(X?.done)Z.releaseLock();return X}catch(X){throw Z.releaseLock(),X}},async return(){let X=Z.cancel();return Z.releaseLock(),await X,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function V5($){if($===null||typeof $!=="object")return;if($[Symbol.asyncIterator]){await $[Symbol.asyncIterator]().return?.();return}let Z=$.getReader(),X=Z.cancel();Z.releaseLock(),await X}var AG=({headers:$,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};var H5="RFC3986",K5=($)=>String($),B5={RFC1738:($)=>String($).replace(/%20/g,"+"),RFC3986:K5},SG="RFC1738";var A8=($,Z)=>(A8=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),A8($,Z)),c0=(()=>{let $=[];for(let Z=0;Z<256;++Z)$.push("%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase());return $})();var U5=1024,CG=($,Z,X,Y,G)=>{if($.length===0)return $;let z=$;if(typeof $==="symbol")z=Symbol.prototype.toString.call($);else if(typeof $!=="string")z=String($);if(X==="iso-8859-1")return escape(z).replace(/%u[0-9a-f]{4}/gi,function(Q){return"%26%23"+parseInt(Q.slice(2),16)+"%3B"});let J="";for(let Q=0;Q<z.length;Q+=U5){let W=z.length>=U5?z.slice(Q,Q+U5):z,V=[];for(let K=0;K<W.length;++K){let H=W.charCodeAt(K);if(H===45||H===46||H===95||H===126||H>=48&&H<=57||H>=65&&H<=90||H>=97&&H<=122||G===SG&&(H===40||H===41)){V[V.length]=W.charAt(K);continue}if(H<128){V[V.length]=c0[H];continue}if(H<2048){V[V.length]=c0[192|H>>6]+c0[128|H&63];continue}if(H<55296||H>=57344){V[V.length]=c0[224|H>>12]+c0[128|H>>6&63]+c0[128|H&63];continue}K+=1,H=65536+((H&1023)<<10|W.charCodeAt(K)&1023),V[V.length]=c0[240|H>>18]+c0[128|H>>12&63]+c0[128|H>>6&63]+c0[128|H&63]}J+=V.join("")}return J};function IG($){if(!$||typeof $!=="object")return!1;return!!($.constructor&&$.constructor.isBuffer&&$.constructor.isBuffer($))}function q5($,Z){if(U0($)){let X=[];for(let Y=0;Y<$.length;Y+=1)X.push(Z($[Y]));return X}return Z($)}var xG={brackets($){return String($)+"[]"},comma:"comma",indices($,Z){return String($)+"["+Z+"]"},repeat($){return String($)}},kG=function($,Z){Array.prototype.push.apply($,U0(Z)?Z:[Z])},jG,Z0={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:CG,encodeValuesOnly:!1,format:H5,formatter:K5,indices:!1,serializeDate($){return(jG??(jG=Function.prototype.call.bind(Date.prototype.toISOString)))($)},skipNulls:!1,strictNullHandling:!1};function jL($){return typeof $==="string"||typeof $==="number"||typeof $==="boolean"||typeof $==="symbol"||typeof $==="bigint"}var T5={};function bG($,Z,X,Y,G,z,J,Q,W,V,K,H,B,U,F,T,w,O){let N=$,P=O,E=0,I=!1;while((P=P.get(T5))!==void 0&&!I){let k=P.get($);if(E+=1,typeof k<"u")if(k===E)throw RangeError("Cyclic object value");else I=!0;if(typeof P.get(T5)>"u")E=0}if(typeof V==="function")N=V(Z,N);else if(N instanceof Date)N=B?.(N);else if(X==="comma"&&U0(N))N=q5(N,function(k){if(k instanceof Date)return B?.(k);return k});if(N===null){if(z)return W&&!T?W(Z,Z0.encoder,w,"key",U):Z;N=""}if(jL(N)||IG(N)){if(W){let k=T?Z:W(Z,Z0.encoder,w,"key",U);return[F?.(k)+"="+F?.(W(N,Z0.encoder,w,"value",U))]}return[F?.(Z)+"="+F?.(String(N))]}let A=[];if(typeof N>"u")return A;let C;if(X==="comma"&&U0(N)){if(T&&W)N=q5(N,W);C=[{value:N.length>0?N.join(",")||null:void 0}]}else if(U0(V))C=V;else{let k=Object.keys(N);C=K?k.sort(K):k}let D=Q?String(Z).replace(/\./g,"%2E"):String(Z),v=Y&&U0(N)&&N.length===1?D+"[]":D;if(G&&U0(N)&&N.length===0)return v+"[]";for(let k=0;k<C.length;++k){let i=C[k],l=typeof i==="object"&&typeof i.value<"u"?i.value:N[i];if(J&&l===null)continue;let R0=H&&Q?i.replace(/\./g,"%2E"):i,A0=U0(N)?typeof X==="function"?X(v,R0):v:v+(H?"."+R0:"["+R0+"]");O.set($,E);let g$=new WeakMap;g$.set(T5,O),kG(A,bG(l,A0,X,Y,G,z,J,Q,X==="comma"&&T&&U0(N)?null:W,V,K,H,B,U,F,T,w,g$))}return A}function xL($=Z0){if(typeof $.allowEmptyArrays<"u"&&typeof $.allowEmptyArrays!=="boolean")throw TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys<"u"&&typeof $.encodeDotInKeys!=="boolean")throw TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder<"u"&&typeof $.encoder!=="function")throw TypeError("Encoder has to be a function.");let Z=$.charset||Z0.charset;if(typeof $.charset<"u"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let X=H5;if(typeof $.format<"u"){if(!A8(B5,$.format))throw TypeError("Unknown format option provided.");X=$.format}let Y=B5[X],G=Z0.filter;if(typeof $.filter==="function"||U0($.filter))G=$.filter;let z;if($.arrayFormat&&$.arrayFormat in xG)z=$.arrayFormat;else if("indices"in $)z=$.indices?"indices":"repeat";else z=Z0.arrayFormat;if("commaRoundTrip"in $&&typeof $.commaRoundTrip!=="boolean")throw TypeError("`commaRoundTrip` must be a boolean, or absent");let J=typeof $.allowDots>"u"?!!$.encodeDotInKeys===!0?!0:Z0.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix==="boolean"?$.addQueryPrefix:Z0.addQueryPrefix,allowDots:J,allowEmptyArrays:typeof $.allowEmptyArrays==="boolean"?!!$.allowEmptyArrays:Z0.allowEmptyArrays,arrayFormat:z,charset:Z,charsetSentinel:typeof $.charsetSentinel==="boolean"?$.charsetSentinel:Z0.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter>"u"?Z0.delimiter:$.delimiter,encode:typeof $.encode==="boolean"?$.encode:Z0.encode,encodeDotInKeys:typeof $.encodeDotInKeys==="boolean"?$.encodeDotInKeys:Z0.encodeDotInKeys,encoder:typeof $.encoder==="function"?$.encoder:Z0.encoder,encodeValuesOnly:typeof $.encodeValuesOnly==="boolean"?$.encodeValuesOnly:Z0.encodeValuesOnly,filter:G,format:X,formatter:Y,serializeDate:typeof $.serializeDate==="function"?$.serializeDate:Z0.serializeDate,skipNulls:typeof $.skipNulls==="boolean"?$.skipNulls:Z0.skipNulls,sort:typeof $.sort==="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling==="boolean"?$.strictNullHandling:Z0.strictNullHandling}}function fG($,Z={}){let X=$,Y=xL(Z),G,z;if(typeof Y.filter==="function")z=Y.filter,X=z("",X);else if(U0(Y.filter))z=Y.filter,G=z;let J=[];if(typeof X!=="object"||X===null)return"";let Q=xG[Y.arrayFormat],W=Q==="comma"&&Y.commaRoundTrip;if(!G)G=Object.keys(X);if(Y.sort)G.sort(Y.sort);let V=new WeakMap;for(let B=0;B<G.length;++B){let U=G[B];if(Y.skipNulls&&X[U]===null)continue;kG(J,bG(X[U],U,Q,W,Y.allowEmptyArrays,Y.strictNullHandling,Y.skipNulls,Y.encodeDotInKeys,Y.encode?Y.encoder:null,Y.filter,Y.sort,Y.allowDots,Y.serializeDate,Y.format,Y.formatter,Y.encodeValuesOnly,Y.charset,V))}let K=J.join(Y.delimiter),H=Y.addQueryPrefix===!0?"?":"";if(Y.charsetSentinel)if(Y.charset==="iso-8859-1")H+="utf8=%26%2310003%3B&";else H+="utf8=%E2%9C%93&";return K.length>0?H+K:""}function yG($){return fG($,{arrayFormat:"brackets"})}function hG($){let Z=0;for(let G of $)Z+=G.length;let X=new Uint8Array(Z),Y=0;for(let G of $)X.set(G,Y),Y+=G.length;return X}var gG;function a1($){let Z;return(gG??(Z=new globalThis.TextEncoder,gG=Z.encode.bind(Z)))($)}var vG;function F5($){let Z;return(vG??(Z=new globalThis.TextDecoder,vG=Z.decode.bind(Z)))($)}var _0,P0;class n1{constructor(){_0.set(this,void 0),P0.set(this,void 0),x(this,_0,new Uint8Array,"f"),x(this,P0,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?a1($):$;x(this,_0,hG([M(this,_0,"f"),Z]),"f");let X=[],Y;while((Y=bL(M(this,_0,"f"),M(this,P0,"f")))!=null){if(Y.carriage&&M(this,P0,"f")==null){x(this,P0,Y.index,"f");continue}if(M(this,P0,"f")!=null&&(Y.index!==M(this,P0,"f")+1||Y.carriage)){X.push(F5(M(this,_0,"f").subarray(0,M(this,P0,"f")-1))),x(this,_0,M(this,_0,"f").subarray(M(this,P0,"f")),"f"),x(this,P0,null,"f");continue}let G=M(this,P0,"f")!==null?Y.preceding-1:Y.preceding,z=F5(M(this,_0,"f").subarray(0,G));X.push(z),x(this,_0,M(this,_0,"f").subarray(Y.index),"f"),x(this,P0,null,"f")}return X}flush(){if(!M(this,_0,"f").length)return[];return this.decode(`
242
+ `)}}_0=new WeakMap,P0=new WeakMap;n1.NEWLINE_CHARS=new Set([`
243
+ `,"\r"]);n1.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function bL($,Z){for(let G=Z??0;G<$.length;G++){if($[G]===10)return{preceding:G,index:G+1,carriage:!1};if($[G]===13)return{preceding:G,index:G+1,carriage:!0}}return null}function uG($){for(let Y=0;Y<$.length-1;Y++){if($[Y]===10&&$[Y+1]===10)return Y+2;if($[Y]===13&&$[Y+1]===13)return Y+2;if($[Y]===13&&$[Y+1]===10&&Y+3<$.length&&$[Y+2]===13&&$[Y+3]===10)return Y+4}return-1}var C8={off:0,error:200,warn:300,info:400,debug:500},L5=($,Z,X)=>{if(!$)return;if(wG(C8,$))return $;s(X).warn(`${Z} was set to ${JSON.stringify($)}, expected one of ${JSON.stringify(Object.keys(C8))}`);return};function k4(){}function S8($,Z,X){if(!Z||C8[$]>C8[X])return k4;else return Z[$].bind(Z)}var fL={error:k4,warn:k4,info:k4,debug:k4},mG=new WeakMap;function s($){let Z=$.logger,X=$.logLevel??"off";if(!Z)return fL;let Y=mG.get(Z);if(Y&&Y[0]===X)return Y[1];let G={error:S8("error",Z,X),warn:S8("warn",Z,X),info:S8("info",Z,X),debug:S8("debug",Z,X)};return mG.set(Z,[X,G]),G}var z$=($)=>{if($.options)$.options={...$.options},delete $.options.headers;if($.headers)$.headers=Object.fromEntries(($.headers instanceof Headers?[...$.headers]:Object.entries($.headers)).map(([Z,X])=>[Z,Z.toLowerCase()==="authorization"||Z.toLowerCase()==="api-key"||Z.toLowerCase()==="x-api-key"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":X]));if("retryOfRequestLogID"in $){if($.retryOfRequestLogID)$.retryOf=$.retryOfRequestLogID;delete $.retryOfRequestLogID}return $};var b4;class D0{constructor($,Z,X){this.iterator=$,b4.set(this,void 0),this.controller=Z,x(this,b4,X,"f")}static fromSSEResponse($,Z,X,Y){let G=!1,z=X?s(X):console;async function*J(){if(G)throw new S("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");G=!0;let Q=!1;try{for await(let W of yL($,Z)){if(Q)continue;if(W.data.startsWith("[DONE]")){Q=!0;continue}if(W.event===null||!W.event.startsWith("thread.")){let V;try{V=JSON.parse(W.data)}catch(K){throw z.error("Could not parse message into JSON:",W.data),z.error("From chunk:",W.raw),K}if(V&&V.error)throw new r(void 0,V.error,void 0,$.headers);yield Y?{event:W.event,data:V}:V}else{let V;try{V=JSON.parse(W.data)}catch(K){throw console.error("Could not parse message into JSON:",W.data),console.error("From chunk:",W.raw),K}if(W.event=="error")throw new r(void 0,V.error,V.message,void 0);yield{event:W.event,data:V}}}Q=!0}catch(W){if(N4(W))return;throw W}finally{if(!Q)Z.abort()}}return new D0(J,Z,X)}static fromReadableStream($,Z,X){let Y=!1;async function*G(){let J=new n1,Q=W5($);for await(let W of Q)for(let V of J.decode(W))yield V;for(let W of J.flush())yield W}async function*z(){if(Y)throw new S("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");Y=!0;let J=!1;try{for await(let Q of G()){if(J)continue;if(Q)yield JSON.parse(Q)}J=!0}catch(Q){if(N4(Q))return;throw Q}finally{if(!J)Z.abort()}}return new D0(z,Z,X)}[(b4=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let $=[],Z=[],X=this.iterator(),Y=(G)=>{return{next:()=>{if(G.length===0){let z=X.next();$.push(z),Z.push(z)}return G.shift()}}};return[new D0(()=>Y($),this.controller,M(this,b4,"f")),new D0(()=>Y(Z),this.controller,M(this,b4,"f"))]}toReadableStream(){let $=this,Z;return Q5({async start(){Z=$[Symbol.asyncIterator]()},async pull(X){try{let{value:Y,done:G}=await Z.next();if(G)return X.close();let z=a1(JSON.stringify(Y)+`
244
+ `);X.enqueue(z)}catch(Y){X.error(Y)}},async cancel(){await Z.return?.()}})}}async function*yL($,Z){if(!$.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new S("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new S("Attempted to iterate over a response with no body")}let X=new dG,Y=new n1,G=W5($.body);for await(let z of gL(G))for(let J of Y.decode(z)){let Q=X.decode(J);if(Q)yield Q}for(let z of Y.flush()){let J=X.decode(z);if(J)yield J}}async function*gL($){let Z=new Uint8Array;for await(let X of $){if(X==null)continue;let Y=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?a1(X):X,G=new Uint8Array(Z.length+Y.length);G.set(Z),G.set(Y,Z.length),Z=G;let z;while((z=uG(Z))!==-1)yield Z.slice(0,z),Z=Z.slice(z)}if(Z.length>0)yield Z}class dG{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let G={event:this.event,data:this.data.join(`
245
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],G}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,X,Y]=vL($,":");if(Y.startsWith(" "))Y=Y.substring(1);if(Z==="event")this.event=Y;else if(Z==="data")this.data.push(Y);return null}}function vL($,Z){let X=$.indexOf(Z);if(X!==-1)return[$.substring(0,X),Z,$.substring(X+Z.length)];return[$,"",""]}async function I8($,Z){let{response:X,requestLogID:Y,retryOfRequestLogID:G,startTime:z}=Z,J=await(async()=>{if(Z.options.stream){if(s($).debug("response",X.status,X.url,X.headers,X.body),Z.options.__streamClass)return Z.options.__streamClass.fromSSEResponse(X,Z.controller,$,Z.options.__synthesizeEventData);return D0.fromSSEResponse(X,Z.controller,$,Z.options.__synthesizeEventData)}if(X.status===204)return null;if(Z.options.__binaryResponse)return X;let W=X.headers.get("content-type")?.split(";")[0]?.trim();if(W?.includes("application/json")||W?.endsWith("+json")){if(X.headers.get("content-length")==="0")return;let B=await X.json();return w5(B,X)}return await X.text()})();return s($).debug(`[${Y}] response parsed`,z$({retryOfRequestLogID:G,url:X.url,status:X.status,body:J,durationMs:Date.now()-z})),J}function w5($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("x-request-id"),enumerable:!1})}var f4;class X1 extends Promise{constructor($,Z,X=I8){super((Y)=>{Y(null)});this.responsePromise=Z,this.parseResponse=X,f4.set(this,void 0),x(this,f4,$,"f")}_thenUnwrap($){return new X1(M(this,f4,"f"),this.responsePromise,async(Z,X)=>w5($(await this.parseResponse(Z,X),X),X.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:Z,request_id:Z.headers.get("x-request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(($)=>this.parseResponse(M(this,f4,"f"),$));return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}f4=new WeakMap;var j8;class y4{constructor($,Z,X,Y){j8.set(this,void 0),x(this,j8,$,"f"),this.options=Y,this.response=Z,this.body=X}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let $=this.nextPageRequestOptions();if(!$)throw new S("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await M(this,j8,"f").requestAPIList(this.constructor,$)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(j8=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}}class x8 extends X1{constructor($,Z,X){super($,Z,async(Y,G)=>new X(Y,G.response,await I8(Y,G),G.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}}class L0 extends y4{constructor($,Z,X,Y){super($,Z,X,Y);this.data=X.data||[],this.object=X.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}}class f extends y4{constructor($,Z,X,Y){super($,Z,X,Y);this.data=X.data||[],this.has_more=X.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let $=this.getPaginatedItems(),Z=$[$.length-1]?.id;if(!Z)return null;return{...this.options,query:{...D8(this.options.query),after:Z}}}}class d extends y4{constructor($,Z,X,Y){super($,Z,X,Y);this.data=X.data||[],this.has_more=X.has_more||!1,this.last_id=X.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let $=this.last_id;if(!$)return null;return{...this.options,query:{...D8(this.options.query),after:$}}}}class X0 extends y4{constructor($,Z,X,Y){super($,Z,X,Y);this.data=X.data||[],this.has_more=X.has_more||!1,this.next=X.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){let $=this.next;if(!$)return null;return{...this.options,query:{...D8(this.options.query),after:$}}}}var uL={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},mL="urn:ietf:params:oauth:grant-type:token-exchange";class M5{constructor($,Z){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl="https://auth.openai.com/oauth/token",this.config=$,this.fetch=Z??E8()}async getToken(){if(!this.cachedToken||this.isTokenExpired(this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.refreshPromise}finally{this.refreshPromise=null}}if(this.needsRefresh(this.cachedToken)&&!this.refreshPromise)this.refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null});return this.cachedToken.token}async refreshToken(){let $=await this.config.provider.getToken(),Z={grant_type:mL,subject_token:$,subject_token_type:uL[this.config.provider.tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId};if(this.config.clientId)Z.client_id=this.config.clientId;let X=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)});if(!X.ok){let J=await X.text(),Q=void 0;try{Q=JSON.parse(J)}catch{}if(X.status===400||X.status===401||X.status===403)throw new i1(X.status,Q,X.headers);throw r.generate(X.status,Q,`Token exchange failed with status ${X.status}`,X.headers)}let Y=await X.json(),G=Y.expires_in||3600,z=Date.now()+G*1000;return this.cachedToken={token:Y.access_token,expiresAt:z},Y.access_token}isTokenExpired($){return Date.now()>=$.expiresAt}needsRefresh($){let X=(this.config.refreshBufferSeconds??1200)*1000;return Date.now()>=$.expiresAt-X}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}}var _5=()=>{if(typeof File>"u"){let{process:$}=globalThis,Z=typeof $?.versions?.node==="string"&&parseInt($.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Z?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function r1($,Z,X){return _5(),new File($,Z??"unknown_file",X)}function g4($){return(typeof $==="object"&&$!==null&&(("name"in $)&&$.name&&String($.name)||("url"in $)&&$.url&&String($.url)||("filename"in $)&&$.filename&&String($.filename)||("path"in $)&&$.path&&String($.path))||"").split(/[\\/]/).pop()||void 0}var k8=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",A$=async($,Z)=>{if(!N5($.body))return $;return{...$,body:await lG($.body,Z)}},q0=async($,Z)=>{return{...$,body:await lG($.body,Z)}},cG=new WeakMap;function dL($){let Z=typeof $==="function"?$:$.fetch,X=cG.get(Z);if(X)return X;let Y=(async()=>{try{let G="Response"in Z?Z.Response:(await Z("data:,")).constructor,z=new FormData;if(z.toString()===await new G(z).text())return!1;return!0}catch{return!0}})();return cG.set(Z,Y),Y}var lG=async($,Z)=>{if(!await dL(Z))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let X=new FormData;return await Promise.all(Object.entries($||{}).map(([Y,G])=>O5(X,Y,G))),X},pG=($)=>$ instanceof Blob&&("name"in $),cL=($)=>typeof $==="object"&&$!==null&&($ instanceof Response||k8($)||pG($)),N5=($)=>{if(cL($))return!0;if(Array.isArray($))return $.some(N5);if($&&typeof $==="object"){for(let Z in $)if(N5($[Z]))return!0}return!1},O5=async($,Z,X)=>{if(X===void 0)return;if(X==null)throw TypeError(`Received null for "${Z}"; to pass null in FormData, you must use the string 'null'`);if(typeof X==="string"||typeof X==="number"||typeof X==="boolean")$.append(Z,String(X));else if(X instanceof Response)$.append(Z,r1([await X.blob()],g4(X)));else if(k8(X))$.append(Z,r1([await new Response(R8(X)).blob()],g4(X)));else if(pG(X))$.append(Z,X,g4(X));else if(Array.isArray(X))await Promise.all(X.map((Y)=>O5($,Z+"[]",Y)));else if(typeof X==="object")await Promise.all(Object.entries(X).map(([Y,G])=>O5($,`${Z}[${Y}]`,G)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${X} instead`)};var iG=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",lL=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&iG($),pL=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function";async function b8($,Z,X){if(_5(),$=await $,lL($)){if($ instanceof File)return $;return r1([await $.arrayBuffer()],$.name)}if(pL($)){let G=await $.blob();return Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()),r1(await P5(G),Z,X)}let Y=await P5($);if(Z||(Z=g4($)),!X?.type){let G=Y.find((z)=>typeof z==="object"&&("type"in z)&&z.type);if(typeof G==="string")X={...X,type:G}}return r1(Y,Z,X)}async function P5($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(iG($))Z.push($ instanceof Blob?$:await $.arrayBuffer());else if(k8($))for await(let X of $)Z.push(...await P5(X));else{let X=$?.constructor?.name;throw Error(`Unexpected data type: ${typeof $}${X?`; constructor: ${X}`:""}${iL($)}`)}return Z}function iL($){if(typeof $!=="object"||$===null)return"";return`; props: [${Object.getOwnPropertyNames($).map((X)=>`"${X}"`).join(", ")}]`}class L{constructor($){this._client=$}}function nG($){return $.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var aG=Object.freeze(Object.create(null)),nL=($=nG)=>function(X,...Y){if(X.length===1)return X[0];let G=!1,z=[],J=X.reduce((K,H,B)=>{if(/[?#]/.test(H))G=!0;let U=Y[B],F=(G?encodeURIComponent:$)(""+U);if(B!==Y.length&&(U==null||typeof U==="object"&&U.toString===Object.getPrototypeOf(Object.getPrototypeOf(U.hasOwnProperty??aG)??aG)?.toString))F=U+"",z.push({start:K.length+H.length,length:F.length,error:`Value of type ${Object.prototype.toString.call(U).slice(8,-1)} is not a valid path parameter`});return K+H+(B===Y.length?"":F)},""),Q=J.split(/[?#]/,1)[0],W=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,V;while((V=W.exec(Q))!==null)z.push({start:V.index,length:V[0].length,error:`Value "${V[0]}" can't be safely passed as a path parameter`});if(z.sort((K,H)=>K.start-H.start),z.length>0){let K=0,H=z.reduce((B,U)=>{let F=" ".repeat(U.start-K),T="^".repeat(U.length);return K=U.start+U.length,B+F+T},"");throw new S(`Path parameters result in path with invalid segments:
246
+ ${z.map((B)=>B.error).join(`
247
+ `)}
248
+ ${J}
249
+ ${H}`)}return J},q=nL(nG);class s1 extends L{list($,Z={},X){return this._client.getAPIList(q`/chat/completions/${$}/messages`,f,{query:Z,...X,__security:{bearerAuth:!0}})}}function v4($){return $!==void 0&&"function"in $&&$.function!==void 0}function h4($){return $?.$brand==="auto-parseable-response-format"}function Y1($){return $?.$brand==="auto-parseable-tool"}function rG($,Z){if(!Z||!D5(Z))return{...$,choices:$.choices.map((X)=>{return oG(X.message.tool_calls),{...X,message:{...X.message,parsed:null,...X.message.tool_calls?{tool_calls:X.message.tool_calls}:void 0}}})};return u4($,Z)}function u4($,Z){let X=$.choices.map((Y)=>{if(Y.finish_reason==="length")throw new I4;if(Y.finish_reason==="content_filter")throw new j4;return oG(Y.message.tool_calls),{...Y,message:{...Y.message,...Y.message.tool_calls?{tool_calls:Y.message.tool_calls?.map((G)=>tL(Z,G))??void 0}:void 0,parsed:Y.message.content&&!Y.message.refusal?oL(Z,Y.message.content):null}}});return{...$,choices:X}}function oL($,Z){if($.response_format?.type!=="json_schema")return null;if($.response_format?.type==="json_schema"){if("$parseRaw"in $.response_format)return $.response_format.$parseRaw(Z);return JSON.parse(Z)}return null}function tL($,Z){let X=$.tools?.find((Y)=>v4(Y)&&Y.function?.name===Z.function.name);return{...Z,function:{...Z.function,parsed_arguments:Y1(X)?X.$parseRaw(Z.function.arguments):X?.function.strict?JSON.parse(Z.function.arguments):null}}}function sG($,Z){if(!$||!("tools"in $)||!$.tools)return!1;let X=$.tools?.find((Y)=>v4(Y)&&Y.function?.name===Z.function.name);return v4(X)&&(Y1(X)||X?.function.strict||!1)}function D5($){if(h4($.response_format))return!0;return $.tools?.some((Z)=>Y1(Z)||Z.type==="function"&&Z.function.strict===!0)??!1}function oG($){for(let Z of $||[])if(Z.type!=="function")throw new S(`Currently only \`function\` tool calls are supported; Received \`${Z.type}\``)}function tG($){for(let Z of $??[]){if(Z.type!=="function")throw new S(`Currently only \`function\` tool types support auto-parsing; Received \`${Z.type}\``);if(Z.function.strict!==!0)throw new S(`The \`${Z.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}var o1=($)=>{return $?.role==="assistant"},E5=($)=>{return $?.role==="tool"};var R5,f8,y8,m4,d4,g8,c4,J$,l4,v8,h8,t1,eG;class G1{constructor(){R5.add(this),this.controller=new AbortController,f8.set(this,void 0),y8.set(this,()=>{}),m4.set(this,()=>{}),d4.set(this,void 0),g8.set(this,()=>{}),c4.set(this,()=>{}),J$.set(this,{}),l4.set(this,!1),v8.set(this,!1),h8.set(this,!1),t1.set(this,!1),x(this,f8,new Promise(($,Z)=>{x(this,y8,$,"f"),x(this,m4,Z,"f")}),"f"),x(this,d4,new Promise(($,Z)=>{x(this,g8,$,"f"),x(this,c4,Z,"f")}),"f"),M(this,f8,"f").catch(()=>{}),M(this,d4,"f").catch(()=>{})}_run($){setTimeout(()=>{$().then(()=>{this._emitFinal(),this._emit("end")},M(this,R5,"m",eG).bind(this))},0)}_connected(){if(this.ended)return;M(this,y8,"f").call(this),this._emit("connect")}get ended(){return M(this,l4,"f")}get errored(){return M(this,v8,"f")}get aborted(){return M(this,h8,"f")}abort(){this.controller.abort()}on($,Z){return(M(this,J$,"f")[$]||(M(this,J$,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=M(this,J$,"f")[$];if(!X)return this;let Y=X.findIndex((G)=>G.listener===Z);if(Y>=0)X.splice(Y,1);return this}once($,Z){return(M(this,J$,"f")[$]||(M(this,J$,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(x(this,t1,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){x(this,t1,!0,"f"),await M(this,d4,"f")}_emit($,...Z){if(M(this,l4,"f"))return;if($==="end")x(this,l4,!0,"f"),M(this,g8,"f").call(this);let X=M(this,J$,"f")[$];if(X)M(this,J$,"f")[$]=X.filter((Y)=>!Y.once),X.forEach(({listener:Y})=>Y(...Z));if($==="abort"){let Y=Z[0];if(!M(this,t1,"f")&&!X?.length)Promise.reject(Y);M(this,m4,"f").call(this,Y),M(this,c4,"f").call(this,Y),this._emit("end");return}if($==="error"){let Y=Z[0];if(!M(this,t1,"f")&&!X?.length)Promise.reject(Y);M(this,m4,"f").call(this,Y),M(this,c4,"f").call(this,Y),this._emit("end")}}_emitFinal(){}}f8=new WeakMap,y8=new WeakMap,m4=new WeakMap,d4=new WeakMap,g8=new WeakMap,c4=new WeakMap,J$=new WeakMap,l4=new WeakMap,v8=new WeakMap,h8=new WeakMap,t1=new WeakMap,R5=new WeakSet,eG=function(Z){if(x(this,v8,!0,"f"),Z instanceof Error&&Z.name==="AbortError")Z=new $0;if(Z instanceof $0)return x(this,h8,!0,"f"),this._emit("abort",Z);if(Z instanceof S)return this._emit("error",Z);if(Z instanceof Error){let X=new S(Z.message);return X.cause=Z,this._emit("error",X)}return this._emit("error",new S(String(Z)))};function $z($){return typeof $.parse==="function"}var w0,A5,u8,S5,C5,I5,Zz,Xz,eL=10;class p4 extends G1{constructor(){super(...arguments);w0.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion($){this._chatCompletions.push($),this._emit("chatCompletion",$);let Z=$.choices[0]?.message;if(Z)this._addMessage(Z);return $}_addMessage($,Z=!0){if(!("content"in $))$.content=null;if(this.messages.push($),Z){if(this._emit("message",$),E5($)&&$.content)this._emit("functionToolCallResult",$.content);else if(o1($)&&$.tool_calls){for(let X of $.tool_calls)if(X.type==="function")this._emit("functionToolCall",X.function)}}}async finalChatCompletion(){await this.done();let $=this._chatCompletions[this._chatCompletions.length-1];if(!$)throw new S("stream ended without producing a ChatCompletion");return $}async finalContent(){return await this.done(),M(this,w0,"m",A5).call(this)}async finalMessage(){return await this.done(),M(this,w0,"m",u8).call(this)}async finalFunctionToolCall(){return await this.done(),M(this,w0,"m",S5).call(this)}async finalFunctionToolCallResult(){return await this.done(),M(this,w0,"m",C5).call(this)}async totalUsage(){return await this.done(),M(this,w0,"m",I5).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){let $=this._chatCompletions[this._chatCompletions.length-1];if($)this._emit("finalChatCompletion",$);let Z=M(this,w0,"m",u8).call(this);if(Z)this._emit("finalMessage",Z);let X=M(this,w0,"m",A5).call(this);if(X)this._emit("finalContent",X);let Y=M(this,w0,"m",S5).call(this);if(Y)this._emit("finalFunctionToolCall",Y);let G=M(this,w0,"m",C5).call(this);if(G!=null)this._emit("finalFunctionToolCallResult",G);if(this._chatCompletions.some((z)=>z.usage))this._emit("totalUsage",M(this,w0,"m",I5).call(this))}async _createChatCompletion($,Z,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}M(this,w0,"m",Zz).call(this,Z);let G=await $.chat.completions.create({...Z,stream:!1},{...X,signal:this.controller.signal});return this._connected(),this._addChatCompletion(u4(G,Z))}async _runChatCompletion($,Z,X){for(let Y of Z.messages)this._addMessage(Y,!1);return await this._createChatCompletion($,Z,X)}async _runTools($,Z,X){let{tool_choice:G="auto",stream:z,...J}=Z,Q=typeof G!=="string"&&G.type==="function"&&G?.function?.name,{maxChatCompletions:W=eL}=X||{},V=Z.tools.map((B)=>{if(Y1(B)){if(!B.$callback)throw new S("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:B.$callback,name:B.function.name,description:B.function.description||"",parameters:B.function.parameters,parse:B.$parseRaw,strict:!0}}}return B}),K={};for(let B of V)if(B.type==="function")K[B.function.name||B.function.function.name]=B.function;let H="tools"in Z?V.map((B)=>B.type==="function"?{type:"function",function:{name:B.function.name||B.function.function.name,parameters:B.function.parameters,description:B.function.description,strict:B.function.strict}}:B):void 0;for(let B of Z.messages)this._addMessage(B,!1);for(let B=0;B<W;++B){let F=(await this._createChatCompletion($,{...J,tool_choice:G,tools:H,messages:[...this.messages]},X)).choices[0]?.message;if(!F)throw new S("missing message in ChatCompletion response");if(!F.tool_calls?.length)return;for(let T of F.tool_calls){if(T.type!=="function")continue;let w=T.id,{name:O,arguments:N}=T.function,P=K[O];if(!P){let C=`Invalid tool_call: ${JSON.stringify(O)}. Available options are: ${Object.keys(K).map((D)=>JSON.stringify(D)).join(", ")}. Please try again`;this._addMessage({role:"tool",tool_call_id:w,content:C});continue}else if(Q&&Q!==O){let C=`Invalid tool_call: ${JSON.stringify(O)}. ${JSON.stringify(Q)} requested. Please try again`;this._addMessage({role:"tool",tool_call_id:w,content:C});continue}let E;try{E=$z(P)?await P.parse(N):N}catch(C){let D=C instanceof Error?C.message:String(C);this._addMessage({role:"tool",tool_call_id:w,content:D});continue}let I=await P.function(E,this),A=M(this,w0,"m",Xz).call(this,I);if(this._addMessage({role:"tool",tool_call_id:w,content:A}),Q)return}}return}}w0=new WeakSet,A5=function(){return M(this,w0,"m",u8).call(this).content??null},u8=function(){let Z=this.messages.length;while(Z-- >0){let X=this.messages[Z];if(o1(X))return{...X,content:X.content??null,refusal:X.refusal??null}}throw new S("stream ended without producing a ChatCompletionMessage with role=assistant")},S5=function(){for(let Z=this.messages.length-1;Z>=0;Z--){let X=this.messages[Z];if(o1(X)&&X?.tool_calls?.length)return X.tool_calls.filter((Y)=>Y.type==="function").at(-1)?.function}return},C5=function(){for(let Z=this.messages.length-1;Z>=0;Z--){let X=this.messages[Z];if(E5(X)&&X.content!=null&&typeof X.content==="string"&&this.messages.some((Y)=>Y.role==="assistant"&&Y.tool_calls?.some((G)=>G.type==="function"&&G.id===X.tool_call_id)))return X.content}return},I5=function(){let Z={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(let{usage:X}of this._chatCompletions)if(X)Z.completion_tokens+=X.completion_tokens,Z.prompt_tokens+=X.prompt_tokens,Z.total_tokens+=X.total_tokens;return Z},Zz=function(Z){if(Z.n!=null&&Z.n>1)throw new S("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},Xz=function(Z){return typeof Z==="string"?Z:Z===void 0?"undefined":JSON.stringify(Z)};class i4 extends p4{static runTools($,Z,X){let Y=new i4,G={...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"runTools"}};return Y._run(()=>Y._runTools($,Z,G)),Y}_addMessage($,Z=!0){if(super._addMessage($,Z),o1($)&&$.content)this._emit("content",$.content)}}var J0={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,ALL:511};class Yz extends Error{}class Gz extends Error{}function $w($,Z=J0.ALL){if(typeof $!=="string")throw TypeError(`expecting str, got ${typeof $}`);if(!$.trim())throw Error(`${$} is empty`);return Zw($.trim(),Z)}var Zw=($,Z)=>{let X=$.length,Y=0,G=(B)=>{throw new Yz(`${B} at position ${Y}`)},z=(B)=>{throw new Gz(`${B} at position ${Y}`)},J=()=>{if(H(),Y>=X)G("Unexpected end of input");if($[Y]==='"')return Q();if($[Y]==="{")return W();if($[Y]==="[")return V();if($.substring(Y,Y+4)==="null"||J0.NULL&Z&&X-Y<4&&"null".startsWith($.substring(Y)))return Y+=4,null;if($.substring(Y,Y+4)==="true"||J0.BOOL&Z&&X-Y<4&&"true".startsWith($.substring(Y)))return Y+=4,!0;if($.substring(Y,Y+5)==="false"||J0.BOOL&Z&&X-Y<5&&"false".startsWith($.substring(Y)))return Y+=5,!1;if($.substring(Y,Y+8)==="Infinity"||J0.INFINITY&Z&&X-Y<8&&"Infinity".startsWith($.substring(Y)))return Y+=8,1/0;if($.substring(Y,Y+9)==="-Infinity"||J0.MINUS_INFINITY&Z&&1<X-Y&&X-Y<9&&"-Infinity".startsWith($.substring(Y)))return Y+=9,-1/0;if($.substring(Y,Y+3)==="NaN"||J0.NAN&Z&&X-Y<3&&"NaN".startsWith($.substring(Y)))return Y+=3,NaN;return K()},Q=()=>{let B=Y,U=!1;Y++;while(Y<X&&($[Y]!=='"'||U&&$[Y-1]==="\\"))U=$[Y]==="\\"?!U:!1,Y++;if($.charAt(Y)=='"')try{return JSON.parse($.substring(B,++Y-Number(U)))}catch(F){z(String(F))}else if(J0.STR&Z)try{return JSON.parse($.substring(B,Y-Number(U))+'"')}catch(F){return JSON.parse($.substring(B,$.lastIndexOf("\\"))+'"')}G("Unterminated string literal")},W=()=>{Y++,H();let B={};try{while($[Y]!=="}"){if(H(),Y>=X&&J0.OBJ&Z)return B;let U=Q();H(),Y++;try{let F=J();Object.defineProperty(B,U,{value:F,writable:!0,enumerable:!0,configurable:!0})}catch(F){if(J0.OBJ&Z)return B;else throw F}if(H(),$[Y]===",")Y++}}catch(U){if(J0.OBJ&Z)return B;else G("Expected '}' at end of object")}return Y++,B},V=()=>{Y++;let B=[];try{while($[Y]!=="]")if(B.push(J()),H(),$[Y]===",")Y++}catch(U){if(J0.ARR&Z)return B;G("Expected ']' at end of array")}return Y++,B},K=()=>{if(Y===0){if($==="-"&&J0.NUM&Z)G("Not sure what '-' is");try{return JSON.parse($)}catch(U){if(J0.NUM&Z)try{if($[$.length-1]===".")return JSON.parse($.substring(0,$.lastIndexOf(".")));return JSON.parse($.substring(0,$.lastIndexOf("e")))}catch(F){}z(String(U))}}let B=Y;if($[Y]==="-")Y++;while($[Y]&&!",]}".includes($[Y]))Y++;if(Y==X&&!(J0.NUM&Z))G("Unterminated number literal");try{return JSON.parse($.substring(B,Y))}catch(U){if($.substring(B,Y)==="-"&&J0.NUM&Z)G("Not sure what '-' is");try{return JSON.parse($.substring(B,$.lastIndexOf("e")))}catch(F){z(String(F))}}},H=()=>{while(Y<X&&`
250
+ \r `.includes($[Y]))Y++};return J()},j5=($)=>$w($,J0.ALL^J0.NUM);var Y0,Q$,e1,S$,x5,m8,k5,b5,f5,d8,y5,zz;class C$ extends p4{constructor($){super();Y0.add(this),Q$.set(this,void 0),e1.set(this,void 0),S$.set(this,void 0),x(this,Q$,$,"f"),x(this,e1,[],"f")}get currentChatCompletionSnapshot(){return M(this,S$,"f")}static fromReadableStream($){let Z=new C$(null);return Z._run(()=>Z._fromReadableStream($)),Z}static createChatCompletion($,Z,X){let Y=new C$(Z);return Y._run(()=>Y._runChatCompletion($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}async _createChatCompletion($,Z,X){super._createChatCompletion;let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}M(this,Y0,"m",x5).call(this);let G=await $.chat.completions.create({...Z,stream:!0},{...X,signal:this.controller.signal});this._connected();for await(let z of G)M(this,Y0,"m",k5).call(this,z);if(G.controller.signal?.aborted)throw new $0;return this._addChatCompletion(M(this,Y0,"m",d8).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}M(this,Y0,"m",x5).call(this),this._connected();let Y=D0.fromReadableStream($,this.controller),G;for await(let z of Y){if(G&&G!==z.id)this._addChatCompletion(M(this,Y0,"m",d8).call(this));M(this,Y0,"m",k5).call(this,z),G=z.id}if(Y.controller.signal?.aborted)throw new $0;return this._addChatCompletion(M(this,Y0,"m",d8).call(this))}[(Q$=new WeakMap,e1=new WeakMap,S$=new WeakMap,Y0=new WeakSet,x5=function(){if(this.ended)return;x(this,S$,void 0,"f")},m8=function(Z){let X=M(this,e1,"f")[Z.index];if(X)return X;return X={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},M(this,e1,"f")[Z.index]=X,X},k5=function(Z){if(this.ended)return;let X=M(this,Y0,"m",zz).call(this,Z);this._emit("chunk",Z,X);for(let Y of Z.choices){let G=X.choices[Y.index];if(Y.delta.content!=null&&G.message?.role==="assistant"&&G.message?.content)this._emit("content",Y.delta.content,G.message.content),this._emit("content.delta",{delta:Y.delta.content,snapshot:G.message.content,parsed:G.message.parsed});if(Y.delta.refusal!=null&&G.message?.role==="assistant"&&G.message?.refusal)this._emit("refusal.delta",{delta:Y.delta.refusal,snapshot:G.message.refusal});if(Y.logprobs?.content!=null&&G.message?.role==="assistant")this._emit("logprobs.content.delta",{content:Y.logprobs?.content,snapshot:G.logprobs?.content??[]});if(Y.logprobs?.refusal!=null&&G.message?.role==="assistant")this._emit("logprobs.refusal.delta",{refusal:Y.logprobs?.refusal,snapshot:G.logprobs?.refusal??[]});let z=M(this,Y0,"m",m8).call(this,G);if(G.finish_reason){if(M(this,Y0,"m",f5).call(this,G),z.current_tool_call_index!=null)M(this,Y0,"m",b5).call(this,G,z.current_tool_call_index)}for(let J of Y.delta.tool_calls??[]){if(z.current_tool_call_index!==J.index){if(M(this,Y0,"m",f5).call(this,G),z.current_tool_call_index!=null)M(this,Y0,"m",b5).call(this,G,z.current_tool_call_index)}z.current_tool_call_index=J.index}for(let J of Y.delta.tool_calls??[]){let Q=G.message.tool_calls?.[J.index];if(!Q?.type)continue;if(Q?.type==="function")this._emit("tool_calls.function.arguments.delta",{name:Q.function?.name,index:J.index,arguments:Q.function.arguments,parsed_arguments:Q.function.parsed_arguments,arguments_delta:J.function?.arguments??""});else Qz(Q?.type)}}},b5=function(Z,X){if(M(this,Y0,"m",m8).call(this,Z).done_tool_calls.has(X))return;let G=Z.message.tool_calls?.[X];if(!G)throw Error("no tool call snapshot");if(!G.type)throw Error("tool call snapshot missing `type`");if(G.type==="function"){let z=M(this,Q$,"f")?.tools?.find((J)=>v4(J)&&J.function.name===G.function.name);this._emit("tool_calls.function.arguments.done",{name:G.function.name,index:X,arguments:G.function.arguments,parsed_arguments:Y1(z)?z.$parseRaw(G.function.arguments):z?.function.strict?JSON.parse(G.function.arguments):null})}else Qz(G.type)},f5=function(Z){let X=M(this,Y0,"m",m8).call(this,Z);if(Z.message.content&&!X.content_done){X.content_done=!0;let Y=M(this,Y0,"m",y5).call(this);this._emit("content.done",{content:Z.message.content,parsed:Y?Y.$parseRaw(Z.message.content):null})}if(Z.message.refusal&&!X.refusal_done)X.refusal_done=!0,this._emit("refusal.done",{refusal:Z.message.refusal});if(Z.logprobs?.content&&!X.logprobs_content_done)X.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:Z.logprobs.content});if(Z.logprobs?.refusal&&!X.logprobs_refusal_done)X.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:Z.logprobs.refusal})},d8=function(){if(this.ended)throw new S("stream has ended, this shouldn't happen");let Z=M(this,S$,"f");if(!Z)throw new S("request ended without sending any chunks");return x(this,S$,void 0,"f"),x(this,e1,[],"f"),Xw(Z,M(this,Q$,"f"))},y5=function(){let Z=M(this,Q$,"f")?.response_format;if(h4(Z))return Z;return null},zz=function(Z){var X,Y,G,z;let J=M(this,S$,"f"),{choices:Q,...W}=Z;if(!J)J=x(this,S$,{...W,choices:[]},"f");else Object.assign(J,W);for(let{delta:V,finish_reason:K,index:H,logprobs:B=null,...U}of Z.choices){let F=J.choices[H];if(!F)F=J.choices[H]={finish_reason:K,index:H,message:{},logprobs:B,...U};if(B)if(!F.logprobs)F.logprobs=Object.assign({},B);else{let{content:I,refusal:A,...C}=B;if(Jz(C),Object.assign(F.logprobs,C),I)(X=F.logprobs).content??(X.content=[]),F.logprobs.content.push(...I);if(A)(Y=F.logprobs).refusal??(Y.refusal=[]),F.logprobs.refusal.push(...A)}if(K){if(F.finish_reason=K,M(this,Q$,"f")&&D5(M(this,Q$,"f"))){if(K==="length")throw new I4;if(K==="content_filter")throw new j4}}if(Object.assign(F,U),!V)continue;let{content:T,refusal:w,function_call:O,role:N,tool_calls:P,...E}=V;if(Jz(E),Object.assign(F.message,E),w)F.message.refusal=(F.message.refusal||"")+w;if(N)F.message.role=N;if(O)if(!F.message.function_call)F.message.function_call=O;else{if(O.name)F.message.function_call.name=O.name;if(O.arguments)(G=F.message.function_call).arguments??(G.arguments=""),F.message.function_call.arguments+=O.arguments}if(T){if(F.message.content=(F.message.content||"")+T,!F.message.refusal&&M(this,Y0,"m",y5).call(this))F.message.parsed=j5(F.message.content)}if(P){if(!F.message.tool_calls)F.message.tool_calls=[];for(let{index:I,id:A,type:C,function:D,...v}of P){let k=(z=F.message.tool_calls)[I]??(z[I]={});if(Object.assign(k,v),A)k.id=A;if(C)k.type=C;if(D)k.function??(k.function={name:D.name??"",arguments:""});if(D?.name)k.function.name=D.name;if(D?.arguments){if(k.function.arguments+=D.arguments,sG(M(this,Q$,"f"),k))k.function.parsed_arguments=j5(k.function.arguments)}}}}return J},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("chunk",(Y)=>{let G=Z.shift();if(G)G.resolve(Y);else $.push(Y)}),this.on("end",()=>{X=!0;for(let Y of Z)Y.resolve(void 0);Z.length=0}),this.on("abort",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),this.on("error",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((G,z)=>Z.push({resolve:G,reject:z})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new D0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Xw($,Z){let{id:X,choices:Y,created:G,model:z,system_fingerprint:J,...Q}=$,W={...Q,id:X,choices:Y.map(({message:V,finish_reason:K,index:H,logprobs:B,...U})=>{if(!K)throw new S(`missing finish_reason for choice ${H}`);let{content:F=null,function_call:T,tool_calls:w,...O}=V,N=V.role;if(!N)throw new S(`missing role for choice ${H}`);if(T){let{arguments:P,name:E}=T;if(P==null)throw new S(`missing function_call.arguments for choice ${H}`);if(!E)throw new S(`missing function_call.name for choice ${H}`);return{...U,message:{content:F,function_call:{arguments:P,name:E},role:N,refusal:V.refusal??null},finish_reason:K,index:H,logprobs:B}}if(w)return{...U,index:H,finish_reason:K,logprobs:B,message:{...O,role:N,content:F,refusal:V.refusal??null,tool_calls:w.map((P,E)=>{let{function:I,type:A,id:C,...D}=P,{arguments:v,name:k,...i}=I||{};if(C==null)throw new S(`missing choices[${H}].tool_calls[${E}].id
251
+ ${c8($)}`);if(A==null)throw new S(`missing choices[${H}].tool_calls[${E}].type
252
+ ${c8($)}`);if(k==null)throw new S(`missing choices[${H}].tool_calls[${E}].function.name
253
+ ${c8($)}`);if(v==null)throw new S(`missing choices[${H}].tool_calls[${E}].function.arguments
254
+ ${c8($)}`);return{...D,id:C,type:A,function:{...i,name:k,arguments:v}}})}};return{...U,message:{...O,content:F,role:N,refusal:V.refusal??null},finish_reason:K,index:H,logprobs:B}}),created:G,model:z,object:"chat.completion",...J?{system_fingerprint:J}:{}};return rG(W,Z)}function c8($){return JSON.stringify($)}function Jz($){return}function Qz($){}class $2 extends C${static fromReadableStream($){let Z=new $2(null);return Z._run(()=>Z._fromReadableStream($)),Z}static runTools($,Z,X){let Y=new $2(Z),G={...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"runTools"}};return Y._run(()=>Y._runTools($,Z,G)),Y}}class I$ extends L{constructor(){super(...arguments);this.messages=new s1(this._client)}create($,Z){return this._client.post("/chat/completions",{body:$,...Z,stream:$.stream??!1,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/chat/completions/${$}`,{...Z,__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/chat/completions/${$}`,{body:Z,...X,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/chat/completions",f,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/chat/completions/${$}`,{...Z,__security:{bearerAuth:!0}})}parse($,Z){return tG($.tools),this._client.chat.completions.create($,{...Z,headers:{...Z?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap((X)=>u4(X,$))}runTools($,Z){if($.stream)return $2.runTools(this._client,$,Z);return i4.runTools(this._client,$,Z)}stream($,Z){return C$.createChatCompletion(this._client,$,Z)}}I$.Messages=s1;class z1 extends L{constructor(){super(...arguments);this.completions=new I$(this._client)}}z1.Completions=I$;class a4 extends L{create($,Z){return this._client.post("/organization/admin_api_keys",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z){return this._client.get(q`/organization/admin_api_keys/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/admin_api_keys",f,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/admin_api_keys/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}class n4 extends L{list($={},Z){return this._client.getAPIList("/organization/audit_logs",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}}class r4 extends L{create($,Z){return this._client.post("/organization/certificates",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z={},X){return this._client.get(q`/organization/certificates/${$}`,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/certificates/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/certificates",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/certificates/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}activate($,Z){return this._client.getAPIList("/organization/certificates/activate",L0,{body:$,method:"post",...Z,__security:{adminAPIKeyAuth:!0}})}deactivate($,Z){return this._client.getAPIList("/organization/certificates/deactivate",L0,{body:$,method:"post",...Z,__security:{adminAPIKeyAuth:!0}})}}class s4 extends L{retrieve($){return this._client.get("/organization/data_retention",{...$,__security:{adminAPIKeyAuth:!0}})}update($,Z){return this._client.post("/organization/data_retention",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}}class o4 extends L{create($,Z){return this._client.post("/organization/invites",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z){return this._client.get(q`/organization/invites/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/invites",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/invites/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}class t4 extends L{create($,Z){return this._client.post("/organization/roles",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z){return this._client.get(q`/organization/roles/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/roles/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/roles",X0,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/roles/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}class e4 extends L{create($,Z){return this._client.post("/organization/spend_alerts",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/spend_alerts/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/spend_alerts",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/spend_alerts/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}class $Z extends L{audioSpeeches($,Z){return this._client.get("/organization/usage/audio_speeches",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}audioTranscriptions($,Z){return this._client.get("/organization/usage/audio_transcriptions",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}codeInterpreterSessions($,Z){return this._client.get("/organization/usage/code_interpreter_sessions",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}completions($,Z){return this._client.get("/organization/usage/completions",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}costs($,Z){return this._client.get("/organization/costs",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}embeddings($,Z){return this._client.get("/organization/usage/embeddings",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}fileSearchCalls($,Z){return this._client.get("/organization/usage/file_search_calls",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}images($,Z){return this._client.get("/organization/usage/images",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}moderations($,Z){return this._client.get("/organization/usage/moderations",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}vectorStores($,Z){return this._client.get("/organization/usage/vector_stores",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}webSearchCalls($,Z){return this._client.get("/organization/usage/web_search_calls",{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}}class ZZ extends L{create($,Z,X){return this._client.post(q`/organization/groups/${$}/roles`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{group_id:Y}=Z;return this._client.get(q`/organization/groups/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/groups/${$}/roles`,X0,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{group_id:Y}=Z;return this._client.delete(q`/organization/groups/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class XZ extends L{create($,Z,X){return this._client.post(q`/organization/groups/${$}/users`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{group_id:Y}=Z;return this._client.get(q`/organization/groups/${Y}/users/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/groups/${$}/users`,X0,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{group_id:Y}=Z;return this._client.delete(q`/organization/groups/${Y}/users/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class J1 extends L{constructor(){super(...arguments);this.users=new XZ(this._client),this.roles=new ZZ(this._client)}create($,Z){return this._client.post("/organization/groups",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z){return this._client.get(q`/organization/groups/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/groups/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/groups",X0,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/groups/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}J1.Users=XZ;J1.Roles=ZZ;class YZ extends L{retrieve($,Z,X){let{project_id:Y}=Z;return this._client.get(q`/organization/projects/${Y}/api_keys/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/api_keys`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/organization/projects/${Y}/api_keys/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class GZ extends L{list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/certificates`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}activate($,Z,X){return this._client.getAPIList(q`/organization/projects/${$}/certificates/activate`,L0,{body:Z,method:"post",...X,__security:{adminAPIKeyAuth:!0}})}deactivate($,Z,X){return this._client.getAPIList(q`/organization/projects/${$}/certificates/deactivate`,L0,{body:Z,method:"post",...X,__security:{adminAPIKeyAuth:!0}})}}class zZ extends L{retrieve($,Z){return this._client.get(q`/organization/projects/${$}/data_retention`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/projects/${$}/data_retention`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}}class JZ extends L{retrieve($,Z){return this._client.get(q`/organization/projects/${$}/hosted_tool_permissions`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/projects/${$}/hosted_tool_permissions`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}}class QZ extends L{retrieve($,Z){return this._client.get(q`/organization/projects/${$}/model_permissions`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/projects/${$}/model_permissions`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/projects/${$}/model_permissions`,{...Z,__security:{adminAPIKeyAuth:!0}})}}class WZ extends L{listRateLimits($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/rate_limits`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}updateRateLimit($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/organization/projects/${Y}/rate_limits/${$}`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}}class VZ extends L{create($,Z,X){return this._client.post(q`/projects/${$}/roles`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y}=Z;return this._client.get(q`/projects/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/projects/${Y}/roles/${$}`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/projects/${$}/roles`,X0,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/projects/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class HZ extends L{create($,Z,X){return this._client.post(q`/organization/projects/${$}/service_accounts`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y}=Z;return this._client.get(q`/organization/projects/${Y}/service_accounts/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/organization/projects/${Y}/service_accounts/${$}`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/service_accounts`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/organization/projects/${Y}/service_accounts/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class KZ extends L{create($,Z,X){return this._client.post(q`/organization/projects/${$}/spend_alerts`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/organization/projects/${Y}/spend_alerts/${$}`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/spend_alerts`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/organization/projects/${Y}/spend_alerts/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class BZ extends L{create($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/projects/${Y}/groups/${$}/roles`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y,group_id:G}=Z;return this._client.get(q`/projects/${Y}/groups/${G}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z,X){let{project_id:Y,...G}=Z;return this._client.getAPIList(q`/projects/${Y}/groups/${$}/roles`,X0,{query:G,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y,group_id:G}=Z;return this._client.delete(q`/projects/${Y}/groups/${G}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class Z2 extends L{constructor(){super(...arguments);this.roles=new BZ(this._client)}create($,Z,X){return this._client.post(q`/organization/projects/${$}/groups`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y,...G}=Z;return this._client.get(q`/organization/projects/${Y}/groups/${$}`,{query:G,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/groups`,X0,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/organization/projects/${Y}/groups/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}Z2.Roles=BZ;class UZ extends L{create($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/projects/${Y}/users/${$}/roles`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y,user_id:G}=Z;return this._client.get(q`/projects/${Y}/users/${G}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z,X){let{project_id:Y,...G}=Z;return this._client.getAPIList(q`/projects/${Y}/users/${$}/roles`,X0,{query:G,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y,user_id:G}=Z;return this._client.delete(q`/projects/${Y}/users/${G}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class X2 extends L{constructor(){super(...arguments);this.roles=new UZ(this._client)}create($,Z,X){return this._client.post(q`/organization/projects/${$}/users`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{project_id:Y}=Z;return this._client.get(q`/organization/projects/${Y}/users/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){let{project_id:Y,...G}=Z;return this._client.post(q`/organization/projects/${Y}/users/${$}`,{body:G,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/projects/${$}/users`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{project_id:Y}=Z;return this._client.delete(q`/organization/projects/${Y}/users/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}X2.Roles=UZ;class T0 extends L{constructor(){super(...arguments);this.users=new X2(this._client),this.serviceAccounts=new HZ(this._client),this.apiKeys=new YZ(this._client),this.rateLimits=new WZ(this._client),this.modelPermissions=new QZ(this._client),this.hostedToolPermissions=new JZ(this._client),this.groups=new Z2(this._client),this.roles=new VZ(this._client),this.dataRetention=new zZ(this._client),this.spendAlerts=new KZ(this._client),this.certificates=new GZ(this._client)}create($,Z){return this._client.post("/organization/projects",{body:$,...Z,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z){return this._client.get(q`/organization/projects/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/projects/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/projects",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}archive($,Z){return this._client.post(q`/organization/projects/${$}/archive`,{...Z,__security:{adminAPIKeyAuth:!0}})}}T0.Users=X2;T0.ServiceAccounts=HZ;T0.APIKeys=YZ;T0.RateLimits=WZ;T0.ModelPermissions=QZ;T0.HostedToolPermissions=JZ;T0.Groups=Z2;T0.Roles=VZ;T0.DataRetention=zZ;T0.SpendAlerts=KZ;T0.Certificates=GZ;class qZ extends L{create($,Z,X){return this._client.post(q`/organization/users/${$}/roles`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z,X){let{user_id:Y}=Z;return this._client.get(q`/organization/users/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/organization/users/${$}/roles`,X0,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{user_id:Y}=Z;return this._client.delete(q`/organization/users/${Y}/roles/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class Y2 extends L{constructor(){super(...arguments);this.roles=new qZ(this._client)}retrieve($,Z){return this._client.get(q`/organization/users/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}update($,Z,X){return this._client.post(q`/organization/users/${$}`,{body:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($={},Z){return this._client.getAPIList("/organization/users",d,{query:$,...Z,__security:{adminAPIKeyAuth:!0}})}delete($,Z){return this._client.delete(q`/organization/users/${$}`,{...Z,__security:{adminAPIKeyAuth:!0}})}}Y2.Roles=qZ;class F0 extends L{constructor(){super(...arguments);this.auditLogs=new n4(this._client),this.adminAPIKeys=new a4(this._client),this.usage=new $Z(this._client),this.invites=new o4(this._client),this.users=new Y2(this._client),this.groups=new J1(this._client),this.roles=new t4(this._client),this.dataRetention=new s4(this._client),this.spendAlerts=new e4(this._client),this.certificates=new r4(this._client),this.projects=new T0(this._client)}}F0.AuditLogs=n4;F0.AdminAPIKeys=a4;F0.Usage=$Z;F0.Invites=o4;F0.Users=Y2;F0.Groups=J1;F0.Roles=t4;F0.DataRetention=s4;F0.SpendAlerts=e4;F0.Certificates=r4;F0.Projects=T0;class Q1 extends L{constructor(){super(...arguments);this.organization=new F0(this._client)}}Q1.Organization=F0;var Wz=Symbol("brand.privateNullableHeaders");function*xw($){if(!$)return;if(Wz in $){let{values:Y,nulls:G}=$;yield*Y.entries();for(let z of G)yield[z,null];return}let Z=!1,X;if($ instanceof Headers)X=$.entries();else if(z5($))X=$;else Z=!0,X=Object.entries($??{});for(let Y of X){let G=Y[0];if(typeof G!=="string")throw TypeError("expected header name to be a string");let z=z5(Y[1])?Y[1]:[Y[1]],J=!1;for(let Q of z){if(Q===void 0)continue;if(Z&&!J)J=!0,yield[G,null];yield[G,Q]}}}var _=($)=>{let Z=new Headers,X=new Set;for(let Y of $){let G=new Set;for(let[z,J]of xw(Y)){let Q=z.toLowerCase();if(!G.has(Q))Z.delete(z),G.add(Q);if(J===null)Z.delete(z),X.add(Q);else Z.append(z,J),X.delete(Q)}}return{[Wz]:!0,values:Z,nulls:X}};class TZ extends L{create($,Z){return this._client.post("/audio/speech",{body:$,...Z,headers:_([{Accept:"application/octet-stream"},Z?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}class FZ extends L{create($,Z){return this._client.post("/audio/transcriptions",q0({body:$,...Z,stream:$.stream??!1,__metadata:{model:$.model},__security:{bearerAuth:!0}},this._client))}}class LZ extends L{create($,Z){return this._client.post("/audio/translations",q0({body:$,...Z,__metadata:{model:$.model},__security:{bearerAuth:!0}},this._client))}}class W$ extends L{constructor(){super(...arguments);this.transcriptions=new FZ(this._client),this.translations=new LZ(this._client),this.speech=new TZ(this._client)}}W$.Transcriptions=FZ;W$.Translations=LZ;W$.Speech=TZ;class G2 extends L{create($,Z){return this._client.post("/batches",{body:$,...Z,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/batches/${$}`,{...Z,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/batches",f,{query:$,...Z,__security:{bearerAuth:!0}})}cancel($,Z){return this._client.post(q`/batches/${$}/cancel`,{...Z,__security:{bearerAuth:!0}})}}class wZ extends L{create($,Z){return this._client.post("/assistants",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/assistants/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/assistants/${$}`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/assistants",f,{query:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/assistants/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}}class MZ extends L{create($,Z){return this._client.post("/realtime/sessions",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}}class NZ extends L{create($,Z){return this._client.post("/realtime/transcription_sessions",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}}class W1 extends L{constructor(){super(...arguments);this.sessions=new MZ(this._client),this.transcriptionSessions=new NZ(this._client)}}W1.Sessions=MZ;W1.TranscriptionSessions=NZ;class OZ extends L{create($,Z){return this._client.post("/chatkit/sessions",{body:$,...Z,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers]),__security:{bearerAuth:!0}})}cancel($,Z){return this._client.post(q`/chatkit/sessions/${$}/cancel`,{...Z,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers]),__security:{bearerAuth:!0}})}}class _Z extends L{retrieve($,Z){return this._client.get(q`/chatkit/threads/${$}`,{...Z,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers]),__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/chatkit/threads",d,{query:$,...Z,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers]),__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/chatkit/threads/${$}`,{...Z,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},Z?.headers]),__security:{bearerAuth:!0}})}listItems($,Z={},X){return this._client.getAPIList(q`/chatkit/threads/${$}/items`,d,{query:Z,...X,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},X?.headers]),__security:{bearerAuth:!0}})}}class V1 extends L{constructor(){super(...arguments);this.sessions=new OZ(this._client),this.threads=new _Z(this._client)}}V1.Sessions=OZ;V1.Threads=_Z;class PZ extends L{create($,Z,X){return this._client.post(q`/threads/${$}/messages`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z,X){let{thread_id:Y}=Z;return this._client.get(q`/threads/${Y}/messages/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){let{thread_id:Y,...G}=Z;return this._client.post(q`/threads/${Y}/messages/${$}`,{body:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/threads/${$}/messages`,f,{query:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}delete($,Z,X){let{thread_id:Y}=Z;return this._client.delete(q`/threads/${Y}/messages/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}}class DZ extends L{retrieve($,Z,X){let{thread_id:Y,run_id:G,...z}=Z;return this._client.get(q`/threads/${Y}/runs/${G}/steps/${$}`,{query:z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($,Z,X){let{thread_id:Y,...G}=Z;return this._client.getAPIList(q`/threads/${Y}/runs/${$}/steps`,f,{query:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}}var Vz=($)=>{if(typeof Buffer<"u"){let Z=Buffer.from($,"base64");return Array.from(new Float32Array(Z.buffer,Z.byteOffset,Z.length/Float32Array.BYTES_PER_ELEMENT))}else{let Z=atob($),X=Z.length,Y=new Uint8Array(X);for(let G=0;G<X;G++)Y[G]=Z.charCodeAt(G);return Array.from(new Float32Array(Y.buffer))}};var l0=($)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[$]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.($)?.trim()||void 0;return};var V0,K1,g5,p0,l8,g0,B1,z2,H1,a8,E0,p8,i8,AZ,EZ,RZ,Hz,Kz,Bz,Uz,qz,Tz,Fz;class j$ extends G1{constructor(){super(...arguments);V0.add(this),g5.set(this,[]),p0.set(this,{}),l8.set(this,{}),g0.set(this,void 0),B1.set(this,void 0),z2.set(this,void 0),H1.set(this,void 0),a8.set(this,void 0),E0.set(this,void 0),p8.set(this,void 0),i8.set(this,void 0),AZ.set(this,void 0)}[(g5=new WeakMap,p0=new WeakMap,l8=new WeakMap,g0=new WeakMap,B1=new WeakMap,z2=new WeakMap,H1=new WeakMap,a8=new WeakMap,E0=new WeakMap,p8=new WeakMap,i8=new WeakMap,AZ=new WeakMap,V0=new WeakSet,Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("event",(Y)=>{let G=Z.shift();if(G)G.resolve(Y);else $.push(Y)}),this.on("end",()=>{X=!0;for(let Y of Z)Y.resolve(void 0);Z.length=0}),this.on("abort",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),this.on("error",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((G,z)=>Z.push({resolve:G,reject:z})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}static fromReadableStream($){let Z=new K1;return Z._run(()=>Z._fromReadableStream($)),Z}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}this._connected();let Y=D0.fromReadableStream($,this.controller);for await(let G of Y)M(this,V0,"m",EZ).call(this,G);if(Y.controller.signal?.aborted)throw new $0;return this._addRun(M(this,V0,"m",RZ).call(this))}toReadableStream(){return new D0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream($,Z,X,Y){let G=new K1;return G._run(()=>G._runToolAssistantStream($,Z,X,{...Y,headers:{...Y?.headers,"X-Stainless-Helper-Method":"stream"}})),G}async _createToolAssistantStream($,Z,X,Y){let G=Y?.signal;if(G){if(G.aborted)this.controller.abort();G.addEventListener("abort",()=>this.controller.abort())}let z={...X,stream:!0},J=await $.submitToolOutputs(Z,z,{...Y,signal:this.controller.signal});this._connected();for await(let Q of J)M(this,V0,"m",EZ).call(this,Q);if(J.controller.signal?.aborted)throw new $0;return this._addRun(M(this,V0,"m",RZ).call(this))}static createThreadAssistantStream($,Z,X){let Y=new K1;return Y._run(()=>Y._threadAssistantStream($,Z,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}static createAssistantStream($,Z,X,Y){let G=new K1;return G._run(()=>G._runAssistantStream($,Z,X,{...Y,headers:{...Y?.headers,"X-Stainless-Helper-Method":"stream"}})),G}currentEvent(){return M(this,p8,"f")}currentRun(){return M(this,i8,"f")}currentMessageSnapshot(){return M(this,g0,"f")}currentRunStepSnapshot(){return M(this,AZ,"f")}async finalRunSteps(){return await this.done(),Object.values(M(this,p0,"f"))}async finalMessages(){return await this.done(),Object.values(M(this,l8,"f"))}async finalRun(){if(await this.done(),!M(this,B1,"f"))throw Error("Final run was not received.");return M(this,B1,"f")}async _createThreadAssistantStream($,Z,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}let G={...Z,stream:!0},z=await $.createAndRun(G,{...X,signal:this.controller.signal});this._connected();for await(let J of z)M(this,V0,"m",EZ).call(this,J);if(z.controller.signal?.aborted)throw new $0;return this._addRun(M(this,V0,"m",RZ).call(this))}async _createAssistantStream($,Z,X,Y){let G=Y?.signal;if(G){if(G.aborted)this.controller.abort();G.addEventListener("abort",()=>this.controller.abort())}let z={...X,stream:!0},J=await $.create(Z,z,{...Y,signal:this.controller.signal});this._connected();for await(let Q of J)M(this,V0,"m",EZ).call(this,Q);if(J.controller.signal?.aborted)throw new $0;return this._addRun(M(this,V0,"m",RZ).call(this))}static accumulateDelta($,Z){for(let[X,Y]of Object.entries(Z)){if(!$.hasOwnProperty(X)){$[X]=Y;continue}let G=$[X];if(G===null||G===void 0){$[X]=Y;continue}if(X==="index"||X==="type"){$[X]=Y;continue}if(typeof G==="string"&&typeof Y==="string")G+=Y;else if(typeof G==="number"&&typeof Y==="number")G+=Y;else if(x4(G)&&x4(Y))G=this.accumulateDelta(G,Y);else if(Array.isArray(G)&&Array.isArray(Y)){if(G.every((z)=>typeof z==="string"||typeof z==="number")){G.push(...Y);continue}for(let z of Y){if(!x4(z))throw Error(`Expected array delta entry to be an object but got: ${z}`);let J=z.index;if(J==null)throw console.error(z),Error("Expected array delta entry to have an `index` property");if(typeof J!=="number")throw Error(`Expected array delta entry \`index\` property to be a number but got ${J}`);let Q=G[J];if(Q==null)G.push(z);else G[J]=this.accumulateDelta(Q,z)}continue}else throw Error(`Unhandled record type: ${X}, deltaValue: ${Y}, accValue: ${G}`);$[X]=G}return $}_addRun($){return $}async _threadAssistantStream($,Z,X){return await this._createThreadAssistantStream(Z,$,X)}async _runAssistantStream($,Z,X,Y){return await this._createAssistantStream(Z,$,X,Y)}async _runToolAssistantStream($,Z,X,Y){return await this._createToolAssistantStream(Z,$,X,Y)}}K1=j$,EZ=function(Z){if(this.ended)return;switch(x(this,p8,Z,"f"),M(this,V0,"m",Bz).call(this,Z),Z.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":M(this,V0,"m",Fz).call(this,Z);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":M(this,V0,"m",Kz).call(this,Z);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":M(this,V0,"m",Hz).call(this,Z);break;case"error":throw Error("Encountered an error event in event processing - errors should be processed earlier");default:pw(Z)}},RZ=function(){if(this.ended)throw new S("stream has ended, this shouldn't happen");if(!M(this,B1,"f"))throw Error("Final run has not been received");return M(this,B1,"f")},Hz=function(Z){let[X,Y]=M(this,V0,"m",qz).call(this,Z,M(this,g0,"f"));x(this,g0,X,"f"),M(this,l8,"f")[X.id]=X;for(let G of Y){let z=X.content[G.index];if(z?.type=="text")this._emit("textCreated",z.text)}switch(Z.event){case"thread.message.created":this._emit("messageCreated",Z.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",Z.data.delta,X),Z.data.delta.content)for(let G of Z.data.delta.content){if(G.type=="text"&&G.text){let z=G.text,J=X.content[G.index];if(J&&J.type=="text")this._emit("textDelta",z,J.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(G.index!=M(this,z2,"f")){if(M(this,H1,"f"))switch(M(this,H1,"f").type){case"text":this._emit("textDone",M(this,H1,"f").text,M(this,g0,"f"));break;case"image_file":this._emit("imageFileDone",M(this,H1,"f").image_file,M(this,g0,"f"));break}x(this,z2,G.index,"f")}x(this,H1,X.content[G.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(M(this,z2,"f")!==void 0){let G=Z.data.content[M(this,z2,"f")];if(G)switch(G.type){case"image_file":this._emit("imageFileDone",G.image_file,M(this,g0,"f"));break;case"text":this._emit("textDone",G.text,M(this,g0,"f"));break}}if(M(this,g0,"f"))this._emit("messageDone",Z.data);x(this,g0,void 0,"f")}},Kz=function(Z){let X=M(this,V0,"m",Uz).call(this,Z);switch(x(this,AZ,X,"f"),Z.event){case"thread.run.step.created":this._emit("runStepCreated",Z.data);break;case"thread.run.step.delta":let Y=Z.data.delta;if(Y.step_details&&Y.step_details.type=="tool_calls"&&Y.step_details.tool_calls&&X.step_details.type=="tool_calls")for(let z of Y.step_details.tool_calls)if(z.index==M(this,a8,"f"))this._emit("toolCallDelta",z,X.step_details.tool_calls[z.index]);else{if(M(this,E0,"f"))this._emit("toolCallDone",M(this,E0,"f"));if(x(this,a8,z.index,"f"),x(this,E0,X.step_details.tool_calls[z.index],"f"),M(this,E0,"f"))this._emit("toolCallCreated",M(this,E0,"f"))}this._emit("runStepDelta",Z.data.delta,X);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":if(x(this,AZ,void 0,"f"),Z.data.step_details.type=="tool_calls"){if(M(this,E0,"f"))this._emit("toolCallDone",M(this,E0,"f")),x(this,E0,void 0,"f")}this._emit("runStepDone",Z.data,X);break;case"thread.run.step.in_progress":break}},Bz=function(Z){M(this,g5,"f").push(Z),this._emit("event",Z)},Uz=function(Z){switch(Z.event){case"thread.run.step.created":return M(this,p0,"f")[Z.data.id]=Z.data,Z.data;case"thread.run.step.delta":let X=M(this,p0,"f")[Z.data.id];if(!X)throw Error("Received a RunStepDelta before creation of a snapshot");let Y=Z.data;if(Y.delta){let G=K1.accumulateDelta(X,Y.delta);M(this,p0,"f")[Z.data.id]=G}return M(this,p0,"f")[Z.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":M(this,p0,"f")[Z.data.id]=Z.data;break}if(M(this,p0,"f")[Z.data.id])return M(this,p0,"f")[Z.data.id];throw Error("No snapshot available")},qz=function(Z,X){let Y=[];switch(Z.event){case"thread.message.created":return[Z.data,Y];case"thread.message.delta":if(!X)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let G=Z.data;if(G.delta.content)for(let z of G.delta.content)if(z.index in X.content){let J=X.content[z.index];X.content[z.index]=M(this,V0,"m",Tz).call(this,z,J)}else X.content[z.index]=z,Y.push(z);return[X,Y];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(X)return[X,Y];else throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},Tz=function(Z,X){return K1.accumulateDelta(X,Z)},Fz=function(Z){switch(x(this,i8,Z.data,"f"),Z.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":if(x(this,B1,Z.data,"f"),M(this,E0,"f"))this._emit("toolCallDone",M(this,E0,"f")),x(this,E0,void 0,"f");break;case"thread.run.cancelling":break}};function pw($){}class J2 extends L{constructor(){super(...arguments);this.steps=new DZ(this._client)}create($,Z,X){let{include:Y,...G}=Z;return this._client.post(q`/threads/${$}/runs`,{query:{include:Y},body:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),stream:Z.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}retrieve($,Z,X){let{thread_id:Y}=Z;return this._client.get(q`/threads/${Y}/runs/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){let{thread_id:Y,...G}=Z;return this._client.post(q`/threads/${Y}/runs/${$}`,{body:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/threads/${$}/runs`,f,{query:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}cancel($,Z,X){let{thread_id:Y}=Z;return this._client.post(q`/threads/${Y}/runs/${$}/cancel`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}async createAndPoll($,Z,X){let Y=await this.create($,Z,X);return await this.poll(Y.id,{thread_id:$},X)}createAndStream($,Z,X){return j$.createAssistantStream($,this._client.beta.threads.runs,Z,X)}async poll($,Z,X){let Y=_([X?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":X?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:G,response:z}=await this.retrieve($,Z,{...X,headers:{...X?.headers,...Y}}).withResponse();switch(G.status){case"queued":case"in_progress":case"cancelling":let J=5000;if(X?.pollIntervalMs)J=X.pollIntervalMs;else{let Q=z.headers.get("openai-poll-after-ms");if(Q){let W=parseInt(Q);if(!isNaN(W))J=W}}await d0(J);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return G}}}stream($,Z,X){return j$.createAssistantStream($,this._client.beta.threads.runs,Z,X)}submitToolOutputs($,Z,X){let{thread_id:Y,...G}=Z;return this._client.post(q`/threads/${Y}/runs/${$}/submit_tool_outputs`,{body:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),stream:Z.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async submitToolOutputsAndPoll($,Z,X){let Y=await this.submitToolOutputs($,Z,X);return await this.poll(Y.id,Z,X)}submitToolOutputsStream($,Z,X){return j$.createToolAssistantStream($,this._client.beta.threads.runs,Z,X)}}J2.Steps=DZ;class U1 extends L{constructor(){super(...arguments);this.runs=new J2(this._client),this.messages=new PZ(this._client)}create($={},Z){return this._client.post("/threads",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/threads/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/threads/${$}`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/threads/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}createAndRun($,Z){return this._client.post("/threads/runs",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),stream:$.stream??!1,__synthesizeEventData:!0,__security:{bearerAuth:!0}})}async createAndRunPoll($,Z){let X=await this.createAndRun($,Z);return await this.runs.poll(X.id,{thread_id:X.thread_id},Z)}createAndRunStream($,Z){return j$.createThreadAssistantStream($,this._client.beta.threads,Z)}}U1.Runs=J2;U1.Messages=PZ;class i0 extends L{constructor(){super(...arguments);this.realtime=new W1(this._client),this.chatkit=new V1(this._client),this.assistants=new wZ(this._client),this.threads=new U1(this._client)}}i0.Realtime=W1;i0.ChatKit=V1;i0.Assistants=wZ;i0.Threads=U1;class Q2 extends L{create($,Z){return this._client.post("/completions",{body:$,...Z,stream:$.stream??!1,__security:{bearerAuth:!0}})}}class SZ extends L{retrieve($,Z,X){let{container_id:Y}=Z;return this._client.get(q`/containers/${Y}/files/${$}/content`,{...X,headers:_([{Accept:"application/binary"},X?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}class W2 extends L{constructor(){super(...arguments);this.content=new SZ(this._client)}create($,Z,X){return this._client.post(q`/containers/${$}/files`,A$({body:Z,...X,__security:{bearerAuth:!0}},this._client))}retrieve($,Z,X){let{container_id:Y}=Z;return this._client.get(q`/containers/${Y}/files/${$}`,{...X,__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/containers/${$}/files`,f,{query:Z,...X,__security:{bearerAuth:!0}})}delete($,Z,X){let{container_id:Y}=Z;return this._client.delete(q`/containers/${Y}/files/${$}`,{...X,headers:_([{Accept:"*/*"},X?.headers]),__security:{bearerAuth:!0}})}}W2.Content=SZ;class q1 extends L{constructor(){super(...arguments);this.files=new W2(this._client)}create($,Z){return this._client.post("/containers",{body:$,...Z,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/containers/${$}`,{...Z,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/containers",f,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/containers/${$}`,{...Z,headers:_([{Accept:"*/*"},Z?.headers]),__security:{bearerAuth:!0}})}}q1.Files=W2;class CZ extends L{create($,Z,X){let{include:Y,...G}=Z;return this._client.post(q`/conversations/${$}/items`,{query:{include:Y},body:G,...X,__security:{bearerAuth:!0}})}retrieve($,Z,X){let{conversation_id:Y,...G}=Z;return this._client.get(q`/conversations/${Y}/items/${$}`,{query:G,...X,__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/conversations/${$}/items`,d,{query:Z,...X,__security:{bearerAuth:!0}})}delete($,Z,X){let{conversation_id:Y}=Z;return this._client.delete(q`/conversations/${Y}/items/${$}`,{...X,__security:{bearerAuth:!0}})}}class T1 extends L{constructor(){super(...arguments);this.items=new CZ(this._client)}create($={},Z){return this._client.post("/conversations",{body:$,...Z,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/conversations/${$}`,{...Z,__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/conversations/${$}`,{body:Z,...X,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/conversations/${$}`,{...Z,__security:{bearerAuth:!0}})}}T1.Items=CZ;class V2 extends L{create($,Z){let X=!!$.encoding_format,Y=X?$.encoding_format:"base64";if(X)s(this._client).debug("embeddings/user defined encoding_format:",$.encoding_format);let G=this._client.post("/embeddings",{body:{...$,encoding_format:Y},...Z,__security:{bearerAuth:!0}});if(X)return G;return s(this._client).debug("embeddings/decoding base64 embeddings from base64"),G._thenUnwrap((z)=>{if(z&&z.data)z.data.forEach((J)=>{let Q=J.embedding;J.embedding=Vz(Q)});return z})}}class IZ extends L{retrieve($,Z,X){let{eval_id:Y,run_id:G}=Z;return this._client.get(q`/evals/${Y}/runs/${G}/output_items/${$}`,{...X,__security:{bearerAuth:!0}})}list($,Z,X){let{eval_id:Y,...G}=Z;return this._client.getAPIList(q`/evals/${Y}/runs/${$}/output_items`,f,{query:G,...X,__security:{bearerAuth:!0}})}}class H2 extends L{constructor(){super(...arguments);this.outputItems=new IZ(this._client)}create($,Z,X){return this._client.post(q`/evals/${$}/runs`,{body:Z,...X,__security:{bearerAuth:!0}})}retrieve($,Z,X){let{eval_id:Y}=Z;return this._client.get(q`/evals/${Y}/runs/${$}`,{...X,__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/evals/${$}/runs`,f,{query:Z,...X,__security:{bearerAuth:!0}})}delete($,Z,X){let{eval_id:Y}=Z;return this._client.delete(q`/evals/${Y}/runs/${$}`,{...X,__security:{bearerAuth:!0}})}cancel($,Z,X){let{eval_id:Y}=Z;return this._client.post(q`/evals/${Y}/runs/${$}`,{...X,__security:{bearerAuth:!0}})}}H2.OutputItems=IZ;class F1 extends L{constructor(){super(...arguments);this.runs=new H2(this._client)}create($,Z){return this._client.post("/evals",{body:$,...Z,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/evals/${$}`,{...Z,__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/evals/${$}`,{body:Z,...X,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/evals",f,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/evals/${$}`,{...Z,__security:{bearerAuth:!0}})}}F1.Runs=H2;class K2 extends L{create($,Z){return this._client.post("/files",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}retrieve($,Z){return this._client.get(q`/files/${$}`,{...Z,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/files",f,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/files/${$}`,{...Z,__security:{bearerAuth:!0}})}content($,Z){return this._client.get(q`/files/${$}/content`,{...Z,headers:_([{Accept:"application/binary"},Z?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}async waitForProcessing($,{pollInterval:Z=5000,maxWait:X=1800000}={}){let Y=new Set(["processed","error","deleted"]),G=Date.now(),z=await this.retrieve($);while(!z.status||!Y.has(z.status))if(await d0(Z),z=await this.retrieve($),Date.now()-G>X)throw new Z1({message:`Giving up on waiting for file ${$} to finish processing after ${X} milliseconds.`});return z}}class jZ extends L{}class xZ extends L{run($,Z){return this._client.post("/fine_tuning/alpha/graders/run",{body:$,...Z,__security:{bearerAuth:!0}})}validate($,Z){return this._client.post("/fine_tuning/alpha/graders/validate",{body:$,...Z,__security:{bearerAuth:!0}})}}class B2 extends L{constructor(){super(...arguments);this.graders=new xZ(this._client)}}B2.Graders=xZ;class kZ extends L{create($,Z,X){return this._client.getAPIList(q`/fine_tuning/checkpoints/${$}/permissions`,L0,{body:Z,method:"post",...X,__security:{adminAPIKeyAuth:!0}})}retrieve($,Z={},X){return this._client.get(q`/fine_tuning/checkpoints/${$}/permissions`,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/fine_tuning/checkpoints/${$}/permissions`,d,{query:Z,...X,__security:{adminAPIKeyAuth:!0}})}delete($,Z,X){let{fine_tuned_model_checkpoint:Y}=Z;return this._client.delete(q`/fine_tuning/checkpoints/${Y}/permissions/${$}`,{...X,__security:{adminAPIKeyAuth:!0}})}}class U2 extends L{constructor(){super(...arguments);this.permissions=new kZ(this._client)}}U2.Permissions=kZ;class bZ extends L{list($,Z={},X){return this._client.getAPIList(q`/fine_tuning/jobs/${$}/checkpoints`,f,{query:Z,...X,__security:{bearerAuth:!0}})}}class q2 extends L{constructor(){super(...arguments);this.checkpoints=new bZ(this._client)}create($,Z){return this._client.post("/fine_tuning/jobs",{body:$,...Z,__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/fine_tuning/jobs/${$}`,{...Z,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/fine_tuning/jobs",f,{query:$,...Z,__security:{bearerAuth:!0}})}cancel($,Z){return this._client.post(q`/fine_tuning/jobs/${$}/cancel`,{...Z,__security:{bearerAuth:!0}})}listEvents($,Z={},X){return this._client.getAPIList(q`/fine_tuning/jobs/${$}/events`,f,{query:Z,...X,__security:{bearerAuth:!0}})}pause($,Z){return this._client.post(q`/fine_tuning/jobs/${$}/pause`,{...Z,__security:{bearerAuth:!0}})}resume($,Z){return this._client.post(q`/fine_tuning/jobs/${$}/resume`,{...Z,__security:{bearerAuth:!0}})}}q2.Checkpoints=bZ;class a0 extends L{constructor(){super(...arguments);this.methods=new jZ(this._client),this.jobs=new q2(this._client),this.checkpoints=new U2(this._client),this.alpha=new B2(this._client)}}a0.Methods=jZ;a0.Jobs=q2;a0.Checkpoints=U2;a0.Alpha=B2;class fZ extends L{}class L1 extends L{constructor(){super(...arguments);this.graderModels=new fZ(this._client)}}L1.GraderModels=fZ;class T2 extends L{createVariation($,Z){return this._client.post("/images/variations",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}edit($,Z){return this._client.post("/images/edits",q0({body:$,...Z,stream:$.stream??!1,__security:{bearerAuth:!0}},this._client))}generate($,Z){return this._client.post("/images/generations",{body:$,...Z,stream:$.stream??!1,__security:{bearerAuth:!0}})}}class F2 extends L{retrieve($,Z){return this._client.get(q`/models/${$}`,{...Z,__security:{bearerAuth:!0}})}list($){return this._client.getAPIList("/models",L0,{...$,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/models/${$}`,{...Z,__security:{bearerAuth:!0}})}}class L2 extends L{create($,Z){return this._client.post("/moderations",{body:$,...Z,__security:{bearerAuth:!0}})}}class yZ extends L{accept($,Z,X){return this._client.post(q`/realtime/calls/${$}/accept`,{body:Z,...X,headers:_([{Accept:"*/*"},X?.headers]),__security:{bearerAuth:!0}})}hangup($,Z){return this._client.post(q`/realtime/calls/${$}/hangup`,{...Z,headers:_([{Accept:"*/*"},Z?.headers]),__security:{bearerAuth:!0}})}refer($,Z,X){return this._client.post(q`/realtime/calls/${$}/refer`,{body:Z,...X,headers:_([{Accept:"*/*"},X?.headers]),__security:{bearerAuth:!0}})}reject($,Z={},X){return this._client.post(q`/realtime/calls/${$}/reject`,{body:Z,...X,headers:_([{Accept:"*/*"},X?.headers]),__security:{bearerAuth:!0}})}}class gZ extends L{create($,Z){return this._client.post("/realtime/client_secrets",{body:$,...Z,__security:{bearerAuth:!0}})}}class x$ extends L{constructor(){super(...arguments);this.clientSecrets=new gZ(this._client),this.calls=new yZ(this._client)}}x$.ClientSecrets=gZ;x$.Calls=yZ;function Lz($,Z){if(!Z||!HM(Z))return{...$,output_parsed:null,output:$.output.map((X)=>{if(X.type==="function_call")return{...X,parsed_arguments:null};if(X.type==="message")return{...X,content:X.content.map((Y)=>({...Y,parsed:null}))};else return X})};return v5($,Z)}function v5($,Z){let X=$.output.map((G)=>{if(G.type==="function_call")return{...G,parsed_arguments:UM(Z,G)};if(G.type==="message"){let z=G.content.map((J)=>{if(J.type==="output_text")return{...J,parsed:VM(Z,J.text)};return J});return{...G,content:z}}return G}),Y=Object.assign({},$,{output:X});if(!Object.getOwnPropertyDescriptor($,"output_text"))n8(Y);return Object.defineProperty(Y,"output_parsed",{enumerable:!0,get(){for(let G of Y.output){if(G.type!=="message")continue;for(let z of G.content)if(z.type==="output_text"&&z.parsed!==null)return z.parsed}return null}}),Y}function VM($,Z){if($.text?.format?.type!=="json_schema")return null;if("$parseRaw"in $.text?.format)return($.text?.format).$parseRaw(Z);return JSON.parse(Z)}function HM($){if(h4($.text?.format))return!0;return!1}function KM($){return $?.$brand==="auto-parseable-tool"}function BM($,Z){return $.find((X)=>X.type==="function"&&X.name===Z)}function UM($,Z){let X=BM($.tools??[],Z.name);return{...Z,...Z,parsed_arguments:KM(X)?X.$parseRaw(Z.arguments):X?.strict?JSON.parse(Z.arguments):null}}function n8($){let Z=[];for(let X of $.output){if(X.type!=="message")continue;for(let Y of X.content)if(Y.type==="output_text")Z.push(Y.text)}$.output_text=Z.join("")}var w2,r8,k$,s8,wz,Mz,Nz,Oz;class o8 extends G1{constructor($){super();w2.add(this),r8.set(this,void 0),k$.set(this,void 0),s8.set(this,void 0),x(this,r8,$,"f")}static createResponse($,Z,X){let Y=new o8(Z);return Y._run(()=>Y._createOrRetrieveResponse($,Z,{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),Y}async _createOrRetrieveResponse($,Z,X){let Y=X?.signal;if(Y){if(Y.aborted)this.controller.abort();Y.addEventListener("abort",()=>this.controller.abort())}M(this,w2,"m",wz).call(this);let G,z=null;if("response_id"in Z)G=await $.responses.retrieve(Z.response_id,{stream:!0},{...X,signal:this.controller.signal,stream:!0}),z=Z.starting_after??null;else G=await $.responses.create({...Z,stream:!0},{...X,signal:this.controller.signal});this._connected();for await(let J of G)M(this,w2,"m",Mz).call(this,J,z);if(G.controller.signal?.aborted)throw new $0;return M(this,w2,"m",Nz).call(this)}[(r8=new WeakMap,k$=new WeakMap,s8=new WeakMap,w2=new WeakSet,wz=function(){if(this.ended)return;x(this,k$,void 0,"f")},Mz=function(Z,X){if(this.ended)return;let Y=(z,J)=>{if(X==null||J.sequence_number>X)this._emit(z,J)},G=M(this,w2,"m",Oz).call(this,Z);switch(Y("event",Z),Z.type){case"response.output_text.delta":{let z=G.output[Z.output_index];if(!z)throw new S(`missing output at index ${Z.output_index}`);if(z.type==="message"){let J=z.content[Z.content_index];if(!J)throw new S(`missing content at index ${Z.content_index}`);if(J.type!=="output_text")throw new S(`expected content to be 'output_text', got ${J.type}`);Y("response.output_text.delta",{...Z,snapshot:J.text})}break}case"response.function_call_arguments.delta":{let z=G.output[Z.output_index];if(!z)throw new S(`missing output at index ${Z.output_index}`);if(z.type==="function_call")Y("response.function_call_arguments.delta",{...Z,snapshot:z.arguments});break}default:Y(Z.type,Z);break}},Nz=function(){if(this.ended)throw new S("stream has ended, this shouldn't happen");let Z=M(this,k$,"f");if(!Z)throw new S("request ended without sending any events");x(this,k$,void 0,"f");let X=qM(Z,M(this,r8,"f"));return x(this,s8,X,"f"),X},Oz=function(Z){let X=M(this,k$,"f");if(!X){if(Z.type!=="response.created")throw new S(`When snapshot hasn't been set yet, expected 'response.created' event, got ${Z.type}`);return X=x(this,k$,Z.response,"f"),X}switch(Z.type){case"response.output_item.added":{X.output.push(Z.item);break}case"response.content_part.added":{let Y=X.output[Z.output_index];if(!Y)throw new S(`missing output at index ${Z.output_index}`);let G=Y.type,z=Z.part;if(G==="message"&&z.type!=="reasoning_text")Y.content.push(z);else if(G==="reasoning"&&z.type==="reasoning_text"){if(!Y.content)Y.content=[];Y.content.push(z)}break}case"response.output_text.delta":{let Y=X.output[Z.output_index];if(!Y)throw new S(`missing output at index ${Z.output_index}`);if(Y.type==="message"){let G=Y.content[Z.content_index];if(!G)throw new S(`missing content at index ${Z.content_index}`);if(G.type!=="output_text")throw new S(`expected content to be 'output_text', got ${G.type}`);G.text+=Z.delta}break}case"response.function_call_arguments.delta":{let Y=X.output[Z.output_index];if(!Y)throw new S(`missing output at index ${Z.output_index}`);if(Y.type==="function_call")Y.arguments+=Z.delta;break}case"response.reasoning_text.delta":{let Y=X.output[Z.output_index];if(!Y)throw new S(`missing output at index ${Z.output_index}`);if(Y.type==="reasoning"){let G=Y.content?.[Z.content_index];if(!G)throw new S(`missing content at index ${Z.content_index}`);if(G.type!=="reasoning_text")throw new S(`expected content to be 'reasoning_text', got ${G.type}`);G.text+=Z.delta}break}case"response.completed":{x(this,k$,Z.response,"f");break}}return X},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("event",(Y)=>{let G=Z.shift();if(G)G.resolve(Y);else $.push(Y)}),this.on("end",()=>{X=!0;for(let Y of Z)Y.resolve(void 0);Z.length=0}),this.on("abort",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),this.on("error",(Y)=>{X=!0;for(let G of Z)G.reject(Y);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((G,z)=>Z.push({resolve:G,reject:z})).then((G)=>G?{value:G,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}async finalResponse(){await this.done();let $=M(this,s8,"f");if(!$)throw new S("stream ended without producing a ChatCompletion");return $}}function qM($,Z){return Lz($,Z)}class vZ extends L{list($,Z={},X){return this._client.getAPIList(q`/responses/${$}/input_items`,f,{query:Z,...X,__security:{bearerAuth:!0}})}}class hZ extends L{count($={},Z){return this._client.post("/responses/input_tokens",{body:$,...Z,__security:{bearerAuth:!0}})}}class b$ extends L{constructor(){super(...arguments);this.inputItems=new vZ(this._client),this.inputTokens=new hZ(this._client)}create($,Z){return this._client.post("/responses",{body:$,...Z,stream:$.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap((X)=>{if("object"in X&&X.object==="response")n8(X);return X})}retrieve($,Z={},X){return this._client.get(q`/responses/${$}`,{query:Z,...X,stream:Z?.stream??!1,__security:{bearerAuth:!0}})._thenUnwrap((Y)=>{if("object"in Y&&Y.object==="response")n8(Y);return Y})}delete($,Z){return this._client.delete(q`/responses/${$}`,{...Z,headers:_([{Accept:"*/*"},Z?.headers]),__security:{bearerAuth:!0}})}parse($,Z){return this._client.responses.create($,Z)._thenUnwrap((X)=>v5(X,$))}stream($,Z){return o8.createResponse(this._client,$,Z)}cancel($,Z){return this._client.post(q`/responses/${$}/cancel`,{...Z,__security:{bearerAuth:!0}})}compact($,Z){return this._client.post("/responses/compact",{body:$,...Z,__security:{bearerAuth:!0}})}}b$.InputItems=vZ;b$.InputTokens=hZ;class uZ extends L{retrieve($,Z){return this._client.get(q`/skills/${$}/content`,{...Z,headers:_([{Accept:"application/binary"},Z?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}class mZ extends L{retrieve($,Z,X){let{skill_id:Y}=Z;return this._client.get(q`/skills/${Y}/versions/${$}/content`,{...X,headers:_([{Accept:"application/binary"},X?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}}class M2 extends L{constructor(){super(...arguments);this.content=new mZ(this._client)}create($,Z={},X){return this._client.post(q`/skills/${$}/versions`,A$({body:Z,...X,__security:{bearerAuth:!0}},this._client))}retrieve($,Z,X){let{skill_id:Y}=Z;return this._client.get(q`/skills/${Y}/versions/${$}`,{...X,__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/skills/${$}/versions`,f,{query:Z,...X,__security:{bearerAuth:!0}})}delete($,Z,X){let{skill_id:Y}=Z;return this._client.delete(q`/skills/${Y}/versions/${$}`,{...X,__security:{bearerAuth:!0}})}}M2.Content=mZ;class f$ extends L{constructor(){super(...arguments);this.content=new uZ(this._client),this.versions=new M2(this._client)}create($={},Z){return this._client.post("/skills",A$({body:$,...Z,__security:{bearerAuth:!0}},this._client))}retrieve($,Z){return this._client.get(q`/skills/${$}`,{...Z,__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/skills/${$}`,{body:Z,...X,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/skills",f,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/skills/${$}`,{...Z,__security:{bearerAuth:!0}})}}f$.Content=uZ;f$.Versions=M2;class dZ extends L{create($,Z,X){return this._client.post(q`/uploads/${$}/parts`,q0({body:Z,...X,__security:{bearerAuth:!0}},this._client))}}class w1 extends L{constructor(){super(...arguments);this.parts=new dZ(this._client)}create($,Z){return this._client.post("/uploads",{body:$,...Z,__security:{bearerAuth:!0}})}cancel($,Z){return this._client.post(q`/uploads/${$}/cancel`,{...Z,__security:{bearerAuth:!0}})}complete($,Z,X){return this._client.post(q`/uploads/${$}/complete`,{body:Z,...X,__security:{bearerAuth:!0}})}}w1.Parts=dZ;var _z=async($)=>{let Z=await Promise.allSettled($),X=Z.filter((G)=>G.status==="rejected");if(X.length){for(let G of X)console.error(G.reason);throw Error(`${X.length} promise(s) failed - see the above errors`)}let Y=[];for(let G of Z)if(G.status==="fulfilled")Y.push(G.value);return Y};class cZ extends L{create($,Z,X){return this._client.post(q`/vector_stores/${$}/file_batches`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z,X){let{vector_store_id:Y}=Z;return this._client.get(q`/vector_stores/${Y}/file_batches/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}cancel($,Z,X){let{vector_store_id:Y}=Z;return this._client.post(q`/vector_stores/${Y}/file_batches/${$}/cancel`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}async createAndPoll($,Z,X){let Y=await this.create($,Z);return await this.poll($,Y.id,X)}listFiles($,Z,X){let{vector_store_id:Y,...G}=Z;return this._client.getAPIList(q`/vector_stores/${Y}/file_batches/${$}/files`,f,{query:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}async poll($,Z,X){let Y=_([X?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":X?.pollIntervalMs?.toString()??void 0}]);while(!0){let{data:G,response:z}=await this.retrieve(Z,{vector_store_id:$},{...X,headers:Y}).withResponse();switch(G.status){case"in_progress":let J=5000;if(X?.pollIntervalMs)J=X.pollIntervalMs;else{let Q=z.headers.get("openai-poll-after-ms");if(Q){let W=parseInt(Q);if(!isNaN(W))J=W}}await d0(J);break;case"failed":case"cancelled":case"completed":return G}}}async uploadAndPoll($,{files:Z,fileIds:X=[]},Y){if(Z==null||Z.length==0)throw Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");let G=Y?.maxConcurrency??5,z=Math.min(G,Z.length),J=this._client,Q=Z.values(),W=[...X];async function V(H){for(let B of H){let U=await J.files.create({file:B,purpose:"assistants"},Y);W.push(U.id)}}let K=Array(z).fill(Q).map(V);return await _z(K),await this.createAndPoll($,{file_ids:W})}}class lZ extends L{create($,Z,X){return this._client.post(q`/vector_stores/${$}/files`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z,X){let{vector_store_id:Y}=Z;return this._client.get(q`/vector_stores/${Y}/files/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){let{vector_store_id:Y,...G}=Z;return this._client.post(q`/vector_stores/${Y}/files/${$}`,{body:G,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($,Z={},X){return this._client.getAPIList(q`/vector_stores/${$}/files`,f,{query:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}delete($,Z,X){let{vector_store_id:Y}=Z;return this._client.delete(q`/vector_stores/${Y}/files/${$}`,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}async createAndPoll($,Z,X){let Y=await this.create($,Z,X);return await this.poll($,Y.id,X)}async poll($,Z,X){let Y=_([X?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":X?.pollIntervalMs?.toString()??void 0}]);while(!0){let G=await this.retrieve(Z,{vector_store_id:$},{...X,headers:Y}).withResponse(),z=G.data;switch(z.status){case"in_progress":let J=5000;if(X?.pollIntervalMs)J=X.pollIntervalMs;else{let Q=G.response.headers.get("openai-poll-after-ms");if(Q){let W=parseInt(Q);if(!isNaN(W))J=W}}await d0(J);break;case"failed":case"completed":return z}}}async upload($,Z,X){let Y=await this._client.files.create({file:Z,purpose:"assistants"},X);return this.create($,{file_id:Y.id},X)}async uploadAndPoll($,Z,X){let Y=await this.upload($,Z,X);return await this.poll($,Y.id,X)}content($,Z,X){let{vector_store_id:Y}=Z;return this._client.getAPIList(q`/vector_stores/${Y}/files/${$}/content`,L0,{...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}}class y$ extends L{constructor(){super(...arguments);this.files=new lZ(this._client),this.fileBatches=new cZ(this._client)}create($,Z){return this._client.post("/vector_stores",{body:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}retrieve($,Z){return this._client.get(q`/vector_stores/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}update($,Z,X){return this._client.post(q`/vector_stores/${$}`,{body:Z,...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/vector_stores",f,{query:$,...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/vector_stores/${$}`,{...Z,headers:_([{"OpenAI-Beta":"assistants=v2"},Z?.headers]),__security:{bearerAuth:!0}})}search($,Z,X){return this._client.getAPIList(q`/vector_stores/${$}/search`,L0,{body:Z,method:"post",...X,headers:_([{"OpenAI-Beta":"assistants=v2"},X?.headers]),__security:{bearerAuth:!0}})}}y$.Files=lZ;y$.FileBatches=cZ;class N2 extends L{create($,Z){return this._client.post("/videos",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}retrieve($,Z){return this._client.get(q`/videos/${$}`,{...Z,__security:{bearerAuth:!0}})}list($={},Z){return this._client.getAPIList("/videos",d,{query:$,...Z,__security:{bearerAuth:!0}})}delete($,Z){return this._client.delete(q`/videos/${$}`,{...Z,__security:{bearerAuth:!0}})}createCharacter($,Z){return this._client.post("/videos/characters",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}downloadContent($,Z={},X){return this._client.get(q`/videos/${$}/content`,{query:Z,...X,headers:_([{Accept:"application/binary"},X?.headers]),__security:{bearerAuth:!0},__binaryResponse:!0})}edit($,Z){return this._client.post("/videos/edits",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}extend($,Z){return this._client.post("/videos/extensions",q0({body:$,...Z,__security:{bearerAuth:!0}},this._client))}getCharacter($,Z){return this._client.get(q`/videos/characters/${$}`,{...Z,__security:{bearerAuth:!0}})}remix($,Z,X){return this._client.post(q`/videos/${$}/remix`,A$({body:Z,...X,__security:{bearerAuth:!0}},this._client))}}var O2,Pz,t8;class _2 extends L{constructor(){super(...arguments);O2.add(this)}async unwrap($,Z,X=this._client.webhookSecret,Y=300){return await this.verifySignature($,Z,X,Y),JSON.parse($)}async verifySignature($,Z,X=this._client.webhookSecret,Y=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!=="function"||typeof crypto.subtle.verify!=="function")throw Error("Webhook signature verification is only supported when the `crypto` global is defined");M(this,O2,"m",Pz).call(this,X);let G=_([Z]).values,z=M(this,O2,"m",t8).call(this,G,"webhook-signature"),J=M(this,O2,"m",t8).call(this,G,"webhook-timestamp"),Q=M(this,O2,"m",t8).call(this,G,"webhook-id"),W=parseInt(J,10);if(isNaN(W))throw new G$("Invalid webhook timestamp format");let V=Math.floor(Date.now()/1000);if(V-W>Y)throw new G$("Webhook timestamp is too old");if(W>V+Y)throw new G$("Webhook timestamp is too new");let K=z.split(" ").map((F)=>F.startsWith("v1,")?F.substring(3):F),H=X.startsWith("whsec_")?Buffer.from(X.replace("whsec_",""),"base64"):Buffer.from(X,"utf-8"),B=Q?`${Q}.${J}.${$}`:`${J}.${$}`,U=await crypto.subtle.importKey("raw",H,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(let F of K)try{let T=Buffer.from(F,"base64");if(await crypto.subtle.verify("HMAC",U,T,new TextEncoder().encode(B)))return}catch{continue}throw new G$("The given webhook signature does not match the expected signature")}}O2=new WeakSet,Pz=function(Z){if(typeof Z!=="string"||Z.length===0)throw Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},t8=function(Z,X){if(!Z)throw Error("Headers are required");let Y=Z.get(X);if(Y===null||Y===void 0)throw Error(`Missing required header: ${X}`);return Y};var h5,u5,e8,Dz,DM="workload-identity-auth";class b{constructor({baseURL:$=l0("OPENAI_BASE_URL"),apiKey:Z=l0("OPENAI_API_KEY")??null,adminAPIKey:X=l0("OPENAI_ADMIN_KEY")??null,organization:Y=l0("OPENAI_ORG_ID")??null,project:G=l0("OPENAI_PROJECT_ID")??null,webhookSecret:z=l0("OPENAI_WEBHOOK_SECRET")??null,workloadIdentity:J,...Q}={}){h5.add(this),e8.set(this,void 0),this.completions=new Q2(this),this.chat=new z1(this),this.embeddings=new V2(this),this.files=new K2(this),this.images=new T2(this),this.audio=new W$(this),this.moderations=new L2(this),this.models=new F2(this),this.fineTuning=new a0(this),this.graders=new L1(this),this.vectorStores=new y$(this),this.webhooks=new _2(this),this.beta=new i0(this),this.batches=new G2(this),this.uploads=new w1(this),this.admin=new Q1(this),this.responses=new b$(this),this.realtime=new x$(this),this.conversations=new T1(this),this.evals=new F1(this),this.containers=new q1(this),this.skills=new f$(this),this.videos=new N2(this);let W={apiKey:Z,adminAPIKey:X,organization:Y,project:G,webhookSecret:z,workloadIdentity:J,...Q,baseURL:$||"https://api.openai.com/v1"};if(Z&&J)throw new S("The `apiKey` and `workloadIdentity` options are mutually exclusive");if(!Z&&!X&&!J)throw new S("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");if(!W.dangerouslyAllowBrowser&&DG())throw new S(`It looks like you're running in a browser-like environment.
255
+
256
+ This is disabled by default, as it risks exposing your secret API credentials to attackers.
257
+ If you understand the risks and have appropriate mitigations in place,
258
+ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
259
+
260
+ new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
261
+
262
+ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
263
+ `);this.baseURL=W.baseURL,this.timeout=W.timeout??u5.DEFAULT_TIMEOUT,this.logger=W.logger??console;let V="warn";this.logLevel=V,this.logLevel=L5(W.logLevel,"ClientOptions.logLevel",this)??L5(l0("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??V,this.fetchOptions=W.fetchOptions,this.maxRetries=W.maxRetries??2,this.fetch=W.fetch??E8(),x(this,e8,AG,"f");let K=l0("OPENAI_CUSTOM_HEADERS");if(K){let H={};for(let B of K.split(`
264
+ `)){let U=B.indexOf(":");if(U>=0)H[B.substring(0,U).trim()]=B.substring(U+1).trim()}W.defaultHeaders=_([H,W.defaultHeaders])}if(this._options=W,J)this._workloadIdentityAuth=new M5(J,this.fetch);this.apiKey=typeof Z==="string"?Z:null,this.adminAPIKey=X,this.organization=Y,this.project=G,this.webhookSecret=z}withOptions($){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this._options.apiKey,adminAPIKey:this.adminAPIKey,workloadIdentity:this._options.workloadIdentity,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...$})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:$,nulls:Z},X={bearerAuth:!0,adminAPIKeyAuth:!0}){if($.get("authorization")||$.get("api-key"))return;if(Z.has("authorization")||Z.has("api-key"))return;if(this._workloadIdentityAuth&&X.bearerAuth)return;throw Error('Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted')}async authHeaders($,Z={bearerAuth:!0,adminAPIKeyAuth:!0}){return _([Z.bearerAuth?await this.bearerAuth($):null,Z.adminAPIKeyAuth?await this.adminAPIKeyAuth($):null])}async bearerAuth($){if(this._workloadIdentityAuth)return _([{Authorization:`Bearer ${await this._workloadIdentityAuth.getToken()}`}]);if(this.apiKey==null)return;return _([{Authorization:`Bearer ${this.apiKey}`}])}async adminAPIKeyAuth($){if(this.adminAPIKey==null)return;return _([{Authorization:`Bearer ${this.adminAPIKey}`}])}stringifyQuery($){return yG($)}getUserAgent(){return`${this.constructor.name}/JS ${R$}`}defaultIdempotencyKey(){return`stainless-node-retry-${G5()}`}makeStatusError($,Z,X,Y){return r.generate($,Z,X,Y)}async _callApiKey(){let $=this._options.apiKey;if(typeof $!=="function")return!1;let Z;try{Z=await $()}catch(X){if(X instanceof S)throw X;throw new S(`Failed to get token from 'apiKey' function: ${X.message}`,{cause:X})}if(typeof Z!=="string"||!Z)throw new S(`Expected 'apiKey' function argument to return a string but it returned ${Z}`);return this.apiKey=Z,!0}buildURL($,Z,X){let Y=!M(this,h5,"m",Dz).call(this)&&X||this.baseURL,G=LG($)?new URL($):new URL(Y+(Y.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),z=this.defaultQuery(),J=Object.fromEntries(G.searchParams);if(!J5(z)||!J5(J))Z={...J,...z,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))G.search=this.stringifyQuery(Z);return G.toString()}async prepareOptions($){if(($.__security??{bearerAuth:!0}).bearerAuth)await this._callApiKey()}async prepareRequest($,{url:Z,options:X}){}get($,Z){return this.methodRequest("get",$,Z)}post($,Z){return this.methodRequest("post",$,Z)}patch($,Z){return this.methodRequest("patch",$,Z)}put($,Z){return this.methodRequest("put",$,Z)}delete($,Z){return this.methodRequest("delete",$,Z)}methodRequest($,Z,X){return this.request(Promise.resolve(X).then((Y)=>{return{method:$,path:Z,...Y}}))}request($,Z=null){return new X1(this,this.makeRequest($,Z,void 0))}async makeRequest($,Z,X){let Y=await $,G=Y.maxRetries??this.maxRetries;if(Z==null)Z=G;await this.prepareOptions(Y);let{req:z,url:J,timeout:Q}=await this.buildRequest(Y,{retryCount:G-Z});await this.prepareRequest(z,{url:J,options:Y});let W="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),V=X===void 0?"":`, retryOf: ${X}`,K=Date.now();if(s(this).debug(`[${W}] sending request`,z$({retryOfRequestLogID:X,method:Y.method,url:J,options:Y,headers:z.headers})),Y.signal?.aborted)throw new $0;let H=Y.__security??{bearerAuth:!0},B=new AbortController,U=await this.fetchWithAuth(J,z,Q,B,H).catch(O4),F=Date.now();if(U instanceof globalThis.Error){let O=`retrying, ${Z} attempts remaining`;if(Y.signal?.aborted)throw new $0;let N=N4(U)||/timed? ?out/i.test(String(U)+("cause"in U?String(U.cause):""));if(Z)return s(this).info(`[${W}] connection ${N?"timed out":"failed"} - ${O}`),s(this).debug(`[${W}] connection ${N?"timed out":"failed"} (${O})`,z$({retryOfRequestLogID:X,url:J,durationMs:F-K,message:U.message})),this.retryRequest(Y,Z,X??W);if(s(this).info(`[${W}] connection ${N?"timed out":"failed"} - error; no more retries left`),s(this).debug(`[${W}] connection ${N?"timed out":"failed"} (error; no more retries left)`,z$({retryOfRequestLogID:X,url:J,durationMs:F-K,message:U.message})),U instanceof i1||U instanceof P8)throw U;if(N)throw new Z1;throw new $1({cause:U})}let T=[...U.headers.entries()].filter(([O])=>O==="x-request-id").map(([O,N])=>", "+O+": "+JSON.stringify(N)).join(""),w=`[${W}${V}${T}] ${z.method} ${J} ${U.ok?"succeeded":"failed"} with status ${U.status} in ${F-K}ms`;if(!U.ok){if(U.status===401&&this._workloadIdentityAuth&&H.bearerAuth&&!Y.__metadata?.hasStreamingBody&&!Y.__metadata?.workloadIdentityTokenRefreshed)return await V5(U.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest({...Y,__metadata:{...Y.__metadata,workloadIdentityTokenRefreshed:!0}},Z,X??W);let O=await this.shouldRetry(U);if(Z&&O){let C=`retrying, ${Z} attempts remaining`;return await V5(U.body),s(this).info(`${w} - ${C}`),s(this).debug(`[${W}] response error (${C})`,z$({retryOfRequestLogID:X,url:U.url,status:U.status,headers:U.headers,durationMs:F-K})),this.retryRequest(Y,Z,X??W,U.headers)}let N=O?"error; no more retries left":"error; not retryable";s(this).info(`${w} - ${N}`);let P=await U.text().catch((C)=>O4(C).message),E=NG(P),I=E?void 0:P;throw s(this).debug(`[${W}] response error (${N})`,z$({retryOfRequestLogID:X,url:U.url,status:U.status,headers:U.headers,message:I,durationMs:Date.now()-K})),this.makeStatusError(U.status,E,I,U.headers)}return s(this).info(w),s(this).debug(`[${W}] response start`,z$({retryOfRequestLogID:X,url:U.url,status:U.status,headers:U.headers,durationMs:F-K})),{response:U,options:Y,controller:B,requestLogID:W,retryOfRequestLogID:X,startTime:K}}getAPIList($,Z,X){return this.requestAPIList(Z,X&&"then"in X?X.then((Y)=>({method:"get",path:$,...Y})):{method:"get",path:$,...X})}requestAPIList($,Z){let X=this.makeRequest(Z,null,void 0);return new x8(this,X,$)}async fetchWithAuth($,Z,X,Y,G={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&G.bearerAuth){let J=Z.headers,Q=J.get("Authorization");if(!Q||Q===`Bearer ${DM}`){let W=await this._workloadIdentityAuth.getToken();J.set("Authorization",`Bearer ${W}`)}}return await this.fetchWithTimeout($,Z,X,Y)}async fetchWithTimeout($,Z,X,Y){let{signal:G,method:z,...J}=Z||{},Q=this._makeAbort(Y);if(G)G.addEventListener("abort",Q,{once:!0});let W=setTimeout(Q,X),V=globalThis.ReadableStream&&J.body instanceof globalThis.ReadableStream||typeof J.body==="object"&&J.body!==null&&Symbol.asyncIterator in J.body,K={signal:Y.signal,...V?{duplex:"half"}:{},method:"GET",...J};if(z)K.method=z.toUpperCase();try{return await this.fetch.call(void 0,$,K)}finally{clearTimeout(W)}}async shouldRetry($){let Z=$.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,Z,X,Y){let G,z=Y?.get("retry-after-ms");if(z){let Q=parseFloat(z);if(!Number.isNaN(Q))G=Q}let J=Y?.get("retry-after");if(J&&!G){let Q=parseFloat(J);if(!Number.isNaN(Q))G=Q*1000;else G=Date.parse(J)-Date.now()}if(G===void 0){let Q=$.maxRetries??this.maxRetries;G=this.calculateDefaultRetryTimeoutMillis(Z,Q)}return await d0(G),this.makeRequest($,Z-1,X)}calculateDefaultRetryTimeoutMillis($,Z){let G=Z-$,z=Math.min(0.5*Math.pow(2,G),8),J=1-Math.random()*0.25;return z*J*1000}async buildRequest($,{retryCount:Z=0}={}){let X={...$},{method:Y,path:G,query:z,defaultBaseURL:J}=X,Q=this.buildURL(G,z,J);if("timeout"in X)MG("timeout",X.timeout);X.timeout=X.timeout??this.timeout;let{bodyHeaders:W,body:V,isStreamingBody:K}=this.buildBody({options:X});if(K)$.__metadata={...$.__metadata,hasStreamingBody:!0};let H=await this.buildHeaders({options:$,method:Y,bodyHeaders:W,retryCount:Z});return{req:{method:Y,headers:H,...X.signal&&{signal:X.signal},...globalThis.ReadableStream&&V instanceof globalThis.ReadableStream&&{duplex:"half"},...V&&{body:V},...this.fetchOptions??{},...X.fetchOptions??{}},url:Q,timeout:X.timeout}}async buildHeaders({options:$,method:Z,bodyHeaders:X,retryCount:Y}){let G={};if(this.idempotencyHeader&&Z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();G[this.idempotencyHeader]=$.idempotencyKey}let z=_([G,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(Y),...$.timeout?{"X-Stainless-Timeout":String(Math.trunc($.timeout/1000))}:{},...EG(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders($,$.__security??{bearerAuth:!0}),this._options.defaultHeaders,X,$.headers]);return this.validateHeaders(z,$.__security??{bearerAuth:!0}),z.values}_makeAbort($){return()=>$.abort()}buildBody({options:{body:$,headers:Z}}){if(!$)return{bodyHeaders:void 0,body:void 0,isStreamingBody:!1};let X=_([Z]),Y=typeof globalThis.ReadableStream<"u"&&$ instanceof globalThis.ReadableStream,G=!Y&&(typeof $==="string"||$ instanceof ArrayBuffer||ArrayBuffer.isView($)||typeof globalThis.Blob<"u"&&$ instanceof globalThis.Blob||$ instanceof URLSearchParams||$ instanceof FormData);if(ArrayBuffer.isView($)||$ instanceof ArrayBuffer||$ instanceof DataView||typeof $==="string"&&X.values.has("content-type")||globalThis.Blob&&$ instanceof globalThis.Blob||$ instanceof FormData||$ instanceof URLSearchParams||Y)return{bodyHeaders:void 0,body:$,isStreamingBody:!G};else if(typeof $==="object"&&((Symbol.asyncIterator in $)||(Symbol.iterator in $)&&("next"in $)&&typeof $.next==="function"))return{bodyHeaders:void 0,body:R8($),isStreamingBody:!0};else if(typeof $==="object"&&X.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery($),isStreamingBody:!1};else return{...M(this,e8,"f").call(this,{body:$,headers:X}),isStreamingBody:!1}}}u5=b,e8=new WeakMap,h5=new WeakSet,Dz=function(){return this.baseURL!=="https://api.openai.com/v1"};b.OpenAI=u5;b.DEFAULT_TIMEOUT=600000;b.OpenAIError=S;b.APIError=r;b.APIConnectionError=$1;b.APIConnectionTimeoutError=Z1;b.APIUserAbortError=$0;b.NotFoundError=E4;b.ConflictError=R4;b.RateLimitError=S4;b.BadRequestError=_4;b.AuthenticationError=P4;b.InternalServerError=C4;b.PermissionDeniedError=D4;b.UnprocessableEntityError=A4;b.InvalidWebhookSignatureError=G$;b.toFile=b8;b.Completions=Q2;b.Chat=z1;b.Embeddings=V2;b.Files=K2;b.Images=T2;b.Audio=W$;b.Moderations=L2;b.Models=F2;b.FineTuning=a0;b.Graders=L1;b.VectorStores=y$;b.Webhooks=_2;b.Beta=i0;b.Batches=G2;b.Uploads=w1;b.Admin=Q1;b.Responses=b$;b.Realtime=x$;b.Conversations=T1;b.Evals=F1;b.Containers=q1;b.Skills=f$;b.Videos=N2;class m5{category="api";provider="openai";name;config;clientFactory;constructor($,Z,X){this.name=$,this.config=Z,this.clientFactory=X??(()=>new b)}async run($,Z){let{tool:X,docs:Y,requiredSources:G,discovery:z}=Z;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let J=z?p1(X,z.sourceHint):E$(X,Y,G),W=await this.clientFactory().responses.create({model:this.config.model,instructions:J,input:$,temperature:this.config.temperature??0,max_output_tokens:this.config.maxTokens??4096}),V=typeof W.output_text==="string"?W.output_text:"";return{response:V,allResponses:V?[{type:"final",text:V}]:[],toolsUsed:[],sources:[],metadata:{model:this.config.model,category:this.category,provider:this.provider,target:this.name}}}}import{query as EM}from"@anthropic-ai/claude-agent-sdk";class d5{category="cli";provider="claude-code";name;config;constructor($,Z){this.name=$,this.config=Z}async run($,Z){let{tool:X,cwd:Y,context:G,docs:z,requiredSources:J,discovery:Q,restrictBuiltinTools:W}=Z,V=[],K=[],H=Q?p1(X,Q.sourceHint):E$(X,z,J),B={cwd:Y,model:this.config.model??"sonnet",systemPrompt:H,allowedTools:G?.allowedTools??this.config.allowedTools??LX,disallowedTools:G?.disallowedTools??this.config.disallowedTools??wX,permissionMode:this.config.permissionMode??"acceptEdits",maxTurns:this.config.maxTurns??10,maxThinkingTokens:this.config.maxThinkingTokens,maxBudgetUsd:this.config.maxBudgetUsd,mcpServers:G?.mcpServers??this.config.mcpServers,settingSources:[]};if(W!==void 0)B.tools=W;let U=[],F="",T="";for await(let w of EM({prompt:$,options:B})){if(w.type==="assistant"){let O=w.message?.content;if(Array.isArray(O)){let N="";for(let P of O){if(P.type==="text")N+=P.text;if(P.type==="tool_use"){let E=P;if(!V.includes(E.name))V.push(E.name)}}if(N){let P=U.length===0?"initial":"intermediate";U.push({type:P,text:N}),F=N}}}if(w.type==="result"){let O=w;if(O.result)T=O.result}}if(U.length>0)U[U.length-1].type="final";return{response:T||F,allResponses:U,toolsUsed:V,sources:K,metadata:{model:this.config.model??"sonnet",category:this.category,provider:this.provider,target:this.name}}}}import{randomUUID as RM}from"crypto";import{rm as AM}from"fs/promises";import{tmpdir as SM}from"os";import{join as CM}from"path";var IM="codex";class c5{category="cli";provider="codex-cli";name;config;spawnFn;readFileFn;binary;constructor($,Z,X={}){this.name=$,this.config=Z,this.spawnFn=X.spawn??bM,this.readFileFn=X.readFile??fM,this.binary=X.binary??IM}async run($,Z){let{tool:X,cwd:Y,docs:G,requiredSources:z}=Z,J=this.config.model;if(!J)throw Error(`CodexCliTarget "${this.name}" requires an explicit model. Validation should have caught this at config load.`);let W=`${E$(X,G,z)}
242
265
 
243
266
  ---
244
267
 
245
- ${$}`,H=mW(uW(),`pickled-codex-${gW()}.txt`),W=["--ask-for-approval","never","exec","--json","--sandbox","read-only","--ignore-user-config","--ignore-rules","--ephemeral","--skip-git-repo-check","--cd",z,"--model",J,"--output-last-message",H,"-"];try{let U=await this.spawnFn(this.binary,W,{cwd:z,stdin:Y}),{allResponses:V,toolsUsed:B}=pW(U.stdout);if(U.exitCode!==0)throw Error(`codex exec failed (exit ${U.exitCode}): ${U.stderr.trim()||"no stderr output"}`);let T="";try{T=(await this.readFileFn(H)).trim()}catch{T=V.length>0?V[V.length-1].text:""}if(V.length>0)V[V.length-1].type="final";return{response:T,allResponses:V,toolsUsed:B,sources:[],metadata:{model:J,category:this.category,provider:this.provider,target:this.name}}}finally{await vW(H,{force:!0})}}}function pW($){let Z=[],X=[];for(let z of $.split(`
246
- `)){let q=z.trim();if(!q)continue;let G;try{G=JSON.parse(q)}catch{continue}let J=lW(G);if(J){let Y=Z.length===0?"initial":"intermediate";Z.push({type:Y,text:J})}let Q=cW(G);if(Q&&!X.includes(Q))X.push(Q)}return{allResponses:Z,toolsUsed:X}}function lW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.message==="string")return Z.message;if(typeof Z.content==="string")return Z.content;if(typeof Z.type==="string"&&(Z.type==="assistant_message"||Z.type==="agent_message")&&typeof Z.text==="string")return Z.text;if(Z.type==="message"&&typeof Z.text==="string")return Z.text;return null}function cW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.tool==="string")return Z.tool;if(typeof Z.type==="string"&&(Z.type==="tool_call"||Z.type==="function_call")&&typeof Z.name==="string")return Z.name;return null}var iW=async($,Z,X)=>{let z=Bun.spawn([$,...Z],{cwd:X.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});z.stdin.write(X.stdin),await z.stdin.end();let[q,G,J]=await Promise.all([new Response(z.stdout).text(),new Response(z.stderr).text(),z.exited]);return{exitCode:J,stdout:q,stderr:G}},aW=async($)=>{let Z=Bun.file($);if(!await Z.exists())throw Error(`Last-message file not found: ${$}`);return Z.text()};function q4($,Z){let X=Z??U0;switch(X.category){case"cli":return nW($,X);case"api":return sW($,X);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${X.category}`)}}function nW($,Z){switch(Z.provider){case"claude-code":return new H5($,Z);case"codex-cli":return new U5($,Z);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${Z.provider}`)}}function sW($,Z){switch(Z.provider){case"anthropic":return new Y5($,Z);case"openai":throw Error("OpenAI API target not yet implemented. Coming soon!");case"google":throw Error("Google API target not yet implemented. Coming soon!");default:throw Error(`Unknown API provider: ${Z.provider}`)}}var S$="default";function G4($,Z){if(!$||$===S$)return{name:S$,config:U0};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Target "${$}" not found, using default`),{name:S$,config:U0}}function W5($,Z){if(!$||$===S$)return{name:S$,config:{}};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Context "${$}" not found, using default`),{name:S$,config:{}}}var V5="__matrix__";function rW($){let Z=[],X=$.matrix?.target??["default"],z=$.matrix?.context??["default"];for(let q of $.scenarios){let G=q.context?[q.context]:z;if(q.matrix){for(let Q of G)Z.push({scenario:q,targetName:V5,contextName:Q});continue}let J=q.target?[q.target]:X;for(let Q of J)for(let Y of G)Z.push({scenario:q,targetName:Q,contextName:Y})}return Z}async function K5($,Z,X={}){let{onProgress:z}=X,q=[];if(Z.scenarios.length===0)throw Error("No scenarios defined in config");let G=Z.docs?.sources??{},J=[];if(Object.keys(G).length>0){z?.("Loading sources..."),J=await Q1(G,$.path);for(let W of J)z?.(` [${W.id}] ${W.name}`);z?.("")}let Q=J.map((W)=>W.id),Y=rW(Z);if(X.scenarioFilter&&X.scenarioFilter.length>0){let W=new Set(X.scenarioFilter);if(Y=Y.filter((U)=>W.has(U.scenario.name)),Y.length===0)throw Error(`No scenarios matched filter: ${[...W].join(", ")}. Declared scenarios: ${Z.scenarios.map((U)=>U.name).join(", ")}`)}let H="";for(let{scenario:W,targetName:U,contextName:V}of Y){let B=oW(U,V);if(W.name!==H){if(H)z?.("");z?.(`"${W.name}"`),H=W.name}try{let T=await tW(W,U,V,$,Z,J,Q,X);q.push(T);let K=B?B.padEnd(18):"";if(T.cells){z?.(` ${K} (matrix mode)`);for(let L of T.cells){let D=F0(L),O=` [${[L.cell.interface,L.cell.source??"-",L.cell.toolset].join(" \xB7 ")}]`.padEnd(40);z?.(`${O} ${D.icon} ${D.label} (${D.confidence}%)`)}}else if(T.surfaces){z?.(` ${K} (compare-surfaces mode)`);for(let L of T.surfaces){let D=F0(L),_=` [${L.active.join(",")}]`.padEnd(22);z?.(`${_} ${D.icon} ${D.label} (${D.confidence}%)`)}}else{let L=F0({answerable:T.answerable??"NO",confidence:T.confidence??0,traps:T.traps??{fired:[],avoided:[]},error:T.error});z?.(` ${K} ${L.icon} ${L.label} (${L.confidence}%)`)}}catch(T){let K=U==="default"?U0:Z.targets?.[U]??U0,L=W.requiredSources??[],D={scenario:W,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:L,missing:L,unknown:[]},traps:{fired:[],avoided:(W.traps??[]).map((O)=>O.id)},error:T instanceof Error?T.message:String(T),target:{target:U===V5?"matrix":U,category:K.category,provider:K.provider,model:K.model??"unknown"},context:{name:V}};q.push(D);let _=B?B.padEnd(18):"";z?.(` ${_} \u2717 Error`)}}return z?.(""),eW($,J,q)}function oW($,Z){if($==="default"&&Z==="default")return"";if(Z==="default")return`[${$}]`;return`[${$}/${Z}]`}async function tW($,Z,X,z,q,G,J,Q){if($.matrix&&Z===V5)return $V($,X,z,q,G,Q);let{config:Y}=G4(Z,q.targets),{config:H}=W5(X,q.contexts),W=Q.targetFactory?Q.targetFactory(Z,Y):q4(Z,Y);if($.compareSurfaces&&$.compareSurfaces.length>0){let w=[],R;for(let I of $.compareSurfaces){let C=new Set(I),M=G.filter((K0)=>C.has(K0.id)),p=($.requiredSources??[]).filter((K0)=>C.has(K0)),s=await W.run($.prompt,{tool:z,cwd:z.path,context:H,docs:M,requiredSources:p,onProgress:Q.onProgress}),k=D$({response:s.response,requiredSources:p,registeredIds:I}),o=x0({response:s.response,traps:$.traps??[]}),Z$=o.fired.length>0,U4=Z$?"NO":k.answerable,N1=Z$?0:k.confidence,W4=Z$?`Trap fired: ${o.fired.map((K0)=>`"${K0.id}" (${K0.reason})`).join("; ")}`:k.reason;w.push({active:I,answerable:U4,confidence:N1,response:s.response,reason:W4,citations:k.citations,traps:o,allResponses:s.allResponses}),R=s.metadata??R}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:w,target:R,context:{name:X}}}let U=$.requiredSources??[],V=await W.run($.prompt,{tool:z,cwd:z.path,context:H,docs:G,requiredSources:U,onProgress:Q.onProgress}),B=x0({response:V.response,traps:$.traps??[]}),T=B.fired.length>0,K=$.requiredSources!==void 0?D$({response:V.response,requiredSources:U,registeredIds:J}):null,L=$.expected!==void 0?N2({response:V.response,expected:$.expected}):null,D,_,O;if(T)D="NO",_=0,O=`Trap fired: ${B.fired.map((w)=>`"${w.id}" (${w.reason})`).join("; ")}`;else{let w=[],R=[];if(K)w.push({answerable:K.answerable,confidence:K.confidence}),R.push(K.reason);if(L){let I=L.total===0?100:Math.round(L.satisfied/L.total*100),C=I===100?"YES":I===0?"NO":"PARTIAL";w.push({answerable:C,confidence:I})}if(w.length===0)D="YES",_=100,O="No traps fired; no other contract declared";else{let I={YES:0,PARTIAL:1,NO:2};D=w.reduce((M,y)=>I[y.answerable]>I[M.answerable]?y:M).answerable,_=Math.round(w.reduce((M,y)=>M+y.confidence,0)/w.length),O=R.filter((M)=>M.length>0).join(" | ")}}return{scenario:$,answerable:D,confidence:_,response:V.response,reason:O,citations:K?K.citations:{cited:[],required:U,missing:[],unknown:[]},traps:B,target:V.metadata,context:{name:X},toolsUsed:V.toolsUsed,sources:V.sources,allResponses:V.allResponses}}function eW($,Z,X){let z=[];for(let Q of X){if(Q.surfaces){for(let Y of Q.surfaces)z.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.cells){for(let Y of Q.cells)z.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)z.push({answerable:Q.answerable,confidence:Q.confidence})}let q=z.length,G=z.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,J=q>0?Math.round(z.reduce((Q,Y)=>{if(Y.answerable==="YES")return Q+Y.confidence;if(Y.answerable==="PARTIAL")return Q+Y.confidence*0.5;return Q},0)/q):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:Z,scenarios:X,summary:{total:q,answered:G,unanswered:q-G,score:J}}}async function $V($,Z,X,z,q,G){let{config:J}=W5(Z,z.contexts),Q=$.matrix??{},Y=$.target??"default",H=Q.interfaces??[Y],W=Q.sources??[null],U=Q.toolsets??["none"],V=G.cellFilter??{},B=[],T;for(let L of H){if(V.interface&&V.interface!==L)continue;for(let D of W){if(V.source!==void 0&&V.source!==(D??""))continue;for(let _ of U){if(V.toolset&&V.toolset!==_)continue;let O=_==="none"?null:z.toolsets?.[_]??null,w=_!=="none"&&(O?.webSearch===!0||O?.webFetch===!0),R=_!=="none"&&O?.mcpServers?Object.keys(O.mcpServers):[],I=R.length>0,{config:C}=G4(L,z.targets);if(_!=="none"){if(w&&I)throw Error(`Toolset "${_}" mixes webSearch/webFetch with mcpServers; declare separate toolsets per shape so provenance can be attributed to one tool path.`);if(!w&&!I)throw Error(`Toolset "${_}" is declared but defines no runtime shape. Supported today: "none", web (webSearch/webFetch flags), MCP (mcpServers map). Other adapters (Firecrawl, native API search) land per release.`);if(C.provider!=="claude-code")throw Error(`Toolset "${_}" is implemented only on the claude-code interface. Interface "${L}" uses provider "${C.provider}"; rerun with a Claude Code interface or use toolset "none".`)}let M=[],y=[],p=[];if(w){if(O?.webSearch)M.push("WebSearch"),y.push("WebSearch"),p.push((j)=>j==="WebSearch");if(O?.webFetch)M.push("WebFetch"),y.push("WebFetch"),p.push((j)=>j==="WebFetch")}if(I)for(let j of R)M.push(`mcp__${j}__*`),p.push((d)=>d.startsWith(`mcp__${j}__`));let s=_==="none"?C:{...C,allowedTools:M,disallowedTools:[],mcpServers:I?O?.mcpServers:void 0,maxTurns:Math.max(C.maxTurns??0,15)},k=G.targetFactory?G.targetFactory(L,s):q4(L,s),o=_==="none",Z$=D==="none",U4=Z$||!o?[]:D===null?q:q.filter((j)=>j.id===D),N1=Z$||!o?[]:D===null?q.map((j)=>j.id):[D],W4=$.requiredSources??[],K0=o?W4.filter((j)=>N1.includes(j)):[],GX=XV($.prompt,D,q,o),JX=o?void 0:{sourceHint:zV(D,q)},B0;try{let j=_==="none"?J:void 0;B0=await k.run(GX,{tool:X,cwd:X.path,context:j,docs:U4,requiredSources:K0,discovery:JX,restrictBuiltinTools:_==="none"?void 0:y,onProgress:G.onProgress})}catch(j){B.push({cell:{interface:L,source:D,toolset:_},answerable:"NO",confidence:0,response:"",reason:`Error in cell: ${j instanceof Error?j.message:String(j)}`,citations:null,traps:{fired:[],avoided:($.traps??[]).map((d)=>d.id)},error:j instanceof Error?j.message:String(j)});continue}let V4=x0({response:B0.response,traps:$.traps??[]}),QX=V4.fired.length>0,I0=$.requiredSources!==void 0&&o?D$({response:B0.response,requiredSources:K0,registeredIds:N1}):null,m=$.expected!==void 0?N2({response:B0.response,expected:$.expected}):null,b$=_!=="none"&&p.length>0?{expected:M,used:(B0.toolsUsed??[]).filter((j)=>p.some((d)=>d(j)))}:null,YX=b$!==null&&b$.used.length===0,HX=()=>{let j=[];if(I0)j.push(I0.reason);if(m){let d=m.includes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),$0=m.excludes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),v0=[];if(d.length>0)v0.push(`missing includes: ${d.join(", ")}`);if($0.length>0)v0.push(`hit excludes: ${$0.join(", ")}`);j.push(v0.length>0?v0.join("; "):`expected checks satisfied (${m.satisfied}/${m.total})`)}return j.filter((d)=>d.length>0)},y$,x$,k$;if(QX)y$="NO",x$=0,k$=`Trap fired: ${V4.fired.map((j)=>`"${j.id}" (${j.reason})`).join("; ")}`;else if(YX){let j=b$;y$="NO",x$=0;let d=`Provenance failed: toolset "${_}" configured but none of [${j.expected.join(", ")}] were used (answer rests on model prior knowledge)`,$0=HX();k$=$0.length>0?`${d} | ${$0.join(" | ")}`:d}else{let j=[],d=[];if(I0)j.push({answerable:I0.answerable,confidence:I0.confidence}),d.push(I0.reason);if(m){let $0=m.total===0?100:Math.round(m.satisfied/m.total*100),v0=$0===100?"YES":$0===0?"NO":"PARTIAL";j.push({answerable:v0,confidence:$0});let l=m.includes.filter((m0)=>!m0.satisfied).map((m0)=>`"${m0.value}"`),u0=m.excludes.filter((m0)=>!m0.satisfied).map((m0)=>`"${m0.value}"`),S1=[];if(l.length>0)S1.push(`missing includes: ${l.join(", ")}`);if(u0.length>0)S1.push(`hit excludes: ${u0.join(", ")}`);d.push(S1.length>0?S1.join("; "):`expected checks satisfied (${m.satisfied}/${m.total})`)}if(b$)d.push(`tool use verified (${b$.used.join(", ")})`);if(j.length===0)y$="YES",x$=100,k$="No traps fired; no other contract declared";else{let $0={YES:0,PARTIAL:1,NO:2};y$=j.reduce((l,u0)=>$0[u0.answerable]>$0[l.answerable]?u0:l).answerable,x$=Math.round(j.reduce((l,u0)=>l+u0.confidence,0)/j.length),k$=d.filter((l)=>l.length>0).join(" | ")}}B.push({cell:{interface:L,source:D,toolset:_},answerable:y$,confidence:x$,response:B0.response,reason:k$,citations:I0?I0.citations:null,traps:V4,expected:m?{includes:m.includes,excludes:m.excludes,satisfied:m.satisfied,total:m.total}:void 0,toolsUsed:B0.toolsUsed,allResponses:B0.allResponses}),T=B0.metadata??T}}}let K=ZV($,q);return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,cells:B,verifierSamples:K,target:T,context:{name:Z}}}function ZV($,Z){let X=$.verifiers?.sources;if(!X||X.length===0)return;let z=new Map(Z.map((G)=>[G.id,G])),q=[];for(let G of X){let J=z.get(G);if(!J)continue;q.push({id:J.id,name:J.name,content:J.content})}return q.length>0?q:void 0}function XV($,Z,X,z){if(z)return $;if(Z===null||Z==="none")return $;let q=X.find((J)=>J.id===Z);if(!q)return $;let G=q.type==="url"?`The canonical source for this question is the documentation at ${q.source}. Use your available tools to research it.`:`The canonical source for this question is "${q.name}" (registered locally as ${q.id}). Use your available tools to research from authoritative sources.`;return`${$}
268
+ ${$}`,V=CM(SM(),`pickled-codex-${RM()}.txt`),K=["--ask-for-approval","never","exec","--json","--sandbox","read-only","--ignore-user-config","--ignore-rules","--ephemeral","--skip-git-repo-check","--cd",Y,"--model",J,"--output-last-message",V,"-"];try{let H=await this.spawnFn(this.binary,K,{cwd:Y,stdin:W}),{allResponses:B,toolsUsed:U}=jM(H.stdout);if(H.exitCode!==0)throw Error(`codex exec failed (exit ${H.exitCode}): ${H.stderr.trim()||"no stderr output"}`);let F="";try{F=(await this.readFileFn(V)).trim()}catch{F=B.length>0?B[B.length-1].text:""}if(B.length>0)B[B.length-1].type="final";return{response:F,allResponses:B,toolsUsed:U,sources:[],metadata:{model:J,category:this.category,provider:this.provider,target:this.name}}}finally{await AM(V,{force:!0})}}}function jM($){let Z=[],X=[];for(let Y of $.split(`
269
+ `)){let G=Y.trim();if(!G)continue;let z;try{z=JSON.parse(G)}catch{continue}let J=xM(z);if(J){let W=Z.length===0?"initial":"intermediate";Z.push({type:W,text:J})}let Q=kM(z);if(Q&&!X.includes(Q))X.push(Q)}return{allResponses:Z,toolsUsed:X}}function xM($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.message==="string")return Z.message;if(typeof Z.content==="string")return Z.content;if(typeof Z.type==="string"&&(Z.type==="assistant_message"||Z.type==="agent_message")&&typeof Z.text==="string")return Z.text;if(Z.type==="message"&&typeof Z.text==="string")return Z.text;return null}function kM($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.tool==="string")return Z.tool;if(typeof Z.type==="string"&&(Z.type==="tool_call"||Z.type==="function_call")&&typeof Z.name==="string")return Z.name;return null}var bM=async($,Z,X)=>{let Y=Bun.spawn([$,...Z],{cwd:X.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});Y.stdin.write(X.stdin),await Y.stdin.end();let[G,z,J]=await Promise.all([new Response(Y.stdout).text(),new Response(Y.stderr).text(),Y.exited]);return{exitCode:J,stdout:G,stderr:z}},fM=async($)=>{let Z=Bun.file($);if(!await Z.exists())throw Error(`Last-message file not found: ${$}`);return Z.text()};function $X($,Z){let X=Z??h0;switch(X.category){case"cli":return yM($,X);case"api":return gM($,X);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${X.category}`)}}function yM($,Z){switch(Z.provider){case"claude-code":return new d5($,Z);case"codex-cli":return new c5($,Z);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${Z.provider}`)}}function gM($,Z){switch(Z.provider){case"anthropic":return new Y5($,Z);case"openai":return new m5($,Z);case"google":throw Error("Google API target not yet implemented. Coming soon!");default:throw Error(`Unknown API provider: ${Z.provider}`)}}var P2="default";function ZX($,Z){if(!$||$===P2)return{name:P2,config:h0};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Target "${$}" not found, using default`),{name:P2,config:h0}}function l5($,Z){if(!$||$===P2)return{name:P2,config:{}};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Context "${$}" not found, using default`),{name:P2,config:{}}}var p5="__matrix__";function vM($){let Z=[],X=$.matrix?.target??["default"],Y=$.matrix?.context??["default"];for(let G of $.scenarios){let z=G.context?[G.context]:Y;if(G.matrix){for(let Q of z)Z.push({scenario:G,targetName:p5,contextName:Q});continue}let J=G.target?[G.target]:X;for(let Q of J)for(let W of z)Z.push({scenario:G,targetName:Q,contextName:W})}return Z}async function i5($,Z,X={}){let{onProgress:Y}=X,G=[];if(Z.scenarios.length===0)throw Error("No scenarios defined in config");let z=Z.docs?.sources??{},J=[];if(Object.keys(z).length>0){Y?.("Loading sources..."),J=await Z4(z,$.path);for(let K of J)Y?.(` [${K.id}] ${K.name}`);Y?.("")}let Q=J.map((K)=>K.id),W=vM(Z);if(X.scenarioFilter&&X.scenarioFilter.length>0){let K=new Set(X.scenarioFilter);if(W=W.filter((H)=>K.has(H.scenario.name)),W.length===0)throw Error(`No scenarios matched filter: ${[...K].join(", ")}. Declared scenarios: ${Z.scenarios.map((H)=>H.name).join(", ")}`)}let V="";for(let{scenario:K,targetName:H,contextName:B}of W){let U=hM(H,B);if(K.name!==V){if(V)Y?.("");Y?.(`"${K.name}"`),V=K.name}try{let F=await uM(K,H,B,$,Z,J,Q,X);G.push(F);let T=U?U.padEnd(18):"";if(F.cells){Y?.(` ${T} (matrix mode)`);for(let w of F.cells){let O=e0(w),P=` [${[w.cell.interface,w.cell.source??"-",w.cell.toolset].join(" \xB7 ")}]`.padEnd(40);Y?.(`${P} ${O.icon} ${O.label} (${O.confidence}%)`)}}else if(F.surfaces){Y?.(` ${T} (compare-surfaces mode)`);for(let w of F.surfaces){let O=e0(w),N=` [${w.active.join(",")}]`.padEnd(22);Y?.(`${N} ${O.icon} ${O.label} (${O.confidence}%)`)}}else{let w=e0({answerable:F.answerable??"NO",confidence:F.confidence??0,traps:F.traps??{fired:[],avoided:[]},error:F.error});Y?.(` ${T} ${w.icon} ${w.label} (${w.confidence}%)`)}}catch(F){let T=H==="default"?h0:Z.targets?.[H]??h0,w=K.requiredSources??[],O={scenario:K,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:w,missing:w,unknown:[]},traps:{fired:[],avoided:(K.traps??[]).map((P)=>P.id)},error:F instanceof Error?F.message:String(F),target:{target:H===p5?"matrix":H,category:T.category,provider:T.provider,model:T.model??"unknown"},context:{name:B}};G.push(O);let N=U?U.padEnd(18):"";Y?.(` ${N} \u2717 Error`)}}return Y?.(""),mM($,J,G)}function hM($,Z){if($==="default"&&Z==="default")return"";if(Z==="default")return`[${$}]`;return`[${$}/${Z}]`}async function uM($,Z,X,Y,G,z,J,Q){if($.matrix&&Z===p5)return dM($,X,Y,G,z,Q);let{config:W}=ZX(Z,G.targets),{config:V}=l5(X,G.contexts),K=Q.targetFactory?Q.targetFactory(Z,W):$X(Z,W);if($.compareSurfaces&&$.compareSurfaces.length>0){let E=[],I;for(let A of $.compareSurfaces){let C=new Set(A),D=z.filter((V$)=>C.has(V$.id)),k=($.requiredSources??[]).filter((V$)=>C.has(V$)),i=await K.run($.prompt,{tool:Y,cwd:Y.path,context:V,docs:D,requiredSources:k,onProgress:Q.onProgress}),l=b1({response:i.response,requiredSources:k,registeredIds:A}),R0=N$({response:i.response,traps:$.traps??[]}),A0=R0.fired.length>0,g$=A0?"NO":l.answerable,JX=A0?0:l.confidence,aZ=A0?`Trap fired: ${R0.fired.map((V$)=>`"${V$.id}" (${V$.reason})`).join("; ")}`:l.reason;E.push({active:A,answerable:g$,confidence:JX,response:i.response,reason:aZ,citations:l.citations,traps:R0,allResponses:i.allResponses}),I=i.metadata??I}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:E,target:I,context:{name:X}}}let H=$.requiredSources??[],B=await K.run($.prompt,{tool:Y,cwd:Y.path,context:V,docs:z,requiredSources:H,onProgress:Q.onProgress}),U=N$({response:B.response,traps:$.traps??[]}),F=U.fired.length>0,T=$.requiredSources!==void 0?b1({response:B.response,requiredSources:H,registeredIds:J}):null,w=$.expected!==void 0?a6({response:B.response,expected:$.expected}):null,O,N,P;if(F)O="NO",N=0,P=`Trap fired: ${U.fired.map((E)=>`"${E.id}" (${E.reason})`).join("; ")}`;else{let E=[],I=[];if(T)E.push({answerable:T.answerable,confidence:T.confidence}),I.push(T.reason);if(w){let A=w.total===0?100:Math.round(w.satisfied/w.total*100),C=A===100?"YES":A===0?"NO":"PARTIAL";E.push({answerable:C,confidence:A})}if(E.length===0)O="YES",N=100,P="No traps fired; no other contract declared";else{let A={YES:0,PARTIAL:1,NO:2};O=E.reduce((D,v)=>A[v.answerable]>A[D.answerable]?v:D).answerable,N=Math.round(E.reduce((D,v)=>D+v.confidence,0)/E.length),P=I.filter((D)=>D.length>0).join(" | ")}}return{scenario:$,answerable:O,confidence:N,response:B.response,reason:P,citations:T?T.citations:{cited:[],required:H,missing:[],unknown:[]},traps:U,target:B.metadata,context:{name:X},toolsUsed:B.toolsUsed,sources:B.sources,allResponses:B.allResponses}}function mM($,Z,X){let Y=[];for(let Q of X){if(Q.surfaces){for(let W of Q.surfaces)Y.push({answerable:W.answerable,confidence:W.confidence});continue}if(Q.cells){for(let W of Q.cells)Y.push({answerable:W.answerable,confidence:W.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)Y.push({answerable:Q.answerable,confidence:Q.confidence})}let G=Y.length,z=Y.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,J=G>0?Math.round(Y.reduce((Q,W)=>{if(W.answerable==="YES")return Q+W.confidence;if(W.answerable==="PARTIAL")return Q+W.confidence*0.5;return Q},0)/G):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:Z,scenarios:X,summary:{total:G,answered:z,unanswered:G-z,score:J}}}async function dM($,Z,X,Y,G,z){let{config:J}=l5(Z,Y.contexts),Q=$.matrix??{},W=$.target??"default",V=Q.interfaces??[W],K=Q.sources??[null],H=Q.toolsets??["none"],B=z.cellFilter??{},U=[],F;for(let w of V){if(B.interface&&B.interface!==w)continue;for(let O of K){if(B.source!==void 0&&B.source!==(O??""))continue;for(let N of H){if(B.toolset&&B.toolset!==N)continue;let P=N==="none"?null:Y.toolsets?.[N]??null,E=N!=="none"&&(P?.webSearch===!0||P?.webFetch===!0),I=N!=="none"&&P?.mcpServers?Object.keys(P.mcpServers):[],A=I.length>0,{config:C}=ZX(w,Y.targets);if(N!=="none"){if(E&&A)throw Error(`Toolset "${N}" mixes webSearch/webFetch with mcpServers; declare separate toolsets per shape so provenance can be attributed to one tool path.`);if(!E&&!A)throw Error(`Toolset "${N}" is declared but defines no runtime shape. Supported today: "none", web (webSearch/webFetch flags), MCP (mcpServers map). Other adapters (Firecrawl, native API search) land per release.`);if(A&&C.provider!=="claude-code")throw Error(`Toolset "${N}" (MCP) is implemented only on the claude-code interface today. Interface "${w}" uses provider "${C.provider}"; rerun with a Claude Code interface or use toolset "none".`);if(E&&C.provider!=="claude-code"&&C.provider!=="anthropic")throw Error(`Toolset "${N}" (web) is implemented on claude-code and anthropic interfaces today. Interface "${w}" uses provider "${C.provider}"; rerun with a supported interface or use toolset "none".`);if(E&&C.provider==="anthropic"&&!P?.webSearch)throw Error(`Toolset "${N}" on anthropic provider requires webSearch: true. The Anthropic API exposes a single server-side web tool; declare webSearch to enable it, or split web/fetch behaviour across separate toolsets.`)}let D=[],v=[],k=[],i=C.provider==="anthropic";if(E)if(i)k.push((g)=>g==="web_search");else{if(P?.webSearch)D.push("WebSearch"),v.push("WebSearch"),k.push((g)=>g==="WebSearch");if(P?.webFetch)D.push("WebFetch"),v.push("WebFetch"),k.push((g)=>g==="WebFetch")}if(A)for(let g of I)D.push(`mcp__${g}__*`),k.push((z0)=>z0.startsWith(`mcp__${g}__`));let l=N==="none"||i?C:{...C,allowedTools:D,disallowedTools:[],mcpServers:A?P?.mcpServers:void 0,maxTurns:Math.max(C.maxTurns??0,15)},R0=z.targetFactory?z.targetFactory(w,l):$X(w,l),A0=N==="none",g$=O==="none",JX=g$||!A0?[]:O===null?G:G.filter((g)=>g.id===O),aZ=g$||!A0?[]:O===null?G.map((g)=>g.id):[O],V$=$.requiredSources??[],Z3=A0?V$.filter((g)=>aZ.includes(g)):[],iz=lM($.prompt,O,G,A0),az=A0?void 0:{sourceHint:pM(O,G)},n0;try{let g=N==="none"?J:void 0;n0=await R0.run(iz,{tool:X,cwd:X.path,context:g,docs:JX,requiredSources:Z3,discovery:az,restrictBuiltinTools:N==="none"?void 0:v,webTools:E&&i?{search:P?.webSearch===!0}:void 0,onProgress:z.onProgress})}catch(g){U.push({cell:{interface:w,source:O,toolset:N},answerable:"NO",confidence:0,response:"",reason:`Error in cell: ${g instanceof Error?g.message:String(g)}`,citations:null,traps:{fired:[],avoided:($.traps??[]).map((z0)=>z0.id)},error:g instanceof Error?g.message:String(g)});continue}let QX=N$({response:n0.response,traps:$.traps??[]}),nz=QX.fired.length>0,H$=$.requiredSources!==void 0&&A0?b1({response:n0.response,requiredSources:Z3,registeredIds:aZ}):null,G0=$.expected!==void 0?a6({response:n0.response,expected:$.expected}):null,R2=N!=="none"&&k.length>0?{expected:D,used:(n0.toolsUsed??[]).filter((g)=>k.some((z0)=>z0(g)))}:null,rz=R2!==null&&R2.used.length===0,sz=()=>{let g=[];if(H$)g.push(H$.reason);if(G0){let z0=G0.includes.filter((Q0)=>!Q0.satisfied).map((Q0)=>`"${Q0.value}"`),S0=G0.excludes.filter((Q0)=>!Q0.satisfied).map((Q0)=>`"${Q0.value}"`),v$=[];if(z0.length>0)v$.push(`missing includes: ${z0.join(", ")}`);if(S0.length>0)v$.push(`hit excludes: ${S0.join(", ")}`);g.push(v$.length>0?v$.join("; "):`expected checks satisfied (${G0.satisfied}/${G0.total})`)}return g.filter((z0)=>z0.length>0)},A2,S2,C2;if(nz)A2="NO",S2=0,C2=`Trap fired: ${QX.fired.map((g)=>`"${g.id}" (${g.reason})`).join("; ")}`;else if(rz){let g=R2;A2="NO",S2=0;let z0=`Provenance failed: toolset "${N}" configured but none of [${g.expected.join(", ")}] were used (answer rests on model prior knowledge)`,S0=sz();C2=S0.length>0?`${z0} | ${S0.join(" | ")}`:z0}else{let g=[],z0=[];if(H$)g.push({answerable:H$.answerable,confidence:H$.confidence}),z0.push(H$.reason);if(G0){let S0=G0.total===0?100:Math.round(G0.satisfied/G0.total*100),v$=S0===100?"YES":S0===0?"NO":"PARTIAL";g.push({answerable:v$,confidence:S0});let Q0=G0.includes.filter((u$)=>!u$.satisfied).map((u$)=>`"${u$.value}"`),h$=G0.excludes.filter((u$)=>!u$.satisfied).map((u$)=>`"${u$.value}"`),nZ=[];if(Q0.length>0)nZ.push(`missing includes: ${Q0.join(", ")}`);if(h$.length>0)nZ.push(`hit excludes: ${h$.join(", ")}`);z0.push(nZ.length>0?nZ.join("; "):`expected checks satisfied (${G0.satisfied}/${G0.total})`)}if(R2)z0.push(`tool use verified (${R2.used.join(", ")})`);if(g.length===0)A2="YES",S2=100,C2="No traps fired; no other contract declared";else{let S0={YES:0,PARTIAL:1,NO:2};A2=g.reduce((Q0,h$)=>S0[h$.answerable]>S0[Q0.answerable]?h$:Q0).answerable,S2=Math.round(g.reduce((Q0,h$)=>Q0+h$.confidence,0)/g.length),C2=z0.filter((Q0)=>Q0.length>0).join(" | ")}}U.push({cell:{interface:w,source:O,toolset:N},answerable:A2,confidence:S2,response:n0.response,reason:C2,citations:H$?H$.citations:null,traps:QX,expected:G0?{includes:G0.includes,excludes:G0.excludes,satisfied:G0.satisfied,total:G0.total}:void 0,toolsUsed:n0.toolsUsed,allResponses:n0.allResponses}),F=n0.metadata??F}}}let T=cM($,G);return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,cells:U,verifierSamples:T,target:F,context:{name:Z}}}function cM($,Z){let X=$.verifiers?.sources;if(!X||X.length===0)return;let Y=new Map(Z.map((z)=>[z.id,z])),G=[];for(let z of X){let J=Y.get(z);if(!J)continue;G.push({id:J.id,name:J.name,content:J.content})}return G.length>0?G:void 0}function lM($,Z,X,Y){if(Y)return $;if(Z===null||Z==="none")return $;let G=X.find((J)=>J.id===Z);if(!G)return $;let z=G.type==="url"?`The canonical source for this question is the documentation at ${G.source}. Use your available tools to research it.`:`The canonical source for this question is "${G.name}" (registered locally as ${G.id}). Use your available tools to research from authoritative sources.`;return`${$}
247
270
 
248
- ${G}`}function zV($,Z){if($===null||$==="none")return null;let X=Z.find((z)=>z.id===$);if(!X)return null;if(X.type==="url")return X.source;return X.name}var gZ=($=0)=>(Z)=>`\x1B[${Z+$}m`,vZ=($=0)=>(Z)=>`\x1B[${38+$};5;${Z}m`,uZ=($=0)=>(Z,X,z)=>`\x1B[${38+$};2;${Z};${X};${z}m`,f={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},qD=Object.keys(f.modifier),qV=Object.keys(f.color),GV=Object.keys(f.bgColor),GD=[...qV,...GV];function JV(){let $=new Map;for(let[Z,X]of Object.entries(f)){for(let[z,q]of Object.entries(X))f[z]={open:`\x1B[${q[0]}m`,close:`\x1B[${q[1]}m`},X[z]=f[z],$.set(q[0],q[1]);Object.defineProperty(f,Z,{value:X,enumerable:!1})}return Object.defineProperty(f,"codes",{value:$,enumerable:!1}),f.color.close="\x1B[39m",f.bgColor.close="\x1B[49m",f.color.ansi=gZ(),f.color.ansi256=vZ(),f.color.ansi16m=uZ(),f.bgColor.ansi=gZ(10),f.bgColor.ansi256=vZ(10),f.bgColor.ansi16m=uZ(10),Object.defineProperties(f,{rgbToAnsi256:{value(Z,X,z){if(Z===X&&X===z){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(X/255*5)+Math.round(z/255*5)},enumerable:!1},hexToRgb:{value(Z){let X=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Z.toString(16));if(!X)return[0,0,0];let[z]=X;if(z.length===3)z=[...z].map((G)=>G+G).join("");let q=Number.parseInt(z,16);return[q>>16&255,q>>8&255,q&255]},enumerable:!1},hexToAnsi256:{value:(Z)=>f.rgbToAnsi256(...f.hexToRgb(Z)),enumerable:!1},ansi256ToAnsi:{value(Z){if(Z<8)return 30+Z;if(Z<16)return 90+(Z-8);let X,z,q;if(Z>=232)X=((Z-232)*10+8)/255,z=X,q=X;else{Z-=16;let Q=Z%36;X=Math.floor(Z/36)/5,z=Math.floor(Q/6)/5,q=Q%6/5}let G=Math.max(X,z,q)*2;if(G===0)return 30;let J=30+(Math.round(q)<<2|Math.round(z)<<1|Math.round(X));if(G===2)J+=60;return J},enumerable:!1},rgbToAnsi:{value:(Z,X,z)=>f.ansi256ToAnsi(f.rgbToAnsi256(Z,X,z)),enumerable:!1},hexToAnsi:{value:(Z)=>f.ansi256ToAnsi(f.hexToAnsi256(Z)),enumerable:!1}}),f}var QV=JV(),H0=QV;import B5 from"process";import YV from"os";import mZ from"tty";function J0($,Z=globalThis.Deno?globalThis.Deno.args:B5.argv){let X=$.startsWith("-")?"":$.length===1?"-":"--",z=Z.indexOf(X+$),q=Z.indexOf("--");return z!==-1&&(q===-1||z<q)}var{env:h}=B5,J4;if(J0("no-color")||J0("no-colors")||J0("color=false")||J0("color=never"))J4=0;else if(J0("color")||J0("colors")||J0("color=true")||J0("color=always"))J4=1;function HV(){if("FORCE_COLOR"in h){if(h.FORCE_COLOR==="true")return 1;if(h.FORCE_COLOR==="false")return 0;return h.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(h.FORCE_COLOR,10),3)}}function UV($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function WV($,{streamIsTTY:Z,sniffFlags:X=!0}={}){let z=HV();if(z!==void 0)J4=z;let q=X?J4:z;if(q===0)return 0;if(X){if(J0("color=16m")||J0("color=full")||J0("color=truecolor"))return 3;if(J0("color=256"))return 2}if("TF_BUILD"in h&&"AGENT_NAME"in h)return 1;if($&&!Z&&q===void 0)return 0;let G=q||0;if(h.TERM==="dumb")return G;if(B5.platform==="win32"){let J=YV.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in h){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((J)=>(J in h)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((J)=>(J in h))||h.CI_NAME==="codeship")return 1;return G}if("TEAMCITY_VERSION"in h)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(h.TEAMCITY_VERSION)?1:0;if(h.COLORTERM==="truecolor")return 3;if(h.TERM==="xterm-kitty")return 3;if(h.TERM==="xterm-ghostty")return 3;if(h.TERM==="wezterm")return 3;if("TERM_PROGRAM"in h){let J=Number.parseInt((h.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(h.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(h.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(h.TERM))return 1;if("COLORTERM"in h)return 1;return G}function dZ($,Z={}){let X=WV($,{streamIsTTY:$&&$.isTTY,...Z});return UV(X)}var VV={stdout:dZ({isTTY:mZ.isatty(1)}),stderr:dZ({isTTY:mZ.isatty(2)})},pZ=VV;function lZ($,Z,X){let z=$.indexOf(Z);if(z===-1)return $;let q=Z.length,G=0,J="";do J+=$.slice(G,z)+Z+X,G=z+q,z=$.indexOf(Z,G);while(z!==-1);return J+=$.slice(G),J}function cZ($,Z,X,z){let q=0,G="";do{let J=$[z-1]==="\r";G+=$.slice(q,J?z-1:z)+Z+(J?`\r
271
+ ${z}`}function pM($,Z){if($===null||$==="none")return null;let X=Z.find((Y)=>Y.id===$);if(!X)return null;if(X.type==="url")return X.source;return X.name}var Ez=($=0)=>(Z)=>`\x1B[${Z+$}m`,Rz=($=0)=>(Z)=>`\x1B[${38+$};5;${Z}m`,Az=($=0)=>(Z,X,Y)=>`\x1B[${38+$};2;${Z};${X};${Y}m`,a={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Yf=Object.keys(a.modifier),iM=Object.keys(a.color),aM=Object.keys(a.bgColor),Gf=[...iM,...aM];function nM(){let $=new Map;for(let[Z,X]of Object.entries(a)){for(let[Y,G]of Object.entries(X))a[Y]={open:`\x1B[${G[0]}m`,close:`\x1B[${G[1]}m`},X[Y]=a[Y],$.set(G[0],G[1]);Object.defineProperty(a,Z,{value:X,enumerable:!1})}return Object.defineProperty(a,"codes",{value:$,enumerable:!1}),a.color.close="\x1B[39m",a.bgColor.close="\x1B[49m",a.color.ansi=Ez(),a.color.ansi256=Rz(),a.color.ansi16m=Az(),a.bgColor.ansi=Ez(10),a.bgColor.ansi256=Rz(10),a.bgColor.ansi16m=Az(10),Object.defineProperties(a,{rgbToAnsi256:{value(Z,X,Y){if(Z===X&&X===Y){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(X/255*5)+Math.round(Y/255*5)},enumerable:!1},hexToRgb:{value(Z){let X=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Z.toString(16));if(!X)return[0,0,0];let[Y]=X;if(Y.length===3)Y=[...Y].map((z)=>z+z).join("");let G=Number.parseInt(Y,16);return[G>>16&255,G>>8&255,G&255]},enumerable:!1},hexToAnsi256:{value:(Z)=>a.rgbToAnsi256(...a.hexToRgb(Z)),enumerable:!1},ansi256ToAnsi:{value(Z){if(Z<8)return 30+Z;if(Z<16)return 90+(Z-8);let X,Y,G;if(Z>=232)X=((Z-232)*10+8)/255,Y=X,G=X;else{Z-=16;let Q=Z%36;X=Math.floor(Z/36)/5,Y=Math.floor(Q/6)/5,G=Q%6/5}let z=Math.max(X,Y,G)*2;if(z===0)return 30;let J=30+(Math.round(G)<<2|Math.round(Y)<<1|Math.round(X));if(z===2)J+=60;return J},enumerable:!1},rgbToAnsi:{value:(Z,X,Y)=>a.ansi256ToAnsi(a.rgbToAnsi256(Z,X,Y)),enumerable:!1},hexToAnsi:{value:(Z)=>a.ansi256ToAnsi(a.hexToAnsi256(Z)),enumerable:!1}}),a}var rM=nM(),v0=rM;import a5 from"process";import sM from"os";import Sz from"tty";function b0($,Z=globalThis.Deno?globalThis.Deno.args:a5.argv){let X=$.startsWith("-")?"":$.length===1?"-":"--",Y=Z.indexOf(X+$),G=Z.indexOf("--");return Y!==-1&&(G===-1||Y<G)}var{env:n}=a5,XX;if(b0("no-color")||b0("no-colors")||b0("color=false")||b0("color=never"))XX=0;else if(b0("color")||b0("colors")||b0("color=true")||b0("color=always"))XX=1;function oM(){if("FORCE_COLOR"in n){if(n.FORCE_COLOR==="true")return 1;if(n.FORCE_COLOR==="false")return 0;return n.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(n.FORCE_COLOR,10),3)}}function tM($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function eM($,{streamIsTTY:Z,sniffFlags:X=!0}={}){let Y=oM();if(Y!==void 0)XX=Y;let G=X?XX:Y;if(G===0)return 0;if(X){if(b0("color=16m")||b0("color=full")||b0("color=truecolor"))return 3;if(b0("color=256"))return 2}if("TF_BUILD"in n&&"AGENT_NAME"in n)return 1;if($&&!Z&&G===void 0)return 0;let z=G||0;if(n.TERM==="dumb")return z;if(a5.platform==="win32"){let J=sM.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in n){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((J)=>(J in n)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((J)=>(J in n))||n.CI_NAME==="codeship")return 1;return z}if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if(n.TERM==="xterm-kitty")return 3;if(n.TERM==="xterm-ghostty")return 3;if(n.TERM==="wezterm")return 3;if("TERM_PROGRAM"in n){let J=Number.parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(n.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM))return 1;if("COLORTERM"in n)return 1;return z}function Cz($,Z={}){let X=eM($,{streamIsTTY:$&&$.isTTY,...Z});return tM(X)}var $N={stdout:Cz({isTTY:Sz.isatty(1)}),stderr:Cz({isTTY:Sz.isatty(2)})},Iz=$N;function jz($,Z,X){let Y=$.indexOf(Z);if(Y===-1)return $;let G=Z.length,z=0,J="";do J+=$.slice(z,Y)+Z+X,z=Y+G,Y=$.indexOf(Z,z);while(Y!==-1);return J+=$.slice(z),J}function xz($,Z,X,Y){let G=0,z="";do{let J=$[Y-1]==="\r";z+=$.slice(G,J?Y-1:Y)+Z+(J?`\r
249
272
  `:`
250
- `)+X,q=z+1,z=$.indexOf(`
251
- `,q)}while(z!==-1);return G+=$.slice(q),G}var{stdout:iZ,stderr:aZ}=pZ,L5=Symbol("GENERATOR"),C$=Symbol("STYLER"),A1=Symbol("IS_EMPTY"),nZ=["ansi","ansi","ansi256","ansi16m"],E$=Object.create(null),KV=($,Z={})=>{if(Z.level&&!(Number.isInteger(Z.level)&&Z.level>=0&&Z.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let X=iZ?iZ.level:0;$.level=Z.level===void 0?X:Z.level};var BV=($)=>{let Z=(...X)=>X.join(" ");return KV(Z,$),Object.setPrototypeOf(Z,j1.prototype),Z};function j1($){return BV($)}Object.setPrototypeOf(j1.prototype,Function.prototype);for(let[$,Z]of Object.entries(H0))E$[$]={get(){let X=Q4(this,D5(Z.open,Z.close,this[C$]),this[A1]);return Object.defineProperty(this,$,{value:X}),X}};E$.visible={get(){let $=Q4(this,this[C$],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var T5=($,Z,X,...z)=>{if($==="rgb"){if(Z==="ansi16m")return H0[X].ansi16m(...z);if(Z==="ansi256")return H0[X].ansi256(H0.rgbToAnsi256(...z));return H0[X].ansi(H0.rgbToAnsi(...z))}if($==="hex")return T5("rgb",Z,X,...H0.hexToRgb(...z));return H0[X][$](...z)},LV=["rgb","hex","ansi256"];for(let $ of LV){E$[$]={get(){let{level:X}=this;return function(...z){let q=D5(T5($,nZ[X],"color",...z),H0.color.close,this[C$]);return Q4(this,q,this[A1])}}};let Z="bg"+$[0].toUpperCase()+$.slice(1);E$[Z]={get(){let{level:X}=this;return function(...z){let q=D5(T5($,nZ[X],"bgColor",...z),H0.bgColor.close,this[C$]);return Q4(this,q,this[A1])}}}}var TV=Object.defineProperties(()=>{},{...E$,level:{enumerable:!0,get(){return this[L5].level},set($){this[L5].level=$}}}),D5=($,Z,X)=>{let z,q;if(X===void 0)z=$,q=Z;else z=X.openAll+$,q=Z+X.closeAll;return{open:$,close:Z,openAll:z,closeAll:q,parent:X}},Q4=($,Z,X)=>{let z=(...q)=>DV(z,q.length===1?""+q[0]:q.join(" "));return Object.setPrototypeOf(z,TV),z[L5]=$,z[C$]=Z,z[A1]=X,z},DV=($,Z)=>{if($.level<=0||!Z)return $[A1]?"":Z;let X=$[C$];if(X===void 0)return Z;let{openAll:z,closeAll:q}=X;if(Z.includes("\x1B"))while(X!==void 0)Z=lZ(Z,X.close,X.open),X=X.parent;let G=Z.indexOf(`
252
- `);if(G!==-1)Z=cZ(Z,q,z,G);return z+Z+q};Object.defineProperties(j1.prototype,E$);var _V=j1(),LD=j1({level:aZ?aZ.level:0});var P=_V;var sZ="\u2500".repeat(55);function _5($){if($==="success")return P.green;if($==="warning")return P.yellow;return P.red}function FV($){if($>=70)return P.green;if($>=50)return P.yellow;return P.red}function F5($){if($.label==="Error")return $.label;return`${$.label} (${$.confidence}%)`}function MV($){let Z=F0({answerable:$.answerable??"NO",confidence:$.confidence??0,traps:$.traps??{fired:[],avoided:[]},error:$.error}),X=_5(Z.tone);return{icon:X(Z.icon),status:F5(Z),color:X}}function OV($){let Z=$.target?.target??"default",X=$.context?.name??"default";if(Z==="default"&&X==="default")return"";if(X==="default")return P.dim(`[${Z}]`);return P.dim(`[${Z}/${X}]`)}function wV($){let Z=$.map((X)=>X.scenario.name);return new Set(Z).size!==Z.length}function Y4($){return $.map((Z)=>`[${Z}]`).join(", ")}function M5($,Z){let X=[];if($.error)return X.push(P.dim(`${Z}error: ${$.error}`)),X;if($.traps.fired.length>0)for(let z of $.traps.fired)X.push(P.red(`${Z}trap: ${z.id}`)),X.push(P.dim(`${Z}reason: ${z.reason}`)),X.push(P.dim(`${Z}match: "${z.matched}"`));else if($.reason&&$.answerable!=="YES")X.push(P.dim(`${Z}reason: ${$.reason}`));if($.citations.cited.length>0)X.push(P.dim(`${Z}cited: ${Y4($.citations.cited)}`));if($.citations.missing.length>0)X.push(P.dim(`${Z}missing: ${Y4($.citations.missing)}`));if($.citations.unknown.length>0)X.push(P.dim(`${Z}unknown: ${Y4($.citations.unknown)}`));return X}function rZ($,Z){if(!$.traps||!$.citations)return[];return M5({error:$.error,traps:$.traps,reason:$.reason??"",answerable:$.answerable??"NO",citations:$.citations},Z)}function oZ($){let{icon:Z,status:X,color:z}=MV($),q=OV($),G=`${Z} ${X}`;return q?`${q} ${z(G)}`:z(G)}function tZ($,Z){if(!$.cells)return[];let X=[];X.push(`${Z}${P.dim("Matrix cells (interface \xB7 source \xB7 toolset)")}`);for(let z of $.cells){let q=F0(z),G=_5(q.tone),J=`[${z.cell.interface} \xB7 ${z.cell.source??"-"} \xB7 ${z.cell.toolset}]`,Q=P.dim(J),Y=`${G(q.icon)} ${G(F5(q))}`;if(X.push(`${Z}${Q} ${Y}`),X.push(...M5({traps:z.traps,reason:z.reason,answerable:z.answerable,citations:z.citations??{cited:[],required:[],missing:[],unknown:[]}},`${Z} `)),z.expected){let H=z.expected.includes.filter((U)=>!U.satisfied).map((U)=>`"${U.value}"`),W=z.expected.excludes.filter((U)=>!U.satisfied).map((U)=>`"${U.value}"`);if(H.length>0)X.push(P.dim(`${Z} expected.includes missing: ${H.join(", ")}`));if(W.length>0)X.push(P.dim(`${Z} expected.excludes hit: ${W.join(", ")}`))}if(z.toolsUsed&&z.toolsUsed.length>0)X.push(P.dim(`${Z} tools: ${z.toolsUsed.join(", ")}`))}if($.verifierSamples&&$.verifierSamples.length>0){X.push(`${Z}${P.dim("Verifier samples (human review; never LLM-judged)")}`);for(let z of $.verifierSamples){let q=z.content.slice(0,200).replace(/\s+/g," ").trim(),G=z.content.length>200?"...":"";X.push(P.dim(`${Z} [${z.id}] ${z.name}`)),X.push(P.dim(`${Z} ${q}${G}`))}}return X}function eZ($,Z){if(!$.surfaces)return[];let X=[];X.push(`${Z}${P.dim("Citations scoped to active surface (compare mode)")}`);for(let z of $.surfaces){let q=F0(z),G=_5(q.tone),J=P.dim(`[${z.active.join(",")}]`),Q=`${G(q.icon)} ${G(F5(q))}`;X.push(`${Z}${J} ${Q}`),X.push(...M5({traps:z.traps,reason:z.reason,answerable:z.answerable,citations:z.citations},`${Z} `))}return X}function PV($){let Z=0,X=0,z=0;for(let q of $){if(q.surfaces){for(let G of q.surfaces)Z+=G.traps.fired.length,X+=G.citations.missing.length,z+=G.citations.unknown.length;continue}if(q.traps)Z+=q.traps.fired.length;if(q.citations)X+=q.citations.missing.length,z+=q.citations.unknown.length}if(Z>0&&X+z>0)return"Review fired traps and citation gaps.";if(Z>0)return"Review fired traps before trusting this surface.";if(X+z>0)return"Review missing and unknown citations.";return"Citations hold. No declared traps fired."}function IV($,Z){let X=$.summary.score,q=`Overall: ${FV(X)(`${X}`)} / 100`;if(Z===void 0||Z<=0)return q;let J=X>=Z?P.green("run passes"):P.red("run fails");return`${q} \xB7 threshold ${Z} \xB7 ${J}`}function $X($,Z={}){let{tool:X,scenarios:z,summary:q}=$,G=z,J=[];if(J.push(P.bold("pickled check")),J.push(sZ),J.push(`Tool: ${P.cyan(X.name)}`),$.docs.length>0)J.push(`Sources: ${P.dim(Y4($.docs.map((Q)=>Q.id)))}`);else J.push(`Sources: ${P.dim("none registered")}`);if(J.push(`Scenarios: ${P.dim(String(q.total))}`),J.push(""),wV(G)){let Q=new Map;for(let Y of G){let H=Y.scenario.name;if(!Q.has(H))Q.set(H,[]);Q.get(H)?.push(Y)}for(let[Y,H]of Q){J.push(`Scenario: ${Y}`);for(let W of H)if(W.cells)J.push(...tZ(W," "));else if(W.surfaces)J.push(...eZ(W," "));else J.push(` ${oZ(W)}`),J.push(...rZ(W," "));J.push("")}}else for(let Q of G){if(J.push(`Scenario: ${Q.scenario.name}`),Q.cells)J.push(...tZ(Q," "));else if(Q.surfaces)J.push(...eZ(Q," "));else J.push(` ${oZ(Q)}`),J.push(...rZ(Q," "));J.push("")}return J.push(sZ),J.push(IV($,Z.threshold)),J.push(P.dim(PV(z))),J.join(`
253
- `)}function O5($,Z={}){console.log($X($,Z)),console.log()}function H4($,Z={}){if(Z.verbose)return JSON.stringify($,null,2);let X={...$,docs:$.docs.map((z)=>({...z,content:""})),scenarios:$.scenarios.map((z)=>{let{allResponses:q,verifierSamples:G,cells:J,surfaces:Q,...Y}=z;return{...Y,verifierSamples:G?.map((H)=>({...H,content:""})),cells:J?.map((H)=>{let{allResponses:W,...U}=H;return U}),surfaces:Q?.map((H)=>{let{allResponses:W,...U}=H;return U})}})};return JSON.stringify(X,null,2)}function AV($){if($.format&&$.format!=="terminal")return $.format;if($.json)return"json";return $.format??"terminal"}async function ZX($,Z){let{output:X}=Z,z=AV(Z),q=RV.resolve($),G;try{G=await j2({targetRepo:q})}catch(U){console.error(P.red(U instanceof Error?U.message:U)),process.exit(1)}let J;if(z==="json")J=M2(G);else if(z==="markdown")J=F2(G);else J=O2(G);if(X)await Bun.write(X,J);else await jV(`${J}
254
- `);let Q=G.findings.filter((U)=>U.severity==="error").length,Y=G.findings.filter((U)=>U.severity==="warning").length;if(z!=="json"&&!X)if(console.log(),Q===0&&Y===0)console.log(P.green("Audit clean. No issues found."));else{let U=Q>0?P.red:P.yellow;console.log(U(`Audit found ${Q} error(s), ${Y} warning(s).`))}if((Z.failOn??"error")==="warning"?Q+Y>0:Q>0)process.exit(1)}function jV($){return new Promise((Z,X)=>{process.stdout.write($,(z)=>{if(z)X(z);else Z()})})}import NV from"path";async function zX($,Z){let{json:X,output:z,verbose:q}=Z,G=(K)=>!X&&console.log(K),J=NV.resolve($),Q;try{Q=await B$(J)}catch(K){console.error(P.red(K instanceof Error?K.message:K)),console.error(),console.error(P.dim("Run `pickled init` to create a config file")),process.exit(1)}if(Z.target){let K=Q.scenarios.length;try{Q=f9(Q,Z.target)}catch(D){console.error(P.red(D instanceof Error?D.message:String(D))),process.exit(1)}let L=K-Q.scenarios.length;if(L>0&&!X)G(P.dim(`Skipping ${L} scenario(s) with explicit target != "${Z.target}"`))}let Y={name:Q.tool.name,description:Q.tool.description,path:J};if(q){G(P.bold("pickled check")),G(""),G(P.dim(` Tool: ${Y.name}`)),G(P.dim(` Scenarios: ${Q.scenarios.length}`));for(let K of Q.scenarios)G(P.dim(` - ${K.name}`))}let H;try{H=SV(Z.threshold,Q.threshold)}catch(K){console.error(P.red(K instanceof Error?K.message:K)),process.exit(1)}let W=Z.interface??Z.target,U=W||Z.source||Z.toolset?{interface:W,source:Z.source,toolset:Z.toolset}:void 0,V=Z.scenario?[Z.scenario]:void 0,B=await K5(Y,Q,{onProgress:q?(K)=>{if(!X)G(P.dim(` ${K}`))}:void 0,cellFilter:U,scenarioFilter:V}),T=H>0&&B.summary.score<H;if(z)await Bun.write(z,H4(B,{verbose:q}));else if(X)await CV(`${H4(B,{verbose:q})}
255
- `);else O5(B,{threshold:H});if(T){if(X||z)console.error(P.red(`Overall: ${B.summary.score} / 100 \xB7 threshold ${H} \xB7 run fails`)),console.error(P.dim("Review failed scenarios before trusting this surface."));process.exit(1)}}function SV($,Z){if($===void 0){if(Z===void 0)return 0;return XX(Z,"pickled.yml threshold")}return XX($,"--threshold")}function XX($,Z){if(typeof $==="number"){if(Number.isInteger($)&&$>=0&&$<=100)return $;throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`)}if(typeof $==="string"&&/^\d+$/.test($)){let X=Number($);if(X<=100)return X}if(typeof $==="string")throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`);throw Error(`Invalid ${Z}. Expected an integer from 0 to 100.`)}function CV($){return new Promise((Z,X)=>{process.stdout.write($,(z)=>{if(z)X(z);else Z()})})}import EV from"path";var bV=`# pickled.yml - Agent legibility check for your product
273
+ `)+X,G=Y+1,Y=$.indexOf(`
274
+ `,G)}while(Y!==-1);return z+=$.slice(G),z}var{stdout:kz,stderr:bz}=Iz,n5=Symbol("GENERATOR"),D2=Symbol("STYLER"),pZ=Symbol("IS_EMPTY"),fz=["ansi","ansi","ansi256","ansi16m"],E2=Object.create(null),ZN=($,Z={})=>{if(Z.level&&!(Number.isInteger(Z.level)&&Z.level>=0&&Z.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let X=kz?kz.level:0;$.level=Z.level===void 0?X:Z.level};var XN=($)=>{let Z=(...X)=>X.join(" ");return ZN(Z,$),Object.setPrototypeOf(Z,iZ.prototype),Z};function iZ($){return XN($)}Object.setPrototypeOf(iZ.prototype,Function.prototype);for(let[$,Z]of Object.entries(v0))E2[$]={get(){let X=YX(this,s5(Z.open,Z.close,this[D2]),this[pZ]);return Object.defineProperty(this,$,{value:X}),X}};E2.visible={get(){let $=YX(this,this[D2],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var r5=($,Z,X,...Y)=>{if($==="rgb"){if(Z==="ansi16m")return v0[X].ansi16m(...Y);if(Z==="ansi256")return v0[X].ansi256(v0.rgbToAnsi256(...Y));return v0[X].ansi(v0.rgbToAnsi(...Y))}if($==="hex")return r5("rgb",Z,X,...v0.hexToRgb(...Y));return v0[X][$](...Y)},YN=["rgb","hex","ansi256"];for(let $ of YN){E2[$]={get(){let{level:X}=this;return function(...Y){let G=s5(r5($,fz[X],"color",...Y),v0.color.close,this[D2]);return YX(this,G,this[pZ])}}};let Z="bg"+$[0].toUpperCase()+$.slice(1);E2[Z]={get(){let{level:X}=this;return function(...Y){let G=s5(r5($,fz[X],"bgColor",...Y),v0.bgColor.close,this[D2]);return YX(this,G,this[pZ])}}}}var GN=Object.defineProperties(()=>{},{...E2,level:{enumerable:!0,get(){return this[n5].level},set($){this[n5].level=$}}}),s5=($,Z,X)=>{let Y,G;if(X===void 0)Y=$,G=Z;else Y=X.openAll+$,G=Z+X.closeAll;return{open:$,close:Z,openAll:Y,closeAll:G,parent:X}},YX=($,Z,X)=>{let Y=(...G)=>zN(Y,G.length===1?""+G[0]:G.join(" "));return Object.setPrototypeOf(Y,GN),Y[n5]=$,Y[D2]=Z,Y[pZ]=X,Y},zN=($,Z)=>{if($.level<=0||!Z)return $[pZ]?"":Z;let X=$[D2];if(X===void 0)return Z;let{openAll:Y,closeAll:G}=X;if(Z.includes("\x1B"))while(X!==void 0)Z=jz(Z,X.close,X.open),X=X.parent;let z=Z.indexOf(`
275
+ `);if(z!==-1)Z=xz(Z,G,Y,z);return Y+Z+G};Object.defineProperties(iZ.prototype,E2);var JN=iZ(),qf=iZ({level:bz?bz.level:0});var j=JN;var yz="\u2500".repeat(55);function o5($){if($==="success")return j.green;if($==="warning")return j.yellow;return j.red}function QN($){if($>=70)return j.green;if($>=50)return j.yellow;return j.red}function t5($){if($.label==="Error")return $.label;return`${$.label} (${$.confidence}%)`}function WN($){let Z=e0({answerable:$.answerable??"NO",confidence:$.confidence??0,traps:$.traps??{fired:[],avoided:[]},error:$.error}),X=o5(Z.tone);return{icon:X(Z.icon),status:t5(Z),color:X}}function VN($){let Z=$.target?.target??"default",X=$.context?.name??"default";if(Z==="default"&&X==="default")return"";if(X==="default")return j.dim(`[${Z}]`);return j.dim(`[${Z}/${X}]`)}function HN($){let Z=$.map((X)=>X.scenario.name);return new Set(Z).size!==Z.length}function GX($){return $.map((Z)=>`[${Z}]`).join(", ")}function e5($,Z){let X=[];if($.error)return X.push(j.dim(`${Z}error: ${$.error}`)),X;if($.traps.fired.length>0)for(let Y of $.traps.fired)X.push(j.red(`${Z}trap: ${Y.id}`)),X.push(j.dim(`${Z}reason: ${Y.reason}`)),X.push(j.dim(`${Z}match: "${Y.matched}"`));else if($.reason&&$.answerable!=="YES")X.push(j.dim(`${Z}reason: ${$.reason}`));if($.citations.cited.length>0)X.push(j.dim(`${Z}cited: ${GX($.citations.cited)}`));if($.citations.missing.length>0)X.push(j.dim(`${Z}missing: ${GX($.citations.missing)}`));if($.citations.unknown.length>0)X.push(j.dim(`${Z}unknown: ${GX($.citations.unknown)}`));return X}function gz($,Z){if(!$.traps||!$.citations)return[];return e5({error:$.error,traps:$.traps,reason:$.reason??"",answerable:$.answerable??"NO",citations:$.citations},Z)}function vz($){let{icon:Z,status:X,color:Y}=WN($),G=VN($),z=`${Z} ${X}`;return G?`${G} ${Y(z)}`:Y(z)}function hz($,Z){if(!$.cells)return[];let X=[];X.push(`${Z}${j.dim("Matrix cells (interface \xB7 source \xB7 toolset)")}`);for(let Y of $.cells){let G=e0(Y),z=o5(G.tone),J=`[${Y.cell.interface} \xB7 ${Y.cell.source??"-"} \xB7 ${Y.cell.toolset}]`,Q=j.dim(J),W=`${z(G.icon)} ${z(t5(G))}`;if(X.push(`${Z}${Q} ${W}`),X.push(...e5({traps:Y.traps,reason:Y.reason,answerable:Y.answerable,citations:Y.citations??{cited:[],required:[],missing:[],unknown:[]}},`${Z} `)),Y.expected){let V=Y.expected.includes.filter((H)=>!H.satisfied).map((H)=>`"${H.value}"`),K=Y.expected.excludes.filter((H)=>!H.satisfied).map((H)=>`"${H.value}"`);if(V.length>0)X.push(j.dim(`${Z} expected.includes missing: ${V.join(", ")}`));if(K.length>0)X.push(j.dim(`${Z} expected.excludes hit: ${K.join(", ")}`))}if(Y.toolsUsed&&Y.toolsUsed.length>0)X.push(j.dim(`${Z} tools: ${Y.toolsUsed.join(", ")}`))}if($.verifierSamples&&$.verifierSamples.length>0){X.push(`${Z}${j.dim("Verifier samples (human review; never LLM-judged)")}`);for(let Y of $.verifierSamples){let G=Y.content.slice(0,200).replace(/\s+/g," ").trim(),z=Y.content.length>200?"...":"";X.push(j.dim(`${Z} [${Y.id}] ${Y.name}`)),X.push(j.dim(`${Z} ${G}${z}`))}}return X}function uz($,Z){if(!$.surfaces)return[];let X=[];X.push(`${Z}${j.dim("Citations scoped to active surface (compare mode)")}`);for(let Y of $.surfaces){let G=e0(Y),z=o5(G.tone),J=j.dim(`[${Y.active.join(",")}]`),Q=`${z(G.icon)} ${z(t5(G))}`;X.push(`${Z}${J} ${Q}`),X.push(...e5({traps:Y.traps,reason:Y.reason,answerable:Y.answerable,citations:Y.citations},`${Z} `))}return X}function KN($){let Z=0,X=0,Y=0;for(let G of $){if(G.surfaces){for(let z of G.surfaces)Z+=z.traps.fired.length,X+=z.citations.missing.length,Y+=z.citations.unknown.length;continue}if(G.traps)Z+=G.traps.fired.length;if(G.citations)X+=G.citations.missing.length,Y+=G.citations.unknown.length}if(Z>0&&X+Y>0)return"Review fired traps and citation gaps.";if(Z>0)return"Review fired traps before trusting this surface.";if(X+Y>0)return"Review missing and unknown citations.";return"Citations hold. No declared traps fired."}function BN($,Z){let X=$.summary.score,G=`Overall: ${QN(X)(`${X}`)} / 100`;if(Z===void 0||Z<=0)return G;let J=X>=Z?j.green("run passes"):j.red("run fails");return`${G} \xB7 threshold ${Z} \xB7 ${J}`}function mz($,Z={}){let{tool:X,scenarios:Y,summary:G}=$,z=Y,J=[];if(J.push(j.bold("pickled check")),J.push(yz),J.push(`Tool: ${j.cyan(X.name)}`),$.docs.length>0)J.push(`Sources: ${j.dim(GX($.docs.map((Q)=>Q.id)))}`);else J.push(`Sources: ${j.dim("none registered")}`);if(J.push(`Scenarios: ${j.dim(String(G.total))}`),J.push(""),HN(z)){let Q=new Map;for(let W of z){let V=W.scenario.name;if(!Q.has(V))Q.set(V,[]);Q.get(V)?.push(W)}for(let[W,V]of Q){J.push(`Scenario: ${W}`);for(let K of V)if(K.cells)J.push(...hz(K," "));else if(K.surfaces)J.push(...uz(K," "));else J.push(` ${vz(K)}`),J.push(...gz(K," "));J.push("")}}else for(let Q of z){if(J.push(`Scenario: ${Q.scenario.name}`),Q.cells)J.push(...hz(Q," "));else if(Q.surfaces)J.push(...uz(Q," "));else J.push(` ${vz(Q)}`),J.push(...gz(Q," "));J.push("")}return J.push(yz),J.push(BN($,Z.threshold)),J.push(j.dim(KN(Y))),J.join(`
276
+ `)}function $3($,Z={}){console.log(mz($,Z)),console.log()}function zX($,Z={}){if(Z.verbose)return JSON.stringify($,null,2);let X={...$,docs:$.docs.map((Y)=>({...Y,content:""})),scenarios:$.scenarios.map((Y)=>{let{allResponses:G,verifierSamples:z,cells:J,surfaces:Q,...W}=Y;return{...W,verifierSamples:z?.map((V)=>({...V,content:""})),cells:J?.map((V)=>{let{allResponses:K,...H}=V;return H}),surfaces:Q?.map((V)=>{let{allResponses:K,...H}=V;return H})}})};return JSON.stringify(X,null,2)}function qN($){if($.format&&$.format!=="terminal")return $.format;if($.json)return"json";return $.format??"terminal"}async function dz($,Z){let{output:X}=Z,Y=qN(Z),G=UN.resolve($),z;try{z=await i6({targetRepo:G})}catch(H){console.error(j.red(H instanceof Error?H.message:H)),process.exit(1)}let J;if(Y==="json")J=h6(z);else if(Y==="markdown")J=v6(z);else J=u6(z);if(X)await Bun.write(X,J);else await TN(`${J}
277
+ `);let Q=z.findings.filter((H)=>H.severity==="error").length,W=z.findings.filter((H)=>H.severity==="warning").length;if(Y!=="json"&&!X)if(console.log(),Q===0&&W===0)console.log(j.green("Audit clean. No issues found."));else{let H=Q>0?j.red:j.yellow;console.log(H(`Audit found ${Q} error(s), ${W} warning(s).`))}if((Z.failOn??"error")==="warning"?Q+W>0:Q>0)process.exit(1)}function TN($){return new Promise((Z,X)=>{process.stdout.write($,(Y)=>{if(Y)X(Y);else Z()})})}import FN from"path";async function lz($,Z){let{json:X,output:Y,verbose:G}=Z,z=(T)=>!X&&console.log(T),J=FN.resolve($),Q;try{Q=await j1(J)}catch(T){console.error(j.red(T instanceof Error?T.message:T)),console.error(),console.error(j.dim("Run `pickled init` to create a config file")),process.exit(1)}if(Z.target){let T=Q.scenarios.length;try{Q=j9(Q,Z.target)}catch(O){console.error(j.red(O instanceof Error?O.message:String(O))),process.exit(1)}let w=T-Q.scenarios.length;if(w>0&&!X)z(j.dim(`Skipping ${w} scenario(s) with explicit target != "${Z.target}"`))}let W={name:Q.tool.name,description:Q.tool.description,path:J};if(G){z(j.bold("pickled check")),z(""),z(j.dim(` Tool: ${W.name}`)),z(j.dim(` Scenarios: ${Q.scenarios.length}`));for(let T of Q.scenarios)z(j.dim(` - ${T.name}`))}let V;try{V=LN(Z.threshold,Q.threshold)}catch(T){console.error(j.red(T instanceof Error?T.message:T)),process.exit(1)}let K=Z.interface??Z.target,H=K||Z.source||Z.toolset?{interface:K,source:Z.source,toolset:Z.toolset}:void 0,B=Z.scenario?[Z.scenario]:void 0,U=await i5(W,Q,{onProgress:G?(T)=>{if(!X)z(j.dim(` ${T}`))}:void 0,cellFilter:H,scenarioFilter:B}),F=V>0&&U.summary.score<V;if(Y)await Bun.write(Y,zX(U,{verbose:G}));else if(X)await wN(`${zX(U,{verbose:G})}
278
+ `);else $3(U,{threshold:V});if(F){if(X||Y)console.error(j.red(`Overall: ${U.summary.score} / 100 \xB7 threshold ${V} \xB7 run fails`)),console.error(j.dim("Review failed scenarios before trusting this surface."));process.exit(1)}}function LN($,Z){if($===void 0){if(Z===void 0)return 0;return cz(Z,"pickled.yml threshold")}return cz($,"--threshold")}function cz($,Z){if(typeof $==="number"){if(Number.isInteger($)&&$>=0&&$<=100)return $;throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`)}if(typeof $==="string"&&/^\d+$/.test($)){let X=Number($);if(X<=100)return X}if(typeof $==="string")throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`);throw Error(`Invalid ${Z}. Expected an integer from 0 to 100.`)}function wN($){return new Promise((Z,X)=>{process.stdout.write($,(Y)=>{if(Y)X(Y);else Z()})})}import MN from"path";var NN=`# pickled.yml - Agent legibility check for your product
256
279
 
257
280
  tool:
258
281
  name: "your-product"
@@ -274,4 +297,4 @@ scenarios:
274
297
 
275
298
  # Optional: fail CI if score falls below threshold
276
299
  # threshold: 80
277
- `;async function qX($){let X=`${EV.resolve($)}/pickled.yml`;if(await Bun.file(X).exists())console.error(P.red("pickled.yml already exists")),process.exit(1);await Bun.write(X,bV),console.log(P.green("Created pickled.yml")),console.log(),console.log(P.dim("Next steps:")),console.log(P.dim(" 1. Edit pickled.yml: list your sources and scenarios")),console.log(P.dim(" 2. Run: pickled check")),console.log()}X$.name("pickled").description("Test what agents actually understand about your product").version(m5.version);X$.command("init").description("Create a pickled.yml config file").argument("[path]","Path to your project (default: current directory)",".").action(qX);X$.command("audit").description("Static scan of agent-context files (CLAUDE.md, AGENTS.md, llms.txt). No LLM calls.").argument("[path]","Path to your project (default: current directory)",".").addOption(new O4("--format <name>","Output format").choices(["terminal","markdown","json"]).default("terminal")).option("--json","Shorthand for --format json").option("-o, --output <file>","Save report to file").addOption(new O4("--fail-on <level>","Exit non-zero on this severity or higher").choices(["error","warning"]).default("error")).action(ZX);X$.command("check").description("Run agent scenarios against registered sources").argument("[path]","Path to your project (default: current directory)",".").option("--json","Output as JSON").option("-o, --output <file>","Save report to file").option("-v, --verbose","Show detailed progress").option("-t, --threshold <percent>","Minimum score % to pass (overrides config)").option("--target <name>","Restrict to the named target. Overrides matrix.target for non-matrix scenarios; for matrix scenarios, also filters cells by interface unless --interface is explicitly set.").option("--scenario <name>","Run only the named scenario (for CI matrix one-job-per-cell usage)").option("--interface <name>","Matrix cell filter: run only cells with this interface. Takes precedence over --target for matrix cells.").option("--source <name>","Matrix cell filter: run only cells with this source id").option("--toolset <name>","Matrix cell filter: run only cells with this toolset name").action(zX);await X$.parseAsync();
300
+ `;async function pz($){let X=`${MN.resolve($)}/pickled.yml`;if(await Bun.file(X).exists())console.error(j.red("pickled.yml already exists")),process.exit(1);await Bun.write(X,NN),console.log(j.green("Created pickled.yml")),console.log(),console.log(j.dim("Next steps:")),console.log(j.dim(" 1. Edit pickled.yml: list your sources and scenarios")),console.log(j.dim(" 2. Run: pickled check")),console.log()}M1.name("pickled").description("Test what agents actually understand about your product").version(O3.version);M1.command("init").description("Create a pickled.yml config file").argument("[path]","Path to your project (default: current directory)",".").action(pz);M1.command("audit").description("Static scan of agent-context files (CLAUDE.md, AGENTS.md, llms.txt). No LLM calls.").argument("[path]","Path to your project (default: current directory)",".").addOption(new FX("--format <name>","Output format").choices(["terminal","markdown","json"]).default("terminal")).option("--json","Shorthand for --format json").option("-o, --output <file>","Save report to file").addOption(new FX("--fail-on <level>","Exit non-zero on this severity or higher").choices(["error","warning"]).default("error")).action(dz);M1.command("check").description("Run agent scenarios against registered sources").argument("[path]","Path to your project (default: current directory)",".").option("--json","Output as JSON").option("-o, --output <file>","Save report to file").option("-v, --verbose","Show detailed progress").option("-t, --threshold <percent>","Minimum score % to pass (overrides config)").option("--target <name>","Restrict to the named target. Overrides matrix.target for non-matrix scenarios; for matrix scenarios, also filters cells by interface unless --interface is explicitly set.").option("--scenario <name>","Run only the named scenario (for CI matrix one-job-per-cell usage)").option("--interface <name>","Matrix cell filter: run only cells with this interface. Takes precedence over --target for matrix cells.").option("--source <name>","Matrix cell filter: run only cells with this source id").option("--toolset <name>","Matrix cell filter: run only cells with this toolset name").action(lz);await M1.parseAsync();