@s-analytics/cli 0.1.3 → 0.2.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 (2) hide show
  1. package/package.json +1 -1
  2. package/published.js +120 -120
package/published.js CHANGED
@@ -1,171 +1,171 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as my}from"node:module";var na=Object.defineProperty;var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ly=(e)=>e;function uy(e,t){this[e]=ly.bind(null,t)}var py=(e,t)=>{for(var r in t)na(e,r,{get:t[r],enumerable:!0,configurable:!0,set:uy.bind(t,r)})};var dy=(e,t,r)=>{for(var n in t)na(e,n,{get:t[n],set:r[n],enumerable:!0,configurable:!0})},We=my(import.meta.url);var vr=I(function(Yb){class mo extends Error{constructor(e,t,r){super(r);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}class Du extends mo{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}Yb.CommanderError=mo;Yb.InvalidArgumentError=Du});var hn=I(function(rw){var{InvalidArgumentError:ew}=vr();class Pu{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new ew(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,r);return t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function tw(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}rw.Argument=Pu;rw.humanReadableArgName=tw});var fo=I(function(iw){var{humanReadableArgName:ow}=hn();class Iu{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter((n)=>!n._hidden),r=e._getHelpCommand();if(r&&!r._hidden)t.push(r);if(this.sortSubcommands)t.sort((n,s)=>n.name().localeCompare(s.name()));return t}compareOptions(e,t){let r=(n)=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter((n)=>!n.hidden),r=e._getHelpOption();if(r&&!r.hidden){let n=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);if(!n&&!s)t.push(r);else if(r.long&&!s)t.push(e.createOption(r.long,r.description));else if(r.short&&!n)t.push(e.createOption(r.short,r.description))}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let n=r.options.filter((s)=>!s.hidden);t.push(...n)}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleArguments(e){if(e._argsDescription)e.registeredArguments.forEach((t)=>{t.description=t.description||e._argsDescription[t.name()]||""});if(e.registeredArguments.find((t)=>t.description))return e.registeredArguments;return[]}subcommandTerm(e){let t=e.registeredArguments.map((r)=>ow(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;if(e._aliases[0])t=t+"|"+e._aliases[0];let r="";for(let n=e.parent;n;n=n.parent)r=n.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((r)=>JSON.stringify(r)).join(", ")}`);if(e.defaultValue!==void 0){if(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==="boolean")t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional)t.push(`preset: ${JSON.stringify(e.presetArg)}`);if(e.envVar!==void 0)t.push(`env: ${e.envVar}`);if(t.length>0){let r=`(${t.join(", ")})`;if(e.description)return`${e.description} ${r}`;return r}return e.description}argumentDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((r)=>JSON.stringify(r)).join(", ")}`);if(e.defaultValue!==void 0)t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`);if(t.length>0){let r=`(${t.join(", ")})`;if(e.description)return`${e.description} ${r}`;return r}return e.description}formatItemList(e,t,r){if(t.length===0)return[];return[r.styleTitle(e),...t,""]}groupItems(e,t,r){let n=new Map;return e.forEach((s)=>{let o=r(s);if(!n.has(o))n.set(o,[])}),t.forEach((s)=>{let o=r(s);if(!n.has(o))n.set(o,[]);n.get(o).push(s)}),n}formatHelp(e,t){let r=t.padWidth(e,t),n=t.helpWidth??80;function s(p,u){return t.formatItem(p,r,u,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],i=t.commandDescription(e);if(i.length>0)o=o.concat([t.boxWrap(t.styleCommandDescription(i),n),""]);let a=t.visibleArguments(e).map((p)=>s(t.styleArgumentTerm(t.argumentTerm(p)),t.styleArgumentDescription(t.argumentDescription(p))));if(o=o.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),(p)=>p.helpGroupHeading??"Options:").forEach((p,u)=>{let d=p.map((h)=>s(t.styleOptionTerm(t.optionTerm(h)),t.styleOptionDescription(t.optionDescription(h))));o=o.concat(this.formatItemList(u,d,t))}),t.showGlobalOptions){let p=t.visibleGlobalOptions(e).map((u)=>s(t.styleOptionTerm(t.optionTerm(u)),t.styleOptionDescription(t.optionDescription(u))));o=o.concat(this.formatItemList("Global Options:",p,t))}return this.groupItems(e.commands,t.visibleCommands(e),(p)=>p.helpGroup()||"Commands:").forEach((p,u)=>{let d=p.map((h)=>s(t.styleSubcommandTerm(t.subcommandTerm(h)),t.styleSubcommandDescription(t.subcommandDescription(h))));o=o.concat(this.formatItemList(u,d,t))}),o.join(`
3
- `)}displayWidth(e){return Fu(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t==="[command]")return this.styleSubcommandText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleCommandText(t)}).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleSubcommandText(t)}).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,n){let o=" ".repeat(2);if(!r)return o+e;let i=e.padEnd(t+e.length-n.displayWidth(e)),a=2,l=(this.helpWidth??80)-t-a-2,p;if(l<this.minWidthToWrap||n.preformatted(r))p=r;else p=n.boxWrap(r,l).replace(/\n/g,`
4
- `+" ".repeat(t+a));return o+i+" ".repeat(a)+p.replace(/\n/g,`
5
- ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return r.forEach((o)=>{let i=o.match(n);if(i===null){s.push("");return}let a=[i.shift()],c=this.displayWidth(a[0]);i.forEach((l)=>{let p=this.displayWidth(l);if(c+p<=t){a.push(l),c+=p;return}s.push(a.join(""));let u=l.trimStart();a=[u],c=this.displayWidth(u)}),s.push(a.join(""))}),s.join(`
6
- `)}}function Fu(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}iw.Help=Iu;iw.stripColor=Fu});var ho=I(function(pw){var{InvalidArgumentError:lw}=vr();class zu{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=uw(e);if(this.short=r.shortFlag,this.long=r.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;if(typeof e==="string")t={[e]:!0};return this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new lw(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,r);return t},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return Lu(this.name().replace(/^no-/,""));return Lu(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class qu{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((t)=>{if(t.negate)this.negativeOptions.set(t.attributeName(),t);else this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{if(this.positiveOptions.has(r))this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let n=this.negativeOptions.get(r).presetArg,s=n!==void 0?n:!1;return t.negate===(s===e)}}function Lu(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function uw(e){let t,r,n=/^-[^-]$/,s=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");if(n.test(o[0]))t=o.shift();if(s.test(o[0]))r=o.shift();if(!t&&n.test(o[0]))t=o.shift();if(!t&&s.test(o[0]))t=r,r=o.shift();if(o[0].startsWith("-")){let i=o[0],a=`option creation failed due to '${i}' in option flags '${e}'`;if(/^-[^-][^-]/.test(i))throw Error(`${a}
2
+ import{createRequire as vy}from"node:module";var ia=Object.defineProperty;var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var gy=(e)=>e;function yy(e,t){this[e]=gy.bind(null,t)}var by=(e,t)=>{for(var r in t)ia(e,r,{get:t[r],enumerable:!0,configurable:!0,set:yy.bind(t,r)})};var wy=(e,t,r)=>{for(var n in t)ia(e,n,{get:t[n],set:r[n],enumerable:!0,configurable:!0})},We=vy(import.meta.url);var kr=I(function(sw){class fo extends Error{constructor(e,t,r){super(r);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}class Iu extends fo{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}sw.CommanderError=fo;sw.InvalidArgumentError=Iu});var hn=I(function(lw){var{InvalidArgumentError:aw}=kr();class Fu{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new aw(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,r);return t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function cw(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}lw.Argument=Fu;lw.humanReadableArgName=cw});var ho=I(function(mw){var{humanReadableArgName:dw}=hn();class Lu{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter((n)=>!n._hidden),r=e._getHelpCommand();if(r&&!r._hidden)t.push(r);if(this.sortSubcommands)t.sort((n,s)=>n.name().localeCompare(s.name()));return t}compareOptions(e,t){let r=(n)=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter((n)=>!n.hidden),r=e._getHelpOption();if(r&&!r.hidden){let n=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);if(!n&&!s)t.push(r);else if(r.long&&!s)t.push(e.createOption(r.long,r.description));else if(r.short&&!n)t.push(e.createOption(r.short,r.description))}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let n=r.options.filter((s)=>!s.hidden);t.push(...n)}if(this.sortOptions)t.sort(this.compareOptions);return t}visibleArguments(e){if(e._argsDescription)e.registeredArguments.forEach((t)=>{t.description=t.description||e._argsDescription[t.name()]||""});if(e.registeredArguments.find((t)=>t.description))return e.registeredArguments;return[]}subcommandTerm(e){let t=e.registeredArguments.map((r)=>dw(r)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,n)=>Math.max(r,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;if(e._aliases[0])t=t+"|"+e._aliases[0];let r="";for(let n=e.parent;n;n=n.parent)r=n.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((r)=>JSON.stringify(r)).join(", ")}`);if(e.defaultValue!==void 0){if(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==="boolean")t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional)t.push(`preset: ${JSON.stringify(e.presetArg)}`);if(e.envVar!==void 0)t.push(`env: ${e.envVar}`);if(t.length>0){let r=`(${t.join(", ")})`;if(e.description)return`${e.description} ${r}`;return r}return e.description}argumentDescription(e){let t=[];if(e.argChoices)t.push(`choices: ${e.argChoices.map((r)=>JSON.stringify(r)).join(", ")}`);if(e.defaultValue!==void 0)t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`);if(t.length>0){let r=`(${t.join(", ")})`;if(e.description)return`${e.description} ${r}`;return r}return e.description}formatItemList(e,t,r){if(t.length===0)return[];return[r.styleTitle(e),...t,""]}groupItems(e,t,r){let n=new Map;return e.forEach((s)=>{let o=r(s);if(!n.has(o))n.set(o,[])}),t.forEach((s)=>{let o=r(s);if(!n.has(o))n.set(o,[]);n.get(o).push(s)}),n}formatHelp(e,t){let r=t.padWidth(e,t),n=t.helpWidth??80;function s(u,p){return t.formatItem(u,r,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],i=t.commandDescription(e);if(i.length>0)o=o.concat([t.boxWrap(t.styleCommandDescription(i),n),""]);let a=t.visibleArguments(e).map((u)=>s(t.styleArgumentTerm(t.argumentTerm(u)),t.styleArgumentDescription(t.argumentDescription(u))));if(o=o.concat(this.formatItemList("Arguments:",a,t)),this.groupItems(e.options,t.visibleOptions(e),(u)=>u.helpGroupHeading??"Options:").forEach((u,p)=>{let d=u.map((g)=>s(t.styleOptionTerm(t.optionTerm(g)),t.styleOptionDescription(t.optionDescription(g))));o=o.concat(this.formatItemList(p,d,t))}),t.showGlobalOptions){let u=t.visibleGlobalOptions(e).map((p)=>s(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.concat(this.formatItemList("Global Options:",u,t))}return this.groupItems(e.commands,t.visibleCommands(e),(u)=>u.helpGroup()||"Commands:").forEach((u,p)=>{let d=u.map((g)=>s(t.styleSubcommandTerm(t.subcommandTerm(g)),t.styleSubcommandDescription(t.subcommandDescription(g))));o=o.concat(this.formatItemList(p,d,t))}),o.join(`
3
+ `)}displayWidth(e){return zu(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t==="[command]")return this.styleSubcommandText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleCommandText(t)}).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map((t)=>{if(t==="[options]")return this.styleOptionText(t);if(t[0]==="["||t[0]==="<")return this.styleArgumentText(t);return this.styleSubcommandText(t)}).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,r,n){let o=" ".repeat(2);if(!r)return o+e;let i=e.padEnd(t+e.length-n.displayWidth(e)),a=2,l=(this.helpWidth??80)-t-a-2,u;if(l<this.minWidthToWrap||n.preformatted(r))u=r;else u=n.boxWrap(r,l).replace(/\n/g,`
4
+ `+" ".repeat(t+a));return o+i+" ".repeat(a)+u.replace(/\n/g,`
5
+ ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let r=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return r.forEach((o)=>{let i=o.match(n);if(i===null){s.push("");return}let a=[i.shift()],c=this.displayWidth(a[0]);i.forEach((l)=>{let u=this.displayWidth(l);if(c+u<=t){a.push(l),c+=u;return}s.push(a.join(""));let p=l.trimStart();a=[p],c=this.displayWidth(p)}),s.push(a.join(""))}),s.join(`
6
+ `)}}function zu(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}mw.Help=Lu;mw.stripColor=zu});var go=I(function(bw){var{InvalidArgumentError:gw}=kr();class Ku{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let r=yw(e);if(this.short=r.shortFlag,this.long=r.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(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;if(typeof e==="string")t={[e]:!0};return this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){if(t===this.defaultValue||!Array.isArray(t))return[e];return t.push(e),t}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new gw(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(t,r);return t},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return qu(this.name().replace(/^no-/,""));return qu(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class Ru{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((t)=>{if(t.negate)this.negativeOptions.set(t.attributeName(),t);else this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,r)=>{if(this.positiveOptions.has(r))this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let n=this.negativeOptions.get(r).presetArg,s=n!==void 0?n:!1;return t.negate===(s===e)}}function qu(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}function yw(e){let t,r,n=/^-[^-]$/,s=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");if(n.test(o[0]))t=o.shift();if(s.test(o[0]))r=o.shift();if(!t&&n.test(o[0]))t=o.shift();if(!t&&s.test(o[0]))t=r,r=o.shift();if(o[0].startsWith("-")){let i=o[0],a=`option creation failed due to '${i}' in option flags '${e}'`;if(/^-[^-][^-]/.test(i))throw Error(`${a}
7
7
  - a short flag is a single dash and a single character
8
8
  - either use a single dash and a single character (for a short flag)
9
9
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(n.test(i))throw Error(`${a}
10
10
  - too many short flags`);if(s.test(i))throw Error(`${a}
11
11
  - too many long flags`);throw Error(`${a}
12
- - unrecognised flag format`)}if(t===void 0&&r===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}pw.Option=zu;pw.DualOptions=qu});var Ku=I(function(gw){function fw(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let n=0;n<=e.length;n++)r[n]=[n];for(let n=0;n<=t.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let s=1;s<=e.length;s++){let o=1;if(e[s-1]===t[n-1])o=0;else o=1;if(r[s][n]=Math.min(r[s-1][n]+1,r[s][n-1]+1,r[s-1][n-1]+o),s>1&&n>1&&e[s-1]===t[n-2]&&e[s-2]===t[n-1])r[s][n]=Math.min(r[s][n],r[s-2][n-2]+1)}return r[e.length][t.length]}function hw(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");if(r)e=e.slice(2),t=t.map((i)=>i.slice(2));let n=[],s=3,o=0.4;if(t.forEach((i)=>{if(i.length<=1)return;let a=fw(e,i),c=Math.max(e.length,i.length);if((c-a)/c>o){if(a<s)s=a,n=[i];else if(a===s)n.push(i)}}),n.sort((i,a)=>i.localeCompare(a)),r)n=n.map((i)=>`--${i}`);if(n.length>1)return`
12
+ - unrecognised flag format`)}if(t===void 0&&r===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}bw.Option=Ku;bw.DualOptions=Ru});var Uu=I(function(xw){function kw(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let n=0;n<=e.length;n++)r[n]=[n];for(let n=0;n<=t.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let s=1;s<=e.length;s++){let o=1;if(e[s-1]===t[n-1])o=0;else o=1;if(r[s][n]=Math.min(r[s-1][n]+1,r[s][n-1]+1,r[s-1][n-1]+o),s>1&&n>1&&e[s-1]===t[n-2]&&e[s-2]===t[n-1])r[s][n]=Math.min(r[s][n],r[s-2][n-2]+1)}return r[e.length][t.length]}function Sw(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");if(r)e=e.slice(2),t=t.map((i)=>i.slice(2));let n=[],s=3,o=0.4;if(t.forEach((i)=>{if(i.length<=1)return;let a=kw(e,i),c=Math.max(e.length,i.length);if((c-a)/c>o){if(a<s)s=a,n=[i];else if(a===s)n.push(i)}}),n.sort((i,a)=>i.localeCompare(a)),r)n=n.map((i)=>`--${i}`);if(n.length>1)return`
13
13
  (Did you mean one of ${n.join(", ")}?)`;if(n.length===1)return`
14
- (Did you mean ${n[0]}?)`;return""}gw.suggestSimilar=hw});var ju=I(function(Cw){var bw=We("node:events").EventEmitter,Zt=We("node:child_process"),de=We("node:path"),et=We("node:fs"),z=We("node:process"),{Argument:ww,humanReadableArgName:vw}=hn(),{CommanderError:go}=vr(),{Help:kw,stripColor:Sw}=fo(),{Option:Ru,DualOptions:xw}=ho(),{suggestSimilar:Uu}=Ku();class bo extends bw{constructor(e){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=e||"",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:(t)=>z.stdout.write(t),writeErr:(t)=>z.stderr.write(t),outputError:(t,r)=>r(t),getOutHelpWidth:()=>z.stdout.isTTY?z.stdout.columns:void 0,getErrHelpWidth:()=>z.stderr.isTTY?z.stderr.columns:void 0,getOutHasColors:()=>yo()??(z.stdout.isTTY&&z.stdout.hasColors?.()),getErrHasColors:()=>yo()??(z.stderr.isTTY&&z.stderr.hasColors?.()),stripColor:(t)=>Sw(t)},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(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let n=t,s=r;if(typeof n==="object"&&n!==null)s=n,n=null;s=s||{};let[,o,i]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);if(n)a.description(n),a._executableHandler=!0;if(s.isDefault)this._defaultCommandName=a._name;if(a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,i)a.arguments(i);if(this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n)return this;return a}createCommand(e){return new bo(e)}createHelp(){return Object.assign(new kw,this.configureHelp())}configureHelp(e){if(e===void 0)return this._helpConfiguration;return this._helpConfiguration=e,this}configureOutput(e){if(e===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...e},this}showHelpAfterError(e=!0){if(typeof e!=="string")e=!!e;return this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
15
- - specify the name in Command constructor or using .name()`);if(t=t||{},t.isDefault)this._defaultCommandName=e._name;if(t.noHelp||t.hidden)e._hidden=!0;return this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new ww(e,t)}argument(e,t,r,n){let s=this.createArgument(e,t);if(typeof r==="function")s.default(n).argParser(r);else s.default(r);return this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach((t)=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==="boolean"){if(this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let r=e??"help [command]",[,n,s]=r.match(/([^ ]+) *(.*)/),o=t??"display help for command",i=this.createCommand(n);if(i.helpOption(!1),s)i.arguments(s);if(o)i.description(o);if(this._addImplicitHelpCommand=!0,this._helpCommand=i,e||t)this._initCommandGroup(i);return this}addHelpCommand(e,t){if(typeof e!=="object")return this.helpCommand(e,t),this;return this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),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(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
16
- Expecting one of '${r.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycleHooks[e].push(t);else this._lifeCycleHooks[e]=[t];return this}exitOverride(e){if(e)this._exitCallback=e;else this._exitCallback=(t)=>{if(t.code!=="commander.executeSubCommandAsync")throw t};return this}_exit(e,t,r){if(this._exitCallback)this._exitCallback(new go(e,t,r));z.exit(e)}action(e){let t=(r)=>{let n=this.registeredArguments.length,s=r.slice(0,n);if(this._storeOptionsAsProperties)s[n]=this;else s[n]=this.opts();return s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Ru(e,t)}_callParseArg(e,t,r,n){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${n} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
17
- - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=(n)=>[n.name()].concat(n.aliases()),r=t(e).find((n)=>this._findCommand(n));if(r){let n=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");if(!this._findOption(s))this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else if(e.defaultValue!==void 0)this.setOptionValueWithSource(r,e.defaultValue,"default");let n=(s,o,i)=>{if(s==null&&e.presetArg!==void 0)s=e.presetArg;let a=this.getOptionValue(r);if(s!==null&&e.parseArg)s=this._callParseArg(e,s,a,o);else if(s!==null&&e.variadic)s=e._collectValue(s,a);if(s==null)if(e.negate)s=!1;else if(e.isBoolean()||e.optional)s=!0;else s="";this.setOptionValueWithSource(r,s,i)};if(this.on("option:"+t,(s)=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;n(s,o,"cli")}),e.envVar)this.on("optionEnv:"+t,(s)=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;n(s,o,"env")});return this}_optionEx(e,t,r,n,s){if(typeof t==="object"&&t instanceof Ru)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,r);if(o.makeOptionMandatory(!!e.mandatory),typeof n==="function")o.default(s).argParser(n);else if(n instanceof RegExp){let i=n;n=(a,c)=>{let l=i.exec(a);return l?l[0]:c},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,r,n){return this._optionEx({},e,t,r,n)}requiredOption(e,t,r,n){return this._optionEx({mandatory:!0},e,t,r,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){if(this._storeOptionsAsProperties)return this[e];return this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){if(this._storeOptionsAsProperties)this[e]=t;else this._optionValues[e]=t;return this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((r)=>{if(r.getOptionValueSource(e)!==void 0)t=r.getOptionValueSource(e)}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){if(z.versions?.electron)t.from="electron";let n=z.execArgv??[];if(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))t.from="eval"}if(e===void 0)e=z.argv;this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":if(z.defaultApp)this._scriptPath=e[1],r=e.slice(2);else r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),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.
14
+ (Did you mean ${n[0]}?)`;return""}xw.suggestSimilar=Sw});var Vu=I(function(Nw){var _w=We("node:events").EventEmitter,Vt=We("node:child_process"),de=We("node:path"),et=We("node:fs"),z=We("node:process"),{Argument:Aw,humanReadableArgName:Ow}=hn(),{CommanderError:yo}=kr(),{Help:Tw,stripColor:$w}=ho(),{Option:Mu,DualOptions:Ew}=go(),{suggestSimilar:ju}=Uu();class wo extends _w{constructor(e){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=e||"",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:(t)=>z.stdout.write(t),writeErr:(t)=>z.stderr.write(t),outputError:(t,r)=>r(t),getOutHelpWidth:()=>z.stdout.isTTY?z.stdout.columns:void 0,getErrHelpWidth:()=>z.stderr.isTTY?z.stderr.columns:void 0,getOutHasColors:()=>bo()??(z.stdout.isTTY&&z.stdout.hasColors?.()),getErrHasColors:()=>bo()??(z.stderr.isTTY&&z.stderr.hasColors?.()),stripColor:(t)=>$w(t)},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(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let n=t,s=r;if(typeof n==="object"&&n!==null)s=n,n=null;s=s||{};let[,o,i]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);if(n)a.description(n),a._executableHandler=!0;if(s.isDefault)this._defaultCommandName=a._name;if(a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,i)a.arguments(i);if(this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n)return this;return a}createCommand(e){return new wo(e)}createHelp(){return Object.assign(new Tw,this.configureHelp())}configureHelp(e){if(e===void 0)return this._helpConfiguration;return this._helpConfiguration=e,this}configureOutput(e){if(e===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...e},this}showHelpAfterError(e=!0){if(typeof e!=="string")e=!!e;return this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);if(t=t||{},t.isDefault)this._defaultCommandName=e._name;if(t.noHelp||t.hidden)e._hidden=!0;return this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Aw(e,t)}argument(e,t,r,n){let s=this.createArgument(e,t);if(typeof r==="function")s.default(n).argParser(r);else s.default(r);return this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach((t)=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==="boolean"){if(this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let r=e??"help [command]",[,n,s]=r.match(/([^ ]+) *(.*)/),o=t??"display help for command",i=this.createCommand(n);if(i.helpOption(!1),s)i.arguments(s);if(o)i.description(o);if(this._addImplicitHelpCommand=!0,this._helpCommand=i,e||t)this._initCommandGroup(i);return this}addHelpCommand(e,t){if(typeof e!=="object")return this.helpCommand(e,t),this;return this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),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(e,t){let r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
16
+ Expecting one of '${r.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycleHooks[e].push(t);else this._lifeCycleHooks[e]=[t];return this}exitOverride(e){if(e)this._exitCallback=e;else this._exitCallback=(t)=>{if(t.code!=="commander.executeSubCommandAsync")throw t};return this}_exit(e,t,r){if(this._exitCallback)this._exitCallback(new yo(e,t,r));z.exit(e)}action(e){let t=(r)=>{let n=this.registeredArguments.length,s=r.slice(0,n);if(this._storeOptionsAsProperties)s[n]=this;else s[n]=this.opts();return s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Mu(e,t)}_callParseArg(e,t,r,n){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${n} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${r}'
17
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=(n)=>[n.name()].concat(n.aliases()),r=t(e).find((n)=>this._findCommand(n));if(r){let n=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");if(!this._findOption(s))this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else if(e.defaultValue!==void 0)this.setOptionValueWithSource(r,e.defaultValue,"default");let n=(s,o,i)=>{if(s==null&&e.presetArg!==void 0)s=e.presetArg;let a=this.getOptionValue(r);if(s!==null&&e.parseArg)s=this._callParseArg(e,s,a,o);else if(s!==null&&e.variadic)s=e._collectValue(s,a);if(s==null)if(e.negate)s=!1;else if(e.isBoolean()||e.optional)s=!0;else s="";this.setOptionValueWithSource(r,s,i)};if(this.on("option:"+t,(s)=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;n(s,o,"cli")}),e.envVar)this.on("optionEnv:"+t,(s)=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;n(s,o,"env")});return this}_optionEx(e,t,r,n,s){if(typeof t==="object"&&t instanceof Mu)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,r);if(o.makeOptionMandatory(!!e.mandatory),typeof n==="function")o.default(s).argParser(n);else if(n instanceof RegExp){let i=n;n=(a,c)=>{let l=i.exec(a);return l?l[0]:c},o.default(s).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,r,n){return this._optionEx({},e,t,r,n)}requiredOption(e,t,r,n){return this._optionEx({mandatory:!0},e,t,r,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,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(e=!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=!!e,this}getOptionValue(e){if(this._storeOptionsAsProperties)return this[e];return this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){if(this._storeOptionsAsProperties)this[e]=t;else this._optionValues[e]=t;return this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((r)=>{if(r.getOptionValueSource(e)!==void 0)t=r.getOptionValueSource(e)}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){if(z.versions?.electron)t.from="electron";let n=z.execArgv??[];if(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))t.from="eval"}if(e===void 0)e=z.argv;this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":if(z.defaultApp)this._scriptPath=e[1],r=e.slice(2);else r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",r}parse(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){this._prepareForParse();let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),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.
18
18
  - 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(e,t,r){if(et.existsSync(e))return;let n=t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
19
19
  - if '${r}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${n}`;throw Error(s)}_executeSubCommand(e,t){t=t.slice();let r=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(l,p){let u=de.resolve(l,p);if(et.existsSync(u))return u;if(n.includes(de.extname(p)))return;let d=n.find((h)=>et.existsSync(`${u}${h}`));if(d)return`${u}${d}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,i=this._executableDir||"";if(this._scriptPath){let l;try{l=et.realpathSync(this._scriptPath)}catch{l=this._scriptPath}i=de.resolve(de.dirname(l),i)}if(i){let l=s(i,o);if(!l&&!e._executableFile&&this._scriptPath){let p=de.basename(this._scriptPath,de.extname(this._scriptPath));if(p!==this._name)l=s(i,`${p}-${e._name}`)}o=l||o}r=n.includes(de.extname(o));let a;if(z.platform!=="win32")if(r)t.unshift(o),t=Mu(z.execArgv).concat(t),a=Zt.spawn(z.argv[0],t,{stdio:"inherit"});else a=Zt.spawn(o,t,{stdio:"inherit"});else this._checkForMissingExecutable(o,i,e._name),t.unshift(o),t=Mu(z.execArgv).concat(t),a=Zt.spawn(z.execPath,t,{stdio:"inherit"});if(!a.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((p)=>{z.on(p,()=>{if(a.killed===!1&&a.exitCode===null)a.kill(p)})});let c=this._exitCallback;a.on("close",(l)=>{if(l=l??1,!c)z.exit(l);else c(new go(l,"commander.executeSubCommandAsync","(close)"))}),a.on("error",(l)=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,i,e._name);else if(l.code==="EACCES")throw Error(`'${o}' not executable`);if(!c)z.exit(1);else{let p=new go(1,"commander.executeSubCommandAsync","(error)");p.nestedError=l,c(p)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let n=this._findCommand(e);if(!n)this.help({error:!0});n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(r));else return n._parseCommand(t,r)}),s}_dispatchHelpCommand(e){if(!e)this.help();let t=this._findCommand(e);if(t&&!t._executableHandler)t.help();return this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((e,t)=>{if(e.required&&this.args[t]==null)this.missingArgument(e.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 e=(r,n,s)=>{let o=n;if(n!==null&&r.parseArg){let i=`error: command-argument value '${n}' is invalid for argument '${r.name()}'.`;o=this._callParseArg(r,n,s,i)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,n)=>{let s=r.defaultValue;if(r.variadic){if(n<this.args.length){if(s=this.args.slice(n),r.parseArg)s=s.reduce((o,i)=>e(r,i,o),r.defaultValue)}else if(s===void 0)s=[]}else if(n<this.args.length){if(s=this.args[n],r.parseArg)s=e(r,s,r.defaultValue)}t[n]=s}),this.processedArgs=t}_chainOrCall(e,t){if(e?.then&&typeof e.then==="function")return e.then(()=>t());return t()}_chainOrCallHooks(e,t){let r=e,n=[];if(this._getCommandAndAncestors().reverse().filter((s)=>s._lifeCycleHooks[t]!==void 0).forEach((s)=>{s._lifeCycleHooks[t].forEach((o)=>{n.push({hookedCommand:s,callback:o})})}),t==="postAction")n.reverse();return n.forEach((s)=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let n=e;if(this._lifeCycleHooks[r]!==void 0)this._lifeCycleHooks[r].forEach((s)=>{n=this._chainOrCall(n,()=>s(this,t))});return n}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{if(r.unknown.length>0)this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;if(o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent)o=this._chainOrCall(o,()=>{this.parent.emit(s,e,t)});return o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);if(this.listenerCount("command:*"))this.emit("command:*",e,t);else if(this.commands.length)this.unknownCommand();else n(),this._processArguments()}else if(this.commands.length)n(),this.help({error:!0});else n(),this._processArguments()}_findCommand(e){if(!e)return;return this.commands.find((t)=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find((t)=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e)=>{e.options.forEach((t)=>{if(t.mandatory&&e.getOptionValue(t.attributeName())===void 0)e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter((r)=>{let n=r.attributeName();if(this.getOptionValue(n)===void 0)return!1;return this.getOptionValueSource(n)!=="default"});e.filter((r)=>r.conflictsWith.length>0).forEach((r)=>{let n=e.find((s)=>r.conflictsWith.includes(s.attributeName()));if(n)this._conflictingOption(r,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e)=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],n=t;function s(l){return l.length>1&&l[0]==="-"}let o=(l)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l))return!1;return!this._getCommandAndAncestors().some((p)=>p.options.map((u)=>u.short).some((u)=>/^-\d$/.test(u)))},i=null,a=null,c=0;while(c<e.length||a){let l=a??e[c++];if(a=null,l==="--"){if(n===r)n.push(l);n.push(...e.slice(c));break}if(i&&(!s(l)||o(l))){this.emit(`option:${i.name()}`,l);continue}if(i=null,s(l)){let p=this._findOption(l);if(p){if(p.required){let u=e[c++];if(u===void 0)this.optionMissingArgument(p);this.emit(`option:${p.name()}`,u)}else if(p.optional){let u=null;if(c<e.length&&(!s(e[c])||o(e[c])))u=e[c++];this.emit(`option:${p.name()}`,u)}else this.emit(`option:${p.name()}`);i=p.variadic?p:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let p=this._findOption(`-${l[1]}`);if(p){if(p.required||p.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${p.name()}`,l.slice(2));else this.emit(`option:${p.name()}`),a=`-${l.slice(2)}`;continue}}if(/^--[^=]+=/.test(l)){let p=l.indexOf("="),u=this._findOption(l.slice(0,p));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,l.slice(p+1));continue}}if(n===t&&s(l)&&!(this.commands.length===0&&o(l)))n=r;if((this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(l)){t.push(l),r.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){r.push(l,...e.slice(c));break}}if(this._passThroughOptions){n.push(l,...e.slice(c));break}n.push(l)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let n=this.options[r].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){if(this._outputConfiguration.outputError(`${e}
21
+ - ${n}`;throw Error(s)}_executeSubCommand(e,t){t=t.slice();let r=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function s(l,u){let p=de.resolve(l,u);if(et.existsSync(p))return p;if(n.includes(de.extname(u)))return;let d=n.find((g)=>et.existsSync(`${p}${g}`));if(d)return`${p}${d}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,i=this._executableDir||"";if(this._scriptPath){let l;try{l=et.realpathSync(this._scriptPath)}catch{l=this._scriptPath}i=de.resolve(de.dirname(l),i)}if(i){let l=s(i,o);if(!l&&!e._executableFile&&this._scriptPath){let u=de.basename(this._scriptPath,de.extname(this._scriptPath));if(u!==this._name)l=s(i,`${u}-${e._name}`)}o=l||o}r=n.includes(de.extname(o));let a;if(z.platform!=="win32")if(r)t.unshift(o),t=Zu(z.execArgv).concat(t),a=Vt.spawn(z.argv[0],t,{stdio:"inherit"});else a=Vt.spawn(o,t,{stdio:"inherit"});else this._checkForMissingExecutable(o,i,e._name),t.unshift(o),t=Zu(z.execArgv).concat(t),a=Vt.spawn(z.execPath,t,{stdio:"inherit"});if(!a.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((u)=>{z.on(u,()=>{if(a.killed===!1&&a.exitCode===null)a.kill(u)})});let c=this._exitCallback;a.on("close",(l)=>{if(l=l??1,!c)z.exit(l);else c(new yo(l,"commander.executeSubCommandAsync","(close)"))}),a.on("error",(l)=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,i,e._name);else if(l.code==="EACCES")throw Error(`'${o}' not executable`);if(!c)z.exit(1);else{let u=new yo(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,c(u)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let n=this._findCommand(e);if(!n)this.help({error:!0});n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(r));else return n._parseCommand(t,r)}),s}_dispatchHelpCommand(e){if(!e)this.help();let t=this._findCommand(e);if(t&&!t._executableHandler)t.help();return this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((e,t)=>{if(e.required&&this.args[t]==null)this.missingArgument(e.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 e=(r,n,s)=>{let o=n;if(n!==null&&r.parseArg){let i=`error: command-argument value '${n}' is invalid for argument '${r.name()}'.`;o=this._callParseArg(r,n,s,i)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,n)=>{let s=r.defaultValue;if(r.variadic){if(n<this.args.length){if(s=this.args.slice(n),r.parseArg)s=s.reduce((o,i)=>e(r,i,o),r.defaultValue)}else if(s===void 0)s=[]}else if(n<this.args.length){if(s=this.args[n],r.parseArg)s=e(r,s,r.defaultValue)}t[n]=s}),this.processedArgs=t}_chainOrCall(e,t){if(e?.then&&typeof e.then==="function")return e.then(()=>t());return t()}_chainOrCallHooks(e,t){let r=e,n=[];if(this._getCommandAndAncestors().reverse().filter((s)=>s._lifeCycleHooks[t]!==void 0).forEach((s)=>{s._lifeCycleHooks[t].forEach((o)=>{n.push({hookedCommand:s,callback:o})})}),t==="postAction")n.reverse();return n.forEach((s)=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let n=e;if(this._lifeCycleHooks[r]!==void 0)this._lifeCycleHooks[r].forEach((s)=>{n=this._chainOrCall(n,()=>s(this,t))});return n}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{if(r.unknown.length>0)this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;if(o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent)o=this._chainOrCall(o,()=>{this.parent.emit(s,e,t)});return o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);if(this.listenerCount("command:*"))this.emit("command:*",e,t);else if(this.commands.length)this.unknownCommand();else n(),this._processArguments()}else if(this.commands.length)n(),this.help({error:!0});else n(),this._processArguments()}_findCommand(e){if(!e)return;return this.commands.find((t)=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find((t)=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e)=>{e.options.forEach((t)=>{if(t.mandatory&&e.getOptionValue(t.attributeName())===void 0)e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter((r)=>{let n=r.attributeName();if(this.getOptionValue(n)===void 0)return!1;return this.getOptionValueSource(n)!=="default"});e.filter((r)=>r.conflictsWith.length>0).forEach((r)=>{let n=e.find((s)=>r.conflictsWith.includes(s.attributeName()));if(n)this._conflictingOption(r,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e)=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],n=t;function s(l){return l.length>1&&l[0]==="-"}let o=(l)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l))return!1;return!this._getCommandAndAncestors().some((u)=>u.options.map((p)=>p.short).some((p)=>/^-\d$/.test(p)))},i=null,a=null,c=0;while(c<e.length||a){let l=a??e[c++];if(a=null,l==="--"){if(n===r)n.push(l);n.push(...e.slice(c));break}if(i&&(!s(l)||o(l))){this.emit(`option:${i.name()}`,l);continue}if(i=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let p=e[c++];if(p===void 0)this.optionMissingArgument(u);this.emit(`option:${u.name()}`,p)}else if(u.optional){let p=null;if(c<e.length&&(!s(e[c])||o(e[c])))p=e[c++];this.emit(`option:${u.name()}`,p)}else this.emit(`option:${u.name()}`);i=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){if(u.required||u.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${u.name()}`,l.slice(2));else this.emit(`option:${u.name()}`),a=`-${l.slice(2)}`;continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),p=this._findOption(l.slice(0,u));if(p&&(p.required||p.optional)){this.emit(`option:${p.name()}`,l.slice(u+1));continue}}if(n===t&&s(l)&&!(this.commands.length===0&&o(l)))n=r;if((this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(l)){t.push(l),r.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){r.push(l,...e.slice(c));break}}if(this._passThroughOptions){n.push(l,...e.slice(c));break}n.push(l)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let n=this.options[r].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){if(this._outputConfiguration.outputError(`${e}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
24
- `),this.outputHelp({error:!0});let r=t||{},n=r.exitCode||1,s=r.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in z.env){let t=e.attributeName();if(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,z.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new xw(this.options),t=(r)=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter((r)=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach((r)=>{Object.keys(r.implied).filter((n)=>!t(n)).forEach((n)=>{this.setOptionValueWithSource(n,r.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=(o)=>{let i=o.attributeName(),a=this.getOptionValue(i),c=this.options.find((p)=>p.negate&&i===p.attributeName()),l=this.options.find((p)=>!p.negate&&i===p.attributeName());if(c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg))return c;return l||o},n=(o)=>{let i=r(o),a=i.attributeName();if(this.getOptionValueSource(a)==="env")return`environment variable '${i.envVar}'`;return`option '${i.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter((i)=>i.long).map((i)=>i.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=Uu(e,n)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach((s)=>{if(n.push(s.name()),s.alias())n.push(s.alias())}),t=Uu(e,n)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let n=this.createOption(t,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
- `),this._exit(0,"commander.version",e)}),this}description(e,t){if(e===void 0&&t===void 0)return this._description;if(this._description=e,t)this._argsDescription=t;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)t=this.commands[this.commands.length-1];if(e===t._name)throw Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let n=[r.name()].concat(r.aliases()).join("|");throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((t)=>this.alias(t)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map((r)=>vw(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}helpGroup(e){if(e===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=e,this}commandsGroup(e){if(e===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=e,this}optionsGroup(e){if(e===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=e,this}_initOptionGroup(e){if(this._defaultOptionGroup&&!e.helpGroupHeading)e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){if(this._defaultCommandGroup&&!e.helpGroup())e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=de.basename(e,de.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let n=t.formatHelp(this,t);if(r.hasColors)return n;return this._outputConfiguration.stripColor(n)}_getOutputContext(e){e=e||{};let t=!!e.error,r,n,s;if(t)r=(i)=>this._outputConfiguration.writeErr(i),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth();else r=(i)=>this._outputConfiguration.writeOut(i),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth();return{error:t,write:(i)=>{if(!n)i=this._outputConfiguration.stripColor(i);return r(i)},hasColors:n,helpWidth:s}}outputHelp(e){let t;if(typeof e==="function")t=e,e=void 0;let r=this._getOutputContext(e),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach((o)=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:r.error});if(t){if(s=t(s),typeof s!=="string"&&!Buffer.isBuffer(s))throw Error("outputHelp callback must return a string or a Buffer")}if(r.write(s),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",n),this._getCommandAndAncestors().forEach((o)=>o.emit("afterAllHelp",n))}helpOption(e,t){if(typeof e==="boolean"){if(e){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(e??"-h, --help",t??"display help for command"),e||t)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(z.exitCode??0);if(t===0&&e&&typeof e!=="function"&&e.error)t=1;this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw Error(`Unexpected value for position to addHelpText.
24
+ `),this.outputHelp({error:!0});let r=t||{},n=r.exitCode||1,s=r.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in z.env){let t=e.attributeName();if(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,z.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new Ew(this.options),t=(r)=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter((r)=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach((r)=>{Object.keys(r.implied).filter((n)=>!t(n)).forEach((n)=>{this.setOptionValueWithSource(n,r.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let r=(o)=>{let i=o.attributeName(),a=this.getOptionValue(i),c=this.options.find((u)=>u.negate&&i===u.attributeName()),l=this.options.find((u)=>!u.negate&&i===u.attributeName());if(c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg))return c;return l||o},n=(o)=>{let i=r(o),a=i.attributeName();if(this.getOptionValueSource(a)==="env")return`environment variable '${i.envVar}'`;return`option '${i.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter((i)=>i.long).map((i)=>i.long);n=n.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=ju(e,n)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach((s)=>{if(n.push(s.name()),s.alias())n.push(s.alias())}),t=ju(e,n)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let n=this.createOption(t,r);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
25
+ `),this._exit(0,"commander.version",e)}),this}description(e,t){if(e===void 0&&t===void 0)return this._description;if(this._description=e,t)this._argsDescription=t;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)t=this.commands[this.commands.length-1];if(e===t._name)throw Error("Command alias can't be the same as its name");let r=this.parent?._findCommand(e);if(r){let n=[r.name()].concat(r.aliases()).join("|");throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((t)=>this.alias(t)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map((r)=>Ow(r));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}helpGroup(e){if(e===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=e,this}commandsGroup(e){if(e===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=e,this}optionsGroup(e){if(e===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=e,this}_initOptionGroup(e){if(this._defaultOptionGroup&&!e.helpGroupHeading)e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){if(this._defaultCommandGroup&&!e.helpGroup())e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=de.basename(e,de.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let t=this.createHelp(),r=this._getOutputContext(e);t.prepareContext({error:r.error,helpWidth:r.helpWidth,outputHasColors:r.hasColors});let n=t.formatHelp(this,t);if(r.hasColors)return n;return this._outputConfiguration.stripColor(n)}_getOutputContext(e){e=e||{};let t=!!e.error,r,n,s;if(t)r=(i)=>this._outputConfiguration.writeErr(i),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth();else r=(i)=>this._outputConfiguration.writeOut(i),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth();return{error:t,write:(i)=>{if(!n)i=this._outputConfiguration.stripColor(i);return r(i)},hasColors:n,helpWidth:s}}outputHelp(e){let t;if(typeof e==="function")t=e,e=void 0;let r=this._getOutputContext(e),n={error:r.error,write:r.write,command:this};this._getCommandAndAncestors().reverse().forEach((o)=>o.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:r.error});if(t){if(s=t(s),typeof s!=="string"&&!Buffer.isBuffer(s))throw Error("outputHelp callback must return a string or a Buffer")}if(r.write(s),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",n),this._getCommandAndAncestors().forEach((o)=>o.emit("afterAllHelp",n))}helpOption(e,t){if(typeof e==="boolean"){if(e){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(e??"-h, --help",t??"display help for command"),e||t)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(z.exitCode??0);if(t===0&&e&&typeof e!=="function"&&e.error)t=1;this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${r.join("', '")}'`);let n=`${e}Help`;return this.on(n,(s)=>{let o;if(typeof t==="function")o=t({error:s.error,command:s.command});else o=t;if(o)s.write(`${o}
27
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();if(t&&e.find((n)=>t.is(n)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Mu(e){return e.map((t)=>{if(!t.startsWith("--inspect"))return t;let r,n="127.0.0.1",s="9229",o;if((o=t.match(/^(--inspect(-brk)?)$/))!==null)r=o[1];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(r=o[1],/^\d+$/.test(o[3]))s=o[3];else n=o[3];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)r=o[1],n=o[3],s=o[4];if(r&&s!=="0")return`${r}=${n}:${parseInt(s)+1}`;return t})}function yo(){if(z.env.NO_COLOR||z.env.FORCE_COLOR==="0"||z.env.FORCE_COLOR==="false")return!1;if(z.env.FORCE_COLOR||z.env.CLICOLOR_FORCE!==void 0)return!0;return}Cw.Command=bo;Cw.useColor=yo});var J=I(function(Yw){var Oo=Symbol.for("yaml.alias"),Pp=Symbol.for("yaml.document"),vn=Symbol.for("yaml.map"),Ip=Symbol.for("yaml.pair"),To=Symbol.for("yaml.scalar"),kn=Symbol.for("yaml.seq"),Be=Symbol.for("yaml.node.type"),Zw=(e)=>!!e&&typeof e==="object"&&e[Be]===Oo,Vw=(e)=>!!e&&typeof e==="object"&&e[Be]===Pp,Ww=(e)=>!!e&&typeof e==="object"&&e[Be]===vn,Gw=(e)=>!!e&&typeof e==="object"&&e[Be]===Ip,Fp=(e)=>!!e&&typeof e==="object"&&e[Be]===To,Jw=(e)=>!!e&&typeof e==="object"&&e[Be]===kn;function Lp(e){if(e&&typeof e==="object")switch(e[Be]){case vn:case kn:return!0}return!1}function Bw(e){if(e&&typeof e==="object")switch(e[Be]){case Oo:case vn:case To:case kn:return!0}return!1}var Hw=(e)=>(Fp(e)||Lp(e))&&!!e.anchor;Yw.ALIAS=Oo;Yw.DOC=Pp;Yw.MAP=vn;Yw.NODE_TYPE=Be;Yw.PAIR=Ip;Yw.SCALAR=To;Yw.SEQ=kn;Yw.hasAnchor=Hw;Yw.isAlias=Zw;Yw.isCollection=Lp;Yw.isDocument=Vw;Yw.isMap=Ww;Yw.isNode=Bw;Yw.isPair=Gw;Yw.isScalar=Fp;Yw.isSeq=Jw});var Cr=I(function(fv){var pe=J(),we=Symbol("break visit"),zp=Symbol("skip children"),Ke=Symbol("remove node");function Sn(e,t){let r=qp(t);if(pe.isDocument(e)){if(Vt(null,e.contents,r,Object.freeze([e]))===Ke)e.contents=null}else Vt(null,e,r,Object.freeze([]))}Sn.BREAK=we;Sn.SKIP=zp;Sn.REMOVE=Ke;function Vt(e,t,r,n){let s=Kp(e,t,r,n);if(pe.isNode(s)||pe.isPair(s))return Rp(e,n,s),Vt(e,s,r,n);if(typeof s!=="symbol"){if(pe.isCollection(t)){n=Object.freeze(n.concat(t));for(let o=0;o<t.items.length;++o){let i=Vt(o,t.items[o],r,n);if(typeof i==="number")o=i-1;else if(i===we)return we;else if(i===Ke)t.items.splice(o,1),o-=1}}else if(pe.isPair(t)){n=Object.freeze(n.concat(t));let o=Vt("key",t.key,r,n);if(o===we)return we;else if(o===Ke)t.key=null;let i=Vt("value",t.value,r,n);if(i===we)return we;else if(i===Ke)t.value=null}}return s}async function xn(e,t){let r=qp(t);if(pe.isDocument(e)){if(await Wt(null,e.contents,r,Object.freeze([e]))===Ke)e.contents=null}else await Wt(null,e,r,Object.freeze([]))}xn.BREAK=we;xn.SKIP=zp;xn.REMOVE=Ke;async function Wt(e,t,r,n){let s=await Kp(e,t,r,n);if(pe.isNode(s)||pe.isPair(s))return Rp(e,n,s),Wt(e,s,r,n);if(typeof s!=="symbol"){if(pe.isCollection(t)){n=Object.freeze(n.concat(t));for(let o=0;o<t.items.length;++o){let i=await Wt(o,t.items[o],r,n);if(typeof i==="number")o=i-1;else if(i===we)return we;else if(i===Ke)t.items.splice(o,1),o-=1}}else if(pe.isPair(t)){n=Object.freeze(n.concat(t));let o=await Wt("key",t.key,r,n);if(o===we)return we;else if(o===Ke)t.key=null;let i=await Wt("value",t.value,r,n);if(i===we)return we;else if(i===Ke)t.value=null}}return s}function qp(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Kp(e,t,r,n){if(typeof r==="function")return r(e,t,n);if(pe.isMap(t))return r.Map?.(e,t,n);if(pe.isSeq(t))return r.Seq?.(e,t,n);if(pe.isPair(t))return r.Pair?.(e,t,n);if(pe.isScalar(t))return r.Scalar?.(e,t,n);if(pe.isAlias(t))return r.Alias?.(e,t,n);return}function Rp(e,t,r){let n=t[t.length-1];if(pe.isCollection(n))n.items[e]=r;else if(pe.isPair(n))if(e==="key")n.key=r;else n.value=r;else if(pe.isDocument(n))n.contents=r;else{let s=pe.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${s} parent`)}}fv.visit=Sn;fv.visitAsync=xn});var $o=I(function(vv){var Up=J(),yv=Cr(),bv={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},wv=(e)=>e.replace(/[!,[\]{}]/g,(t)=>bv[t]);class $e{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},$e.defaultYaml,e),this.tags=Object.assign({},$e.defaultTags,t)}clone(){let e=new $e(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new $e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:$e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},$e.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:$e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},$e.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[s,o]=r;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;else{let o=/^\d+\.\d+$/.test(s);return t(6,`Unsupported YAML version ${s}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);if(o==="!"||o==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return o}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(n)}catch(o){return t(String(o)),null}if(r==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+wv(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&Up.isNode(e.contents)){let s={};yv.visit(e.contents,(o,i)=>{if(Up.isNode(i)&&i.tag)s[i.tag]=!0}),n=Object.keys(s)}else n=[];for(let[s,o]of r){if(s==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||n.some((i)=>i.startsWith(o)))t.push(`%TAG ${s} ${o}`)}return t.join(`
28
- `)}}$e.defaultYaml={explicit:!1,version:"1.2"};$e.defaultTags={"!!":"tag:yaml.org,2002:"};vv.Directives=$e});var Cn=I(function(_v){var Mp=J(),Sv=Cr();function xv(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(r)}return!0}function jp(e){let t=new Set;return Sv.visit(e,{Value(r,n){if(n.anchor)t.add(n.anchor)}}),t}function Zp(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function Cv(e,t){let r=[],n=new Map,s=null;return{onAnchor:(o)=>{r.push(o),s??(s=jp(e));let i=Zp(t,s);return s.add(i),i},setAnchors:()=>{for(let o of r){let i=n.get(o);if(typeof i==="object"&&i.anchor&&(Mp.isScalar(i.node)||Mp.isCollection(i.node)))i.node.anchor=i.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}_v.anchorIsValid=xv;_v.anchorNames=jp;_v.createNodeAnchors=Cv;_v.findNewAnchor=Zp});var Eo=I(function(Ev){function _r(e,t,r,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let s=0,o=n.length;s<o;++s){let i=n[s],a=_r(e,n,String(s),i);if(a===void 0)delete n[s];else if(a!==i)n[s]=a}else if(n instanceof Map)for(let s of Array.from(n.keys())){let o=n.get(s),i=_r(e,n,s,o);if(i===void 0)n.delete(s);else if(i!==o)n.set(s,i)}else if(n instanceof Set)for(let s of Array.from(n)){let o=_r(e,n,s,s);if(o===void 0)n.delete(s);else if(o!==s)n.delete(s),n.add(o)}else for(let[s,o]of Object.entries(n)){let i=_r(e,n,s,o);if(i===void 0)delete n[s];else if(i!==o)n[s]=i}return e.call(t,r,n)}Ev.applyReviver=_r});var rt=I(function(Pv){var Dv=J();function Vp(e,t,r){if(Array.isArray(e))return e.map((n,s)=>Vp(n,String(s),r));if(e&&typeof e.toJSON==="function"){if(!r||!Dv.hasAnchor(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=(o)=>{n.res=o,delete r.onCreate};let s=e.toJSON(t,r);if(r.onCreate)r.onCreate(s);return s}if(typeof e==="bigint"&&!r?.keep)return Number(e);return e}Pv.toJS=Vp});var _n=I(function(zv){var Fv=Eo(),Wp=J(),Lv=rt();class Gp{constructor(e){Object.defineProperty(this,Wp.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:n,reviver:s}={}){if(!Wp.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},i=Lv.toJS(this,"",o);if(typeof n==="function")for(let{count:a,res:c}of o.anchors.values())n(c,a);return typeof s==="function"?Fv.applyReviver(s,{"":i},"",i):i}}zv.NodeBase=Gp});var Ar=I(function(jv){var Kv=Cn(),Rv=Cr(),Gt=J(),Uv=_n(),Mv=rt();class Jp extends Uv.NodeBase{constructor(e){super(Gt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let r;if(t?.aliasResolveCache)r=t.aliasResolveCache;else if(r=[],Rv.visit(e,{Node:(s,o)=>{if(Gt.isAlias(o)||Gt.hasAnchor(o))r.push(o)}}),t)t.aliasResolveCache=r;let n=void 0;for(let s of r){if(s===this)break;if(s.anchor===this.source)n=s}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:s}=t,o=this.resolve(n,t);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let i=r.get(o);if(!i)Mv.toJS(o,null,t),i=r.get(o);if(i?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(s>=0){if(i.count+=1,i.aliasCount===0)i.aliasCount=An(n,o,r);if(i.count*i.aliasCount>s)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return i.res}toString(e,t,r){let n=`*${this.source}`;if(e){if(Kv.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(s)}if(e.implicitKey)return`${n} `}return n}}function An(e,t,r){if(Gt.isAlias(t)){let n=t.resolve(e),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(Gt.isCollection(t)){let n=0;for(let s of t.items){let o=An(e,s,r);if(o>n)n=o}return n}else if(Gt.isPair(t)){let n=An(e,t.key,r),s=An(e,t.value,r);return Math.max(n,s)}return 1}jv.Alias=Jp});var ae=I(function(Bv){var Vv=J(),Wv=_n(),Gv=rt(),Jv=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class At extends Wv.NodeBase{constructor(e){super(Vv.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Gv.toJS(this.value,e,t)}toString(){return String(this.value)}}At.BLOCK_FOLDED="BLOCK_FOLDED";At.BLOCK_LITERAL="BLOCK_LITERAL";At.PLAIN="PLAIN";At.QUOTE_DOUBLE="QUOTE_DOUBLE";At.QUOTE_SINGLE="QUOTE_SINGLE";Bv.Scalar=At;Bv.isScalarValue=Jv});var Or=I(function(rk){var Qv=Ar(),Ot=J(),Bp=ae(),Xv="tag:yaml.org,2002:";function ek(e,t,r){if(t){let n=r.filter((o)=>o.tag===t),s=n.find((o)=>!o.format)??n[0];if(!s)throw Error(`Tag ${t} not found`);return s}return r.find((n)=>n.identify?.(e)&&!n.format)}function tk(e,t,r){if(Ot.isDocument(e))e=e.contents;if(Ot.isNode(e))return e;if(Ot.isPair(e)){let u=r.schema[Ot.MAP].createNode?.(r.schema,null,r);return u.items.push(e),u}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:o,schema:i,sourceObjects:a}=r,c=void 0;if(n&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=s(e)),new Qv.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=Xv+t.slice(2);let l=ek(e,t,i.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new Bp.Scalar(e);if(c)c.node=u;return u}l=e instanceof Map?i[Ot.MAP]:(Symbol.iterator in Object(e))?i[Ot.SEQ]:i[Ot.MAP]}if(o)o(l),delete r.onTagObj;let p=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(r.schema,e,r):new Bp.Scalar(e);if(t)p.tag=t;else if(!l.default)p.tag=l.tag;if(c)c.node=p;return p}rk.createNode=tk});var On=I(function(ik){var sk=Or(),Re=J(),ok=_n();function No(e,t,r){let n=r;for(let s=t.length-1;s>=0;--s){let o=t[s];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=n,n=i}else n=new Map([[o,n]])}return sk.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Hp=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Yp extends ok.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((r)=>Re.isNode(r)||Re.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(Hp(e))this.add(t);else{let[r,...n]=e,s=this.get(r,!0);if(Re.isCollection(s))s.addIn(n,t);else if(s===void 0&&this.schema)this.set(r,No(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let n=this.get(t,!0);if(Re.isCollection(n))return n.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...n]=e,s=this.get(r,!0);if(n.length===0)return!t&&Re.isScalar(s)?s.value:s;else return Re.isCollection(s)?s.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Re.isPair(t))return!1;let r=t.value;return r==null||e&&Re.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let n=this.get(t,!0);return Re.isCollection(n)?n.hasIn(r):!1}setIn(e,t){let[r,...n]=e;if(n.length===0)this.set(r,t);else{let s=this.get(r,!0);if(Re.isCollection(s))s.setIn(n,t);else if(s===void 0&&this.schema)this.set(r,No(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}ik.Collection=Yp;ik.collectionFromPath=No;ik.isEmptyPath=Hp});var Tr=I(function(dk){var uk=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Do(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var pk=(e,t,r)=>e.endsWith(`
29
- `)?Do(r,t):r.includes(`
27
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();if(t&&e.find((n)=>t.is(n)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function Zu(e){return e.map((t)=>{if(!t.startsWith("--inspect"))return t;let r,n="127.0.0.1",s="9229",o;if((o=t.match(/^(--inspect(-brk)?)$/))!==null)r=o[1];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(r=o[1],/^\d+$/.test(o[3]))s=o[3];else n=o[3];else if((o=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)r=o[1],n=o[3],s=o[4];if(r&&s!=="0")return`${r}=${n}:${parseInt(s)+1}`;return t})}function bo(){if(z.env.NO_COLOR||z.env.FORCE_COLOR==="0"||z.env.FORCE_COLOR==="false")return!1;if(z.env.FORCE_COLOR||z.env.CLICOLOR_FORCE!==void 0)return!0;return}Nw.Command=wo;Nw.useColor=bo});var J=I(function(sv){var To=Symbol.for("yaml.alias"),Lp=Symbol.for("yaml.document"),vn=Symbol.for("yaml.map"),zp=Symbol.for("yaml.pair"),$o=Symbol.for("yaml.scalar"),kn=Symbol.for("yaml.seq"),Be=Symbol.for("yaml.node.type"),Yw=(e)=>!!e&&typeof e==="object"&&e[Be]===To,Qw=(e)=>!!e&&typeof e==="object"&&e[Be]===Lp,Xw=(e)=>!!e&&typeof e==="object"&&e[Be]===vn,ev=(e)=>!!e&&typeof e==="object"&&e[Be]===zp,qp=(e)=>!!e&&typeof e==="object"&&e[Be]===$o,tv=(e)=>!!e&&typeof e==="object"&&e[Be]===kn;function Kp(e){if(e&&typeof e==="object")switch(e[Be]){case vn:case kn:return!0}return!1}function rv(e){if(e&&typeof e==="object")switch(e[Be]){case To:case vn:case $o:case kn:return!0}return!1}var nv=(e)=>(qp(e)||Kp(e))&&!!e.anchor;sv.ALIAS=To;sv.DOC=Lp;sv.MAP=vn;sv.NODE_TYPE=Be;sv.PAIR=zp;sv.SCALAR=$o;sv.SEQ=kn;sv.hasAnchor=nv;sv.isAlias=Yw;sv.isCollection=Kp;sv.isDocument=Qw;sv.isMap=Xw;sv.isNode=rv;sv.isPair=ev;sv.isScalar=qp;sv.isSeq=tv});var Cr=I(function(kv){var pe=J(),we=Symbol("break visit"),Rp=Symbol("skip children"),Ke=Symbol("remove node");function Sn(e,t){let r=Up(t);if(pe.isDocument(e)){if(Gt(null,e.contents,r,Object.freeze([e]))===Ke)e.contents=null}else Gt(null,e,r,Object.freeze([]))}Sn.BREAK=we;Sn.SKIP=Rp;Sn.REMOVE=Ke;function Gt(e,t,r,n){let s=Mp(e,t,r,n);if(pe.isNode(s)||pe.isPair(s))return jp(e,n,s),Gt(e,s,r,n);if(typeof s!=="symbol"){if(pe.isCollection(t)){n=Object.freeze(n.concat(t));for(let o=0;o<t.items.length;++o){let i=Gt(o,t.items[o],r,n);if(typeof i==="number")o=i-1;else if(i===we)return we;else if(i===Ke)t.items.splice(o,1),o-=1}}else if(pe.isPair(t)){n=Object.freeze(n.concat(t));let o=Gt("key",t.key,r,n);if(o===we)return we;else if(o===Ke)t.key=null;let i=Gt("value",t.value,r,n);if(i===we)return we;else if(i===Ke)t.value=null}}return s}async function xn(e,t){let r=Up(t);if(pe.isDocument(e)){if(await Jt(null,e.contents,r,Object.freeze([e]))===Ke)e.contents=null}else await Jt(null,e,r,Object.freeze([]))}xn.BREAK=we;xn.SKIP=Rp;xn.REMOVE=Ke;async function Jt(e,t,r,n){let s=await Mp(e,t,r,n);if(pe.isNode(s)||pe.isPair(s))return jp(e,n,s),Jt(e,s,r,n);if(typeof s!=="symbol"){if(pe.isCollection(t)){n=Object.freeze(n.concat(t));for(let o=0;o<t.items.length;++o){let i=await Jt(o,t.items[o],r,n);if(typeof i==="number")o=i-1;else if(i===we)return we;else if(i===Ke)t.items.splice(o,1),o-=1}}else if(pe.isPair(t)){n=Object.freeze(n.concat(t));let o=await Jt("key",t.key,r,n);if(o===we)return we;else if(o===Ke)t.key=null;let i=await Jt("value",t.value,r,n);if(i===we)return we;else if(i===Ke)t.value=null}}return s}function Up(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Mp(e,t,r,n){if(typeof r==="function")return r(e,t,n);if(pe.isMap(t))return r.Map?.(e,t,n);if(pe.isSeq(t))return r.Seq?.(e,t,n);if(pe.isPair(t))return r.Pair?.(e,t,n);if(pe.isScalar(t))return r.Scalar?.(e,t,n);if(pe.isAlias(t))return r.Alias?.(e,t,n);return}function jp(e,t,r){let n=t[t.length-1];if(pe.isCollection(n))n.items[e]=r;else if(pe.isPair(n))if(e==="key")n.key=r;else n.value=r;else if(pe.isDocument(n))n.contents=r;else{let s=pe.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${s} parent`)}}kv.visit=Sn;kv.visitAsync=xn});var Eo=I(function(Ov){var Zp=J(),Cv=Cr(),_v={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Av=(e)=>e.replace(/[!,[\]{}]/g,(t)=>_v[t]);class $e{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},$e.defaultYaml,e),this.tags=Object.assign({},$e.defaultTags,t)}clone(){let e=new $e(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new $e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:$e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},$e.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:$e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},$e.defaultTags),this.atNextDocument=!1;let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),r.length<2)return!1}let[s,o]=r;return this.tags[s]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;else{let o=/^\d+\.\d+$/.test(s);return t(6,`Unsupported YAML version ${s}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);if(o==="!"||o==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return o}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(n)}catch(o){return t(String(o)),null}if(r==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+Av(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(e&&r.length>0&&Zp.isNode(e.contents)){let s={};Cv.visit(e.contents,(o,i)=>{if(Zp.isNode(i)&&i.tag)s[i.tag]=!0}),n=Object.keys(s)}else n=[];for(let[s,o]of r){if(s==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||n.some((i)=>i.startsWith(o)))t.push(`%TAG ${s} ${o}`)}return t.join(`
28
+ `)}}$e.defaultYaml={explicit:!1,version:"1.2"};$e.defaultTags={"!!":"tag:yaml.org,2002:"};Ov.Directives=$e});var Cn=I(function(Dv){var Vp=J(),$v=Cr();function Ev(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(r)}return!0}function Wp(e){let t=new Set;return $v.visit(e,{Value(r,n){if(n.anchor)t.add(n.anchor)}}),t}function Gp(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}function Nv(e,t){let r=[],n=new Map,s=null;return{onAnchor:(o)=>{r.push(o),s??(s=Wp(e));let i=Gp(t,s);return s.add(i),i},setAnchors:()=>{for(let o of r){let i=n.get(o);if(typeof i==="object"&&i.anchor&&(Vp.isScalar(i.node)||Vp.isCollection(i.node)))i.node.anchor=i.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}Dv.anchorIsValid=Ev;Dv.anchorNames=Wp;Dv.createNodeAnchors=Nv;Dv.findNewAnchor=Gp});var No=I(function(zv){function _r(e,t,r,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let s=0,o=n.length;s<o;++s){let i=n[s],a=_r(e,n,String(s),i);if(a===void 0)delete n[s];else if(a!==i)n[s]=a}else if(n instanceof Map)for(let s of Array.from(n.keys())){let o=n.get(s),i=_r(e,n,s,o);if(i===void 0)n.delete(s);else if(i!==o)n.set(s,i)}else if(n instanceof Set)for(let s of Array.from(n)){let o=_r(e,n,s,s);if(o===void 0)n.delete(s);else if(o!==s)n.delete(s),n.add(o)}else for(let[s,o]of Object.entries(n)){let i=_r(e,n,s,o);if(i===void 0)delete n[s];else if(i!==o)n[s]=i}return e.call(t,r,n)}zv.applyReviver=_r});var rt=I(function(Rv){var Kv=J();function Jp(e,t,r){if(Array.isArray(e))return e.map((n,s)=>Jp(n,String(s),r));if(e&&typeof e.toJSON==="function"){if(!r||!Kv.hasAnchor(e))return e.toJSON(t,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(e,n),r.onCreate=(o)=>{n.res=o,delete r.onCreate};let s=e.toJSON(t,r);if(r.onCreate)r.onCreate(s);return s}if(typeof e==="bigint"&&!r?.keep)return Number(e);return e}Rv.toJS=Jp});var _n=I(function(Zv){var Mv=No(),Bp=J(),jv=rt();class Hp{constructor(e){Object.defineProperty(this,Bp.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:n,reviver:s}={}){if(!Bp.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},i=jv.toJS(this,"",o);if(typeof n==="function")for(let{count:a,res:c}of o.anchors.values())n(c,a);return typeof s==="function"?Mv.applyReviver(s,{"":i},"",i):i}}Zv.NodeBase=Hp});var Ar=I(function(Hv){var Wv=Cn(),Gv=Cr(),Bt=J(),Jv=_n(),Bv=rt();class Yp extends Jv.NodeBase{constructor(e){super(Bt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let r;if(t?.aliasResolveCache)r=t.aliasResolveCache;else if(r=[],Gv.visit(e,{Node:(s,o)=>{if(Bt.isAlias(o)||Bt.hasAnchor(o))r.push(o)}}),t)t.aliasResolveCache=r;let n=void 0;for(let s of r){if(s===this)break;if(s.anchor===this.source)n=s}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:s}=t,o=this.resolve(n,t);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let i=r.get(o);if(!i)Bv.toJS(o,null,t),i=r.get(o);if(i?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(s>=0){if(i.count+=1,i.aliasCount===0)i.aliasCount=An(n,o,r);if(i.count*i.aliasCount>s)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return i.res}toString(e,t,r){let n=`*${this.source}`;if(e){if(Wv.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(s)}if(e.implicitKey)return`${n} `}return n}}function An(e,t,r){if(Bt.isAlias(t)){let n=t.resolve(e),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(Bt.isCollection(t)){let n=0;for(let s of t.items){let o=An(e,s,r);if(o>n)n=o}return n}else if(Bt.isPair(t)){let n=An(e,t.key,r),s=An(e,t.value,r);return Math.max(n,s)}return 1}Hv.Alias=Yp});var ae=I(function(rk){var Qv=J(),Xv=_n(),ek=rt(),tk=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class At extends Xv.NodeBase{constructor(e){super(Qv.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:ek.toJS(this.value,e,t)}toString(){return String(this.value)}}At.BLOCK_FOLDED="BLOCK_FOLDED";At.BLOCK_LITERAL="BLOCK_LITERAL";At.PLAIN="PLAIN";At.QUOTE_DOUBLE="QUOTE_DOUBLE";At.QUOTE_SINGLE="QUOTE_SINGLE";rk.Scalar=At;rk.isScalarValue=tk});var Or=I(function(lk){var ok=Ar(),Ot=J(),Qp=ae(),ik="tag:yaml.org,2002:";function ak(e,t,r){if(t){let n=r.filter((o)=>o.tag===t),s=n.find((o)=>!o.format)??n[0];if(!s)throw Error(`Tag ${t} not found`);return s}return r.find((n)=>n.identify?.(e)&&!n.format)}function ck(e,t,r){if(Ot.isDocument(e))e=e.contents;if(Ot.isNode(e))return e;if(Ot.isPair(e)){let p=r.schema[Ot.MAP].createNode?.(r.schema,null,r);return p.items.push(e),p}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:o,schema:i,sourceObjects:a}=r,c=void 0;if(n&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=s(e)),new ok.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=ik+t.slice(2);let l=ak(e,t,i.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new Qp.Scalar(e);if(c)c.node=p;return p}l=e instanceof Map?i[Ot.MAP]:(Symbol.iterator in Object(e))?i[Ot.SEQ]:i[Ot.MAP]}if(o)o(l),delete r.onTagObj;let u=l?.createNode?l.createNode(r.schema,e,r):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(r.schema,e,r):new Qp.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}lk.createNode=ck});var On=I(function(mk){var pk=Or(),Re=J(),dk=_n();function Do(e,t,r){let n=r;for(let s=t.length-1;s>=0;--s){let o=t[s];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=n,n=i}else n=new Map([[o,n]])}return pk.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Xp=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class ed extends dk.NodeBase{constructor(e,t){super(e);Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(e)t.schema=e;if(t.items=t.items.map((r)=>Re.isNode(r)||Re.isPair(r)?r.clone(e):r),this.range)t.range=this.range.slice();return t}addIn(e,t){if(Xp(e))this.add(t);else{let[r,...n]=e,s=this.get(r,!0);if(Re.isCollection(s))s.addIn(n,t);else if(s===void 0&&this.schema)this.set(r,Do(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let n=this.get(t,!0);if(Re.isCollection(n))return n.deleteIn(r);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...n]=e,s=this.get(r,!0);if(n.length===0)return!t&&Re.isScalar(s)?s.value:s;else return Re.isCollection(s)?s.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Re.isPair(t))return!1;let r=t.value;return r==null||e&&Re.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let n=this.get(t,!0);return Re.isCollection(n)?n.hasIn(r):!1}setIn(e,t){let[r,...n]=e;if(n.length===0)this.set(r,t);else{let s=this.get(r,!0);if(Re.isCollection(s))s.setIn(n,t);else if(s===void 0&&this.schema)this.set(r,Do(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}mk.Collection=ed;mk.collectionFromPath=Do;mk.isEmptyPath=Xp});var Tr=I(function(wk){var yk=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Po(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var bk=(e,t,r)=>e.endsWith(`
29
+ `)?Po(r,t):r.includes(`
30
30
  `)?`
31
- `+Do(r,t):(e.endsWith(" ")?"":" ")+r;dk.indentComment=Do;dk.lineComment=pk;dk.stringifyComment=uk});var Xp=I(function(yk){function gk(e,t,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!s||s<0)return e;if(s<o)o=0;let c=Math.max(1+o,1+s-t.length);if(e.length<=c)return e;let l=[],p={},u=s-t.length;if(typeof n==="number")if(n>s-Math.max(2,o))l.push(0);else u=s-n;let d=void 0,h=void 0,b=!1,g=-1,w=-1,T=-1;if(r==="block"){if(g=Qp(e,g,t.length),g!==-1)u=g+c}for(let x;x=e[g+=1];){if(r==="quoted"&&x==="\\"){switch(w=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}T=g}if(x===`
32
- `){if(r==="block")g=Qp(e,g,t.length);u=g+t.length+c,d=void 0}else{if(x===" "&&h&&h!==" "&&h!==`
33
- `&&h!=="\t"){let D=e[g+1];if(D&&D!==" "&&D!==`
34
- `&&D!=="\t")d=g}if(g>=u)if(d)l.push(d),u=d+c,d=void 0;else if(r==="quoted"){while(h===" "||h==="\t")h=x,x=e[g+=1],b=!0;let D=g>T+1?g-2:w-1;if(p[D])return e;l.push(D),p[D]=!0,u=D+c,d=void 0}else b=!0}h=x}if(b&&a)a();if(l.length===0)return e;if(i)i();let N=e.slice(0,l[0]);for(let x=0;x<l.length;++x){let D=l[x],P=l[x+1]||e.length;if(D===0)N=`
35
- ${t}${e.slice(0,P)}`;else{if(r==="quoted"&&p[D])N+=`${e[D]}\\`;N+=`
36
- ${t}${e.slice(D+1,P)}`}}return N}function Qp(e,t,r){let n=t,s=t+1,o=e[s];while(o===" "||o==="\t")if(t<s+r)o=e[++t];else{do o=e[++t];while(o&&o!==`
37
- `);n=t,s=t+1,o=e[s]}return n}yk.FOLD_BLOCK="block";yk.FOLD_FLOW="flow";yk.FOLD_QUOTED="quoted";yk.foldFlowLines=gk});var Er=I(function(_k){var Pe=ae(),nt=Xp(),$n=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),En=(e)=>/^(%|---|\.\.\.)/m.test(e);function Sk(e,t,r){if(!t||t<0)return!1;let n=t-r,s=e.length;if(s<=n)return!1;for(let o=0,i=0;o<s;++o)if(e[o]===`
38
- `){if(o-i>n)return!0;if(i=o+1,s-i<=n)return!1}return!0}function $r(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,s=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(En(e)?" ":""),i="",a=0;for(let c=0,l=r[c];l;l=r[++c]){if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n")i+=r.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(r[c+1]){case"u":{i+=r.slice(a,c);let p=r.substr(c+2,4);switch(p){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:if(p.substr(0,2)==="00")i+="\\x"+p.substr(2);else i+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(n||r[c+2]==='"'||r.length<s)c+=1;else{i+=r.slice(a,c)+`
31
+ `+Po(r,t):(e.endsWith(" ")?"":" ")+r;wk.indentComment=Po;wk.lineComment=bk;wk.stringifyComment=yk});var rd=I(function(Ck){function xk(e,t,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!s||s<0)return e;if(s<o)o=0;let c=Math.max(1+o,1+s-t.length);if(e.length<=c)return e;let l=[],u={},p=s-t.length;if(typeof n==="number")if(n>s-Math.max(2,o))l.push(0);else p=s-n;let d=void 0,g=void 0,b=!1,y=-1,w=-1,T=-1;if(r==="block"){if(y=td(e,y,t.length),y!==-1)p=y+c}for(let x;x=e[y+=1];){if(r==="quoted"&&x==="\\"){switch(w=y,e[y+1]){case"x":y+=3;break;case"u":y+=5;break;case"U":y+=9;break;default:y+=1}T=y}if(x===`
32
+ `){if(r==="block")y=td(e,y,t.length);p=y+t.length+c,d=void 0}else{if(x===" "&&g&&g!==" "&&g!==`
33
+ `&&g!=="\t"){let D=e[y+1];if(D&&D!==" "&&D!==`
34
+ `&&D!=="\t")d=y}if(y>=p)if(d)l.push(d),p=d+c,d=void 0;else if(r==="quoted"){while(g===" "||g==="\t")g=x,x=e[y+=1],b=!0;let D=y>T+1?y-2:w-1;if(u[D])return e;l.push(D),u[D]=!0,p=D+c,d=void 0}else b=!0}g=x}if(b&&a)a();if(l.length===0)return e;if(i)i();let N=e.slice(0,l[0]);for(let x=0;x<l.length;++x){let D=l[x],P=l[x+1]||e.length;if(D===0)N=`
35
+ ${t}${e.slice(0,P)}`;else{if(r==="quoted"&&u[D])N+=`${e[D]}\\`;N+=`
36
+ ${t}${e.slice(D+1,P)}`}}return N}function td(e,t,r){let n=t,s=t+1,o=e[s];while(o===" "||o==="\t")if(t<s+r)o=e[++t];else{do o=e[++t];while(o&&o!==`
37
+ `);n=t,s=t+1,o=e[s]}return n}Ck.FOLD_BLOCK="block";Ck.FOLD_FLOW="flow";Ck.FOLD_QUOTED="quoted";Ck.foldFlowLines=xk});var Er=I(function(Dk){var Ie=ae(),nt=rd(),$n=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),En=(e)=>/^(%|---|\.\.\.)/m.test(e);function $k(e,t,r){if(!t||t<0)return!1;let n=t-r,s=e.length;if(s<=n)return!1;for(let o=0,i=0;o<s;++o)if(e[o]===`
38
+ `){if(o-i>n)return!0;if(i=o+1,s-i<=n)return!1}return!0}function $r(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,s=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(En(e)?" ":""),i="",a=0;for(let c=0,l=r[c];l;l=r[++c]){if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n")i+=r.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(r[c+1]){case"u":{i+=r.slice(a,c);let u=r.substr(c+2,4);switch(u){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:if(u.substr(0,2)==="00")i+="\\x"+u.substr(2);else i+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(n||r[c+2]==='"'||r.length<s)c+=1;else{i+=r.slice(a,c)+`
39
39
 
40
40
  `;while(r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"')i+=`
41
- `,c+=2;if(i+=o,r[c+2]===" ")i+="\\";c+=1,a=c+1}break;default:c+=1}}return i=a?i+r.slice(a):r,n?i:nt.foldFlowLines(i,o,nt.FOLD_QUOTED,$n(t,!1))}function Po(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
41
+ `,c+=2;if(i+=o,r[c+2]===" ")i+="\\";c+=1,a=c+1}break;default:c+=1}}return i=a?i+r.slice(a):r,n?i:nt.foldFlowLines(i,o,nt.FOLD_QUOTED,$n(t,!1))}function Io(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
42
42
  `)||/[ \t]\n|\n[ \t]/.test(e))return $r(e,t);let r=t.indent||(En(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
43
- ${r}`)+"'";return t.implicitKey?n:nt.foldFlowLines(n,r,nt.FOLD_FLOW,$n(t,!1))}function Jt(e,t){let{singleQuote:r}=t.options,n;if(r===!1)n=$r;else{let s=e.includes('"'),o=e.includes("'");if(s&&!o)n=Po;else if(o&&!s)n=$r;else n=r?Po:$r}return n(e,t)}var Io;try{Io=new RegExp(`(^|(?<!
43
+ ${r}`)+"'";return t.implicitKey?n:nt.foldFlowLines(n,r,nt.FOLD_FLOW,$n(t,!1))}function Ht(e,t){let{singleQuote:r}=t.options,n;if(r===!1)n=$r;else{let s=e.includes('"'),o=e.includes("'");if(s&&!o)n=Io;else if(o&&!s)n=$r;else n=r?Io:$r}return n(e,t)}var Fo;try{Fo=new RegExp(`(^|(?<!
44
44
  ))
45
45
  +(?!
46
- |$)`,"g")}catch{Io=/\n+(?!\n|$)/g}function Tn({comment:e,type:t,value:r},n,s,o){let{blockQuote:i,commentString:a,lineWidth:c}=n.options;if(!i||/\n[\t ]+$/.test(r))return Jt(r,n);let l=n.indent||(n.forceBlockIndent||En(r)?" ":""),p=i==="literal"?!0:i==="folded"||t===Pe.Scalar.BLOCK_FOLDED?!1:t===Pe.Scalar.BLOCK_LITERAL?!0:!Sk(r,c,l.length);if(!r)return p?`|
46
+ |$)`,"g")}catch{Fo=/\n+(?!\n|$)/g}function Tn({comment:e,type:t,value:r},n,s,o){let{blockQuote:i,commentString:a,lineWidth:c}=n.options;if(!i||/\n[\t ]+$/.test(r))return Ht(r,n);let l=n.indent||(n.forceBlockIndent||En(r)?" ":""),u=i==="literal"?!0:i==="folded"||t===Ie.Scalar.BLOCK_FOLDED?!1:t===Ie.Scalar.BLOCK_LITERAL?!0:!$k(r,c,l.length);if(!r)return u?`|
47
47
  `:`>
48
- `;let u,d;for(d=r.length;d>0;--d){let P=r[d-1];if(P!==`
49
- `&&P!=="\t"&&P!==" ")break}let h=r.substring(d),b=h.indexOf(`
50
- `);if(b===-1)u="-";else if(r===h||b!==h.length-1){if(u="+",o)o()}else u="";if(h){if(r=r.slice(0,-h.length),h[h.length-1]===`
51
- `)h=h.slice(0,-1);h=h.replace(Io,`$&${l}`)}let g=!1,w,T=-1;for(w=0;w<r.length;++w){let P=r[w];if(P===" ")g=!0;else if(P===`
52
- `)T=w;else break}let N=r.substring(0,T<w?T+1:w);if(N)r=r.substring(N.length),N=N.replace(/\n+/g,`$&${l}`);let D=(g?l?"2":"1":"")+u;if(e){if(D+=" "+a(e.replace(/ ?[\r\n]+/g," ")),s)s()}if(!p){let P=r.replace(/\n+/g,`
53
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),L=!1,K=$n(n,!0);if(i!=="folded"&&t!==Pe.Scalar.BLOCK_FOLDED)K.onOverflow=()=>{L=!0};let E=nt.foldFlowLines(`${N}${P}${h}`,l,nt.FOLD_BLOCK,K);if(!L)return`>${D}
48
+ `;let p,d;for(d=r.length;d>0;--d){let P=r[d-1];if(P!==`
49
+ `&&P!=="\t"&&P!==" ")break}let g=r.substring(d),b=g.indexOf(`
50
+ `);if(b===-1)p="-";else if(r===g||b!==g.length-1){if(p="+",o)o()}else p="";if(g){if(r=r.slice(0,-g.length),g[g.length-1]===`
51
+ `)g=g.slice(0,-1);g=g.replace(Fo,`$&${l}`)}let y=!1,w,T=-1;for(w=0;w<r.length;++w){let P=r[w];if(P===" ")y=!0;else if(P===`
52
+ `)T=w;else break}let N=r.substring(0,T<w?T+1:w);if(N)r=r.substring(N.length),N=N.replace(/\n+/g,`$&${l}`);let D=(y?l?"2":"1":"")+p;if(e){if(D+=" "+a(e.replace(/ ?[\r\n]+/g," ")),s)s()}if(!u){let P=r.replace(/\n+/g,`
53
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),L=!1,K=$n(n,!0);if(i!=="folded"&&t!==Ie.Scalar.BLOCK_FOLDED)K.onOverflow=()=>{L=!0};let E=nt.foldFlowLines(`${N}${P}${g}`,l,nt.FOLD_BLOCK,K);if(!L)return`>${D}
54
54
  ${l}${E}`}return r=r.replace(/\n+/g,`$&${l}`),`|${D}
55
- ${l}${N}${r}${h}`}function xk(e,t,r,n){let{type:s,value:o}=e,{actualString:i,implicitKey:a,indent:c,indentStep:l,inFlow:p}=t;if(a&&o.includes(`
56
- `)||p&&/[[\]{},]/.test(o))return Jt(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||p||!o.includes(`
57
- `)?Jt(o,t):Tn(e,t,r,n);if(!a&&!p&&s!==Pe.Scalar.PLAIN&&o.includes(`
58
- `))return Tn(e,t,r,n);if(En(o)){if(c==="")return t.forceBlockIndent=!0,Tn(e,t,r,n);else if(a&&c===l)return Jt(o,t)}let u=o.replace(/\n+/g,`$&
59
- ${c}`);if(i){let d=(g)=>g.default&&g.tag!=="tag:yaml.org,2002:str"&&g.test?.test(u),{compat:h,tags:b}=t.doc.schema;if(b.some(d)||h?.some(d))return Jt(o,t)}return a?u:nt.foldFlowLines(u,c,nt.FOLD_FLOW,$n(t,!1))}function Ck(e,t,r,n){let{implicitKey:s,inFlow:o}=t,i=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Pe.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value))a=Pe.Scalar.QUOTE_DOUBLE}let c=(p)=>{switch(p){case Pe.Scalar.BLOCK_FOLDED:case Pe.Scalar.BLOCK_LITERAL:return s||o?Jt(i.value,t):Tn(i,t,r,n);case Pe.Scalar.QUOTE_DOUBLE:return $r(i.value,t);case Pe.Scalar.QUOTE_SINGLE:return Po(i.value,t);case Pe.Scalar.PLAIN:return xk(i,t,r,n);default:return null}},l=c(a);if(l===null){let{defaultKeyType:p,defaultStringType:u}=t.options,d=s&&p||u;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}_k.stringifyString=Ck});var Nr=I(function(Ik){var Ok=Cn(),st=J(),Tk=Tr(),$k=Er();function Ek(e,t){let r=Object.assign({blockQuote:!0,commentString:Tk.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,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function Nk(e,t){if(t.tag){let s=e.filter((o)=>o.tag===t.tag);if(s.length>0)return s.find((o)=>o.format===t.format)??s[0]}let r=void 0,n;if(st.isScalar(t)){n=t.value;let s=e.filter((o)=>o.identify?.(n));if(s.length>1){let o=s.filter((i)=>i.test);if(o.length>0)s=o}r=s.find((o)=>o.format===t.format)??s.find((o)=>!o.format)}else n=t,r=e.find((s)=>s.nodeClass&&n instanceof s.nodeClass);if(!r){let s=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${s} value`)}return r}function Dk(e,t,{anchors:r,doc:n}){if(!n.directives)return"";let s=[],o=(st.isScalar(e)||st.isCollection(e))&&e.anchor;if(o&&Ok.anchorIsValid(o))r.add(o),s.push(`&${o}`);let i=e.tag??(t.default?null:t.tag);if(i)s.push(n.directives.tagString(i));return s.join(" ")}function Pk(e,t,r,n){if(st.isPair(e))return e.toString(t,r,n);if(st.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let s=void 0,o=st.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>s=c});s??(s=Nk(t.doc.schema.tags,o));let i=Dk(o,s,t);if(i.length>0)t.indentAtStart=(t.indentAtStart??0)+i.length+1;let a=typeof s.stringify==="function"?s.stringify(o,t,r,n):st.isScalar(o)?$k.stringifyString(o,t,r,n):o.toString(t,r,n);if(!i)return a;return st.isScalar(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
60
- ${t.indent}${a}`}Ik.createStringifyContext=Ek;Ik.stringify=Pk});var rd=I(function(qk){var He=J(),ed=ae(),td=Nr(),Dr=Tr();function zk({key:e,value:t},r,n,s){let{allNullValues:o,doc:i,indent:a,indentStep:c,options:{commentString:l,indentSeq:p,simpleKeys:u}}=r,d=He.isNode(e)&&e.comment||null;if(u){if(d)throw Error("With simple keys, key nodes cannot have comments");if(He.isCollection(e)||!He.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!u&&(!e||d&&t==null&&!r.inFlow||He.isCollection(e)||(He.isScalar(e)?e.type===ed.Scalar.BLOCK_FOLDED||e.type===ed.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(u||!o),indent:a+c});let b=!1,g=!1,w=td.stringify(e,r,()=>b=!0,()=>g=!0);if(!h&&!r.inFlow&&w.length>1024){if(u)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(o||t==null){if(b&&n)n();return w===""?"?":h?`? ${w}`:w}}else if(o&&!u||t==null&&h){if(w=`? ${w}`,d&&!b)w+=Dr.lineComment(w,r.indent,l(d));else if(g&&s)s();return w}if(b)d=null;if(h){if(d)w+=Dr.lineComment(w,r.indent,l(d));w=`? ${w}
61
- ${a}:`}else if(w=`${w}:`,d)w+=Dr.lineComment(w,r.indent,l(d));let T,N,x;if(He.isNode(t))T=!!t.spaceBefore,N=t.commentBefore,x=t.comment;else if(T=!1,N=null,x=null,t&&typeof t==="object")t=i.createNode(t);if(r.implicitKey=!1,!h&&!d&&He.isScalar(t))r.indentAtStart=w.length+1;if(g=!1,!p&&c.length>=2&&!r.inFlow&&!h&&He.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let D=!1,P=td.stringify(t,r,()=>D=!0,()=>g=!0),L=" ";if(d||T||N){if(L=T?`
55
+ ${l}${N}${r}${g}`}function Ek(e,t,r,n){let{type:s,value:o}=e,{actualString:i,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes(`
56
+ `)||u&&/[[\]{},]/.test(o))return Ht(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
57
+ `)?Ht(o,t):Tn(e,t,r,n);if(!a&&!u&&s!==Ie.Scalar.PLAIN&&o.includes(`
58
+ `))return Tn(e,t,r,n);if(En(o)){if(c==="")return t.forceBlockIndent=!0,Tn(e,t,r,n);else if(a&&c===l)return Ht(o,t)}let p=o.replace(/\n+/g,`$&
59
+ ${c}`);if(i){let d=(y)=>y.default&&y.tag!=="tag:yaml.org,2002:str"&&y.test?.test(p),{compat:g,tags:b}=t.doc.schema;if(b.some(d)||g?.some(d))return Ht(o,t)}return a?p:nt.foldFlowLines(p,c,nt.FOLD_FLOW,$n(t,!1))}function Nk(e,t,r,n){let{implicitKey:s,inFlow:o}=t,i=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Ie.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value))a=Ie.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Ie.Scalar.BLOCK_FOLDED:case Ie.Scalar.BLOCK_LITERAL:return s||o?Ht(i.value,t):Tn(i,t,r,n);case Ie.Scalar.QUOTE_DOUBLE:return $r(i.value,t);case Ie.Scalar.QUOTE_SINGLE:return Io(i.value,t);case Ie.Scalar.PLAIN:return Ek(i,t,r,n);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:p}=t.options,d=s&&u||p;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}Dk.stringifyString=Nk});var Nr=I(function(Uk){var Ik=Cn(),st=J(),Fk=Tr(),Lk=Er();function zk(e,t){let r=Object.assign({blockQuote:!0,commentString:Fk.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,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent==="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function qk(e,t){if(t.tag){let s=e.filter((o)=>o.tag===t.tag);if(s.length>0)return s.find((o)=>o.format===t.format)??s[0]}let r=void 0,n;if(st.isScalar(t)){n=t.value;let s=e.filter((o)=>o.identify?.(n));if(s.length>1){let o=s.filter((i)=>i.test);if(o.length>0)s=o}r=s.find((o)=>o.format===t.format)??s.find((o)=>!o.format)}else n=t,r=e.find((s)=>s.nodeClass&&n instanceof s.nodeClass);if(!r){let s=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${s} value`)}return r}function Kk(e,t,{anchors:r,doc:n}){if(!n.directives)return"";let s=[],o=(st.isScalar(e)||st.isCollection(e))&&e.anchor;if(o&&Ik.anchorIsValid(o))r.add(o),s.push(`&${o}`);let i=e.tag??(t.default?null:t.tag);if(i)s.push(n.directives.tagString(i));return s.join(" ")}function Rk(e,t,r,n){if(st.isPair(e))return e.toString(t,r,n);if(st.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let s=void 0,o=st.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>s=c});s??(s=qk(t.doc.schema.tags,o));let i=Kk(o,s,t);if(i.length>0)t.indentAtStart=(t.indentAtStart??0)+i.length+1;let a=typeof s.stringify==="function"?s.stringify(o,t,r,n):st.isScalar(o)?Lk.stringifyString(o,t,r,n):o.toString(t,r,n);if(!i)return a;return st.isScalar(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
60
+ ${t.indent}${a}`}Uk.createStringifyContext=zk;Uk.stringify=Rk});var od=I(function(Vk){var He=J(),nd=ae(),sd=Nr(),Dr=Tr();function Zk({key:e,value:t},r,n,s){let{allNullValues:o,doc:i,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:p}}=r,d=He.isNode(e)&&e.comment||null;if(p){if(d)throw Error("With simple keys, key nodes cannot have comments");if(He.isCollection(e)||!He.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let g=!p&&(!e||d&&t==null&&!r.inFlow||He.isCollection(e)||(He.isScalar(e)?e.type===nd.Scalar.BLOCK_FOLDED||e.type===nd.Scalar.BLOCK_LITERAL:typeof e==="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!g&&(p||!o),indent:a+c});let b=!1,y=!1,w=sd.stringify(e,r,()=>b=!0,()=>y=!0);if(!g&&!r.inFlow&&w.length>1024){if(p)throw Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(r.inFlow){if(o||t==null){if(b&&n)n();return w===""?"?":g?`? ${w}`:w}}else if(o&&!p||t==null&&g){if(w=`? ${w}`,d&&!b)w+=Dr.lineComment(w,r.indent,l(d));else if(y&&s)s();return w}if(b)d=null;if(g){if(d)w+=Dr.lineComment(w,r.indent,l(d));w=`? ${w}
61
+ ${a}:`}else if(w=`${w}:`,d)w+=Dr.lineComment(w,r.indent,l(d));let T,N,x;if(He.isNode(t))T=!!t.spaceBefore,N=t.commentBefore,x=t.comment;else if(T=!1,N=null,x=null,t&&typeof t==="object")t=i.createNode(t);if(r.implicitKey=!1,!g&&!d&&He.isScalar(t))r.indentAtStart=w.length+1;if(y=!1,!u&&c.length>=2&&!r.inFlow&&!g&&He.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)r.indent=r.indent.substring(2);let D=!1,P=sd.stringify(t,r,()=>D=!0,()=>y=!0),L=" ";if(d||T||N){if(L=T?`
62
62
  `:"",N){let K=l(N);L+=`
63
63
  ${Dr.indentComment(K,r.indent)}`}if(P===""&&!r.inFlow){if(L===`
64
64
  `&&x)L=`
65
65
 
66
66
  `}else L+=`
67
- ${r.indent}`}else if(!h&&He.isCollection(t)){let K=P[0],E=P.indexOf(`
67
+ ${r.indent}`}else if(!g&&He.isCollection(t)){let K=P[0],E=P.indexOf(`
68
68
  `),O=E!==-1,C=r.inFlow??t.flow??t.items.length===0;if(O||!C){let v=!1;if(O&&(K==="&"||K==="!")){let A=P.indexOf(" ");if(K==="&"&&A!==-1&&A<E&&P[A+1]==="!")A=P.indexOf(" ",A+1);if(A===-1||E<A)v=!0}if(!v)L=`
69
69
  ${r.indent}`}}else if(P===""||P[0]===`
70
- `)L="";if(w+=L+P,r.inFlow){if(D&&n)n()}else if(x&&!D)w+=Dr.lineComment(w,r.indent,l(x));else if(g&&s)s();return w}qk.stringifyPair=zk});var Fo=I(function(Mk){var nd=We("process");function Rk(e,...t){if(e==="debug")console.log(...t)}function Uk(e,t){if(e==="debug"||e==="warn")if(typeof nd.emitWarning==="function")nd.emitWarning(t);else console.warn(t)}Mk.debug=Rk;Mk.warn=Uk});var In=I(function(Wk){var Pn=J(),sd=ae(),Nn="<<",Dn={identify:(e)=>e===Nn||typeof e==="symbol"&&e.description===Nn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new sd.Scalar(Symbol(Nn)),{addToJSMap:od}),stringify:()=>Nn},Vk=(e,t)=>(Dn.identify(t)||Pn.isScalar(t)&&(!t.type||t.type===sd.Scalar.PLAIN)&&Dn.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===Dn.tag&&r.default);function od(e,t,r){let n=id(e,r);if(Pn.isSeq(n))for(let s of n.items)Lo(e,t,s);else if(Array.isArray(n))for(let s of n)Lo(e,t,s);else Lo(e,t,n)}function Lo(e,t,r){let n=id(e,r);if(!Pn.isMap(n))throw Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,e,Map);for(let[o,i]of s)if(t instanceof Map){if(!t.has(o))t.set(o,i)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function id(e,t){return e&&Pn.isAlias(t)?t.resolve(e.doc,e):t}Wk.addMergeToJSMap=od;Wk.isMergeKey=Vk;Wk.merge=Dn});var qo=I(function(eS){var Hk=Fo(),ad=In(),Yk=Nr(),cd=J(),zo=rt();function Qk(e,t,{key:r,value:n}){if(cd.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,n);else if(ad.isMergeKey(e,r))ad.addMergeToJSMap(e,t,n);else{let s=zo.toJS(r,"",e);if(t instanceof Map)t.set(s,zo.toJS(n,s,e));else if(t instanceof Set)t.add(s);else{let o=Xk(r,s,e),i=zo.toJS(n,o,e);if(o in t)Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});else t[o]=i}}return t}function Xk(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(cd.isNode(e)&&r?.doc){let n=Yk.createStringifyContext(r.doc,{});n.anchors=new Set;for(let o of r.anchors.keys())n.anchors.add(o.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=e.toString(n);if(!r.mapKeyWarned){let o=JSON.stringify(s);if(o.length>40)o=o.substring(0,36)+'..."';Hk.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return s}return JSON.stringify(t)}eS.addPairToJSMap=Qk});var ot=I(function(oS){var ld=Or(),rS=rd(),nS=qo(),Fn=J();function sS(e,t,r){let n=ld.createNode(e,void 0,r),s=ld.createNode(t,void 0,r);return new Ln(n,s)}class Ln{constructor(e,t=null){Object.defineProperty(this,Fn.NODE_TYPE,{value:Fn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(Fn.isNode(t))t=t.clone(e);if(Fn.isNode(r))r=r.clone(e);return new Ln(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return nS.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?rS.stringifyPair(this,e,t,r):JSON.stringify(this)}}oS.Pair=Ln;oS.createPair=sS});var Ko=I(function(pS){var Tt=J(),ud=Nr(),zn=Tr();function cS(e,t,r){return(t.inFlow??e.flow?uS:lS)(e,t,r)}function lS({comment:e,items:t},r,{blockItemPrefix:n,flowChars:s,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:l}}=r,p=Object.assign({},r,{indent:o,type:null}),u=!1,d=[];for(let b=0;b<t.length;++b){let g=t[b],w=null;if(Tt.isNode(g)){if(!u&&g.spaceBefore)d.push("");if(qn(r,d,g.commentBefore,u),g.comment)w=g.comment}else if(Tt.isPair(g)){let N=Tt.isNode(g.key)?g.key:null;if(N){if(!u&&N.spaceBefore)d.push("");qn(r,d,N.commentBefore,u)}}u=!1;let T=ud.stringify(g,p,()=>w=null,()=>u=!0);if(w)T+=zn.lineComment(T,o,l(w));if(u&&w)u=!1;d.push(n+T)}let h;if(d.length===0)h=s.start+s.end;else{h=d[0];for(let b=1;b<d.length;++b){let g=d[b];h+=g?`
71
- ${c}${g}`:`
72
- `}}if(e){if(h+=`
73
- `+zn.indentComment(l(e),c),a)a()}else if(u&&i)i();return h}function uS({items:e},t,{flowChars:r,itemIndent:n}){let{indent:s,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=t;n+=o;let c=Object.assign({},t,{indent:n,inFlow:!0,type:null}),l=!1,p=0,u=[];for(let b=0;b<e.length;++b){let g=e[b],w=null;if(Tt.isNode(g)){if(g.spaceBefore)u.push("");if(qn(t,u,g.commentBefore,!1),g.comment)w=g.comment}else if(Tt.isPair(g)){let N=Tt.isNode(g.key)?g.key:null;if(N){if(N.spaceBefore)u.push("");if(qn(t,u,N.commentBefore,!1),N.comment)l=!0}let x=Tt.isNode(g.value)?g.value:null;if(x){if(x.comment)w=x.comment;if(x.commentBefore)l=!0}else if(g.value==null&&N?.comment)w=N.comment}if(w)l=!0;let T=ud.stringify(g,c,()=>w=null);if(l||(l=u.length>p||T.includes(`
74
- `)),b<e.length-1)T+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=u.reduce((N,x)=>N+x.length+2,2)+(T.length+2)>t.options.lineWidth);if(l)T+=","}if(w)T+=zn.lineComment(T,n,a(w));u.push(T),p=u.length}let{start:d,end:h}=r;if(u.length===0)return d+h;else{if(!l){let b=u.reduce((g,w)=>g+w.length+2,2);l=t.options.lineWidth>0&&b>t.options.lineWidth}if(l){let b=d;for(let g of u)b+=g?`
75
- ${o}${s}${g}`:`
70
+ `)L="";if(w+=L+P,r.inFlow){if(D&&n)n()}else if(x&&!D)w+=Dr.lineComment(w,r.indent,l(x));else if(y&&s)s();return w}Vk.stringifyPair=Zk});var Lo=I(function(Bk){var id=We("process");function Gk(e,...t){if(e==="debug")console.log(...t)}function Jk(e,t){if(e==="debug"||e==="warn")if(typeof id.emitWarning==="function")id.emitWarning(t);else console.warn(t)}Bk.debug=Gk;Bk.warn=Jk});var In=I(function(Xk){var Pn=J(),ad=ae(),Nn="<<",Dn={identify:(e)=>e===Nn||typeof e==="symbol"&&e.description===Nn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ad.Scalar(Symbol(Nn)),{addToJSMap:cd}),stringify:()=>Nn},Qk=(e,t)=>(Dn.identify(t)||Pn.isScalar(t)&&(!t.type||t.type===ad.Scalar.PLAIN)&&Dn.identify(t.value))&&e?.doc.schema.tags.some((r)=>r.tag===Dn.tag&&r.default);function cd(e,t,r){let n=ld(e,r);if(Pn.isSeq(n))for(let s of n.items)zo(e,t,s);else if(Array.isArray(n))for(let s of n)zo(e,t,s);else zo(e,t,n)}function zo(e,t,r){let n=ld(e,r);if(!Pn.isMap(n))throw Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,e,Map);for(let[o,i]of s)if(t instanceof Map){if(!t.has(o))t.set(o,i)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function ld(e,t){return e&&Pn.isAlias(t)?t.resolve(e.doc,e):t}Xk.addMergeToJSMap=cd;Xk.isMergeKey=Qk;Xk.merge=Dn});var Ko=I(function(aS){var nS=Lo(),ud=In(),sS=Nr(),pd=J(),qo=rt();function oS(e,t,{key:r,value:n}){if(pd.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,n);else if(ud.isMergeKey(e,r))ud.addMergeToJSMap(e,t,n);else{let s=qo.toJS(r,"",e);if(t instanceof Map)t.set(s,qo.toJS(n,s,e));else if(t instanceof Set)t.add(s);else{let o=iS(r,s,e),i=qo.toJS(n,o,e);if(o in t)Object.defineProperty(t,o,{value:i,writable:!0,enumerable:!0,configurable:!0});else t[o]=i}}return t}function iS(e,t,r){if(t===null)return"";if(typeof t!=="object")return String(t);if(pd.isNode(e)&&r?.doc){let n=sS.createStringifyContext(r.doc,{});n.anchors=new Set;for(let o of r.anchors.keys())n.anchors.add(o.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=e.toString(n);if(!r.mapKeyWarned){let o=JSON.stringify(s);if(o.length>40)o=o.substring(0,36)+'..."';nS.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return s}return JSON.stringify(t)}aS.addPairToJSMap=oS});var ot=I(function(dS){var dd=Or(),lS=od(),uS=Ko(),Fn=J();function pS(e,t,r){let n=dd.createNode(e,void 0,r),s=dd.createNode(t,void 0,r);return new Ln(n,s)}class Ln{constructor(e,t=null){Object.defineProperty(this,Fn.NODE_TYPE,{value:Fn.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;if(Fn.isNode(t))t=t.clone(e);if(Fn.isNode(r))r=r.clone(e);return new Ln(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return uS.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?lS.stringifyPair(this,e,t,r):JSON.stringify(this)}}dS.Pair=Ln;dS.createPair=pS});var Ro=I(function(bS){var Tt=J(),md=Nr(),zn=Tr();function hS(e,t,r){return(t.inFlow??e.flow?yS:gS)(e,t,r)}function gS({comment:e,items:t},r,{blockItemPrefix:n,flowChars:s,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:o,type:null}),p=!1,d=[];for(let b=0;b<t.length;++b){let y=t[b],w=null;if(Tt.isNode(y)){if(!p&&y.spaceBefore)d.push("");if(qn(r,d,y.commentBefore,p),y.comment)w=y.comment}else if(Tt.isPair(y)){let N=Tt.isNode(y.key)?y.key:null;if(N){if(!p&&N.spaceBefore)d.push("");qn(r,d,N.commentBefore,p)}}p=!1;let T=md.stringify(y,u,()=>w=null,()=>p=!0);if(w)T+=zn.lineComment(T,o,l(w));if(p&&w)p=!1;d.push(n+T)}let g;if(d.length===0)g=s.start+s.end;else{g=d[0];for(let b=1;b<d.length;++b){let y=d[b];g+=y?`
71
+ ${c}${y}`:`
72
+ `}}if(e){if(g+=`
73
+ `+zn.indentComment(l(e),c),a)a()}else if(p&&i)i();return g}function yS({items:e},t,{flowChars:r,itemIndent:n}){let{indent:s,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=t;n+=o;let c=Object.assign({},t,{indent:n,inFlow:!0,type:null}),l=!1,u=0,p=[];for(let b=0;b<e.length;++b){let y=e[b],w=null;if(Tt.isNode(y)){if(y.spaceBefore)p.push("");if(qn(t,p,y.commentBefore,!1),y.comment)w=y.comment}else if(Tt.isPair(y)){let N=Tt.isNode(y.key)?y.key:null;if(N){if(N.spaceBefore)p.push("");if(qn(t,p,N.commentBefore,!1),N.comment)l=!0}let x=Tt.isNode(y.value)?y.value:null;if(x){if(x.comment)w=x.comment;if(x.commentBefore)l=!0}else if(y.value==null&&N?.comment)w=N.comment}if(w)l=!0;let T=md.stringify(y,c,()=>w=null);if(l||(l=p.length>u||T.includes(`
74
+ `)),b<e.length-1)T+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=p.reduce((N,x)=>N+x.length+2,2)+(T.length+2)>t.options.lineWidth);if(l)T+=","}if(w)T+=zn.lineComment(T,n,a(w));p.push(T),u=p.length}let{start:d,end:g}=r;if(p.length===0)return d+g;else{if(!l){let b=p.reduce((y,w)=>y+w.length+2,2);l=t.options.lineWidth>0&&b>t.options.lineWidth}if(l){let b=d;for(let y of p)b+=y?`
75
+ ${o}${s}${y}`:`
76
76
  `;return`${b}
77
- ${s}${h}`}else return`${d}${i}${u.join(" ")}${i}${h}`}}function qn({indent:e,options:{commentString:t}},r,n,s){if(n&&s)n=n.replace(/^\n+/,"");if(n){let o=zn.indentComment(t(n),e);r.push(o.trimStart())}}pS.stringifyCollection=cS});var at=I(function(yS){var mS=Ko(),fS=qo(),hS=On(),it=J(),Kn=ot(),gS=ae();function Pr(e,t){let r=it.isScalar(t)?t.value:t;for(let n of e)if(it.isPair(n)){if(n.key===t||n.key===r)return n;if(it.isScalar(n.key)&&n.key.value===r)return n}return}class pd extends hS.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(it.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:s}=r,o=new this(e),i=(a,c)=>{if(typeof s==="function")c=s.call(t,a,c);else if(Array.isArray(s)&&!s.includes(a))return;if(c!==void 0||n)o.items.push(Kn.createPair(a,c,r))};if(t instanceof Map)for(let[a,c]of t)i(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))i(a,t[a]);if(typeof e.sortMapEntries==="function")o.items.sort(e.sortMapEntries);return o}add(e,t){let r;if(it.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new Kn.Pair(e,e?.value);else r=new Kn.Pair(e.key,e.value);let n=Pr(this.items,r.key),s=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${r.key} already set`);if(it.isScalar(n.value)&&gS.isScalarValue(r.value))n.value.value=r.value;else n.value=r.value}else if(s){let o=this.items.findIndex((i)=>s(r,i)<0);if(o===-1)this.items.push(r);else this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let t=Pr(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Pr(this.items,e)?.value;return(!t&&it.isScalar(n)?n.value:n)??void 0}has(e){return!!Pr(this.items,e)}set(e,t){this.add(new Kn.Pair(e,t),!0)}toJSON(e,t,r){let n=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let s of this.items)fS.addPairToJSMap(t,n,s);return n}toString(e,t,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!it.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return mS.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}yS.YAMLMap=pd;yS.findPair=Pr});var Bt=I(function(SS){var vS=J(),dd=at(),kS={collection:"map",default:!0,nodeClass:dd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!vS.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>dd.YAMLMap.from(e,t,r)};SS.map=kS});var ct=I(function($S){var CS=Or(),_S=Ko(),AS=On(),Un=J(),OS=ae(),TS=rt();class md extends AS.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Un.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Rn(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=Rn(e);if(typeof r!=="number")return;let n=this.items[r];return!t&&Un.isScalar(n)?n.value:n}has(e){let t=Rn(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=Rn(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[r];if(Un.isScalar(n)&&OS.isScalarValue(t))n.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let n=0;for(let s of this.items)r.push(TS.toJS(s,String(n++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return _S.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let i of t){if(typeof n==="function"){let a=t instanceof Set?i:String(o++);i=n.call(t,a,i)}s.items.push(CS.createNode(i,void 0,r))}}return s}}function Rn(e){let t=Un.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}$S.YAMLSeq=md});var Ht=I(function(PS){var NS=J(),fd=ct(),DS={collection:"seq",default:!0,nodeClass:fd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!NS.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>fd.YAMLSeq.from(e,t,r)};PS.seq=DS});var Ir=I(function(zS){var FS=Er(),LS={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,n){return t=Object.assign({actualString:!0},t),FS.stringifyString(e,t,r,n)}};zS.string=LS});var Mn=I(function(KS){var hd=ae(),gd={identify:(e)=>e==null,createNode:()=>new hd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new hd.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&gd.test.test(e)?e:t.options.nullStr};KS.nullTag=gd});var Ro=I(function(MS){var US=ae(),yd={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new US.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&yd.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?r.options.trueStr:r.options.falseStr}};MS.boolTag=yd});var Yt=I(function(VS){function ZS({format:e,minFractionDigits:t,tag:r,value:n}){if(typeof n==="bigint")return String(n);let s=typeof n==="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");if(i<0)i=o.length,o+=".";let a=t-(o.length-i-1);while(a-- >0)o+="0"}return o}VS.stringifyNumber=ZS});var Mo=I(function(YS){var GS=ae(),Uo=Yt(),JS={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Uo.stringifyNumber},BS={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Uo.stringifyNumber(e)}},HS={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new GS.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:Uo.stringifyNumber};YS.float=HS;YS.floatExp=BS;YS.floatNaN=JS});var Zo=I(function(sx){var bd=Yt(),jn=(e)=>typeof e==="bigint"||Number.isInteger(e),jo=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function wd(e,t,r){let{value:n}=e;if(jn(n)&&n>=0)return r+n.toString(t);return bd.stringifyNumber(e)}var tx={identify:(e)=>jn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>jo(e,2,8,r),stringify:(e)=>wd(e,8,"0o")},rx={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>jo(e,0,10,r),stringify:bd.stringifyNumber},nx={identify:(e)=>jn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>jo(e,2,16,r),stringify:(e)=>wd(e,16,"0x")};sx.int=rx;sx.intHex=nx;sx.intOct=tx});var vd=I(function(fx){var cx=Bt(),lx=Mn(),ux=Ht(),px=Ir(),dx=Ro(),Vo=Mo(),Wo=Zo(),mx=[cx.map,ux.seq,px.string,lx.nullTag,dx.boolTag,Wo.intOct,Wo.int,Wo.intHex,Vo.floatNaN,Vo.floatExp,Vo.float];fx.schema=mx});var Sd=I(function(Sx){var gx=ae(),yx=Bt(),bx=Ht();function kd(e){return typeof e==="bigint"||Number.isInteger(e)}var Zn=({value:e})=>JSON.stringify(e),wx=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:Zn},{identify:(e)=>e==null,createNode:()=>new gx.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Zn},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:Zn},{identify:kd,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>kd(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:Zn}],vx={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},kx=[yx.map,bx.seq].concat(wx,vx);Sx.schema=kx});var Jo=I(function(Ax){var Fr=We("buffer"),Go=ae(),Cx=Er(),_x={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Fr.Buffer==="function")return Fr.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let s=0;s<r.length;++s)n[s]=r.charCodeAt(s);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},n,s,o){if(!r)return"";let i=r,a;if(typeof Fr.Buffer==="function")a=i instanceof Fr.Buffer?i.toString("base64"):Fr.Buffer.from(i.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<i.length;++l)c+=String.fromCharCode(i[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Go.Scalar.BLOCK_LITERAL),t!==Go.Scalar.QUOTE_DOUBLE){let c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),l=Math.ceil(a.length/c),p=Array(l);for(let u=0,d=0;u<l;++u,d+=c)p[u]=a.substr(d,c);a=p.join(t===Go.Scalar.BLOCK_LITERAL?`
78
- `:" ")}return Cx.stringifyString({comment:e,type:t,value:a},n,s,o)}};Ax.binary=_x});var Wn=I(function(Nx){var Vn=J(),Bo=ot(),Tx=ae(),$x=ct();function xd(e,t){if(Vn.isSeq(e))for(let r=0;r<e.items.length;++r){let n=e.items[r];if(Vn.isPair(n))continue;else if(Vn.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let s=n.items[0]||new Bo.Pair(new Tx.Scalar(null));if(n.commentBefore)s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
77
+ ${s}${g}`}else return`${d}${i}${p.join(" ")}${i}${g}`}}function qn({indent:e,options:{commentString:t}},r,n,s){if(n&&s)n=n.replace(/^\n+/,"");if(n){let o=zn.indentComment(t(n),e);r.push(o.trimStart())}}bS.stringifyCollection=hS});var at=I(function(CS){var vS=Ro(),kS=Ko(),SS=On(),it=J(),Kn=ot(),xS=ae();function Pr(e,t){let r=it.isScalar(t)?t.value:t;for(let n of e)if(it.isPair(n)){if(n.key===t||n.key===r)return n;if(it.isScalar(n.key)&&n.key.value===r)return n}return}class fd extends SS.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(it.MAP,e);this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:s}=r,o=new this(e),i=(a,c)=>{if(typeof s==="function")c=s.call(t,a,c);else if(Array.isArray(s)&&!s.includes(a))return;if(c!==void 0||n)o.items.push(Kn.createPair(a,c,r))};if(t instanceof Map)for(let[a,c]of t)i(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))i(a,t[a]);if(typeof e.sortMapEntries==="function")o.items.sort(e.sortMapEntries);return o}add(e,t){let r;if(it.isPair(e))r=e;else if(!e||typeof e!=="object"||!("key"in e))r=new Kn.Pair(e,e?.value);else r=new Kn.Pair(e.key,e.value);let n=Pr(this.items,r.key),s=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${r.key} already set`);if(it.isScalar(n.value)&&xS.isScalarValue(r.value))n.value.value=r.value;else n.value=r.value}else if(s){let o=this.items.findIndex((i)=>s(r,i)<0);if(o===-1)this.items.push(r);else this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let t=Pr(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Pr(this.items,e)?.value;return(!t&&it.isScalar(n)?n.value:n)??void 0}has(e){return!!Pr(this.items,e)}set(e,t){this.add(new Kn.Pair(e,t),!0)}toJSON(e,t,r){let n=r?new r:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let s of this.items)kS.addPairToJSMap(t,n,s);return n}toString(e,t,r){if(!e)return JSON.stringify(this);for(let n of this.items)if(!it.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return vS.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}CS.YAMLMap=fd;CS.findPair=Pr});var Yt=I(function($S){var OS=J(),hd=at(),TS={collection:"map",default:!0,nodeClass:hd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!OS.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,r)=>hd.YAMLMap.from(e,t,r)};$S.map=TS});var ct=I(function(LS){var NS=Or(),DS=Ro(),PS=On(),Un=J(),IS=ae(),FS=rt();class gd extends PS.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Un.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Rn(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let r=Rn(e);if(typeof r!=="number")return;let n=this.items[r];return!t&&Un.isScalar(n)?n.value:n}has(e){let t=Rn(e);return typeof t==="number"&&t<this.items.length}set(e,t){let r=Rn(e);if(typeof r!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[r];if(Un.isScalar(n)&&IS.isScalarValue(t))n.value=t;else this.items[r]=t}toJSON(e,t){let r=[];if(t?.onCreate)t.onCreate(r);let n=0;for(let s of this.items)r.push(FS.toJS(s,String(n++),t));return r}toString(e,t,r){if(!e)return JSON.stringify(this);return DS.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t})}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let i of t){if(typeof n==="function"){let a=t instanceof Set?i:String(o++);i=n.call(t,a,i)}s.items.push(NS.createNode(i,void 0,r))}}return s}}function Rn(e){let t=Un.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}LS.YAMLSeq=gd});var Qt=I(function(RS){var qS=J(),yd=ct(),KS={collection:"seq",default:!0,nodeClass:yd.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!qS.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,r)=>yd.YAMLSeq.from(e,t,r)};RS.seq=KS});var Ir=I(function(ZS){var MS=Er(),jS={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,r,n){return t=Object.assign({actualString:!0},t),MS.stringifyString(e,t,r,n)}};ZS.string=jS});var Mn=I(function(WS){var bd=ae(),wd={identify:(e)=>e==null,createNode:()=>new bd.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new bd.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&wd.test.test(e)?e:t.options.nullStr};WS.nullTag=wd});var Uo=I(function(BS){var JS=ae(),vd={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new JS.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},r){if(e&&vd.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?r.options.trueStr:r.options.falseStr}};BS.boolTag=vd});var Xt=I(function(QS){function YS({format:e,minFractionDigits:t,tag:r,value:n}){if(typeof n==="bigint")return String(n);let s=typeof n==="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");if(i<0)i=o.length,o+=".";let a=t-(o.length-i-1);while(a-- >0)o+="0"}return o}QS.stringifyNumber=YS});var jo=I(function(sx){var ex=ae(),Mo=Xt(),tx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Mo.stringifyNumber},rx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Mo.stringifyNumber(e)}},nx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new ex.Scalar(parseFloat(e)),r=e.indexOf(".");if(r!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-r-1;return t},stringify:Mo.stringifyNumber};sx.float=nx;sx.floatExp=rx;sx.floatNaN=tx});var Vo=I(function(px){var kd=Xt(),jn=(e)=>typeof e==="bigint"||Number.isInteger(e),Zo=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function Sd(e,t,r){let{value:n}=e;if(jn(n)&&n>=0)return r+n.toString(t);return kd.stringifyNumber(e)}var cx={identify:(e)=>jn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>Zo(e,2,8,r),stringify:(e)=>Sd(e,8,"0o")},lx={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>Zo(e,0,10,r),stringify:kd.stringifyNumber},ux={identify:(e)=>jn(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>Zo(e,2,16,r),stringify:(e)=>Sd(e,16,"0x")};px.int=lx;px.intHex=ux;px.intOct=cx});var xd=I(function(kx){var hx=Yt(),gx=Mn(),yx=Qt(),bx=Ir(),wx=Uo(),Wo=jo(),Go=Vo(),vx=[hx.map,yx.seq,bx.string,gx.nullTag,wx.boolTag,Go.intOct,Go.int,Go.intHex,Wo.floatNaN,Wo.floatExp,Wo.float];kx.schema=vx});var _d=I(function($x){var xx=ae(),Cx=Yt(),_x=Qt();function Cd(e){return typeof e==="bigint"||Number.isInteger(e)}var Zn=({value:e})=>JSON.stringify(e),Ax=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:Zn},{identify:(e)=>e==null,createNode:()=>new xx.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Zn},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:Zn},{identify:Cd,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>Cd(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:Zn}],Ox={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Tx=[Cx.map,_x.seq].concat(Ax,Ox);$x.schema=Tx});var Bo=I(function(Px){var Fr=We("buffer"),Jo=ae(),Nx=Er(),Dx={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Fr.Buffer==="function")return Fr.Buffer.from(e,"base64");else if(typeof atob==="function"){let r=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let s=0;s<r.length;++s)n[s]=r.charCodeAt(s);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:r},n,s,o){if(!r)return"";let i=r,a;if(typeof Fr.Buffer==="function")a=i instanceof Fr.Buffer?i.toString("base64"):Fr.Buffer.from(i.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<i.length;++l)c+=String.fromCharCode(i[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Jo.Scalar.BLOCK_LITERAL),t!==Jo.Scalar.QUOTE_DOUBLE){let c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let p=0,d=0;p<l;++p,d+=c)u[p]=a.substr(d,c);a=u.join(t===Jo.Scalar.BLOCK_LITERAL?`
78
+ `:" ")}return Nx.stringifyString({comment:e,type:t,value:a},n,s,o)}};Px.binary=Dx});var Wn=I(function(qx){var Vn=J(),Ho=ot(),Fx=ae(),Lx=ct();function Ad(e,t){if(Vn.isSeq(e))for(let r=0;r<e.items.length;++r){let n=e.items[r];if(Vn.isPair(n))continue;else if(Vn.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let s=n.items[0]||new Ho.Pair(new Fx.Scalar(null));if(n.commentBefore)s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
79
79
  ${s.key.commentBefore}`:n.commentBefore;if(n.comment){let o=s.value??s.key;o.comment=o.comment?`${n.comment}
80
- ${o.comment}`:n.comment}n=s}e.items[r]=Vn.isPair(n)?n:new Bo.Pair(n)}else t("Expected a sequence for this tag");return e}function Cd(e,t,r){let{replacer:n}=r,s=new $x.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,String(o++),i);let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=i[1];else throw TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let l=Object.keys(i);if(l.length===1)a=l[0],c=i[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=i;s.items.push(Bo.createPair(a,c,r))}return s}var Ex={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:xd,createNode:Cd};Nx.createPairs=Cd;Nx.pairs=Ex;Nx.resolvePairs=xd});var Yo=I(function(zx){var _d=J(),Ho=rt(),Lr=at(),Fx=ct(),Ad=Wn();class $t extends Fx.YAMLSeq{constructor(){super();this.add=Lr.YAMLMap.prototype.add.bind(this),this.delete=Lr.YAMLMap.prototype.delete.bind(this),this.get=Lr.YAMLMap.prototype.get.bind(this),this.has=Lr.YAMLMap.prototype.has.bind(this),this.set=Lr.YAMLMap.prototype.set.bind(this),this.tag=$t.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let n of this.items){let s,o;if(_d.isPair(n))s=Ho.toJS(n.key,"",t),o=Ho.toJS(n.value,s,t);else s=Ho.toJS(n,"",t);if(r.has(s))throw Error("Ordered maps must not include duplicate keys");r.set(s,o)}return r}static from(e,t,r){let n=Ad.createPairs(e,t,r),s=new this;return s.items=n.items,s}}$t.tag="tag:yaml.org,2002:omap";var Lx={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:$t,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=Ad.resolvePairs(e,t),n=[];for(let{key:s}of r.items)if(_d.isScalar(s))if(n.includes(s.value))t(`Ordered maps must not include duplicate keys: ${s.value}`);else n.push(s.value);return Object.assign(new $t,r)},createNode:(e,t,r)=>$t.from(e,t,r)};zx.YAMLOMap=$t;zx.omap=Lx});var Nd=I(function(Rx){var Od=ae();function Td({value:e,source:t},r){if(t&&(e?$d:Ed).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var $d={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Od.Scalar(!0),stringify:Td},Ed={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Od.Scalar(!1),stringify:Td};Rx.falseTag=Ed;Rx.trueTag=$d});var Dd=I(function(Gx){var jx=ae(),Qo=Yt(),Zx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Qo.stringifyNumber},Vx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Qo.stringifyNumber(e)}},Wx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new jx.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let n=e.substring(r+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Qo.stringifyNumber};Gx.float=Wx;Gx.floatExp=Vx;Gx.floatNaN=Zx});var Id=I(function(tC){var Pd=Yt(),zr=(e)=>typeof e==="bigint"||Number.isInteger(e);function Gn(e,t,r,{intAsBigInt:n}){let s=e[0];if(s==="-"||s==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let i=BigInt(e);return s==="-"?BigInt(-1)*i:i}let o=parseInt(e,r);return s==="-"?-1*o:o}function Xo(e,t,r){let{value:n}=e;if(zr(n)){let s=n.toString(t);return n<0?"-"+r+s.substr(1):r+s}return Pd.stringifyNumber(e)}var Yx={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Gn(e,2,2,r),stringify:(e)=>Xo(e,2,"0b")},Qx={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Gn(e,1,8,r),stringify:(e)=>Xo(e,8,"0")},Xx={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Gn(e,0,10,r),stringify:Pd.stringifyNumber},eC={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Gn(e,2,16,r),stringify:(e)=>Xo(e,16,"0x")};tC.int=Xx;tC.intBin=Yx;tC.intHex=eC;tC.intOct=Qx});var ei=I(function(aC){var Hn=J(),Jn=ot(),Bn=at();class Et extends Bn.YAMLMap{constructor(e){super(e);this.tag=Et.tag}add(e){let t;if(Hn.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Jn.Pair(e.key,null);else t=new Jn.Pair(e,null);if(!Bn.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Bn.findPair(this.items,e);return!t&&Hn.isPair(r)?Hn.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Bn.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Jn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,o,o);s.items.push(Jn.createPair(o,null,r))}return s}}Et.tag="tag:yaml.org,2002:set";var iC={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Et,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Et.from(e,t,r),resolve(e,t){if(Hn.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Et,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};aC.YAMLSet=Et;aC.set=iC});var ri=I(function(mC){var uC=Yt();function ti(e,t){let r=e[0],n=r==="-"||r==="+"?e.substring(1):e,s=(i)=>t?BigInt(i):Number(i),o=n.replace(/_/g,"").split(":").reduce((i,a)=>i*s(60)+s(a),s(0));return r==="-"?s(-1)*o:o}function Fd(e){let{value:t}=e,r=(i)=>i;if(typeof t==="bigint")r=(i)=>BigInt(i);else if(isNaN(t)||!isFinite(t))return uC.stringifyNumber(e);let n="";if(t<0)n="-",t*=r(-1);let s=r(60),o=[t%s];if(t<60)o.unshift(0);else if(t=(t-o[0])/s,o.unshift(t%s),t>=60)t=(t-o[0])/s,o.unshift(t);return n+o.map((i)=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var pC={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>ti(e,r),stringify:Fd},dC={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ti(e,!1),stringify:Fd},Ld={identify:(e)=>e 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(e){let t=e.match(Ld.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,i,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,n-1,s,o||0,i||0,a||0,c),p=t[8];if(p&&p!=="Z"){let u=ti(p,!1);if(Math.abs(u)<30)u*=60;l-=60000*u}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};mC.floatTime=dC;mC.intTime=pC;mC.timestamp=Ld});var qd=I(function(OC){var yC=Bt(),bC=Mn(),wC=Ht(),vC=Ir(),kC=Jo(),zd=Nd(),ni=Dd(),Yn=Id(),SC=In(),xC=Yo(),CC=Wn(),_C=ei(),si=ri(),AC=[yC.map,wC.seq,vC.string,bC.nullTag,zd.trueTag,zd.falseTag,Yn.intBin,Yn.intOct,Yn.int,Yn.intHex,ni.floatNaN,ni.floatExp,ni.float,kC.binary,SC.merge,xC.omap,CC.pairs,_C.set,si.intTime,si.floatTime,si.timestamp];OC.schema=AC});var Jd=I(function(LC){var Md=Bt(),$C=Mn(),jd=Ht(),EC=Ir(),NC=Ro(),oi=Mo(),ii=Zo(),DC=vd(),PC=Sd(),Zd=Jo(),qr=In(),Vd=Yo(),Wd=Wn(),Kd=qd(),Gd=ei(),Qn=ri(),Rd=new Map([["core",DC.schema],["failsafe",[Md.map,jd.seq,EC.string]],["json",PC.schema],["yaml11",Kd.schema],["yaml-1.1",Kd.schema]]),Ud={binary:Zd.binary,bool:NC.boolTag,float:oi.float,floatExp:oi.floatExp,floatNaN:oi.floatNaN,floatTime:Qn.floatTime,int:ii.int,intHex:ii.intHex,intOct:ii.intOct,intTime:Qn.intTime,map:Md.map,merge:qr.merge,null:$C.nullTag,omap:Vd.omap,pairs:Wd.pairs,seq:jd.seq,set:Gd.set,timestamp:Qn.timestamp},IC={"tag:yaml.org,2002:binary":Zd.binary,"tag:yaml.org,2002:merge":qr.merge,"tag:yaml.org,2002:omap":Vd.omap,"tag:yaml.org,2002:pairs":Wd.pairs,"tag:yaml.org,2002:set":Gd.set,"tag:yaml.org,2002:timestamp":Qn.timestamp};function FC(e,t,r){let n=Rd.get(t);if(n&&!e)return r&&!n.includes(qr.merge)?n.concat(qr.merge):n.slice();let s=n;if(!s)if(Array.isArray(e))s=[];else{let o=Array.from(Rd.keys()).filter((i)=>i!=="yaml11").map((i)=>JSON.stringify(i)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)s=s.concat(o);else if(typeof e==="function")s=e(s.slice());if(r)s=s.concat(qr.merge);return s.reduce((o,i)=>{let a=typeof i==="string"?Ud[i]:i;if(!a){let c=JSON.stringify(i),l=Object.keys(Ud).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}LC.coreKnownTags=IC;LC.getTags=FC});var li=I(function(jC){var ai=J(),KC=Bt(),RC=Ht(),UC=Ir(),Xn=Jd(),MC=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class ci{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:n,schema:s,sortMapEntries:o,toStringDefaults:i}){this.compat=Array.isArray(e)?Xn.getTags(e,"compat"):e?Xn.getTags(null,e):null,this.name=typeof s==="string"&&s||"core",this.knownTags=n?Xn.coreKnownTags:{},this.tags=Xn.getTags(t,this.name,r),this.toStringOptions=i??null,Object.defineProperty(this,ai.MAP,{value:KC.map}),Object.defineProperty(this,ai.SCALAR,{value:UC.string}),Object.defineProperty(this,ai.SEQ,{value:RC.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?MC:null}clone(){let e=Object.create(ci.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}jC.Schema=ci});var Bd=I(function(GC){var VC=J(),ui=Nr(),Kr=Tr();function WC(e,t){let r=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),n=!0;else if(e.directives.docStart)n=!0}if(n)r.push("---");let s=ui.createStringifyContext(e,t),{commentString:o}=s.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(Kr.indentComment(c,""))}let i=!1,a=null;if(e.contents){if(VC.isNode(e.contents)){if(e.contents.spaceBefore&&n)r.push("");if(e.contents.commentBefore){let p=o(e.contents.commentBefore);r.push(Kr.indentComment(p,""))}s.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>i=!0,l=ui.stringify(e.contents,s,()=>a=null,c);if(a)l+=Kr.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${l}`;else r.push(l)}else r.push(ui.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
80
+ ${o.comment}`:n.comment}n=s}e.items[r]=Vn.isPair(n)?n:new Ho.Pair(n)}else t("Expected a sequence for this tag");return e}function Od(e,t,r){let{replacer:n}=r,s=new Lx.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,String(o++),i);let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=i[1];else throw TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let l=Object.keys(i);if(l.length===1)a=l[0],c=i[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=i;s.items.push(Ho.createPair(a,c,r))}return s}var zx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ad,createNode:Od};qx.createPairs=Od;qx.pairs=zx;qx.resolvePairs=Ad});var Qo=I(function(Zx){var Td=J(),Yo=rt(),Lr=at(),Mx=ct(),$d=Wn();class $t extends Mx.YAMLSeq{constructor(){super();this.add=Lr.YAMLMap.prototype.add.bind(this),this.delete=Lr.YAMLMap.prototype.delete.bind(this),this.get=Lr.YAMLMap.prototype.get.bind(this),this.has=Lr.YAMLMap.prototype.has.bind(this),this.set=Lr.YAMLMap.prototype.set.bind(this),this.tag=$t.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;if(t?.onCreate)t.onCreate(r);for(let n of this.items){let s,o;if(Td.isPair(n))s=Yo.toJS(n.key,"",t),o=Yo.toJS(n.value,s,t);else s=Yo.toJS(n,"",t);if(r.has(s))throw Error("Ordered maps must not include duplicate keys");r.set(s,o)}return r}static from(e,t,r){let n=$d.createPairs(e,t,r),s=new this;return s.items=n.items,s}}$t.tag="tag:yaml.org,2002:omap";var jx={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:$t,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=$d.resolvePairs(e,t),n=[];for(let{key:s}of r.items)if(Td.isScalar(s))if(n.includes(s.value))t(`Ordered maps must not include duplicate keys: ${s.value}`);else n.push(s.value);return Object.assign(new $t,r)},createNode:(e,t,r)=>$t.from(e,t,r)};Zx.YAMLOMap=$t;Zx.omap=jx});var Id=I(function(Gx){var Ed=ae();function Nd({value:e,source:t},r){if(t&&(e?Dd:Pd).test.test(t))return t;return e?r.options.trueStr:r.options.falseStr}var Dd={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ed.Scalar(!0),stringify:Nd},Pd={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ed.Scalar(!1),stringify:Nd};Gx.falseTag=Pd;Gx.trueTag=Dd});var Fd=I(function(eC){var Hx=ae(),Xo=Xt(),Yx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Xo.stringifyNumber},Qx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Xo.stringifyNumber(e)}},Xx={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Hx.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(r!==-1){let n=e.substring(r+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Xo.stringifyNumber};eC.float=Xx;eC.floatExp=Qx;eC.floatNaN=Yx});var zd=I(function(cC){var Ld=Xt(),zr=(e)=>typeof e==="bigint"||Number.isInteger(e);function Gn(e,t,r,{intAsBigInt:n}){let s=e[0];if(s==="-"||s==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let i=BigInt(e);return s==="-"?BigInt(-1)*i:i}let o=parseInt(e,r);return s==="-"?-1*o:o}function ei(e,t,r){let{value:n}=e;if(zr(n)){let s=n.toString(t);return n<0?"-"+r+s.substr(1):r+s}return Ld.stringifyNumber(e)}var sC={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>Gn(e,2,2,r),stringify:(e)=>ei(e,2,"0b")},oC={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>Gn(e,1,8,r),stringify:(e)=>ei(e,8,"0")},iC={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>Gn(e,0,10,r),stringify:Ld.stringifyNumber},aC={identify:zr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>Gn(e,2,16,r),stringify:(e)=>ei(e,16,"0x")};cC.int=iC;cC.intBin=sC;cC.intHex=aC;cC.intOct=oC});var ti=I(function(fC){var Hn=J(),Jn=ot(),Bn=at();class Et extends Bn.YAMLMap{constructor(e){super(e);this.tag=Et.tag}add(e){let t;if(Hn.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Jn.Pair(e.key,null);else t=new Jn.Pair(e,null);if(!Bn.findPair(this.items,t.key))this.items.push(t)}get(e,t){let r=Bn.findPair(this.items,e);return!t&&Hn.isPair(r)?Hn.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=Bn.findPair(this.items,e);if(r&&!t)this.items.splice(this.items.indexOf(r),1);else if(!r&&t)this.items.push(new Jn.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);else throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,o,o);s.items.push(Jn.createPair(o,null,r))}return s}}Et.tag="tag:yaml.org,2002:set";var mC={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Et,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>Et.from(e,t,r),resolve(e,t){if(Hn.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Et,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};fC.YAMLSet=Et;fC.set=mC});var ni=I(function(vC){var yC=Xt();function ri(e,t){let r=e[0],n=r==="-"||r==="+"?e.substring(1):e,s=(i)=>t?BigInt(i):Number(i),o=n.replace(/_/g,"").split(":").reduce((i,a)=>i*s(60)+s(a),s(0));return r==="-"?s(-1)*o:o}function qd(e){let{value:t}=e,r=(i)=>i;if(typeof t==="bigint")r=(i)=>BigInt(i);else if(isNaN(t)||!isFinite(t))return yC.stringifyNumber(e);let n="";if(t<0)n="-",t*=r(-1);let s=r(60),o=[t%s];if(t<60)o.unshift(0);else if(t=(t-o[0])/s,o.unshift(t%s),t>=60)t=(t-o[0])/s,o.unshift(t);return n+o.map((i)=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var bC={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>ri(e,r),stringify:qd},wC={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ri(e,!1),stringify:qd},Kd={identify:(e)=>e 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(e){let t=e.match(Kd.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,i,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(r,n-1,s,o||0,i||0,a||0,c),u=t[8];if(u&&u!=="Z"){let p=ri(u,!1);if(Math.abs(p)<30)p*=60;l-=60000*p}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};vC.floatTime=wC;vC.intTime=bC;vC.timestamp=Kd});var Ud=I(function(IC){var CC=Yt(),_C=Mn(),AC=Qt(),OC=Ir(),TC=Bo(),Rd=Id(),si=Fd(),Yn=zd(),$C=In(),EC=Qo(),NC=Wn(),DC=ti(),oi=ni(),PC=[CC.map,AC.seq,OC.string,_C.nullTag,Rd.trueTag,Rd.falseTag,Yn.intBin,Yn.intOct,Yn.int,Yn.intHex,si.floatNaN,si.floatExp,si.float,TC.binary,$C.merge,EC.omap,NC.pairs,DC.set,oi.intTime,oi.floatTime,oi.timestamp];IC.schema=PC});var Yd=I(function(jC){var Vd=Yt(),LC=Mn(),Wd=Qt(),zC=Ir(),qC=Uo(),ii=jo(),ai=Vo(),KC=xd(),RC=_d(),Gd=Bo(),qr=In(),Jd=Qo(),Bd=Wn(),Md=Ud(),Hd=ti(),Qn=ni(),jd=new Map([["core",KC.schema],["failsafe",[Vd.map,Wd.seq,zC.string]],["json",RC.schema],["yaml11",Md.schema],["yaml-1.1",Md.schema]]),Zd={binary:Gd.binary,bool:qC.boolTag,float:ii.float,floatExp:ii.floatExp,floatNaN:ii.floatNaN,floatTime:Qn.floatTime,int:ai.int,intHex:ai.intHex,intOct:ai.intOct,intTime:Qn.intTime,map:Vd.map,merge:qr.merge,null:LC.nullTag,omap:Jd.omap,pairs:Bd.pairs,seq:Wd.seq,set:Hd.set,timestamp:Qn.timestamp},UC={"tag:yaml.org,2002:binary":Gd.binary,"tag:yaml.org,2002:merge":qr.merge,"tag:yaml.org,2002:omap":Jd.omap,"tag:yaml.org,2002:pairs":Bd.pairs,"tag:yaml.org,2002:set":Hd.set,"tag:yaml.org,2002:timestamp":Qn.timestamp};function MC(e,t,r){let n=jd.get(t);if(n&&!e)return r&&!n.includes(qr.merge)?n.concat(qr.merge):n.slice();let s=n;if(!s)if(Array.isArray(e))s=[];else{let o=Array.from(jd.keys()).filter((i)=>i!=="yaml11").map((i)=>JSON.stringify(i)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)s=s.concat(o);else if(typeof e==="function")s=e(s.slice());if(r)s=s.concat(qr.merge);return s.reduce((o,i)=>{let a=typeof i==="string"?Zd[i]:i;if(!a){let c=JSON.stringify(i),l=Object.keys(Zd).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}jC.coreKnownTags=UC;jC.getTags=MC});var ui=I(function(HC){var ci=J(),WC=Yt(),GC=Qt(),JC=Ir(),Xn=Yd(),BC=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class li{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:n,schema:s,sortMapEntries:o,toStringDefaults:i}){this.compat=Array.isArray(e)?Xn.getTags(e,"compat"):e?Xn.getTags(null,e):null,this.name=typeof s==="string"&&s||"core",this.knownTags=n?Xn.coreKnownTags:{},this.tags=Xn.getTags(t,this.name,r),this.toStringOptions=i??null,Object.defineProperty(this,ci.MAP,{value:WC.map}),Object.defineProperty(this,ci.SCALAR,{value:JC.string}),Object.defineProperty(this,ci.SEQ,{value:GC.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?BC:null}clone(){let e=Object.create(li.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}HC.Schema=li});var Qd=I(function(e_){var QC=J(),pi=Nr(),Kr=Tr();function XC(e,t){let r=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)r.push(c),n=!0;else if(e.directives.docStart)n=!0}if(n)r.push("---");let s=pi.createStringifyContext(e,t),{commentString:o}=s.options;if(e.commentBefore){if(r.length!==1)r.unshift("");let c=o(e.commentBefore);r.unshift(Kr.indentComment(c,""))}let i=!1,a=null;if(e.contents){if(QC.isNode(e.contents)){if(e.contents.spaceBefore&&n)r.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);r.push(Kr.indentComment(u,""))}s.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>i=!0,l=pi.stringify(e.contents,s,()=>a=null,c);if(a)l+=Kr.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&r[r.length-1]==="---")r[r.length-1]=`--- ${l}`;else r.push(l)}else r.push(pi.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
81
81
  `))r.push("..."),r.push(Kr.indentComment(c,""));else r.push(`... ${c}`)}else r.push("...");else{let c=e.comment;if(c&&i)c=c.replace(/^\n+/,"");if(c){if((!i||a)&&r[r.length-1]!=="")r.push("");r.push(Kr.indentComment(o(c),""))}}return r.join(`
82
82
  `)+`
83
- `}GC.stringifyDocument=WC});var Rr=I(function(r_){var BC=Ar(),Qt=On(),Ee=J(),HC=ot(),YC=rt(),QC=li(),XC=Bd(),pi=Cn(),e_=Eo(),t_=Or(),di=$o();class mi{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ee.NODE_TYPE,{value:Ee.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t,t=void 0;let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=s;let{version:o}=s;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new di.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(mi.prototype,{[Ee.NODE_TYPE]:{value:Ee.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Ee.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Xt(this.contents))this.contents.add(e)}addIn(e,t){if(Xt(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=pi.anchorNames(this);e.anchor=!t||r.has(t)?pi.findNewAnchor(t||"a",r):t}return new BC.Alias(e.anchor)}createNode(e,t,r){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let g=(T)=>typeof T==="number"||T instanceof String||T instanceof Number,w=t.filter(g).map(String);if(w.length>0)t=t.concat(w);n=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:s,anchorPrefix:o,flow:i,keepUndefined:a,onTagObj:c,tag:l}=r??{},{onAnchor:p,setAnchors:u,sourceObjects:d}=pi.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:d},b=t_.createNode(e,l,h);if(i&&Ee.isCollection(b))b.flow=!0;return u(),b}createPair(e,t,r={}){let n=this.createNode(e,null,r),s=this.createNode(t,null,r);return new HC.Pair(n,s)}delete(e){return Xt(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(Qt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Xt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Ee.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(Qt.isEmptyPath(e))return!t&&Ee.isScalar(this.contents)?this.contents.value:this.contents;return Ee.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Ee.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(Qt.isEmptyPath(e))return this.contents!==void 0;return Ee.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,[e],t);else if(Xt(this.contents))this.contents.set(e,t)}setIn(e,t){if(Qt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,Array.from(e),t);else if(Xt(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let r;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new di.Directives({version:"1.1"});r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new di.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let n=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new QC.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:o}={}){let i={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},a=YC.toJS(this.contents,t??"",i);if(typeof s==="function")for(let{count:c,res:l}of i.anchors.values())s(l,c);return typeof o==="function"?e_.applyReviver(o,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return XC.stringifyDocument(this,e)}}function Xt(e){if(Ee.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}r_.Document=mi});var Ur=I(function(o_){class es extends Error{constructor(e,t,r,n){super();this.name=e,this.code=r,this.message=n,this.pos=t}}class Hd extends es{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class Yd extends es{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var s_=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:n,col:s}=r.linePos[0];r.message+=` at line ${n}, column ${s}`;let o=s-1,i=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="…"+i.substring(a),o-=a-1}if(i.length>80)i=i.substring(0,79)+"…";if(n>1&&/^ *$/.test(i.substring(0,o))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(a.length>80)a=a.substring(0,79)+`…
83
+ `}e_.stringifyDocument=XC});var Rr=I(function(l_){var r_=Ar(),er=On(),Ee=J(),n_=ot(),s_=rt(),o_=ui(),i_=Qd(),di=Cn(),a_=No(),c_=Or(),mi=Eo();class fi{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ee.NODE_TYPE,{value:Ee.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t,t=void 0;let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=s;let{version:o}=s;if(r?._directives){if(this.directives=r._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new mi.Directives({version:o});this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,n,r)}clone(){let e=Object.create(fi.prototype,{[Ee.NODE_TYPE]:{value:Ee.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Ee.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(tr(this.contents))this.contents.add(e)}addIn(e,t){if(tr(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=di.anchorNames(this);e.anchor=!t||r.has(t)?di.findNewAnchor(t||"a",r):t}return new r_.Alias(e.anchor)}createNode(e,t,r){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let y=(T)=>typeof T==="number"||T instanceof String||T instanceof Number,w=t.filter(y).map(String);if(w.length>0)t=t.concat(w);n=t}else if(r===void 0&&t)r=t,t=void 0;let{aliasDuplicateObjects:s,anchorPrefix:o,flow:i,keepUndefined:a,onTagObj:c,tag:l}=r??{},{onAnchor:u,setAnchors:p,sourceObjects:d}=di.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:d},b=c_.createNode(e,l,g);if(i&&Ee.isCollection(b))b.flow=!0;return p(),b}createPair(e,t,r={}){let n=this.createNode(e,null,r),s=this.createNode(t,null,r);return new n_.Pair(n,s)}delete(e){return tr(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(er.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return tr(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Ee.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(er.isEmptyPath(e))return!t&&Ee.isScalar(this.contents)?this.contents.value:this.contents;return Ee.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Ee.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(er.isEmptyPath(e))return this.contents!==void 0;return Ee.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=er.collectionFromPath(this.schema,[e],t);else if(tr(this.contents))this.contents.set(e,t)}setIn(e,t){if(er.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=er.collectionFromPath(this.schema,Array.from(e),t);else if(tr(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let r;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new mi.Directives({version:"1.1"});r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new mi.Directives({version:e});r={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;r=null;break;default:{let n=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new o_.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:o}={}){let i={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},a=s_.toJS(this.contents,t??"",i);if(typeof s==="function")for(let{count:c,res:l}of i.anchors.values())s(l,c);return typeof o==="function"?a_.applyReviver(o,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return i_.stringifyDocument(this,e)}}function tr(e){if(Ee.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}l_.Document=fi});var Ur=I(function(d_){class es extends Error{constructor(e,t,r,n){super();this.name=e,this.code=r,this.message=n,this.pos=t}}class Xd extends es{constructor(e,t,r){super("YAMLParseError",e,t,r)}}class em extends es{constructor(e,t,r){super("YAMLWarning",e,t,r)}}var p_=(e,t)=>(r)=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map((a)=>t.linePos(a));let{line:n,col:s}=r.linePos[0];r.message+=` at line ${n}, column ${s}`;let o=s-1,i=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="…"+i.substring(a),o-=a-1}if(i.length>80)i=i.substring(0,79)+"…";if(n>1&&/^ *$/.test(i.substring(0,o))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(a.length>80)a=a.substring(0,79)+`…
84
84
  `;i=a+i}if(/[^ ]/.test(i)){let a=1,c=r.linePos[1];if(c?.line===n&&c.col>s)a=Math.max(1,Math.min(c.col-s,80-o));let l=" ".repeat(o)+"^".repeat(a);r.message+=`:
85
85
 
86
86
  ${i}
87
87
  ${l}
88
- `}};o_.YAMLError=es;o_.YAMLParseError=Hd;o_.YAMLWarning=Yd;o_.prettifyError=s_});var Mr=I(function(p_){function u_(e,{flow:t,indicator:r,next:n,offset:s,onError:o,parentIndent:i,startOnNewline:a}){let c=!1,l=a,p=a,u="",d="",h=!1,b=!1,g=null,w=null,T=null,N=null,x=null,D=null,P=null;for(let E of e){if(b){if(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma")o(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(g){if(l&&E.type!=="comment"&&E.type!=="newline")o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");g=null}switch(E.type){case"space":if(!t&&(r!=="doc-start"||n?.type!=="flow-collection")&&E.source.includes("\t"))g=E;p=!0;break;case"comment":{if(!p)o(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=E.source.substring(1)||" ";if(!u)u=O;else u+=d+O;d="",l=!1;break}case"newline":if(l){if(u)u+=E.source;else if(!D||r!=="seq-item-ind")c=!0}else d+=E.source;if(l=!0,h=!0,w||T)N=E;p=!0;break;case"anchor":if(w)o(E,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(E.source.endsWith(":"))o(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);w=E,P??(P=E.offset),l=!1,p=!1,b=!0;break;case"tag":{if(T)o(E,"MULTIPLE_TAGS","A node can have at most one tag");T=E,P??(P=E.offset),l=!1,p=!1,b=!0;break}case r:if(w||T)o(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`);if(D)o(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`);D=E,l=r==="seq-item-ind"||r==="explicit-key-ind",p=!1;break;case"comma":if(t){if(x)o(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=E,l=!1,p=!1;break}default:o(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),l=!1,p=!1}}let L=e[e.length-1],K=L?L.offset+L.source.length:s;if(b&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(g&&(l&&g.indent<=i||n?.type==="block-map"||n?.type==="block-seq"))o(g,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:x,found:D,spaceBefore:c,comment:u,hasNewline:h,anchor:w,tag:T,newlineAfterProp:N,end:K,start:P??K}}p_.resolveProps=u_});var ts=I(function(m_){function fi(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
89
- `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(fi(t.key)||fi(t.value))return!0}return!1;default:return!0}}m_.containsNewline=fi});var hi=I(function(y_){var h_=ts();function g_(e,t,r){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&h_.containsNewline(t))r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}y_.flowIndentCheck=g_});var gi=I(function(v_){var Qd=J();function w_(e,t,r){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let s=typeof n==="function"?n:(o,i)=>o===i||Qd.isScalar(o)&&Qd.isScalar(i)&&o.value===i.value;return t.some((o)=>s(o.key,r))}v_.mapIncludes=w_});var nm=I(function(A_){var Xd=ot(),S_=at(),em=Mr(),x_=ts(),tm=hi(),C_=gi(),rm="All mapping items must start at the same column";function __({composeNode:e,composeEmptyNode:t},r,n,s,o){let a=new(o?.nodeClass??S_.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=n.offset,l=null;for(let p of n.items){let{start:u,key:d,sep:h,value:b}=p,g=em.resolveProps(u,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0}),w=!g.found;if(w){if(d){if(d.type==="block-seq")s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==n.indent)s(c,"BAD_INDENT",rm)}if(!g.anchor&&!g.tag&&!h){if(l=g.end,g.comment)if(a.comment)a.comment+=`
90
- `+g.comment;else a.comment=g.comment;continue}if(g.newlineAfterProp||x_.containsNewline(d))s(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(g.found?.indent!==n.indent)s(c,"BAD_INDENT",rm);r.atKey=!0;let T=g.end,N=d?e(r,d,g,s):t(r,T,u,null,g,s);if(r.schema.compat)tm.flowIndentCheck(n.indent,d,s);if(r.atKey=!1,C_.mapIncludes(r,a.items,N))s(T,"DUPLICATE_KEY","Map keys must be unique");let x=em.resolveProps(h??[],{indicator:"map-value-ind",next:b,offset:N.range[2],onError:s,parentIndent:n.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=x.end,x.found){if(w){if(b?.type==="block-map"&&!x.hasNewline)s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&g.start<x.found.offset-1024)s(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let D=b?e(r,b,x,s):t(r,c,h,null,x,s);if(r.schema.compat)tm.flowIndentCheck(n.indent,b,s);c=D.range[2];let P=new Xd.Pair(N,D);if(r.options.keepSourceTokens)P.srcToken=p;a.items.push(P)}else{if(w)s(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(x.comment)if(N.comment)N.comment+=`
91
- `+x.comment;else N.comment=x.comment;let D=new Xd.Pair(N);if(r.options.keepSourceTokens)D.srcToken=p;a.items.push(D)}}if(l&&l<c)s(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,c,l??c],a}A_.resolveBlockMap=__});var sm=I(function(D_){var T_=ct(),$_=Mr(),E_=hi();function N_({composeNode:e,composeEmptyNode:t},r,n,s,o){let a=new(o?.nodeClass??T_.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=n.offset,l=null;for(let{start:p,value:u}of n.items){let d=$_.resolveProps(p,{indicator:"seq-item-ind",next:u,offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)if(u?.type==="block-seq")s(d.end,"BAD_INDENT","All sequence items must start at the same column");else s(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=d.end,d.comment)a.comment=d.comment;continue}let h=u?e(r,u,d,s):t(r,d.end,p,null,d,s);if(r.schema.compat)E_.flowIndentCheck(n.indent,u,s);c=h.range[2],a.items.push(h)}return a.range=[n.offset,c,l??c],a}D_.resolveBlockSeq=N_});var er=I(function(F_){function I_(e,t,r,n){let s="";if(e){let o=!1,i="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(r&&!o)n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=c.substring(1)||" ";if(!s)s=p;else s+=i+p;i="";break}case"newline":if(s)i+=c;o=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:s,offset:t}}F_.resolveEnd=I_});var am=I(function(Z_){var z_=J(),q_=ot(),om=at(),K_=ct(),R_=er(),im=Mr(),U_=ts(),M_=gi(),yi="Block collections are not allowed within flow collections",bi=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function j_({composeNode:e,composeEmptyNode:t},r,n,s,o){let i=n.start.source==="{",a=i?"flow map":"flow sequence",l=new(o?.nodeClass??(i?om.YAMLMap:K_.YAMLSeq))(r.schema);l.flow=!0;let p=r.atRoot;if(p)r.atRoot=!1;if(r.atKey)r.atKey=!1;let u=n.offset+n.start.source.length;for(let w=0;w<n.items.length;++w){let T=n.items[w],{start:N,key:x,sep:D,value:P}=T,L=im.resolveProps(N,{flow:a,indicator:"explicit-key-ind",next:x??D?.[0],offset:u,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!L.found){if(!L.anchor&&!L.tag&&!D&&!P){if(w===0&&L.comma)s(L.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(w<n.items.length-1)s(L.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(L.comment)if(l.comment)l.comment+=`
92
- `+L.comment;else l.comment=L.comment;u=L.end;continue}if(!i&&r.options.strict&&U_.containsNewline(x))s(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(w===0){if(L.comma)s(L.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!L.comma)s(L.start,"MISSING_CHAR",`Missing , between ${a} items`);if(L.comment){let K="";e:for(let E of N)switch(E.type){case"comma":case"space":break;case"comment":K=E.source.substring(1);break e;default:break e}if(K){let E=l.items[l.items.length-1];if(z_.isPair(E))E=E.value??E.key;if(E.comment)E.comment+=`
93
- `+K;else E.comment=K;L.comment=L.comment.substring(K.length+1)}}}if(!i&&!D&&!L.found){let K=P?e(r,P,L,s):t(r,L.end,D,null,L,s);if(l.items.push(K),u=K.range[2],bi(P))s(K.range,"BLOCK_IN_FLOW",yi)}else{r.atKey=!0;let K=L.end,E=x?e(r,x,L,s):t(r,K,N,null,L,s);if(bi(x))s(E.range,"BLOCK_IN_FLOW",yi);r.atKey=!1;let O=im.resolveProps(D??[],{flow:a,indicator:"map-value-ind",next:P,offset:E.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(O.found){if(!i&&!L.found&&r.options.strict){if(D)for(let A of D){if(A===O.found)break;if(A.type==="newline"){s(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(L.start<O.found.offset-1024)s(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(P)if("source"in P&&P.source?.[0]===":")s(P,"MISSING_CHAR",`Missing space after : in ${a}`);else s(O.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let C=P?e(r,P,O,s):O.found?t(r,O.end,D,null,O,s):null;if(C){if(bi(P))s(C.range,"BLOCK_IN_FLOW",yi)}else if(O.comment)if(E.comment)E.comment+=`
94
- `+O.comment;else E.comment=O.comment;let v=new q_.Pair(E,C);if(r.options.keepSourceTokens)v.srcToken=T;if(i){let A=l;if(M_.mapIncludes(r,A.items,E))s(K,"DUPLICATE_KEY","Map keys must be unique");A.items.push(v)}else{let A=new om.YAMLMap(r.schema);A.flow=!0,A.items.push(v);let U=(C??E).range;A.range=[E.range[0],U[1],U[2]],l.items.push(A)}u=C?C.range[2]:O.end}}let d=i?"}":"]",[h,...b]=n.end,g=u;if(h?.source===d)g=h.offset+h.source.length;else{let w=a[0].toUpperCase()+a.substring(1),T=p?`${w} must end with a ${d}`:`${w} in block collection must be sufficiently indented and end with a ${d}`;if(s(u,p?"MISSING_CHAR":"BAD_INDENT",T),h&&h.source.length!==1)b.unshift(h)}if(b.length>0){let w=R_.resolveEnd(b,g,r.options.strict,s);if(w.comment)if(l.comment)l.comment+=`
95
- `+w.comment;else l.comment=w.comment;l.range=[n.offset,g,w.offset]}else l.range=[n.offset,g,g];return l}Z_.resolveFlowCollection=j_});var cm=I(function(eA){var W_=J(),G_=ae(),J_=at(),B_=ct(),H_=nm(),Y_=sm(),Q_=am();function wi(e,t,r,n,s,o){let i=r.type==="block-map"?H_.resolveBlockMap(e,t,r,n,o):r.type==="block-seq"?Y_.resolveBlockSeq(e,t,r,n,o):Q_.resolveFlowCollection(e,t,r,n,o),a=i.constructor;if(s==="!"||s===a.tagName)return i.tag=a.tagName,i;if(s)i.tag=s;return i}function X_(e,t,r,n,s){let o=n.tag,i=!o?null:t.directives.tagName(o.source,(d)=>s(o,"TAG_RESOLVE_FAILED",d));if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=n,b=d&&o?d.offset>o.offset?d:o:d??o;if(b&&(!h||h.offset<b.offset))s(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===J_.YAMLMap.tagName&&a==="map"||i===B_.YAMLSeq.tagName&&a==="seq")return wi(e,t,r,s,i);let c=t.schema.tags.find((d)=>d.tag===i&&d.collection===a);if(!c){let d=t.schema.knownTags[i];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else{if(d)s(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else s(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0);return wi(e,t,r,s,i)}}let l=wi(e,t,r,s,i,c),p=c.resolve?.(l,(d)=>s(o,"TAG_RESOLVE_FAILED",d),t.options)??l,u=W_.isNode(p)?p:new G_.Scalar(p);if(u.range=l.range,u.tag=i,c?.format)u.format=c.format;return u}eA.composeCollection=X_});var ki=I(function(oA){var vi=ae();function rA(e,t,r){let n=t.offset,s=nA(t,e.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let o=s.mode===">"?vi.Scalar.BLOCK_FOLDED:vi.Scalar.BLOCK_LITERAL,i=t.source?sA(t.source):[],a=i.length;for(let g=i.length-1;g>=0;--g){let w=i[g][1];if(w===""||w==="\r")a=g;else break}if(a===0){let g=s.chomp==="+"&&i.length>0?`
96
- `.repeat(Math.max(1,i.length-1)):"",w=n+s.length;if(t.source)w+=t.source.length;return{value:g,type:o,comment:s.comment,range:[n,w,w]}}let c=t.indent+s.indent,l=t.offset+s.length,p=0;for(let g=0;g<a;++g){let[w,T]=i[g];if(T===""||T==="\r"){if(s.indent===0&&w.length>c)c=w.length}else{if(w.length<c)r(l+w.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(s.indent===0)c=w.length;if(p=g,c===0&&!e.atRoot)r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=w.length+T.length+1}for(let g=i.length-1;g>=a;--g)if(i[g][0].length>c)a=g+1;let u="",d="",h=!1;for(let g=0;g<p;++g)u+=i[g][0].slice(c)+`
97
- `;for(let g=p;g<a;++g){let[w,T]=i[g];l+=w.length+T.length+1;let N=T[T.length-1]==="\r";if(N)T=T.slice(0,-1);if(T&&w.length<c){let D=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(l-T.length-(N?2:1),"BAD_INDENT",D),w=""}if(o===vi.Scalar.BLOCK_LITERAL)u+=d+w.slice(c)+T,d=`
88
+ `}};d_.YAMLError=es;d_.YAMLParseError=Xd;d_.YAMLWarning=em;d_.prettifyError=p_});var Mr=I(function(b_){function y_(e,{flow:t,indicator:r,next:n,offset:s,onError:o,parentIndent:i,startOnNewline:a}){let c=!1,l=a,u=a,p="",d="",g=!1,b=!1,y=null,w=null,T=null,N=null,x=null,D=null,P=null;for(let E of e){if(b){if(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma")o(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(y){if(l&&E.type!=="comment"&&E.type!=="newline")o(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");y=null}switch(E.type){case"space":if(!t&&(r!=="doc-start"||n?.type!=="flow-collection")&&E.source.includes("\t"))y=E;u=!0;break;case"comment":{if(!u)o(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=E.source.substring(1)||" ";if(!p)p=O;else p+=d+O;d="",l=!1;break}case"newline":if(l){if(p)p+=E.source;else if(!D||r!=="seq-item-ind")c=!0}else d+=E.source;if(l=!0,g=!0,w||T)N=E;u=!0;break;case"anchor":if(w)o(E,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(E.source.endsWith(":"))o(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);w=E,P??(P=E.offset),l=!1,u=!1,b=!0;break;case"tag":{if(T)o(E,"MULTIPLE_TAGS","A node can have at most one tag");T=E,P??(P=E.offset),l=!1,u=!1,b=!0;break}case r:if(w||T)o(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`);if(D)o(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`);D=E,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(t){if(x)o(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=E,l=!1,u=!1;break}default:o(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),l=!1,u=!1}}let L=e[e.length-1],K=L?L.offset+L.source.length:s;if(b&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(y&&(l&&y.indent<=i||n?.type==="block-map"||n?.type==="block-seq"))o(y,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:x,found:D,spaceBefore:c,comment:p,hasNewline:g,anchor:w,tag:T,newlineAfterProp:N,end:K,start:P??K}}b_.resolveProps=y_});var ts=I(function(v_){function hi(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
89
+ `))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let r of t.start)if(r.type==="newline")return!0;if(t.sep){for(let r of t.sep)if(r.type==="newline")return!0}if(hi(t.key)||hi(t.value))return!0}return!1;default:return!0}}v_.containsNewline=hi});var gi=I(function(C_){var S_=ts();function x_(e,t,r){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&S_.containsNewline(t))r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}C_.flowIndentCheck=x_});var yi=I(function(O_){var tm=J();function A_(e,t,r){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let s=typeof n==="function"?n:(o,i)=>o===i||tm.isScalar(o)&&tm.isScalar(i)&&o.value===i.value;return t.some((o)=>s(o.key,r))}O_.mapIncludes=A_});var im=I(function(P_){var rm=ot(),$_=at(),nm=Mr(),E_=ts(),sm=gi(),N_=yi(),om="All mapping items must start at the same column";function D_({composeNode:e,composeEmptyNode:t},r,n,s,o){let a=new(o?.nodeClass??$_.YAMLMap)(r.schema);if(r.atRoot)r.atRoot=!1;let c=n.offset,l=null;for(let u of n.items){let{start:p,key:d,sep:g,value:b}=u,y=nm.resolveProps(p,{indicator:"explicit-key-ind",next:d??g?.[0],offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0}),w=!y.found;if(w){if(d){if(d.type==="block-seq")s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==n.indent)s(c,"BAD_INDENT",om)}if(!y.anchor&&!y.tag&&!g){if(l=y.end,y.comment)if(a.comment)a.comment+=`
90
+ `+y.comment;else a.comment=y.comment;continue}if(y.newlineAfterProp||E_.containsNewline(d))s(d??p[p.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(y.found?.indent!==n.indent)s(c,"BAD_INDENT",om);r.atKey=!0;let T=y.end,N=d?e(r,d,y,s):t(r,T,p,null,y,s);if(r.schema.compat)sm.flowIndentCheck(n.indent,d,s);if(r.atKey=!1,N_.mapIncludes(r,a.items,N))s(T,"DUPLICATE_KEY","Map keys must be unique");let x=nm.resolveProps(g??[],{indicator:"map-value-ind",next:b,offset:N.range[2],onError:s,parentIndent:n.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=x.end,x.found){if(w){if(b?.type==="block-map"&&!x.hasNewline)s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(r.options.strict&&y.start<x.found.offset-1024)s(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let D=b?e(r,b,x,s):t(r,c,g,null,x,s);if(r.schema.compat)sm.flowIndentCheck(n.indent,b,s);c=D.range[2];let P=new rm.Pair(N,D);if(r.options.keepSourceTokens)P.srcToken=u;a.items.push(P)}else{if(w)s(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(x.comment)if(N.comment)N.comment+=`
91
+ `+x.comment;else N.comment=x.comment;let D=new rm.Pair(N);if(r.options.keepSourceTokens)D.srcToken=u;a.items.push(D)}}if(l&&l<c)s(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,c,l??c],a}P_.resolveBlockMap=D_});var am=I(function(K_){var F_=ct(),L_=Mr(),z_=gi();function q_({composeNode:e,composeEmptyNode:t},r,n,s,o){let a=new(o?.nodeClass??F_.YAMLSeq)(r.schema);if(r.atRoot)r.atRoot=!1;if(r.atKey)r.atKey=!1;let c=n.offset,l=null;for(let{start:u,value:p}of n.items){let d=L_.resolveProps(u,{indicator:"seq-item-ind",next:p,offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||p)if(p?.type==="block-seq")s(d.end,"BAD_INDENT","All sequence items must start at the same column");else s(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=d.end,d.comment)a.comment=d.comment;continue}let g=p?e(r,p,d,s):t(r,d.end,u,null,d,s);if(r.schema.compat)z_.flowIndentCheck(n.indent,p,s);c=g.range[2],a.items.push(g)}return a.range=[n.offset,c,l??c],a}K_.resolveBlockSeq=q_});var rr=I(function(M_){function U_(e,t,r,n){let s="";if(e){let o=!1,i="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(r&&!o)n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!s)s=u;else s+=i+u;i="";break}case"newline":if(s)i+=c;o=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:s,offset:t}}M_.resolveEnd=U_});var um=I(function(Y_){var Z_=J(),V_=ot(),cm=at(),W_=ct(),G_=rr(),lm=Mr(),J_=ts(),B_=yi(),bi="Block collections are not allowed within flow collections",wi=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function H_({composeNode:e,composeEmptyNode:t},r,n,s,o){let i=n.start.source==="{",a=i?"flow map":"flow sequence",l=new(o?.nodeClass??(i?cm.YAMLMap:W_.YAMLSeq))(r.schema);l.flow=!0;let u=r.atRoot;if(u)r.atRoot=!1;if(r.atKey)r.atKey=!1;let p=n.offset+n.start.source.length;for(let w=0;w<n.items.length;++w){let T=n.items[w],{start:N,key:x,sep:D,value:P}=T,L=lm.resolveProps(N,{flow:a,indicator:"explicit-key-ind",next:x??D?.[0],offset:p,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!L.found){if(!L.anchor&&!L.tag&&!D&&!P){if(w===0&&L.comma)s(L.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(w<n.items.length-1)s(L.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(L.comment)if(l.comment)l.comment+=`
92
+ `+L.comment;else l.comment=L.comment;p=L.end;continue}if(!i&&r.options.strict&&J_.containsNewline(x))s(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(w===0){if(L.comma)s(L.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!L.comma)s(L.start,"MISSING_CHAR",`Missing , between ${a} items`);if(L.comment){let K="";e:for(let E of N)switch(E.type){case"comma":case"space":break;case"comment":K=E.source.substring(1);break e;default:break e}if(K){let E=l.items[l.items.length-1];if(Z_.isPair(E))E=E.value??E.key;if(E.comment)E.comment+=`
93
+ `+K;else E.comment=K;L.comment=L.comment.substring(K.length+1)}}}if(!i&&!D&&!L.found){let K=P?e(r,P,L,s):t(r,L.end,D,null,L,s);if(l.items.push(K),p=K.range[2],wi(P))s(K.range,"BLOCK_IN_FLOW",bi)}else{r.atKey=!0;let K=L.end,E=x?e(r,x,L,s):t(r,K,N,null,L,s);if(wi(x))s(E.range,"BLOCK_IN_FLOW",bi);r.atKey=!1;let O=lm.resolveProps(D??[],{flow:a,indicator:"map-value-ind",next:P,offset:E.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(O.found){if(!i&&!L.found&&r.options.strict){if(D)for(let A of D){if(A===O.found)break;if(A.type==="newline"){s(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(L.start<O.found.offset-1024)s(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(P)if("source"in P&&P.source?.[0]===":")s(P,"MISSING_CHAR",`Missing space after : in ${a}`);else s(O.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let C=P?e(r,P,O,s):O.found?t(r,O.end,D,null,O,s):null;if(C){if(wi(P))s(C.range,"BLOCK_IN_FLOW",bi)}else if(O.comment)if(E.comment)E.comment+=`
94
+ `+O.comment;else E.comment=O.comment;let v=new V_.Pair(E,C);if(r.options.keepSourceTokens)v.srcToken=T;if(i){let A=l;if(B_.mapIncludes(r,A.items,E))s(K,"DUPLICATE_KEY","Map keys must be unique");A.items.push(v)}else{let A=new cm.YAMLMap(r.schema);A.flow=!0,A.items.push(v);let U=(C??E).range;A.range=[E.range[0],U[1],U[2]],l.items.push(A)}p=C?C.range[2]:O.end}}let d=i?"}":"]",[g,...b]=n.end,y=p;if(g?.source===d)y=g.offset+g.source.length;else{let w=a[0].toUpperCase()+a.substring(1),T=u?`${w} must end with a ${d}`:`${w} in block collection must be sufficiently indented and end with a ${d}`;if(s(p,u?"MISSING_CHAR":"BAD_INDENT",T),g&&g.source.length!==1)b.unshift(g)}if(b.length>0){let w=G_.resolveEnd(b,y,r.options.strict,s);if(w.comment)if(l.comment)l.comment+=`
95
+ `+w.comment;else l.comment=w.comment;l.range=[n.offset,y,w.offset]}else l.range=[n.offset,y,y];return l}Y_.resolveFlowCollection=H_});var pm=I(function(aA){var X_=J(),eA=ae(),tA=at(),rA=ct(),nA=im(),sA=am(),oA=um();function vi(e,t,r,n,s,o){let i=r.type==="block-map"?nA.resolveBlockMap(e,t,r,n,o):r.type==="block-seq"?sA.resolveBlockSeq(e,t,r,n,o):oA.resolveFlowCollection(e,t,r,n,o),a=i.constructor;if(s==="!"||s===a.tagName)return i.tag=a.tagName,i;if(s)i.tag=s;return i}function iA(e,t,r,n,s){let o=n.tag,i=!o?null:t.directives.tagName(o.source,(d)=>s(o,"TAG_RESOLVE_FAILED",d));if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:g}=n,b=d&&o?d.offset>o.offset?d:o:d??o;if(b&&(!g||g.offset<b.offset))s(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===tA.YAMLMap.tagName&&a==="map"||i===rA.YAMLSeq.tagName&&a==="seq")return vi(e,t,r,s,i);let c=t.schema.tags.find((d)=>d.tag===i&&d.collection===a);if(!c){let d=t.schema.knownTags[i];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else{if(d)s(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else s(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0);return vi(e,t,r,s,i)}}let l=vi(e,t,r,s,i,c),u=c.resolve?.(l,(d)=>s(o,"TAG_RESOLVE_FAILED",d),t.options)??l,p=X_.isNode(u)?u:new eA.Scalar(u);if(p.range=l.range,p.tag=i,c?.format)p.format=c.format;return p}aA.composeCollection=iA});var Si=I(function(dA){var ki=ae();function lA(e,t,r){let n=t.offset,s=uA(t,e.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let o=s.mode===">"?ki.Scalar.BLOCK_FOLDED:ki.Scalar.BLOCK_LITERAL,i=t.source?pA(t.source):[],a=i.length;for(let y=i.length-1;y>=0;--y){let w=i[y][1];if(w===""||w==="\r")a=y;else break}if(a===0){let y=s.chomp==="+"&&i.length>0?`
96
+ `.repeat(Math.max(1,i.length-1)):"",w=n+s.length;if(t.source)w+=t.source.length;return{value:y,type:o,comment:s.comment,range:[n,w,w]}}let c=t.indent+s.indent,l=t.offset+s.length,u=0;for(let y=0;y<a;++y){let[w,T]=i[y];if(T===""||T==="\r"){if(s.indent===0&&w.length>c)c=w.length}else{if(w.length<c)r(l+w.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(s.indent===0)c=w.length;if(u=y,c===0&&!e.atRoot)r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=w.length+T.length+1}for(let y=i.length-1;y>=a;--y)if(i[y][0].length>c)a=y+1;let p="",d="",g=!1;for(let y=0;y<u;++y)p+=i[y][0].slice(c)+`
97
+ `;for(let y=u;y<a;++y){let[w,T]=i[y];l+=w.length+T.length+1;let N=T[T.length-1]==="\r";if(N)T=T.slice(0,-1);if(T&&w.length<c){let D=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(l-T.length-(N?2:1),"BAD_INDENT",D),w=""}if(o===ki.Scalar.BLOCK_LITERAL)p+=d+w.slice(c)+T,d=`
98
98
  `;else if(w.length>c||T[0]==="\t"){if(d===" ")d=`
99
- `;else if(!h&&d===`
99
+ `;else if(!g&&d===`
100
100
  `)d=`
101
101
 
102
- `;u+=d+w.slice(c)+T,d=`
103
- `,h=!0}else if(T==="")if(d===`
104
- `)u+=`
102
+ `;p+=d+w.slice(c)+T,d=`
103
+ `,g=!0}else if(T==="")if(d===`
104
+ `)p+=`
105
105
  `;else d=`
106
- `;else u+=d+T,d=" ",h=!1}switch(s.chomp){case"-":break;case"+":for(let g=a;g<i.length;++g)u+=`
107
- `+i[g][0].slice(c);if(u[u.length-1]!==`
108
- `)u+=`
109
- `;break;default:u+=`
110
- `}let b=n+s.length+t.source.length;return{value:u,type:o,comment:s.comment,range:[n,b,b]}}function nA({offset:e,props:t},r,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=t[0],o=s[0],i=0,a="",c=-1;for(let d=1;d<s.length;++d){let h=s[d];if(!a&&(h==="-"||h==="+"))a=h;else{let b=Number(h);if(!i&&b)i=b;else if(c===-1)c=e+d}}if(c!==-1)n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,p="",u=s.length;for(let d=1;d<t.length;++d){let h=t[d];switch(h.type){case"space":l=!0;case"newline":u+=h.source.length;break;case"comment":if(r&&!l)n(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");u+=h.source.length,p=h.source.substring(1);break;case"error":n(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;n(h,"UNEXPECTED_TOKEN",b);let g=h.source;if(g&&typeof g==="string")u+=g.length}}}return{mode:o,indent:i,chomp:a,comment:p,length:u}}function sA(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),o=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let i=1;i<t.length;i+=2)o.push([t[i],t[i+1]]);return o}oA.resolveBlockScalar=rA});var xi=I(function(hA){var Si=ae(),aA=er();function cA(e,t,r){let{offset:n,type:s,source:o,end:i}=e,a,c,l=(d,h,b)=>r(n+d,h,b);switch(s){case"scalar":a=Si.Scalar.PLAIN,c=lA(o,l);break;case"single-quoted-scalar":a=Si.Scalar.QUOTE_SINGLE,c=uA(o,l);break;case"double-quoted-scalar":a=Si.Scalar.QUOTE_DOUBLE,c=pA(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}let p=n+o.length,u=aA.resolveEnd(i,p,t,r);return{value:c,type:a,comment:u.comment,range:[n,p,u.offset]}}function lA(e,t){let r="";switch(e[0]){case"\t":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}if(r)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`);return lm(e)}function uA(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return lm(e.slice(1,-1)).replace(/''/g,"'")}function lm(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
106
+ `;else p+=d+T,d=" ",g=!1}switch(s.chomp){case"-":break;case"+":for(let y=a;y<i.length;++y)p+=`
107
+ `+i[y][0].slice(c);if(p[p.length-1]!==`
108
+ `)p+=`
109
+ `;break;default:p+=`
110
+ `}let b=n+s.length+t.source.length;return{value:p,type:o,comment:s.comment,range:[n,b,b]}}function uA({offset:e,props:t},r,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=t[0],o=s[0],i=0,a="",c=-1;for(let d=1;d<s.length;++d){let g=s[d];if(!a&&(g==="-"||g==="+"))a=g;else{let b=Number(g);if(!i&&b)i=b;else if(c===-1)c=e+d}}if(c!==-1)n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,u="",p=s.length;for(let d=1;d<t.length;++d){let g=t[d];switch(g.type){case"space":l=!0;case"newline":p+=g.source.length;break;case"comment":if(r&&!l)n(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");p+=g.source.length,u=g.source.substring(1);break;case"error":n(g,"UNEXPECTED_TOKEN",g.message),p+=g.source.length;break;default:{let b=`Unexpected token in block scalar header: ${g.type}`;n(g,"UNEXPECTED_TOKEN",b);let y=g.source;if(y&&typeof y==="string")p+=y.length}}}return{mode:o,indent:i,chomp:a,comment:u,length:p}}function pA(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),o=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let i=1;i<t.length;i+=2)o.push([t[i],t[i+1]]);return o}dA.resolveBlockScalar=lA});var Ci=I(function(SA){var xi=ae(),fA=rr();function hA(e,t,r){let{offset:n,type:s,source:o,end:i}=e,a,c,l=(d,g,b)=>r(n+d,g,b);switch(s){case"scalar":a=xi.Scalar.PLAIN,c=gA(o,l);break;case"single-quoted-scalar":a=xi.Scalar.QUOTE_SINGLE,c=yA(o,l);break;case"double-quoted-scalar":a=xi.Scalar.QUOTE_DOUBLE,c=bA(o,l);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}let u=n+o.length,p=fA.resolveEnd(i,u,t,r);return{value:c,type:a,comment:p.comment,range:[n,u,p.offset]}}function gA(e,t){let r="";switch(e[0]){case"\t":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${e[0]}`;break}case"@":case"`":{r=`reserved character ${e[0]}`;break}}if(r)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`);return dm(e)}function yA(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return dm(e.slice(1,-1)).replace(/''/g,"'")}function dm(e){let t,r;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
111
111
  `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
112
112
  `,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let s=n[1],o=" ",i=t.lastIndex;r.lastIndex=i;while(n=r.exec(e)){if(n[1]==="")if(o===`
113
113
  `)s+=o;else o=`
114
- `;else s+=o+n[1],o=" ";i=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=i,n=a.exec(e),s+o+(n?.[1]??"")}function pA(e,t){let r="";for(let n=1;n<e.length-1;++n){let s=e[n];if(s==="\r"&&e[n+1]===`
114
+ `;else s+=o+n[1],o=" ";i=r.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=i,n=a.exec(e),s+o+(n?.[1]??"")}function bA(e,t){let r="";for(let n=1;n<e.length-1;++n){let s=e[n];if(s==="\r"&&e[n+1]===`
115
115
  `)continue;if(s===`
116
- `){let{fold:o,offset:i}=dA(e,n);r+=o,n=i}else if(s==="\\"){let o=e[++n],i=mA[o];if(i)r+=i;else if(o===`
116
+ `){let{fold:o,offset:i}=wA(e,n);r+=o,n=i}else if(s==="\\"){let o=e[++n],i=vA[o];if(i)r+=i;else if(o===`
117
117
  `){o=e[n+1];while(o===" "||o==="\t")o=e[++n+1]}else if(o==="\r"&&e[n+1]===`
118
- `){o=e[++n+1];while(o===" "||o==="\t")o=e[++n+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;r+=fA(e,n+1,a,t),n+=a}else{let a=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(s===" "||s==="\t"){let o=n,i=e[n+1];while(i===" "||i==="\t")i=e[++n+1];if(i!==`
118
+ `){o=e[++n+1];while(o===" "||o==="\t")o=e[++n+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;r+=kA(e,n+1,a,t),n+=a}else{let a=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(s===" "||s==="\t"){let o=n,i=e[n+1];while(i===" "||i==="\t")i=e[++n+1];if(i!==`
119
119
  `&&!(i==="\r"&&e[n+2]===`
120
- `))r+=n>o?e.slice(o,n+1):s}else r+=s}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function dA(e,t){let r="",n=e[t+1];while(n===" "||n==="\t"||n===`
120
+ `))r+=n>o?e.slice(o,n+1):s}else r+=s}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return r}function wA(e,t){let r="",n=e[t+1];while(n===" "||n==="\t"||n===`
121
121
  `||n==="\r"){if(n==="\r"&&e[t+2]!==`
122
122
  `)break;if(n===`
123
123
  `)r+=`
124
- `;t+=1,n=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var mA={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
125
- `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function fA(e,t,r,n){let s=e.substr(t,r),i=s.length===r&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(i)}catch{let a=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}hA.resolveFlowScalar=cA});var pm=I(function(SA){var Nt=J(),um=ae(),yA=ki(),bA=xi();function wA(e,t,r,n){let{value:s,type:o,comment:i,range:a}=t.type==="block-scalar"?yA.resolveBlockScalar(e,t,n):bA.resolveFlowScalar(t,e.options.strict,n),c=r?e.directives.tagName(r.source,(u)=>n(r,"TAG_RESOLVE_FAILED",u)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[Nt.SCALAR];else if(c)l=vA(e.schema,s,c,r,n);else if(t.type==="scalar")l=kA(e,s,t,n);else l=e.schema[Nt.SCALAR];let p;try{let u=l.resolve(s,(d)=>n(r??t,"TAG_RESOLVE_FAILED",d),e.options);p=Nt.isScalar(u)?u:new um.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);n(r??t,"TAG_RESOLVE_FAILED",d),p=new um.Scalar(s)}if(p.range=a,p.source=s,o)p.type=o;if(c)p.tag=c;if(l.format)p.format=l.format;if(i)p.comment=i;return p}function vA(e,t,r,n,s){if(r==="!")return e[Nt.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let i=e.knownTags[r];if(i&&!i.collection)return e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i;return s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[Nt.SCALAR]}function kA({atKey:e,directives:t,schema:r},n,s,o){let i=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||r[Nt.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(n))??r[Nt.SCALAR];if(i.tag!==a.tag){let c=t.tagString(i.tag),l=t.tagString(a.tag),p=`Value may be parsed as either ${c} or ${l}`;o(s,"TAG_RESOLVE_FAILED",p,!0)}}return i}SA.composeScalar=wA});var dm=I(function(_A){function CA(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let s=t[n];switch(s.type){case"space":case"comment":case"newline":e-=s.source.length;continue}s=t[++n];while(s?.type==="space")e+=s.source.length,s=t[++n];break}}return e}_A.emptyScalarPosition=CA});var hm=I(function(IA){var OA=Ar(),TA=J(),$A=cm(),mm=pm(),EA=er(),NA=dm(),DA={composeNode:fm,composeEmptyNode:Ci};function fm(e,t,r,n){let s=e.atKey,{spaceBefore:o,comment:i,anchor:a,tag:c}=r,l,p=!0;switch(t.type){case"alias":if(l=PA(e,t,n),a||c)n(t,"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(l=mm.composeScalar(e,t,c,n),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=$A.composeCollection(DA,e,t,r,n),a)l.anchor=a.source.substring(1)}catch(u){let d=u instanceof Error?u.message:String(u);n(t,"RESOURCE_EXHAUSTION",d)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",u),p=!1}}if(l??(l=Ci(e,t.offset,void 0,null,r,n)),a&&l.anchor==="")n(a,"BAD_ALIAS","Anchor cannot be an empty string");if(s&&e.options.stringKeys&&(!TA.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))n(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(o)l.spaceBefore=!0;if(i)if(t.type==="scalar"&&t.source==="")l.comment=i;else l.commentBefore=i;if(e.options.keepSourceTokens&&p)l.srcToken=t;return l}function Ci(e,t,r,n,{spaceBefore:s,comment:o,anchor:i,tag:a,end:c},l){let p={type:"scalar",offset:NA.emptyScalarPosition(t,r,n),indent:-1,source:""},u=mm.composeScalar(e,p,a,l);if(i){if(u.anchor=i.source.substring(1),u.anchor==="")l(i,"BAD_ALIAS","Anchor cannot be an empty string")}if(s)u.spaceBefore=!0;if(o)u.comment=o,u.range[2]=c;return u}function PA({options:e},{offset:t,source:r,end:n},s){let o=new OA.Alias(r.substring(1));if(o.source==="")s(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))s(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=t+r.length,a=EA.resolveEnd(n,i,e.strict,s);if(o.range=[t,i,a.offset],a.comment)o.comment=a.comment;return o}IA.composeEmptyNode=Ci;IA.composeNode=fm});var ym=I(function(UA){var zA=Rr(),gm=hm(),qA=er(),KA=Mr();function RA(e,t,{offset:r,start:n,value:s,end:o},i){let a=Object.assign({_directives:t},e),c=new zA.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},p=KA.resolveProps(n,{indicator:"doc-start",next:s??o?.[0],offset:r,onError:i,parentIndent:0,startOnNewline:!0});if(p.found){if(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!p.hasNewline)i(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=s?gm.composeNode(l,s,p,i):gm.composeEmptyNode(l,p.end,n,null,p,i);let u=c.contents.range[2],d=qA.resolveEnd(o,u,!1,i);if(d.comment)c.comment=d.comment;return c.range=[r,u,d.offset],c}UA.composeDoc=RA});var _i=I(function(JA){var jA=We("process"),ZA=$o(),VA=Rr(),jr=Ur(),bm=J(),WA=ym(),GA=er();function Zr(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r==="string"?r.length:1)]}function wm(e){let t="",r=!1,n=!1;for(let s=0;s<e.length;++s){let o=e[s];switch(o[0]){case"#":t+=(t===""?"":n?`
124
+ `;t+=1,n=e[t+1]}if(!r)r=" ";return{fold:r,offset:t}}var vA={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
125
+ `,r:"\r",t:"\t",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function kA(e,t,r,n){let s=e.substr(t,r),i=s.length===r&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(i)}catch{let a=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}SA.resolveFlowScalar=hA});var fm=I(function($A){var Nt=J(),mm=ae(),CA=Si(),_A=Ci();function AA(e,t,r,n){let{value:s,type:o,comment:i,range:a}=t.type==="block-scalar"?CA.resolveBlockScalar(e,t,n):_A.resolveFlowScalar(t,e.options.strict,n),c=r?e.directives.tagName(r.source,(p)=>n(r,"TAG_RESOLVE_FAILED",p)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[Nt.SCALAR];else if(c)l=OA(e.schema,s,c,r,n);else if(t.type==="scalar")l=TA(e,s,t,n);else l=e.schema[Nt.SCALAR];let u;try{let p=l.resolve(s,(d)=>n(r??t,"TAG_RESOLVE_FAILED",d),e.options);u=Nt.isScalar(p)?p:new mm.Scalar(p)}catch(p){let d=p instanceof Error?p.message:String(p);n(r??t,"TAG_RESOLVE_FAILED",d),u=new mm.Scalar(s)}if(u.range=a,u.source=s,o)u.type=o;if(c)u.tag=c;if(l.format)u.format=l.format;if(i)u.comment=i;return u}function OA(e,t,r,n,s){if(r==="!")return e[Nt.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let i=e.knownTags[r];if(i&&!i.collection)return e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i;return s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),e[Nt.SCALAR]}function TA({atKey:e,directives:t,schema:r},n,s,o){let i=r.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||r[Nt.SCALAR];if(r.compat){let a=r.compat.find((c)=>c.default&&c.test?.test(n))??r[Nt.SCALAR];if(i.tag!==a.tag){let c=t.tagString(i.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(s,"TAG_RESOLVE_FAILED",u,!0)}}return i}$A.composeScalar=AA});var hm=I(function(DA){function NA(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let s=t[n];switch(s.type){case"space":case"comment":case"newline":e-=s.source.length;continue}s=t[++n];while(s?.type==="space")e+=s.source.length,s=t[++n];break}}return e}DA.emptyScalarPosition=NA});var bm=I(function(UA){var IA=Ar(),FA=J(),LA=pm(),gm=fm(),zA=rr(),qA=hm(),KA={composeNode:ym,composeEmptyNode:_i};function ym(e,t,r,n){let s=e.atKey,{spaceBefore:o,comment:i,anchor:a,tag:c}=r,l,u=!0;switch(t.type){case"alias":if(l=RA(e,t,n),a||c)n(t,"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(l=gm.composeScalar(e,t,c,n),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=LA.composeCollection(KA,e,t,r,n),a)l.anchor=a.source.substring(1)}catch(p){let d=p instanceof Error?p.message:String(p);n(t,"RESOURCE_EXHAUSTION",d)}break;default:{let p=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",p),u=!1}}if(l??(l=_i(e,t.offset,void 0,null,r,n)),a&&l.anchor==="")n(a,"BAD_ALIAS","Anchor cannot be an empty string");if(s&&e.options.stringKeys&&(!FA.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))n(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(o)l.spaceBefore=!0;if(i)if(t.type==="scalar"&&t.source==="")l.comment=i;else l.commentBefore=i;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function _i(e,t,r,n,{spaceBefore:s,comment:o,anchor:i,tag:a,end:c},l){let u={type:"scalar",offset:qA.emptyScalarPosition(t,r,n),indent:-1,source:""},p=gm.composeScalar(e,u,a,l);if(i){if(p.anchor=i.source.substring(1),p.anchor==="")l(i,"BAD_ALIAS","Anchor cannot be an empty string")}if(s)p.spaceBefore=!0;if(o)p.comment=o,p.range[2]=c;return p}function RA({options:e},{offset:t,source:r,end:n},s){let o=new IA.Alias(r.substring(1));if(o.source==="")s(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))s(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=t+r.length,a=zA.resolveEnd(n,i,e.strict,s);if(o.range=[t,i,a.offset],a.comment)o.comment=a.comment;return o}UA.composeEmptyNode=_i;UA.composeNode=ym});var vm=I(function(JA){var ZA=Rr(),wm=bm(),VA=rr(),WA=Mr();function GA(e,t,{offset:r,start:n,value:s,end:o},i){let a=Object.assign({_directives:t},e),c=new ZA.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=WA.resolveProps(n,{indicator:"doc-start",next:s??o?.[0],offset:r,onError:i,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline)i(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=s?wm.composeNode(l,s,u,i):wm.composeEmptyNode(l,u.end,n,null,u,i);let p=c.contents.range[2],d=VA.resolveEnd(o,p,!1,i);if(d.comment)c.comment=d.comment;return c.range=[r,p,d.offset],c}JA.composeDoc=GA});var Ai=I(function(tO){var HA=We("process"),YA=Eo(),QA=Rr(),jr=Ur(),km=J(),XA=vm(),eO=rr();function Zr(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+(typeof r==="string"?r.length:1)]}function Sm(e){let t="",r=!1,n=!1;for(let s=0;s<e.length;++s){let o=e[s];switch(o[0]){case"#":t+=(t===""?"":n?`
126
126
 
127
127
  `:`
128
- `)+(o.substring(1)||" "),r=!0,n=!1;break;case"%":if(e[s+1]?.[0]!=="#")s+=1;r=!1;break;default:if(!r)n=!0;r=!1}}return{comment:t,afterEmptyLine:n}}class vm{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,n,s)=>{let o=Zr(t);if(s)this.warnings.push(new jr.YAMLWarning(o,r,n));else this.errors.push(new jr.YAMLParseError(o,r,n))},this.directives=new ZA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:n}=wm(this.prelude);if(r){let s=e.contents;if(t)e.comment=e.comment?`${e.comment}
129
- ${r}`:r;else if(n||e.directives.docStart||!s)e.commentBefore=r;else if(bm.isCollection(s)&&!s.flow&&s.items.length>0){let o=s.items[0];if(bm.isPair(o))o=o.key;let i=o.commentBefore;o.commentBefore=i?`${r}
128
+ `)+(o.substring(1)||" "),r=!0,n=!1;break;case"%":if(e[s+1]?.[0]!=="#")s+=1;r=!1;break;default:if(!r)n=!0;r=!1}}return{comment:t,afterEmptyLine:n}}class xm{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,n,s)=>{let o=Zr(t);if(s)this.warnings.push(new jr.YAMLWarning(o,r,n));else this.errors.push(new jr.YAMLParseError(o,r,n))},this.directives=new YA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:n}=Sm(this.prelude);if(r){let s=e.contents;if(t)e.comment=e.comment?`${e.comment}
129
+ ${r}`:r;else if(n||e.directives.docStart||!s)e.commentBefore=r;else if(km.isCollection(s)&&!s.flow&&s.items.length>0){let o=s.items[0];if(km.isPair(o))o=o.key;let i=o.commentBefore;o.commentBefore=i?`${r}
130
130
  ${i}`:r}else{let o=s.commentBefore;s.commentBefore=o?`${r}
131
- ${o}`:r}}if(t){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:wm(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(t,r)}*next(e){if(jA.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,n)=>{let s=Zr(e);s[0]+=t,this.onError(s,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=WA.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(r);else this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=GA.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
132
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new VA.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}JA.Composer=vm});var xm=I(function(nO){var HA=ki(),YA=xi(),QA=Ur(),km=Er();function XA(e,t=!0,r){if(e){let n=(s,o,i)=>{let a=typeof s==="number"?s:Array.isArray(s)?s[0]:s.offset;if(r)r(a,o,i);else throw new QA.YAMLParseError([a,a+1],o,i)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return YA.resolveFlowScalar(e,t,n);case"block-scalar":return HA.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function eO(e,t){let{implicitKey:r=!1,indent:n,inFlow:s=!1,offset:o=-1,type:i="PLAIN"}=t,a=km.stringifyString({type:i,value:e},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:n,source:`
131
+ ${o}`:r}}if(t){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Sm(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let n of e)yield*this.next(n);yield*this.end(t,r)}*next(e){if(HA.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,r,n)=>{let s=Zr(e);s[0]+=t,this.onError(s,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=XA.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(t,!1),this.doc)yield this.doc;this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(r);else this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=eO.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
132
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new jr.YAMLParseError(Zr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),n=new QA.Document(void 0,r);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}tO.Composer=xm});var Am=I(function(uO){var nO=Si(),sO=Ci(),oO=Ur(),Cm=Er();function iO(e,t=!0,r){if(e){let n=(s,o,i)=>{let a=typeof s==="number"?s:Array.isArray(s)?s[0]:s.offset;if(r)r(a,o,i);else throw new oO.YAMLParseError([a,a+1],o,i)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return sO.resolveFlowScalar(e,t,n);case"block-scalar":return nO.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function aO(e,t){let{implicitKey:r=!1,indent:n,inFlow:s=!1,offset:o=-1,type:i="PLAIN"}=t,a=Cm.stringifyString({type:i,value:e},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:n,source:`
133
133
  `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
134
- `),p=a.substring(0,l),u=a.substring(l+1)+`
135
- `,d=[{type:"block-scalar-header",offset:o,indent:n,source:p}];if(!Sm(d,c))d.push({type:"newline",offset:-1,indent:n,source:`
136
- `});return{type:"block-scalar",offset:o,indent:n,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:o,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:n,source:a,end:c};default:return{type:"scalar",offset:o,indent:n,source:a,end:c}}}function tO(e,t,r={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:o=!1,type:i}=r,a="indent"in e?e.indent:null;if(n&&typeof a==="number")a+=2;if(!i)switch(e.type){case"single-quoted-scalar":i="QUOTE_SINGLE";break;case"double-quoted-scalar":i="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");i=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:i="PLAIN"}let c=km.stringifyString({type:i,value:t},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":rO(e,c);break;case'"':Ai(e,c,"double-quoted-scalar");break;case"'":Ai(e,c,"single-quoted-scalar");break;default:Ai(e,c,"scalar")}}function rO(e,t){let r=t.indexOf(`
134
+ `),u=a.substring(0,l),p=a.substring(l+1)+`
135
+ `,d=[{type:"block-scalar-header",offset:o,indent:n,source:u}];if(!_m(d,c))d.push({type:"newline",offset:-1,indent:n,source:`
136
+ `});return{type:"block-scalar",offset:o,indent:n,props:d,source:p}}case'"':return{type:"double-quoted-scalar",offset:o,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:n,source:a,end:c};default:return{type:"scalar",offset:o,indent:n,source:a,end:c}}}function cO(e,t,r={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:o=!1,type:i}=r,a="indent"in e?e.indent:null;if(n&&typeof a==="number")a+=2;if(!i)switch(e.type){case"single-quoted-scalar":i="QUOTE_SINGLE";break;case"double-quoted-scalar":i="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");i=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:i="PLAIN"}let c=Cm.stringifyString({type:i,value:t},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":lO(e,c);break;case'"':Oi(e,c,"double-quoted-scalar");break;case"'":Oi(e,c,"single-quoted-scalar");break;default:Oi(e,c,"scalar")}}function lO(e,t){let r=t.indexOf(`
137
137
  `),n=t.substring(0,r),s=t.substring(r+1)+`
138
- `;if(e.type==="block-scalar"){let o=e.props[0];if(o.type!=="block-scalar-header")throw Error("Invalid block scalar header");o.source=n,e.source=s}else{let{offset:o}=e,i="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:i,source:n}];if(!Sm(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:i,source:`
139
- `});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:i,props:a,source:s})}}function Sm(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function Ai(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),s=t.length;if(e.props[0].type==="block-scalar-header")s-=e.props[0].source.length;for(let o of n)o.offset+=s;delete e.props,Object.assign(e,{type:r,source:t,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
140
- `};delete e.items,Object.assign(e,{type:r,source:t,end:[s]});break}default:{let n="indent"in e?e.indent:-1,s="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:r,indent:n,source:t,end:s})}}}nO.createScalarToken=eO;nO.resolveAsScalar=XA;nO.setScalarValue=tO});var Cm=I(function(cO){var aO=(e)=>("type"in e)?ns(e):rs(e);function ns(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=ns(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=rs(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=rs(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=rs(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function rs({start:e,key:t,sep:r,value:n}){let s="";for(let o of e)s+=o.source;if(t)s+=ns(t);if(r)for(let o of r)s+=o.source;if(n)s+=ns(n);return s}cO.stringify=aO});var Om=I(function(pO){var Oi=Symbol("break visit"),uO=Symbol("skip children"),_m=Symbol("remove item");function Dt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Am(Object.freeze([]),e,t)}Dt.BREAK=Oi;Dt.SKIP=uO;Dt.REMOVE=_m;Dt.itemAtPath=(e,t)=>{let r=e;for(let[n,s]of t){let o=r?.[n];if(o&&"items"in o)r=o.items[s];else return}return r};Dt.parentCollection=(e,t)=>{let r=Dt.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],s=r?.[n];if(s&&"items"in s)return s;throw Error("Parent collection not found")};function Am(e,t,r){let n=r(t,e);if(typeof n==="symbol")return n;for(let s of["key","value"]){let o=t[s];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Am(Object.freeze(e.concat([[s,i]])),o.items[i],r);if(typeof a==="number")i=a-1;else if(a===Oi)return Oi;else if(a===_m)o.items.splice(i,1),i-=1}if(typeof n==="function"&&s==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}pO.visit=Dt});var ss=I(function(wO){var Ti=xm(),mO=Cm(),fO=Om(),$i="\uFEFF",Ei="\x02",Ni="\x18",Di="\x1F",hO=(e)=>!!e&&("items"in e),gO=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function yO(e){switch(e){case $i:return"<BOM>";case Ei:return"<DOC>";case Ni:return"<FLOW_END>";case Di:return"<SCALAR>";default:return JSON.stringify(e)}}function bO(e){switch(e){case $i:return"byte-order-mark";case Ei:return"doc-mode";case Ni:return"flow-error-end";case Di:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
138
+ `;if(e.type==="block-scalar"){let o=e.props[0];if(o.type!=="block-scalar-header")throw Error("Invalid block scalar header");o.source=n,e.source=s}else{let{offset:o}=e,i="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:i,source:n}];if(!_m(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:i,source:`
139
+ `});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:i,props:a,source:s})}}function _m(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function Oi(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),s=t.length;if(e.props[0].type==="block-scalar-header")s-=e.props[0].source.length;for(let o of n)o.offset+=s;delete e.props,Object.assign(e,{type:r,source:t,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
140
+ `};delete e.items,Object.assign(e,{type:r,source:t,end:[s]});break}default:{let n="indent"in e?e.indent:-1,s="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:r,indent:n,source:t,end:s})}}}uO.createScalarToken=aO;uO.resolveAsScalar=iO;uO.setScalarValue=cO});var Om=I(function(hO){var fO=(e)=>("type"in e)?ns(e):rs(e);function ns(e){switch(e.type){case"block-scalar":{let t="";for(let r of e.props)t+=ns(r);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=rs(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=rs(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=rs(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function rs({start:e,key:t,sep:r,value:n}){let s="";for(let o of e)s+=o.source;if(t)s+=ns(t);if(r)for(let o of r)s+=o.source;if(n)s+=ns(n);return s}hO.stringify=fO});var Em=I(function(bO){var Ti=Symbol("break visit"),yO=Symbol("skip children"),Tm=Symbol("remove item");function Dt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};$m(Object.freeze([]),e,t)}Dt.BREAK=Ti;Dt.SKIP=yO;Dt.REMOVE=Tm;Dt.itemAtPath=(e,t)=>{let r=e;for(let[n,s]of t){let o=r?.[n];if(o&&"items"in o)r=o.items[s];else return}return r};Dt.parentCollection=(e,t)=>{let r=Dt.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],s=r?.[n];if(s&&"items"in s)return s;throw Error("Parent collection not found")};function $m(e,t,r){let n=r(t,e);if(typeof n==="symbol")return n;for(let s of["key","value"]){let o=t[s];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=$m(Object.freeze(e.concat([[s,i]])),o.items[i],r);if(typeof a==="number")i=a-1;else if(a===Ti)return Ti;else if(a===Tm)o.items.splice(i,1),i-=1}if(typeof n==="function"&&s==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}bO.visit=Dt});var ss=I(function(AO){var $i=Am(),vO=Om(),kO=Em(),Ei="\uFEFF",Ni="\x02",Di="\x18",Pi="\x1F",SO=(e)=>!!e&&("items"in e),xO=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function CO(e){switch(e){case Ei:return"<BOM>";case Ni:return"<DOC>";case Di:return"<FLOW_END>";case Pi:return"<SCALAR>";default:return JSON.stringify(e)}}function _O(e){switch(e){case Ei:return"byte-order-mark";case Ni:return"doc-mode";case Di:return"flow-error-end";case Pi:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
141
141
  `:case`\r
142
- `: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(e[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}wO.createScalarToken=Ti.createScalarToken;wO.resolveAsScalar=Ti.resolveAsScalar;wO.setScalarValue=Ti.setScalarValue;wO.stringify=mO.stringify;wO.visit=fO.visit;wO.BOM=$i;wO.DOCUMENT=Ei;wO.FLOW_END=Ni;wO.SCALAR=Di;wO.isCollection=hO;wO.isScalar=gO;wO.prettyToken=yO;wO.tokenType=bO});var Ii=I(function(FO){var Vr=ss();function Ie(e){switch(e){case void 0:case" ":case`
143
- `:case"\r":case"\t":return!0;default:return!1}}var Tm=new Set("0123456789ABCDEFabcdef"),PO=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),os=new Set(",[]{}"),IO=new Set(` ,[]{}
144
- \r `),Pi=(e)=>!e||IO.has(e);class $m{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(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";while(r&&(t||this.hasChars(1)))r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
142
+ `: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(e[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}AO.createScalarToken=$i.createScalarToken;AO.resolveAsScalar=$i.resolveAsScalar;AO.setScalarValue=$i.setScalarValue;AO.stringify=vO.stringify;AO.visit=kO.visit;AO.BOM=Ei;AO.DOCUMENT=Ni;AO.FLOW_END=Di;AO.SCALAR=Pi;AO.isCollection=SO;AO.isScalar=xO;AO.prettyToken=CO;AO.tokenType=_O});var Fi=I(function(MO){var Vr=ss();function Fe(e){switch(e){case void 0:case" ":case`
143
+ `:case"\r":case"\t":return!0;default:return!1}}var Nm=new Set("0123456789ABCDEFabcdef"),RO=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),os=new Set(",[]{}"),UO=new Set(` ,[]{}
144
+ \r `),Ii=(e)=>!e||UO.has(e);class Dm{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(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";while(r&&(t||this.hasChars(1)))r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
145
145
  `)return!0;if(t==="\r")return this.buffer[e+1]===`
146
146
  `;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;while(t===" ")t=this.buffer[++r+e];if(t==="\r"){let n=this.buffer[r+e+1];if(n===`
147
147
  `||!n&&!this.atEnd)return e+r+1}return t===`
148
- `||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Ie(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
149
- `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){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 e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Vr.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,r=e.indexOf("#");while(r!==-1){let s=e[r-1];if(s===" "||s==="\t"){t=r-1;break}else r=e.indexOf("#",r+1)}while(!0){let s=e[t-1];if(s===" "||s==="\t")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Vr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&Ie(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Ie(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Ie(t)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(Pi),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=r=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if(r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&Ie(n[3])){if(!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Vr.FLOW_END,yield*this.parseLineStart()}let s=0;while(n[s]===",")s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),n[s]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-s),"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(Pi),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ie(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let s=0;while(this.buffer[t-1-s]==="\\")s+=1;if(s%2===0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),n=r.indexOf(`
148
+ `||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Fe(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
149
+ `,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return this.buffer.substring(this.pos,e)}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){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 e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Vr.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,r=e.indexOf("#");while(r!==-1){let s=e[r-1];if(s===" "||s==="\t"){t=r-1;break}else r=e.indexOf("#",r+1)}while(!0){let s=e[t-1];if(s===" "||s==="\t")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Vr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&Fe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Fe(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Fe(t)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(Ii),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=r=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if(r!==-1&&r<this.indentNext&&n[0]!=="#"||r===0&&(n.startsWith("---")||n.startsWith("..."))&&Fe(n[3])){if(!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Vr.FLOW_END,yield*this.parseLineStart()}let s=0;while(n[s]===",")s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),n[s]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-s),"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(Ii),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Fe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let s=0;while(this.buffer[t-1-s]==="\\")s+=1;if(s%2===0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),n=r.indexOf(`
150
150
  `,this.pos);if(n!==-1){while(n!==-1){let s=this.continueScalar(n+1);if(s===-1)break;n=r.indexOf(`
151
- `,s)}if(n!==-1)t=n-(r[n-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>Ie(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":t+=1;break;case`
151
+ `,s)}if(n!==-1)t=n-(r[n-1]==="\r"?2:1)}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;while(!0){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil((t)=>Fe(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":t+=1;break;case`
152
152
  `:e=s,t=0;break;case"\r":{let o=this.buffer[s+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
153
153
  `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let s=this.continueScalar(e+1);if(s===-1)break;e=this.buffer.indexOf(`
154
154
  `,s)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;r=this.buffer[n];while(r===" ")r=this.buffer[++n];if(r==="\t"){while(r==="\t"||r===" "||r==="\r"||r===`
155
155
  `)r=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let s=e-1,o=this.buffer[s];if(o==="\r")o=this.buffer[--s];let i=s;while(o===" ")o=this.buffer[--s];if(o===`
156
- `&&s>=this.pos&&s+1+t>i)e=s;else break}while(!0);return yield Vr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,n;while(n=this.buffer[++r])if(n===":"){let s=this.buffer[r+1];if(Ie(s)||e&&os.has(s))break;t=r}else if(Ie(n)){let s=this.buffer[r+1];if(n==="\r")if(s===`
156
+ `&&s>=this.pos&&s+1+t>i)e=s;else break}while(!0);return yield Vr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,r=this.pos-1,n;while(n=this.buffer[++r])if(n===":"){let s=this.buffer[r+1];if(Fe(s)||e&&os.has(s))break;t=r}else if(Fe(n)){let s=this.buffer[r+1];if(n==="\r")if(s===`
157
157
  `)r+=1,n=`
158
158
  `,s=this.buffer[r+1];else t=r;if(s==="#"||e&&os.has(s))break;if(n===`
159
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&os.has(n))break;t=r}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield Vr.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Pi),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(Ie(r)||t&&os.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Ie(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(PO.has(t))t=this.buffer[++e];else if(t==="%"&&Tm.has(this.buffer[e+1])&&Tm.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
159
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&os.has(n))break;t=r}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield Vr.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);if(r)return yield r,this.pos+=r.length,r.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Ii),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(Fe(r)||t&&os.has(r)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Fe(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(RO.has(t))t=this.buffer[++e];else if(t==="%"&&Nm.has(this.buffer[e+1])&&Nm.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];if(e===`
160
160
  `)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
161
- `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}FO.Lexer=$m});var Fi=I(function(zO){class Em{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,r=this.lineStarts.length;while(t<r){let s=t+r>>1;if(this.lineStarts[s]<e)t=s+1;else r=s}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}zO.LineCounter=Em});var Li=I(function(UO){var KO=We("process"),Nm=ss(),RO=Ii();function lt(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function Dm(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Im(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function is(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function tr(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function as(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function Pm(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!lt(t.start,"explicit-key-ind")&&!lt(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Im(t.value))if(t.value.end)as(t.value.end,t.sep);else t.value.end=t.sep;else as(t.start,t.sep);delete t.sep}}}class Fm{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new RO.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);if(!t)yield*this.end()}*next(e){if(this.source=e,KO.env.LOG_TOKENS)console.log("|",Nm.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Nm.tokenType(e);if(!t){let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.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 e=this.peek(1);if(this.type==="doc-end"&&e?.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(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in r?r.indent:0;else if(t.type==="flow-collection"&&r.type==="document")t.indent=0;if(t.type==="flow-collection")Pm(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];if(n.value)r.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=r.items[r.items.length-1];if(!n||n.value)r.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&Dm(n.start)===-1&&(t.indent===0||n.start.every((s)=>s.type!=="comment"||s.indent<t.indent))){if(r.type==="document")r.end=n.start;else r.items.push({start:n.start});t.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 e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(Dm(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=is(this.peek(2)),r=tr(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
161
+ `)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,r=this.buffer[t];while(!e(r))r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}MO.Lexer=Dm});var Li=I(function(ZO){class Pm{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,r=this.lineStarts.length;while(t<r){let s=t+r>>1;if(this.lineStarts[s]<e)t=s+1;else r=s}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}ZO.LineCounter=Pm});var zi=I(function(JO){var WO=We("process"),Im=ss(),GO=Fi();function lt(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function Fm(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function zm(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function is(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function nr(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function as(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function Lm(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!lt(t.start,"explicit-key-ind")&&!lt(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,zm(t.value))if(t.value.end)as(t.value.end,t.sep);else t.value.end=t.sep;else as(t.start,t.sep);delete t.sep}}}class qm{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new GO.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);if(!t)yield*this.end()}*next(e){if(this.source=e,WO.env.LOG_TOKENS)console.log("|",Im.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Im.tokenType(e);if(!t){let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.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 e=this.peek(1);if(this.type==="doc-end"&&e?.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(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in r?r.indent:0;else if(t.type==="flow-collection"&&r.type==="document")t.indent=0;if(t.type==="flow-collection")Lm(t);switch(r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let n=r.items[r.items.length-1];if(n.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=r.items[r.items.length-1];if(n.value)r.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=r.items[r.items.length-1];if(!n||n.value)r.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&Fm(n.start)===-1&&(t.indent===0||n.start.every((s)=>s.type!=="comment"||s.indent<t.indent))){if(r.type==="document")r.end=n.start;else r.items.push({start:n.start});t.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 e={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")e.start.push(this.sourceToken);this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{if(Fm(e.start)!==-1)yield*this.pop(),yield*this.step();else e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=is(this.peek(2)),r=nr(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
162
162
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
163
- `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){as(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",s=[];if(n&&t.sep&&!t.value){let o=[];for(let i=0;i<t.sep.length;++i){let a=t.sep[i];switch(a.type){case"newline":o.push(i);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)s=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)s.push(this.sourceToken),e.items.push({start:s,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(t.explicitKey)if(!t.sep)if(lt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=tr(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(lt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Im(t.key)&&!lt(t.sep,"newline")){let o=tr(t.start),{key:i,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:i,sep:a}]})}else if(s.length>0)t.sep=t.sep.concat(s,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:s,key:null,sep:[this.sourceToken]});else if(lt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(n||t.value)e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!lt(t.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(r)e.items.push({start:s});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){as(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||lt(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);if(r)this.stack.push(r);else yield*this.pop(),yield*this.step()}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=is(r),s=tr(n);Pm(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
163
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){as(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",s=[];if(n&&t.sep&&!t.value){let o=[];for(let i=0;i<t.sep.length;++i){let a=t.sep[i];switch(a.type){case"newline":o.push(i);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)s=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)s.push(this.sourceToken),e.items.push({start:s,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(t.explicitKey)if(!t.sep)if(lt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=nr(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(lt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(zm(t.key)&&!lt(t.sep,"newline")){let o=nr(t.start),{key:i,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:i,sep:a}]})}else if(s.length>0)t.sep=t.sep.concat(s,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:s,key:null,sep:[this.sourceToken]});else if(lt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(n||t.value)e.items.push({start:s,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!lt(t.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(r)e.items.push({start:s});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0;if((Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment")r?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){as(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;if(t.value||lt(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);if(r)this.stack.push(r);else yield*this.pop(),yield*this.step()}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let n=is(r),s=nr(n);Lm(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
164
164
  `)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
165
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){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 t=is(e),r=tr(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=is(e),r=tr(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){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(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}UO.Parser=Fm});var Rm=I(function(HO){var Lm=_i(),jO=Rr(),Wr=Ur(),ZO=Fo(),VO=J(),WO=Fi(),zm=Li();function qm(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new WO.LineCounter||null,prettyErrors:t}}function GO(e,t={}){let{lineCounter:r,prettyErrors:n}=qm(t),s=new zm.Parser(r?.addNewLine),o=new Lm.Composer(t),i=Array.from(o.compose(s.parse(e)));if(n&&r)for(let a of i)a.errors.forEach(Wr.prettifyError(e,r)),a.warnings.forEach(Wr.prettifyError(e,r));if(i.length>0)return i;return Object.assign([],{empty:!0},o.streamInfo())}function Km(e,t={}){let{lineCounter:r,prettyErrors:n}=qm(t),s=new zm.Parser(r?.addNewLine),o=new Lm.Composer(t),i=null;for(let a of o.compose(s.parse(e),!0,e.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new Wr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&r)i.errors.forEach(Wr.prettifyError(e,r)),i.warnings.forEach(Wr.prettifyError(e,r));return i}function JO(e,t,r){let n=void 0;if(typeof t==="function")n=t;else if(r===void 0&&t&&typeof t==="object")r=t;let s=Km(e,r);if(!s)return null;if(s.warnings.forEach((o)=>ZO.warn(s.options.logLevel,o)),s.errors.length>0)if(s.options.logLevel!=="silent")throw s.errors[0];else s.errors=[];return s.toJS(Object.assign({reviver:n},r))}function BO(e,t,r){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(e===void 0){let{keepUndefined:s}=r??t??{};if(!s)return}if(VO.isDocument(e)&&!n)return e.toString(r);return new jO.Document(e,n,r).toString(r)}HO.parse=JO;HO.parseAllDocuments=GO;HO.parseDocument=Km;HO.stringify=BO});var hr={};py(hr,{ZodISODate:()=>Hl,ZodISODateTime:()=>Bl,ZodISODuration:()=>Ql,ZodISOTime:()=>Yl,date:()=>Qs,datetime:()=>Ys,duration:()=>eo,time:()=>Xs});var vo={};dy(vo,{program:()=>Gu,createCommand:()=>Ju,createOption:()=>Bu,createArgument:()=>Hu,Command:()=>Yu,Option:()=>Qu,Argument:()=>Xu,Help:()=>ep,CommanderError:()=>tp,InvalidArgumentError:()=>rp,InvalidOptionArgumentError:()=>np},{program:(NN)=>Gu=NN,createCommand:(NN)=>Ju=NN,createOption:(NN)=>Bu=NN,createArgument:(NN)=>Hu=NN,Command:(NN)=>Yu=NN,Option:(NN)=>Qu=NN,Argument:(NN)=>Xu=NN,Help:(NN)=>ep=NN,CommanderError:(NN)=>tp=NN,InvalidArgumentError:(NN)=>rp=NN,InvalidOptionArgumentError:(NN)=>np=NN});import{inspect as fy}from"node:util";function vs(e){return fy(e,{depth:null,colors:process.stderr.isTTY})}function ws(e){let t=Object.fromEntries(Object.getOwnPropertyNames(e).filter((r)=>!["name","message","stack","cause"].includes(r)).map((r)=>[r,e[r]]).filter(([,r])=>r!==void 0));return Object.keys(t).length>0?t:null}function sa(e){if(e instanceof Error)return oa(e);if(typeof e==="string")return e;return vs(e)}function oa(e){let t=[e.message],r=ws(e);if(r)t.push(""),t.push("Details:"),t.push(vs(r));if("cause"in e&&e.cause!==void 0)t.push(""),t.push("Cause:"),t.push(sa(e.cause));return t.join(`
166
- `)}function ks(e){let t=e instanceof Error?{message:e.message,details:ws(e),cause:"cause"in e&&e.cause!==void 0?e.cause instanceof Error?{message:e.cause.message,details:ws(e.cause)}:e.cause:null}:{message:sa(e),details:null,cause:null};return JSON.stringify({schemaVersion:1,ok:!1,error:t},null,2)}function ia(e,t={}){if(t.json){console.error(ks(e));return}let r=e instanceof Error?oa(e):vs(e);console.error(r)}function Le(e){return new Promise((t)=>setTimeout(t,e))}async function hy(e,t,r=fetch){let n=await r(e,t);if(!n.ok)throw Error(`Request failed: ${n.status} ${n.statusText}`,{cause:await n.text().catch(()=>null)});return await n.json()}async function gy(e,t=fetch){return hy(new URL("/.well-known/openid-configuration",e),void 0,t)}async function yy(e,t,r=fetch){return await(await r(e.token_endpoint,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:t})).json()}async function by(e,t,r,n=fetch){if(!r.refreshToken)throw Error("No refresh token available. Run login again.");let s=await yy(e,new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken,client_id:t}),n);if(!("access_token"in s))throw Error(s.error_description??s.error);return s}function wy(e,t,r){let n=new Date(Date.now()+r.expires_in*1000).toISOString(),s=r.refresh_token_expires_in?new Date(Date.now()+r.refresh_token_expires_in*1000).toISOString():null;return{serverUrl:e,issuerUrl:t,tokenType:r.token_type,accessToken:r.access_token,accessTokenExpiresAt:n,refreshToken:r.refresh_token??null,refreshTokenExpiresAt:s}}function aa(e){return Date.now()>=new Date(e).getTime()}async function ca(e,t,r){let n=t.load();if(!n)throw Error("No saved session found. Run login first.");if(n.serverUrl!==e)throw Error("Saved session belongs to a different server. Run login again.");if(!aa(n.accessTokenExpiresAt))return n.accessToken;if(!n.refreshToken||n.refreshTokenExpiresAt&&aa(n.refreshTokenExpiresAt))throw Error("Saved session has expired. Run login again.");let s=await r.loadAuthConfig(e),o=await gy(s.issuerUrl,r.fetch),i=await by(o,s.flows.cli.clientId,n,r.fetch),a=wy(n.serverUrl,s.issuerUrl,i);return t.save({...n,...a}),a.accessToken}async function la(e,t){let r=await ca(e,t.store,{fetch:t.fetch,loadAuthConfig:t.loadAuthConfig}),s=t.store.load()?.workspaceKey??null;return{serverUrl:e,store:t.store,accessToken:r,workspaceKey:s,api:t.createApiClient(e,{getAccessToken:()=>r,getWorkspaceKey:()=>s})}}var m$=Object.freeze({status:"aborted"});function S(e,t,r){function n(a,c){var l;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(l=a._zod).traits??(l.traits=new Set),a._zod.traits.add(e),t(a,c);for(let p in i.prototype)if(!(p in a))Object.defineProperty(a,p,{value:i.prototype[p].bind(a)});a._zod.constr=i,a._zod.def=c}let s=r?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function i(a){var c;let l=r?.Parent?new o:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let p of l._zod.deferred)p();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}var f$=Symbol("zod_brand");class Qe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var Yr={};function Oe(e){if(e)Object.assign(Yr,e);return Yr}function ua(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function xs(e,t="|"){return e.map((r)=>_s(r)).join(t)}function pa(e,t){if(typeof t==="bigint")return t.toString();return t}function Xr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function en(e){return e===null||e===void 0}function tn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function da(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),i=Number.parseInt(t.toFixed(s).replace(".",""));return o%i/10**s}function Y(e,t,r){Object.defineProperty(e,t,{get(){{let s=r();return e[t]=s,s}throw Error("cached value already set")},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function rn(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function qt(e){return JSON.stringify(e)}var Cs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function cr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ma=Xr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function lr(e){if(cr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;if(cr(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}var fa=new Set(["string","number","symbol"]);function vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function q(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function _s(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function ha(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ga={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function vy(e,t){let r={},n=e._zod.def;for(let s in t){if(!(s in n.shape))throw Error(`Unrecognized key: "${s}"`);if(!t[s])continue;r[s]=n.shape[s]}return Ge(e,{...e._zod.def,shape:r,checks:[]})}function ky(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let s in t){if(!(s in n.shape))throw Error(`Unrecognized key: "${s}"`);if(!t[s])continue;delete r[s]}return Ge(e,{...e._zod.def,shape:r,checks:[]})}function Sy(e,t){if(!lr(t))throw Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return rn(this,"shape",n),n},checks:[]};return Ge(e,r)}function xy(e,t){return Ge(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return rn(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Cy(e,t,r){let n=t._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in n))throw Error(`Unrecognized key: "${o}"`);if(!r[o])continue;s[o]=e?new e({type:"optional",innerType:n[o]}):n[o]}else for(let o in n)s[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return Ge(t,{...t._zod.def,shape:s,checks:[]})}function _y(e,t,r){let n=t._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in s))throw Error(`Unrecognized key: "${o}"`);if(!r[o])continue;s[o]=new e({type:"nonoptional",innerType:n[o]})}else for(let o in n)s[o]=new e({type:"nonoptional",innerType:n[o]});return Ge(t,{...t._zod.def,shape:s,checks:[]})}function Kt(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Je(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Qr(e){return typeof e==="string"?e:e?.message}function ze(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let s=Qr(e.inst?._zod.def?.error?.(e))??Qr(t?.error?.(e))??Qr(r.customError?.(e))??Qr(r.localeError?.(e))??"Invalid input";n.message=s}if(delete n.inst,delete n.continue,!t?.reportInput)delete n.input;return n}function nn(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Rt(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}var ya=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,pa,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sn=S("$ZodError",ya),As=S("$ZodError",ya,{Parent:Error});function ba(e,t=(r)=>r.message){let r={},n=[];for(let s of e.issues)if(s.path.length>0)r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s));else n.push(t(s));return{formErrors:n,fieldErrors:r}}function wa(e,t){let r=t||function(o){return o.message},n={_errors:[]},s=(o)=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((a)=>s({issues:a}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;while(c<i.path.length){let l=i.path[c];if(c!==i.path.length-1)a[l]=a[l]||{_errors:[]};else a[l]=a[l]||{_errors:[]},a[l]._errors.push(r(i));a=a[l],c++}}};return s(e),n}var va=(e)=>(t,r,n,s)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Qe;if(i.issues.length){let a=new(s?.Err??e)(i.issues.map((c)=>ze(c,o,Oe())));throw Cs(a,s?.callee),a}return i.value};var ka=(e)=>async(t,r,n,s)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;if(i.issues.length){let a=new(s?.Err??e)(i.issues.map((c)=>ze(c,o,Oe())));throw Cs(a,s?.callee),a}return i.value};var Os=(e)=>(t,r,n)=>{let s=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Qe;return o.issues.length?{success:!1,error:new(e??sn)(o.issues.map((i)=>ze(i,s,Oe())))}:{success:!0,data:o.value}},Sa=Os(As),Ts=(e)=>async(t,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)o=await o;return o.issues.length?{success:!1,error:new e(o.issues.map((i)=>ze(i,s,Oe())))}:{success:!0,data:o.value}},xa=Ts(As);var Ca=/^[cC][^\s-]{8,}$/,_a=/^[0-9a-z]+$/,Aa=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Oa=/^[0-9a-vA-V]{20}$/,Ta=/^[A-Za-z0-9]{27}$/,$a=/^[a-zA-Z0-9_-]{21}$/,Ea=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Na=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$s=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Da=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Pa(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var Ia=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Fa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,La=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,za=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Es=/^[A-Za-z0-9_-]*$/,Ka=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Ra=/^\+(?:[0-9]){6,14}[0-9]$/,Ua="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ma=new RegExp(`^${Ua}$`);function ja(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Za(e){return new RegExp(`^${ja(e)}$`)}function Va(e){let t=ja({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Ua}T(?:${n})$`)}var Wa=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ga=/^\d+$/,Ja=/^-?\d+(?:\.\d+)?/i,Ba=/true|false/i,Ha=/null/i;var Ya=/^[^A-Z]*$/,Qa=/^[^a-z]*$/;var he=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Xa={number:"number",bigint:"bigint",object:"date"},Ds=S("$ZodCheckLessThan",(e,t)=>{he.init(e,t);let r=Xa[typeof t.value];e._zod.onattach.push((n)=>{let s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<o)if(t.inclusive)s.maximum=t.value;else s.exclusiveMaximum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ps=S("$ZodCheckGreaterThan",(e,t)=>{he.init(e,t);let r=Xa[typeof t.value];e._zod.onattach.push((n)=>{let s=n._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>o)if(t.inclusive)s.minimum=t.value;else s.exclusiveMinimum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ec=S("$ZodCheckMultipleOf",(e,t)=>{he.init(e,t),e._zod.onattach.push((r)=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):da(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),tc=S("$ZodCheckNumberFormat",(e,t)=>{he.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[s,o]=ga[t.format];e._zod.onattach.push((i)=>{let a=i._zod.bag;if(a.format=t.format,a.minimum=s,a.maximum=o,r)a.pattern=Ga}),e._zod.check=(i)=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});else i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}if(a<s)i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort});if(a>o)i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var rc=S("$ZodCheckMaxLength",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<s)n._zod.bag.maximum=t.maximum}),e._zod.check=(n)=>{let s=n.value;if(s.length<=t.maximum)return;let i=nn(s);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),nc=S("$ZodCheckMinLength",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>s)n._zod.bag.minimum=t.minimum}),e._zod.check=(n)=>{let s=n.value;if(s.length>=t.minimum)return;let i=nn(s);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),sc=S("$ZodCheckLengthEquals",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=(n)=>{let s=n.value,o=s.length;if(o===t.length)return;let i=nn(s),a=o>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ur=S("$ZodCheckStringFormat",(e,t)=>{var r,n;if(he.init(e,t),e._zod.onattach.push((s)=>{let o=s._zod.bag;if(o.format=t.format,t.pattern)o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(s)=>{if(t.pattern.lastIndex=0,t.pattern.test(s.value))return;s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),oc=S("$ZodCheckRegex",(e,t)=>{ur.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ic=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ya),ur.init(e,t)}),ac=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Qa),ur.init(e,t)}),cc=S("$ZodCheckIncludes",(e,t)=>{he.init(e,t);let r=vt(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((s)=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(s)=>{if(s.value.includes(t.includes,t.position))return;s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),lc=S("$ZodCheckStartsWith",(e,t)=>{he.init(e,t);let r=new RegExp(`^${vt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),uc=S("$ZodCheckEndsWith",(e,t)=>{he.init(e,t);let r=new RegExp(`.*${vt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var pc=S("$ZodCheckOverwrite",(e,t)=>{he.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Is{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
165
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){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 t=is(e),r=nr(t);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=is(e),r=nr(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((r)=>r.type==="newline"||r.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(e){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(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}JO.Parser=qm});var jm=I(function(nT){var Km=Ai(),HO=Rr(),Wr=Ur(),YO=Lo(),QO=J(),XO=Li(),Rm=zi();function Um(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new XO.LineCounter||null,prettyErrors:t}}function eT(e,t={}){let{lineCounter:r,prettyErrors:n}=Um(t),s=new Rm.Parser(r?.addNewLine),o=new Km.Composer(t),i=Array.from(o.compose(s.parse(e)));if(n&&r)for(let a of i)a.errors.forEach(Wr.prettifyError(e,r)),a.warnings.forEach(Wr.prettifyError(e,r));if(i.length>0)return i;return Object.assign([],{empty:!0},o.streamInfo())}function Mm(e,t={}){let{lineCounter:r,prettyErrors:n}=Um(t),s=new Rm.Parser(r?.addNewLine),o=new Km.Composer(t),i=null;for(let a of o.compose(s.parse(e),!0,e.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new Wr.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&r)i.errors.forEach(Wr.prettifyError(e,r)),i.warnings.forEach(Wr.prettifyError(e,r));return i}function tT(e,t,r){let n=void 0;if(typeof t==="function")n=t;else if(r===void 0&&t&&typeof t==="object")r=t;let s=Mm(e,r);if(!s)return null;if(s.warnings.forEach((o)=>YO.warn(s.options.logLevel,o)),s.errors.length>0)if(s.options.logLevel!=="silent")throw s.errors[0];else s.errors=[];return s.toJS(Object.assign({reviver:n},r))}function rT(e,t,r){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(r===void 0&&t)r=t;if(typeof r==="string")r=r.length;if(typeof r==="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(e===void 0){let{keepUndefined:s}=r??t??{};if(!s)return}if(QO.isDocument(e)&&!n)return e.toString(r);return new HO.Document(e,n,r).toString(r)}nT.parse=tT;nT.parseAllDocuments=eT;nT.parseDocument=Mm;nT.stringify=rT});var gr={};by(gr,{ZodISODate:()=>Ql,ZodISODateTime:()=>Yl,ZodISODuration:()=>eu,ZodISOTime:()=>Xl,date:()=>Xs,datetime:()=>Qs,duration:()=>to,time:()=>eo});var ko={};wy(ko,{program:()=>Bu,createCommand:()=>Hu,createOption:()=>Yu,createArgument:()=>Qu,Command:()=>Xu,Option:()=>ep,Argument:()=>tp,Help:()=>rp,CommanderError:()=>np,InvalidArgumentError:()=>sp,InvalidOptionArgumentError:()=>op},{program:(UN)=>Bu=UN,createCommand:(UN)=>Hu=UN,createOption:(UN)=>Yu=UN,createArgument:(UN)=>Qu=UN,Command:(UN)=>Xu=UN,Option:(UN)=>ep=UN,Argument:(UN)=>tp=UN,Help:(UN)=>rp=UN,CommanderError:(UN)=>np=UN,InvalidArgumentError:(UN)=>sp=UN,InvalidOptionArgumentError:(UN)=>op=UN});import{inspect as ky}from"node:util";function vs(e){return ky(e,{depth:null,colors:process.stderr.isTTY})}function ws(e){let t=Object.fromEntries(Object.getOwnPropertyNames(e).filter((r)=>!["name","message","stack","cause"].includes(r)).map((r)=>[r,e[r]]).filter(([,r])=>r!==void 0));return Object.keys(t).length>0?t:null}function aa(e){if(e instanceof Error)return ca(e);if(typeof e==="string")return e;return vs(e)}function ca(e){let t=[e.message],r=ws(e);if(r)t.push(""),t.push("Details:"),t.push(vs(r));if("cause"in e&&e.cause!==void 0)t.push(""),t.push("Cause:"),t.push(aa(e.cause));return t.join(`
166
+ `)}function ks(e){let t=e instanceof Error?{message:e.message,details:ws(e),cause:"cause"in e&&e.cause!==void 0?e.cause instanceof Error?{message:e.cause.message,details:ws(e.cause)}:e.cause:null}:{message:aa(e),details:null,cause:null};return JSON.stringify({schemaVersion:1,ok:!1,error:t},null,2)}function la(e,t={}){if(t.json){console.error(ks(e));return}let r=e instanceof Error?ca(e):vs(e);console.error(r)}function ze(e){return new Promise((t)=>setTimeout(t,e))}async function Sy(e,t,r=fetch){let n=await r(e,t);if(!n.ok)throw Error(`Request failed: ${n.status} ${n.statusText}`,{cause:await n.text().catch(()=>null)});return await n.json()}async function xy(e,t=fetch){return Sy(new URL("/.well-known/openid-configuration",e),void 0,t)}async function Cy(e,t,r=fetch){return await(await r(e.token_endpoint,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:t})).json()}async function _y(e,t,r,n=fetch){if(!r.refreshToken)throw Error("No refresh token available. Run login again.");let s=await Cy(e,new URLSearchParams({grant_type:"refresh_token",refresh_token:r.refreshToken,client_id:t}),n);if(!("access_token"in s))throw Error(s.error_description??s.error);return s}function Ay(e,t,r){let n=new Date(Date.now()+r.expires_in*1000).toISOString(),s=r.refresh_token_expires_in?new Date(Date.now()+r.refresh_token_expires_in*1000).toISOString():null;return{serverUrl:e,issuerUrl:t,tokenType:r.token_type,accessToken:r.access_token,accessTokenExpiresAt:n,refreshToken:r.refresh_token??null,refreshTokenExpiresAt:s}}function Ss(e){return Date.now()>=new Date(e).getTime()}async function ua(e,t,r){let n=t.load();if(!n)throw Error("No saved session found. Run login first.");if(n.serverUrl!==e)throw Error("Saved session belongs to a different server. Run login again.");if(!Ss(n.accessTokenExpiresAt))return n.accessToken;if(!n.refreshToken||n.refreshTokenExpiresAt&&Ss(n.refreshTokenExpiresAt))throw Error("Saved session has expired. Run login again.");let s=await r.loadAuthConfig(e),o=await xy(s.issuerUrl,r.fetch),i=await _y(o,s.flows.cli.clientId,n,r.fetch).catch((c)=>{let l=t.load();if(l?.serverUrl===e&&l.refreshToken!==n.refreshToken&&!Ss(l.accessTokenExpiresAt))return null;throw c});if(!i)return t.load().accessToken;let a=Ay(n.serverUrl,s.issuerUrl,i);return t.save({...n,...a}),a.accessToken}async function pa(e,t){let r=await ua(e,t.store,{fetch:t.fetch,loadAuthConfig:t.loadAuthConfig}),s=t.store.load()?.workspaceKey??null;return{serverUrl:e,store:t.store,accessToken:r,workspaceKey:s,api:t.createApiClient(e,{getAccessToken:()=>r,getWorkspaceKey:()=>s})}}var x$=Object.freeze({status:"aborted"});function S(e,t,r){function n(a,c){var l;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(l=a._zod).traits??(l.traits=new Set),a._zod.traits.add(e),t(a,c);for(let u in i.prototype)if(!(u in a))Object.defineProperty(a,u,{value:i.prototype[u].bind(a)});a._zod.constr=i,a._zod.def=c}let s=r?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function i(a){var c;let l=r?.Parent?new o:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}var C$=Symbol("zod_brand");class Qe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}var Yr={};function Oe(e){if(e)Object.assign(Yr,e);return Yr}function da(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,s])=>t.indexOf(+n)===-1).map(([n,s])=>s)}function Cs(e,t="|"){return e.map((r)=>As(r)).join(t)}function ma(e,t){if(typeof t==="bigint")return t.toString();return t}function Xr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function en(e){return e===null||e===void 0}function tn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function fa(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(e.toFixed(s).replace(".","")),i=Number.parseInt(t.toFixed(s).replace(".",""));return o%i/10**s}function Y(e,t,r){Object.defineProperty(e,t,{get(){{let s=r();return e[t]=s,s}throw Error("cached value already set")},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function rn(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kt(e){return JSON.stringify(e)}var _s=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function lr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ha=Xr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ur(e){if(lr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;if(lr(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}var ga=new Set(["string","number","symbol"]);function vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function q(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function As(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function ya(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ba={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Oy(e,t){let r={},n=e._zod.def;for(let s in t){if(!(s in n.shape))throw Error(`Unrecognized key: "${s}"`);if(!t[s])continue;r[s]=n.shape[s]}return Ge(e,{...e._zod.def,shape:r,checks:[]})}function Ty(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let s in t){if(!(s in n.shape))throw Error(`Unrecognized key: "${s}"`);if(!t[s])continue;delete r[s]}return Ge(e,{...e._zod.def,shape:r,checks:[]})}function $y(e,t){if(!ur(t))throw Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return rn(this,"shape",n),n},checks:[]};return Ge(e,r)}function Ey(e,t){return Ge(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return rn(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function Ny(e,t,r){let n=t._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in n))throw Error(`Unrecognized key: "${o}"`);if(!r[o])continue;s[o]=e?new e({type:"optional",innerType:n[o]}):n[o]}else for(let o in n)s[o]=e?new e({type:"optional",innerType:n[o]}):n[o];return Ge(t,{...t._zod.def,shape:s,checks:[]})}function Dy(e,t,r){let n=t._zod.def.shape,s={...n};if(r)for(let o in r){if(!(o in s))throw Error(`Unrecognized key: "${o}"`);if(!r[o])continue;s[o]=new e({type:"nonoptional",innerType:n[o]})}else for(let o in n)s[o]=new e({type:"nonoptional",innerType:n[o]});return Ge(t,{...t._zod.def,shape:s,checks:[]})}function Rt(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Je(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Qr(e){return typeof e==="string"?e:e?.message}function qe(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let s=Qr(e.inst?._zod.def?.error?.(e))??Qr(t?.error?.(e))??Qr(r.customError?.(e))??Qr(r.localeError?.(e))??"Invalid input";n.message=s}if(delete n.inst,delete n.continue,!t?.reportInput)delete n.input;return n}function nn(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ut(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}var wa=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,ma,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sn=S("$ZodError",wa),Os=S("$ZodError",wa,{Parent:Error});function va(e,t=(r)=>r.message){let r={},n=[];for(let s of e.issues)if(s.path.length>0)r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s));else n.push(t(s));return{formErrors:n,fieldErrors:r}}function ka(e,t){let r=t||function(o){return o.message},n={_errors:[]},s=(o)=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((a)=>s({issues:a}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;while(c<i.path.length){let l=i.path[c];if(c!==i.path.length-1)a[l]=a[l]||{_errors:[]};else a[l]=a[l]||{_errors:[]},a[l]._errors.push(r(i));a=a[l],c++}}};return s(e),n}var Sa=(e)=>(t,r,n,s)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Qe;if(i.issues.length){let a=new(s?.Err??e)(i.issues.map((c)=>qe(c,o,Oe())));throw _s(a,s?.callee),a}return i.value};var xa=(e)=>async(t,r,n,s)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;if(i.issues.length){let a=new(s?.Err??e)(i.issues.map((c)=>qe(c,o,Oe())));throw _s(a,s?.callee),a}return i.value};var Ts=(e)=>(t,r,n)=>{let s=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Qe;return o.issues.length?{success:!1,error:new(e??sn)(o.issues.map((i)=>qe(i,s,Oe())))}:{success:!0,data:o.value}},Ca=Ts(Os),$s=(e)=>async(t,r,n)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)o=await o;return o.issues.length?{success:!1,error:new e(o.issues.map((i)=>qe(i,s,Oe())))}:{success:!0,data:o.value}},_a=$s(Os);var Aa=/^[cC][^\s-]{8,}$/,Oa=/^[0-9a-z]+$/,Ta=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,$a=/^[0-9a-vA-V]{20}$/,Ea=/^[A-Za-z0-9]{27}$/,Na=/^[a-zA-Z0-9_-]{21}$/,Da=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Pa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Es=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Ia=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Fa(){return new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")}var La=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,za=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,qa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ka=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ra=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ns=/^[A-Za-z0-9_-]*$/,Ua=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Ma=/^\+(?:[0-9]){6,14}[0-9]$/,ja="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Za=new RegExp(`^${ja}$`);function Va(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Wa(e){return new RegExp(`^${Va(e)}$`)}function Ga(e){let t=Va({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${ja}T(?:${n})$`)}var Ja=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ba=/^\d+$/,Ha=/^-?\d+(?:\.\d+)?/i,Ya=/true|false/i,Qa=/null/i;var Xa=/^[^A-Z]*$/,ec=/^[^a-z]*$/;var he=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tc={number:"number",bigint:"bigint",object:"date"},Ps=S("$ZodCheckLessThan",(e,t)=>{he.init(e,t);let r=tc[typeof t.value];e._zod.onattach.push((n)=>{let s=n._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<o)if(t.inclusive)s.maximum=t.value;else s.exclusiveMaximum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Is=S("$ZodCheckGreaterThan",(e,t)=>{he.init(e,t);let r=tc[typeof t.value];e._zod.onattach.push((n)=>{let s=n._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>o)if(t.inclusive)s.minimum=t.value;else s.exclusiveMinimum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rc=S("$ZodCheckMultipleOf",(e,t)=>{he.init(e,t),e._zod.onattach.push((r)=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):fa(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),nc=S("$ZodCheckNumberFormat",(e,t)=>{he.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[s,o]=ba[t.format];e._zod.onattach.push((i)=>{let a=i._zod.bag;if(a.format=t.format,a.minimum=s,a.maximum=o,r)a.pattern=Ba}),e._zod.check=(i)=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});else i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}if(a<s)i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort});if(a>o)i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inst:e})}});var sc=S("$ZodCheckMaxLength",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<s)n._zod.bag.maximum=t.maximum}),e._zod.check=(n)=>{let s=n.value;if(s.length<=t.maximum)return;let i=nn(s);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),oc=S("$ZodCheckMinLength",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>s)n._zod.bag.minimum=t.minimum}),e._zod.check=(n)=>{let s=n.value;if(s.length>=t.minimum)return;let i=nn(s);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),ic=S("$ZodCheckLengthEquals",(e,t)=>{var r;he.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let s=n.value;return!en(s)&&s.length!==void 0}),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=(n)=>{let s=n.value,o=s.length;if(o===t.length)return;let i=nn(s),a=o>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),pr=S("$ZodCheckStringFormat",(e,t)=>{var r,n;if(he.init(e,t),e._zod.onattach.push((s)=>{let o=s._zod.bag;if(o.format=t.format,t.pattern)o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(s)=>{if(t.pattern.lastIndex=0,t.pattern.test(s.value))return;s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),ac=S("$ZodCheckRegex",(e,t)=>{pr.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),cc=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Xa),pr.init(e,t)}),lc=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ec),pr.init(e,t)}),uc=S("$ZodCheckIncludes",(e,t)=>{he.init(e,t);let r=vt(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((s)=>{let o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(s)=>{if(s.value.includes(t.includes,t.position))return;s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),pc=S("$ZodCheckStartsWith",(e,t)=>{he.init(e,t);let r=new RegExp(`^${vt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),dc=S("$ZodCheckEndsWith",(e,t)=>{he.init(e,t);let r=new RegExp(`.*${vt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var mc=S("$ZodCheckOverwrite",(e,t)=>{he.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Fs{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
167
167
  `).filter((o)=>o),n=Math.min(...r.map((o)=>o.length-o.trimStart().length)),s=r.map((o)=>o.slice(n)).map((o)=>" ".repeat(this.indent*2)+o);for(let o of s)this.content.push(o)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[""]).map((s)=>` ${s}`)];return new e(...t,n.join(`
168
- `))}}var mc={major:4,minor:0,patch:0};var Q=S("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=mc;let n=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))n.unshift(e);for(let s of n)for(let o of s._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,i,a)=>{let c=Kt(o),l;for(let p of i){if(p._zod.def.when){if(!p._zod.def.when(o))continue}else if(c)continue;let u=o.issues.length,d=p._zod.check(o);if(d instanceof Promise&&a?.async===!1)throw new Qe;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await d,o.issues.length===u)return;if(!c)c=Kt(o,u)});else{if(o.issues.length===u)continue;if(!c)c=Kt(o,u)}}if(l)return l.then(()=>o);return o};e._zod.run=(o,i)=>{let a=e._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new Qe;return a.then((c)=>s(c,n,i))}return s(a,n,i)}}e["~standard"]={validate:(s)=>{try{let o=Sa(e,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch(o){return xa(e,s).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),an=S("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Wa(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(s){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),X=S("$ZodStringFormat",(e,t)=>{ur.init(e,t),an.init(e,t)}),xc=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Na),X.init(e,t)}),Cc=S("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$s(n))}else t.pattern??(t.pattern=$s());X.init(e,t)}),_c=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Da),X.init(e,t)}),Ac=S("$ZodURL",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{try{let n=r.value,s=new URL(n),o=s.href;if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(s.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Ka.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(!n.endsWith("/")&&o.endsWith("/"))r.value=o.slice(0,-1);else r.value=o;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Oc=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Pa()),X.init(e,t)}),Tc=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=$a),X.init(e,t)}),$c=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ca),X.init(e,t)}),Ec=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_a),X.init(e,t)}),Nc=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Aa),X.init(e,t)}),Dc=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Oa),X.init(e,t)}),Pc=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ta),X.init(e,t)}),Ic=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Va(t)),X.init(e,t)}),Fc=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ma),X.init(e,t)}),Lc=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Za(t)),X.init(e,t)}),zc=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ea),X.init(e,t)}),qc=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ia),X.init(e,t),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.format="ipv4"})}),Kc=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Fa),X.init(e,t),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Rc=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=La),X.init(e,t)}),Uc=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=za),X.init(e,t),e._zod.check=(r)=>{let[n,s]=r.value.split("/");try{if(!s)throw Error();let o=Number(s);if(`${o}`!==s)throw Error();if(o<0||o>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Mc(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var jc=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=qa),X.init(e,t),e._zod.onattach.push((r)=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=(r)=>{if(Mc(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Oy(e){if(!Es.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Mc(r)}var Zc=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Es),X.init(e,t),e._zod.onattach.push((r)=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=(r)=>{if(Oy(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Vc=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ra),X.init(e,t)});function Ty(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));if("typ"in s&&s?.typ!=="JWT")return!1;if(!s.alg)return!1;if(t&&(!("alg"in s)||s.alg!==t))return!1;return!0}catch{return!1}}var Wc=S("$ZodJWT",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{if(Ty(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Ls=S("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ja,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let s=r.value;if(typeof s==="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let o=typeof s==="number"?Number.isNaN(s)?"NaN":!Number.isFinite(s)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),r}}),Gc=S("$ZodNumber",(e,t)=>{tc.init(e,t),Ls.init(e,t)}),Jc=S("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=Ba,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(o){}let s=r.value;if(typeof s==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}});var Bc=S("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=Ha,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let s=r.value;if(s===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),r}});var Hc=S("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=(r)=>r}),Yc=S("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function fc(e,t,r){if(e.issues.length)t.issues.push(...Je(r,e.issues));t.value[r]=e.value}var Qc=S("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);let o=[];for(let i=0;i<s.length;i++){let a=s[i],c=t.element._zod.run({value:a,issues:[]},n);if(c instanceof Promise)o.push(c.then((l)=>fc(l,r,i)));else fc(c,r,i)}if(o.length)return Promise.all(o).then(()=>r);return r}});function on(e,t,r){if(e.issues.length)t.issues.push(...Je(r,e.issues));t.value[r]=e.value}function hc(e,t,r,n){if(e.issues.length)if(n[r]===void 0)if(r in n)t.value[r]=void 0;else t.value[r]=e.value;else t.issues.push(...Je(r,e.issues));else if(e.value===void 0){if(r in n)t.value[r]=void 0}else t.value[r]=e.value}var Xc=S("$ZodObject",(e,t)=>{Q.init(e,t);let r=Xr(()=>{let u=Object.keys(t.shape);for(let h of u)if(!(t.shape[h]instanceof Q))throw Error(`Invalid element at key "${h}": expected a Zod schema`);let d=ha(t.shape);return{shape:t.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(d)}});Y(e._zod,"propValues",()=>{let u=t.shape,d={};for(let h in u){let b=u[h]._zod;if(b.values){d[h]??(d[h]=new Set);for(let g of b.values)d[h].add(g)}}return d});let n=(u)=>{let d=new Is(["shape","payload","ctx"]),h=r.value,b=(N)=>{let x=qt(N);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};d.write("const input = payload.value;");let g=Object.create(null),w=0;for(let N of h.keys)g[N]=`key_${w++}`;d.write("const newResult = {}");for(let N of h.keys)if(h.optionalKeys.has(N)){let x=g[N];d.write(`const ${x} = ${b(N)};`);let D=qt(N);d.write(`
168
+ `))}}var hc={major:4,minor:0,patch:0};var Q=S("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hc;let n=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))n.unshift(e);for(let s of n)for(let o of s._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(o,i,a)=>{let c=Rt(o),l;for(let u of i){if(u._zod.def.when){if(!u._zod.def.when(o))continue}else if(c)continue;let p=o.issues.length,d=u._zod.check(o);if(d instanceof Promise&&a?.async===!1)throw new Qe;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await d,o.issues.length===p)return;if(!c)c=Rt(o,p)});else{if(o.issues.length===p)continue;if(!c)c=Rt(o,p)}}if(l)return l.then(()=>o);return o};e._zod.run=(o,i)=>{let a=e._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new Qe;return a.then((c)=>s(c,n,i))}return s(a,n,i)}}e["~standard"]={validate:(s)=>{try{let o=Ca(e,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch(o){return _a(e,s).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),an=S("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ja(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(s){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),X=S("$ZodStringFormat",(e,t)=>{pr.init(e,t),an.init(e,t)}),_c=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Pa),X.init(e,t)}),Ac=S("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Es(n))}else t.pattern??(t.pattern=Es());X.init(e,t)}),Oc=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ia),X.init(e,t)}),Tc=S("$ZodURL",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{try{let n=r.value,s=new URL(n),o=s.href;if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(s.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Ua.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(!n.endsWith("/")&&o.endsWith("/"))r.value=o.slice(0,-1);else r.value=o;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),$c=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fa()),X.init(e,t)}),Ec=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Na),X.init(e,t)}),Nc=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Aa),X.init(e,t)}),Dc=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Oa),X.init(e,t)}),Pc=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ta),X.init(e,t)}),Ic=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=$a),X.init(e,t)}),Fc=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ea),X.init(e,t)}),Lc=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ga(t)),X.init(e,t)}),zc=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Za),X.init(e,t)}),qc=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Wa(t)),X.init(e,t)}),Kc=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Da),X.init(e,t)}),Rc=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=La),X.init(e,t),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.format="ipv4"})}),Uc=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=za),X.init(e,t),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Mc=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qa),X.init(e,t)}),jc=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ka),X.init(e,t),e._zod.check=(r)=>{let[n,s]=r.value.split("/");try{if(!s)throw Error();let o=Number(s);if(`${o}`!==s)throw Error();if(o<0||o>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Zc(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Vc=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ra),X.init(e,t),e._zod.onattach.push((r)=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=(r)=>{if(Zc(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Iy(e){if(!Ns.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Zc(r)}var Wc=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ns),X.init(e,t),e._zod.onattach.push((r)=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=(r)=>{if(Iy(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Gc=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ma),X.init(e,t)});function Fy(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));if("typ"in s&&s?.typ!=="JWT")return!1;if(!s.alg)return!1;if(t&&(!("alg"in s)||s.alg!==t))return!1;return!0}catch{return!1}}var Jc=S("$ZodJWT",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{if(Fy(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var zs=S("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ha,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let s=r.value;if(typeof s==="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let o=typeof s==="number"?Number.isNaN(s)?"NaN":!Number.isFinite(s)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),r}}),Bc=S("$ZodNumber",(e,t)=>{nc.init(e,t),zs.init(e,t)}),Hc=S("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=Ya,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(o){}let s=r.value;if(typeof s==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}});var Yc=S("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=Qa,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let s=r.value;if(s===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:s,inst:e}),r}});var Qc=S("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=(r)=>r}),Xc=S("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function gc(e,t,r){if(e.issues.length)t.issues.push(...Je(r,e.issues));t.value[r]=e.value}var el=S("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);let o=[];for(let i=0;i<s.length;i++){let a=s[i],c=t.element._zod.run({value:a,issues:[]},n);if(c instanceof Promise)o.push(c.then((l)=>gc(l,r,i)));else gc(c,r,i)}if(o.length)return Promise.all(o).then(()=>r);return r}});function on(e,t,r){if(e.issues.length)t.issues.push(...Je(r,e.issues));t.value[r]=e.value}function yc(e,t,r,n){if(e.issues.length)if(n[r]===void 0)if(r in n)t.value[r]=void 0;else t.value[r]=e.value;else t.issues.push(...Je(r,e.issues));else if(e.value===void 0){if(r in n)t.value[r]=void 0}else t.value[r]=e.value}var tl=S("$ZodObject",(e,t)=>{Q.init(e,t);let r=Xr(()=>{let p=Object.keys(t.shape);for(let g of p)if(!(t.shape[g]instanceof Q))throw Error(`Invalid element at key "${g}": expected a Zod schema`);let d=ya(t.shape);return{shape:t.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(d)}});Y(e._zod,"propValues",()=>{let p=t.shape,d={};for(let g in p){let b=p[g]._zod;if(b.values){d[g]??(d[g]=new Set);for(let y of b.values)d[g].add(y)}}return d});let n=(p)=>{let d=new Fs(["shape","payload","ctx"]),g=r.value,b=(N)=>{let x=Kt(N);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};d.write("const input = payload.value;");let y=Object.create(null),w=0;for(let N of g.keys)y[N]=`key_${w++}`;d.write("const newResult = {}");for(let N of g.keys)if(g.optionalKeys.has(N)){let x=y[N];d.write(`const ${x} = ${b(N)};`);let D=Kt(N);d.write(`
169
169
  if (${x}.issues.length) {
170
170
  if (input[${D}] === undefined) {
171
171
  if (${D} in input) {
@@ -184,24 +184,24 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
184
184
  } else {
185
185
  newResult[${D}] = ${x}.value;
186
186
  }
187
- `)}else{let x=g[N];d.write(`const ${x} = ${b(N)};`),d.write(`
187
+ `)}else{let x=y[N];d.write(`const ${x} = ${b(N)};`),d.write(`
188
188
  if (${x}.issues.length) payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
189
189
  ...iss,
190
- path: iss.path ? [${qt(N)}, ...iss.path] : [${qt(N)}]
191
- })));`),d.write(`newResult[${qt(N)}] = ${x}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");let T=d.compile();return(N,x)=>T(u,N,x)},s,o=cr,i=!Yr.jitless,c=i&&ma.value,l=t.catchall,p;e._zod.parse=(u,d)=>{p??(p=r.value);let h=u.value;if(!o(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;let b=[];if(i&&c&&d?.async===!1&&d.jitless!==!0){if(!s)s=n(t.shape);u=s(u,d)}else{u.value={};let x=p.shape;for(let D of p.keys){let P=x[D],L=P._zod.run({value:h[D],issues:[]},d),K=P._zod.optin==="optional"&&P._zod.optout==="optional";if(L instanceof Promise)b.push(L.then((E)=>K?hc(E,u,D,h):on(E,u,D)));else if(K)hc(L,u,D,h);else on(L,u,D)}}if(!l)return b.length?Promise.all(b).then(()=>u):u;let g=[],w=p.keySet,T=l._zod,N=T.def.type;for(let x of Object.keys(h)){if(w.has(x))continue;if(N==="never"){g.push(x);continue}let D=T.run({value:h[x],issues:[]},d);if(D instanceof Promise)b.push(D.then((P)=>on(P,u,x)));else on(D,u,x)}if(g.length)u.issues.push({code:"unrecognized_keys",keys:g,input:h,inst:e});if(!b.length)return u;return Promise.all(b).then(()=>u)}});function gc(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((o)=>ze(o,n,Oe())))}),t}var zs=S("$ZodUnion",(e,t)=>{Q.init(e,t),Y(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),Y(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),Y(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),Y(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>tn(n.source)).join("|")})$`)}return}),e._zod.parse=(r,n)=>{let s=!1,o=[];for(let i of t.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}if(!s)return gc(o,r,e,n);return Promise.all(o).then((i)=>gc(i,r,e,n))}}),el=S("$ZodDiscriminatedUnion",(e,t)=>{zs.init(e,t);let r=e._zod.parse;Y(e._zod,"propValues",()=>{let s={};for(let o of t.options){let i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,c]of Object.entries(i)){if(!s[a])s[a]=new Set;for(let l of c)s[a].add(l)}}return s});let n=Xr(()=>{let s=t.options,o=new Map;for(let i of s){let a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(o.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});e._zod.parse=(s,o)=>{let i=s.value;if(!cr(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;let a=n.value.get(i?.[t.discriminator]);if(a)return a._zod.run(s,o);if(t.unionFallback)return r(s,o);return s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),s}}),tl=S("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value,o=t.left._zod.run({value:s,issues:[]},n),i=t.right._zod.run({value:s,issues:[]},n);if(o instanceof Promise||i instanceof Promise)return Promise.all([o,i]).then(([c,l])=>yc(r,c,l));return yc(r,o,i)}});function Fs(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(lr(e)&&lr(t)){let r=Object.keys(t),n=Object.keys(e).filter((o)=>r.indexOf(o)!==-1),s={...e,...t};for(let o of n){let i=Fs(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[n],i=Fs(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function yc(e,t,r){if(t.issues.length)e.issues.push(...t.issues);if(r.issues.length)e.issues.push(...r.issues);if(Kt(e))return e;let n=Fs(t.value,r.value);if(!n.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var rl=S("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value;if(!lr(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;let o=[];if(t.keyType._zod.values){let i=t.keyType._zod.values;r.value={};for(let c of i)if(typeof c==="string"||typeof c==="number"||typeof c==="symbol"){let l=t.valueType._zod.run({value:s[c],issues:[]},n);if(l instanceof Promise)o.push(l.then((p)=>{if(p.issues.length)r.issues.push(...Je(c,p.issues));r.value[c]=p.value}));else{if(l.issues.length)r.issues.push(...Je(c,l.issues));r.value[c]=l.value}}let a;for(let c in s)if(!i.has(c))a=a??[],a.push(c);if(a&&a.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(s)){if(i==="__proto__")continue;let a=t.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map((l)=>ze(l,n,Oe())),input:i,path:[i],inst:e}),r.value[a.value]=a.value;continue}let c=t.valueType._zod.run({value:s[i],issues:[]},n);if(c instanceof Promise)o.push(c.then((l)=>{if(l.issues.length)r.issues.push(...Je(i,l.issues));r.value[a.value]=l.value}));else{if(c.issues.length)r.issues.push(...Je(i,c.issues));r.value[a.value]=c.value}}}if(o.length)return Promise.all(o).then(()=>r);return r}});var nl=S("$ZodEnum",(e,t)=>{Q.init(e,t);let r=ua(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter((n)=>fa.has(typeof n)).map((n)=>typeof n==="string"?vt(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let o=n.value;if(e._zod.values.has(o))return n;return n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),sl=S("$ZodLiteral",(e,t)=>{Q.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?vt(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let s=r.value;if(e._zod.values.has(s))return r;return r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var ol=S("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then((i)=>(r.value=i,r));if(s instanceof Promise)throw new Qe;return r.value=s,r}}),il=S("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Y(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tn(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional")return t.innerType._zod.run(r,n);if(r.value===void 0)return r;return t.innerType._zod.run(r,n)}}),al=S("$ZodNullable",(e,t)=>{Q.init(e,t),Y(e._zod,"optin",()=>t.innerType._zod.optin),Y(e._zod,"optout",()=>t.innerType._zod.optout),Y(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tn(r.source)}|null)$`):void 0}),Y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),cl=S("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>bc(o,t));return bc(s,t)}});function bc(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var ll=S("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),ul=S("$ZodNonOptional",(e,t)=>{Q.init(e,t),Y(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>wc(o,e));return wc(s,e)}});function wc(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var pl=S("$ZodCatch",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"optout",()=>t.innerType._zod.optout),Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>{if(r.value=o.value,o.issues.length)r.value=t.catchValue({...r,error:{issues:o.issues.map((i)=>ze(i,n,Oe()))},input:r.value}),r.issues=[];return r});if(r.value=s.value,s.issues.length)r.value=t.catchValue({...r,error:{issues:s.issues.map((o)=>ze(o,n,Oe()))},input:r.value}),r.issues=[];return r}});var dl=S("$ZodPipe",(e,t)=>{Q.init(e,t),Y(e._zod,"values",()=>t.in._zod.values),Y(e._zod,"optin",()=>t.in._zod.optin),Y(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let s=t.in._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>vc(o,t,n));return vc(s,t,n)}});function vc(e,t,r){if(Kt(e))return e;return t.out._zod.run({value:e.value,issues:e.issues},r)}var ml=S("$ZodReadonly",(e,t)=>{Q.init(e,t),Y(e._zod,"propValues",()=>t.innerType._zod.propValues),Y(e._zod,"values",()=>t.innerType._zod.values),Y(e._zod,"optin",()=>t.innerType._zod.optin),Y(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then(kc);return kc(s)}});function kc(e){return e.value=Object.freeze(e.value),e}var fl=S("$ZodCustom",(e,t)=>{he.init(e,t),Q.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then((o)=>Sc(o,r,n,e));Sc(s,r,n,e);return}});function Sc(e,t,r,n){if(!e){let s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)s.params=n._zod.def.params;t.issues.push(Rt(s))}}var $y=(e)=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},Ey=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(n)=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${$y(n.input)}`;case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${_s(n.values[0])}`;return`Invalid option: expected one of ${xs(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",o=t(n.origin);if(o)return`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",o=t(n.origin);if(o)return`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${o.unit}`;return`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${xs(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function qs(){return{localeError:Ey()}}var N$=Symbol("ZodOutput"),D$=Symbol("ZodInput");class hl{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r){if(this._idmap.has(r.id))throw Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Ny(){return new hl}var pr=Ny();function gl(e,t){return new e({type:"string",...q(t)})}function yl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...q(t)})}function Ks(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...q(t)})}function Rs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...q(t)})}function bl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(t)})}function wl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(t)})}function kl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...q(t)})}function Sl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...q(t)})}function xl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(t)})}function Cl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...q(t)})}function _l(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(t)})}function Al(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...q(t)})}function Ol(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...q(t)})}function Tl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(t)})}function $l(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(t)})}function El(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(t)})}function Nl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(t)})}function Dl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(t)})}function Pl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...q(t)})}function Il(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...q(t)})}function Fl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...q(t)})}function Ll(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...q(t)})}function zl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(t)})}function ql(e,t){return new e({type:"string",format:"date",check:"string_format",...q(t)})}function Kl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...q(t)})}function Rl(e,t){return new e({type:"string",format:"duration",check:"string_format",...q(t)})}function Ul(e,t){return new e({type:"number",checks:[],...q(t)})}function Ml(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...q(t)})}function jl(e,t){return new e({type:"boolean",...q(t)})}function Zl(e,t){return new e({type:"null",...q(t)})}function Vl(e){return new e({type:"unknown"})}function Wl(e,t){return new e({type:"never",...q(t)})}function cn(e,t){return new Ds({check:"less_than",...q(t),value:e,inclusive:!1})}function dr(e,t){return new Ds({check:"less_than",...q(t),value:e,inclusive:!0})}function ln(e,t){return new Ps({check:"greater_than",...q(t),value:e,inclusive:!1})}function mr(e,t){return new Ps({check:"greater_than",...q(t),value:e,inclusive:!0})}function un(e,t){return new ec({check:"multiple_of",...q(t),value:e})}function pn(e,t){return new rc({check:"max_length",...q(t),maximum:e})}function Ut(e,t){return new nc({check:"min_length",...q(t),minimum:e})}function dn(e,t){return new sc({check:"length_equals",...q(t),length:e})}function Us(e,t){return new oc({check:"string_format",format:"regex",...q(t),pattern:e})}function Ms(e){return new ic({check:"string_format",format:"lowercase",...q(e)})}function js(e){return new ac({check:"string_format",format:"uppercase",...q(e)})}function Zs(e,t){return new cc({check:"string_format",format:"includes",...q(t),includes:e})}function Vs(e,t){return new lc({check:"string_format",format:"starts_with",...q(t),prefix:e})}function Ws(e,t){return new uc({check:"string_format",format:"ends_with",...q(t),suffix:e})}function kt(e){return new pc({check:"overwrite",tx:e})}function Gs(e){return kt((t)=>t.normalize(e))}function Js(){return kt((e)=>e.trim())}function Bs(){return kt((e)=>e.toLowerCase())}function Hs(){return kt((e)=>e.toUpperCase())}function Gl(e,t,r){return new e({type:"array",element:t,...q(r)})}function Jl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...q(r)})}var Bl=S("ZodISODateTime",(e,t)=>{Ic.init(e,t),ee.init(e,t)});function Ys(e){return zl(Bl,e)}var Hl=S("ZodISODate",(e,t)=>{Fc.init(e,t),ee.init(e,t)});function Qs(e){return ql(Hl,e)}var Yl=S("ZodISOTime",(e,t)=>{Lc.init(e,t),ee.init(e,t)});function Xs(e){return Kl(Yl,e)}var Ql=S("ZodISODuration",(e,t)=>{zc.init(e,t),ee.init(e,t)});function eo(e){return Rl(Ql,e)}var Xl=(e,t)=>{sn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>wa(e,r)},flatten:{value:(r)=>ba(e,r)},addIssue:{value:(r)=>e.issues.push(r)},addIssues:{value:(r)=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},oE=S("ZodError",Xl),gr=S("ZodError",Xl,{Parent:Error});var eu=va(gr),tu=ka(gr),ru=Os(gr),nu=Ts(gr);var re=S("ZodType",(e,t)=>(Q.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Ge(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>eu(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>ru(e,r,n),e.parseAsync=async(r,n)=>tu(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>nu(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Nb(r,n)),e.superRefine=(r)=>e.check(Db(r)),e.overwrite=(r)=>e.check(kt(r)),e.optional=()=>iu(e),e.nullable=()=>au(e),e.nullish=()=>iu(au(e)),e.nonoptional=(r)=>xb(e,r),e.array=()=>Z(e),e.or=(r)=>br([e,r]),e.and=(r)=>fb(e,r),e.transform=(r)=>ro(e,du(r)),e.default=(r)=>vb(e,r),e.prefault=(r)=>Sb(e,r),e.catch=(r)=>_b(e,r),e.pipe=(r)=>ro(e,r),e.readonly=()=>Tb(e),e.describe=(r)=>{let n=e.clone();return pr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return pr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return pr.get(e);let n=e.clone();return pr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),cu=S("_ZodString",(e,t)=>{an.init(e,t),re.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Us(...n)),e.includes=(...n)=>e.check(Zs(...n)),e.startsWith=(...n)=>e.check(Vs(...n)),e.endsWith=(...n)=>e.check(Ws(...n)),e.min=(...n)=>e.check(Ut(...n)),e.max=(...n)=>e.check(pn(...n)),e.length=(...n)=>e.check(dn(...n)),e.nonempty=(...n)=>e.check(Ut(1,...n)),e.lowercase=(n)=>e.check(Ms(n)),e.uppercase=(n)=>e.check(js(n)),e.trim=()=>e.check(Js()),e.normalize=(...n)=>e.check(Gs(...n)),e.toLowerCase=()=>e.check(Bs()),e.toUpperCase=()=>e.check(Hs())}),Ry=S("ZodString",(e,t)=>{an.init(e,t),cu.init(e,t),e.email=(r)=>e.check(yl(Uy,r)),e.url=(r)=>e.check(kl(jy,r)),e.jwt=(r)=>e.check(Ll(sb,r)),e.emoji=(r)=>e.check(Sl(Zy,r)),e.guid=(r)=>e.check(Ks(su,r)),e.uuid=(r)=>e.check(Rs(yr,r)),e.uuidv4=(r)=>e.check(bl(yr,r)),e.uuidv6=(r)=>e.check(wl(yr,r)),e.uuidv7=(r)=>e.check(vl(yr,r)),e.nanoid=(r)=>e.check(xl(Vy,r)),e.guid=(r)=>e.check(Ks(su,r)),e.cuid=(r)=>e.check(Cl(Wy,r)),e.cuid2=(r)=>e.check(_l(Gy,r)),e.ulid=(r)=>e.check(Al(Jy,r)),e.base64=(r)=>e.check(Pl(tb,r)),e.base64url=(r)=>e.check(Il(rb,r)),e.xid=(r)=>e.check(Ol(By,r)),e.ksuid=(r)=>e.check(Tl(Hy,r)),e.ipv4=(r)=>e.check($l(Yy,r)),e.ipv6=(r)=>e.check(El(Qy,r)),e.cidrv4=(r)=>e.check(Nl(Xy,r)),e.cidrv6=(r)=>e.check(Dl(eb,r)),e.e164=(r)=>e.check(Fl(nb,r)),e.datetime=(r)=>e.check(Ys(r)),e.date=(r)=>e.check(Qs(r)),e.time=(r)=>e.check(Xs(r)),e.duration=(r)=>e.check(eo(r))});function R(e){return gl(Ry,e)}var ee=S("ZodStringFormat",(e,t)=>{X.init(e,t),cu.init(e,t)}),Uy=S("ZodEmail",(e,t)=>{_c.init(e,t),ee.init(e,t)});var su=S("ZodGUID",(e,t)=>{xc.init(e,t),ee.init(e,t)});var yr=S("ZodUUID",(e,t)=>{Cc.init(e,t),ee.init(e,t)});function My(e){return Rs(yr,e)}var jy=S("ZodURL",(e,t)=>{Ac.init(e,t),ee.init(e,t)});var Zy=S("ZodEmoji",(e,t)=>{Oc.init(e,t),ee.init(e,t)});var Vy=S("ZodNanoID",(e,t)=>{Tc.init(e,t),ee.init(e,t)});var Wy=S("ZodCUID",(e,t)=>{$c.init(e,t),ee.init(e,t)});var Gy=S("ZodCUID2",(e,t)=>{Ec.init(e,t),ee.init(e,t)});var Jy=S("ZodULID",(e,t)=>{Nc.init(e,t),ee.init(e,t)});var By=S("ZodXID",(e,t)=>{Dc.init(e,t),ee.init(e,t)});var Hy=S("ZodKSUID",(e,t)=>{Pc.init(e,t),ee.init(e,t)});var Yy=S("ZodIPv4",(e,t)=>{qc.init(e,t),ee.init(e,t)});var Qy=S("ZodIPv6",(e,t)=>{Kc.init(e,t),ee.init(e,t)});var Xy=S("ZodCIDRv4",(e,t)=>{Rc.init(e,t),ee.init(e,t)});var eb=S("ZodCIDRv6",(e,t)=>{Uc.init(e,t),ee.init(e,t)});var tb=S("ZodBase64",(e,t)=>{jc.init(e,t),ee.init(e,t)});var rb=S("ZodBase64URL",(e,t)=>{Zc.init(e,t),ee.init(e,t)});var nb=S("ZodE164",(e,t)=>{Vc.init(e,t),ee.init(e,t)});var sb=S("ZodJWT",(e,t)=>{Wc.init(e,t),ee.init(e,t)});var lu=S("ZodNumber",(e,t)=>{Ls.init(e,t),re.init(e,t),e.gt=(n,s)=>e.check(ln(n,s)),e.gte=(n,s)=>e.check(mr(n,s)),e.min=(n,s)=>e.check(mr(n,s)),e.lt=(n,s)=>e.check(cn(n,s)),e.lte=(n,s)=>e.check(dr(n,s)),e.max=(n,s)=>e.check(dr(n,s)),e.int=(n)=>e.check(ou(n)),e.safe=(n)=>e.check(ou(n)),e.positive=(n)=>e.check(ln(0,n)),e.nonnegative=(n)=>e.check(mr(0,n)),e.negative=(n)=>e.check(cn(0,n)),e.nonpositive=(n)=>e.check(dr(0,n)),e.multipleOf=(n,s)=>e.check(un(n,s)),e.step=(n,s)=>e.check(un(n,s)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});function ie(e){return Ul(lu,e)}var ob=S("ZodNumberFormat",(e,t)=>{Gc.init(e,t),lu.init(e,t)});function ou(e){return Ml(ob,e)}var ib=S("ZodBoolean",(e,t)=>{Jc.init(e,t),re.init(e,t)});function oe(e){return jl(ib,e)}var ab=S("ZodNull",(e,t)=>{Bc.init(e,t),re.init(e,t)});function cb(e){return Zl(ab,e)}var lb=S("ZodUnknown",(e,t)=>{Hc.init(e,t),re.init(e,t)});function mn(){return Vl(lb)}var ub=S("ZodNever",(e,t)=>{Yc.init(e,t),re.init(e,t)});function Te(e){return Wl(ub,e)}var pb=S("ZodArray",(e,t)=>{Qc.init(e,t),re.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Ut(r,n)),e.nonempty=(r)=>e.check(Ut(1,r)),e.max=(r,n)=>e.check(pn(r,n)),e.length=(r,n)=>e.check(dn(r,n)),e.unwrap=()=>e.element});function Z(e,t){return Gl(pb,e,t)}var uu=S("ZodObject",(e,t)=>{Xc.init(e,t),re.init(e,t),Y(e,"shape",()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=(r)=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:mn()}),e.loose=()=>e.clone({...e._zod.def,catchall:mn()}),e.strict=()=>e.clone({...e._zod.def,catchall:Te()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=(r)=>Sy(e,r),e.merge=(r)=>xy(e,r),e.pick=(r)=>vy(e,r),e.omit=(r)=>ky(e,r),e.partial=(...r)=>Cy(mu,e,r[0]),e.required=(...r)=>_y(fu,e,r[0])});function ne(e,t){let r={type:"object",get shape(){return rn(this,"shape",{...e}),this.shape},...q(t)};return new uu(r)}function j(e,t){return new uu({type:"object",get shape(){return rn(this,"shape",{...e}),this.shape},catchall:Te(),...q(t)})}var pu=S("ZodUnion",(e,t)=>{zs.init(e,t),re.init(e,t),e.options=t.options});function br(e,t){return new pu({type:"union",options:e,...q(t)})}var db=S("ZodDiscriminatedUnion",(e,t)=>{pu.init(e,t),el.init(e,t)});function wr(e,t,r){return new db({type:"union",options:t,discriminator:e,...q(r)})}var mb=S("ZodIntersection",(e,t)=>{tl.init(e,t),re.init(e,t)});function fb(e,t){return new mb({type:"intersection",left:e,right:t})}var hb=S("ZodRecord",(e,t)=>{rl.init(e,t),re.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function no(e,t,r){return new hb({type:"record",keyType:e,valueType:t,...q(r)})}var to=S("ZodEnum",(e,t)=>{nl.init(e,t),re.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new to({...t,checks:[],...q(s),entries:o})},e.exclude=(n,s)=>{let o={...t.entries};for(let i of n)if(r.has(i))delete o[i];else throw Error(`Key ${i} not found in enum`);return new to({...t,checks:[],...q(s),entries:o})}});function H(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new to({type:"enum",entries:r,...q(t)})}var gb=S("ZodLiteral",(e,t)=>{sl.init(e,t),re.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function te(e,t){return new gb({type:"literal",values:Array.isArray(e)?e:[e],...q(t)})}var yb=S("ZodTransform",(e,t)=>{ol.init(e,t),re.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Rt(o,r.value,t));else{let i=o;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),r.issues.push(Rt(i))}};let s=t.transform(r.value,r);if(s instanceof Promise)return s.then((o)=>(r.value=o,r));return r.value=s,r}});function du(e){return new yb({type:"transform",transform:e})}var mu=S("ZodOptional",(e,t)=>{il.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function iu(e){return new mu({type:"optional",innerType:e})}var bb=S("ZodNullable",(e,t)=>{al.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function au(e){return new bb({type:"nullable",innerType:e})}var wb=S("ZodDefault",(e,t)=>{cl.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vb(e,t){return new wb({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():t}})}var kb=S("ZodPrefault",(e,t)=>{ll.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Sb(e,t){return new kb({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():t}})}var fu=S("ZodNonOptional",(e,t)=>{ul.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function xb(e,t){return new fu({type:"nonoptional",innerType:e,...q(t)})}var Cb=S("ZodCatch",(e,t)=>{pl.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _b(e,t){return new Cb({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Ab=S("ZodPipe",(e,t)=>{dl.init(e,t),re.init(e,t),e.in=t.in,e.out=t.out});function ro(e,t){return new Ab({type:"pipe",in:e,out:t})}var Ob=S("ZodReadonly",(e,t)=>{ml.init(e,t),re.init(e,t)});function Tb(e){return new Ob({type:"readonly",innerType:e})}var $b=S("ZodCustom",(e,t)=>{fl.init(e,t),re.init(e,t)});function Eb(e){let t=new he({check:"custom"});return t._zod.check=e,t}function Nb(e,t={}){return Jl($b,e,t)}function Db(e){let t=Eb((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(Rt(n,r.value,t._zod.def));else{let s=n;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),r.issues.push(Rt(s))}},e(r.value,r)));return t}function hu(e,t){return ro(du(e),t)}Oe(qs());var so=12,oo={min:8,max:240,default:28};function St(e){try{return Intl.getCanonicalLocales(e.trim())[0]}catch{return}}var bu=R().overwrite((e)=>St(e)??e).refine((e)=>St(e)===e,"Use a valid locale tag such as en-US or ar-SA"),wu=(e)=>Object.keys(e).length>0,io=(e)=>no(bu,e).refine(wu,"Add at least one locale"),ao=(e)=>no(bu,e.nullable()).refine(wu,"Add at least one locale"),co=(e=R().trim().min(1))=>io(e),be=co(),fn=ao(R().trim().min(1)),gu=(e)=>e.split("-")[0].toLowerCase();function yu(e,t){if(!e)return;let r=St(e)??e;return t.find((n)=>n===r)??t.find((n)=>gu(n)===gu(r))}function vu(e,t,r){let n=Object.keys(e),s=yu(t,n)??yu(r,n)??n[0];return s===void 0?void 0:e[s]}var De=j({threadId:R().trim().min(1).max(200),runId:R().trim().min(1).max(200),toolCallId:R().trim().min(1).max(200)});var Pb=["layout-dashboard","chart-column","chart-line","table","chart-pie","activity","badge-dollar-sign","banknote","book-open","briefcase","building-2","calendar-days","circle-dollar-sign","clipboard-list","credit-card","database","factory","gauge","goal","landmark","map","package","receipt","shopping-cart","sparkles","store","target","trending-up","users","wallet"],Ib=["published","draft"],ue=R().trim().nonempty("Identity is required").regex(/^[a-z0-9-]+$/,"Identity must use only lowercase ASCII letters, digits, and dashes"),Fb=R().trim().nonempty("User group key is required").regex(/^[a-zA-Z0-9_-]+$/,"User group key must use only letters, digits, underscores, and dashes"),uN=j({view:H(["summary","full"]).optional(),editableOnly:oe().optional(),sharedWithGroup:Fb.optional(),sort:te("recently-pinned").optional(),hidden:H(["include","only"]).optional(),limit:ie().int().min(1).max(100).optional(),cursor:R().min(1).max(4096).optional()}),pN=ne({nextCursor:R().nullable().optional()}),dN=j({agentContext:De.optional(),title:be,visualisationKeys:Z(ue).max(10).optional()}),Su=H(Pb),mN=j({dashboardId:My(),dashboardKey:ue,title:be,icon:Su,tabs:Z(j({tabKey:ue,title:be,position:ie().int().nonnegative()})),capabilities:j({canUpdate:oe(),canDelete:oe(),canShare:oe()}),draftDashboardKey:R().nullable(),draftOfDashboardKey:R().nullable(),canPersonalise:oe(),canResetToDefault:oe(),personalCopyDashboardKey:R().nullable()}),uo=j({visualisationKey:ue,dashboardKey:ue,tabKey:ue}),fN=j({agentContext:De.optional(),pins:Z(uo).min(1).max(100),removeIncompatibleFilters:oe().default(!1)}).superRefine(({pins:e},t)=>{let r=new Set;e.forEach((n,s)=>{let o=JSON.stringify([n.visualisationKey,n.dashboardKey,n.tabKey]);if(r.has(o))t.addIssue({code:"custom",path:["pins",s],message:"Duplicate pin destination"});r.add(o)})}),hN=j({dashboardKey:ue,title:be,removedFilterKeys:Z(R())}),gN=wr("status",[j({pin:uo,status:te("pinned"),dashboardKey:ue,visualisationKey:ue,dashboardVisualisationId:R(),tabKey:ue}),j({pin:uo,status:H(["failed","unknown"]),error:R(),removedFilterKeys:Z(R()).optional()})]),xu=H(Ib),Cu=ie().int().nonnegative(),Lb=R().uuid(),_u=co(R()),zb=Z(R().trim().nonempty("Filter key is required")),qb=["today","yesterday","this-week","last-week","this-month","last-month","last-7-days","last-30-days","this-quarter","last-quarter","this-year","last-year"],po=R().trim().nonempty("Filter key is required"),Kb=(e)=>j({value:e,inclusive:oe()}),Rb=hr.datetime({offset:!0,precision:0}),ku=(e,t)=>{let r=Kb(t);return j({key:po,kind:te(e),from:r.optional(),to:r.optional()}).refine((n)=>n.from||n.to,{message:"At least one temporal filter bound is required"}).refine((n)=>!n.from||!n.to||Date.parse(n.from.value)<Date.parse(n.to.value)||Date.parse(n.from.value)===Date.parse(n.to.value)&&n.from.inclusive&&n.to.inclusive,{message:"Temporal filter range is invalid"})},Ub=br([j({key:po,kind:te("dimension"),values:Z(R()).min(1)}),ku("date",hr.date()),ku("timestamp",Rb),j({key:po,kind:H(["date","timestamp"]),preset:H(qb),weekStartsOn:ie().int().min(0).max(6).optional()}).check((e)=>{let t=e.value.preset==="this-week"||e.value.preset==="last-week";if(t!==(e.value.weekStartsOn!==void 0))e.issues.push({code:"custom",input:e.value.weekStartsOn,path:["weekStartsOn"],message:t?"weekStartsOn is required for week presets":"weekStartsOn is only allowed for week presets"})})]),Mb=j({key:ue,title:be,filters:Z(Ub)}),jb=Z(Mb),Zb=R().trim().url("Note link must be a valid URL").refine((e)=>{try{return new URL(e).protocol==="http:"||new URL(e).protocol==="https:"}catch{return!1}},"Note link must use http or https"),Vb=j({insert:R(),attributes:j({bold:oe().optional(),italic:oe().optional(),underline:oe().optional(),header:br([te(1),te(2),te(3)]).optional(),list:H(["bullet","ordered"]).optional(),align:H(["left","center","right"]).optional(),link:Zb.optional()}).optional()}),Au=j({version:te(1),delta:j({ops:Z(Vb).min(1)})}),Ou=io(Au),yN=j({agentContext:De.optional(),content:Ou}),bN=j({agentContext:De.optional(),content:ao(Au)});var Tu={gridX:ie().int().min(0),gridY:ie().int().min(0),gridW:ie().int().positive(),gridH:ie().int().positive()},Wb=j({noteKey:ue,content:Ou,...Tu}),Gb=j({tileId:ue,visualisationKey:ue,...Tu}),Jb=j({tabKey:ue,title:_u,visualisations:Z(Gb),notes:Z(Wb)}),$u=j({title:_u,icon:Su,filterKeys:zb,filterViews:jb.optional().default([]),defaultFilterViewKey:ue.nullable().optional().default(null),tabs:Z(Jb).min(1)}),wN=$u.superRefine((e,t)=>Nu(e,t,!1)),Eu=$u.superRefine((e,t)=>Nu(e,t,!0)),vN=j({agentContext:De.optional(),baseVersion:Cu,mutationId:Lb,kind:xu,state:Eu}),lo=j({clientId:ue,savedId:ue}),Bb=j({tabKeys:Z(lo),noteKeys:Z(lo),tileIds:Z(lo)}),kN=j({dashboardKey:ue,kind:xu,version:Cu,state:Eu,identifierMappings:Bb});function Hb(e,t){return e.gridX<t.gridX+t.gridW&&e.gridX+e.gridW>t.gridX&&e.gridY<t.gridY+t.gridH&&e.gridY+e.gridH>t.gridY}function xt(e,t,r){e.addIssue({code:"custom",path:t,message:r})}function jt(e,t,r,n,s){if(e.has(r))xt(t,n,s);e.add(r)}function Nu(e,t,r){let n=new Set,s=new Set,o=new Set,i=new Set,a=new Set;for(let[c,l]of e.filterKeys.entries())jt(n,t,l,["filterKeys",c],"Filter keys must be unique");for(let[c,l]of e.filterViews.entries()){jt(s,t,l.key,["filterViews",c,"key"],"Filter view keys must be unique");let p=new Set;for(let[u,d]of l.filters.entries())if(jt(p,t,d.key,["filterViews",c,"filters",u,"key"],"Filter keys must be unique within a view"),!n.has(d.key))xt(t,["filterViews",c,"filters",u,"key"],"Saved view filters must be configured on the dashboard")}if(e.defaultFilterViewKey&&!s.has(e.defaultFilterViewKey))xt(t,["defaultFilterViewKey"],"Default filter view must reference an existing view");for(let[c,l]of e.tabs.entries()){jt(o,t,l.tabKey,["tabs",c,"tabKey"],"Tab key must be unique");for(let[p,u]of l.notes.entries())jt(i,t,u.noteKey,["tabs",c,"notes",p,"noteKey"],"Note key must be unique");for(let[p,u]of l.visualisations.entries())jt(a,t,u.tileId,["tabs",c,"visualisations",p,"tileId"],"Tile id must be unique")}for(let[c,l]of e.tabs.entries()){let p=[...l.visualisations.map((u,d)=>({label:`visualisation '${u.tileId}'`,path:["tabs",c,"visualisations",d],tile:u})),...l.notes.map((u,d)=>({label:`note '${u.noteKey}'`,path:["tabs",c,"notes",d],tile:u}))];for(let u of p)if(u.tile.gridX+u.tile.gridW>so)xt(t,u.path,`Position of ${u.label} exceeds the dashboard grid.`);for(let u=0;u<p.length;u+=1)for(let d=u+1;d<p.length;d+=1){let h=p[u],b=p[d];if(h&&b&&Hb(h.tile,b.tile))xt(t,h.path,`Position of ${h.label} overlaps with ${b.label}.`)}if(r&&Object.values(l.title).some((u)=>u.trim()===""))xt(t,["tabs",c,"title"],"Title is required")}if(r&&Object.values(e.title).some((c)=>c.trim()===""))xt(t,["title"],"Title is required")}var{Argument:Zu}=hn(),{Command:wo}=ju(),{CommanderError:Ow,InvalidArgumentError:Vu}=vr(),{Help:Tw}=fo(),{Option:Wu}=ho();var Gu=new wo,Ju=(e)=>new wo(e),Bu=(e,t)=>new Wu(e,t),Hu=(e,t)=>new Zu(e,t),Yu=wo,Qu=Wu,Xu=Zu,ep=Tw,tp=Ow,rp=Vu,np=Vu;var{program:PN,createCommand:IN,createArgument:FN,createOption:LN,CommanderError:zN,InvalidArgumentError:gn,InvalidOptionArgumentError:qN,Command:sp,Argument:ko,Option:ge,Help:KN}=vo;import{once as $w}from"node:events";import{readFileSync as Ew}from"node:fs";function Nw(e,t,r=!1){return{Authorization:`Bearer ${e}`,"X-S-Workspace-Key":t,"x-s-client":"cli",...r?{"Content-Type":"application/json"}:{}}}async function qe(e,t,r,n,s={}){let o=await fetch(new URL(n,e),{...s,headers:{...Nw(t,r,s.body!==void 0),...s.headers}});if(!o.ok)throw Error(`Agent request failed (${o.status}).`,{cause:await o.json().catch(()=>o.statusText)});return o}async function op(e,t=!1){if(!e.body)throw Error("Agent stream response had no body.");let r=async(a)=>{if(!process.stdout.write(a))await $w(process.stdout,"drain")};if(t){await e.body.pipeTo(new WritableStream({async write(a){await r(a)}}));return}let n=e.body.getReader(),s=new TextDecoder,o="",i=async(a)=>{let c="message",l,p=[];for(let h of a.split(/\r?\n/)){if(h.startsWith("event:"))c=h.slice(6).trim();if(h.startsWith("id:"))l=h.slice(3).trim();if(h.startsWith("data:"))p.push(h.slice(5).trimStart())}if(p.length===0)return;let u=p.join(`
192
- `),d=u;try{d=JSON.parse(u)}catch{}if(await r(`${JSON.stringify({event:c,...l?{id:l}:{},data:d})}
193
- `),c==="error")throw Error("Agent run stream reported an error.",{cause:d})};while(!0){let{done:a,value:c}=await n.read();o+=s.decode(c,{stream:!a});let l=o.match(/\r?\n\r?\n/);while(l?.index!==void 0)await i(o.slice(0,l.index)),o=o.slice(l.index+l[0].length),l=o.match(/\r?\n\r?\n/);if(a)break}if(o.trim())await i(o)}function kr(e){return e?JSON.parse(Ew(e,"utf8")):{}}async function ip(e,t,r,n){let s=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads`,{method:"POST",body:JSON.stringify({})});console.log(JSON.stringify(await s.json(),null,2))}async function ap(e,t,r,n,s){let o=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/search`,{method:"POST",body:JSON.stringify(s)});console.log(JSON.stringify(await o.json(),null,2))}async function cp(e,t,r,n,s){let o=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}`);console.log(JSON.stringify(await o.json(),null,2))}async function lp(e,t,r,n,s,o){let i=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/history`,{method:"POST",body:JSON.stringify(o)});console.log(JSON.stringify(await i.json(),null,2))}async function up(e,t,r,n,s){let o=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/state`);console.log(JSON.stringify(await o.json(),null,2))}async function pp(e,t,r,n,s,o,i){let a=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/messages/${encodeURIComponent(o)}/feedback`,{method:"POST",body:JSON.stringify(i)});console.log(JSON.stringify(await a.json(),null,2))}async function dp(e,t,r,n,s,o,i={}){let a=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs/stream`,{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify(o)});await op(a,i.raw)}async function mp(e,t,r,n,s,o){let i=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs`,{method:"POST",body:JSON.stringify(o)});console.log(JSON.stringify(await i.json(),null,2))}async function fp(e,t,r,n,s,o,i,a={}){let c=new URL(`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs/${encodeURIComponent(o)}/stream`,e);for(let[p,u]of Object.entries(i.query??{}))c.searchParams.set(p,u);let l=await qe(e,t,r,`${c.pathname}${c.search}`,{headers:{Accept:"text/event-stream",...i.lastEventId?{"Last-Event-ID":i.lastEventId}:{}}});await op(l,a.raw)}async function hp(e,t,r,n,s,o={}){let i=new URLSearchParams;for(let[c,l]of Object.entries(o))if(l!==void 0)i.set(c,l);let a=await qe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/artifacts?${i}`);console.log(JSON.stringify(await a.json(),null,2))}function gp(e,t,r={}){let n=e.command("agent").description("Run app conversations"),s=n.command("threads").description("Manage agent threads"),o=n.command("runs").description("Start agent runs");s.command("artifacts").argument("<app-key>").argument("<thread-id>").description("List accessible artifacts created or updated in a thread").option("--limit <limit>","Page size (1–100)").option("--cursor <cursor>","Cursor from the previous page").option("--run-id <run-id>","Filter associations to a run").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentThreadsArtifacts??hp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,c)}),s.command("create").argument("<app-key>","App key").action(async(i)=>{let a=await t.createWorkspaceContext();await(r.runAgentThreadsCreate??ip)(a.serverUrl,a.accessToken,a.workspaceKey,i)}),s.command("search").argument("<app-key>","App key").option("--input-file <file>","LangGraph search JSON").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsSearch??ap)(c.serverUrl,c.accessToken,c.workspaceKey,i,kr(a.inputFile))}),s.command("get").argument("<app-key>","App key").argument("<thread-id>","Thread ID").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsGet??cp)(c.serverUrl,c.accessToken,c.workspaceKey,i,a)}),s.command("history").argument("<app-key>","App key").argument("<thread-id>","Thread ID").option("--input-file <file>","LangGraph history JSON").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentThreadsHistory??lp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,kr(c.inputFile))}),s.command("state").argument("<app-key>","App key").argument("<thread-id>","Thread ID").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsState??up)(c.serverUrl,c.accessToken,c.workspaceKey,i,a)}),s.command("feedback").argument("<app-key>","App key").argument("<thread-id>","Thread ID").argument("<message-id>","Message ID").requiredOption("--score <score>","0 or 1").option("--comment <comment>","Feedback comment").action(async(i,a,c,l)=>{if(l.score!=="0"&&l.score!=="1")throw Error("--score must be 0 or 1.");let p=await t.createWorkspaceContext();await(r.runAgentThreadsFeedback??pp)(p.serverUrl,p.accessToken,p.workspaceKey,i,a,c,{score:Number.parseInt(l.score,10),...l.comment?{comment:l.comment}:{}})}),o.command("stream").argument("<app-key>","App key").argument("<thread-id>","Thread ID").requiredOption("--input-file <file>","LangGraph run JSON").option("--raw","Print the original SSE byte stream").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentRunsStream??dp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,kr(c.inputFile),{raw:c.raw})}),o.command("create").argument("<app-key>","App key").argument("<thread-id>","Thread ID").requiredOption("--input-file <file>","LangGraph run JSON").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentRunsCreate??mp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,kr(c.inputFile))}),o.command("join").argument("<app-key>","App key").argument("<thread-id>","Thread ID").argument("<run-id>","Run ID").option("--last-event-id <id>","Resume after this SSE event").option("--query <json>","Join-stream query parameters as JSON").option("--raw","Print the original SSE byte stream").action(async(i,a,c,l)=>{let p=await t.createWorkspaceContext();await(r.runAgentRunsJoin??fp)(p.serverUrl,p.accessToken,p.workspaceKey,i,a,c,{lastEventId:l.lastEventId,query:l.query?JSON.parse(l.query):void 0},{raw:l.raw})})}import{readFileSync as rr}from"node:fs";import{writeFileSync as Dw}from"node:fs";var Sr=1;function me(e,t,r=!1){try{Dw(e,t,{flag:r?"w":"wx"})}catch(n){if(!r&&n instanceof Error&&"code"in n&&n.code==="EEXIST")throw Error(`Output file '${e}' already exists. Pass --force to replace it.`);throw n}}function fe(e,t={}){console.log(JSON.stringify({schemaVersion:Sr,ok:!0,outputFile:e,...t},null,2))}function xe(e){process.stderr.write(`${e}
194
- `)}var tt=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=t}},Pw=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,Iw=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,Fw=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,Lw=(e)=>e.trim().length!==0&&!Number.isNaN(Number(e)),yn=(e,t)=>{if(typeof e!="string"||t?.parseDate===!1)return null;let r=e.replace(/"/g,"");if(Pw.test(r)||Iw.test(r)||Fw.test(r)){let n=new Date(r);if(!Number.isNaN(n.getTime()))return n}return null},zw=(e)=>{let t=e.charCodeAt(0),r=e.charCodeAt(e.length-1);return t===123&&r===125||t===91&&r===93},qw=(e,t)=>JSON.parse(e,(r,n)=>yn(n,t)||n),Ct=(e,t)=>{if(!e)return e;if(Lw(e))return+e;if(e==="true")return!0;if(e==="false")return!1;if(t?.parseDate!==!1){let r=yn(e,t);if(r)return r}if(zw(e))try{return qw(e,t)}catch{}return e},So=(e,t)=>{let r=e.data.toString();return r==="null"?null:Ct(r,t)};var Kw=class{constructor(e){this.url=e,this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach((t)=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,(n)=>{if(e==="message"){let s=So(n);t({...n,data:s})}else t(n)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},Rw=["get","post","put","delete","patch","options","head","connect","subscribe"],yp=(e,t)=>typeof t=="function"?t(e):t===!0,vp=["localhost","127.0.0.1","0.0.0.0"],Co=typeof FileList>"u",bn=(e)=>Co?e instanceof Blob:e instanceof FileList||e instanceof File,Uw=(e)=>{if(!e)return!1;for(let t in e)if(bn(e[t])||Array.isArray(e[t])&&e[t].find(bn))return!0;return!1},xo=(e)=>Co?e:new Promise((t)=>{let r=new FileReader;r.onload=()=>{let n=new File([r.result],e.name,{lastModified:e.lastModified,type:e.type});t(n)},r.readAsArrayBuffer(e)}),_t=async(e,t,r={},n={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))n=await _t(s,t,r,n);else{let o=s[0];if(typeof o=="string")n[o.toLowerCase()]=s[1];else for(let[i,a]of o)n[i.toLowerCase()]=a}return n}if(!e)return n;switch(typeof e){case"function":if(e instanceof Headers)return _t(e,t,r,n);let s=await e(t,r);return s?_t(s,t,r,n):n;case"object":if(e instanceof Headers)return e.forEach((o,i)=>{n[i.toLowerCase()]=o}),n;for(let[o,i]of Object.entries(e))n[o.toLowerCase()]=i;return n;default:return n}};function kp(e,t){let r=e.split(`
195
- `),n={};for(let s of r){if(!s||s.startsWith(":"))continue;let o=s.indexOf(":");if(o>0){let i=s.slice(0,o).trim(),a=s.slice(o+1).replace(/^ /,"");n[i]=a&&Ct(a,t)}}return Object.keys(n).length>0?n:null}function*bp(e,t){let r;for(;(r=e.value.indexOf(`
190
+ path: iss.path ? [${Kt(N)}, ...iss.path] : [${Kt(N)}]
191
+ })));`),d.write(`newResult[${Kt(N)}] = ${x}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");let T=d.compile();return(N,x)=>T(p,N,x)},s,o=lr,i=!Yr.jitless,c=i&&ha.value,l=t.catchall,u;e._zod.parse=(p,d)=>{u??(u=r.value);let g=p.value;if(!o(g))return p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p;let b=[];if(i&&c&&d?.async===!1&&d.jitless!==!0){if(!s)s=n(t.shape);p=s(p,d)}else{p.value={};let x=u.shape;for(let D of u.keys){let P=x[D],L=P._zod.run({value:g[D],issues:[]},d),K=P._zod.optin==="optional"&&P._zod.optout==="optional";if(L instanceof Promise)b.push(L.then((E)=>K?yc(E,p,D,g):on(E,p,D)));else if(K)yc(L,p,D,g);else on(L,p,D)}}if(!l)return b.length?Promise.all(b).then(()=>p):p;let y=[],w=u.keySet,T=l._zod,N=T.def.type;for(let x of Object.keys(g)){if(w.has(x))continue;if(N==="never"){y.push(x);continue}let D=T.run({value:g[x],issues:[]},d);if(D instanceof Promise)b.push(D.then((P)=>on(P,p,x)));else on(D,p,x)}if(y.length)p.issues.push({code:"unrecognized_keys",keys:y,input:g,inst:e});if(!b.length)return p;return Promise.all(b).then(()=>p)}});function bc(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((o)=>qe(o,n,Oe())))}),t}var qs=S("$ZodUnion",(e,t)=>{Q.init(e,t),Y(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),Y(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),Y(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),Y(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>tn(n.source)).join("|")})$`)}return}),e._zod.parse=(r,n)=>{let s=!1,o=[];for(let i of t.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}if(!s)return bc(o,r,e,n);return Promise.all(o).then((i)=>bc(i,r,e,n))}}),rl=S("$ZodDiscriminatedUnion",(e,t)=>{qs.init(e,t);let r=e._zod.parse;Y(e._zod,"propValues",()=>{let s={};for(let o of t.options){let i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,c]of Object.entries(i)){if(!s[a])s[a]=new Set;for(let l of c)s[a].add(l)}}return s});let n=Xr(()=>{let s=t.options,o=new Map;for(let i of s){let a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(o.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});e._zod.parse=(s,o)=>{let i=s.value;if(!lr(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;let a=n.value.get(i?.[t.discriminator]);if(a)return a._zod.run(s,o);if(t.unionFallback)return r(s,o);return s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),s}}),nl=S("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value,o=t.left._zod.run({value:s,issues:[]},n),i=t.right._zod.run({value:s,issues:[]},n);if(o instanceof Promise||i instanceof Promise)return Promise.all([o,i]).then(([c,l])=>wc(r,c,l));return wc(r,o,i)}});function Ls(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ur(e)&&ur(t)){let r=Object.keys(t),n=Object.keys(e).filter((o)=>r.indexOf(o)!==-1),s={...e,...t};for(let o of n){let i=Ls(e[o],t[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let s=e[n],o=t[n],i=Ls(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function wc(e,t,r){if(t.issues.length)e.issues.push(...t.issues);if(r.issues.length)e.issues.push(...r.issues);if(Rt(e))return e;let n=Ls(t.value,r.value);if(!n.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var sl=S("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=r.value;if(!ur(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;let o=[];if(t.keyType._zod.values){let i=t.keyType._zod.values;r.value={};for(let c of i)if(typeof c==="string"||typeof c==="number"||typeof c==="symbol"){let l=t.valueType._zod.run({value:s[c],issues:[]},n);if(l instanceof Promise)o.push(l.then((u)=>{if(u.issues.length)r.issues.push(...Je(c,u.issues));r.value[c]=u.value}));else{if(l.issues.length)r.issues.push(...Je(c,l.issues));r.value[c]=l.value}}let a;for(let c in s)if(!i.has(c))a=a??[],a.push(c);if(a&&a.length>0)r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(s)){if(i==="__proto__")continue;let a=t.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map((l)=>qe(l,n,Oe())),input:i,path:[i],inst:e}),r.value[a.value]=a.value;continue}let c=t.valueType._zod.run({value:s[i],issues:[]},n);if(c instanceof Promise)o.push(c.then((l)=>{if(l.issues.length)r.issues.push(...Je(i,l.issues));r.value[a.value]=l.value}));else{if(c.issues.length)r.issues.push(...Je(i,c.issues));r.value[a.value]=c.value}}}if(o.length)return Promise.all(o).then(()=>r);return r}});var ol=S("$ZodEnum",(e,t)=>{Q.init(e,t);let r=da(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter((n)=>ga.has(typeof n)).map((n)=>typeof n==="string"?vt(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let o=n.value;if(e._zod.values.has(o))return n;return n.issues.push({code:"invalid_value",values:r,input:o,inst:e}),n}}),il=S("$ZodLiteral",(e,t)=>{Q.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?vt(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let s=r.value;if(e._zod.values.has(s))return r;return r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var al=S("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then((i)=>(r.value=i,r));if(s instanceof Promise)throw new Qe;return r.value=s,r}}),cl=S("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Y(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tn(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional")return t.innerType._zod.run(r,n);if(r.value===void 0)return r;return t.innerType._zod.run(r,n)}}),ll=S("$ZodNullable",(e,t)=>{Q.init(e,t),Y(e._zod,"optin",()=>t.innerType._zod.optin),Y(e._zod,"optout",()=>t.innerType._zod.optout),Y(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${tn(r.source)}|null)$`):void 0}),Y(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),ul=S("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>vc(o,t));return vc(s,t)}});function vc(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var pl=S("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),dl=S("$ZodNonOptional",(e,t)=>{Q.init(e,t),Y(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>kc(o,e));return kc(s,e)}});function kc(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var ml=S("$ZodCatch",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Y(e._zod,"optout",()=>t.innerType._zod.optout),Y(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>{if(r.value=o.value,o.issues.length)r.value=t.catchValue({...r,error:{issues:o.issues.map((i)=>qe(i,n,Oe()))},input:r.value}),r.issues=[];return r});if(r.value=s.value,s.issues.length)r.value=t.catchValue({...r,error:{issues:s.issues.map((o)=>qe(o,n,Oe()))},input:r.value}),r.issues=[];return r}});var fl=S("$ZodPipe",(e,t)=>{Q.init(e,t),Y(e._zod,"values",()=>t.in._zod.values),Y(e._zod,"optin",()=>t.in._zod.optin),Y(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let s=t.in._zod.run(r,n);if(s instanceof Promise)return s.then((o)=>Sc(o,t,n));return Sc(s,t,n)}});function Sc(e,t,r){if(Rt(e))return e;return t.out._zod.run({value:e.value,issues:e.issues},r)}var hl=S("$ZodReadonly",(e,t)=>{Q.init(e,t),Y(e._zod,"propValues",()=>t.innerType._zod.propValues),Y(e._zod,"values",()=>t.innerType._zod.values),Y(e._zod,"optin",()=>t.innerType._zod.optin),Y(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then(xc);return xc(s)}});function xc(e){return e.value=Object.freeze(e.value),e}var gl=S("$ZodCustom",(e,t)=>{he.init(e,t),Q.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then((o)=>Cc(o,r,n,e));Cc(s,r,n,e);return}});function Cc(e,t,r,n){if(!e){let s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)s.params=n._zod.def.params;t.issues.push(Ut(s))}}var Ly=(e)=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},zy=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(n)=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${Ly(n.input)}`;case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${As(n.values[0])}`;return`Invalid option: expected one of ${Cs(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",o=t(n.origin);if(o)return`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${o.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",o=t(n.origin);if(o)return`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${o.unit}`;return`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Cs(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Ks(){return{localeError:zy()}}var U$=Symbol("ZodOutput"),M$=Symbol("ZodInput");class yl{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r){if(this._idmap.has(r.id))throw Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function qy(){return new yl}var dr=qy();function bl(e,t){return new e({type:"string",...q(t)})}function wl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...q(t)})}function Rs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...q(t)})}function Us(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...q(t)})}function vl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(t)})}function kl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(t)})}function xl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...q(t)})}function Cl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...q(t)})}function _l(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(t)})}function Al(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...q(t)})}function Ol(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(t)})}function Tl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...q(t)})}function $l(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...q(t)})}function El(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(t)})}function Nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(t)})}function Dl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(t)})}function Pl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(t)})}function Il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(t)})}function Fl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...q(t)})}function Ll(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...q(t)})}function zl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...q(t)})}function ql(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...q(t)})}function Kl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(t)})}function Rl(e,t){return new e({type:"string",format:"date",check:"string_format",...q(t)})}function Ul(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...q(t)})}function Ml(e,t){return new e({type:"string",format:"duration",check:"string_format",...q(t)})}function jl(e,t){return new e({type:"number",checks:[],...q(t)})}function Zl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...q(t)})}function Vl(e,t){return new e({type:"boolean",...q(t)})}function Wl(e,t){return new e({type:"null",...q(t)})}function Gl(e){return new e({type:"unknown"})}function Jl(e,t){return new e({type:"never",...q(t)})}function cn(e,t){return new Ps({check:"less_than",...q(t),value:e,inclusive:!1})}function mr(e,t){return new Ps({check:"less_than",...q(t),value:e,inclusive:!0})}function ln(e,t){return new Is({check:"greater_than",...q(t),value:e,inclusive:!1})}function fr(e,t){return new Is({check:"greater_than",...q(t),value:e,inclusive:!0})}function un(e,t){return new rc({check:"multiple_of",...q(t),value:e})}function pn(e,t){return new sc({check:"max_length",...q(t),maximum:e})}function Mt(e,t){return new oc({check:"min_length",...q(t),minimum:e})}function dn(e,t){return new ic({check:"length_equals",...q(t),length:e})}function Ms(e,t){return new ac({check:"string_format",format:"regex",...q(t),pattern:e})}function js(e){return new cc({check:"string_format",format:"lowercase",...q(e)})}function Zs(e){return new lc({check:"string_format",format:"uppercase",...q(e)})}function Vs(e,t){return new uc({check:"string_format",format:"includes",...q(t),includes:e})}function Ws(e,t){return new pc({check:"string_format",format:"starts_with",...q(t),prefix:e})}function Gs(e,t){return new dc({check:"string_format",format:"ends_with",...q(t),suffix:e})}function kt(e){return new mc({check:"overwrite",tx:e})}function Js(e){return kt((t)=>t.normalize(e))}function Bs(){return kt((e)=>e.trim())}function Hs(){return kt((e)=>e.toLowerCase())}function Ys(){return kt((e)=>e.toUpperCase())}function Bl(e,t,r){return new e({type:"array",element:t,...q(r)})}function Hl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...q(r)})}var Yl=S("ZodISODateTime",(e,t)=>{Lc.init(e,t),ee.init(e,t)});function Qs(e){return Kl(Yl,e)}var Ql=S("ZodISODate",(e,t)=>{zc.init(e,t),ee.init(e,t)});function Xs(e){return Rl(Ql,e)}var Xl=S("ZodISOTime",(e,t)=>{qc.init(e,t),ee.init(e,t)});function eo(e){return Ul(Xl,e)}var eu=S("ZodISODuration",(e,t)=>{Kc.init(e,t),ee.init(e,t)});function to(e){return Ml(eu,e)}var tu=(e,t)=>{sn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>ka(e,r)},flatten:{value:(r)=>va(e,r)},addIssue:{value:(r)=>e.issues.push(r)},addIssues:{value:(r)=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},hE=S("ZodError",tu),yr=S("ZodError",tu,{Parent:Error});var ru=Sa(yr),nu=xa(yr),su=Ts(yr),ou=$s(yr);var re=S("ZodType",(e,t)=>(Q.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Ge(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>ru(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>su(e,r,n),e.parseAsync=async(r,n)=>nu(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>ou(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(qb(r,n)),e.superRefine=(r)=>e.check(Kb(r)),e.overwrite=(r)=>e.check(kt(r)),e.optional=()=>cu(e),e.nullable=()=>lu(e),e.nullish=()=>cu(lu(e)),e.nonoptional=(r)=>Eb(e,r),e.array=()=>Z(e),e.or=(r)=>wr([e,r]),e.and=(r)=>kb(e,r),e.transform=(r)=>no(e,fu(r)),e.default=(r)=>Ob(e,r),e.prefault=(r)=>$b(e,r),e.catch=(r)=>Db(e,r),e.pipe=(r)=>no(e,r),e.readonly=()=>Fb(e),e.describe=(r)=>{let n=e.clone();return dr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return dr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return dr.get(e);let n=e.clone();return dr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),uu=S("_ZodString",(e,t)=>{an.init(e,t),re.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Ms(...n)),e.includes=(...n)=>e.check(Vs(...n)),e.startsWith=(...n)=>e.check(Ws(...n)),e.endsWith=(...n)=>e.check(Gs(...n)),e.min=(...n)=>e.check(Mt(...n)),e.max=(...n)=>e.check(pn(...n)),e.length=(...n)=>e.check(dn(...n)),e.nonempty=(...n)=>e.check(Mt(1,...n)),e.lowercase=(n)=>e.check(js(n)),e.uppercase=(n)=>e.check(Zs(n)),e.trim=()=>e.check(Bs()),e.normalize=(...n)=>e.check(Js(...n)),e.toLowerCase=()=>e.check(Hs()),e.toUpperCase=()=>e.check(Ys())}),Gy=S("ZodString",(e,t)=>{an.init(e,t),uu.init(e,t),e.email=(r)=>e.check(wl(Jy,r)),e.url=(r)=>e.check(xl(Hy,r)),e.jwt=(r)=>e.check(ql(pb,r)),e.emoji=(r)=>e.check(Cl(Yy,r)),e.guid=(r)=>e.check(Rs(iu,r)),e.uuid=(r)=>e.check(Us(br,r)),e.uuidv4=(r)=>e.check(vl(br,r)),e.uuidv6=(r)=>e.check(kl(br,r)),e.uuidv7=(r)=>e.check(Sl(br,r)),e.nanoid=(r)=>e.check(_l(Qy,r)),e.guid=(r)=>e.check(Rs(iu,r)),e.cuid=(r)=>e.check(Al(Xy,r)),e.cuid2=(r)=>e.check(Ol(eb,r)),e.ulid=(r)=>e.check(Tl(tb,r)),e.base64=(r)=>e.check(Fl(cb,r)),e.base64url=(r)=>e.check(Ll(lb,r)),e.xid=(r)=>e.check($l(rb,r)),e.ksuid=(r)=>e.check(El(nb,r)),e.ipv4=(r)=>e.check(Nl(sb,r)),e.ipv6=(r)=>e.check(Dl(ob,r)),e.cidrv4=(r)=>e.check(Pl(ib,r)),e.cidrv6=(r)=>e.check(Il(ab,r)),e.e164=(r)=>e.check(zl(ub,r)),e.datetime=(r)=>e.check(Qs(r)),e.date=(r)=>e.check(Xs(r)),e.time=(r)=>e.check(eo(r)),e.duration=(r)=>e.check(to(r))});function R(e){return bl(Gy,e)}var ee=S("ZodStringFormat",(e,t)=>{X.init(e,t),uu.init(e,t)}),Jy=S("ZodEmail",(e,t)=>{Oc.init(e,t),ee.init(e,t)});var iu=S("ZodGUID",(e,t)=>{_c.init(e,t),ee.init(e,t)});var br=S("ZodUUID",(e,t)=>{Ac.init(e,t),ee.init(e,t)});function By(e){return Us(br,e)}var Hy=S("ZodURL",(e,t)=>{Tc.init(e,t),ee.init(e,t)});var Yy=S("ZodEmoji",(e,t)=>{$c.init(e,t),ee.init(e,t)});var Qy=S("ZodNanoID",(e,t)=>{Ec.init(e,t),ee.init(e,t)});var Xy=S("ZodCUID",(e,t)=>{Nc.init(e,t),ee.init(e,t)});var eb=S("ZodCUID2",(e,t)=>{Dc.init(e,t),ee.init(e,t)});var tb=S("ZodULID",(e,t)=>{Pc.init(e,t),ee.init(e,t)});var rb=S("ZodXID",(e,t)=>{Ic.init(e,t),ee.init(e,t)});var nb=S("ZodKSUID",(e,t)=>{Fc.init(e,t),ee.init(e,t)});var sb=S("ZodIPv4",(e,t)=>{Rc.init(e,t),ee.init(e,t)});var ob=S("ZodIPv6",(e,t)=>{Uc.init(e,t),ee.init(e,t)});var ib=S("ZodCIDRv4",(e,t)=>{Mc.init(e,t),ee.init(e,t)});var ab=S("ZodCIDRv6",(e,t)=>{jc.init(e,t),ee.init(e,t)});var cb=S("ZodBase64",(e,t)=>{Vc.init(e,t),ee.init(e,t)});var lb=S("ZodBase64URL",(e,t)=>{Wc.init(e,t),ee.init(e,t)});var ub=S("ZodE164",(e,t)=>{Gc.init(e,t),ee.init(e,t)});var pb=S("ZodJWT",(e,t)=>{Jc.init(e,t),ee.init(e,t)});var pu=S("ZodNumber",(e,t)=>{zs.init(e,t),re.init(e,t),e.gt=(n,s)=>e.check(ln(n,s)),e.gte=(n,s)=>e.check(fr(n,s)),e.min=(n,s)=>e.check(fr(n,s)),e.lt=(n,s)=>e.check(cn(n,s)),e.lte=(n,s)=>e.check(mr(n,s)),e.max=(n,s)=>e.check(mr(n,s)),e.int=(n)=>e.check(au(n)),e.safe=(n)=>e.check(au(n)),e.positive=(n)=>e.check(ln(0,n)),e.nonnegative=(n)=>e.check(fr(0,n)),e.negative=(n)=>e.check(cn(0,n)),e.nonpositive=(n)=>e.check(mr(0,n)),e.multipleOf=(n,s)=>e.check(un(n,s)),e.step=(n,s)=>e.check(un(n,s)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});function oe(e){return jl(pu,e)}var db=S("ZodNumberFormat",(e,t)=>{Bc.init(e,t),pu.init(e,t)});function au(e){return Zl(db,e)}var mb=S("ZodBoolean",(e,t)=>{Hc.init(e,t),re.init(e,t)});function ie(e){return Vl(mb,e)}var fb=S("ZodNull",(e,t)=>{Yc.init(e,t),re.init(e,t)});function hb(e){return Wl(fb,e)}var gb=S("ZodUnknown",(e,t)=>{Qc.init(e,t),re.init(e,t)});function mn(){return Gl(gb)}var yb=S("ZodNever",(e,t)=>{Xc.init(e,t),re.init(e,t)});function Te(e){return Jl(yb,e)}var bb=S("ZodArray",(e,t)=>{el.init(e,t),re.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Mt(r,n)),e.nonempty=(r)=>e.check(Mt(1,r)),e.max=(r,n)=>e.check(pn(r,n)),e.length=(r,n)=>e.check(dn(r,n)),e.unwrap=()=>e.element});function Z(e,t){return Bl(bb,e,t)}var du=S("ZodObject",(e,t)=>{tl.init(e,t),re.init(e,t),Y(e,"shape",()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=(r)=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:mn()}),e.loose=()=>e.clone({...e._zod.def,catchall:mn()}),e.strict=()=>e.clone({...e._zod.def,catchall:Te()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=(r)=>$y(e,r),e.merge=(r)=>Ey(e,r),e.pick=(r)=>Oy(e,r),e.omit=(r)=>Ty(e,r),e.partial=(...r)=>Ny(hu,e,r[0]),e.required=(...r)=>Dy(gu,e,r[0])});function ne(e,t){let r={type:"object",get shape(){return rn(this,"shape",{...e}),this.shape},...q(t)};return new du(r)}function j(e,t){return new du({type:"object",get shape(){return rn(this,"shape",{...e}),this.shape},catchall:Te(),...q(t)})}var mu=S("ZodUnion",(e,t)=>{qs.init(e,t),re.init(e,t),e.options=t.options});function wr(e,t){return new mu({type:"union",options:e,...q(t)})}var wb=S("ZodDiscriminatedUnion",(e,t)=>{mu.init(e,t),rl.init(e,t)});function vr(e,t,r){return new wb({type:"union",options:t,discriminator:e,...q(r)})}var vb=S("ZodIntersection",(e,t)=>{nl.init(e,t),re.init(e,t)});function kb(e,t){return new vb({type:"intersection",left:e,right:t})}var Sb=S("ZodRecord",(e,t)=>{sl.init(e,t),re.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function so(e,t,r){return new Sb({type:"record",keyType:e,valueType:t,...q(r)})}var ro=S("ZodEnum",(e,t)=>{ol.init(e,t),re.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ro({...t,checks:[],...q(s),entries:o})},e.exclude=(n,s)=>{let o={...t.entries};for(let i of n)if(r.has(i))delete o[i];else throw Error(`Key ${i} not found in enum`);return new ro({...t,checks:[],...q(s),entries:o})}});function H(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new ro({type:"enum",entries:r,...q(t)})}var xb=S("ZodLiteral",(e,t)=>{il.init(e,t),re.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function te(e,t){return new xb({type:"literal",values:Array.isArray(e)?e:[e],...q(t)})}var Cb=S("ZodTransform",(e,t)=>{al.init(e,t),re.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Ut(o,r.value,t));else{let i=o;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),r.issues.push(Ut(i))}};let s=t.transform(r.value,r);if(s instanceof Promise)return s.then((o)=>(r.value=o,r));return r.value=s,r}});function fu(e){return new Cb({type:"transform",transform:e})}var hu=S("ZodOptional",(e,t)=>{cl.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function cu(e){return new hu({type:"optional",innerType:e})}var _b=S("ZodNullable",(e,t)=>{ll.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function lu(e){return new _b({type:"nullable",innerType:e})}var Ab=S("ZodDefault",(e,t)=>{ul.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ob(e,t){return new Ab({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():t}})}var Tb=S("ZodPrefault",(e,t)=>{pl.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $b(e,t){return new Tb({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():t}})}var gu=S("ZodNonOptional",(e,t)=>{dl.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Eb(e,t){return new gu({type:"nonoptional",innerType:e,...q(t)})}var Nb=S("ZodCatch",(e,t)=>{ml.init(e,t),re.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Db(e,t){return new Nb({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Pb=S("ZodPipe",(e,t)=>{fl.init(e,t),re.init(e,t),e.in=t.in,e.out=t.out});function no(e,t){return new Pb({type:"pipe",in:e,out:t})}var Ib=S("ZodReadonly",(e,t)=>{hl.init(e,t),re.init(e,t)});function Fb(e){return new Ib({type:"readonly",innerType:e})}var Lb=S("ZodCustom",(e,t)=>{gl.init(e,t),re.init(e,t)});function zb(e){let t=new he({check:"custom"});return t._zod.check=e,t}function qb(e,t={}){return Hl(Lb,e,t)}function Kb(e){let t=zb((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(Ut(n,r.value,t._zod.def));else{let s=n;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),r.issues.push(Ut(s))}},e(r.value,r)));return t}function yu(e,t){return no(fu(e),t)}Oe(Ks());var oo=12,io={min:8,max:240,default:28};function St(e){try{return Intl.getCanonicalLocales(e.trim())[0]}catch{return}}var vu=R().overwrite((e)=>St(e)??e).refine((e)=>St(e)===e,"Use a valid locale tag such as en-US or ar-SA"),ku=(e)=>Object.keys(e).length>0,ao=(e)=>so(vu,e).refine(ku,"Add at least one locale"),co=(e)=>so(vu,e.nullable()).refine(ku,"Add at least one locale"),lo=(e=R().trim().min(1))=>ao(e),be=lo(),fn=co(R().trim().min(1)),bu=(e)=>e.split("-")[0].toLowerCase();function wu(e,t){if(!e)return;let r=St(e)??e;return t.find((n)=>n===r)??t.find((n)=>bu(n)===bu(r))}function Su(e,t,r){let n=Object.keys(e),s=wu(t,n)??wu(r,n)??n[0];return s===void 0?void 0:e[s]}var De=j({threadId:R().trim().min(1).max(200),runId:R().trim().min(1).max(200),toolCallId:R().trim().min(1).max(200)});var Rb=["layout-dashboard","chart-column","chart-line","table","chart-pie","activity","badge-dollar-sign","banknote","book-open","briefcase","building-2","calendar-days","circle-dollar-sign","clipboard-list","credit-card","database","factory","gauge","goal","landmark","map","package","receipt","shopping-cart","sparkles","store","target","trending-up","users","wallet"],Ub=["published","draft"],ue=R().trim().nonempty("Identity is required").regex(/^[a-z0-9-]+$/,"Identity must use only lowercase ASCII letters, digits, and dashes"),Mb=R().trim().nonempty("User group key is required").regex(/^[a-zA-Z0-9_-]+$/,"User group key must use only letters, digits, underscores, and dashes"),vN=j({view:H(["summary","full"]).optional(),editableOnly:ie().optional(),sharedWithGroup:Mb.optional(),sort:te("recently-pinned").optional(),hidden:H(["include","only"]).optional(),limit:oe().int().min(1).max(100).optional(),cursor:R().min(1).max(4096).optional()}),kN=ne({nextCursor:R().nullable().optional()}),SN=j({agentContext:De.optional(),title:be,visualisationKeys:Z(ue).max(10).optional()}),Cu=H(Rb),xN=j({dashboardId:By(),dashboardKey:ue,title:be,icon:Cu,tabs:Z(j({tabKey:ue,title:be,position:oe().int().nonnegative()})),capabilities:j({canUpdate:ie(),canDelete:ie(),canShare:ie()}),draftDashboardKey:R().nullable(),draftOfDashboardKey:R().nullable(),canPersonalise:ie(),canResetToDefault:ie(),personalCopyDashboardKey:R().nullable()}),po=j({visualisationKey:ue,dashboardKey:ue,tabKey:ue}),CN=j({agentContext:De.optional(),pins:Z(po).min(1).max(100),removeIncompatibleFilters:ie().default(!1)}).superRefine(({pins:e},t)=>{let r=new Set;e.forEach((n,s)=>{let o=JSON.stringify([n.visualisationKey,n.dashboardKey,n.tabKey]);if(r.has(o))t.addIssue({code:"custom",path:["pins",s],message:"Duplicate pin destination"});r.add(o)})}),_N=j({dashboardKey:ue,title:be,removedFilterKeys:Z(R())}),AN=vr("status",[j({pin:po,status:te("pinned"),dashboardKey:ue,visualisationKey:ue,dashboardVisualisationId:R(),tabKey:ue}),j({pin:po,status:H(["failed","unknown"]),error:R(),removedFilterKeys:Z(R()).optional()})]),_u=H(Ub),Au=oe().int().nonnegative(),jb=R().uuid(),Ou=lo(R()),Zb=Z(R().trim().nonempty("Filter key is required")),Vb=["today","yesterday","this-week","last-week","this-month","last-month","last-7-days","last-30-days","this-quarter","last-quarter","this-year","last-year"],mo=R().trim().nonempty("Filter key is required"),Wb=(e)=>j({value:e,inclusive:ie()}),Gb=gr.datetime({offset:!0,precision:0}),xu=(e,t)=>{let r=Wb(t);return j({key:mo,kind:te(e),from:r.optional(),to:r.optional()}).refine((n)=>n.from||n.to,{message:"At least one temporal filter bound is required"}).refine((n)=>!n.from||!n.to||Date.parse(n.from.value)<Date.parse(n.to.value)||Date.parse(n.from.value)===Date.parse(n.to.value)&&n.from.inclusive&&n.to.inclusive,{message:"Temporal filter range is invalid"})},Jb=wr([j({key:mo,kind:te("dimension"),values:Z(R()).min(1)}),xu("date",gr.date()),xu("timestamp",Gb),j({key:mo,kind:H(["date","timestamp"]),preset:H(Vb),weekStartsOn:oe().int().min(0).max(6).optional()}).check((e)=>{let t=e.value.preset==="this-week"||e.value.preset==="last-week";if(t!==(e.value.weekStartsOn!==void 0))e.issues.push({code:"custom",input:e.value.weekStartsOn,path:["weekStartsOn"],message:t?"weekStartsOn is required for week presets":"weekStartsOn is only allowed for week presets"})})]),Bb=j({key:ue,title:be,filters:Z(Jb)}),Hb=Z(Bb),Yb=R().trim().url("Note link must be a valid URL").refine((e)=>{try{return new URL(e).protocol==="http:"||new URL(e).protocol==="https:"}catch{return!1}},"Note link must use http or https"),Qb=j({insert:R(),attributes:j({bold:ie().optional(),italic:ie().optional(),underline:ie().optional(),header:wr([te(1),te(2),te(3)]).optional(),list:H(["bullet","ordered"]).optional(),align:H(["left","center","right"]).optional(),link:Yb.optional()}).optional()}),Tu=j({version:te(1),delta:j({ops:Z(Qb).min(1)})}),$u=ao(Tu),ON=j({agentContext:De.optional(),content:$u}),TN=j({agentContext:De.optional(),content:co(Tu)});var Eu={gridX:oe().int().min(0),gridY:oe().int().min(0),gridW:oe().int().positive(),gridH:oe().int().positive()},Xb=j({noteKey:ue,content:$u,...Eu}),ew=j({tileId:ue,visualisationKey:ue,...Eu}),tw=j({tabKey:ue,title:Ou,visualisations:Z(ew),notes:Z(Xb)}),Nu=j({title:Ou,icon:Cu,filterKeys:Zb,filterViews:Hb.optional().default([]),defaultFilterViewKey:ue.nullable().optional().default(null),tabs:Z(tw).min(1)}),$N=Nu.superRefine((e,t)=>Pu(e,t,!1)),Du=Nu.superRefine((e,t)=>Pu(e,t,!0)),EN=j({agentContext:De.optional(),baseVersion:Au,mutationId:jb,kind:_u,state:Du}),uo=j({clientId:ue,savedId:ue}),rw=j({tabKeys:Z(uo),noteKeys:Z(uo),tileIds:Z(uo)}),NN=j({dashboardKey:ue,kind:_u,version:Au,state:Du,identifierMappings:rw});function nw(e,t){return e.gridX<t.gridX+t.gridW&&e.gridX+e.gridW>t.gridX&&e.gridY<t.gridY+t.gridH&&e.gridY+e.gridH>t.gridY}function xt(e,t,r){e.addIssue({code:"custom",path:t,message:r})}function Zt(e,t,r,n,s){if(e.has(r))xt(t,n,s);e.add(r)}function Pu(e,t,r){let n=new Set,s=new Set,o=new Set,i=new Set,a=new Set;for(let[c,l]of e.filterKeys.entries())Zt(n,t,l,["filterKeys",c],"Filter keys must be unique");for(let[c,l]of e.filterViews.entries()){Zt(s,t,l.key,["filterViews",c,"key"],"Filter view keys must be unique");let u=new Set;for(let[p,d]of l.filters.entries())if(Zt(u,t,d.key,["filterViews",c,"filters",p,"key"],"Filter keys must be unique within a view"),!n.has(d.key))xt(t,["filterViews",c,"filters",p,"key"],"Saved view filters must be configured on the dashboard")}if(e.defaultFilterViewKey&&!s.has(e.defaultFilterViewKey))xt(t,["defaultFilterViewKey"],"Default filter view must reference an existing view");for(let[c,l]of e.tabs.entries()){Zt(o,t,l.tabKey,["tabs",c,"tabKey"],"Tab key must be unique");for(let[u,p]of l.notes.entries())Zt(i,t,p.noteKey,["tabs",c,"notes",u,"noteKey"],"Note key must be unique");for(let[u,p]of l.visualisations.entries())Zt(a,t,p.tileId,["tabs",c,"visualisations",u,"tileId"],"Tile id must be unique")}for(let[c,l]of e.tabs.entries()){let u=[...l.visualisations.map((p,d)=>({label:`visualisation '${p.tileId}'`,path:["tabs",c,"visualisations",d],tile:p})),...l.notes.map((p,d)=>({label:`note '${p.noteKey}'`,path:["tabs",c,"notes",d],tile:p}))];for(let p of u)if(p.tile.gridX+p.tile.gridW>oo)xt(t,p.path,`Position of ${p.label} exceeds the dashboard grid.`);for(let p=0;p<u.length;p+=1)for(let d=p+1;d<u.length;d+=1){let g=u[p],b=u[d];if(g&&b&&nw(g.tile,b.tile))xt(t,g.path,`Position of ${g.label} overlaps with ${b.label}.`)}if(r&&Object.values(l.title).some((p)=>p.trim()===""))xt(t,["tabs",c,"title"],"Title is required")}if(r&&Object.values(e.title).some((c)=>c.trim()===""))xt(t,["title"],"Title is required")}var{Argument:Wu}=hn(),{Command:vo}=Vu(),{CommanderError:Iw,InvalidArgumentError:Gu}=kr(),{Help:Fw}=ho(),{Option:Ju}=go();var Bu=new vo,Hu=(e)=>new vo(e),Yu=(e,t)=>new Ju(e,t),Qu=(e,t)=>new Wu(e,t),Xu=vo,ep=Ju,tp=Wu,rp=Fw,np=Iw,sp=Gu,op=Gu;var{program:jN,createCommand:ZN,createArgument:VN,createOption:WN,CommanderError:GN,InvalidArgumentError:gn,InvalidOptionArgumentError:JN,Command:ip,Argument:So,Option:ge,Help:BN}=ko;import{once as Lw}from"node:events";import{readFileSync as zw}from"node:fs";function qw(e,t,r=!1){return{Authorization:`Bearer ${e}`,"X-S-Workspace-Key":t,"x-s-client":"cli",...r?{"Content-Type":"application/json"}:{}}}async function Pe(e,t,r,n,s={}){let o=await fetch(new URL(n,e),{...s,headers:{...qw(t,r,s.body!==void 0),...s.headers}});if(!o.ok)throw Error(`Agent request failed (${o.status}).`,{cause:await o.json().catch(()=>o.statusText)});return o}async function ap(e,t=!1){if(!e.body)throw Error("Agent stream response had no body.");let r=async(a)=>{if(!process.stdout.write(a))await Lw(process.stdout,"drain")};if(t){await e.body.pipeTo(new WritableStream({async write(a){await r(a)}}));return}let n=e.body.getReader(),s=new TextDecoder,o="",i=async(a)=>{let c="message",l,u=[];for(let g of a.split(/\r?\n/)){if(g.startsWith("event:"))c=g.slice(6).trim();if(g.startsWith("id:"))l=g.slice(3).trim();if(g.startsWith("data:"))u.push(g.slice(5).trimStart())}if(u.length===0)return;let p=u.join(`
192
+ `),d=p;try{d=JSON.parse(p)}catch{}if(await r(`${JSON.stringify({event:c,...l?{id:l}:{},data:d})}
193
+ `),c==="error")throw Error("Agent run stream reported an error.",{cause:d})};while(!0){let{done:a,value:c}=await n.read();o+=s.decode(c,{stream:!a});let l=o.match(/\r?\n\r?\n/);while(l?.index!==void 0)await i(o.slice(0,l.index)),o=o.slice(l.index+l[0].length),l=o.match(/\r?\n\r?\n/);if(a)break}if(o.trim())await i(o)}function Wt(e){return e?JSON.parse(zw(e,"utf8")):{}}async function cp(e,t,r,n,s={}){let o=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads`,{method:"POST",body:JSON.stringify(s)});console.log(JSON.stringify(await o.json(),null,2))}async function lp(e,t,r,n,s,o){let i=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/messages`,{method:"POST",body:JSON.stringify(o)});console.log(JSON.stringify(await i.json(),null,2))}async function up(e,t,r,n,s){let o=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/search`,{method:"POST",body:JSON.stringify(s)});console.log(JSON.stringify(await o.json(),null,2))}async function pp(e,t,r,n,s){let o=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}`);console.log(JSON.stringify(await o.json(),null,2))}async function dp(e,t,r,n,s,o){let i=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/history`,{method:"POST",body:JSON.stringify(o)});console.log(JSON.stringify(await i.json(),null,2))}async function mp(e,t,r,n,s){let o=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/state`);console.log(JSON.stringify(await o.json(),null,2))}async function fp(e,t,r,n,s,o,i){let a=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/messages/${encodeURIComponent(o)}/feedback`,{method:"POST",body:JSON.stringify(i)});console.log(JSON.stringify(await a.json(),null,2))}async function hp(e,t,r,n,s,o,i={}){let a=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs/stream`,{method:"POST",headers:{Accept:"text/event-stream"},body:JSON.stringify(o)});await ap(a,i.raw)}async function gp(e,t,r,n,s,o){let i=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs`,{method:"POST",body:JSON.stringify(o)});console.log(JSON.stringify(await i.json(),null,2))}async function yp(e,t,r,n,s,o,i,a={}){let c=new URL(`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/runs/${encodeURIComponent(o)}/stream`,e);for(let[u,p]of Object.entries(i.query??{}))c.searchParams.set(u,p);let l=await Pe(e,t,r,`${c.pathname}${c.search}`,{headers:{Accept:"text/event-stream",...i.lastEventId?{"Last-Event-ID":i.lastEventId}:{}}});await ap(l,a.raw)}async function bp(e,t,r,n,s,o={}){let i=new URLSearchParams;for(let[c,l]of Object.entries(o))if(l!==void 0)i.set(c,l);let a=await Pe(e,t,r,`/apps/${encodeURIComponent(n)}/agent/langgraph/threads/${encodeURIComponent(s)}/artifacts?${i}`);console.log(JSON.stringify(await a.json(),null,2))}function wp(e,t,r={}){let n=e.command("agent").description("Run app conversations"),s=n.command("threads").description("Manage agent threads"),o=n.command("runs").description("Start agent runs");s.command("artifacts").argument("<app-key>").argument("<thread-id>").description("List accessible artifacts created or updated in a thread").option("--limit <limit>","Page size (1–100)").option("--cursor <cursor>","Cursor from the previous page").option("--run-id <run-id>","Filter associations to a run").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentThreadsArtifacts??bp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,c)}),s.command("create").argument("<app-key>","App key").option("--origin <origin>","Assistant that started the chat, as a lowercase slug such as labeeb").option("--external-conversation-id <id>","That assistant's conversation; the same conversation returns the same chat").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsCreate??cp)(c.serverUrl,c.accessToken,c.workspaceKey,i,a)}),s.command("append-messages").argument("<app-key>","App key").argument("<thread-id>","Thread ID").requiredOption("--input-file <file>",'JSON with "messages": one finished exchange').description("Add an exchange another assistant answered to a thread").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentThreadsAppendMessages??lp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,Wt(c.inputFile))}),s.command("search").argument("<app-key>","App key").option("--input-file <file>","LangGraph search JSON").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsSearch??up)(c.serverUrl,c.accessToken,c.workspaceKey,i,Wt(a.inputFile))}),s.command("get").argument("<app-key>","App key").argument("<thread-id>","Thread ID").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsGet??pp)(c.serverUrl,c.accessToken,c.workspaceKey,i,a)}),s.command("history").argument("<app-key>","App key").argument("<thread-id>","Thread ID").option("--input-file <file>","LangGraph history JSON").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentThreadsHistory??dp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,Wt(c.inputFile))}),s.command("state").argument("<app-key>","App key").argument("<thread-id>","Thread ID").action(async(i,a)=>{let c=await t.createWorkspaceContext();await(r.runAgentThreadsState??mp)(c.serverUrl,c.accessToken,c.workspaceKey,i,a)}),s.command("feedback").argument("<app-key>","App key").argument("<thread-id>","Thread ID").argument("<message-id>","Message ID").requiredOption("--score <score>","0 or 1").option("--comment <comment>","Feedback comment").action(async(i,a,c,l)=>{if(l.score!=="0"&&l.score!=="1")throw Error("--score must be 0 or 1.");let u=await t.createWorkspaceContext();await(r.runAgentThreadsFeedback??fp)(u.serverUrl,u.accessToken,u.workspaceKey,i,a,c,{score:Number.parseInt(l.score,10),...l.comment?{comment:l.comment}:{}})}),o.command("stream").argument("<app-key>","App key").argument("<thread-id>","Thread ID").requiredOption("--input-file <file>","LangGraph run JSON").option("--raw","Print the original SSE byte stream").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentRunsStream??hp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,Wt(c.inputFile),{raw:c.raw})}),o.command("create").argument("<app-key>","App key").argument("<thread-id>","Thread ID").requiredOption("--input-file <file>","LangGraph run JSON").action(async(i,a,c)=>{let l=await t.createWorkspaceContext();await(r.runAgentRunsCreate??gp)(l.serverUrl,l.accessToken,l.workspaceKey,i,a,Wt(c.inputFile))}),o.command("join").argument("<app-key>","App key").argument("<thread-id>","Thread ID").argument("<run-id>","Run ID").option("--last-event-id <id>","Resume after this SSE event").option("--query <json>","Join-stream query parameters as JSON").option("--raw","Print the original SSE byte stream").action(async(i,a,c,l)=>{let u=await t.createWorkspaceContext();await(r.runAgentRunsJoin??yp)(u.serverUrl,u.accessToken,u.workspaceKey,i,a,c,{lastEventId:l.lastEventId,query:l.query?JSON.parse(l.query):void 0},{raw:l.raw})})}import{readFileSync as sr}from"node:fs";import{writeFileSync as Kw}from"node:fs";var Sr=1;function me(e,t,r=!1){try{Kw(e,t,{flag:r?"w":"wx"})}catch(n){if(!r&&n instanceof Error&&"code"in n&&n.code==="EEXIST")throw Error(`Output file '${e}' already exists. Pass --force to replace it.`);throw n}}function fe(e,t={}){console.log(JSON.stringify({schemaVersion:Sr,ok:!0,outputFile:e,...t},null,2))}function xe(e){process.stderr.write(`${e}
194
+ `)}var tt=class extends Error{constructor(e,t){super(t+"");this.status=e,this.value=t}},Rw=/(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))/,Uw=/(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT(?:\+|-)\d{4}\s\([^)]+\)/,Mw=/^(?:(?:(?:(?:0?[1-9]|[12][0-9]|3[01])[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:19|20)\d{2})|(?:(?:19|20)\d{2}[/\s-](?:0?[1-9]|1[0-2])[/\s-](?:0?[1-9]|[12][0-9]|3[01]))))(?:\s(?:1[012]|0?[1-9]):[0-5][0-9](?::[0-5][0-9])?(?:\s[AP]M)?)?$/,jw=(e)=>e.trim().length!==0&&!Number.isNaN(Number(e)),yn=(e,t)=>{if(typeof e!="string"||t?.parseDate===!1)return null;let r=e.replace(/"/g,"");if(Rw.test(r)||Uw.test(r)||Mw.test(r)){let n=new Date(r);if(!Number.isNaN(n.getTime()))return n}return null},Zw=(e)=>{let t=e.charCodeAt(0),r=e.charCodeAt(e.length-1);return t===123&&r===125||t===91&&r===93},Vw=(e,t)=>JSON.parse(e,(r,n)=>yn(n,t)||n),Ct=(e,t)=>{if(!e)return e;if(jw(e))return+e;if(e==="true")return!0;if(e==="false")return!1;if(t?.parseDate!==!1){let r=yn(e,t);if(r)return r}if(Zw(e))try{return Vw(e,t)}catch{}return e},xo=(e,t)=>{let r=e.data.toString();return r==="null"?null:Ct(r,t)};var Ww=class{constructor(e){this.url=e,this.ws=new WebSocket(e)}ws;send(e){return Array.isArray(e)?(e.forEach((t)=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,r){return this.addEventListener(e,t,r)}off(e,t,r){return this.ws.removeEventListener(e,t,r),this}subscribe(e,t){return this.addEventListener("message",e,t)}addEventListener(e,t,r){return this.ws.addEventListener(e,(n)=>{if(e==="message"){let s=xo(n);t({...n,data:s})}else t(n)},r),this}removeEventListener(e,t,r){return this.off(e,t,r),this}close(){return this.ws.close(),this}},Gw=["get","post","put","delete","patch","options","head","connect","subscribe"],vp=(e,t)=>typeof t=="function"?t(e):t===!0,xp=["localhost","127.0.0.1","0.0.0.0"],_o=typeof FileList>"u",bn=(e)=>_o?e instanceof Blob:e instanceof FileList||e instanceof File,Jw=(e)=>{if(!e)return!1;for(let t in e)if(bn(e[t])||Array.isArray(e[t])&&e[t].find(bn))return!0;return!1},Co=(e)=>_o?e:new Promise((t)=>{let r=new FileReader;r.onload=()=>{let n=new File([r.result],e.name,{lastModified:e.lastModified,type:e.type});t(n)},r.readAsArrayBuffer(e)}),_t=async(e,t,r={},n={})=>{if(Array.isArray(e)){for(let s of e)if(!Array.isArray(s))n=await _t(s,t,r,n);else{let o=s[0];if(typeof o=="string")n[o.toLowerCase()]=s[1];else for(let[i,a]of o)n[i.toLowerCase()]=a}return n}if(!e)return n;switch(typeof e){case"function":if(e instanceof Headers)return _t(e,t,r,n);let s=await e(t,r);return s?_t(s,t,r,n):n;case"object":if(e instanceof Headers)return e.forEach((o,i)=>{n[i.toLowerCase()]=o}),n;for(let[o,i]of Object.entries(e))n[o.toLowerCase()]=i;return n;default:return n}};function Cp(e,t){let r=e.split(`
195
+ `),n={};for(let s of r){if(!s||s.startsWith(":"))continue;let o=s.indexOf(":");if(o>0){let i=s.slice(0,o).trim(),a=s.slice(o+1).replace(/^ /,"");n[i]=a&&Ct(a,t)}}return Object.keys(n).length>0?n:null}function*kp(e,t){let r;for(;(r=e.value.indexOf(`
196
196
 
197
- `))!==-1;){let n=e.value.slice(0,r);if(e.value=e.value.slice(r+2),n.trim()){let s=kp(n,t);s&&(yield s)}}}async function*wp(e,t){let r=e.body;if(!r)return;let n=r.getReader(),s=new TextDecoder("utf-8");if(e.headers.get("Content-Type")?.startsWith("text/event-stream")){let o={value:""};try{for(;;){let{done:a,value:c}=await n.read();if(a)break;let l=typeof c=="string"?c:s.decode(c,{stream:!0});o.value+=l,yield*bp(o,t)}let i=s.decode();if(i&&(o.value+=i),yield*bp(o,t),o.value.trim()){let a=kp(o.value,t);a&&(yield a)}}finally{n.releaseLock()}}else try{for(;;){let{done:o,value:i}=await n.read();if(o)break;yield Ct(typeof i=="string"?i:s.decode(i,{stream:!0}),{parseDate:t?.parseDate})}}finally{n.releaseLock()}}var xr=(e,t,r=[],n)=>new Proxy(()=>{},{get(s,o){if(o==="~path")return"/"+r.join("/");if(!(r.length===0&&(o==="then"||o==="catch"||o==="finally")))return xr(e,t,[...r,o],n)},apply(s,o,[i,a]){if(!i||a||typeof i=="object"&&Object.keys(i).length!==1||Rw.includes(r.at(-1))){let c=[...r],l=c.pop(),p="/"+c.join("/"),{fetcher:u=fetch,headers:d,onRequest:h,onResponse:b,fetch:g}=t,w=l==="get"||l==="head"||l==="subscribe",T=w?i?.query:a?.query,N="";if(T){let x=(D,P)=>{P!=null&&(P instanceof Date&&(P=P.toISOString()),N+=(N?"&":"?")+`${encodeURIComponent(D)}=${encodeURIComponent(typeof P=="object"?JSON.stringify(P):P+"")}`)};for(let[D,P]of Object.entries(T)){if(Array.isArray(P)){for(let L of P)x(D,L);continue}x(D,P)}}if(l==="subscribe"){let x=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||vp.find((D)=>e.includes(D))?"ws://":"wss://")+p+N;return new Kw(x)}return(async()=>{d=await _t(d,p,a);let x={method:l?.toUpperCase(),body:i,...g,headers:d};x.headers={...d,...await _t(w?i?.headers:a?.headers,p,x)};let D=w&&typeof i=="object"?i.fetch:a?.fetch,P=(w&&typeof i=="object"?i.throwHttpError:a?.throwHttpError)??t.throwHttpError;if(x={...x,...D},w&&delete x.body,h){Array.isArray(h)||(h=[h]);for(let C of h){let v=await C(p,x);typeof v=="object"&&(x={...x,...v,headers:{...x.headers,...await _t(v.headers,p,x)}})}}if(w&&delete x.body,Uw(i)){let C=new FormData,v=(U)=>{if(typeof U=="string"||bn(U))return!1;if(typeof U=="object"){if(U!==null)return!0;if(U instanceof Date)return!1}return!1},A=async(U)=>U instanceof File?await xo(U):v(U)?JSON.stringify(U):U;for(let[U,G]of Object.entries(x.body)){if(Array.isArray(G)){if(G.some((B)=>typeof B=="object"&&B!==null&&!bn(B)))C.append(U,JSON.stringify(G));else for(let B=0;B<G.length;B++){let Fe=G[B],ye=await A(Fe);C.append(U,ye)}continue}if(Co){if(Array.isArray(G))for(let B of G)C.append(U,await A(B));else C.append(U,await A(G));continue}if(G instanceof File){C.append(U,await xo(G));continue}if(G instanceof FileList){for(let B=0;B<G.length;B++)C.append(U,await xo(G[B]));continue}C.append(U,await A(G))}x.body=C}else typeof i=="object"?(x.headers["content-type"]="application/json",x.body=JSON.stringify(i)):i!=null&&(x.headers["content-type"]="text/plain");if(w&&delete x.body,h){Array.isArray(h)||(h=[h]);for(let C of h){let v=await C(p,x);typeof v=="object"&&(x={...x,...v,headers:{...x.headers,...await _t(v.headers,p,x)}})}}a?.headers?.["content-type"]&&(x.headers["content-type"]=a?.headers["content-type"]);let L=e+p+N,K;try{K=await(n?.handle(new Request(L,x))??u(L,x))}catch(C){let v=new tt(503,C);if(yp(v,P))throw v;return{data:null,error:v,response:void 0,status:503,headers:void 0}}let E=null,O=null;if(b){Array.isArray(b)||(b=[b]);for(let C of b)try{let v=await C(K.clone());if(v!=null){E=v;break}}catch(v){v instanceof tt?O=v:O=new tt(422,v);break}}if(E!==null)return{data:E,error:O,response:K,status:K.status,headers:K.headers};switch(K.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":E=wp(K,{parseDate:t.parseDate});break;case"application/json":E=JSON.parse(await K.text(),(v,A)=>{if(typeof A!="string")return A;return yn(A,{parseDate:t.parseDate})||A});break;case"application/octet-stream":E=await K.arrayBuffer();break;case"multipart/form-data":let C=await K.formData();E={},C.forEach((v,A)=>{E[A]=v});break;default:K.headers.get("content-type")?.startsWith("text/")&&K.headers.get("transfer-encoding")==="chunked"&&!K.headers.has("content-length")?E=wp(K,{parseDate:t.parseDate}):E=await K.text().then((v)=>Ct(v,{parseDate:t.parseDate}))}if(K.status>=300||K.status<200){if(O=new tt(K.status,E),yp(O,P))throw O;E=null}return{data:E,error:O,response:K,status:K.status,headers:K.headers}})()}return typeof i=="object"?xr(e,t,[...r,Object.values(i)[0]],n):xr(e,t,r)}}),_o=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(vp.find((r)=>e.includes(r))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),xr(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),xr("http://e.ly",t,[],e));function Sp(e,t={}){return _o(e,{headers:async()=>{let r=t.getAccessToken?await t.getAccessToken():null,n=t.getWorkspaceKey?await t.getWorkspaceKey():null;return{"x-s-client":"cli",...r?{authorization:`Bearer ${r}`}:{},...n?{"x-s-workspace-key":n}:{}}}})}function V(e,t={}){return Sp(e,t)}function k(e,t,r){return V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r})}async function wn(e){let r=await V(e).auth.config.get(),{data:n,error:s}=r;if(s||!n)throw Error("Failed to load server auth configuration.",{cause:s});return n}async function xp(e,t,r,n,s,o={}){let a=k(e,t,r).connections({connectionKey:n}).catalog,{data:c,error:l}=s?await a.get({query:s}):await a.get();if(l||!c)throw Error("Failed to read connection catalog.",{cause:l});let p=c.type==="tables"&&o.search?{...c,totalTableCount:c.tables.length,tables:c.tables.filter((b)=>`${b.database}.${b.schema}.${b.table}`.toLowerCase().includes(o.search.toLowerCase()))}:c,u=p.type==="tables"&&(o.summary||p.tables.length>1000&&!o.search&&!o.full&&!o.outputFile),d=u&&p.type==="tables"?{schemaVersion:Sr,type:"catalog-summary",databaseCount:new Set(p.tables.map((b)=>b.database)).size,schemaCount:new Set(p.tables.map((b)=>`${b.database}.${b.schema}`)).size,tableCount:p.tables.length,totalTableCount:"totalTableCount"in p?p.totalTableCount:p.tables.length}:p,h=`${JSON.stringify(d,null,2)}
198
- `;if(o.outputFile){me(o.outputFile,h,o.force),fe(o.outputFile,{kind:"connection-catalog",tableCount:p.type==="tables"?p.tables.length:1});return}if(u&&!o.summary)process.stderr.write(`${JSON.stringify({event:"warning",data:{type:"large-output-summarized",tableCount:p.type==="tables"?p.tables.length:0,suggestion:"Use --search, --full, or --output-file to retrieve table references."}})}
199
- `);process.stdout.write(h)}async function Cp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections.post({connectionKey:n.connectionKey,displayName:n.displayName,type:n.type,config:n.config});if(i||!o)throw Error("Failed to create connection.",{cause:i});console.log(JSON.stringify(o,null,2))}async function _p(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections({connectionKey:n}).health.post();if(i||!o)throw Error("Failed to check connection health.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ap(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.connections.get();if(o||!s)throw Error("Failed to list connections.",{cause:o});console.log(JSON.stringify(s.connections,null,2))}async function Op(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections({connectionKey:n.connectionKey}).put({displayName:n.displayName,type:n.type,config:n.config});if(i||!o)throw Error("Failed to update connection.",{cause:i});console.log(JSON.stringify(o,null,2))}function Ao(e){return`${e.appKey}/${e.dashboardKey}${e.isDraft?" (draft)":""}`}function Tp(e){return`${e.evaluationSetKey}/${e.evaluationCaseKey}`}function Mw(e){let t=[e.error??"Model is referenced by active dashboards or evaluation cases"];if(e.dashboards?.length)t.push(`Dashboards: ${e.dashboards.map(Ao).join(", ")}`);if(e.evaluationCases?.length)t.push(`Evaluation cases: ${e.evaluationCases.map(Tp).join(", ")}`);return t.push("Re-run with --cascade to delete these too. Cascading deletes an entire referencing dashboard, including charts that use other models."),t.join(`
200
- `)}function jw(e){let t=[`Deleted model '${e.model.modelKey}'.`];if(e.dashboards.length)t.push(`Deleted dashboards: ${e.dashboards.map(Ao).join(", ")}`);if(e.drafts.length)t.push(`Deleted drafts: ${e.drafts.map(Ao).join(", ")}`);if(e.evaluationCases.length)t.push(`Deleted evaluation cases: ${e.evaluationCases.map(Tp).join(", ")}`);return t.join(`
201
- `)}async function $p(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).delete(void 0,{query:n.cascade?{cascade:"true"}:{}});if(i){let a=i&&typeof i==="object"&&"value"in i?i.value:void 0;if(a?.dashboards||a?.evaluationCases)throw Error(Mw(a),{cause:i});throw Error("Failed to delete model.",{cause:i})}if(!o)throw Error("Failed to delete model.");console.log(jw(o)),console.log(JSON.stringify(o,null,2))}async function Ep(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).get();if(i||!o)throw Error("Failed to get model.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Np(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.models.get();if(o||!s)throw Error("Failed to list models.",{cause:o});console.log(JSON.stringify(s.models,null,2))}async function Dp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models.post({connectionKey:n.connectionKey,modelKey:n.modelKey,displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions});if(i||!o)throw Error("Failed to create model.",{cause:i});console.log(JSON.stringify(o,null,2))}import{readFileSync as qT}from"node:fs";import{extname as KT}from"node:path";var tT=_i(),rT=Rr(),nT=li(),zi=Ur(),sT=Ar(),ut=J(),oT=ot(),iT=ae(),aT=at(),cT=ct(),HP=ss(),lT=Ii(),uT=Fi(),pT=Li(),cs=Rm(),Um=Cr();var dT=tT.Composer,mT=rT.Document,fT=nT.Schema,{YAMLError:hT,YAMLParseError:gT,YAMLWarning:yT}=zi,bT=sT.Alias,{isAlias:wT,isCollection:vT,isDocument:kT,isMap:ST,isNode:xT,isPair:CT,isScalar:_T,isSeq:AT}=ut,OT=oT.Pair,TT=iT.Scalar,$T=aT.YAMLMap,ET=cT.YAMLSeq;var NT=lT.Lexer,DT=uT.LineCounter,PT=pT.Parser,{parse:Ue,parseAllDocuments:IT,parseDocument:FT,stringify:Ce}=cs,{visit:LT,visitAsync:zT}=Um;function pt(e){try{let t=qT(e,"utf8");return RT(e,t)}catch(t){throw Error(`Failed to read model file '${e}'. ${t instanceof Error?t.message:""}`.trim(),{cause:t})}}function Mm(e,t,r=!1){let n=jm(e);me(e,n==="json"?`${JSON.stringify(t,null,2)}
202
- `:Ce(t),r)}function RT(e,t){return jm(e)==="json"?JSON.parse(t):Ue(t)}function jm(e){let t=KT(e).toLowerCase();if(t===".json")return"json";if(t===".yaml"||t===".yml")return"yaml";throw Error(`Model files must use .json, .yaml, or .yml: '${e}'.`)}async function Zm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models["with-version"].post({connectionKey:n.connectionKey,displayName:n.displayName,label:n.label,modelKey:n.modelKey,modelSqlInstructions:n.modelSqlInstructions,definition:pt(n.modelFile)});if(i||!o)throw Error("Failed to create model with its first version.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Vm(e,t,r,n){let s=k(e,t,r),o=n.limit??100;if(n.queryKey){let{data:l,error:p}=await s.models({modelKey:n.modelKey}).query.json({queryKey:n.queryKey}).get({query:{limit:o}});if(p||!l)throw Error("Failed to query model.",{cause:p});if(l.truncated)process.stderr.write(`${JSON.stringify({event:"warning",data:{type:"truncated",returnedRowCount:l.rows.length,totalRowCount:l.totalRowCount,limit:o}})}
197
+ `))!==-1;){let n=e.value.slice(0,r);if(e.value=e.value.slice(r+2),n.trim()){let s=Cp(n,t);s&&(yield s)}}}async function*Sp(e,t){let r=e.body;if(!r)return;let n=r.getReader(),s=new TextDecoder("utf-8");if(e.headers.get("Content-Type")?.startsWith("text/event-stream")){let o={value:""};try{for(;;){let{done:a,value:c}=await n.read();if(a)break;let l=typeof c=="string"?c:s.decode(c,{stream:!0});o.value+=l,yield*kp(o,t)}let i=s.decode();if(i&&(o.value+=i),yield*kp(o,t),o.value.trim()){let a=Cp(o.value,t);a&&(yield a)}}finally{n.releaseLock()}}else try{for(;;){let{done:o,value:i}=await n.read();if(o)break;yield Ct(typeof i=="string"?i:s.decode(i,{stream:!0}),{parseDate:t?.parseDate})}}finally{n.releaseLock()}}var xr=(e,t,r=[],n)=>new Proxy(()=>{},{get(s,o){if(o==="~path")return"/"+r.join("/");if(!(r.length===0&&(o==="then"||o==="catch"||o==="finally")))return xr(e,t,[...r,o],n)},apply(s,o,[i,a]){if(!i||a||typeof i=="object"&&Object.keys(i).length!==1||Gw.includes(r.at(-1))){let c=[...r],l=c.pop(),u="/"+c.join("/"),{fetcher:p=fetch,headers:d,onRequest:g,onResponse:b,fetch:y}=t,w=l==="get"||l==="head"||l==="subscribe",T=w?i?.query:a?.query,N="";if(T){let x=(D,P)=>{P!=null&&(P instanceof Date&&(P=P.toISOString()),N+=(N?"&":"?")+`${encodeURIComponent(D)}=${encodeURIComponent(typeof P=="object"?JSON.stringify(P):P+"")}`)};for(let[D,P]of Object.entries(T)){if(Array.isArray(P)){for(let L of P)x(D,L);continue}x(D,P)}}if(l==="subscribe"){let x=e.replace(/^([^]+):\/\//,e.startsWith("https://")?"wss://":e.startsWith("http://")||xp.find((D)=>e.includes(D))?"ws://":"wss://")+u+N;return new Ww(x)}return(async()=>{d=await _t(d,u,a);let x={method:l?.toUpperCase(),body:i,...y,headers:d};x.headers={...d,...await _t(w?i?.headers:a?.headers,u,x)};let D=w&&typeof i=="object"?i.fetch:a?.fetch,P=(w&&typeof i=="object"?i.throwHttpError:a?.throwHttpError)??t.throwHttpError;if(x={...x,...D},w&&delete x.body,g){Array.isArray(g)||(g=[g]);for(let C of g){let v=await C(u,x);typeof v=="object"&&(x={...x,...v,headers:{...x.headers,...await _t(v.headers,u,x)}})}}if(w&&delete x.body,Jw(i)){let C=new FormData,v=(U)=>{if(typeof U=="string"||bn(U))return!1;if(typeof U=="object"){if(U!==null)return!0;if(U instanceof Date)return!1}return!1},A=async(U)=>U instanceof File?await Co(U):v(U)?JSON.stringify(U):U;for(let[U,G]of Object.entries(x.body)){if(Array.isArray(G)){if(G.some((B)=>typeof B=="object"&&B!==null&&!bn(B)))C.append(U,JSON.stringify(G));else for(let B=0;B<G.length;B++){let Le=G[B],ye=await A(Le);C.append(U,ye)}continue}if(_o){if(Array.isArray(G))for(let B of G)C.append(U,await A(B));else C.append(U,await A(G));continue}if(G instanceof File){C.append(U,await Co(G));continue}if(G instanceof FileList){for(let B=0;B<G.length;B++)C.append(U,await Co(G[B]));continue}C.append(U,await A(G))}x.body=C}else typeof i=="object"?(x.headers["content-type"]="application/json",x.body=JSON.stringify(i)):i!=null&&(x.headers["content-type"]="text/plain");if(w&&delete x.body,g){Array.isArray(g)||(g=[g]);for(let C of g){let v=await C(u,x);typeof v=="object"&&(x={...x,...v,headers:{...x.headers,...await _t(v.headers,u,x)}})}}a?.headers?.["content-type"]&&(x.headers["content-type"]=a?.headers["content-type"]);let L=e+u+N,K;try{K=await(n?.handle(new Request(L,x))??p(L,x))}catch(C){let v=new tt(503,C);if(vp(v,P))throw v;return{data:null,error:v,response:void 0,status:503,headers:void 0}}let E=null,O=null;if(b){Array.isArray(b)||(b=[b]);for(let C of b)try{let v=await C(K.clone());if(v!=null){E=v;break}}catch(v){v instanceof tt?O=v:O=new tt(422,v);break}}if(E!==null)return{data:E,error:O,response:K,status:K.status,headers:K.headers};switch(K.headers.get("Content-Type")?.split(";")[0]){case"text/event-stream":E=Sp(K,{parseDate:t.parseDate});break;case"application/json":E=JSON.parse(await K.text(),(v,A)=>{if(typeof A!="string")return A;return yn(A,{parseDate:t.parseDate})||A});break;case"application/octet-stream":E=await K.arrayBuffer();break;case"multipart/form-data":let C=await K.formData();E={},C.forEach((v,A)=>{E[A]=v});break;default:K.headers.get("content-type")?.startsWith("text/")&&K.headers.get("transfer-encoding")==="chunked"&&!K.headers.has("content-length")?E=Sp(K,{parseDate:t.parseDate}):E=await K.text().then((v)=>Ct(v,{parseDate:t.parseDate}))}if(K.status>=300||K.status<200){if(O=new tt(K.status,E),vp(O,P))throw O;E=null}return{data:E,error:O,response:K,status:K.status,headers:K.headers}})()}return typeof i=="object"?xr(e,t,[...r,Object.values(i)[0]],n):xr(e,t,r)}}),Ao=(e,t={})=>typeof e=="string"?(t.keepDomain||(e.includes("://")||(e=(xp.find((r)=>e.includes(r))?"http://":"https://")+e),e.endsWith("/")&&(e=e.slice(0,-1))),xr(e,t)):(typeof window<"u"&&console.warn("Elysia instance server found on client side, this is not recommended for security reason. Use generic type instead."),xr("http://e.ly",t,[],e));function _p(e,t={}){return Ao(e,{headers:async()=>{let r=t.getAccessToken?await t.getAccessToken():null,n=t.getWorkspaceKey?await t.getWorkspaceKey():null;return{"x-s-client":"cli",...r?{authorization:`Bearer ${r}`}:{},...n?{"x-s-workspace-key":n}:{}}}})}function V(e,t={}){return _p(e,t)}function k(e,t,r){return V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r})}async function wn(e){let r=await V(e).auth.config.get(),{data:n,error:s}=r;if(s||!n)throw Error("Failed to load server auth configuration.",{cause:s});return n}async function Ap(e,t,r,n,s,o={}){let a=k(e,t,r).connections({connectionKey:n}).catalog,{data:c,error:l}=s?await a.get({query:s}):await a.get();if(l||!c)throw Error("Failed to read connection catalog.",{cause:l});let u=c.type==="tables"&&o.search?{...c,totalTableCount:c.tables.length,tables:c.tables.filter((b)=>`${b.database}.${b.schema}.${b.table}`.toLowerCase().includes(o.search.toLowerCase()))}:c,p=u.type==="tables"&&(o.summary||u.tables.length>1000&&!o.search&&!o.full&&!o.outputFile),d=p&&u.type==="tables"?{schemaVersion:Sr,type:"catalog-summary",databaseCount:new Set(u.tables.map((b)=>b.database)).size,schemaCount:new Set(u.tables.map((b)=>`${b.database}.${b.schema}`)).size,tableCount:u.tables.length,totalTableCount:"totalTableCount"in u?u.totalTableCount:u.tables.length}:u,g=`${JSON.stringify(d,null,2)}
198
+ `;if(o.outputFile){me(o.outputFile,g,o.force),fe(o.outputFile,{kind:"connection-catalog",tableCount:u.type==="tables"?u.tables.length:1});return}if(p&&!o.summary)process.stderr.write(`${JSON.stringify({event:"warning",data:{type:"large-output-summarized",tableCount:u.type==="tables"?u.tables.length:0,suggestion:"Use --search, --full, or --output-file to retrieve table references."}})}
199
+ `);process.stdout.write(g)}async function Op(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections.post({connectionKey:n.connectionKey,displayName:n.displayName,type:n.type,config:n.config});if(i||!o)throw Error("Failed to create connection.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Tp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections({connectionKey:n}).health.post();if(i||!o)throw Error("Failed to check connection health.",{cause:i});console.log(JSON.stringify(o,null,2))}async function $p(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.connections.get();if(o||!s)throw Error("Failed to list connections.",{cause:o});console.log(JSON.stringify(s.connections,null,2))}async function Ep(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.connections({connectionKey:n.connectionKey}).put({displayName:n.displayName,type:n.type,config:n.config});if(i||!o)throw Error("Failed to update connection.",{cause:i});console.log(JSON.stringify(o,null,2))}function Oo(e){return`${e.appKey}/${e.dashboardKey}${e.isDraft?" (draft)":""}`}function Np(e){return`${e.evaluationSetKey}/${e.evaluationCaseKey}`}function Bw(e){let t=[e.error??"Model is referenced by active dashboards or evaluation cases"];if(e.dashboards?.length)t.push(`Dashboards: ${e.dashboards.map(Oo).join(", ")}`);if(e.evaluationCases?.length)t.push(`Evaluation cases: ${e.evaluationCases.map(Np).join(", ")}`);return t.push("Re-run with --cascade to delete these too. Cascading deletes an entire referencing dashboard, including charts that use other models."),t.join(`
200
+ `)}function Hw(e){let t=[`Deleted model '${e.model.modelKey}'.`];if(e.dashboards.length)t.push(`Deleted dashboards: ${e.dashboards.map(Oo).join(", ")}`);if(e.drafts.length)t.push(`Deleted drafts: ${e.drafts.map(Oo).join(", ")}`);if(e.evaluationCases.length)t.push(`Deleted evaluation cases: ${e.evaluationCases.map(Np).join(", ")}`);return t.join(`
201
+ `)}async function Dp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).delete(void 0,{query:n.cascade?{cascade:"true"}:{}});if(i){let a=i&&typeof i==="object"&&"value"in i?i.value:void 0;if(a?.dashboards||a?.evaluationCases)throw Error(Bw(a),{cause:i});throw Error("Failed to delete model.",{cause:i})}if(!o)throw Error("Failed to delete model.");console.log(Hw(o)),console.log(JSON.stringify(o,null,2))}async function Pp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).get();if(i||!o)throw Error("Failed to get model.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ip(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.models.get();if(o||!s)throw Error("Failed to list models.",{cause:o});console.log(JSON.stringify(s.models,null,2))}async function Fp(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models.post({connectionKey:n.connectionKey,modelKey:n.modelKey,displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions});if(i||!o)throw Error("Failed to create model.",{cause:i});console.log(JSON.stringify(o,null,2))}import{readFileSync as VT}from"node:fs";import{extname as WT}from"node:path";var cT=Ai(),lT=Rr(),uT=ui(),qi=Ur(),pT=Ar(),ut=J(),dT=ot(),mT=ae(),fT=at(),hT=ct(),iI=ss(),gT=Fi(),yT=Li(),bT=zi(),cs=jm(),Zm=Cr();var wT=cT.Composer,vT=lT.Document,kT=uT.Schema,{YAMLError:ST,YAMLParseError:xT,YAMLWarning:CT}=qi,_T=pT.Alias,{isAlias:AT,isCollection:OT,isDocument:TT,isMap:$T,isNode:ET,isPair:NT,isScalar:DT,isSeq:PT}=ut,IT=dT.Pair,FT=mT.Scalar,LT=fT.YAMLMap,zT=hT.YAMLSeq;var qT=gT.Lexer,KT=yT.LineCounter,RT=bT.Parser,{parse:Ue,parseAllDocuments:UT,parseDocument:MT,stringify:Ce}=cs,{visit:jT,visitAsync:ZT}=Zm;function pt(e){try{let t=VT(e,"utf8");return GT(e,t)}catch(t){throw Error(`Failed to read model file '${e}'. ${t instanceof Error?t.message:""}`.trim(),{cause:t})}}function Vm(e,t,r=!1){let n=Wm(e);me(e,n==="json"?`${JSON.stringify(t,null,2)}
202
+ `:Ce(t),r)}function GT(e,t){return Wm(e)==="json"?JSON.parse(t):Ue(t)}function Wm(e){let t=WT(e).toLowerCase();if(t===".json")return"json";if(t===".yaml"||t===".yml")return"yaml";throw Error(`Model files must use .json, .yaml, or .yml: '${e}'.`)}async function Gm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models["with-version"].post({connectionKey:n.connectionKey,displayName:n.displayName,label:n.label,modelKey:n.modelKey,modelSqlInstructions:n.modelSqlInstructions,definition:pt(n.modelFile)});if(i||!o)throw Error("Failed to create model with its first version.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Jm(e,t,r,n){let s=k(e,t,r),o=n.limit??100;if(n.queryKey){let{data:l,error:u}=await s.models({modelKey:n.modelKey}).query.json({queryKey:n.queryKey}).get({query:{limit:o}});if(u||!l)throw Error("Failed to query model.",{cause:u});if(l.truncated)process.stderr.write(`${JSON.stringify({event:"warning",data:{type:"truncated",returnedRowCount:l.rows.length,totalRowCount:l.totalRowCount,limit:o}})}
203
203
  `);console.log(JSON.stringify(l,null,2));return}let{data:i,error:a}=await s.models({modelKey:n.modelKey}).query.json.post({queries:[n.sql],limit:o});if(a||!i)throw Error("Failed to query model.",{cause:a});let c=i.find((l)=>("error"in l));if(c)throw Error("Model query execution failed.",{cause:c});if(i.some((l)=>("truncated"in l)&&l.truncated))process.stderr.write(`${JSON.stringify({event:"warning",data:{type:"truncated",queries:i.filter((l)=>("truncated"in l)&&l.truncated).map((l)=>({queryKey:"queryKey"in l?l.queryKey:null,returnedRowCount:"rows"in l?l.rows.length:0,totalRowCount:"totalRowCount"in l?l.totalRowCount:null,limit:o}))}})}
204
- `);console.log(JSON.stringify(i,null,2))}async function Wm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey})["search-dimension-artifact"].get();if(i||!o)throw Error("Failed to get search dimension artifact.",{cause:i});if(n.outputFile)me(n.outputFile,o.sql,n.force),fe(n.outputFile,{format:"sql"});else console.log(JSON.stringify(o,null,2))}async function Gm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey})["search-dimensions"].post({searchTerms:n.searchTerms});if(i||!o)throw Error("Failed to search dimensions.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Jm(e,t,r,n){let s=k(e,t,r).apps({appKey:n.appKey}).models({modelKey:n.modelKey}).shares,{data:o,error:i}=n.action==="list"?await s.get():n.action==="create"?await s.post({target:n.target,mode:n.mode}):await s({targetType:n.target.type})({targetKey:n.target.key}).delete();if(i||!o)throw Error(`Failed to ${n.action} model shares.`,{cause:i});console.log(JSON.stringify(o,null,2))}async function Bm(e,t,r,n){if(n.modelFile&&!n.expectedCurrentVersion)throw Error("Expected current version is required when updating a model document.");let s=k(e,t,r),{data:o,error:i}=n.modelFile?await s.models({modelKey:n.modelKey})["with-version"].put({displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions??"",expectedCurrentVersion:n.expectedCurrentVersion,definition:pt(n.modelFile)}):await s.models({modelKey:n.modelKey}).put({displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions});if(i||!o)throw Error("Failed to update model.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Hm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models["validate-definition"].post({connectionKey:n.connectionKey,model:pt(n.modelFile)});if(i||!o)throw Error("Failed to validate model definition.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ym(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current.get();if(i||!o)throw Error("Failed to read the current model version.",{cause:i});Mm(n.outputFile,o,n.force),fe(n.outputFile,{format:n.outputFile.split(".").at(-1)})}async function Qm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current["refresh-samples"].post({...n.sampleSize===void 0?{}:{sampleSize:n.sampleSize}});if(i||!o)throw Error("Failed to refresh model samples.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Xm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current.validate.post();if(i||!o)throw Error("Failed to validate the current model version.",{cause:i});console.log(JSON.stringify(o,null,2))}async function ef(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.new.post(pt(n.modelFile));if(i||!o)throw Error("Failed to submit a new model version.",{cause:i});console.log(JSON.stringify(o,null,2))}var tf=(e)=>(t)=>{try{return e.parse(JSON.parse(t))}catch(r){let n=r.issues;throw new gn(`Use a JSON map of locale tag to text, for example '{"en-US":"Sales","ar-SA":"المبيعات"}'. ${n?n.map((s)=>s.message).join("; "):"The value is not valid JSON."}`)}},Me=tf(be),dt=tf(fn),qi,rf=(e)=>{qi=e};function M(e){let t=(r)=>Array.isArray(r)?r.map(t):r&&typeof r==="object"?Object.fromEntries(Object.entries(r).flatMap(([n,s])=>s&&typeof s==="object"&&!Array.isArray(s)&&Object.keys(s).length>0&&Object.entries(s).every(([o,i])=>(typeof i==="string"||!!i&&typeof i==="object"&&("delta"in i))&&/^[a-z]{2,3}(-|$)/.test(o)&&St(o)===o)?[[n,s],[`${n}Resolved`,vu(s,qi)]]:[[n,t(s)]])):r;console.log(JSON.stringify(qi?t(e):e,null,2))}import{readFileSync as UT}from"node:fs";async function nf(e,t,r,n){let i=k(e,t,r).models({modelKey:n.model})["result-artifacts"],{data:a,error:c}=await i.post({...n.queryId?{queryId:n.queryId}:{sql:UT(n.sqlFile,"utf8")},filters:n.filters?JSON.parse(n.filters):[],format:n.format});if(c||!a)throw Error("Failed to create result artifact.",{cause:c});console.log(JSON.stringify(a,null,2))}function af(e,t,r={}){let n=r.runConnectionsList??Ap,s=r.runConnectionsCreate??Cp,o=r.runConnectionsHealth??_p,i=r.runConnectionsCatalog??xp,a=r.runConnectionsUpdate??Op,c=r.runModelsList??Np,l=r.runModelsNew??Dp,p=r.runModelsNewWithVersion??Zm,u=r.runModelsQueryJson??Vm,d=r.runModelsGet??Ep,h=r.runModelsDelete??$p,b=r.runModelsUpdate??Bm,g=r.runModelsShares??Jm,w=r.runModelsVersionCurrentGet??Ym,T=r.runModelsVersionNew??ef,N=r.runModelsValidateDefinition??Hm,x=r.runModelsVersionCurrentValidate??Xm,D=r.runModelsVersionCurrentRefreshSamples??Qm,P=r.runModelsSchemaSearchDimensionArtifact??Wm,L=r.runModelsSearchDimensions??Gm,K=r.runResultArtifactsCreate??nf,E=e.command("connections").description("Manage connections");E.command("list").description("List connections").action(async function(){let C=await t.createWorkspaceContext();await n(C.serverUrl,C.accessToken,C.workspaceKey)}),ZT(E.command("create").description("Create a connection")).action(async function(C,v){let A=await t.createWorkspaceContext();await s(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:v.connectionKey,displayName:v.displayName,type:C,config:sf(v)})}),VT(E.command("update").description("Update a connection")).action(async function(C,v,A){let U=await t.createWorkspaceContext();await a(U.serverUrl,U.accessToken,U.workspaceKey,{connectionKey:C,displayName:A.displayName,type:v,config:sf(A)})}),E.command("health").description("Check connection health").argument("<connection-key>","Stable connection key").action(async function(C){let v=await t.createWorkspaceContext();await o(v.serverUrl,v.accessToken,v.workspaceKey,C)}),E.command("catalog").description("Read connection catalog").argument("<connection-key>","Stable connection key").option("--database <database>","Snowflake database").option("--schema <schema>","Snowflake schema").option("--table <table>","Snowflake table").option("--search <text>","Filter table references by qualified name").option("--summary","Print catalog counts instead of table references").option("--full","Print all table references, including large catalogs").option("--output-file <file>","Write catalog JSON to a file").option("--force","Replace an existing output file").action(async function(C,v){let A=[v.database,v.schema,v.table].filter(Boolean).length;if(A!==0&&A!==3)throw Error("`--database`, `--schema`, and `--table` must be supplied together.");let U=await t.createWorkspaceContext();await i(U.serverUrl,U.accessToken,U.workspaceKey,C,A===3?{database:v.database,schema:v.schema,table:v.table}:void 0,{search:v.search,summary:v.summary,full:v.full,outputFile:v.outputFile,force:v.force})}),e.command("models").description("Manage models").option("--connection-key <connection-key>","Connection key").option("--output-file <file>","Output file").option("--model-file <file>","Model definition JSON or YAML file").option("--display-name <name>","Model display name").option("--label <json>",`Chat picker label as a JSON map of locale tag to text, such as '{"en-US":"Core"}'. On update, null removes a locale.`,dt).option("--sql <sql>","SQL statement").option("--sql-file <file>","Read SQL from a file").option("--model-sql-instructions-file <file>","Model SQL instructions file").option("--query-id <id>","Stored query ID").option("--filters <json>","Result artifact filters as a JSON array").option("--format <format>","Artifact format","csv").option("--sample-size <count>","Sample size").option("--expected-current-version <version>","Expected model version").option("--limit <count>","Maximum sampled rows (1-1000)").option("--term <term>","Dimension search term; repeat for multiple terms",(C,v)=>[...v,C],[]).option("--force","Replace an existing output file").option("--cascade","Delete referencing dashboards, drafts, and evaluation cases").option("--app-key <app-key>","App whose user groups receive model shares").addOption(new ge("--mode <mode>","Share mode: read lets the target chat with the model; download also allows downloads").choices(["read","download"])).argument("[model-args...]").addHelpText("after",`
204
+ `);console.log(JSON.stringify(i,null,2))}async function Bm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey})["search-dimension-artifact"].get();if(i||!o)throw Error("Failed to get search dimension artifact.",{cause:i});if(n.outputFile)me(n.outputFile,o.sql,n.force),fe(n.outputFile,{format:"sql"});else console.log(JSON.stringify(o,null,2))}async function Hm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey})["search-dimensions"].post({searchTerms:n.searchTerms});if(i||!o)throw Error("Failed to search dimensions.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ym(e,t,r,n){let s=k(e,t,r).apps({appKey:n.appKey}).models({modelKey:n.modelKey}).shares,{data:o,error:i}=n.action==="list"?await s.get():n.action==="create"?await s.post({target:n.target,mode:n.mode}):await s({targetType:n.target.type})({targetKey:n.target.key}).delete();if(i||!o)throw Error(`Failed to ${n.action} model shares.`,{cause:i});console.log(JSON.stringify(o,null,2))}async function Qm(e,t,r,n){if(n.modelFile&&!n.expectedCurrentVersion)throw Error("Expected current version is required when updating a model document.");let s=k(e,t,r),{data:o,error:i}=n.modelFile?await s.models({modelKey:n.modelKey})["with-version"].put({displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions??"",expectedCurrentVersion:n.expectedCurrentVersion,definition:pt(n.modelFile)}):await s.models({modelKey:n.modelKey}).put({displayName:n.displayName,label:n.label,modelSqlInstructions:n.modelSqlInstructions});if(i||!o)throw Error("Failed to update model.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Xm(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models["validate-definition"].post({connectionKey:n.connectionKey,model:pt(n.modelFile)});if(i||!o)throw Error("Failed to validate model definition.",{cause:i});console.log(JSON.stringify(o,null,2))}async function ef(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current.get();if(i||!o)throw Error("Failed to read the current model version.",{cause:i});Vm(n.outputFile,o,n.force),fe(n.outputFile,{format:n.outputFile.split(".").at(-1)})}async function tf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current["refresh-samples"].post({...n.sampleSize===void 0?{}:{sampleSize:n.sampleSize}});if(i||!o)throw Error("Failed to refresh model samples.",{cause:i});console.log(JSON.stringify(o,null,2))}async function rf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.current.validate.post();if(i||!o)throw Error("Failed to validate the current model version.",{cause:i});console.log(JSON.stringify(o,null,2))}async function nf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.models({modelKey:n.modelKey}).versions.new.post(pt(n.modelFile));if(i||!o)throw Error("Failed to submit a new model version.",{cause:i});console.log(JSON.stringify(o,null,2))}var sf=(e)=>(t)=>{try{return e.parse(JSON.parse(t))}catch(r){let n=r.issues;throw new gn(`Use a JSON map of locale tag to text, for example '{"en-US":"Sales","ar-SA":"المبيعات"}'. ${n?n.map((s)=>s.message).join("; "):"The value is not valid JSON."}`)}},Me=sf(be),dt=sf(fn),Ki,of=(e)=>{Ki=e};function M(e){let t=(r)=>Array.isArray(r)?r.map(t):r&&typeof r==="object"?Object.fromEntries(Object.entries(r).flatMap(([n,s])=>s&&typeof s==="object"&&!Array.isArray(s)&&Object.keys(s).length>0&&Object.entries(s).every(([o,i])=>(typeof i==="string"||!!i&&typeof i==="object"&&("delta"in i))&&/^[a-z]{2,3}(-|$)/.test(o)&&St(o)===o)?[[n,s],[`${n}Resolved`,Su(s,Ki)]]:[[n,t(s)]])):r;console.log(JSON.stringify(Ki?t(e):e,null,2))}import{readFileSync as JT}from"node:fs";async function af(e,t,r,n){let i=k(e,t,r).models({modelKey:n.model})["result-artifacts"],{data:a,error:c}=await i.post({...n.queryId?{queryId:n.queryId}:{sql:JT(n.sqlFile,"utf8")},filters:n.filters?JSON.parse(n.filters):[],columnFilters:n.columnFilters?JSON.parse(n.columnFilters):[],format:n.format});if(c||!a)throw Error("Failed to create result artifact.",{cause:c});console.log(JSON.stringify(a,null,2))}function uf(e,t,r={}){let n=r.runConnectionsList??$p,s=r.runConnectionsCreate??Op,o=r.runConnectionsHealth??Tp,i=r.runConnectionsCatalog??Ap,a=r.runConnectionsUpdate??Ep,c=r.runModelsList??Ip,l=r.runModelsNew??Fp,u=r.runModelsNewWithVersion??Gm,p=r.runModelsQueryJson??Jm,d=r.runModelsGet??Pp,g=r.runModelsDelete??Dp,b=r.runModelsUpdate??Qm,y=r.runModelsShares??Ym,w=r.runModelsVersionCurrentGet??ef,T=r.runModelsVersionNew??nf,N=r.runModelsValidateDefinition??Xm,x=r.runModelsVersionCurrentValidate??rf,D=r.runModelsVersionCurrentRefreshSamples??tf,P=r.runModelsSchemaSearchDimensionArtifact??Bm,L=r.runModelsSearchDimensions??Hm,K=r.runResultArtifactsCreate??af,E=e.command("connections").description("Manage connections");E.command("list").description("List connections").action(async function(){let C=await t.createWorkspaceContext();await n(C.serverUrl,C.accessToken,C.workspaceKey)}),YT(E.command("create").description("Create a connection")).action(async function(C,v){let A=await t.createWorkspaceContext();await s(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:v.connectionKey,displayName:v.displayName,type:C,config:cf(v)})}),QT(E.command("update").description("Update a connection")).action(async function(C,v,A){let U=await t.createWorkspaceContext();await a(U.serverUrl,U.accessToken,U.workspaceKey,{connectionKey:C,displayName:A.displayName,type:v,config:cf(A)})}),E.command("health").description("Check connection health").argument("<connection-key>","Stable connection key").action(async function(C){let v=await t.createWorkspaceContext();await o(v.serverUrl,v.accessToken,v.workspaceKey,C)}),E.command("catalog").description("Read connection catalog").argument("<connection-key>","Stable connection key").option("--database <database>","Snowflake database").option("--schema <schema>","Snowflake schema").option("--table <table>","Snowflake table").option("--search <text>","Filter table references by qualified name").option("--summary","Print catalog counts instead of table references").option("--full","Print all table references, including large catalogs").option("--output-file <file>","Write catalog JSON to a file").option("--force","Replace an existing output file").action(async function(C,v){let A=[v.database,v.schema,v.table].filter(Boolean).length;if(A!==0&&A!==3)throw Error("`--database`, `--schema`, and `--table` must be supplied together.");let U=await t.createWorkspaceContext();await i(U.serverUrl,U.accessToken,U.workspaceKey,C,A===3?{database:v.database,schema:v.schema,table:v.table}:void 0,{search:v.search,summary:v.summary,full:v.full,outputFile:v.outputFile,force:v.force})}),e.command("models").description("Manage models").option("--connection-key <connection-key>","Connection key").option("--output-file <file>","Output file").option("--model-file <file>","Model definition JSON or YAML file").option("--display-name <name>","Model display name").option("--label <json>",`Chat picker label as a JSON map of locale tag to text, such as '{"en-US":"Core"}'. On update, null removes a locale.`,dt).option("--sql <sql>","SQL statement").option("--sql-file <file>","Read SQL from a file").option("--model-sql-instructions-file <file>","Model SQL instructions file").option("--query-id <id>","Stored query ID").option("--filters <json>","Result artifact filters as a JSON array").option("--column-filters <json>","Table column filters as a JSON array, so the CSV matches a filtered table").option("--format <format>","Artifact format","csv").option("--sample-size <count>","Sample size").option("--expected-current-version <version>","Expected model version").option("--limit <count>","Maximum sampled rows (1-1000)").option("--term <term>","Dimension search term; repeat for multiple terms",(C,v)=>[...v,C],[]).option("--force","Replace an existing output file").option("--cascade","Delete referencing dashboards, drafts, and evaluation cases").option("--app-key <app-key>","App whose user groups receive model shares").addOption(new ge("--mode <mode>","Share mode: read lets the target chat with the model; download also allows downloads").choices(["read","download"])).argument("[model-args...]").addHelpText("after",`
205
205
  Commands:
206
206
  list
207
207
  new <model-key>
@@ -221,10 +221,10 @@ Commands:
221
221
  <model-key> shares list --app-key <app-key>
222
222
  <model-key> shares create <user|user_group> <target-key> --app-key <app-key> [--mode read|download]
223
223
  <model-key> shares delete <user|user_group> <target-key> --app-key <app-key>
224
- `).action(async function(C){if(C.length===0)this.help();let v=this.opts(),A=await t.createWorkspaceContext();if(C[0]==="list"){await c(A.serverUrl,A.accessToken,A.workspaceKey);return}if(C[0]==="new"){await l(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),modelKey:_e(C[1],"model-key"),displayName:_e(v.displayName,"display-name"),label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?rr(v.modelSqlInstructionsFile,"utf8"):void 0});return}if(C[0]==="new-with-version"){await p(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),displayName:_e(v.displayName,"display-name"),modelKey:C[1]&&!C[1].startsWith("--")?C[1]:void 0,label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?rr(v.modelSqlInstructionsFile,"utf8"):void 0,modelFile:_e(v.modelFile,"model-file")});return}if(C[0]==="validate-definition"){await N(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),modelFile:_e(v.modelFile,"model-file")});return}let[U,G,B,Fe]=C;if(!U)throw Error("`<model-key>` is required.");if(G==="shares"&&(B==="list"||B==="create"||B==="delete")){if(B!=="list"&&Fe!=="user"&&Fe!=="user_group")throw Error("Share target type must be `user` or `user_group`.");await g(A.serverUrl,A.accessToken,A.workspaceKey,{appKey:_e(v.appKey,"app-key"),modelKey:U,action:B,...B==="list"?{}:{target:{type:Fe,key:_e(C[4],"target-key")}},mode:v.mode});return}if(G==="get"){await d(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U});return}if(G==="delete"){await h(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,cascade:v.cascade});return}if(G==="query-json"){let ye=B&&!B.startsWith("--")?B:void 0;await u(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,...ye?{queryKey:ye}:{sql:MT(v)},...v.limit!==void 0?{limit:jT(v.limit,"limit",1000)}:{}});return}if(G==="update"){let ye=v.expectedCurrentVersion?Number.parseInt(v.expectedCurrentVersion,10):void 0;if(v.modelFile&&(!ye||ye<1))throw Error("`--expected-current-version` must be a positive integer when `--model-file` is provided.");await b(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,displayName:_e(v.displayName,"display-name"),label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?rr(v.modelSqlInstructionsFile,"utf8"):void 0,modelFile:v.modelFile,expectedCurrentVersion:ye});return}if(G==="versions"&&B==="current"&&Fe==="get"){await w(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,outputFile:_e(v.outputFile,"output-file"),force:v.force});return}if(G==="versions"&&B==="new"){await T(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,modelFile:_e(v.modelFile,"model-file")});return}if(G==="versions"&&B==="current"&&Fe==="refresh-samples"){let ye=v.sampleSize===void 0?void 0:Number.parseInt(v.sampleSize,10);if(ye!==void 0&&Number.isNaN(ye))throw Error("`--sample-size` must be a number.");await D(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,sampleSize:ye});return}if(G==="versions"&&B==="current"&&Fe==="validate"){await x(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U});return}if(G==="search-dimension-artifact"){await P(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,outputFile:v.outputFile,force:v.force});return}if(G==="search-dimensions"){if(!v.term?.length)throw Error("`--term` is required.");await L(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,searchTerms:v.term});return}if(G==="result-artifacts"&&B==="create"){if(Boolean(v.sqlFile)===Boolean(v.queryId))throw Error("Provide either --sql-file or --query-id.");await K(A.serverUrl,A.accessToken,A.workspaceKey,{model:U,sqlFile:v.sqlFile,queryId:v.queryId,filters:v.filters,format:v.format??"csv"});return}throw Error(`Unknown models command '${C.join(" ")}'.`)})}function MT(e){if(Boolean(e.sql)===Boolean(e.sqlFile))throw Error("Provide either --sql or --sql-file.");return e.sql??rr(e.sqlFile,"utf8")}function jT(e,t,r){let n=Number.parseInt(e,10);if(!/^\d+$/.test(e)||!Number.isInteger(n)||n<1||r!==void 0&&n>r)throw Error(`--${t} must be an integer between 1 and ${r??"the supported maximum"}.`);return n}function _e(e,t){if(!e)throw Error(`Missing required command argument '${t}'.`);return e}function ZT(e){return e.addArgument(new ko("<type>","Connection type").choices(["snowflake"])).requiredOption("--connection-key <connection-key>","Stable connection key").requiredOption("--display-name <display-name>","Connection display name").requiredOption("--account <account>","Snowflake account identifier").requiredOption("--username <username>","Snowflake service username").requiredOption("--warehouse <warehouse>","Snowflake warehouse").option("--database <database>","Snowflake database scope for introspection and queries").option("--schema <schema>","Snowflake schema scope for introspection within the selected database set").option("--role <role>","Snowflake role").option("--host <host>","Snowflake host override").requiredOption("--auth-mode <auth-mode>","Snowflake auth mode: private_key or programmatic_access_token").option("--private-key-file <private-key-file>","Path to the Snowflake private key PEM file").option("--private-key-passphrase-file <file>","Read the Snowflake private key passphrase from a file").option("--programmatic-access-token-file <file>","Read the Snowflake programmatic access token from a file").option("--artifact-storage-stage-path <stage-path>","Snowflake stage path for result artifact storage (e.g. @my_db.my_schema.my_stage)")}function VT(e){return e.argument("<connection-key>","Stable connection key").addArgument(new ko("<type>","Connection type").choices(["snowflake"])).requiredOption("--display-name <display-name>","Connection display name").requiredOption("--account <account>","Snowflake account identifier").requiredOption("--username <username>","Snowflake service username").requiredOption("--warehouse <warehouse>","Snowflake warehouse").option("--database <database>","Snowflake database scope for introspection and queries").option("--schema <schema>","Snowflake schema scope for introspection within the selected database set").option("--role <role>","Snowflake role").option("--host <host>","Snowflake host override").requiredOption("--auth-mode <auth-mode>","Snowflake auth mode: private_key or programmatic_access_token").option("--private-key-file <private-key-file>","Path to the Snowflake private key PEM file").option("--private-key-passphrase-file <file>","Read the Snowflake private key passphrase from a file").option("--programmatic-access-token-file <file>","Read the Snowflake programmatic access token from a file").option("--artifact-storage-stage-path <stage-path>","Snowflake stage path for result artifact storage (e.g. @my_db.my_schema.my_stage)")}function sf(e){let t=e.artifactStorageStagePath?{type:"snowflake_stage",stagePath:e.artifactStorageStagePath}:void 0;if(e.authMode==="private_key"){if(!e.privateKeyFile)throw Error("`--private-key-file` is required when `--auth-mode=private_key`.");let r=of("private key passphrase",e.privateKeyPassphraseFile,"S_SNOWFLAKE_PRIVATE_KEY_PASSPHRASE");return{account:e.account,username:e.username,warehouse:e.warehouse,database:e.database,schema:e.schema,role:e.role,host:e.host,authMode:"private_key",privateKey:WT(e.privateKeyFile),privateKeyPassphrase:r,artifactStorage:t}}if(e.authMode==="programmatic_access_token"){let r=of("programmatic access token",e.programmaticAccessTokenFile,"S_SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN");if(!r)throw Error("A programmatic access token is required when `--auth-mode=programmatic_access_token`.");return{account:e.account,username:e.username,warehouse:e.warehouse,database:e.database,schema:e.schema,role:e.role,host:e.host,authMode:"programmatic_access_token",programmaticAccessToken:r,artifactStorage:t}}throw Error("`--auth-mode` must be either `private_key` or `programmatic_access_token`.")}function WT(e){return rr(e,"utf8").replace(/\r\n/g,`
225
- `)}function of(e,t,r){let n=process.env[r];if([t,n].filter((o)=>o!==void 0).length>1)throw Error(`Provide the ${e} through only one CLI option or ${r}.`);return t?rr(t,"utf8").replace(/\r?\n$/,""):n}async function cf(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.emails.test.post(r);if(o||!s)throw Error("Failed to send test email.",{cause:o});console.log(JSON.stringify(s,null,2))}function lf(e,t,r={}){e.command("emails").description("Manage email delivery").command("test").description("Send a test email as an org-admin").requiredOption("--to <email>","Recipient email address").action(async(n)=>{let s=await t.createAuthenticatedContext();await(r.runEmailTest??cf)(s.serverUrl,s.accessToken,{to:n.to})})}async function uf(e,t){let r=await fetch(new URL("/external/embed-sessions",e),{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":t.apiKey,"x-s-client":"cli"},body:JSON.stringify({appKey:t.appKey,externalUserId:t.externalUserId,displayName:t.displayName,...t.email?{email:t.email}:{},roleKey:t.roleKey,currencyCode:t.currencyCode,rls:t.rls,...t.userGroupKeys?{userGroupKeys:t.userGroupKeys}:{},...t.shareUserGroupKeys!==void 0?{shareUserGroupKeys:t.shareUserGroupKeys}:{},...t.embedConfig!==void 0?{embedConfig:t.embedConfig}:{}})}),n=await r.json().catch(()=>null);if(!r.ok||!n)throw Error(`Failed to create embed session (${r.status}).`,{cause:n??r.statusText});console.log(JSON.stringify(n,null,2))}function pf(e,t,r={}){e.command("embed-sessions").description("Manage backend-created embed sessions").command("create").requiredOption("--api-key <key>","Workspace API key").requiredOption("--app-key <key>","App key").requiredOption("--external-user-id <id>","Stable product user ID").requiredOption("--display-name <name>","Embedded user display name").option("--email <email>","Embedded user email").requiredOption("--role-key <key>","Organization role key; replaces all roles on every embed request").requiredOption("--currency-code <code>","ISO 4217 currency code").option("--rls <json>","Embed RLS as JSON","{}").option("--user-group-keys <keys>","Comma-separated user group keys").option("--share-user-group-keys <keys>","Comma-separated share-granter group keys; use an empty value to clear").option("--embed-config <json>","Profile-menu picker options as JSON; use null to clear, omit to keep").action(async(n)=>{await(r.runEmbedSessionsCreate??uf)(t.getResolvedServerUrl(),{apiKey:n.apiKey,appKey:n.appKey,externalUserId:n.externalUserId,displayName:n.displayName,email:n.email,roleKey:n.roleKey,currencyCode:n.currencyCode,rls:JSON.parse(n.rls),userGroupKeys:n.userGroupKeys?.split(",").map((s)=>s.trim()).filter(Boolean),shareUserGroupKeys:n.shareUserGroupKeys===""?[]:n.shareUserGroupKeys?.split(",").map((s)=>s.trim()).filter(Boolean),embedConfig:n.embedConfig===void 0?void 0:JSON.parse(n.embedConfig)})})}import{existsSync as o0,readFileSync as i0}from"node:fs";import{stdin as us,stdout as ls}from"node:process";import{createInterface as df}from"node:readline/promises";import{Writable as GT}from"node:stream";var Ki=!1;async function mf(e){if(Ki||!us.isTTY||!ls.isTTY)throw Error("Password changes require an interactive terminal.");let t=new GT({write(s,o,i){i()}}),r=df({input:us,output:t,terminal:!0}),n=new AbortController;r.once("SIGINT",()=>n.abort()),r.once("close",()=>n.abort()),ls.write(`${e}: `);try{let s=await r.question("",{signal:n.signal});if(!s)throw Error(`${e} is required.`);return s}catch(s){if(n.signal.aborted)throw Error("Password change cancelled.");throw s}finally{r.close(),t.destroy(),ls.write(`
226
- `)}}function ff(e){Ki=e.nonInteractive}async function W(e){if(Ki||!us.isTTY)throw Error(`${e} is required. Pass it explicitly when running non-interactively.`);let t=df({input:us,output:ls});try{let r=(await t.question(`${e}: `)).trim();if(!r)throw Error(`${e} is required.`);return r}finally{t.close()}}async function hf(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluation.cleanup.post();if(o||!s)throw Error("Failed to retry evaluation cleanups.",{cause:o});console.log(JSON.stringify(s,null,2))}async function gf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators.post(n);if(i||!o)throw Error("Failed to create evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function yf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators({evaluatorKey:n}).delete();if(i||!o)throw Error("Failed to delete evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function bf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators({evaluatorKey:n}).get();if(i||!o)throw Error("Failed to get evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function wf(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluators.get();if(o||!s)throw Error("Failed to list evaluators.",{cause:o});console.log(JSON.stringify(s.evaluators,null,2))}async function vf(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.evaluators({evaluatorKey:n}).patch(s);if(a||!i)throw Error("Failed to update evaluator.",{cause:a});console.log(JSON.stringify(i,null,2))}import{readFileSync as Ri,writeFileSync as YT}from"node:fs";import{dirname as QT,join as XT}from"node:path";import{readFileSync as JT,readdirSync as BT}from"node:fs";import{join as HT}from"node:path";var kf={"orchestrator-system.md":["orchestrator","system"],"orchestrator-human.md":["orchestrator","human"],"general-sql-instructions.md":["generalSqlInstructions"],"visualisation-config.md":["visualisationConfig"],"html-visualisation.md":["htmlVisualisation"],"product-information.md":["productInformation"],"context-summary.md":["contextSummary"]};function nr(e){let t={};for(let r of BT(e).filter((n)=>n.endsWith(".md"))){let n=kf[r];if(!n)throw Error(`Unknown prompt file '${r}'. Expected one of: ${Object.keys(kf).join(", ")}.`);let s=JT(HT(e,r),"utf8");if(n.length===2)t.orchestrator={...t.orchestrator,[n[1]]:s};else t[n[0]]=s}return t}var Sf=(e,t)=>({passed:e,total:t,score:t===0?0:e/t});async function xf(e,t,r,n){let s=k(e,t,r),{entries:o}=Ue(Ri(n.suite,"utf8")),i=n.promptsDir?nr(n.promptsDir):void 0;for(let u of o.filter((d)=>d.file)){let d=Ue(Ri(XT(QT(n.suite),u.file),"utf8")),h=await s.evaluation.sets({evaluationSetKey:u.evaluationSet}).patch(d);if(h.error?.status===404){let b=await s.evaluation.sets.post({evaluationSetKey:u.evaluationSet,appKey:u.app});if(b.error)throw Error(`Failed to create evaluation set '${u.evaluationSet}'.`,{cause:b.error});h=await s.evaluation.sets({evaluationSetKey:u.evaluationSet}).patch(d)}if(h.error)throw Error(`Failed to upload evaluation set '${u.evaluationSet}'.`,{cause:h.error})}let a=[];for(let u of o){let{data:d,error:h}=await s.evaluation.experiments.post({evaluationSetKey:u.evaluationSet,evaluationCaseKeys:u.cases,promptOverrides:i,keepArtifacts:n.keepArtifacts??!1,repeatTimes:1,repeatOnNotAllEvaluatorsPass:0,batchSize:10});if(h||!d)throw Error(`Failed to start '${u.app}/${u.evaluationSet}'.`,{cause:h});xe(`Started ${d.experimentKey} for ${u.app}/${u.evaluationSet}.`),a.push({entry:u,experimentKey:d.experimentKey})}let c={};for(let{entry:u,experimentKey:d}of a)for(let h=0;;h+=5000){let{data:b,error:g}=await s.evaluation.experiments({experimentKey:d}).get();if(g||!b)throw Error(`Failed to read ${d}.`,{cause:g});let{status:w,summaryJson:T}=b.experiment;if(w==="completed"||w==="failed"){let N=c[u.app]??={passed:0,total:0};N.passed+=T?.results?.passed??0,N.total+=T?.results?.totalCases??0;break}if(h>3600000)throw Error(`Timed out waiting for ${d}.`);xe(`${d} still ${w}...`),await Le(5000)}let l={apps:Object.fromEntries(Object.entries(c).map(([u,d])=>[u,Sf(d.passed,d.total)])),total:Sf(Object.values(c).reduce((u,d)=>u+d.passed,0),Object.values(c).reduce((u,d)=>u+d.total,0))},p=(u)=>`${Math.round(u*1000)/10}%`;for(let[u,d]of Object.entries(l.apps))console.log(`${u} ${d.passed}/${d.total} ${p(d.score)}`);if(console.log(`total ${l.total.passed}/${l.total.total} ${p(l.total.score)}`),n.save)YT(n.save,`${JSON.stringify(l,null,2)}
227
- `);if(n.baseline){let u=JSON.parse(Ri(n.baseline,"utf8")),d=Object.entries(u.apps).filter(([h,b])=>(l.apps[h]?.score??0)<b.score);if(d.length>0)throw Error(`Score dropped for ${d.map(([h,b])=>`${h} (${p(b.score)} → ${p(l.apps[h]?.score??0)})`).join(", ")}.`)}}import{mkdirSync as e0}from"node:fs";import{join as Cf}from"node:path";function je(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:{}}function _f(e){return Array.isArray(e)?e:[]}function Ui(e,t,r={}){let n=je(t),s=je(n.experiment),o=je(s.summaryJson),i=je(o.results),a=Cf(".local","evaluation-reports");e0(a,{recursive:!0});let c=r.outputFile??Cf(a,`${e}.yaml`);me(c,Ce(r.raw?t:{experiment:{experimentKey:s.experimentKey,status:s.status,summary:s.summaryJson?{results:{totalCases:i.totalCases,passed:i.passed,softFail:i.softFail,mediumFail:i.mediumFail,hardFail:i.hardFail}}:null},caseResults:_f(n.caseResults).map((l)=>{let p=je(l),u=je(p.caseSnapshot),d=je(u.evaluationCase),h={evaluationCaseKey:d.evaluationCaseKey,repeatIndex:p.repeatIndex,status:p.status},b=je(u.subject);if(Object.keys(b).length)h.subject=b;else if(d.subjectId)h.subject={provided:{subjectId:d.subjectId},resolved:{subjectId:d.subjectId,mode:"subject_id",roleKey:null,currencyCode:null,rlsHash:null}};if(p.errorText)h.errorText=p.errorText;if(p.status==="completed"){let g=je(p.evaluatorResults);if(h.agent={message:p.agentMessage,sql:p.agentSql,durationMs:p.agentDurationMs,result:p.agentSqlResult},h.groundTruth={sql:p.groundTruthSql,result:p.groundTruthResult},g.diagnostics)h.extraction=g.diagnostics;h.evaluators=_f(g.results).map((w)=>{let T=je(w);return{evaluatorKey:T.evaluatorKey,status:typeof T.status==="string"?T.status:"evaluated",reasoning:T.reasoning,passed:T.passed}})}return h})}),r.force),fe(c,{kind:"experiment-report",format:"yaml",raw:Boolean(r.raw)})}async function Af(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.experiments({experimentKey:n}).get();if(a||!i)throw Error("Failed to get experiment.",{cause:a});Ui(n,i,s)}async function Of(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.experiments.post({...n,keepArtifacts:n.keepArtifacts??!1});if(i||!o)throw Error("Failed to create experiment.",{cause:i});if(n.wait){let a=Date.now(),c=2000,l=600000;xe(`Created experiment ${o.experimentKey}. Waiting for completion...`);while(Date.now()-a<=600000){let p=await s.evaluation.experiments({experimentKey:o.experimentKey}).get();if(p.error||!p.data)throw Error("Failed to get experiment while waiting.",{cause:p.error});let u=p.data.experiment.status;if(u==="completed"||u==="failed"){Ui(o.experimentKey,p.data,n);return}xe(`${o.experimentKey} still ${u}...`),await Le(2000)}throw Error(`Timed out waiting for experiment '${o.experimentKey}'.`)}console.log(JSON.stringify(o,null,2))}async function Tf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets.post(n);if(i||!o)throw Error("Failed to create evaluation set.",{cause:i});console.log(JSON.stringify(o,null,2))}async function $f(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets({evaluationSetKey:n}).delete();if(i||!o)throw Error("Failed to delete evaluation set.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ef(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.sets({evaluationSetKey:n}).get();if(a||!i)throw Error("Failed to get evaluation set.",{cause:a});let c=s.outputFile??`${n}.yaml`;me(c,Ce(i),s.force),fe(c,{kind:"evaluation-set",format:"yaml"})}async function Nf(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluation.sets.get();if(o||!s)throw Error("Failed to list evaluation sets.",{cause:o});console.log(JSON.stringify(s.evaluationSets,null,2))}async function Df(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.sets({evaluationSetKey:n}).get();if(a||!i)throw Error("Failed to load evaluation set.",{cause:a});let c=new Map(i.cases.map((b)=>[b.evaluationCaseKey,b])),l=s.evaluationCaseKeys?.length?s.evaluationCaseKeys:i.cases.filter((b)=>b.type==="sql").map((b)=>b.evaluationCaseKey),p=Math.min(Math.max(s.batchSize,1),5),u=[];for(let b=0;b<l.length;b+=p){let g=l.slice(b,b+p);u.push(...await Promise.all(g.map(async(w)=>{let T=c.get(w);if(!T)return{evaluationCaseKey:w,status:"failed",errorText:`Evaluation case '${w}' is not on evaluation set '${n}'.`};let N=o.evaluation.sets({evaluationSetKey:n}).cases({evaluationCaseKey:w}),{data:x,error:D}=await N["ground-truth"].run.post({});if(D||!x){let P=D?.value;return{evaluationCaseKey:w,subject:{provided:T.subject},status:"failed",groundTruthSql:T.type==="sql"?T.groundTruthSql:void 0,errorText:typeof P==="string"?P:P instanceof Error?P.message:P?.error||P?.message||"Failed to run ground truth SQL."}}return{evaluationCaseKey:x.evaluationCaseKey,subject:x.subject,status:"completed",groundTruthSql:x.groundTruthSql??(T.type==="sql"?T.groundTruthSql:void 0),columns:x.columns,rows:x.rows}})))}let d={evaluationSetKey:n,summary:{total:u.length,completed:u.filter((b)=>b.status==="completed").length,failed:u.filter((b)=>b.status==="failed").length},results:u},h=s.outputFile??`${n}-ground-truth-results.yaml`;me(h,Ce(d),s.force),fe(h,{kind:"ground-truth-report",format:"yaml"})}async function Pf(e,t,r,n={}){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets.template.get();if(i||!o)throw Error("Failed to get evaluation set template.",{cause:i});let a=n.outputFile??"evaluation-set-template.yaml";me(a,Ce(o),n.force),fe(a,{kind:"evaluation-set-template",format:"yaml"})}import{readFileSync as t0}from"node:fs";async function If(e,t,r,n,s,o={}){let i=k(e,t,r),{data:a,error:c}=await i.evaluation.sets({evaluationSetKey:n}).patch(Ue(t0(s,"utf8")),{query:o.refreshConversationSources?{refreshConversationSources:!0}:{}});if(c||!a)throw Error(`Failed to update evaluation set: ${JSON.stringify(c)}`,{cause:c});console.log(JSON.stringify(a,null,2))}function r0(e){if(e.headline)xe(e.headline);for(let t of e.levels??[]){let r=Math.round(t.attempts.successRate*100),n=Math.round(t.latency.p95Ms/1000);xe(` c=${t.concurrency} slo=${t.slo.status} success=${r}% p95=${n}s`);for(let s of t.cases??[]){let o=Math.round(s.attempts.successRate*100),i=Math.round(s.latency.p95Ms/1000);xe(` ${s.evaluationCaseKey} success=${o}% p95=${i}s`)}}}function Mi(e,t,r={}){let n=typeof t==="object"&&t!==null&&!Array.isArray(t)?t:{},s=n.summaryJson??null,o=r.outputFile??`${e}.yaml`;if(me(o,Ce(r.raw?t:{stressRun:{stressRunKey:n.stressRunKey,status:n.status,slo:n.sloJson,ramp:{levels:n.levelsJson},summary:s,errorText:n.errorText??null}}),r.force),s&&typeof s==="object"&&s!==null)r0(s);fe(o,{kind:"stress-run-report",format:"yaml",raw:Boolean(r.raw)})}async function Ff(e,t,r,n,s,o={}){let a=k(e,t,r).evaluation.sets({evaluationSetKey:n}),{data:c,error:l}=await a["stress-runs"]({stressRunKey:s}).get();if(l||!c)throw Error("Failed to get stress run.",{cause:l});Mi(s,c,o)}async function Lf(e,t,r,n){let o=k(e,t,r).evaluation.sets({evaluationSetKey:n.evaluationSetKey}),{data:i,error:a}=await o["stress-runs"].post({evaluationCaseKeys:n.evaluationCaseKeys,levels:n.levels,successThreshold:n.successThreshold,p95BudgetMs:n.p95BudgetMs,runTimeoutMs:n.runTimeoutMs,verbose:n.verbose});if(a||!i)throw Error("Failed to create stress run.",{cause:a});if(n.wait){let c=Date.now(),l=2000,p=1800000;xe(`Created stress run ${i.stressRunKey}. Waiting for completion...`);while(Date.now()-c<=1800000){let u=await o["stress-runs"]({stressRunKey:i.stressRunKey}).get();if(u.error||!u.data)throw Error("Failed to get stress run while waiting.",{cause:u.error});let d=u.data.status;if(d==="completed"||d==="failed"){Mi(i.stressRunKey,u.data,n);return}xe(`${i.stressRunKey} still ${d}...`),await Le(2000)}throw Error(`Timed out waiting for stress run '${i.stressRunKey}'.`)}console.log(JSON.stringify(i,null,2))}var n0=H(["openai","openrouter","anthropic"]),s0=H(["none","minimal","low","medium","high","xhigh","max"]),ps=j({providerKey:n0,model:R().trim().nonempty("Model is required"),effort:s0.optional()});function qf(e,t,r={}){let n=r.runEvaluatorsCreate??gf,s=r.runEvaluatorsDelete??yf,o=r.runEvaluatorsGet??bf,i=r.runEvaluatorsList??wf,a=r.runEvaluatorsUpdate??vf,c=r.runExperimentsCreate??Of,l=r.runExperimentsGet??Af,p=r.runExperimentsBenchmark??xf,u=r.runEvaluationCleanup??hf,d=r.runStressCreate??Lf,h=r.runStressGet??Ff,b=r.runSetsCreate??Tf,g=r.runSetsDelete??$f,w=r.runSetsGet??Ef,T=r.runSetsList??Nf,N=r.runSetsRunGroundTruth??Df,x=r.runSetsTemplateGet??Pf,D=r.runSetsUpdate??If,P=e.command("evaluators").description("Manage evaluators");P.command("create").description("Create an evaluator").option("--key <key>","Stable evaluator key").option("--display-name <display-name>","Evaluator display name").option("--description <description>","Evaluator description").option("--llm <json>","Evaluator provider, model, and optional effort as JSON").option("--model <model>","Legacy OpenAI evaluator model").option("--prompt <prompt-file>","Evaluator prompt file").action(async function(O){let C=await t.createWorkspaceContext();await n(C.serverUrl,C.accessToken,C.workspaceKey,{evaluatorKey:O.key??await W("Evaluator key"),displayName:O.displayName??await W("Display name"),description:O.description,model:O.model??(O.llm?void 0:await W("Model")),llm:O.llm?ps.parse(JSON.parse(O.llm)):void 0,prompt:zf(O.prompt??await W("Prompt file"))})}),P.command("get").description("Get an evaluator").argument("<evaluator-key>","Evaluator key").action(async function(O){let C=await t.createWorkspaceContext();await o(C.serverUrl,C.accessToken,C.workspaceKey,O)}),P.command("list").description("List evaluators").action(async function(){let O=await t.createWorkspaceContext();await i(O.serverUrl,O.accessToken,O.workspaceKey)}),P.command("update").description("Update an evaluator").argument("<evaluator-key>","Evaluator key").option("--display-name <display-name>","Evaluator display name").option("--description <description>","Evaluator description").option("--llm <json>","Evaluator provider, model, and optional effort as JSON").option("--model <model>","Legacy OpenAI evaluator model").option("--prompt <prompt-file>","Evaluator prompt file").action(async function(O,C){let v=await t.createWorkspaceContext();await a(v.serverUrl,v.accessToken,v.workspaceKey,O,{displayName:C.displayName,description:C.description,model:C.model,llm:C.llm?ps.parse(JSON.parse(C.llm)):void 0,prompt:C.prompt?zf(C.prompt):void 0})}),P.command("delete").description("Delete an evaluator").argument("<evaluator-key>","Evaluator key").action(async function(O){let C=await t.createWorkspaceContext();await s(C.serverUrl,C.accessToken,C.workspaceKey,O)});let L=e.command("sets").description("Manage evaluation sets");L.command("create").description("Create an evaluation set").option("--key <key>","Stable evaluation set key").option("--app <app-key>","App key").action(async function(O){let C=await t.createWorkspaceContext();await b(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.key??await W("Evaluation set key"),appKey:O.app??await W("App key")})}),L.command("get").description("Get an evaluation set document").argument("<evaluation-set-key>","Evaluation set key").option("--output-file <file>","Write the set document to this file").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext();await w(v.serverUrl,v.accessToken,v.workspaceKey,O,C)}),L.command("list").description("List evaluation sets").action(async function(){let O=await t.createWorkspaceContext();await T(O.serverUrl,O.accessToken,O.workspaceKey)}),L.command("template").description("Manage evaluation set templates").command("get").description("Get the evaluation set template").option("--output-file <file>","Write the template to this file").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext();await x(C.serverUrl,C.accessToken,C.workspaceKey,O)}),L.command("update").description("Update an evaluation set document").argument("<evaluation-set-key>","Evaluation set key").option("--filepath <filepath>","Evaluation set YAML file").option("--refresh-conversation-sources","Reimport LangSmith conversation snapshots").action(async function(O,C){let v=[`${O}.yaml`,`${O}.yml`].find((U)=>o0(U)),A=await t.createWorkspaceContext();await D(A.serverUrl,A.accessToken,A.workspaceKey,O,C.filepath??v??await W("Evaluation set YAML file"),{refreshConversationSources:C.refreshConversationSources})}),L.command("run-ground-truth").description("Run ground truth SQL cases").argument("<evaluation-set-key>","Evaluation set key").argument("[evaluation-case-key]","Evaluation case key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--batch-size <batch-size>","Local ground truth runner concurrency, capped at 5",Number).option("--output-file <file>","Write the report to this file").option("--force","Replace an existing output file").action(async function(O,C,v){let A=await t.createWorkspaceContext();await N(A.serverUrl,A.accessToken,A.workspaceKey,O,{evaluationCaseKeys:v.caseKeys?v.caseKeys.split(",").map((U)=>U.trim()).filter(Boolean):C?[C]:void 0,batchSize:v.batchSize??5,outputFile:v.outputFile,force:v.force})}),L.command("delete").description("Delete an evaluation set").argument("<evaluation-set-key>","Evaluation set key").action(async function(O){let C=await t.createWorkspaceContext();await g(C.serverUrl,C.accessToken,C.workspaceKey,O)});let K=e.command("experiments").alias("experiment").description("Manage experiments");K.command("get").description("Get an experiment").argument("<experiment-key>","Experiment key").option("--output-file <file>","Write the report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext();await l(v.serverUrl,v.accessToken,v.workspaceKey,O,C)}),K.command("create").description("Create an experiment").option("--llm-override <json>","Override the experiment agent provider, model, and effort").option("--model-sql-instructions-override <model-key=file>","Replace model SQL instructions for this experiment (repeatable)",(O,C)=>[...C,O],[]).option("--prompts-dir <dir>","Run with the prompt files in this folder instead of the app's saved prompts").option("--keep-artifacts","Keep what each case's chat creates instead of deleting it after scoring").option("--set-key <set-key>","Evaluation set key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--repeat-times <repeat-times>","Repeat each case N times",Number).option("--repeat-on-not-all-evaluators-pass <count>","Adaptive extra repeats when not all evaluators pass",Number).option("--batch-size <batch-size>","Case runner batch size",Number).option("--wait","Wait for the experiment to finish and write the report").option("--output-file <file>","Write the completed report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext(),v={};for(let A of O.modelSqlInstructionsOverride??[]){let U=A.indexOf("="),G=A.slice(0,U).trim(),B=A.slice(U+1);if(U<=0||!G||!B.trim())throw Error("Expected --model-sql-instructions-override model-key=file");if(Object.hasOwn(v,G))throw Error(`Duplicate model SQL instructions override for '${G}'.`);Object.defineProperty(v,G,{value:{modelSqlInstructions:await Bun.file(B).text()},enumerable:!0})}await c(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.setKey??await W("Evaluation set key"),modelOverrides:v,promptOverrides:O.promptsDir?nr(O.promptsDir):void 0,keepArtifacts:O.keepArtifacts??!1,llmOverride:O.llmOverride?ps.parse(JSON.parse(O.llmOverride)):void 0,evaluationCaseKeys:O.caseKeys?.split(",").map((A)=>A.trim()).filter(Boolean),repeatTimes:O.repeatTimes??1,repeatOnNotAllEvaluatorsPass:O.repeatOnNotAllEvaluatorsPass??0,batchSize:O.batchSize??10,wait:O.wait??!1,outputFile:O.outputFile,raw:O.raw,force:O.force})}),K.command("benchmark").description("Run every app's evaluation sets with the same prompts and score each app").requiredOption("--suite <file>","Benchmark YAML listing app, evaluationSet, and optional file and cases").option("--prompts-dir <dir>","Run with the prompt files in this folder instead of each app's saved prompts").option("--baseline <file>","Fail when any app scores lower than in this saved result").option("--save <file>","Save this result as the next baseline").option("--keep-artifacts","Keep what each case's chat creates instead of deleting it after scoring").action(async function(O){let C=await t.createWorkspaceContext();await p(C.serverUrl,C.accessToken,C.workspaceKey,O)}),e.command("evaluation").description("Manage evaluation runs").command("cleanup").description("Retry permission and chat deletions that evaluation cleanups could not finish").action(async function(){let O=await t.createWorkspaceContext();await u(O.serverUrl,O.accessToken,O.workspaceKey)});let E=e.command("stress").description("Measure agent concurrency capacity");E.command("create").description("Create a stress run").option("--set-key <set-key>","Evaluation set key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--levels <levels>","Comma-separated concurrency levels, for example 1,2,5,10").option("--success-threshold <success-threshold>","Minimum success rate to continue the ramp",Number).option("--p95-budget-ms <p95-budget-ms>","Maximum p95 latency in milliseconds before stopping",Number).option("--run-timeout-ms <run-timeout-ms>","Per-request timeout in milliseconds",Number).option("--wait","Wait for the stress run to finish and write the report").option("--verbose","Include per-case stats in the stress run summary").option("--output-file <file>","Write the completed report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext();await d(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.setKey??await W("Evaluation set key"),evaluationCaseKeys:O.caseKeys?.split(",").map((v)=>v.trim()).filter(Boolean),levels:O.levels?.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>Number.isFinite(v)&&v>0),successThreshold:O.successThreshold,p95BudgetMs:O.p95BudgetMs,runTimeoutMs:O.runTimeoutMs,verbose:O.verbose??!1,wait:O.wait??!1,outputFile:O.outputFile,raw:O.raw,force:O.force})}),E.command("get").description("Get a stress run").argument("<stress-run-key>","Stress run key").option("--set-key <set-key>","Evaluation set key").option("--output-file <file>","Write the report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext(),A=C.setKey??await W("Evaluation set key");await h(v.serverUrl,v.accessToken,v.workspaceKey,A,O,C)})}function zf(e){return i0(e,"utf8").replace(/\r\n/g,`
228
- `)}import{chmodSync as Uf,existsSync as Gi,mkdirSync as u0,readFileSync as p0,rmSync as d0,writeFileSync as m0}from"node:fs";import{dirname as f0,join as h0}from"node:path";import se from"node:path";import Rf from"node:os";import Zi from"node:process";var nz=Object.freeze([""," ",".",".."," .",". "," ..",".. ","../","../foo","foo/../bar","foo/bar","foo\\bar","foo\x00bar"]);function Kf(e){if(typeof e!=="string")return!1;let t=e.trim();return t!==""&&t!=="."&&t!==".."&&!e.includes("/")&&!e.includes("\\")&&!e.includes("\x00")}function ji(e){if(typeof e!=="string")throw TypeError("Expected a string");if(!Kf(e))throw Error(`Unsafe filename: ${JSON.stringify(e)}`)}var mt=Rf.homedir(),Vi=Rf.tmpdir(),{env:sr}=Zi,a0=(e)=>{let t=se.join(mt,"Library");return{data:se.join(t,"Application Support",e),config:se.join(t,"Preferences",e),cache:se.join(t,"Caches",e),log:se.join(t,"Logs",e),temp:se.join(Vi,e)}},c0=(e)=>{let t=sr.APPDATA||se.join(mt,"AppData","Roaming"),r=sr.LOCALAPPDATA||se.join(mt,"AppData","Local");return{data:se.join(r,e,"Data"),config:se.join(t,e,"Config"),cache:se.join(r,e,"Cache"),log:se.join(r,e,"Log"),temp:se.join(Vi,e)}},l0=(e)=>{let t=se.basename(mt);return{data:se.join(sr.XDG_DATA_HOME||se.join(mt,".local","share"),e),config:se.join(sr.XDG_CONFIG_HOME||se.join(mt,".config"),e),cache:se.join(sr.XDG_CACHE_HOME||se.join(mt,".cache"),e),log:se.join(sr.XDG_STATE_HOME||se.join(mt,".local","state"),e),temp:se.join(Vi,t,e)}};function Wi(e,{suffix:t="nodejs"}={}){if(ji(e),t)e+=`-${t}`;if(ji(e),Zi.platform==="darwin")return a0(e);if(Zi.platform==="win32")return c0(e);return l0(e)}function Mf(e){return h0(Wi(e,{suffix:""}).data,"session.json")}class Ji{filePath;constructor(e){this.filePath=e}load(){if(!Gi(this.filePath))return null;return JSON.parse(p0(this.filePath,"utf8"))}save(e){let t=f0(this.filePath),r=!Gi(t);if(u0(t,{recursive:!0,mode:448}),r)Uf(t,448);m0(this.filePath,JSON.stringify(e,null,2),{mode:384}),Uf(this.filePath,384)}clear(){if(!Gi(this.filePath))return;d0(this.filePath)}}function g0(){return Mf("server-end-user-cli")}class Gr extends Ji{constructor(e=g0()){super(e)}}function y0(e){return JSON.stringify(e).includes("authorization_pending")}function b0(e){let t=Math.max(1,Math.round((new Date(e).getTime()-Date.now())/60000));return t===1?"1 minute":`${t} minutes`}async function jf(e,t={}){let r=t.log??console.log,n=t.store??new Gr,s=V(e),{data:o,error:i}=await s.auth.login.start.post();if(i||!o)throw Error("Failed to start login.",{cause:i});let a=b0(o.expiresAt);r(`Verification URL: ${o.verificationUrl}`),r("Please use this verification URL to log in to your account."),r(`If you do not log in within ${a}, this login session will be terminated.`);let c=new Date(o.expiresAt).getTime(),l=3;while(!0){if(Date.now()>=c)throw Error(`Login timed out. You did not log in within ${a}, so this login session was terminated. Run \`s login\` again.`);let{data:p,error:u}=await s.auth.login.complete.post({deviceCode:o.deviceCode});if(p){let d=await wn(e);n.save({serverUrl:e,issuerUrl:d.issuerUrl,tokenType:"Bearer",accessToken:p.accessToken,accessTokenExpiresAt:new Date(Date.now()+p.expiresIn*1000).toISOString(),refreshToken:p.refreshToken,refreshTokenExpiresAt:null,workspaceId:p.workspace.workspaceId,workspaceKey:p.workspace.workspaceKey}),r("Login complete."),r(JSON.stringify({workspace:p.workspace},null,2));return}if(u&&y0(u)){await Le(l*1000);continue}if(u&&JSON.stringify(u).includes("slow_down")){l+=5,await Le(l*1000);continue}throw Error("Failed to complete login.",{cause:u})}}async function Zf(e,t,r=mf){let n=await r("Current password"),s=await r("New password"),o=await r("Confirm new password");if(s!==o)throw Error("New passwords do not match.");let i=V(e,{getAccessToken:()=>t}),{data:a,error:c}=await i.auth["change-password"].post({currentPassword:n,newPassword:s});if(c||!a){let l=c?.value&&typeof c.value==="object"&&"error"in c.value?String(c.value.error):"Password change failed.";throw Error(l)}console.log(JSON.stringify(a,null,2))}import{readFileSync as w0}from"node:fs";async function v0(e,t,r){let n=JSON.parse(w0(r.file,"utf8"));if(!Array.isArray(n.permissions)||n.permissions.length===0)throw Error("The file must contain a non-empty permissions array.");if(n.nextCursor!==void 0)throw Error("Use roles permissions export, not a paginated list response.");if(r.operation==="set"&&!/^[a-f0-9]{64}$/.test(n.expectedRevision??""))throw Error("The file must contain expectedRevision. Export the role permissions first.");let s=V(e,{getAccessToken:()=>t}),o=r.operation==="create"?await s.roles.post({roleKey:r.roleKey,permissions:n.permissions}):await s.roles({roleKey:r.roleKey}).permissions.put({permissions:n.permissions,expectedRevision:n.expectedRevision});if(o.error||!o.data)throw Error("Failed to save role permissions.",{cause:o.error});console.log(JSON.stringify(o.data,null,2))}async function k0(e,t,r){let n=V(e,{getAccessToken:()=>t}),s=[],o,i,a=new Set;do{let c=await n.roles({roleKey:r}).permissions.get({query:{limit:100,...o?{cursor:o}:{}}});if(c.error||!c.data)throw Error("Failed to export role permissions. Restart the export.",{cause:c.error});if(i&&i!==c.data.revision)throw Error("Role permissions changed during export. Restart the export.");if(i=c.data.revision,s.push(...c.data.permissions.map(({relation:l,resource:p})=>({relation:l,resource:{type:p.type,id:p.id}}))),o=c.data.nextCursor??void 0,o&&a.has(o))throw Error("Repeated permissions cursor.");if(o)a.add(o)}while(o);console.log(JSON.stringify({expectedRevision:i,permissions:s},null,2))}async function S0(e,t,r){let n=V(e,{getAccessToken:()=>t}),s={limit:r.limit??50,...r.cursor?{cursor:r.cursor}:{}},o=r.operation==="list"?await n.roles.get({query:s}):r.operation==="get"?await n.roles({roleKey:r.roleKey}).get():r.operation==="permissions"?await n.roles({roleKey:r.roleKey}).permissions.get({query:s}):await n.roles({roleKey:r.roleKey}).users.get({query:s});if(o.error||!o.data)throw Error("Failed to read organization roles.",{cause:o.error});console.log(JSON.stringify(o.data,null,2))}async function x0(e,t,r){let s=V(e,{getAccessToken:()=>t}).roles({roleKey:r.roleKey}).users({userId:r.userId}),o=r.assigned?await s.put():await s.delete();if(o.error)throw Error("Failed to update role assignment.",{cause:o.error});console.log(JSON.stringify({roleKey:r.roleKey,userId:r.userId,assigned:r.assigned},null,2))}function Vf(e,t,r=S0,n=v0,s=k0,o=x0){let i=e.command("roles").description("Manage organization roles"),a=i.command("permissions").description("Manage role permissions"),c=i.command("users").description("Manage role assignments");for(let l of["add","remove"])c.command(`${l} <role-key> <user-id>`).description(l==="add"?"Assign an existing role to a user":"Remove a role from a user").action(async(p,u)=>{let d=await t.createAuthenticatedContext();await o(d.serverUrl,d.accessToken,{roleKey:p,userId:u,assigned:l==="add"})});i.command("create <role-key>").description("Create a custom role with permissions").requiredOption("--permissions-file <file>","JSON permissions file").action(async(l,p)=>{let u=await t.createAuthenticatedContext();await n(u.serverUrl,u.accessToken,{operation:"create",roleKey:l,file:p.permissionsFile})}),a.command("export <role-key>").description("Export all permissions as an editable update file").action(async(l)=>{let p=await t.createAuthenticatedContext();await s(p.serverUrl,p.accessToken,l)}),a.command("set <role-key>").description("Replace all permissions using an exported JSON file").requiredOption("--file <file>","JSON permissions file with expectedRevision").action(async(l,p)=>{let u=await t.createAuthenticatedContext();await n(u.serverUrl,u.accessToken,{operation:"set",roleKey:l,file:p.file})}),i.command("get <role-key>").description("Read role metadata").action(async(l)=>{let p=await t.createAuthenticatedContext();await r(p.serverUrl,p.accessToken,{operation:"get",roleKey:l})});for(let l of["list","permissions","users"])(l==="list"?i.command("list").description("List organization roles"):(l==="permissions"?a:c).command("list <role-key>").description(`List role ${l}`)).option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(...u)=>{let d=l==="list"?void 0:u[0],h=u[l==="list"?0:1],b=h.limit===void 0?void 0:Number(h.limit);if(b!==void 0&&(!Number.isInteger(b)||b<1||b>100))throw Error("limit must be an integer between 1 and 100.");let g=await t.createAuthenticatedContext();await r(g.serverUrl,g.accessToken,{operation:l,...d?{roleKey:d}:{},...b!==void 0?{limit:b}:{},...h.cursor?{cursor:h.cursor}:{}})})}import{readFileSync as C0}from"node:fs";function ds(e,t,r){let n=V(e,{getAccessToken:()=>t});return r?n.users({userId:r})["subject-settings"]:n["subject-settings"]}async function Wf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n.get();if(o||!s)throw Error("Failed to get subject settings.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Gf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n["onboarding-tour"].put();if(o||!s)throw Error("Failed to finish the onboarding tour.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Jf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n["onboarding-tour"].delete();if(o||!s)throw Error("Failed to reset the onboarding tour.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Bf(e,t,r,n){let s={...r.analyticsUserKey?{analyticsUserKey:r.analyticsUserKey}:{},...r.currencyCode?{currencyCode:r.currencyCode}:{},...r.timezone?{timezone:r.timezone}:{}};if(r.rulesFile)s.rulesJson=JSON.parse(C0(r.rulesFile,"utf8"));let{data:o,error:i}=await ds(e,t,n).put(s);if(i||!o)throw Error("Failed to update subject settings.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Hf(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.users.post(r);if(o||!s)throw Error("Failed to create user.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Yf(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.users.invite.post({email:r});if(o||!s)throw Error("Failed to invite user.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Qf(e,t,r,n){let s=V(e,{getAccessToken:()=>t}),{data:o,error:i}=await s.users({userId:r}).roles.get({query:{...n,limit:n.limit??50}});if(i||!o)throw Error("Failed to list user roles.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Xf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.users.get({query:{...n,limit:n.limit??50}});if(i||!o)throw Error("Failed to list workspace users.",{cause:i});console.log(JSON.stringify(o,null,2))}async function eh(e,t){let r=V(e,{getAccessToken:()=>t}),{data:n,error:s}=await r.auth.me.get();if(s||!n)throw Error("Failed to load authenticated identity.",{cause:s});console.log(JSON.stringify(n.user,null,2))}function th(e,t,r={},n){Vf(e,t,r.runRolesRead),e.command("password").description("Manage your password").command("change").description("Change your password using hidden interactive prompts").action(async()=>{let b=await t.createAuthenticatedContext();await(r.runPasswordChange??Zf)(b.serverUrl,b.accessToken)});let s=r.runLogin??jf,o=e.command("users").description("Create, invite, and inspect users");o.command("create").description("Create a user with roles and send an invitation").requiredOption("--email <email>","User email address").requiredOption("--first-name <first-name>","First name").requiredOption("--last-name <last-name>","Last name").requiredOption("--role <role-key>","Role to assign (repeat for multiple roles)",(b,g=[])=>[...g,b]).action(async(b)=>{let g=await t.createAuthenticatedContext();await(r.runUsersCreate??Hf)(g.serverUrl,g.accessToken,{email:b.email,firstName:b.firstName,lastName:b.lastName,roleKeys:b.role})}),o.command("invite <email>").description("Send or resend an account setup invitation").action(async(b)=>{let g=await t.createAuthenticatedContext();await(r.runUsersInvite??Yf)(g.serverUrl,g.accessToken,b)}),o.command("roles").description("Inspect user role assignments").command("list <user-id>").description("List roles assigned to a user").option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(b,g)=>{let w=g.limit===void 0?50:Number(g.limit);if(!Number.isInteger(w)||w<1||w>100)throw Error("limit must be an integer between 1 and 100.");let T=await t.createAuthenticatedContext();await(r.runUserRolesList??Qf)(T.serverUrl,T.accessToken,b,{limit:w,...g.cursor?{cursor:g.cursor}:{}})}),o.command("list").description("List users who can read the selected workspace").option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(b)=>{let g=b.limit===void 0?void 0:Number(b.limit);if(g!==void 0&&(!Number.isInteger(g)||g<1||g>100))throw Error("limit must be an integer between 1 and 100.");let w=await t.createWorkspaceContext();await(r.runUsersList??Xf)(w.serverUrl,w.accessToken,w.workspaceKey,{...g!==void 0?{limit:g}:{},...b.cursor?{cursor:b.cursor}:{}})});let i=r.runWhoAmI??eh,a=r.runSubjectSettingsGet??Wf,c=r.runSubjectSettingsPut??Bf,l=r.runOnboardingTourFinish??Gf,p=r.runOnboardingTourReset??Jf;if(e.command("login").description("Authenticate with the server").action(function(){return s(t.getResolvedServerUrl(),{store:t.createStore()})}),e.command("logout").description("Clear the local authenticated session").action(function(){t.createStore().clear(),console.log(JSON.stringify({loggedOut:!0},null,2))}),n)n(e,t,r);e.command("whoami").description("Show the current authenticated user").action(async function(){let b=await t.createAuthenticatedContext();await i(b.serverUrl,b.accessToken)});let u=e.command("subject-settings").description("Manage settings for the signed-in subject, or another user's with --user"),d=["--user <user-id>","Act on this user in the organization (needs subject settings permissions)"];u.command("get").description("Get subject settings").option(...d).action(async function(b){let g=await t.createAuthenticatedContext();await a(g.serverUrl,g.accessToken,b.user)});let h=u.command("onboarding-tour").description("Manage the first-time tour");h.command("finish").description("Mark the first-time tour as finished so it no longer shows for you").option(...d).action(async function(b){let g=await t.createAuthenticatedContext();await l(g.serverUrl,g.accessToken,b.user)}),h.command("reset").description("Show the first-time tour again for you the next time you open the app").option(...d).action(async function(b){let g=await t.createAuthenticatedContext();await p(g.serverUrl,g.accessToken,b.user)}),u.command("put").description("Update subject settings").option("--rules-file <rules-file>","RLS rules JSON file").option("--analytics-user-key <analytics-user-key>","Analytics user key").option("--currency-code <currency-code>","ISO 4217 currency code").option("--timezone <timezone>","IANA time zone").option(...d).action(async function(b){if(!b.rulesFile&&!b.analyticsUserKey&&!b.currencyCode&&!b.timezone)throw Error("Provide at least one of --rules-file, --analytics-user-key, --currency-code, or --timezone.");let g=await t.createAuthenticatedContext();await c(g.serverUrl,g.accessToken,{...b.rulesFile?{rulesFile:b.rulesFile}:{},...b.analyticsUserKey?{analyticsUserKey:b.analyticsUserKey}:{},...b.currencyCode?{currencyCode:b.currencyCode}:{},...b.timezone?{timezone:b.timezone}:{}},b.user)})}import{readFileSync as t$}from"node:fs";async function rh(e,t,r){let n=V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r}),{data:s,error:o}=await n["api-keys"].post();if(o||!s)throw Error("Failed to create API key.",{cause:o});console.log(JSON.stringify(s,null,2))}import{readFileSync as _0}from"node:fs";import{extname as A0}from"node:path";var nh=100;function Bi(e){if(typeof e==="string")return e.length>nh?`${e.slice(0,nh-3)}...`:e;if(Array.isArray(e))return e.map(Bi);if(e&&typeof e==="object")return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Bi(r)]));return e}function ft(e,t,r){return V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r})}function O0(e){try{let t=_0(e,"utf8");return T0(e,t)}catch(t){throw Error(`Failed to read app settings file '${e}'. ${t instanceof Error?t.message:""}`.trim(),{cause:t})}}function T0(e,t){return $0(e)==="json"?JSON.parse(t):Ue(t)}function $0(e){let t=A0(e).toLowerCase();if(t===".json")return"json";if(t===".yaml"||t===".yml")return"yaml";throw Error(`App settings files must use .json, .yaml, or .yml: '${e}'.`)}async function sh(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps.post(n);if(i||!o)throw Error("Failed to create app.",{cause:i});console.log(JSON.stringify(o,null,2))}async function oh(e,t,r){let n=ft(e,t,r),{data:s,error:o}=await n.apps.get();if(o||!s)throw Error("Failed to list apps.",{cause:o});console.log(JSON.stringify(s.apps,null,2))}async function ih(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n}).get();if(i||!o)throw Error("Failed to get app.",{cause:i});console.log(JSON.stringify(o,null,2))}async function ah(e,t,r,n,s,o={}){if(o.full&&o.include)throw Error("--full and --include cannot be combined.");let i=ft(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).agent.get({query:{modelKey:s,...o.include?{include:o.include}:{},...o.tables?{tables:o.tables}:{}}});if(c||!a)throw Error("Failed to get app agent runtime context.",{cause:c});let l=!o.full&&!o.include&&!o.tables,p={schemaVersion:Sr,kind:"app-agent-context",include:o.include??null,truncated:l,data:l?Bi(a):a},u=`${JSON.stringify(p,null,2)}
229
- `;if(o.outputFile){me(o.outputFile,u,o.force),fe(o.outputFile,{kind:p.kind,include:p.include,truncated:l});return}process.stdout.write(u)}async function ch(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n})["frontend-config"].get();if(i||!o)throw Error("Failed to get app frontend config.",{cause:i});console.log(JSON.stringify(o,null,2))}async function lh(e,t,r,n,s){let o=ft(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).patch(s);if(a||!i)throw Error("Failed to update app.",{cause:a});console.log(JSON.stringify(i,null,2))}async function uh(e,t,r,n,s){let o=O0(s.inputFile);if(s.promptsDir){let{orchestrator:l,...p}=nr(s.promptsDir),u=o.agent?.prompts??{};o.agent={...o.agent,prompts:{...u,...p,...l&&{orchestrator:{...u.orchestrator,...l}}}}}let i=ft(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).settings.put(o);if(c||!a)throw Error("Failed to update app settings.",{cause:c});console.log(JSON.stringify(a,null,2))}async function ph(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n}).get();if(i||!o)throw Error("Failed to get app settings.",{cause:i});console.log(JSON.stringify(o.settings,null,2))}function Ze(e,t,r,n){return k(e,t,r).apps({appKey:n})["dashboard-arrangements"]}function ht(e,t,r){if(t||!e)throw Error(r,{cause:t});M(e)}async function dh(e,t,r,n,s){let o=Ze(e,t,r,n),i=s==="default"?await o.default.get():await o.get();ht(i.data,i.error,"Failed to get dashboard arrangement.")}async function mh(e,t,r,n){let{error:s}=await Ze(e,t,r,n).delete();if(s)throw Error("Failed to reset personal dashboard arrangement.",{cause:s});M({reset:!0})}async function fh(e,t,r,n,s,o=!0){let i=Ze(e,t,r,n).dashboards({dashboardKey:s}).hide,{error:a}=o?await i.post():await i.delete();if(a)throw Error(`Failed to ${o?"hide":"show"} dashboard.`,{cause:a});M({hidden:o})}async function hh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups.post({name:s.name});ht(a.data,a.error,"Failed to create dashboard group.")}async function gh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).patch({name:s.name});ht(a.data,a.error,"Failed to update dashboard group.")}async function yh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).position.patch({...s.beforeDashboardGroupId?{beforeDashboardGroupId:s.beforeDashboardGroupId}:{},...s.afterDashboardGroupId?{afterDashboardGroupId:s.afterDashboardGroupId}:{}});ht(a.data,a.error,"Failed to move dashboard group.")}async function bh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).delete();ht(a.data,a.error,"Failed to delete dashboard group.")}async function wh(e,t,r,n,s){let o=await Ze(e,t,r,n).default.dashboards.post({dashboardKey:s.dashboardKey,...s.dashboardGroupId?{dashboardGroupId:s.dashboardGroupId}:{}});ht(o.data,o.error,"Failed to add dashboard to the default arrangement.")}async function vh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).dashboards({dashboardKey:s.dashboardKey}).patch({...s.dashboardGroupId!==void 0?{dashboardGroupId:s.dashboardGroupId}:{},...s.beforeDashboardKey?{beforeDashboardKey:s.beforeDashboardKey}:{},...s.afterDashboardKey?{afterDashboardKey:s.afterDashboardKey}:{}});ht(a.data,a.error,"Failed to move dashboard.")}async function kh(e,t,r,n,s){let i=await Ze(e,t,r,n).default.dashboards({dashboardKey:s.dashboardKey}).delete();ht(i.data,i.error,"Failed to remove dashboard from arrangement.")}import{randomUUID as E0}from"node:crypto";import{createWriteStream as N0,readFileSync as D0}from"node:fs";import{rename as P0,rm as I0}from"node:fs/promises";import{Readable as F0}from"node:stream";import{pipeline as L0}from"node:stream/promises";function Hi(e,t,r){if(t||!e)throw Error(r,{cause:t});console.log(JSON.stringify(e,null,2))}async function Sh(e,t,r){let n=await fetch(e);if(!n.ok)throw Error(`Failed to download dashboard snapshot ${r}.`);if(!n.body)throw Error(`Dashboard snapshot ${r} response has no body.`);let s=`${t}.${E0()}.tmp`;try{await L0(F0.fromWeb(n.body),N0(s)),await P0(s,t)}catch(o){throw await I0(s,{force:!0}),o}console.log(t)}var xh={async create(e,t,r,n,s,o){let a=await k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}).snapshots.post(o?JSON.parse(D0(o,"utf8")):{filters:[]});Hi(a.data,a.error,"Failed to create dashboard snapshot.")},async get(e,t){let n=await V(e)["dashboard-snapshots"]({publicId:t}).get();Hi(n.data,n.error,"Failed to get dashboard snapshot.")},async getVisualisation(e,t,r,n=!1){let o=V(e)["dashboard-snapshots"]({publicId:t}).visualisations({visualisationKey:r}),i=await(n?o.render.get():o.get());Hi(i.data,i.error,"Failed to get dashboard snapshot visualisation.")},async downloadCsv(e,t,r,n){await Sh(new URL(`/dashboard-snapshots/${t}/visualisations/${r}/csv`,e),n,"CSV")},async downloadPdf(e,t,r){await Sh(new URL(`/dashboard-snapshots/${t}/pdf`,e),r,"PDF")}};import{readFileSync as It}from"node:fs";var z0=R().trim().nonempty("Model key is required").regex(/^[a-z0-9-]+$/,"Model key must use only lowercase ASCII letters, digits, and dashes"),Nh=R().trim().nonempty("Query key is required").regex(/^[a-z0-9-]+$/,"Query key must use only lowercase ASCII letters, digits, and dashes"),mq=R().trim().nonempty("Visualisation key is required").regex(/^[a-z0-9-]+$/,"Visualisation key must use only lowercase ASCII letters, digits, and dashes"),Jr=["table","line","bar","pie","metric","pivot","scatter","html"],q0=H(Jr),K0=be,Yi=R().trim().nonempty("Agent generated SQL is required"),Dh=R().trim().nullable(),Ch=ne({column:R().min(1),rowIndex:ie().int().nonnegative()});function _h(e){if(e==null)return null;if(typeof e==="string"&&e.trim()==="")return null;return e}var R0=wr("mode",[ne({mode:te("columns"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1),comparisonValueColumn:R().nullable()}),ne({mode:te("grouped"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1)})]),U0=wr("mode",[ne({mode:te("columns"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1)}),ne({mode:te("grouped"),nameColumn:Te().optional(),clusterColumn:R().nullable().optional(),valueColumns:Z(R()).min(1)})]),ms=ne({position:H(["top","bottom","left","right"])}).nullable().optional(),fs=ne({column:R().refine((e)=>e.trim().length>0),order:Z(R().refine((e)=>e.trim().length>0)).min(1).nullable().optional()}).superRefine((e,t)=>{if(e.order&&new Set(e.order).size!==e.order.length)t.addIssue({code:"custom",path:["order"],message:"order must contain unique names"})}),fq=Z(ne({name:R(),colorIndex:ie().int().nonnegative(),rowIndex:ie().int().nonnegative().optional(),other:oe().optional(),value:ie().optional()})),Ah=Z(ne({valueColumns:Z(R()).min(1),position:H(["left","right","top","bottom"]),index:ie().int().min(0).max(4)})).max(5).nullable().optional(),M0=R().trim().min(1),Ph=j({version:te(1),filters:Z(j({filterKey:M0,status:H(["supported","unsupported"])}))}).superRefine((e,t)=>{let r=new Set;for(let[n,s]of e.filters.entries()){if(r.has(s.filterKey))t.addIssue({code:"custom",path:["filters",n,"filterKey"],message:`Duplicate filter key '${s.filterKey}'`});r.add(s.filterKey)}}),j0=H(["MO","TU","WE","TH","FR","SA","SU"]),Z0=j({freq:H(["DAILY","WEEKLY","MONTHLY"]),byhour:ie().int().min(0).max(23),byminute:ie().int().min(0).max(59),byday:j0.optional(),bymonthday:ie().int().min(-1).max(31).optional()}).superRefine((e,t)=>{if(e.freq==="WEEKLY"&&e.byday===void 0)t.addIssue({code:"custom",path:["byday"],message:"byday is required for WEEKLY"});if(e.freq==="MONTHLY"&&e.bymonthday===void 0)t.addIssue({code:"custom",path:["bymonthday"],message:"bymonthday is required for MONTHLY"})}),Ih=wr("type",[j({type:te("always")}),j({type:te("never")}),j({type:te("schedule"),close:Z0})]);var Oh=H(["muted","success","destructive"]),Th=br([Oh,ne({rules:Z(ne({op:H(["lt","lte","gt","gte","eq"]),value:ie(),color:Oh})).min(1)})]),$h=ne({column:R().min(1),title:be.nullable().optional(),width:ie().int().min(72).max(640).nullable().optional(),format:H(["number","percent"]).nullable().optional(),backgroundColor:Th.nullable().optional(),textColor:Th.nullable().optional()}),Eh=ne({column:R().min(1),title:be.nullable().optional(),order:Z(br([R(),ie(),oe(),cb()])).min(1).refine((e)=>new Set(e).size===e.length,"Order values must be unique").nullable().optional()}),hq=ne({rowKeys:Z(Z(mn())),columnKeys:Z(Z(mn()))}),V0=no(R().min(1),be).nullable().optional(),gt={columnLabels:V0,showChrome:oe().optional()},W0=102400,G0=5,J0=j({name:R().regex(/^[a-z][a-z0-9_]*$/,"Secondary query names use lowercase letters, digits and _"),sql:Yi,params:Z(R().trim().min(1)).max(10)}),Fh=wr("type",[ne({type:te("table"),...gt,columns:Z($h).nullable().optional()}),ne({type:te("line"),...gt,xColumn:R(),series:R0,legendColumn:fs.nullable().optional(),seriesOrder:Te().optional(),sort:H(["asc","desc","preserve"]),fitToScreen:oe().optional(),showLabels:oe().optional(),valueAxes:Ah,legend:ms}),ne({type:te("bar"),...gt,categoryColumn:R(),categoryAxis:H(["x","y"]),series:U0,legendColumn:fs.nullable().optional(),seriesOrder:Te().optional(),stacked:H(["standard","full"]).nullable().optional(),sortBy:H(["value","category"]),sort:H(["asc","desc","preserve"]),fitToScreen:oe().optional(),barSize:ie().min(oo.min).max(oo.max).nullable().optional(),showLabels:oe().optional(),valueAxes:Ah,legend:ms}),ne({type:te("pie"),...gt,legendColumn:fs,labelColumn:Te().optional(),seriesOrder:Te().optional(),valueColumn:R(),showLabels:oe().optional(),legend:ms}),ne({type:te("metric"),...gt,primaryMetricValue:Ch,secondaryMetricValue:hu(_h,Ch.nullable()),secondaryMetricLabel:hu(_h,be.nullable())}),ne({type:te("pivot"),...gt,rowOrder:H(["alphabetical","preserve"]).optional(),rows:Z(Eh),columns:Z(Eh),values:Z($h).min(1),stickyHeader:oe().optional(),stickyRowLabels:oe().optional()}),ne({type:te("scatter"),...gt,xColumn:R().min(1),yColumn:R().min(1),hoverColumn:R().min(1).nullable().optional(),legendColumn:fs.nullable().optional(),colorColumn:Te().optional(),seriesOrder:Te().optional(),sizeColumn:R().min(1).nullable().optional(),showLabels:oe().optional(),legend:ms}),ne({type:te("html"),...gt,template:R().min(1).refine((e)=>new TextEncoder().encode(e).length<=W0,"template must be at most 100 KB"),minHeight:ie().int().min(40).max(4000).optional(),height:H(["fixed","fit"]).optional(),secondaryQueries:Z(J0).max(G0).optional()})]).superRefine((e,t)=>{if(e.type==="html"){let r=(e.secondaryQueries??[]).map((n)=>n.name);for(let[n,s]of r.entries())if(r.indexOf(s)!==n)t.addIssue({code:"custom",path:["secondaryQueries",n,"name"],message:`Duplicate secondary query '${s}'`});return}if(e.type==="bar"||e.type==="line"){if(e.series.mode==="grouped"!==(e.legendColumn!=null))t.addIssue({code:"custom",path:["legendColumn"],message:"legendColumn is required for grouped series and forbidden for columns series"})}if(e.type==="table"){let r=new Set;for(let[n,s]of(e.columns??[]).entries()){if(r.has(s.column))t.addIssue({code:"custom",path:["columns",n,"column"],message:`Duplicate column '${s.column}'`});r.add(s.column)}return}if(e.type==="pivot"){let r=[["rows",e.rows],["columns",e.columns],["values",e.values]],n=new Map;for(let[s,o]of r){let i=new Set;for(let[a,c]of o.entries()){if(i.has(c.column))t.addIssue({code:"custom",path:[s,a,"column"],message:`Duplicate column '${c.column}'`});i.add(c.column);let l=n.get(c.column);if(l)t.addIssue({code:"custom",path:[s,a,"column"],message:`Column '${c.column}' is also in ${l}`});else n.set(c.column,s)}}return}if(e.type==="scatter"){if(e.xColumn===e.yColumn)t.addIssue({code:"custom",path:["yColumn"],message:"yColumn must differ from xColumn"});let r=new Map([[e.xColumn,"xColumn"],[e.yColumn,"yColumn"]]);for(let[n,s]of[["hoverColumn",e.hoverColumn],["legendColumn",e.legendColumn?.column],["sizeColumn",e.sizeColumn]]){if(!s)continue;let o=r.get(s);if(o)t.addIssue({code:"custom",path:[n],message:`Column '${s}' is also ${o}`});else r.set(s,n)}return}if(e.type==="bar"&&e.barSize!=null&&e.fitToScreen!==!1)t.addIssue({code:"custom",path:["barSize"],message:"barSize requires fitToScreen to be false"});if(e.type!=="bar"||e.series.mode!=="grouped"||!e.series.clusterColumn)return;if(e.stacked==null)t.addIssue({code:"custom",path:["series","clusterColumn"],message:"clusterColumn requires stacked to be standard or full"});if(e.series.valueColumns.length!==1)t.addIssue({code:"custom",path:["series","valueColumns"],message:"clusterColumn requires exactly one value column"})});function Lh(e,t){if(e.type==="table"){if(e.config!=null&&e.config.type!=="table")t.addIssue({code:"custom",path:["config"],message:"Config type must match visualisation type"});return}if(e.config==null){t.addIssue({code:"custom",path:["config"],message:"Config is required for non-table visualisations"});return}if(e.config.type!==e.type)t.addIssue({code:"custom",path:["config"],message:"Config type must match visualisation type"})}var B0=j({agentContext:De.optional(),title:K0,type:q0,modelKey:z0,agentGeneratedSql:Yi.optional(),queryKey:Nh.optional(),reasoningText:Dh.optional(),config:Fh.nullable().optional(),filtersConfig:Ph.optional(),freshness:Ih.optional()});function H0(e,t){if(e.queryKey&&e.agentGeneratedSql)t.addIssue({code:"custom",path:["queryKey"],message:"Send either queryKey or agentGeneratedSql, not both"});if(!e.queryKey&&!e.agentGeneratedSql)t.addIssue({code:"custom",path:["agentGeneratedSql"],message:"queryKey or agentGeneratedSql is required"})}var gq=B0.superRefine(Lh).superRefine(H0),yq=j({agentContext:De.optional(),title:fn.optional(),config:Fh.nullable().optional(),reasoningText:Dh.optional(),filtersConfig:Ph.optional(),freshness:Ih.optional(),queryKey:Nh.optional(),agentGeneratedSql:Yi.optional()}).superRefine((e,t)=>{if(e.title===void 0&&e.config===void 0&&e.reasoningText===void 0&&e.filtersConfig===void 0&&e.freshness===void 0&&e.queryKey===void 0&&e.agentGeneratedSql===void 0)t.addIssue({code:"custom",message:"At least one field is required"});if(e.queryKey&&e.agentGeneratedSql)t.addIssue({code:"custom",path:["queryKey"],message:"Send either queryKey or agentGeneratedSql, not both"});if(e.config!==void 0)Lh({type:e.config?.type??"table",config:e.config},t)});import{readFileSync as Y0}from"node:fs";function Pt(e){return e?De.parse(JSON.parse(Y0(e,"utf8"))):void 0}var Q0=["layout-dashboard","chart-column","chart-line","table","chart-pie"];function Ve(e){return{query:e?{response:"minimal"}:{}}}function X0(e,t){if(!e){if(t&&t!=="table")throw Error("Config file is required for non-table visualisations.");return}return JSON.parse(It(e,"utf8"))}async function zh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards.post({agentContext:Pt(s.agentContextFile),title:s.title,...s.visualisationKeys?.length?{visualisationKeys:s.visualisationKeys}:{}},Ve(s.minimal));if(a||!i)throw Error("Failed to create dashboard.",{cause:a});M(i)}async function qh(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards.get({query:s});if(a||!i)throw Error("Failed to list dashboards.",{cause:a});M(s.limit!==void 0||s.cursor?i:i.dashboards)}async function Kh(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).get({query:o?{view:o}:{}});if(c||!a)throw Error("Failed to get dashboard.",{cause:c});M(a)}async function Rh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).filters.available.get();if(a||!i)throw Error("Failed to get available dashboard filters.",{cause:a});M(i.availableFilters)}async function Uh(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).filters({filterKey:o}).values.get({query:{...i.search?{q:i.search}:{},...i.limit!==void 0?{limit:i.limit}:{},...i.cursor?{cursor:i.cursor}:{}}});if(l||!c)throw Error("Failed to search dashboard filter values.",{cause:l});M(c)}async function Mh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).delete();if(a||!i)throw Error("Failed to delete dashboard.",{cause:a});M(i)}async function jh(e,t,r,n,s,o,i,a){let c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).placements({dashboardVisualisationId:i}).delete(void 0,Ve(a));if(p||!l)throw Error("Failed to delete dashboard visualisation.",{cause:p});M(l)}async function Zh(e,t,r,n,s,o){if(o.icon&&!Q0.includes(o.icon))throw Error("Invalid dashboard icon.");let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).patch(o);if(c||!a)throw Error("Failed to update dashboard.",{cause:c});M(a)}async function Vh(e,t,r,n,s,o,i){let a=JSON.parse(It(o,"utf8")),c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).state.patch(a,Ve(i));if(p||!l)throw Error("Failed to save dashboard.",{cause:p});M(l)}async function Wh(e,t,r,n,s,o,i,a){let c=JSON.parse(It(i,"utf8")),l=k(e,t,r),{data:p,error:u}=await l.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).layout.patch({placements:c.placements??[],notes:c.notes??[]},Ve(a));if(u||!p)throw Error("Failed to update dashboard layout.",{cause:u});M(p)}async function Gh(e,t,r,n,s,o,i,a=!1){let c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).visualisations({visualisationKey:i}).pin.post({removeIncompatibleFilters:a});if(p||!l){let u=p?.value?.removedFilterKeys;throw Error(u?.length?`Pin would remove dashboard filters: ${u.join(", ")}. Retry with --remove-incompatible-filters.`:"Failed to pin visualisation to dashboard.",{cause:p})}if(l.removedFilterKeys.length>0)console.warn(`Removed incompatible dashboard filters: ${l.removedFilterKeys.join(", ")}`);M(l)}async function Jh(e,t,r,n,s,o=!1,i){let a=JSON.parse(It(s,"utf8")),c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards.pin.post({...a,...o?{removeIncompatibleFilters:!0}:{}},Ve(i));if(p||!l)throw console.error(JSON.stringify(p?.value??{error:"Bulk pin request failed"},null,2)),Error("Could not pin visualisations. Review conflicts before retrying with --remove-incompatible-filters.",{cause:p});if(M(l),l.results.some((u)=>u.status!=="pinned"))throw Error("Some pins did not complete. Retry only failed pins; check unknown outcomes before retrying.")}async function Bh(e,t,r,n,s,o,i){if(!Jr.includes(i.type))throw Error("Invalid visualisation type.");let a=X0(i.configFile,i.type),c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).visualisations.post({title:i.title,type:i.type,modelKey:i.modelKey,...a!==void 0?{config:a}:{},agentGeneratedSql:It(i.sqlFile,"utf8"),...i.reasoningText?{reasoningText:i.reasoningText}:{},...i.removeIncompatibleFilters?{removeIncompatibleFilters:!0}:{}});if(p||!l){let u=p?.value?.removedFilterKeys;throw Error(u?.length?`Creating this visualisation would remove dashboard filters: ${u.join(", ")}. Retry with --remove-incompatible-filters.`:"Failed to create and pin visualisation to dashboard.",{cause:p})}if(l.removedFilterKeys.length>0)console.warn(`Removed incompatible dashboard filters: ${l.removedFilterKeys.join(", ")}`);M(l)}async function Hh(e,t,r,n,s,o,i,a,c){let l=JSON.parse(It(i,"utf8")),p=k(e,t,r),{data:u,error:d}=await p.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes.post({content:l,agentContext:Pt(a)},Ve(c));if(d||!u)throw Error("Failed to create dashboard note.",{cause:d});M(u)}async function Yh(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).get();if(l||!c)throw Error("Failed to read dashboard note.",{cause:l});M(c)}async function Qh(e,t,r,n,s,o,i,a,c,l){let p=JSON.parse(It(a,"utf8")),u=k(e,t,r),{data:d,error:h}=await u.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).patch({content:p,agentContext:Pt(c)},Ve(l));if(h||!d)throw Error("Failed to update dashboard note.",{cause:h});M(d)}async function Xh(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).delete();if(l||!c)throw Error("Failed to delete dashboard note.",{cause:l});M(c)}async function eg(e,t,r,n,s){let o=k(e,t,r);if(s.dashboard){let c=o.apps({appKey:n}).dashboards({dashboardKey:s.dashboard}),{data:l,error:p}=await c["share-targets"].get({query:{q:s.q??"",limit:s.limit??50}});if(p||!l)throw Error("Failed to list dashboard share targets.",{cause:p});M(l);return}if(!s.targetType)throw Error("--target-type is required without --dashboard");let{data:i,error:a}=await o.apps({appKey:n})["share-targets"].get({query:{targetType:s.targetType,...s.q?{q:s.q}:{},...s.limit!==void 0?{limit:s.limit}:{},...s.cursor?{cursor:s.cursor}:{}}});if(a||!i)throw Error("Failed to list share targets.",{cause:a});M(i)}async function tg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).shares.get();if(a||!i)throw Error("Failed to list dashboard shares.",{cause:a});M(i)}async function rg(e,t,r,n,s,o,i,a="read"){let c=k(e,t,r),{data:l,error:p}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).shares.post({target:{type:o,key:i},mode:a});if(p||!l)throw Error("Failed to create dashboard share.",{cause:p});M(l)}async function ng(e,t,r,n,s){let i=k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}),{data:a,error:c}=await i["personal-copy"].post();if(c||!a)throw Error("Failed to personalise dashboard.",{cause:c});M(a)}async function sg(e,t,r,n,s){let i=k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}),{error:a}=await i["personal-copy"].delete();if(a)throw Error("Failed to reset dashboard to default.",{cause:a});M({reset:!0})}async function og(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).shares({targetType:o})({targetKey:i}).delete();if(l||!c)throw Error("Failed to delete dashboard share.",{cause:l});M(c)}async function ig(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).draft.post();if(a||!i)throw Error("Failed to create or reopen dashboard draft.",{cause:a});M(i)}async function ag(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).publish.post();if(a||!i)throw Error("Failed to publish dashboard draft.",{cause:a});M(i)}async function cg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).draft.delete();if(a||!i)throw Error("Failed to discard dashboard draft.",{cause:a});M(i)}async function lg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs.post({title:o});if(c||!a)throw Error("Failed to create dashboard tab.",{cause:c});M(a)}async function ug(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).patch({title:i});if(l||!c)throw Error("Failed to update dashboard tab.",{cause:l});M(c)}async function pg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs.order.patch({orderedTabKeys:o});if(c||!a)throw Error("Failed to update dashboard tab order.",{cause:c});M(a)}async function dg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).delete();if(c||!a)throw Error("Failed to delete dashboard tab.",{cause:c});M(a)}async function mg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"].post({providerKey:n.providerKey,apiKey:n.apiKey,displayName:n.displayName});if(i||!o)throw Error("Failed to create LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function fg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n.providerKey}).put({apiKey:n.apiKey});if(i||!o)throw Error("Failed to update LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function hg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n}).get();if(i||!o)throw Error("Failed to get LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function gg(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n["llm-providers"].get();if(o||!s)throw Error("Failed to list LLM providers.",{cause:o});console.log(JSON.stringify(s,null,2))}async function yg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n}).delete();if(i||!o)throw Error("Failed to delete LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}import{readFileSync as Qi}from"node:fs";function Ye(e,t,r,n,s){return k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}).schedules}function Ne(e,t,r){if(t||!e)throw Error(r,{cause:t});console.log(JSON.stringify(e,null,2))}var bg={async unsubscribe(e,t){let r=Qi(t,"utf8").trim(),n=await V(e)["scheduled-report-unsubscriptions"].post({token:r});Ne(n.data,n.error,"Failed to unsubscribe from scheduled report.")},async create(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s).post(JSON.parse(Qi(o,"utf8")));Ne(i.data,i.error,"Failed to create scheduled report.")},async list(e,t,r,n,s,o){let i=await k(e,t,r).apps({appKey:n}).schedules.get({query:{limit:s,...o?{cursor:o}:{}}});Ne(i.data,i.error,"Failed to list report schedules.")},async dashboardList(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s).get({query:{limit:o,...i?{cursor:i}:{}}});Ne(a.data,a.error,"Failed to list dashboard report schedules.")},async auditList(e,t,r,n,s,o){let i=await k(e,t,r).apps({appKey:n}).schedules.audit.get({query:{limit:s,...o?{cursor:o}:{}}});Ne(i.data,i.error,"Failed to audit report schedules.")},async unread(e,t,r,n){let s=await k(e,t,r).apps({appKey:n}).schedules.unread.get();Ne(s.data,s.error,"Failed to count unread schedule runs.")},async get(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s)({scheduleId:o}).get();Ne(i.data,i.error,"Failed to get scheduled report.")},async update(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).patch(JSON.parse(Qi(i,"utf8")));Ne(a.data,a.error,"Failed to update scheduled report.")},async delete(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s)({scheduleId:o}).delete();Ne(i.data,i.error,"Failed to delete scheduled report.")},async listRuns(e,t,r,n,s,o,i,a){let c=await Ye(e,t,r,n,s)({scheduleId:o}).runs.get({query:{limit:i,...a?{cursor:a}:{}}});Ne(c.data,c.error,"Failed to list scheduled report runs.")},async getRun(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).runs({runId:i}).get();Ne(a.data,a.error,"Failed to get scheduled report run.")},async readRun(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).runs({runId:i}).read.post();if(a.error)throw Error("Failed to mark scheduled report run read.",{cause:a.error});console.log(JSON.stringify({read:!0},null,2))},async run(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s)({scheduleId:o}).runs.post();Ne(i.data,i.error,"Failed to run scheduled report.")}};function hs(e,t,r,n){return k(e,t,r).apps({appKey:n})["user-groups"]}async function wg(e,t,r,n){let{data:s,error:o}=await hs(e,t,r,n).get();if(o||!s)throw Error("Failed to list user groups.",{cause:o});console.log(JSON.stringify(s,null,2))}async function vg(e,t,r,n,s){let{data:o,error:i}=await hs(e,t,r,n)({groupKey:s}).members.get();if(i||!o)throw Error("Failed to list user group members.",{cause:i});console.log(JSON.stringify(o,null,2))}async function kg(e,t,r,n,s,o){let{error:i}=await hs(e,t,r,n)({groupKey:s}).members({userId:o}).put();if(i)throw Error("Failed to add user group member.",{cause:i});console.log(JSON.stringify({added:!0},null,2))}async function Sg(e,t,r,n,s,o){let{error:i}=await hs(e,t,r,n)({groupKey:s}).members({userId:o}).delete();if(i)throw Error("Failed to remove user group member.",{cause:i});console.log(JSON.stringify({removed:!0},null,2))}import{readFileSync as yt}from"node:fs";function e$(e,t){if(!e){if(t&&t!=="table")throw Error("Config file is required for non-table visualisations.");return}return JSON.parse(yt(e,"utf8"))}async function xg(e,t,r,n,s){if(!Jr.includes(s.type))throw Error("Invalid visualisation type.");if(Boolean(s.sqlFile)===Boolean(s.queryKey))throw Error("Provide either --sql-file or --query-key.");let o=e$(s.configFile,s.type),i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).visualisations.post({agentContext:Pt(s.agentContextFile),title:s.title,type:s.type,modelKey:s.modelKey,...o!==void 0?{config:o}:{},...s.sqlFile?{agentGeneratedSql:yt(s.sqlFile,"utf8")}:{queryKey:s.queryKey},...s.reasoningText?{reasoningText:s.reasoningText}:{},...s.filtersConfigFile?{filtersConfig:JSON.parse(yt(s.filtersConfigFile,"utf8"))}:{},...s.freshnessFile?{freshness:JSON.parse(yt(s.freshnessFile,"utf8"))}:{}},Ve(s.minimal));if(c||!a)throw Error("Failed to create visualisation.",{cause:c});M(a)}async function Cg(e,t,r,n,s,o){if(Boolean(o.sqlFile)&&Boolean(o.queryKey))throw Error("Provide either --sql-file or --query-key.");if(!o.title&&!o.configFile&&!o.sqlFile&&!o.queryKey&&!o.reasoningText&&!o.filtersConfigFile&&!o.freshnessFile)throw Error("Provide at least one update field.");let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).visualisations({visualisationKey:s}).patch({agentContext:Pt(o.agentContextFile),...o.title?{title:o.title}:{},...o.configFile?{config:JSON.parse(yt(o.configFile,"utf8"))}:{},...o.sqlFile?{agentGeneratedSql:yt(o.sqlFile,"utf8")}:{},...o.queryKey?{queryKey:o.queryKey}:{},...o.reasoningText?{reasoningText:o.reasoningText}:{},...o.filtersConfigFile?{filtersConfig:JSON.parse(yt(o.filtersConfigFile,"utf8"))}:{},...o.freshnessFile?{freshness:JSON.parse(yt(o.freshnessFile,"utf8"))}:{}},Ve(o.minimal));if(c||!a)throw Error("Failed to update visualisation.",{cause:c});M(a)}async function _g(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).visualisations({visualisationKey:s}).get();if(a||!i)throw Error("Failed to read visualisation.",{cause:a});M(i)}async function Ag(e,t,r,n,s,o,i="query"){let c=k(e,t,r).apps({appKey:n}).visualisations({visualisationKey:s})[i],{data:l,error:p}=await c.post({filters:o.filters?JSON.parse(o.filters):[],forceRefresh:o.forceRefresh??!1,...o.name&&{secondaryQuery:{name:o.name,params:Object.fromEntries((o.param??[]).map((u)=>{let d=u.indexOf("=");if(d<1)throw Error(`--param must look like COLUMN=value: ${u}`);return[u.slice(0,d),u.slice(d+1)]}))}}});if(p||!l)throw Error(`Failed to ${i} visualisation.`,{cause:p});M(l)}async function Og(e,t){let r=V(e,{getAccessToken:()=>t}),{data:n,error:s}=await r.workspaces.get();if(s||!n)throw Error("Failed to list workspaces.",{cause:s});console.log(JSON.stringify(n.workspaces,null,2))}async function Tg(e,t,r,n){let s=V(e,{getAccessToken:()=>t}),{data:o,error:i}=await s.workspaces.get();if(i||!o)throw Error("Failed to list workspaces.",{cause:i});let a=o.workspaces.find((l)=>l.workspaceKey===r);if(!a)throw Error(`Workspace "${r}" is not available. Run \`s workspaces list\` to see accessible workspaces.`);let c=n.load();if(!c||c.serverUrl!==e)throw Error("No saved session for this server. Run login first.");n.save({...c,workspaceId:a.workspaceId,workspaceKey:a.workspaceKey}),console.log(JSON.stringify({workspace:a},null,2))}function $g(e,t,r={}){let n=r.runApiKeysCreate??rh,s=r.runAppsCreate??sh,o=r.runAppsList??oh,i=r.runAppsGet??ih,a=r.runAppsAgentGet??ah,c=r.runAppsFrontendConfigGet??ch,l=r.runAppsUpdate??lh,p=r.runAppsSettingsGet??ph,u=r.runAppsSettingsNew??uh,d=r.runDashboardsList??qh,h=r.runDashboardsCreate??zh,b=r.runDashboardsDelete??Mh,g=r.runDashboardsDiscard??cg,w=r.runDashboardsDraft??ig,T=r.runDashboardsGet??Kh,N=r.runDashboardsAvailableFilters??Rh,x=r.runDashboardsFilterValues??Uh,D=r.runDashboardsPersonalise??ng,P=r.runDashboardsPublish??ag,L=r.runDashboardsResetToDefault??sg,K=r.runDashboardsSave??Vh,E=r.runDashboardsSharesCreate??rg,O=r.runDashboardsSharesDelete??og,C=r.runDashboardsSharesList??tg,v=r.runDashboardsTabsCreate??lg,A=r.runDashboardsTabsCreateNote??Hh,U=r.runDashboardsTabsCreateVisualisation??Bh,G=r.runDashboardsTabsDelete??dg,B=r.runDashboardsTabsDeleteNote??Xh,Fe=r.runDashboardsTabsDeletePlacement??jh,ye=r.runDashboardsTabsLayout??Wh,Pg=r.runDashboardsTabsOrder??pg,Ig=r.runDashboardsTabsPin??Gh,Fg=r.runDashboardsPin??Jh,Lg=r.runDashboardsTabsUpdate??ug,zg=r.runDashboardsTabsReadNote??Yh,qg=r.runDashboardsTabsUpdateNote??Qh,Kg=r.runDashboardsUpdate??Zh,ve=r.scheduledReportCommands??bg,Ft=r.dashboardSnapshotCommands??xh,Rg=r.runAddDashboardToDefaultArrangement??wh,Ug=r.runDashboardArrangementDashboardsMove??vh,Mg=r.runDashboardArrangementDashboardsRemove??kh,jg=r.runDashboardArrangementGroupsCreate??hh,Zg=r.runDashboardArrangementGroupsDelete??bh,Vg=r.runDashboardArrangementGroupsMove??yh,Wg=r.runDashboardArrangementGroupsUpdate??gh,Gg=r.runDashboardArrangementsGet??dh,Xi=r.runDashboardArrangementsHide??fh,Jg=r.runDashboardArrangementsReset??mh,Bg=r.runUserGroupsList??wg,Hg=r.runUserGroupMembersList??vg,Yg=r.runUserGroupMembersAdd??kg,Qg=r.runUserGroupMembersRemove??Sg,Xg=r.runShareTargetsList??eg,ey=r.runVisualisationsCreate??xg,ty=r.runVisualisationsGet??_g,ea=r.runVisualisationsQuery??Ag,ry=r.runVisualisationsUpdate??Cg,ny=r.runLlmProvidersCreate??mg,sy=r.runLlmProvidersUpdate??fg,oy=r.runLlmProvidersGet??hg,iy=r.runLlmProvidersList??gg,ay=r.runLlmProvidersDelete??yg,cy=r.runWorkspacesList??Og,ta=e.command("workspaces").description("Manage workspaces");ta.command("list").description("List workspaces the signed-in user can read").action(async function(){let y=await t.createAuthenticatedContext();await cy(y.serverUrl,y.accessToken)}),ta.command("select").description("Select the workspace for subsequent commands").argument("<workspace-key>","Workspace key").action(async function(y){let m=await t.createAuthenticatedContext();await(r.runWorkspacesSelect??Tg)(m.serverUrl,m.accessToken,y,t.createStore())}),e.command("api-keys").description("Manage API keys").command("create").description("Create an API key").action(async function(){let y=await t.createWorkspaceContext();await n(y.serverUrl,y.accessToken,y.workspaceKey)});let bt=e.command("apps").description("Manage apps");bt.command("create").description("Create an app").option("--key <key>","Stable app key").option("--display-name <display-name>","App display name").action(async function(y){let m=await t.createWorkspaceContext();await s(m.serverUrl,m.accessToken,m.workspaceKey,{appKey:y.key??await W("App key"),displayName:y.displayName??await W("Display name")})}),bt.command("list").description("List apps").action(async function(){let y=await t.createWorkspaceContext();await o(y.serverUrl,y.accessToken,y.workspaceKey)}),bt.command("get").description("Get an app").argument("<app-key>","App key").action(async function(y){let m=await t.createWorkspaceContext();await i(m.serverUrl,m.accessToken,m.workspaceKey,y)}),bt.command("agent").description("Manage app agent runtime context").command("get").description("Get app agent runtime context").argument("<app-key>","App key").option("--model-key <model-key>","Model key").addOption(new ge("--full","Return every context field without truncation").conflicts("include")).addOption(new ge("--include <fields>","Comma-separated runtime context fields").conflicts("full")).option("--tables <identifiers...>","Exact table identifiers for table-derived context").option("--output-file <file>","Write context JSON to a file").option("--force","Replace an existing output file").action(async function(y,m){let f=await t.createWorkspaceContext();await a(f.serverUrl,f.accessToken,f.workspaceKey,y,m.modelKey??await W("Model key"),{full:m.full,include:m.include,tables:m.tables,outputFile:m.outputFile,force:m.force})}),bt.command("frontend-config").description("Manage app frontend config").command("get").description("Get app frontend config").argument("<app-key>","App key").action(async function(y){let m=await t.createWorkspaceContext();await c(m.serverUrl,m.accessToken,m.workspaceKey,y)}),bt.command("*").description("Manage app settings").argument("<app-key>").argument("<settings-command>").argument("<settings-action>").option("--input-file <input-file>","Settings JSON or YAML file").option("--prompts-dir <prompts-dir>","Folder of agent prompt Markdown files, such as orchestrator-system.md").action(async function(y,m,f,_){if(m!=="settings"||!["get","new"].includes(f))throw Error(`Unknown apps command '${[y,m,f].join(" ")}'.`);let F=await t.createWorkspaceContext();if(f==="get"){await p(F.serverUrl,F.accessToken,F.workspaceKey,y);return}await u(F.serverUrl,F.accessToken,F.workspaceKey,y,{inputFile:_.inputFile??await W("Settings file"),promptsDir:_.promptsDir})}),bt.command("update").description("Update an app").argument("<app-key>","App key").option("--display-name <display-name>","App display name").action(async function(y,m){let f=await t.createWorkspaceContext();await l(f.serverUrl,f.accessToken,f.workspaceKey,y,{displayName:m.displayName??await W("Display name")})});let ce=e.command("dashboards").description("Manage dashboards"),ke=e.command("scheduled-reports").description("Manage scheduled dashboard reports");ke.command("unsubscribe").description("Unsubscribe using a token from a report email").requiredOption("--token-file <file>","File containing the unsubscribe token").action((y)=>ve.unsubscribe(t.getResolvedServerUrl(),y.tokenFile));let Lt=e.command("dashboard-snapshots").description("Create and read frozen dashboard snapshots"),Br=(y)=>y.argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key"),wt=(y)=>Br(y).argument("<schedule-id>","Schedule ID"),Se=async(y)=>{let m=await t.createWorkspaceContext();await y(m.serverUrl,m.accessToken,m.workspaceKey)};Br(ke.command("create").description("Create a report schedule")).requiredOption("--input-file <file>","Schedule JSON file").action((y,m,f)=>Se((..._)=>ve.create(..._,y,m,f.inputFile))),ke.command("list").description("List report schedules across an app").argument("<app-key>","App key").option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((y,m)=>{let f=Number(m.limit);if(!Number.isInteger(f)||f<1||f>100)throw Error("limit must be an integer between 1 and 100.");return Se((..._)=>ve.list(..._,y,f,m.cursor))}),Br(ke.command("dashboard-list").description("List report schedules you created or receive for one dashboard")).option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((y,m,f)=>{let _=Number(f.limit);if(!Number.isInteger(_)||_<1||_>100)throw Error("limit must be an integer between 1 and 100.");return Se((...F)=>ve.dashboardList(...F,y,m,_,f.cursor))}),ke.command("unread").description("Count your unread schedule runs across an app").argument("<app-key>","App key").action((y)=>Se((...m)=>ve.unread(...m,y))),ke.command("audit-list").description("Audit all report schedules across an app").argument("<app-key>","App key").option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((y,m)=>{let f=Number(m.limit);if(!Number.isInteger(f)||f<1||f>100)throw Error("limit must be an integer between 1 and 100.");return Se((..._)=>ve.auditList(..._,y,f,m.cursor))}),wt(ke.command("get").description("Get a report schedule")).action((y,m,f)=>Se((..._)=>ve.get(..._,y,m,f))),wt(ke.command("update").description("Update a report schedule")).requiredOption("--input-file <file>","Schedule patch JSON file").action((y,m,f,_)=>Se((...F)=>ve.update(...F,y,m,f,_.inputFile))),wt(ke.command("delete").description("Delete a report schedule")).action((y,m,f)=>Se((..._)=>ve.delete(..._,y,m,f))),wt(ke.command("run").description("Run a schedule once now to test it; its next scheduled time does not change")).action((y,m,f)=>Se((..._)=>ve.run(..._,y,m,f))),wt(ke.command("runs-list").description("List schedule runs")).option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((y,m,f,_)=>{let F=Number(_.limit);if(!Number.isInteger(F)||F<1||F>100)throw Error("limit must be an integer between 1 and 100.");return Se((...le)=>ve.listRuns(...le,y,m,f,F,_.cursor))}),wt(ke.command("runs-get").description("Get one schedule run")).argument("<run-id>","Run ID").action((y,m,f,_)=>Se((...F)=>ve.getRun(...F,y,m,f,_))),wt(ke.command("runs-read").description("Mark one schedule run read for you")).argument("<run-id>","Run ID").action((y,m,f,_)=>Se((...F)=>ve.readRun(...F,y,m,f,_))),Br(Lt.command("create").description("Create a dashboard snapshot")).option("--input-file <file>","Snapshot filter JSON file").action((y,m,f)=>Se((..._)=>Ft.create(..._,y,m,f.inputFile))),Lt.command("get").description("Get a public frozen dashboard snapshot").argument("<public-id>","Public snapshot ID").action((y)=>Ft.get(t.getResolvedServerUrl(),y)),Lt.command("visualisation-get").description("Get one frozen visualisation result").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").action((y,m)=>Ft.getVisualisation(t.getResolvedServerUrl(),y,m)),Lt.command("visualisation-render").description("Get one frozen visualisation result shaped for drawing, without its raw rows").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").action((y,m)=>Ft.getVisualisation(t.getResolvedServerUrl(),y,m,!0)),Lt.command("pdf-download").description("Download the complete frozen dashboard as PDF").argument("<public-id>","Public snapshot ID").requiredOption("--output <file>","Destination PDF file").action((y,m)=>Ft.downloadPdf(t.getResolvedServerUrl(),y,m.output)),Lt.command("csv-download").description("Download a frozen visualisation CSV").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").requiredOption("--output <file>","Destination CSV file").action((y,m,f)=>Ft.downloadCsv(t.getResolvedServerUrl(),y,m,f.output));let or=()=>new ge("--scope <scope>","Dashboard arrangement scope").choices(["default","personal"]).default("personal"),zt=e.command("dashboard-arrangements").description("Manage dashboard navigation arrangements");zt.command("get").description("Get and reconcile the current personal arrangement").argument("<app-key>","App key").addOption(new ge("--scope <scope>","Dashboard arrangement scope").choices(["current","default"]).default("current")).action(async function(y,m){let f=await t.createWorkspaceContext();await Gg(f.serverUrl,f.accessToken,f.workspaceKey,y,m.scope)}),zt.command("reset").description("Reset the personal dashboard arrangement").argument("<app-key>","App key").action(async function(y){let m=await t.createWorkspaceContext();await Jg(m.serverUrl,m.accessToken,m.workspaceKey,y)}),zt.command("hide").description("Hide a dashboard from the personal arrangement").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await Xi(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),zt.command("show").description("Show a hidden dashboard in the personal arrangement again").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await Xi(f.serverUrl,f.accessToken,f.workspaceKey,y,m,!1)});let Hr=zt.command("groups").description("Manage dashboard arrangement groups");Hr.command("create").description("Create a dashboard group").argument("<app-key>","App key").addOption(or()).requiredOption("--name <json>",'Dashboard group name as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).action(async function(y,m){let f=await t.createWorkspaceContext();await jg(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),Hr.command("update").description("Update a dashboard group").argument("<app-key>","App key").addOption(or()).requiredOption("--group-id <group-id>","Dashboard group ID").requiredOption("--name <json>","Dashboard group name changes as a JSON map of locale tag to text; null removes a locale",dt).action(async function(y,m){let f=await t.createWorkspaceContext();await Wg(f.serverUrl,f.accessToken,f.workspaceKey,y,{scope:m.scope,dashboardGroupId:m.groupId,name:m.name})}),Hr.command("move").description("Move a dashboard group by identity anchor").argument("<app-key>","App key").addOption(or()).requiredOption("--group-id <group-id>","Dashboard group ID").addOption(new ge("--before <group-id>","Place before this group ID").conflicts("after")).addOption(new ge("--after <group-id>","Place after this group ID").conflicts("before")).action(async function(y,m){let f=await t.createWorkspaceContext();await Vg(f.serverUrl,f.accessToken,f.workspaceKey,y,{scope:m.scope,dashboardGroupId:m.groupId,beforeDashboardGroupId:m.before,afterDashboardGroupId:m.after})}),Hr.command("delete").description("Delete a dashboard group").argument("<app-key>","App key").addOption(or()).requiredOption("--group-id <group-id>","Dashboard group ID").action(async function(y,m){let f=await t.createWorkspaceContext();await Zg(f.serverUrl,f.accessToken,f.workspaceKey,y,{scope:m.scope,dashboardGroupId:m.groupId})});let ys=zt.command("dashboards").description("Manage dashboards in an arrangement");ys.command("add").description("Add a dashboard to the app default arrangement").argument("<app-key>","App key").requiredOption("--dashboard-key <dashboard-key>","Dashboard key").option("--group-id <group-id>","Dashboard group ID").action(async function(y,m){let f=await t.createWorkspaceContext();await Rg(f.serverUrl,f.accessToken,f.workspaceKey,y,{dashboardKey:m.dashboardKey,dashboardGroupId:m.groupId})}),ys.command("move").description("Move a dashboard by identity anchor").argument("<app-key>","App key").addOption(or()).requiredOption("--dashboard-key <dashboard-key>","Dashboard key").addOption(new ge("--group-id <group-id>","Move into this group").conflicts("ungrouped")).addOption(new ge("--ungrouped","Move into the ungrouped group").conflicts("groupId")).addOption(new ge("--before <dashboard-key>","Place before this dashboard").conflicts("after")).addOption(new ge("--after <dashboard-key>","Place after this dashboard").conflicts("before")).action(async function(y,m){let f=await t.createWorkspaceContext();await Ug(f.serverUrl,f.accessToken,f.workspaceKey,y,{scope:m.scope,dashboardKey:m.dashboardKey,dashboardGroupId:m.ungrouped?null:m.groupId,beforeDashboardKey:m.before,afterDashboardKey:m.after})}),ys.command("remove").description("Remove a dashboard from the app default arrangement").argument("<app-key>","App key").requiredOption("--dashboard-key <dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await Mg(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("create").description("Create a dashboard for an app").argument("<app-key>","App key").option("--title <json>",'Dashboard title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--visualisation-keys <visualisation-keys>","Comma-separated existing visualisation keys to pin").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(y,m){let f=await t.createWorkspaceContext(),_=m.visualisationKeys?.split(",").map((F)=>F.trim()).filter(Boolean);await h(f.serverUrl,f.accessToken,f.workspaceKey,y,{...m.agentContextFile?{agentContextFile:m.agentContextFile}:{},title:m.title??Me(await W("Title (JSON map)")),..._?.length?{visualisationKeys:_}:{},minimal:m.minimal})}),ce.command("list").description("List dashboards for an app").argument("<app-key>","App key").option("--shared-with-group <group-key>","Only dashboards shared with this user group").addOption(new ge("--sort <sort>","Dashboard ordering").choices(["recently-pinned"])).addOption(new ge("--hidden <hidden>","Include dashboards hidden from your personal arrangement, or list only them").choices(["include","only"])).addOption(new ge("--view <view>","Dashboard response detail").choices(["summary","full"])).option("--editable-only","Only dashboards you can edit").option("--limit <limit>","Page size, 1–100 (enables pagination)",Number).option("--cursor <cursor>","Continue from a dashboard page cursor").action(async function(y,m){let f=await t.createWorkspaceContext();await d(f.serverUrl,f.accessToken,f.workspaceKey,y,{sharedWithGroup:m.sharedWithGroup,...m.sort?{sort:m.sort}:{},...m.hidden?{hidden:m.hidden}:{},...m.view?{view:m.view}:{},...m.editableOnly!==void 0?{editableOnly:m.editableOnly}:{},...m.limit!==void 0?{limit:m.limit}:{},...m.cursor?{cursor:m.cursor}:{}})}),ce.command("get").description("Get a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--view <view>","full (default) or layout: tabs and tiles in save format, without chart SQL or settings").action(async function(y,m,f){let _=await t.createWorkspaceContext();await T(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f.view)}),ce.command("available-filters").description("Get dashboard filters with availability status").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await N(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("filter-values").description("Search values for an available dashboard dimension filter").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<filter-key>","Dimension filter key").option("--search <text>","Case-insensitive value search").option("--limit <number>","Page size",(y)=>Number.parseInt(y,10)).option("--cursor <cursor>","Next-page cursor").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await x(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_)}),ce.command("delete").description("Delete a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await b(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("update").description("Update a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--title <json>","Dashboard title changes as a JSON map of locale tag to text; null removes a locale",dt).option("--icon <icon>","Dashboard icon key").option("--filter-key <filter-keys...>","Configured dashboard filter keys").option("--clear-filters","Remove every configured dashboard filter").option("--filter-views-file <path>","Saved filter views JSON file").option("--clear-filter-views","Remove every saved filter view").option("--default-filter-view-key <key>","Default filter view key").option("--clear-default-filter-view","Remove the default filter view").action(async function(y,m,f){if(f.filterKey&&f.clearFilters)throw Error("Use --filter-key or --clear-filters, not both.");if(f.filterViewsFile&&f.clearFilterViews)throw Error("Use --filter-views-file or --clear-filter-views, not both.");if(f.defaultFilterViewKey&&f.clearDefaultFilterView)throw Error("Use --default-filter-view-key or --clear-default-filter-view, not both.");if(!f.title&&!f.icon&&!f.filterKey&&!f.clearFilters&&!f.filterViewsFile&&!f.clearFilterViews&&!f.defaultFilterViewKey&&!f.clearDefaultFilterView)throw Error("Provide a dashboard field to update.");let _=await t.createWorkspaceContext();await Kg(_.serverUrl,_.accessToken,_.workspaceKey,y,m,{...f.title?{title:f.title}:{},...f.icon?{icon:f.icon}:{},...f.filterKey?{filterKeys:f.filterKey}:{},...f.clearFilters?{filterKeys:[]}:{},...f.filterViewsFile?{filterViews:JSON.parse(t$(f.filterViewsFile,"utf8"))}:{},...f.clearFilterViews?{filterViews:[],defaultFilterViewKey:null}:{},...f.defaultFilterViewKey?{defaultFilterViewKey:f.defaultFilterViewKey}:{},...f.clearDefaultFilterView?{defaultFilterViewKey:null}:{}})}),ce.command("save").description("Save a dashboard document").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--input-file <input-file>","Dashboard save JSON file").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f){let _=await t.createWorkspaceContext();await K(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f.inputFile??await W("Save file"),f.minimal)}),ce.command("draft").description("Create or reopen your private draft when another audience already has direct read access").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await w(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("publish").description("Publish a draft onto its published dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await P(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("discard").description("Discard a private draft without publishing").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await g(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("shares-list").description("List shares for a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await C(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("shares-create").description("Share a dashboard with a user or user group").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<target-type>","Target type: user or user_group").argument("<target-key>","Target key").option("--mode <mode>","Share mode: read or personalise","read").action(async function(y,m,f,_,F){if(f!=="user"&&f!=="user_group")throw Error("target-type must be user or user_group");if(F.mode!=="read"&&F.mode!=="personalise")throw Error("mode must be read or personalise");let le=await t.createWorkspaceContext();await E(le.serverUrl,le.accessToken,le.workspaceKey,y,m,f,_,F.mode)}),ce.command("personalise").description("Create a personal copy of a shared dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(y,m){let f=await t.createWorkspaceContext();await D(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("reset-to-default").description("Delete your personal copy and restore the source dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Personal copy key shown in the dashboard list").action(async function(y,m){let f=await t.createWorkspaceContext();await L(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ce.command("shares-delete").description("Remove a dashboard share").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<target-type>","Target type: user or user_group").argument("<target-key>","Target key").action(async function(y,m,f,_){if(f!=="user"&&f!=="user_group")throw Error("target-type must be user or user_group");let F=await t.createWorkspaceContext();await O(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_)}),ce.command("share-targets").description("List available share targets for an app").argument("<app-key>","App key").option("--dashboard <dashboardKey>","Return users and groups with dashboard share status (max 50)").option("--target-type <targetType>","Target type: user_group or user").option("--q <q>","Search text").option("--limit <limit>","Max results (1-50 with --dashboard; otherwise 1-1000)").option("--cursor <cursor>","Opaque cursor for the next page").action(async function(y,m){if(m.dashboard&&(m.targetType||m.cursor))throw Error("--dashboard cannot be combined with --target-type or --cursor");if(!m.dashboard&&m.targetType!=="user_group"&&m.targetType!=="user")throw Error("--target-type must be user_group or user");let f=await t.createWorkspaceContext();await Xg(f.serverUrl,f.accessToken,f.workspaceKey,y,{...m.dashboard?{dashboard:m.dashboard}:{targetType:m.targetType},...m.q?{q:m.q}:{},...m.limit!==void 0?{limit:Number.parseInt(m.limit,10)}:{},...m.cursor?{cursor:m.cursor}:{}})}),ce.command("pin").description("Pin multiple visualisations to dashboard tabs").argument("<app-key>","App key").requiredOption("--input-file <path>","JSON bulk pin request").option("--remove-incompatible-filters","Remove incompatible filters on requested dashboards").option("--minimal","Return only the keys and version needed next").action(async(y,m)=>{let f=await t.createWorkspaceContext();await Fg(f.serverUrl,f.accessToken,f.workspaceKey,y,m.inputFile,Boolean(m.removeIncompatibleFilters),m.minimal)});let Ae=ce.command("tabs").description("Manage dashboard tabs");Ae.command("create").description("Create a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--title <json>",'Tab title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).action(async function(y,m,f){let _=await t.createWorkspaceContext();await v(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f.title??Me(await W("Title (JSON map)")))}),Ae.command("update").description("Update a dashboard tab title").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--title <json>","Tab title changes as a JSON map of locale tag to text; null removes a locale",dt).action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await Lg(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_.title??dt(await W("Title (JSON map)")))}),Ae.command("order").description("Update dashboard tab order").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--ordered-tab-keys <ordered-tab-keys>","Comma-separated tab keys in display order").action(async function(y,m,f){let _=await t.createWorkspaceContext(),F=(f.orderedTabKeys??await W("Ordered tab keys")).split(",").map((le)=>le.trim()).filter(Boolean);await Pg(_.serverUrl,_.accessToken,_.workspaceKey,y,m,F)}),Ae.command("delete").description("Delete a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").action(async function(y,m,f){let _=await t.createWorkspaceContext();await G(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f)}),Ae.command("pin").description("Pin a visualisation to a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<visualisation-key>","Visualisation key").option("--remove-incompatible-filters","Remove configured filters made unavailable by the pin").action(async function(y,m,f,_,F){let le=await t.createWorkspaceContext();await Ig(le.serverUrl,le.accessToken,le.workspaceKey,y,m,f,_,Boolean(F.removeIncompatibleFilters))}),Ae.command("create-visualisation").description("Create a visualisation and pin it to a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--title <json>",'Visualisation title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--type <type>","Visualisation type","table").option("--model-key <model-key>","Model key").option("--sql-file <sql-file>","SQL file").option("--config-file <config-file>","Visualisation config JSON file").option("--reasoning-text <reasoning-text>","Reasoning text").option("--remove-incompatible-filters","Remove all dashboard filters when the visualisation uses another model").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await U(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,{title:_.title??Me(await W("Title (JSON map)")),type:_.type,modelKey:_.modelKey??await W("Model key"),sqlFile:_.sqlFile??await W("SQL file"),..._.configFile?{configFile:_.configFile}:{},..._.reasoningText?{reasoningText:_.reasoningText}:{},..._.removeIncompatibleFilters?{removeIncompatibleFilters:!0}:{}})}),Ae.command("create-note").description("Create a note on a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--content-file <content-file>","Note content JSON file: a map of locale tag to a Quill Delta document").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await A(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_.contentFile??await W("Content file"),_.agentContextFile,_.minimal)}),Ae.command("read-note").description("Read a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await zg(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_)}),Ae.command("update-note").description("Update a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").option("--content-file <content-file>","Note content changes: a map of locale tag to a Quill Delta document; null removes a locale").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f,_,F){let le=await t.createWorkspaceContext();await qg(le.serverUrl,le.accessToken,le.workspaceKey,y,m,f,_,F.contentFile??await W("Content file"),F.agentContextFile,F.minimal)}),Ae.command("delete-note").description("Delete a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await B(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_)}),Ae.command("layout").description("Update a dashboard tab layout").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--input-file <input-file>","Layout JSON file").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f,_){let F=await t.createWorkspaceContext();await ye(F.serverUrl,F.accessToken,F.workspaceKey,y,m,f,_.inputFile??await W("Layout file"),_.minimal)}),Ae.command("delete-placement").description("Remove a visualisation from a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<dashboard-visualisation-id>","Dashboard visualisation ID").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f,_,F){let le=await t.createWorkspaceContext();await Fe(le.serverUrl,le.accessToken,le.workspaceKey,y,m,f,_,F.minimal)});let ir=e.command("visualisations").description("Manage visualisations");ir.command("create").description("Create a visualisation for an app").argument("<app-key>","App key").option("--title <json>",'Visualisation title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--type <type>","Visualisation type","table").option("--model-key <model-key>","Model key").option("--sql-file <sql-file>","SQL file").option("--query-key <query-key>","Stored model query key").option("--config-file <config-file>","Visualisation config JSON file").option("--reasoning-text <reasoning-text>","Reasoning text").option("--filters-config-file <filters-config-file>","Filters config JSON file").option("--freshness-file <freshness-file>","Freshness JSON file").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(y,m){let f=await t.createWorkspaceContext();await ey(f.serverUrl,f.accessToken,f.workspaceKey,y,{...m.agentContextFile?{agentContextFile:m.agentContextFile}:{},title:m.title??Me(await W("Title (JSON map)")),type:m.type,modelKey:m.modelKey??await W("Model key"),...m.sqlFile?{sqlFile:m.sqlFile}:{},...m.queryKey?{queryKey:m.queryKey}:{},...m.configFile?{configFile:m.configFile}:{},...m.reasoningText?{reasoningText:m.reasoningText}:{},...m.freshnessFile?{freshnessFile:m.freshnessFile}:{},...m.filtersConfigFile?{filtersConfigFile:m.filtersConfigFile}:{},minimal:m.minimal})}),ir.command("read").description("Read a saved visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").action(async function(y,m){let f=await t.createWorkspaceContext();await ty(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),ir.command("query").description("Query a saved visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--filters <filters>","Filters JSON array").option("--force-refresh","Skip the query execution store and run the warehouse query").option("--name <name>","Run this HTML tile secondary query instead").option("--param <column=value>","Secondary query param; repeat for each column",(y,m=[])=>[...m,y]).action(async function(y,m,f){let _=await t.createWorkspaceContext();await ea(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f)}),ir.command("render").description("Render a saved visualisation: its result shaped for drawing, without raw rows").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--filters <filters>","Filters JSON array").option("--force-refresh","Skip the query execution store and run the warehouse query").action(async function(y,m,f){let _=await t.createWorkspaceContext();await ea(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f,"render")}),ir.command("update").description("Update a visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--title <json>","Visualisation title changes as a JSON map of locale tag to text; null removes a locale",dt).option("--config-file <config-file>","Visualisation config JSON file").option("--sql-file <sql-file>","SQL file").option("--query-key <query-key>","Stored model query key").option("--reasoning-text <reasoning-text>","Reasoning text").option("--filters-config-file <filters-config-file>","Filters config JSON file").option("--freshness-file <freshness-file>","Freshness JSON file").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(y,m,f){let _=await t.createWorkspaceContext();await ry(_.serverUrl,_.accessToken,_.workspaceKey,y,m,{...f.agentContextFile?{agentContextFile:f.agentContextFile}:{},...f.title?{title:f.title}:{},...f.configFile?{configFile:f.configFile}:{},...f.sqlFile?{sqlFile:f.sqlFile}:{},...f.queryKey?{queryKey:f.queryKey}:{},...f.reasoningText?{reasoningText:f.reasoningText}:{},...f.filtersConfigFile?{filtersConfigFile:f.filtersConfigFile}:{},...f.freshnessFile?{freshnessFile:f.freshnessFile}:{},minimal:f.minimal})});let ar=e.command("llm-providers").description("Manage workspace LLM providers");ar.command("create").description("Create a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").option("--api-key <api-key>","LLM provider API key").option("--display-name <display-name>","Display name for this credential").action(async function(y){let m=await t.createWorkspaceContext();await ny(m.serverUrl,m.accessToken,m.workspaceKey,{providerKey:y.provider??await W("Provider (e.g. openai)"),apiKey:y.apiKey??await W("API key"),displayName:y.displayName??await W("Display name")})}),ar.command("update").description("Update a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").option("--api-key <api-key>","New LLM provider API key").action(async function(y){if(!y.apiKey)throw Error("Provide --api-key.");let m=await t.createWorkspaceContext();await sy(m.serverUrl,m.accessToken,m.workspaceKey,{providerKey:y.provider??await W("Provider (e.g. openai)"),apiKey:y.apiKey})}),ar.command("get").description("Get a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").action(async function(y){let m=await t.createWorkspaceContext();await oy(m.serverUrl,m.accessToken,m.workspaceKey,y.provider??await W("Provider (e.g. openai)"))}),ar.command("list").description("List workspace LLM providers").action(async function(){let y=await t.createWorkspaceContext();await iy(y.serverUrl,y.accessToken,y.workspaceKey)}),ar.command("delete").description("Delete a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").action(async function(y){let m=await t.createWorkspaceContext();await ay(m.serverUrl,m.accessToken,m.workspaceKey,y.provider??await W("Provider (e.g. openai)"))});let ra=e.command("user-groups").description("Manage app user groups");ra.command("list").description("List user groups in an app").argument("<app-key>","App key").action(async function(y){let m=await t.createWorkspaceContext();await Bg(m.serverUrl,m.accessToken,m.workspaceKey,y)});let bs=ra.command("members").description("Manage members of a user group");bs.command("list").description("List members of a user group").argument("<app-key>","App key").argument("<group-key>","User group key").action(async function(y,m){let f=await t.createWorkspaceContext();await Hg(f.serverUrl,f.accessToken,f.workspaceKey,y,m)}),bs.command("add").description("Add a user to a user group").argument("<app-key>","App key").argument("<group-key>","User group key").argument("<user-id>","User id").action(async function(y,m,f){let _=await t.createWorkspaceContext();await Yg(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f)}),bs.command("remove").description("Remove a user from a user group").argument("<app-key>","App key").argument("<group-key>","User group key").argument("<user-id>","User id").action(async function(y,m,f){let _=await t.createWorkspaceContext();await Qg(_.serverUrl,_.accessToken,_.workspaceKey,y,m,f)})}function Eg(e,t,r=process.env[t]){let n=e?.trim()||r?.trim();if(!n)throw Error(`Missing server URL. Provide --server-url or set ${t}.`);try{return{serverUrl:new URL(n).toString().replace(/\/$/,"")}}catch{throw Error(`Invalid server URL: ${n}`)}}var gs="S_CLI_SERVER_URL";function Ng(e,t=process.env[gs],r){return Eg(e,gs,t?.trim()||r)}function Dg(e={}){let t=e.createStore??(()=>new Gr),r=null,n=new sp;n.name("s").version(e.version??"0.1.3").option("--server-url <url>","Target server URL").option("--non-interactive","Fail instead of prompting when required input is missing").option("--json-errors","Print failures as stable JSON on stderr").option("--locale <tag>","Add each localized text's version for this locale, such as ar-SA, next to it in dashboard, visualisation, and arrangement output",(c)=>{let l=St(c);if(!l)throw new gn("Use a locale tag such as en-US or ar-SA.");return l}),n.configureOutput({outputError:(c,l)=>l(process.argv.includes("--json-errors")?`${ks(c.trim())}
230
- `:c)}),n.hook("preAction",(c,l)=>{if(l.parent===n&&l.name()==="logout")return;let p=l.optsWithGlobals();ff({nonInteractive:Boolean(p.nonInteractive)}),rf(p.locale);let u=process.env[gs];r=Ng(p.serverUrl,u,p.serverUrl?.trim()||u?.trim()?void 0:t().load()?.serverUrl).serverUrl});function s(){if(!r)throw Error("Resolved server URL is unavailable.");return r}async function o(){return la(s(),{store:t(),loadAuthConfig:wn,createApiClient:V})}async function i(){let c=await o();if(!c.workspaceKey)throw Error("No workspace selected. Run `s workspaces select <workspace-key>`.");return c}let a={getResolvedServerUrl:s,createAuthenticatedContext:o,createWorkspaceContext:i,createStore:t};return th(n,a,e,e.registerSignupCommands),$g(n,a,e),gp(n,a,e),af(n,a,e),qf(n,a,e),pf(n,a,e),lf(n,a,e),n}var r$=Dg();try{await r$.parseAsync(process.argv)}catch(e){ia(e,{json:process.argv.includes("--json-errors")}),process.exitCode=1}
224
+ `).action(async function(C){if(C.length===0)this.help();let v=this.opts(),A=await t.createWorkspaceContext();if(C[0]==="list"){await c(A.serverUrl,A.accessToken,A.workspaceKey);return}if(C[0]==="new"){await l(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),modelKey:_e(C[1],"model-key"),displayName:_e(v.displayName,"display-name"),label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?sr(v.modelSqlInstructionsFile,"utf8"):void 0});return}if(C[0]==="new-with-version"){await u(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),displayName:_e(v.displayName,"display-name"),modelKey:C[1]&&!C[1].startsWith("--")?C[1]:void 0,label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?sr(v.modelSqlInstructionsFile,"utf8"):void 0,modelFile:_e(v.modelFile,"model-file")});return}if(C[0]==="validate-definition"){await N(A.serverUrl,A.accessToken,A.workspaceKey,{connectionKey:_e(v.connectionKey,"connection-key"),modelFile:_e(v.modelFile,"model-file")});return}let[U,G,B,Le]=C;if(!U)throw Error("`<model-key>` is required.");if(G==="shares"&&(B==="list"||B==="create"||B==="delete")){if(B!=="list"&&Le!=="user"&&Le!=="user_group")throw Error("Share target type must be `user` or `user_group`.");await y(A.serverUrl,A.accessToken,A.workspaceKey,{appKey:_e(v.appKey,"app-key"),modelKey:U,action:B,...B==="list"?{}:{target:{type:Le,key:_e(C[4],"target-key")}},mode:v.mode});return}if(G==="get"){await d(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U});return}if(G==="delete"){await g(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,cascade:v.cascade});return}if(G==="query-json"){let ye=B&&!B.startsWith("--")?B:void 0;await p(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,...ye?{queryKey:ye}:{sql:BT(v)},...v.limit!==void 0?{limit:HT(v.limit,"limit",1000)}:{}});return}if(G==="update"){let ye=v.expectedCurrentVersion?Number.parseInt(v.expectedCurrentVersion,10):void 0;if(v.modelFile&&(!ye||ye<1))throw Error("`--expected-current-version` must be a positive integer when `--model-file` is provided.");await b(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,displayName:_e(v.displayName,"display-name"),label:v.label,modelSqlInstructions:v.modelSqlInstructionsFile?sr(v.modelSqlInstructionsFile,"utf8"):void 0,modelFile:v.modelFile,expectedCurrentVersion:ye});return}if(G==="versions"&&B==="current"&&Le==="get"){await w(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,outputFile:_e(v.outputFile,"output-file"),force:v.force});return}if(G==="versions"&&B==="new"){await T(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,modelFile:_e(v.modelFile,"model-file")});return}if(G==="versions"&&B==="current"&&Le==="refresh-samples"){let ye=v.sampleSize===void 0?void 0:Number.parseInt(v.sampleSize,10);if(ye!==void 0&&Number.isNaN(ye))throw Error("`--sample-size` must be a number.");await D(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,sampleSize:ye});return}if(G==="versions"&&B==="current"&&Le==="validate"){await x(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U});return}if(G==="search-dimension-artifact"){await P(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,outputFile:v.outputFile,force:v.force});return}if(G==="search-dimensions"){if(!v.term?.length)throw Error("`--term` is required.");await L(A.serverUrl,A.accessToken,A.workspaceKey,{modelKey:U,searchTerms:v.term});return}if(G==="result-artifacts"&&B==="create"){if(Boolean(v.sqlFile)===Boolean(v.queryId))throw Error("Provide either --sql-file or --query-id.");await K(A.serverUrl,A.accessToken,A.workspaceKey,{model:U,sqlFile:v.sqlFile,queryId:v.queryId,filters:v.filters,columnFilters:v.columnFilters,format:v.format??"csv"});return}throw Error(`Unknown models command '${C.join(" ")}'.`)})}function BT(e){if(Boolean(e.sql)===Boolean(e.sqlFile))throw Error("Provide either --sql or --sql-file.");return e.sql??sr(e.sqlFile,"utf8")}function HT(e,t,r){let n=Number.parseInt(e,10);if(!/^\d+$/.test(e)||!Number.isInteger(n)||n<1||r!==void 0&&n>r)throw Error(`--${t} must be an integer between 1 and ${r??"the supported maximum"}.`);return n}function _e(e,t){if(!e)throw Error(`Missing required command argument '${t}'.`);return e}function YT(e){return e.addArgument(new So("<type>","Connection type").choices(["snowflake"])).requiredOption("--connection-key <connection-key>","Stable connection key").requiredOption("--display-name <display-name>","Connection display name").requiredOption("--account <account>","Snowflake account identifier").requiredOption("--username <username>","Snowflake service username").requiredOption("--warehouse <warehouse>","Snowflake warehouse").option("--database <database>","Snowflake database scope for introspection and queries").option("--schema <schema>","Snowflake schema scope for introspection within the selected database set").option("--role <role>","Snowflake role").option("--host <host>","Snowflake host override").requiredOption("--auth-mode <auth-mode>","Snowflake auth mode: private_key or programmatic_access_token").option("--private-key-file <private-key-file>","Path to the Snowflake private key PEM file").option("--private-key-passphrase-file <file>","Read the Snowflake private key passphrase from a file").option("--programmatic-access-token-file <file>","Read the Snowflake programmatic access token from a file").option("--artifact-storage-stage-path <stage-path>","Snowflake stage path for result artifact storage (e.g. @my_db.my_schema.my_stage)")}function QT(e){return e.argument("<connection-key>","Stable connection key").addArgument(new So("<type>","Connection type").choices(["snowflake"])).requiredOption("--display-name <display-name>","Connection display name").requiredOption("--account <account>","Snowflake account identifier").requiredOption("--username <username>","Snowflake service username").requiredOption("--warehouse <warehouse>","Snowflake warehouse").option("--database <database>","Snowflake database scope for introspection and queries").option("--schema <schema>","Snowflake schema scope for introspection within the selected database set").option("--role <role>","Snowflake role").option("--host <host>","Snowflake host override").requiredOption("--auth-mode <auth-mode>","Snowflake auth mode: private_key or programmatic_access_token").option("--private-key-file <private-key-file>","Path to the Snowflake private key PEM file").option("--private-key-passphrase-file <file>","Read the Snowflake private key passphrase from a file").option("--programmatic-access-token-file <file>","Read the Snowflake programmatic access token from a file").option("--artifact-storage-stage-path <stage-path>","Snowflake stage path for result artifact storage (e.g. @my_db.my_schema.my_stage)")}function cf(e){let t=e.artifactStorageStagePath?{type:"snowflake_stage",stagePath:e.artifactStorageStagePath}:void 0;if(e.authMode==="private_key"){if(!e.privateKeyFile)throw Error("`--private-key-file` is required when `--auth-mode=private_key`.");let r=lf("private key passphrase",e.privateKeyPassphraseFile,"S_SNOWFLAKE_PRIVATE_KEY_PASSPHRASE");return{account:e.account,username:e.username,warehouse:e.warehouse,database:e.database,schema:e.schema,role:e.role,host:e.host,authMode:"private_key",privateKey:XT(e.privateKeyFile),privateKeyPassphrase:r,artifactStorage:t}}if(e.authMode==="programmatic_access_token"){let r=lf("programmatic access token",e.programmaticAccessTokenFile,"S_SNOWFLAKE_PROGRAMMATIC_ACCESS_TOKEN");if(!r)throw Error("A programmatic access token is required when `--auth-mode=programmatic_access_token`.");return{account:e.account,username:e.username,warehouse:e.warehouse,database:e.database,schema:e.schema,role:e.role,host:e.host,authMode:"programmatic_access_token",programmaticAccessToken:r,artifactStorage:t}}throw Error("`--auth-mode` must be either `private_key` or `programmatic_access_token`.")}function XT(e){return sr(e,"utf8").replace(/\r\n/g,`
225
+ `)}function lf(e,t,r){let n=process.env[r];if([t,n].filter((o)=>o!==void 0).length>1)throw Error(`Provide the ${e} through only one CLI option or ${r}.`);return t?sr(t,"utf8").replace(/\r?\n$/,""):n}async function pf(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.emails.test.post(r);if(o||!s)throw Error("Failed to send test email.",{cause:o});console.log(JSON.stringify(s,null,2))}function df(e,t,r={}){e.command("emails").description("Manage email delivery").command("test").description("Send a test email as an org-admin").requiredOption("--to <email>","Recipient email address").action(async(n)=>{let s=await t.createAuthenticatedContext();await(r.runEmailTest??pf)(s.serverUrl,s.accessToken,{to:n.to})})}async function mf(e,t){let r=await fetch(new URL("/external/embed-sessions",e),{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":t.apiKey,"x-s-client":"cli"},body:JSON.stringify({appKey:t.appKey,externalUserId:t.externalUserId,...t.analyticsUserKey?{analyticsUserKey:t.analyticsUserKey}:{},displayName:t.displayName,...t.email?{email:t.email}:{},roleKey:t.roleKey,currencyCode:t.currencyCode,rls:t.rls,...t.userGroupKeys?{userGroupKeys:t.userGroupKeys}:{},...t.shareUserGroupKeys!==void 0?{shareUserGroupKeys:t.shareUserGroupKeys}:{},...t.embedConfig!==void 0?{embedConfig:t.embedConfig}:{},...t.scope?{scope:t.scope}:{}})}),n=await r.json().catch(()=>null);if(!r.ok||!n)throw Error(`Failed to create embed session (${r.status}).`,{cause:n??r.statusText});console.log(JSON.stringify(n,null,2))}function ff(e,t,r={}){e.command("embed-sessions").description("Manage backend-created embed sessions").command("create").requiredOption("--api-key <key>","Workspace API key").requiredOption("--app-key <key>","App key").requiredOption("--external-user-id <id>","Stable product user ID").option("--analytics-user-key <key>","User key that row-level security looks up; defaults to the external user ID").requiredOption("--display-name <name>","Embedded user display name").option("--email <email>","Embedded user email").requiredOption("--role-key <key>","Organization role key; replaces all roles on every embed request").requiredOption("--currency-code <code>","ISO 4217 currency code").option("--rls <json>","Embed RLS as JSON","{}").option("--user-group-keys <keys>","Comma-separated user group keys").option("--share-user-group-keys <keys>","Comma-separated share-granter group keys; use an empty value to clear").option("--embed-config <json>","Profile-menu picker options and hiddenEntries as JSON; replaces the stored value; use null to clear, omit to keep").option("--scope <scope>","Saved data scope, such as business:<id>; requests then send it in x-s-scope. Defaults to default").action(async(n)=>{await(r.runEmbedSessionsCreate??mf)(t.getResolvedServerUrl(),{apiKey:n.apiKey,appKey:n.appKey,externalUserId:n.externalUserId,analyticsUserKey:n.analyticsUserKey,displayName:n.displayName,email:n.email,roleKey:n.roleKey,currencyCode:n.currencyCode,rls:JSON.parse(n.rls),userGroupKeys:n.userGroupKeys?.split(",").map((s)=>s.trim()).filter(Boolean),shareUserGroupKeys:n.shareUserGroupKeys===""?[]:n.shareUserGroupKeys?.split(",").map((s)=>s.trim()).filter(Boolean),embedConfig:n.embedConfig===void 0?void 0:JSON.parse(n.embedConfig),scope:n.scope})})}import{existsSync as d0,readFileSync as m0}from"node:fs";import{stdin as us,stdout as ls}from"node:process";import{createInterface as hf}from"node:readline/promises";import{Writable as e0}from"node:stream";var Ri=!1;async function gf(e){if(Ri||!us.isTTY||!ls.isTTY)throw Error("Password changes require an interactive terminal.");let t=new e0({write(s,o,i){i()}}),r=hf({input:us,output:t,terminal:!0}),n=new AbortController;r.once("SIGINT",()=>n.abort()),r.once("close",()=>n.abort()),ls.write(`${e}: `);try{let s=await r.question("",{signal:n.signal});if(!s)throw Error(`${e} is required.`);return s}catch(s){if(n.signal.aborted)throw Error("Password change cancelled.");throw s}finally{r.close(),t.destroy(),ls.write(`
226
+ `)}}function yf(e){Ri=e.nonInteractive}async function W(e){if(Ri||!us.isTTY)throw Error(`${e} is required. Pass it explicitly when running non-interactively.`);let t=hf({input:us,output:ls});try{let r=(await t.question(`${e}: `)).trim();if(!r)throw Error(`${e} is required.`);return r}finally{t.close()}}async function bf(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluation.cleanup.post();if(o||!s)throw Error("Failed to retry evaluation cleanups.",{cause:o});console.log(JSON.stringify(s,null,2))}async function wf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators.post(n);if(i||!o)throw Error("Failed to create evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function vf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators({evaluatorKey:n}).delete();if(i||!o)throw Error("Failed to delete evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function kf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluators({evaluatorKey:n}).get();if(i||!o)throw Error("Failed to get evaluator.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Sf(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluators.get();if(o||!s)throw Error("Failed to list evaluators.",{cause:o});console.log(JSON.stringify(s.evaluators,null,2))}async function xf(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.evaluators({evaluatorKey:n}).patch(s);if(a||!i)throw Error("Failed to update evaluator.",{cause:a});console.log(JSON.stringify(i,null,2))}import{readFileSync as Ui,writeFileSync as s0}from"node:fs";import{dirname as o0,join as i0}from"node:path";import{readFileSync as t0,readdirSync as r0}from"node:fs";import{join as n0}from"node:path";var Cf={"orchestrator-system.md":["orchestrator","system"],"orchestrator-human.md":["orchestrator","human"],"general-sql-instructions.md":["generalSqlInstructions"],"visualisation-config.md":["visualisationConfig"],"html-visualisation.md":["htmlVisualisation"],"product-information.md":["productInformation"],"context-summary.md":["contextSummary"]};function or(e){let t={};for(let r of r0(e).filter((n)=>n.endsWith(".md"))){let n=Cf[r];if(!n)throw Error(`Unknown prompt file '${r}'. Expected one of: ${Object.keys(Cf).join(", ")}.`);let s=t0(n0(e,r),"utf8");if(n.length===2)t.orchestrator={...t.orchestrator,[n[1]]:s};else t[n[0]]=s}return t}var _f=(e,t)=>({passed:e,total:t,score:t===0?0:e/t});async function Af(e,t,r,n){let s=k(e,t,r),{entries:o}=Ue(Ui(n.suite,"utf8")),i=n.promptsDir?or(n.promptsDir):void 0;for(let p of o.filter((d)=>d.file)){let d=Ue(Ui(i0(o0(n.suite),p.file),"utf8")),g=await s.evaluation.sets({evaluationSetKey:p.evaluationSet}).patch(d);if(g.error?.status===404){let b=await s.evaluation.sets.post({evaluationSetKey:p.evaluationSet,appKey:p.app});if(b.error)throw Error(`Failed to create evaluation set '${p.evaluationSet}'.`,{cause:b.error});g=await s.evaluation.sets({evaluationSetKey:p.evaluationSet}).patch(d)}if(g.error)throw Error(`Failed to upload evaluation set '${p.evaluationSet}'.`,{cause:g.error})}let a=[];for(let p of o){let{data:d,error:g}=await s.evaluation.experiments.post({evaluationSetKey:p.evaluationSet,evaluationCaseKeys:p.cases,promptOverrides:i,keepArtifacts:n.keepArtifacts??!1,repeatTimes:1,repeatOnNotAllEvaluatorsPass:0,batchSize:10});if(g||!d)throw Error(`Failed to start '${p.app}/${p.evaluationSet}'.`,{cause:g});xe(`Started ${d.experimentKey} for ${p.app}/${p.evaluationSet}.`),a.push({entry:p,experimentKey:d.experimentKey})}let c={};for(let{entry:p,experimentKey:d}of a)for(let g=0;;g+=5000){let{data:b,error:y}=await s.evaluation.experiments({experimentKey:d}).get();if(y||!b)throw Error(`Failed to read ${d}.`,{cause:y});let{status:w,summaryJson:T}=b.experiment;if(w==="completed"||w==="failed"){let N=c[p.app]??={passed:0,total:0};N.passed+=T?.results?.passed??0,N.total+=T?.results?.totalCases??0;break}if(g>3600000)throw Error(`Timed out waiting for ${d}.`);xe(`${d} still ${w}...`),await ze(5000)}let l={apps:Object.fromEntries(Object.entries(c).map(([p,d])=>[p,_f(d.passed,d.total)])),total:_f(Object.values(c).reduce((p,d)=>p+d.passed,0),Object.values(c).reduce((p,d)=>p+d.total,0))},u=(p)=>`${Math.round(p*1000)/10}%`;for(let[p,d]of Object.entries(l.apps))console.log(`${p} ${d.passed}/${d.total} ${u(d.score)}`);if(console.log(`total ${l.total.passed}/${l.total.total} ${u(l.total.score)}`),n.save)s0(n.save,`${JSON.stringify(l,null,2)}
227
+ `);if(n.baseline){let p=JSON.parse(Ui(n.baseline,"utf8")),d=Object.entries(p.apps).filter(([g,b])=>(l.apps[g]?.score??0)<b.score);if(d.length>0)throw Error(`Score dropped for ${d.map(([g,b])=>`${g} (${u(b.score)} → ${u(l.apps[g]?.score??0)})`).join(", ")}.`)}}import{mkdirSync as a0}from"node:fs";import{join as Of}from"node:path";function je(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?e:{}}function Tf(e){return Array.isArray(e)?e:[]}function Mi(e,t,r={}){let n=je(t),s=je(n.experiment),o=je(s.summaryJson),i=je(o.results),a=Of(".local","evaluation-reports");a0(a,{recursive:!0});let c=r.outputFile??Of(a,`${e}.yaml`);me(c,Ce(r.raw?t:{experiment:{experimentKey:s.experimentKey,status:s.status,summary:s.summaryJson?{results:{totalCases:i.totalCases,passed:i.passed,softFail:i.softFail,mediumFail:i.mediumFail,hardFail:i.hardFail}}:null},caseResults:Tf(n.caseResults).map((l)=>{let u=je(l),p=je(u.caseSnapshot),d=je(p.evaluationCase),g={evaluationCaseKey:d.evaluationCaseKey,repeatIndex:u.repeatIndex,status:u.status},b=je(p.subject);if(Object.keys(b).length)g.subject=b;else if(d.subjectId)g.subject={provided:{subjectId:d.subjectId},resolved:{subjectId:d.subjectId,mode:"subject_id",roleKey:null,currencyCode:null,rlsHash:null}};if(u.errorText)g.errorText=u.errorText;if(u.status==="completed"){let y=je(u.evaluatorResults);if(g.agent={message:u.agentMessage,sql:u.agentSql,durationMs:u.agentDurationMs,result:u.agentSqlResult},g.groundTruth={sql:u.groundTruthSql,result:u.groundTruthResult},y.diagnostics)g.extraction=y.diagnostics;g.evaluators=Tf(y.results).map((w)=>{let T=je(w);return{evaluatorKey:T.evaluatorKey,status:typeof T.status==="string"?T.status:"evaluated",reasoning:T.reasoning,passed:T.passed}})}return g})}),r.force),fe(c,{kind:"experiment-report",format:"yaml",raw:Boolean(r.raw)})}async function $f(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.experiments({experimentKey:n}).get();if(a||!i)throw Error("Failed to get experiment.",{cause:a});Mi(n,i,s)}async function Ef(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.experiments.post({...n,keepArtifacts:n.keepArtifacts??!1});if(i||!o)throw Error("Failed to create experiment.",{cause:i});if(n.wait){let a=Date.now(),c=2000,l=600000;xe(`Created experiment ${o.experimentKey}. Waiting for completion...`);while(Date.now()-a<=600000){let u=await s.evaluation.experiments({experimentKey:o.experimentKey}).get();if(u.error||!u.data)throw Error("Failed to get experiment while waiting.",{cause:u.error});let p=u.data.experiment.status;if(p==="completed"||p==="failed"){Mi(o.experimentKey,u.data,n);return}xe(`${o.experimentKey} still ${p}...`),await ze(2000)}throw Error(`Timed out waiting for experiment '${o.experimentKey}'.`)}console.log(JSON.stringify(o,null,2))}async function Nf(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets.post(n);if(i||!o)throw Error("Failed to create evaluation set.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Df(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets({evaluationSetKey:n}).delete();if(i||!o)throw Error("Failed to delete evaluation set.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Pf(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.sets({evaluationSetKey:n}).get();if(a||!i)throw Error("Failed to get evaluation set.",{cause:a});let c=s.outputFile??`${n}.yaml`;me(c,Ce(i),s.force),fe(c,{kind:"evaluation-set",format:"yaml"})}async function If(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n.evaluation.sets.get();if(o||!s)throw Error("Failed to list evaluation sets.",{cause:o});console.log(JSON.stringify(s.evaluationSets,null,2))}async function Ff(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.evaluation.sets({evaluationSetKey:n}).get();if(a||!i)throw Error("Failed to load evaluation set.",{cause:a});let c=new Map(i.cases.map((b)=>[b.evaluationCaseKey,b])),l=s.evaluationCaseKeys?.length?s.evaluationCaseKeys:i.cases.filter((b)=>b.type==="sql").map((b)=>b.evaluationCaseKey),u=Math.min(Math.max(s.batchSize,1),5),p=[];for(let b=0;b<l.length;b+=u){let y=l.slice(b,b+u);p.push(...await Promise.all(y.map(async(w)=>{let T=c.get(w);if(!T)return{evaluationCaseKey:w,status:"failed",errorText:`Evaluation case '${w}' is not on evaluation set '${n}'.`};let N=o.evaluation.sets({evaluationSetKey:n}).cases({evaluationCaseKey:w}),{data:x,error:D}=await N["ground-truth"].run.post({});if(D||!x){let P=D?.value;return{evaluationCaseKey:w,subject:{provided:T.subject},status:"failed",groundTruthSql:T.type==="sql"?T.groundTruthSql:void 0,errorText:typeof P==="string"?P:P instanceof Error?P.message:P?.error||P?.message||"Failed to run ground truth SQL."}}return{evaluationCaseKey:x.evaluationCaseKey,subject:x.subject,status:"completed",groundTruthSql:x.groundTruthSql??(T.type==="sql"?T.groundTruthSql:void 0),columns:x.columns,rows:x.rows}})))}let d={evaluationSetKey:n,summary:{total:p.length,completed:p.filter((b)=>b.status==="completed").length,failed:p.filter((b)=>b.status==="failed").length},results:p},g=s.outputFile??`${n}-ground-truth-results.yaml`;me(g,Ce(d),s.force),fe(g,{kind:"ground-truth-report",format:"yaml"})}async function Lf(e,t,r,n={}){let s=k(e,t,r),{data:o,error:i}=await s.evaluation.sets.template.get();if(i||!o)throw Error("Failed to get evaluation set template.",{cause:i});let a=n.outputFile??"evaluation-set-template.yaml";me(a,Ce(o),n.force),fe(a,{kind:"evaluation-set-template",format:"yaml"})}import{readFileSync as c0}from"node:fs";async function zf(e,t,r,n,s,o={}){let i=k(e,t,r),{data:a,error:c}=await i.evaluation.sets({evaluationSetKey:n}).patch(Ue(c0(s,"utf8")),{query:o.refreshConversationSources?{refreshConversationSources:!0}:{}});if(c||!a)throw Error(`Failed to update evaluation set: ${JSON.stringify(c)}`,{cause:c});console.log(JSON.stringify(a,null,2))}function l0(e){if(e.headline)xe(e.headline);for(let t of e.levels??[]){let r=Math.round(t.attempts.successRate*100),n=Math.round(t.latency.p95Ms/1000);xe(` c=${t.concurrency} slo=${t.slo.status} success=${r}% p95=${n}s`);for(let s of t.cases??[]){let o=Math.round(s.attempts.successRate*100),i=Math.round(s.latency.p95Ms/1000);xe(` ${s.evaluationCaseKey} success=${o}% p95=${i}s`)}}}function ji(e,t,r={}){let n=typeof t==="object"&&t!==null&&!Array.isArray(t)?t:{},s=n.summaryJson??null,o=r.outputFile??`${e}.yaml`;if(me(o,Ce(r.raw?t:{stressRun:{stressRunKey:n.stressRunKey,status:n.status,slo:n.sloJson,ramp:{levels:n.levelsJson},summary:s,errorText:n.errorText??null}}),r.force),s&&typeof s==="object"&&s!==null)l0(s);fe(o,{kind:"stress-run-report",format:"yaml",raw:Boolean(r.raw)})}async function qf(e,t,r,n,s,o={}){let a=k(e,t,r).evaluation.sets({evaluationSetKey:n}),{data:c,error:l}=await a["stress-runs"]({stressRunKey:s}).get();if(l||!c)throw Error("Failed to get stress run.",{cause:l});ji(s,c,o)}async function Kf(e,t,r,n){let o=k(e,t,r).evaluation.sets({evaluationSetKey:n.evaluationSetKey}),{data:i,error:a}=await o["stress-runs"].post({evaluationCaseKeys:n.evaluationCaseKeys,levels:n.levels,successThreshold:n.successThreshold,p95BudgetMs:n.p95BudgetMs,runTimeoutMs:n.runTimeoutMs,verbose:n.verbose});if(a||!i)throw Error("Failed to create stress run.",{cause:a});if(n.wait){let c=Date.now(),l=2000,u=1800000;xe(`Created stress run ${i.stressRunKey}. Waiting for completion...`);while(Date.now()-c<=1800000){let p=await o["stress-runs"]({stressRunKey:i.stressRunKey}).get();if(p.error||!p.data)throw Error("Failed to get stress run while waiting.",{cause:p.error});let d=p.data.status;if(d==="completed"||d==="failed"){ji(i.stressRunKey,p.data,n);return}xe(`${i.stressRunKey} still ${d}...`),await ze(2000)}throw Error(`Timed out waiting for stress run '${i.stressRunKey}'.`)}console.log(JSON.stringify(i,null,2))}var u0=H(["openai","openrouter","anthropic"]),p0=H(["none","minimal","low","medium","high","xhigh","max"]),ps=j({providerKey:u0,model:R().trim().nonempty("Model is required"),effort:p0.optional()});function Uf(e,t,r={}){let n=r.runEvaluatorsCreate??wf,s=r.runEvaluatorsDelete??vf,o=r.runEvaluatorsGet??kf,i=r.runEvaluatorsList??Sf,a=r.runEvaluatorsUpdate??xf,c=r.runExperimentsCreate??Ef,l=r.runExperimentsGet??$f,u=r.runExperimentsBenchmark??Af,p=r.runEvaluationCleanup??bf,d=r.runStressCreate??Kf,g=r.runStressGet??qf,b=r.runSetsCreate??Nf,y=r.runSetsDelete??Df,w=r.runSetsGet??Pf,T=r.runSetsList??If,N=r.runSetsRunGroundTruth??Ff,x=r.runSetsTemplateGet??Lf,D=r.runSetsUpdate??zf,P=e.command("evaluators").description("Manage evaluators");P.command("create").description("Create an evaluator").option("--key <key>","Stable evaluator key").option("--display-name <display-name>","Evaluator display name").option("--description <description>","Evaluator description").option("--llm <json>","Evaluator provider, model, and optional effort as JSON").option("--model <model>","Legacy OpenAI evaluator model").option("--prompt <prompt-file>","Evaluator prompt file").action(async function(O){let C=await t.createWorkspaceContext();await n(C.serverUrl,C.accessToken,C.workspaceKey,{evaluatorKey:O.key??await W("Evaluator key"),displayName:O.displayName??await W("Display name"),description:O.description,model:O.model??(O.llm?void 0:await W("Model")),llm:O.llm?ps.parse(JSON.parse(O.llm)):void 0,prompt:Rf(O.prompt??await W("Prompt file"))})}),P.command("get").description("Get an evaluator").argument("<evaluator-key>","Evaluator key").action(async function(O){let C=await t.createWorkspaceContext();await o(C.serverUrl,C.accessToken,C.workspaceKey,O)}),P.command("list").description("List evaluators").action(async function(){let O=await t.createWorkspaceContext();await i(O.serverUrl,O.accessToken,O.workspaceKey)}),P.command("update").description("Update an evaluator").argument("<evaluator-key>","Evaluator key").option("--display-name <display-name>","Evaluator display name").option("--description <description>","Evaluator description").option("--llm <json>","Evaluator provider, model, and optional effort as JSON").option("--model <model>","Legacy OpenAI evaluator model").option("--prompt <prompt-file>","Evaluator prompt file").action(async function(O,C){let v=await t.createWorkspaceContext();await a(v.serverUrl,v.accessToken,v.workspaceKey,O,{displayName:C.displayName,description:C.description,model:C.model,llm:C.llm?ps.parse(JSON.parse(C.llm)):void 0,prompt:C.prompt?Rf(C.prompt):void 0})}),P.command("delete").description("Delete an evaluator").argument("<evaluator-key>","Evaluator key").action(async function(O){let C=await t.createWorkspaceContext();await s(C.serverUrl,C.accessToken,C.workspaceKey,O)});let L=e.command("sets").description("Manage evaluation sets");L.command("create").description("Create an evaluation set").option("--key <key>","Stable evaluation set key").option("--app <app-key>","App key").action(async function(O){let C=await t.createWorkspaceContext();await b(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.key??await W("Evaluation set key"),appKey:O.app??await W("App key")})}),L.command("get").description("Get an evaluation set document").argument("<evaluation-set-key>","Evaluation set key").option("--output-file <file>","Write the set document to this file").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext();await w(v.serverUrl,v.accessToken,v.workspaceKey,O,C)}),L.command("list").description("List evaluation sets").action(async function(){let O=await t.createWorkspaceContext();await T(O.serverUrl,O.accessToken,O.workspaceKey)}),L.command("template").description("Manage evaluation set templates").command("get").description("Get the evaluation set template").option("--output-file <file>","Write the template to this file").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext();await x(C.serverUrl,C.accessToken,C.workspaceKey,O)}),L.command("update").description("Update an evaluation set document").argument("<evaluation-set-key>","Evaluation set key").option("--filepath <filepath>","Evaluation set YAML file").option("--refresh-conversation-sources","Reimport LangSmith conversation snapshots").action(async function(O,C){let v=[`${O}.yaml`,`${O}.yml`].find((U)=>d0(U)),A=await t.createWorkspaceContext();await D(A.serverUrl,A.accessToken,A.workspaceKey,O,C.filepath??v??await W("Evaluation set YAML file"),{refreshConversationSources:C.refreshConversationSources})}),L.command("run-ground-truth").description("Run ground truth SQL cases").argument("<evaluation-set-key>","Evaluation set key").argument("[evaluation-case-key]","Evaluation case key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--batch-size <batch-size>","Local ground truth runner concurrency, capped at 5",Number).option("--output-file <file>","Write the report to this file").option("--force","Replace an existing output file").action(async function(O,C,v){let A=await t.createWorkspaceContext();await N(A.serverUrl,A.accessToken,A.workspaceKey,O,{evaluationCaseKeys:v.caseKeys?v.caseKeys.split(",").map((U)=>U.trim()).filter(Boolean):C?[C]:void 0,batchSize:v.batchSize??5,outputFile:v.outputFile,force:v.force})}),L.command("delete").description("Delete an evaluation set").argument("<evaluation-set-key>","Evaluation set key").action(async function(O){let C=await t.createWorkspaceContext();await y(C.serverUrl,C.accessToken,C.workspaceKey,O)});let K=e.command("experiments").alias("experiment").description("Manage experiments");K.command("get").description("Get an experiment").argument("<experiment-key>","Experiment key").option("--output-file <file>","Write the report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext();await l(v.serverUrl,v.accessToken,v.workspaceKey,O,C)}),K.command("create").description("Create an experiment").option("--llm-override <json>","Override the experiment agent provider, model, and effort").option("--model-sql-instructions-override <model-key=file>","Replace model SQL instructions for this experiment (repeatable)",(O,C)=>[...C,O],[]).option("--prompts-dir <dir>","Run with the prompt files in this folder instead of the app's saved prompts").option("--keep-artifacts","Keep what each case's chat creates instead of deleting it after scoring").option("--set-key <set-key>","Evaluation set key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--repeat-times <repeat-times>","Repeat each case N times",Number).option("--repeat-on-not-all-evaluators-pass <count>","Adaptive extra repeats when not all evaluators pass",Number).option("--batch-size <batch-size>","Case runner batch size",Number).option("--wait","Wait for the experiment to finish and write the report").option("--output-file <file>","Write the completed report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext(),v={};for(let A of O.modelSqlInstructionsOverride??[]){let U=A.indexOf("="),G=A.slice(0,U).trim(),B=A.slice(U+1);if(U<=0||!G||!B.trim())throw Error("Expected --model-sql-instructions-override model-key=file");if(Object.hasOwn(v,G))throw Error(`Duplicate model SQL instructions override for '${G}'.`);Object.defineProperty(v,G,{value:{modelSqlInstructions:await Bun.file(B).text()},enumerable:!0})}await c(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.setKey??await W("Evaluation set key"),modelOverrides:v,promptOverrides:O.promptsDir?or(O.promptsDir):void 0,keepArtifacts:O.keepArtifacts??!1,llmOverride:O.llmOverride?ps.parse(JSON.parse(O.llmOverride)):void 0,evaluationCaseKeys:O.caseKeys?.split(",").map((A)=>A.trim()).filter(Boolean),repeatTimes:O.repeatTimes??1,repeatOnNotAllEvaluatorsPass:O.repeatOnNotAllEvaluatorsPass??0,batchSize:O.batchSize??10,wait:O.wait??!1,outputFile:O.outputFile,raw:O.raw,force:O.force})}),K.command("benchmark").description("Run every app's evaluation sets with the same prompts and score each app").requiredOption("--suite <file>","Benchmark YAML listing app, evaluationSet, and optional file and cases").option("--prompts-dir <dir>","Run with the prompt files in this folder instead of each app's saved prompts").option("--baseline <file>","Fail when any app scores lower than in this saved result").option("--save <file>","Save this result as the next baseline").option("--keep-artifacts","Keep what each case's chat creates instead of deleting it after scoring").action(async function(O){let C=await t.createWorkspaceContext();await u(C.serverUrl,C.accessToken,C.workspaceKey,O)}),e.command("evaluation").description("Manage evaluation runs").command("cleanup").description("Retry permission and chat deletions that evaluation cleanups could not finish").action(async function(){let O=await t.createWorkspaceContext();await p(O.serverUrl,O.accessToken,O.workspaceKey)});let E=e.command("stress").description("Measure agent concurrency capacity");E.command("create").description("Create a stress run").option("--set-key <set-key>","Evaluation set key").option("--case-keys <case-keys>","Comma-separated evaluation case keys").option("--levels <levels>","Comma-separated concurrency levels, for example 1,2,5,10").option("--success-threshold <success-threshold>","Minimum success rate to continue the ramp",Number).option("--p95-budget-ms <p95-budget-ms>","Maximum p95 latency in milliseconds before stopping",Number).option("--run-timeout-ms <run-timeout-ms>","Per-request timeout in milliseconds",Number).option("--wait","Wait for the stress run to finish and write the report").option("--verbose","Include per-case stats in the stress run summary").option("--output-file <file>","Write the completed report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O){let C=await t.createWorkspaceContext();await d(C.serverUrl,C.accessToken,C.workspaceKey,{evaluationSetKey:O.setKey??await W("Evaluation set key"),evaluationCaseKeys:O.caseKeys?.split(",").map((v)=>v.trim()).filter(Boolean),levels:O.levels?.split(",").map((v)=>Number.parseInt(v.trim(),10)).filter((v)=>Number.isFinite(v)&&v>0),successThreshold:O.successThreshold,p95BudgetMs:O.p95BudgetMs,runTimeoutMs:O.runTimeoutMs,verbose:O.verbose??!1,wait:O.wait??!1,outputFile:O.outputFile,raw:O.raw,force:O.force})}),E.command("get").description("Get a stress run").argument("<stress-run-key>","Stress run key").option("--set-key <set-key>","Evaluation set key").option("--output-file <file>","Write the report to this file").option("--raw","Write the lossless API response").option("--force","Replace an existing output file").action(async function(O,C){let v=await t.createWorkspaceContext(),A=C.setKey??await W("Evaluation set key");await g(v.serverUrl,v.accessToken,v.workspaceKey,A,O,C)})}function Rf(e){return m0(e,"utf8").replace(/\r\n/g,`
228
+ `)}import{chmodSync as Zf,existsSync as Ji,mkdirSync as y0,readFileSync as b0,renameSync as w0,rmSync as v0,writeFileSync as k0}from"node:fs";import{dirname as S0,join as Vf}from"node:path";import se from"node:path";import jf from"node:os";import Vi from"node:process";var mz=Object.freeze([""," ",".",".."," .",". "," ..",".. ","../","../foo","foo/../bar","foo/bar","foo\\bar","foo\x00bar"]);function Mf(e){if(typeof e!=="string")return!1;let t=e.trim();return t!==""&&t!=="."&&t!==".."&&!e.includes("/")&&!e.includes("\\")&&!e.includes("\x00")}function Zi(e){if(typeof e!=="string")throw TypeError("Expected a string");if(!Mf(e))throw Error(`Unsafe filename: ${JSON.stringify(e)}`)}var mt=jf.homedir(),Wi=jf.tmpdir(),{env:ir}=Vi,f0=(e)=>{let t=se.join(mt,"Library");return{data:se.join(t,"Application Support",e),config:se.join(t,"Preferences",e),cache:se.join(t,"Caches",e),log:se.join(t,"Logs",e),temp:se.join(Wi,e)}},h0=(e)=>{let t=ir.APPDATA||se.join(mt,"AppData","Roaming"),r=ir.LOCALAPPDATA||se.join(mt,"AppData","Local");return{data:se.join(r,e,"Data"),config:se.join(t,e,"Config"),cache:se.join(r,e,"Cache"),log:se.join(r,e,"Log"),temp:se.join(Wi,e)}},g0=(e)=>{let t=se.basename(mt);return{data:se.join(ir.XDG_DATA_HOME||se.join(mt,".local","share"),e),config:se.join(ir.XDG_CONFIG_HOME||se.join(mt,".config"),e),cache:se.join(ir.XDG_CACHE_HOME||se.join(mt,".cache"),e),log:se.join(ir.XDG_STATE_HOME||se.join(mt,".local","state"),e),temp:se.join(Wi,t,e)}};function Gi(e,{suffix:t="nodejs"}={}){if(Zi(e),t)e+=`-${t}`;if(Zi(e),Vi.platform==="darwin")return f0(e);if(Vi.platform==="win32")return h0(e);return g0(e)}function Wf(e,t){let r=Gi(e,{suffix:""}).data;if(!t)return Vf(r,"session.json");if(!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(t))throw Error(`Invalid profile "${t}". Use up to 64 letters, digits, "-" or "_".`);return Vf(r,"profiles",`${t}.json`)}class Bi{filePath;constructor(e){this.filePath=e}load(){if(!Ji(this.filePath))return null;return JSON.parse(b0(this.filePath,"utf8"))}save(e){let t=S0(this.filePath),r=!Ji(t);if(y0(t,{recursive:!0,mode:448}),r)Zf(t,448);let n=`${this.filePath}.${process.pid}.tmp`;k0(n,JSON.stringify(e,null,2),{mode:384}),Zf(n,384),w0(n,this.filePath)}clear(){if(!Ji(this.filePath))return;v0(this.filePath)}}function Hi(e){return Wf("server-end-user-cli",e)}class Gr extends Bi{constructor(e=Hi()){super(e)}}function x0(e){return JSON.stringify(e).includes("authorization_pending")}function C0(e){let t=Math.max(1,Math.round((new Date(e).getTime()-Date.now())/60000));return t===1?"1 minute":`${t} minutes`}async function Gf(e,t={}){let r=t.log??console.log,n=t.store??new Gr,s=V(e),{data:o,error:i}=await s.auth.login.start.post();if(i||!o)throw Error("Failed to start login.",{cause:i});let a=C0(o.expiresAt);r(`Verification URL: ${o.verificationUrl}`),r("Please use this verification URL to log in to your account."),r(`If you do not log in within ${a}, this login session will be terminated.`);let c=new Date(o.expiresAt).getTime(),l=3;while(!0){if(Date.now()>=c)throw Error(`Login timed out. You did not log in within ${a}, so this login session was terminated. Run \`s login\` again.`);let{data:u,error:p}=await s.auth.login.complete.post({deviceCode:o.deviceCode});if(u){let d=await wn(e);n.save({serverUrl:e,issuerUrl:d.issuerUrl,tokenType:"Bearer",accessToken:u.accessToken,accessTokenExpiresAt:new Date(Date.now()+u.expiresIn*1000).toISOString(),refreshToken:u.refreshToken,refreshTokenExpiresAt:null,workspaceId:u.workspace.workspaceId,workspaceKey:u.workspace.workspaceKey}),r("Login complete."),r(JSON.stringify({workspace:u.workspace},null,2));return}if(p&&x0(p)){await ze(l*1000);continue}if(p&&JSON.stringify(p).includes("slow_down")){l+=5,await ze(l*1000);continue}throw Error("Failed to complete login.",{cause:p})}}async function Jf(e,t,r=gf){let n=await r("Current password"),s=await r("New password"),o=await r("Confirm new password");if(s!==o)throw Error("New passwords do not match.");let i=V(e,{getAccessToken:()=>t}),{data:a,error:c}=await i.auth["change-password"].post({currentPassword:n,newPassword:s});if(c||!a){let l=c?.value&&typeof c.value==="object"&&"error"in c.value?String(c.value.error):"Password change failed.";throw Error(l)}console.log(JSON.stringify(a,null,2))}import{readFileSync as _0}from"node:fs";async function A0(e,t,r){let n=JSON.parse(_0(r.file,"utf8"));if(!Array.isArray(n.permissions)||n.permissions.length===0)throw Error("The file must contain a non-empty permissions array.");if(n.nextCursor!==void 0)throw Error("Use roles permissions export, not a paginated list response.");if(r.operation==="set"&&!/^[a-f0-9]{64}$/.test(n.expectedRevision??""))throw Error("The file must contain expectedRevision. Export the role permissions first.");let s=V(e,{getAccessToken:()=>t}),o=r.operation==="create"?await s.roles.post({roleKey:r.roleKey,permissions:n.permissions}):await s.roles({roleKey:r.roleKey}).permissions.put({permissions:n.permissions,expectedRevision:n.expectedRevision});if(o.error||!o.data)throw Error("Failed to save role permissions.",{cause:o.error});console.log(JSON.stringify(o.data,null,2))}async function O0(e,t,r){let n=V(e,{getAccessToken:()=>t}),s=[],o,i,a=new Set;do{let c=await n.roles({roleKey:r}).permissions.get({query:{limit:100,...o?{cursor:o}:{}}});if(c.error||!c.data)throw Error("Failed to export role permissions. Restart the export.",{cause:c.error});if(i&&i!==c.data.revision)throw Error("Role permissions changed during export. Restart the export.");if(i=c.data.revision,s.push(...c.data.permissions.map(({relation:l,resource:u})=>({relation:l,resource:{type:u.type,id:u.id}}))),o=c.data.nextCursor??void 0,o&&a.has(o))throw Error("Repeated permissions cursor.");if(o)a.add(o)}while(o);console.log(JSON.stringify({expectedRevision:i,permissions:s},null,2))}async function T0(e,t,r){let n=V(e,{getAccessToken:()=>t}),s={limit:r.limit??50,...r.cursor?{cursor:r.cursor}:{}},o=r.operation==="list"?await n.roles.get({query:s}):r.operation==="get"?await n.roles({roleKey:r.roleKey}).get():r.operation==="permissions"?await n.roles({roleKey:r.roleKey}).permissions.get({query:s}):await n.roles({roleKey:r.roleKey}).users.get({query:s});if(o.error||!o.data)throw Error("Failed to read organization roles.",{cause:o.error});console.log(JSON.stringify(o.data,null,2))}async function $0(e,t,r){let s=V(e,{getAccessToken:()=>t}).roles({roleKey:r.roleKey}).users({userId:r.userId}),o=r.assigned?await s.put():await s.delete();if(o.error)throw Error("Failed to update role assignment.",{cause:o.error});console.log(JSON.stringify({roleKey:r.roleKey,userId:r.userId,assigned:r.assigned},null,2))}function Bf(e,t,r=T0,n=A0,s=O0,o=$0){let i=e.command("roles").description("Manage organization roles"),a=i.command("permissions").description("Manage role permissions"),c=i.command("users").description("Manage role assignments");for(let l of["add","remove"])c.command(`${l} <role-key> <user-id>`).description(l==="add"?"Assign an existing role to a user":"Remove a role from a user").action(async(u,p)=>{let d=await t.createAuthenticatedContext();await o(d.serverUrl,d.accessToken,{roleKey:u,userId:p,assigned:l==="add"})});i.command("create <role-key>").description("Create a custom role with permissions").requiredOption("--permissions-file <file>","JSON permissions file").action(async(l,u)=>{let p=await t.createAuthenticatedContext();await n(p.serverUrl,p.accessToken,{operation:"create",roleKey:l,file:u.permissionsFile})}),a.command("export <role-key>").description("Export all permissions as an editable update file").action(async(l)=>{let u=await t.createAuthenticatedContext();await s(u.serverUrl,u.accessToken,l)}),a.command("set <role-key>").description("Replace all permissions using an exported JSON file").requiredOption("--file <file>","JSON permissions file with expectedRevision").action(async(l,u)=>{let p=await t.createAuthenticatedContext();await n(p.serverUrl,p.accessToken,{operation:"set",roleKey:l,file:u.file})}),i.command("get <role-key>").description("Read role metadata").action(async(l)=>{let u=await t.createAuthenticatedContext();await r(u.serverUrl,u.accessToken,{operation:"get",roleKey:l})});for(let l of["list","permissions","users"])(l==="list"?i.command("list").description("List organization roles"):(l==="permissions"?a:c).command("list <role-key>").description(`List role ${l}`)).option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(...p)=>{let d=l==="list"?void 0:p[0],g=p[l==="list"?0:1],b=g.limit===void 0?void 0:Number(g.limit);if(b!==void 0&&(!Number.isInteger(b)||b<1||b>100))throw Error("limit must be an integer between 1 and 100.");let y=await t.createAuthenticatedContext();await r(y.serverUrl,y.accessToken,{operation:l,...d?{roleKey:d}:{},...b!==void 0?{limit:b}:{},...g.cursor?{cursor:g.cursor}:{}})})}import{readFileSync as E0}from"node:fs";function ds(e,t,r){let n=V(e,{getAccessToken:()=>t});return r?n.users({userId:r})["subject-settings"]:n["subject-settings"]}async function Hf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n.get();if(o||!s)throw Error("Failed to get subject settings.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Yf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n["onboarding-tour"].put();if(o||!s)throw Error("Failed to finish the onboarding tour.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Qf(e,t,r){let n=ds(e,t,r),{data:s,error:o}=await n["onboarding-tour"].delete();if(o||!s)throw Error("Failed to reset the onboarding tour.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Xf(e,t,r,n){let s={...r.analyticsUserKey?{analyticsUserKey:r.analyticsUserKey}:{},...r.currencyCode?{currencyCode:r.currencyCode}:{},...r.timezone?{timezone:r.timezone}:{}};if(r.rulesFile)s.rulesJson=JSON.parse(E0(r.rulesFile,"utf8"));let{data:o,error:i}=await ds(e,t,n).put(s);if(i||!o)throw Error("Failed to update subject settings.",{cause:i});console.log(JSON.stringify(o,null,2))}async function eh(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.users.post(r);if(o||!s)throw Error("Failed to create user.",{cause:o});console.log(JSON.stringify(s,null,2))}async function th(e,t,r){let n=V(e,{getAccessToken:()=>t}),{data:s,error:o}=await n.users.invite.post({email:r});if(o||!s)throw Error("Failed to invite user.",{cause:o});console.log(JSON.stringify(s,null,2))}async function rh(e,t,r,n){let s=V(e,{getAccessToken:()=>t}),{data:o,error:i}=await s.users({userId:r}).roles.get({query:{...n,limit:n.limit??50}});if(i||!o)throw Error("Failed to list user roles.",{cause:i});console.log(JSON.stringify(o,null,2))}async function nh(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s.users.get({query:{...n,limit:n.limit??50}});if(i||!o)throw Error("Failed to list workspace users.",{cause:i});console.log(JSON.stringify(o,null,2))}async function sh(e,t){let r=V(e,{getAccessToken:()=>t}),{data:n,error:s}=await r.auth.me.get();if(s||!n)throw Error("Failed to load authenticated identity.",{cause:s});console.log(JSON.stringify(n.user,null,2))}function oh(e,t,r={},n){Bf(e,t,r.runRolesRead),e.command("password").description("Manage your password").command("change").description("Change your password using hidden interactive prompts").action(async()=>{let b=await t.createAuthenticatedContext();await(r.runPasswordChange??Jf)(b.serverUrl,b.accessToken)});let s=r.runLogin??Gf,o=e.command("users").description("Create, invite, and inspect users");o.command("create").description("Create a user with roles and send an invitation").requiredOption("--email <email>","User email address").requiredOption("--first-name <first-name>","First name").requiredOption("--last-name <last-name>","Last name").requiredOption("--role <role-key>","Role to assign (repeat for multiple roles)",(b,y=[])=>[...y,b]).action(async(b)=>{let y=await t.createAuthenticatedContext();await(r.runUsersCreate??eh)(y.serverUrl,y.accessToken,{email:b.email,firstName:b.firstName,lastName:b.lastName,roleKeys:b.role})}),o.command("invite <email>").description("Send or resend an account setup invitation").action(async(b)=>{let y=await t.createAuthenticatedContext();await(r.runUsersInvite??th)(y.serverUrl,y.accessToken,b)}),o.command("roles").description("Inspect user role assignments").command("list <user-id>").description("List roles assigned to a user").option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(b,y)=>{let w=y.limit===void 0?50:Number(y.limit);if(!Number.isInteger(w)||w<1||w>100)throw Error("limit must be an integer between 1 and 100.");let T=await t.createAuthenticatedContext();await(r.runUserRolesList??rh)(T.serverUrl,T.accessToken,b,{limit:w,...y.cursor?{cursor:y.cursor}:{}})}),o.command("list").description("List users who can read the selected workspace").option("--limit <limit>","Page size (1-100)").option("--cursor <cursor>","Cursor returned by the previous page").action(async(b)=>{let y=b.limit===void 0?void 0:Number(b.limit);if(y!==void 0&&(!Number.isInteger(y)||y<1||y>100))throw Error("limit must be an integer between 1 and 100.");let w=await t.createWorkspaceContext();await(r.runUsersList??nh)(w.serverUrl,w.accessToken,w.workspaceKey,{...y!==void 0?{limit:y}:{},...b.cursor?{cursor:b.cursor}:{}})});let i=r.runWhoAmI??sh,a=r.runSubjectSettingsGet??Hf,c=r.runSubjectSettingsPut??Xf,l=r.runOnboardingTourFinish??Yf,u=r.runOnboardingTourReset??Qf;if(e.command("login").description("Authenticate with the server").action(function(){return s(t.getResolvedServerUrl(),{store:t.createStore()})}),e.command("logout").description("Clear the local authenticated session").action(function(){t.createStore().clear(),console.log(JSON.stringify({loggedOut:!0},null,2))}),n)n(e,t,r);e.command("whoami").description("Show the current authenticated user").action(async function(){let b=await t.createAuthenticatedContext();await i(b.serverUrl,b.accessToken)});let p=e.command("subject-settings").description("Manage settings for the signed-in subject, or another user's with --user"),d=["--user <user-id>","Act on this user in the organization (needs subject settings permissions)"];p.command("get").description("Get subject settings").option(...d).action(async function(b){let y=await t.createAuthenticatedContext();await a(y.serverUrl,y.accessToken,b.user)});let g=p.command("onboarding-tour").description("Manage the first-time tour");g.command("finish").description("Mark the first-time tour as finished so it no longer shows for you").option(...d).action(async function(b){let y=await t.createAuthenticatedContext();await l(y.serverUrl,y.accessToken,b.user)}),g.command("reset").description("Show the first-time tour again for you the next time you open the app").option(...d).action(async function(b){let y=await t.createAuthenticatedContext();await u(y.serverUrl,y.accessToken,b.user)}),p.command("put").description("Update subject settings").option("--rules-file <rules-file>","RLS rules JSON file").option("--analytics-user-key <analytics-user-key>","Analytics user key").option("--currency-code <currency-code>","ISO 4217 currency code").option("--timezone <timezone>","IANA time zone").option(...d).action(async function(b){if(!b.rulesFile&&!b.analyticsUserKey&&!b.currencyCode&&!b.timezone)throw Error("Provide at least one of --rules-file, --analytics-user-key, --currency-code, or --timezone.");let y=await t.createAuthenticatedContext();await c(y.serverUrl,y.accessToken,{...b.rulesFile?{rulesFile:b.rulesFile}:{},...b.analyticsUserKey?{analyticsUserKey:b.analyticsUserKey}:{},...b.currencyCode?{currencyCode:b.currencyCode}:{},...b.timezone?{timezone:b.timezone}:{}},b.user)})}import{readFileSync as p$}from"node:fs";async function ih(e,t,r){let n=V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r}),{data:s,error:o}=await n["api-keys"].post();if(o||!s)throw Error("Failed to create API key.",{cause:o});console.log(JSON.stringify(s,null,2))}import{readFileSync as N0}from"node:fs";import{extname as D0}from"node:path";var ah=100;function Yi(e){if(typeof e==="string")return e.length>ah?`${e.slice(0,ah-3)}...`:e;if(Array.isArray(e))return e.map(Yi);if(e&&typeof e==="object")return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Yi(r)]));return e}function ft(e,t,r){return V(e,{getAccessToken:()=>t,getWorkspaceKey:()=>r})}function P0(e){try{let t=N0(e,"utf8");return I0(e,t)}catch(t){throw Error(`Failed to read app settings file '${e}'. ${t instanceof Error?t.message:""}`.trim(),{cause:t})}}function I0(e,t){return F0(e)==="json"?JSON.parse(t):Ue(t)}function F0(e){let t=D0(e).toLowerCase();if(t===".json")return"json";if(t===".yaml"||t===".yml")return"yaml";throw Error(`App settings files must use .json, .yaml, or .yml: '${e}'.`)}async function ch(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps.post(n);if(i||!o)throw Error("Failed to create app.",{cause:i});console.log(JSON.stringify(o,null,2))}async function lh(e,t,r){let n=ft(e,t,r),{data:s,error:o}=await n.apps.get();if(o||!s)throw Error("Failed to list apps.",{cause:o});console.log(JSON.stringify(s.apps,null,2))}async function uh(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n}).get();if(i||!o)throw Error("Failed to get app.",{cause:i});console.log(JSON.stringify(o,null,2))}async function ph(e,t,r,n,s,o={}){if(o.full&&o.include)throw Error("--full and --include cannot be combined.");let i=ft(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).agent.get({query:{modelKey:s,...o.include?{include:o.include}:{},...o.tables?{tables:o.tables}:{}}});if(c||!a)throw Error("Failed to get app agent runtime context.",{cause:c});let l=!o.full&&!o.include&&!o.tables,u={schemaVersion:Sr,kind:"app-agent-context",include:o.include??null,truncated:l,data:l?Yi(a):a},p=`${JSON.stringify(u,null,2)}
229
+ `;if(o.outputFile){me(o.outputFile,p,o.force),fe(o.outputFile,{kind:u.kind,include:u.include,truncated:l});return}process.stdout.write(p)}async function dh(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n})["frontend-config"].get();if(i||!o)throw Error("Failed to get app frontend config.",{cause:i});console.log(JSON.stringify(o,null,2))}async function mh(e,t,r,n,s){let o=ft(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).patch(s);if(a||!i)throw Error("Failed to update app.",{cause:a});console.log(JSON.stringify(i,null,2))}async function fh(e,t,r,n,s){let o=P0(s.inputFile);if(s.promptsDir){let{orchestrator:l,...u}=or(s.promptsDir),p=o.agent?.prompts??{};o.agent={...o.agent,prompts:{...p,...u,...l&&{orchestrator:{...p.orchestrator,...l}}}}}let i=ft(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).settings.put(o);if(c||!a)throw Error("Failed to update app settings.",{cause:c});console.log(JSON.stringify(a,null,2))}async function hh(e,t,r,n){let s=ft(e,t,r),{data:o,error:i}=await s.apps({appKey:n}).get();if(i||!o)throw Error("Failed to get app settings.",{cause:i});console.log(JSON.stringify(o.settings,null,2))}function Ze(e,t,r,n){return k(e,t,r).apps({appKey:n})["dashboard-arrangements"]}function ht(e,t,r){if(t||!e)throw Error(r,{cause:t});M(e)}async function gh(e,t,r,n,s){let o=Ze(e,t,r,n),i=s==="default"?await o.default.get():await o.get();ht(i.data,i.error,"Failed to get dashboard arrangement.")}async function yh(e,t,r,n){let{error:s}=await Ze(e,t,r,n).delete();if(s)throw Error("Failed to reset personal dashboard arrangement.",{cause:s});M({reset:!0})}async function bh(e,t,r,n,s,o=!0){let i=Ze(e,t,r,n).dashboards({dashboardKey:s}).hide,{error:a}=o?await i.post():await i.delete();if(a)throw Error(`Failed to ${o?"hide":"show"} dashboard.`,{cause:a});M({hidden:o})}async function wh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups.post({name:s.name});ht(a.data,a.error,"Failed to create dashboard group.")}async function vh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).patch({name:s.name});ht(a.data,a.error,"Failed to update dashboard group.")}async function kh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).position.patch({...s.beforeDashboardGroupId?{beforeDashboardGroupId:s.beforeDashboardGroupId}:{},...s.afterDashboardGroupId?{afterDashboardGroupId:s.afterDashboardGroupId}:{}});ht(a.data,a.error,"Failed to move dashboard group.")}async function Sh(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).groups({dashboardGroupId:s.dashboardGroupId}).delete();ht(a.data,a.error,"Failed to delete dashboard group.")}async function xh(e,t,r,n,s){let o=await Ze(e,t,r,n).default.dashboards.post({dashboardKey:s.dashboardKey,...s.dashboardGroupId?{dashboardGroupId:s.dashboardGroupId}:{}});ht(o.data,o.error,"Failed to add dashboard to the default arrangement.")}async function Ch(e,t,r,n,s){let o=Ze(e,t,r,n),a=await(s.scope==="default"?o.default:o).dashboards({dashboardKey:s.dashboardKey}).patch({...s.dashboardGroupId!==void 0?{dashboardGroupId:s.dashboardGroupId}:{},...s.beforeDashboardKey?{beforeDashboardKey:s.beforeDashboardKey}:{},...s.afterDashboardKey?{afterDashboardKey:s.afterDashboardKey}:{}});ht(a.data,a.error,"Failed to move dashboard.")}async function _h(e,t,r,n,s){let i=await Ze(e,t,r,n).default.dashboards({dashboardKey:s.dashboardKey}).delete();ht(i.data,i.error,"Failed to remove dashboard from arrangement.")}import{randomUUID as L0}from"node:crypto";import{createWriteStream as z0,readFileSync as q0}from"node:fs";import{rename as K0,rm as R0}from"node:fs/promises";import{Readable as U0}from"node:stream";import{pipeline as M0}from"node:stream/promises";function Qi(e,t,r){if(t||!e)throw Error(r,{cause:t});console.log(JSON.stringify(e,null,2))}async function Ah(e,t,r){let n=await fetch(e);if(!n.ok)throw Error(`Failed to download dashboard snapshot ${r}.`);if(!n.body)throw Error(`Dashboard snapshot ${r} response has no body.`);let s=`${t}.${L0()}.tmp`;try{await M0(U0.fromWeb(n.body),z0(s)),await K0(s,t)}catch(o){throw await R0(s,{force:!0}),o}console.log(t)}var Oh={async create(e,t,r,n,s,o){let a=await k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}).snapshots.post(o?JSON.parse(q0(o,"utf8")):{filters:[]});Qi(a.data,a.error,"Failed to create dashboard snapshot.")},async get(e,t){let n=await V(e)["dashboard-snapshots"]({publicId:t}).get();Qi(n.data,n.error,"Failed to get dashboard snapshot.")},async getVisualisation(e,t,r,n=!1){let o=V(e)["dashboard-snapshots"]({publicId:t}).visualisations({visualisationKey:r}),i=await(n?o.render.get():o.get());Qi(i.data,i.error,"Failed to get dashboard snapshot visualisation.")},async downloadCsv(e,t,r,n){await Ah(new URL(`/dashboard-snapshots/${t}/visualisations/${r}/csv`,e),n,"CSV")},async downloadPdf(e,t,r){await Ah(new URL(`/dashboard-snapshots/${t}/pdf`,e),r,"PDF")}};import{readFileSync as It}from"node:fs";var j0=R().trim().nonempty("Model key is required").regex(/^[a-z0-9-]+$/,"Model key must use only lowercase ASCII letters, digits, and dashes"),Lh=R().trim().nonempty("Query key is required").regex(/^[a-z0-9-]+$/,"Query key must use only lowercase ASCII letters, digits, and dashes"),xq=R().trim().nonempty("Visualisation key is required").regex(/^[a-z0-9-]+$/,"Visualisation key must use only lowercase ASCII letters, digits, and dashes"),Jr=["table","line","bar","pie","metric","pivot","scatter","html"],Z0=H(Jr),V0=be,Xi=R().trim().nonempty("Agent generated SQL is required"),zh=R().trim().nullable(),Th=ne({column:R().min(1),rowIndex:oe().int().nonnegative()});function $h(e){if(e==null)return null;if(typeof e==="string"&&e.trim()==="")return null;return e}var W0=vr("mode",[ne({mode:te("columns"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1),comparisonValueColumn:R().nullable()}),ne({mode:te("grouped"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1)})]),G0=vr("mode",[ne({mode:te("columns"),nameColumn:Te().optional(),valueColumns:Z(R()).min(1)}),ne({mode:te("grouped"),nameColumn:Te().optional(),clusterColumn:R().nullable().optional(),valueColumns:Z(R()).min(1)})]),ms=ne({position:H(["top","bottom","left","right"])}).nullable().optional(),fs=ne({column:R().refine((e)=>e.trim().length>0),order:Z(R().refine((e)=>e.trim().length>0)).min(1).nullable().optional()}).superRefine((e,t)=>{if(e.order&&new Set(e.order).size!==e.order.length)t.addIssue({code:"custom",path:["order"],message:"order must contain unique names"})}),Cq=Z(ne({name:R(),colorIndex:oe().int().nonnegative(),rowIndex:oe().int().nonnegative().optional(),other:ie().optional(),value:oe().optional()})),Eh=Z(ne({valueColumns:Z(R()).min(1),position:H(["left","right","top","bottom"]),index:oe().int().min(0).max(4)})).max(5).nullable().optional(),J0=R().trim().min(1),qh=j({version:te(1),filters:Z(j({filterKey:J0,status:H(["supported","unsupported"])}))}).superRefine((e,t)=>{let r=new Set;for(let[n,s]of e.filters.entries()){if(r.has(s.filterKey))t.addIssue({code:"custom",path:["filters",n,"filterKey"],message:`Duplicate filter key '${s.filterKey}'`});r.add(s.filterKey)}}),B0=H(["MO","TU","WE","TH","FR","SA","SU"]),H0=j({freq:H(["DAILY","WEEKLY","MONTHLY"]),byhour:oe().int().min(0).max(23),byminute:oe().int().min(0).max(59),byday:B0.optional(),bymonthday:oe().int().min(-1).max(31).optional()}).superRefine((e,t)=>{if(e.freq==="WEEKLY"&&e.byday===void 0)t.addIssue({code:"custom",path:["byday"],message:"byday is required for WEEKLY"});if(e.freq==="MONTHLY"&&e.bymonthday===void 0)t.addIssue({code:"custom",path:["bymonthday"],message:"bymonthday is required for MONTHLY"})}),Kh=vr("type",[j({type:te("always")}),j({type:te("never")}),j({type:te("schedule"),close:H0})]);var Nh=H(["muted","success","destructive"]),Dh=wr([Nh,ne({rules:Z(ne({op:H(["lt","lte","gt","gte","eq"]),value:oe(),color:Nh})).min(1)})]),Ph=ne({column:R().min(1),title:be.nullable().optional(),width:oe().int().min(72).max(640).nullable().optional(),format:H(["number","percent"]).nullable().optional(),backgroundColor:Dh.nullable().optional(),textColor:Dh.nullable().optional()}),Ih=ne({column:R().min(1),title:be.nullable().optional(),order:Z(wr([R(),oe(),ie(),hb()])).min(1).refine((e)=>new Set(e).size===e.length,"Order values must be unique").nullable().optional()}),_q=ne({rowKeys:Z(Z(mn())),columnKeys:Z(Z(mn()))}),Y0=100,Aq=H(["text","number","date","timestamp","boolean","other"]),Q0=H(["in","not_in","eq","neq","gt","gte","lt","lte","between"]);var Fh=(e)=>/^-?\d+(\.\d+)?$/.test(e),X0=(e)=>{let t=new Date(`${e}T00:00:00Z`);return/^\d{4}-\d{2}-\d{2}$/.test(e)&&!Number.isNaN(t.getTime())&&t.toISOString().startsWith(e)},e$=j({column:R().min(1),operator:Q0,values:Z(R()).min(1).max(Y0),decimals:oe().int().min(0).max(10).optional()}).refine(({operator:e,values:t,decimals:r})=>r===void 0||(e==="eq"||e==="neq")&&t.every(Fh),{message:"Only number eq and neq conditions take decimals",path:["decimals"]}).refine(({values:e,decimals:t})=>t===void 0||e.every((r)=>(r.split(".")[1]?.length??0)<=t),{message:"Values can't have more decimals than decimals",path:["values"]}).refine(({operator:e,values:t})=>e==="in"||e==="not_in"||t.length===(e==="between"?2:1)&&(t.every(Fh)||t.every(X0)),{message:"Conditions take one value, or two for between, each a decimal number or a YYYY-MM-DD date",path:["values"]}),Oq=Z(e$).refine((e)=>new Set(e.map((t)=>t.column)).size===e.length,"Each column can have only one filter"),t$=so(R().min(1),be).nullable().optional(),gt={columnLabels:t$,showChrome:ie().optional()},r$=102400,n$=5,s$=j({name:R().regex(/^[a-z][a-z0-9_]*$/,"Secondary query names use lowercase letters, digits and _"),sql:Xi,params:Z(R().trim().min(1)).max(10)}),Rh=vr("type",[ne({type:te("table"),...gt,columns:Z(Ph).nullable().optional()}),ne({type:te("line"),...gt,xColumn:R(),series:W0,legendColumn:fs.nullable().optional(),seriesOrder:Te().optional(),sort:H(["asc","desc","preserve"]),fitToScreen:ie().optional(),showLabels:ie().optional(),valueAxes:Eh,legend:ms}),ne({type:te("bar"),...gt,categoryColumn:R(),categoryAxis:H(["x","y"]),series:G0,legendColumn:fs.nullable().optional(),seriesOrder:Te().optional(),stacked:H(["standard","full"]).nullable().optional(),sortBy:H(["value","category"]),sort:H(["asc","desc","preserve"]),fitToScreen:ie().optional(),barSize:oe().min(io.min).max(io.max).nullable().optional(),showLabels:ie().optional(),valueAxes:Eh,legend:ms}),ne({type:te("pie"),...gt,legendColumn:fs,labelColumn:Te().optional(),seriesOrder:Te().optional(),valueColumn:R(),showLabels:ie().optional(),legend:ms}),ne({type:te("metric"),...gt,primaryMetricValue:Th,secondaryMetricValue:yu($h,Th.nullable()),secondaryMetricLabel:yu($h,be.nullable())}),ne({type:te("pivot"),...gt,rowOrder:H(["alphabetical","preserve"]).optional(),rows:Z(Ih),columns:Z(Ih),values:Z(Ph).min(1),stickyHeader:ie().optional(),stickyRowLabels:ie().optional()}),ne({type:te("scatter"),...gt,xColumn:R().min(1),yColumn:R().min(1),hoverColumn:R().min(1).nullable().optional(),legendColumn:fs.nullable().optional(),colorColumn:Te().optional(),seriesOrder:Te().optional(),sizeColumn:R().min(1).nullable().optional(),showLabels:ie().optional(),legend:ms}),ne({type:te("html"),...gt,template:R().min(1).refine((e)=>new TextEncoder().encode(e).length<=r$,"template must be at most 100 KB"),minHeight:oe().int().min(40).max(4000).optional(),height:H(["fixed","fit"]).optional(),secondaryQueries:Z(s$).max(n$).optional()})]).superRefine((e,t)=>{if(e.type==="html"){let r=(e.secondaryQueries??[]).map((n)=>n.name);for(let[n,s]of r.entries())if(r.indexOf(s)!==n)t.addIssue({code:"custom",path:["secondaryQueries",n,"name"],message:`Duplicate secondary query '${s}'`});return}if(e.type==="bar"||e.type==="line"){if(e.series.mode==="grouped"!==(e.legendColumn!=null))t.addIssue({code:"custom",path:["legendColumn"],message:"legendColumn is required for grouped series and forbidden for columns series"})}if(e.type==="table"){let r=new Set;for(let[n,s]of(e.columns??[]).entries()){if(r.has(s.column))t.addIssue({code:"custom",path:["columns",n,"column"],message:`Duplicate column '${s.column}'`});r.add(s.column)}return}if(e.type==="pivot"){let r=[["rows",e.rows],["columns",e.columns],["values",e.values]],n=new Map;for(let[s,o]of r){let i=new Set;for(let[a,c]of o.entries()){if(i.has(c.column))t.addIssue({code:"custom",path:[s,a,"column"],message:`Duplicate column '${c.column}'`});i.add(c.column);let l=n.get(c.column);if(l)t.addIssue({code:"custom",path:[s,a,"column"],message:`Column '${c.column}' is also in ${l}`});else n.set(c.column,s)}}return}if(e.type==="scatter"){if(e.xColumn===e.yColumn)t.addIssue({code:"custom",path:["yColumn"],message:"yColumn must differ from xColumn"});let r=new Map([[e.xColumn,"xColumn"],[e.yColumn,"yColumn"]]);for(let[n,s]of[["hoverColumn",e.hoverColumn],["legendColumn",e.legendColumn?.column],["sizeColumn",e.sizeColumn]]){if(!s)continue;let o=r.get(s);if(o)t.addIssue({code:"custom",path:[n],message:`Column '${s}' is also ${o}`});else r.set(s,n)}return}if(e.type==="bar"&&e.barSize!=null&&e.fitToScreen!==!1)t.addIssue({code:"custom",path:["barSize"],message:"barSize requires fitToScreen to be false"});if(e.type!=="bar"||e.series.mode!=="grouped"||!e.series.clusterColumn)return;if(e.stacked==null)t.addIssue({code:"custom",path:["series","clusterColumn"],message:"clusterColumn requires stacked to be standard or full"});if(e.series.valueColumns.length!==1)t.addIssue({code:"custom",path:["series","valueColumns"],message:"clusterColumn requires exactly one value column"})});function Uh(e,t){if(e.type==="table"){if(e.config!=null&&e.config.type!=="table")t.addIssue({code:"custom",path:["config"],message:"Config type must match visualisation type"});return}if(e.config==null){t.addIssue({code:"custom",path:["config"],message:"Config is required for non-table visualisations"});return}if(e.config.type!==e.type)t.addIssue({code:"custom",path:["config"],message:"Config type must match visualisation type"})}var o$=j({agentContext:De.optional(),title:V0,type:Z0,modelKey:j0,agentGeneratedSql:Xi.optional(),queryKey:Lh.optional(),reasoningText:zh.optional(),config:Rh.nullable().optional(),filtersConfig:qh.optional(),freshness:Kh.optional()});function i$(e,t){if(e.queryKey&&e.agentGeneratedSql)t.addIssue({code:"custom",path:["queryKey"],message:"Send either queryKey or agentGeneratedSql, not both"});if(!e.queryKey&&!e.agentGeneratedSql)t.addIssue({code:"custom",path:["agentGeneratedSql"],message:"queryKey or agentGeneratedSql is required"})}var Tq=o$.superRefine(Uh).superRefine(i$),$q=j({agentContext:De.optional(),title:fn.optional(),config:Rh.nullable().optional(),reasoningText:zh.optional(),filtersConfig:qh.optional(),freshness:Kh.optional(),queryKey:Lh.optional(),agentGeneratedSql:Xi.optional()}).superRefine((e,t)=>{if(e.title===void 0&&e.config===void 0&&e.reasoningText===void 0&&e.filtersConfig===void 0&&e.freshness===void 0&&e.queryKey===void 0&&e.agentGeneratedSql===void 0)t.addIssue({code:"custom",message:"At least one field is required"});if(e.queryKey&&e.agentGeneratedSql)t.addIssue({code:"custom",path:["queryKey"],message:"Send either queryKey or agentGeneratedSql, not both"});if(e.config!==void 0)Uh({type:e.config?.type??"table",config:e.config},t)});import{readFileSync as a$}from"node:fs";function Pt(e){return e?De.parse(JSON.parse(a$(e,"utf8"))):void 0}var c$=["layout-dashboard","chart-column","chart-line","table","chart-pie"];function Ve(e){return{query:e?{response:"minimal"}:{}}}function l$(e,t){if(!e){if(t&&t!=="table")throw Error("Config file is required for non-table visualisations.");return}return JSON.parse(It(e,"utf8"))}async function Mh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards.post({agentContext:Pt(s.agentContextFile),title:s.title,...s.visualisationKeys?.length?{visualisationKeys:s.visualisationKeys}:{}},Ve(s.minimal));if(a||!i)throw Error("Failed to create dashboard.",{cause:a});M(i)}async function jh(e,t,r,n,s={}){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards.get({query:s});if(a||!i)throw Error("Failed to list dashboards.",{cause:a});M(s.limit!==void 0||s.cursor?i:i.dashboards)}async function Zh(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).get({query:o?{view:o}:{}});if(c||!a)throw Error("Failed to get dashboard.",{cause:c});M(a)}async function Vh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).filters.available.get();if(a||!i)throw Error("Failed to get available dashboard filters.",{cause:a});M(i.availableFilters)}async function Wh(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).filters({filterKey:o}).values.get({query:{...i.search?{q:i.search}:{},...i.limit!==void 0?{limit:i.limit}:{},...i.cursor?{cursor:i.cursor}:{}}});if(l||!c)throw Error("Failed to search dashboard filter values.",{cause:l});M(c)}async function Gh(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).delete();if(a||!i)throw Error("Failed to delete dashboard.",{cause:a});M(i)}async function Jh(e,t,r,n,s,o,i,a){let c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).placements({dashboardVisualisationId:i}).delete(void 0,Ve(a));if(u||!l)throw Error("Failed to delete dashboard visualisation.",{cause:u});M(l)}async function Bh(e,t,r,n,s,o){if(o.icon&&!c$.includes(o.icon))throw Error("Invalid dashboard icon.");let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).patch(o);if(c||!a)throw Error("Failed to update dashboard.",{cause:c});M(a)}async function Hh(e,t,r,n,s,o,i){let a=JSON.parse(It(o,"utf8")),c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).state.patch(a,Ve(i));if(u||!l)throw Error("Failed to save dashboard.",{cause:u});M(l)}async function Yh(e,t,r,n,s,o,i,a){let c=JSON.parse(It(i,"utf8")),l=k(e,t,r),{data:u,error:p}=await l.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).layout.patch({placements:c.placements??[],notes:c.notes??[]},Ve(a));if(p||!u)throw Error("Failed to update dashboard layout.",{cause:p});M(u)}async function Qh(e,t,r,n,s,o,i,a=!1){let c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).visualisations({visualisationKey:i}).pin.post({removeIncompatibleFilters:a});if(u||!l){let p=u?.value?.removedFilterKeys;throw Error(p?.length?`Pin would remove dashboard filters: ${p.join(", ")}. Retry with --remove-incompatible-filters.`:"Failed to pin visualisation to dashboard.",{cause:u})}if(l.removedFilterKeys.length>0)console.warn(`Removed incompatible dashboard filters: ${l.removedFilterKeys.join(", ")}`);M(l)}async function Xh(e,t,r,n,s,o=!1,i){let a=JSON.parse(It(s,"utf8")),c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards.pin.post({...a,...o?{removeIncompatibleFilters:!0}:{}},Ve(i));if(u||!l)throw console.error(JSON.stringify(u?.value??{error:"Bulk pin request failed"},null,2)),Error("Could not pin visualisations. Review conflicts before retrying with --remove-incompatible-filters.",{cause:u});if(M(l),l.results.some((p)=>p.status!=="pinned"))throw Error("Some pins did not complete. Retry only failed pins; check unknown outcomes before retrying.")}async function eg(e,t,r,n,s,o,i){if(!Jr.includes(i.type))throw Error("Invalid visualisation type.");let a=l$(i.configFile,i.type),c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).visualisations.post({title:i.title,type:i.type,modelKey:i.modelKey,...a!==void 0?{config:a}:{},agentGeneratedSql:It(i.sqlFile,"utf8"),...i.reasoningText?{reasoningText:i.reasoningText}:{},...i.removeIncompatibleFilters?{removeIncompatibleFilters:!0}:{}});if(u||!l){let p=u?.value?.removedFilterKeys;throw Error(p?.length?`Creating this visualisation would remove dashboard filters: ${p.join(", ")}. Retry with --remove-incompatible-filters.`:"Failed to create and pin visualisation to dashboard.",{cause:u})}if(l.removedFilterKeys.length>0)console.warn(`Removed incompatible dashboard filters: ${l.removedFilterKeys.join(", ")}`);M(l)}async function tg(e,t,r,n,s,o,i,a,c){let l=JSON.parse(It(i,"utf8")),u=k(e,t,r),{data:p,error:d}=await u.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes.post({content:l,agentContext:Pt(a)},Ve(c));if(d||!p)throw Error("Failed to create dashboard note.",{cause:d});M(p)}async function rg(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).get();if(l||!c)throw Error("Failed to read dashboard note.",{cause:l});M(c)}async function ng(e,t,r,n,s,o,i,a,c,l){let u=JSON.parse(It(a,"utf8")),p=k(e,t,r),{data:d,error:g}=await p.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).patch({content:u,agentContext:Pt(c)},Ve(l));if(g||!d)throw Error("Failed to update dashboard note.",{cause:g});M(d)}async function sg(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).notes({noteKey:i}).delete();if(l||!c)throw Error("Failed to delete dashboard note.",{cause:l});M(c)}async function og(e,t,r,n,s){let o=k(e,t,r);if(s.dashboard){let c=o.apps({appKey:n}).dashboards({dashboardKey:s.dashboard}),{data:l,error:u}=await c["share-targets"].get({query:{q:s.q??"",limit:s.limit??50}});if(u||!l)throw Error("Failed to list dashboard share targets.",{cause:u});M(l);return}if(!s.targetType)throw Error("--target-type is required without --dashboard");let{data:i,error:a}=await o.apps({appKey:n})["share-targets"].get({query:{targetType:s.targetType,...s.q?{q:s.q}:{},...s.limit!==void 0?{limit:s.limit}:{},...s.cursor?{cursor:s.cursor}:{}}});if(a||!i)throw Error("Failed to list share targets.",{cause:a});M(i)}async function ig(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).shares.get();if(a||!i)throw Error("Failed to list dashboard shares.",{cause:a});M(i)}async function ag(e,t,r,n,s,o,i,a="read"){let c=k(e,t,r),{data:l,error:u}=await c.apps({appKey:n}).dashboards({dashboardKey:s}).shares.post({target:{type:o,key:i},mode:a});if(u||!l)throw Error("Failed to create dashboard share.",{cause:u});M(l)}async function cg(e,t,r,n,s){let i=k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}),{data:a,error:c}=await i["personal-copy"].post();if(c||!a)throw Error("Failed to personalise dashboard.",{cause:c});M(a)}async function lg(e,t,r,n,s){let i=k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}),{error:a}=await i["personal-copy"].delete();if(a)throw Error("Failed to reset dashboard to default.",{cause:a});M({reset:!0})}async function ug(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).shares({targetType:o})({targetKey:i}).delete();if(l||!c)throw Error("Failed to delete dashboard share.",{cause:l});M(c)}async function pg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).draft.post();if(a||!i)throw Error("Failed to create or reopen dashboard draft.",{cause:a});M(i)}async function dg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).publish.post();if(a||!i)throw Error("Failed to publish dashboard draft.",{cause:a});M(i)}async function mg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).dashboards({dashboardKey:s}).draft.delete();if(a||!i)throw Error("Failed to discard dashboard draft.",{cause:a});M(i)}async function fg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs.post({title:o});if(c||!a)throw Error("Failed to create dashboard tab.",{cause:c});M(a)}async function hg(e,t,r,n,s,o,i){let a=k(e,t,r),{data:c,error:l}=await a.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).patch({title:i});if(l||!c)throw Error("Failed to update dashboard tab.",{cause:l});M(c)}async function gg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs.order.patch({orderedTabKeys:o});if(c||!a)throw Error("Failed to update dashboard tab order.",{cause:c});M(a)}async function yg(e,t,r,n,s,o){let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).dashboards({dashboardKey:s}).tabs({tabKey:o}).delete();if(c||!a)throw Error("Failed to delete dashboard tab.",{cause:c});M(a)}async function bg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"].post({providerKey:n.providerKey,apiKey:n.apiKey,displayName:n.displayName});if(i||!o)throw Error("Failed to create LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function wg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n.providerKey}).put({apiKey:n.apiKey});if(i||!o)throw Error("Failed to update LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function vg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n}).get();if(i||!o)throw Error("Failed to get LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}async function kg(e,t,r){let n=k(e,t,r),{data:s,error:o}=await n["llm-providers"].get();if(o||!s)throw Error("Failed to list LLM providers.",{cause:o});console.log(JSON.stringify(s,null,2))}async function Sg(e,t,r,n){let s=k(e,t,r),{data:o,error:i}=await s["llm-providers"]({providerKey:n}).delete();if(i||!o)throw Error("Failed to delete LLM provider.",{cause:i});console.log(JSON.stringify(o,null,2))}import{readFileSync as ea}from"node:fs";function Ye(e,t,r,n,s){return k(e,t,r).apps({appKey:n}).dashboards({dashboardKey:s}).schedules}function Ne(e,t,r){if(t||!e)throw Error(r,{cause:t});console.log(JSON.stringify(e,null,2))}var xg={async unsubscribe(e,t){let r=ea(t,"utf8").trim(),n=await V(e)["scheduled-report-unsubscriptions"].post({token:r});Ne(n.data,n.error,"Failed to unsubscribe from scheduled report.")},async create(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s).post(JSON.parse(ea(o,"utf8")));Ne(i.data,i.error,"Failed to create scheduled report.")},async list(e,t,r,n,s,o){let i=await k(e,t,r).apps({appKey:n}).schedules.get({query:{limit:s,...o?{cursor:o}:{}}});Ne(i.data,i.error,"Failed to list report schedules.")},async dashboardList(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s).get({query:{limit:o,...i?{cursor:i}:{}}});Ne(a.data,a.error,"Failed to list dashboard report schedules.")},async auditList(e,t,r,n,s,o){let i=await k(e,t,r).apps({appKey:n}).schedules.audit.get({query:{limit:s,...o?{cursor:o}:{}}});Ne(i.data,i.error,"Failed to audit report schedules.")},async unread(e,t,r,n){let s=await k(e,t,r).apps({appKey:n}).schedules.unread.get();Ne(s.data,s.error,"Failed to count unread schedule runs.")},async get(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s)({scheduleId:o}).get();Ne(i.data,i.error,"Failed to get scheduled report.")},async update(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).patch(JSON.parse(ea(i,"utf8")));Ne(a.data,a.error,"Failed to update scheduled report.")},async delete(e,t,r,n,s,o){let i=await Ye(e,t,r,n,s)({scheduleId:o}).delete();Ne(i.data,i.error,"Failed to delete scheduled report.")},async listRuns(e,t,r,n,s,o,i,a){let c=await Ye(e,t,r,n,s)({scheduleId:o}).runs.get({query:{limit:i,...a?{cursor:a}:{}}});Ne(c.data,c.error,"Failed to list scheduled report runs.")},async getRun(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).runs({runId:i}).get();Ne(a.data,a.error,"Failed to get scheduled report run.")},async readRun(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).runs({runId:i}).read.post();if(a.error)throw Error("Failed to mark scheduled report run read.",{cause:a.error});console.log(JSON.stringify({read:!0},null,2))},async run(e,t,r,n,s,o,i){let a=await Ye(e,t,r,n,s)({scheduleId:o}).runs.post({sendTo:i});Ne(a.data,a.error,"Failed to run scheduled report.")}};function hs(e,t,r,n){return k(e,t,r).apps({appKey:n})["user-groups"]}async function Cg(e,t,r,n){let{data:s,error:o}=await hs(e,t,r,n).get();if(o||!s)throw Error("Failed to list user groups.",{cause:o});console.log(JSON.stringify(s,null,2))}async function _g(e,t,r,n,s){let{data:o,error:i}=await hs(e,t,r,n)({groupKey:s}).members.get();if(i||!o)throw Error("Failed to list user group members.",{cause:i});console.log(JSON.stringify(o,null,2))}async function Ag(e,t,r,n,s,o){let{error:i}=await hs(e,t,r,n)({groupKey:s}).members({userId:o}).put();if(i)throw Error("Failed to add user group member.",{cause:i});console.log(JSON.stringify({added:!0},null,2))}async function Og(e,t,r,n,s,o){let{error:i}=await hs(e,t,r,n)({groupKey:s}).members({userId:o}).delete();if(i)throw Error("Failed to remove user group member.",{cause:i});console.log(JSON.stringify({removed:!0},null,2))}import{readFileSync as yt}from"node:fs";function u$(e,t){if(!e){if(t&&t!=="table")throw Error("Config file is required for non-table visualisations.");return}return JSON.parse(yt(e,"utf8"))}async function Tg(e,t,r,n,s){if(!Jr.includes(s.type))throw Error("Invalid visualisation type.");if(Boolean(s.sqlFile)===Boolean(s.queryKey))throw Error("Provide either --sql-file or --query-key.");let o=u$(s.configFile,s.type),i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).visualisations.post({agentContext:Pt(s.agentContextFile),title:s.title,type:s.type,modelKey:s.modelKey,...o!==void 0?{config:o}:{},...s.sqlFile?{agentGeneratedSql:yt(s.sqlFile,"utf8")}:{queryKey:s.queryKey},...s.reasoningText?{reasoningText:s.reasoningText}:{},...s.filtersConfigFile?{filtersConfig:JSON.parse(yt(s.filtersConfigFile,"utf8"))}:{},...s.freshnessFile?{freshness:JSON.parse(yt(s.freshnessFile,"utf8"))}:{}},Ve(s.minimal));if(c||!a)throw Error("Failed to create visualisation.",{cause:c});M(a)}async function $g(e,t,r,n,s,o){if(Boolean(o.sqlFile)&&Boolean(o.queryKey))throw Error("Provide either --sql-file or --query-key.");if(!o.title&&!o.configFile&&!o.sqlFile&&!o.queryKey&&!o.reasoningText&&!o.filtersConfigFile&&!o.freshnessFile)throw Error("Provide at least one update field.");let i=k(e,t,r),{data:a,error:c}=await i.apps({appKey:n}).visualisations({visualisationKey:s}).patch({agentContext:Pt(o.agentContextFile),...o.title?{title:o.title}:{},...o.configFile?{config:JSON.parse(yt(o.configFile,"utf8"))}:{},...o.sqlFile?{agentGeneratedSql:yt(o.sqlFile,"utf8")}:{},...o.queryKey?{queryKey:o.queryKey}:{},...o.reasoningText?{reasoningText:o.reasoningText}:{},...o.filtersConfigFile?{filtersConfig:JSON.parse(yt(o.filtersConfigFile,"utf8"))}:{},...o.freshnessFile?{freshness:JSON.parse(yt(o.freshnessFile,"utf8"))}:{}},Ve(o.minimal));if(c||!a)throw Error("Failed to update visualisation.",{cause:c});M(a)}async function Eg(e,t,r,n,s){let o=k(e,t,r),{data:i,error:a}=await o.apps({appKey:n}).visualisations({visualisationKey:s}).get();if(a||!i)throw Error("Failed to read visualisation.",{cause:a});M(i)}async function Ng(e,t,r,n,s,o,i="query"){let c=k(e,t,r).apps({appKey:n}).visualisations({visualisationKey:s})[i],{data:l,error:u}=await c.post({filters:o.filters?JSON.parse(o.filters):[],...o.columnFilters&&{columnFilters:JSON.parse(o.columnFilters)},forceRefresh:o.forceRefresh??!1,...o.name&&{secondaryQuery:{name:o.name,params:Object.fromEntries((o.param??[]).map((p)=>{let d=p.indexOf("=");if(d<1)throw Error(`--param must look like COLUMN=value: ${p}`);return[p.slice(0,d),p.slice(d+1)]}))}}});if(u||!l)throw Error(`Failed to ${i} visualisation.`,{cause:u});M(l)}async function Dg(e,t,r,n,s,o,i){let c=k(e,t,r).apps({appKey:n}).visualisations({visualisationKey:s}).columns({column:o}).values,{data:l,error:u}=await c.post({...i.search?{q:i.search}:{},...i.limit!==void 0?{limit:i.limit}:{},...i.cursor?{cursor:i.cursor}:{},filters:i.filters?JSON.parse(i.filters):[],columnFilters:i.columnFilters?JSON.parse(i.columnFilters):[]});if(u||!l)throw Error("Failed to search visualisation column values.",{cause:u});M(l)}async function Pg(e,t){let r=V(e,{getAccessToken:()=>t}),{data:n,error:s}=await r.workspaces.get();if(s||!n)throw Error("Failed to list workspaces.",{cause:s});console.log(JSON.stringify(n.workspaces,null,2))}async function Ig(e,t,r,n){let s=V(e,{getAccessToken:()=>t}),{data:o,error:i}=await s.workspaces.get();if(i||!o)throw Error("Failed to list workspaces.",{cause:i});let a=o.workspaces.find((l)=>l.workspaceKey===r);if(!a)throw Error(`Workspace "${r}" is not available. Run \`s workspaces list\` to see accessible workspaces.`);let c=n.load();if(!c||c.serverUrl!==e)throw Error("No saved session for this server. Run login first.");n.save({...c,workspaceId:a.workspaceId,workspaceKey:a.workspaceKey}),console.log(JSON.stringify({workspace:a},null,2))}function Fg(e,t,r={}){let n=r.runApiKeysCreate??ih,s=r.runAppsCreate??ch,o=r.runAppsList??lh,i=r.runAppsGet??uh,a=r.runAppsAgentGet??ph,c=r.runAppsFrontendConfigGet??dh,l=r.runAppsUpdate??mh,u=r.runAppsSettingsGet??hh,p=r.runAppsSettingsNew??fh,d=r.runDashboardsList??jh,g=r.runDashboardsCreate??Mh,b=r.runDashboardsDelete??Gh,y=r.runDashboardsDiscard??mg,w=r.runDashboardsDraft??pg,T=r.runDashboardsGet??Zh,N=r.runDashboardsAvailableFilters??Vh,x=r.runDashboardsFilterValues??Wh,D=r.runDashboardsPersonalise??cg,P=r.runDashboardsPublish??dg,L=r.runDashboardsResetToDefault??lg,K=r.runDashboardsSave??Hh,E=r.runDashboardsSharesCreate??ag,O=r.runDashboardsSharesDelete??ug,C=r.runDashboardsSharesList??ig,v=r.runDashboardsTabsCreate??fg,A=r.runDashboardsTabsCreateNote??tg,U=r.runDashboardsTabsCreateVisualisation??eg,G=r.runDashboardsTabsDelete??yg,B=r.runDashboardsTabsDeleteNote??sg,Le=r.runDashboardsTabsDeletePlacement??Jh,ye=r.runDashboardsTabsLayout??Yh,Kg=r.runDashboardsTabsOrder??gg,Rg=r.runDashboardsTabsPin??Qh,Ug=r.runDashboardsPin??Xh,Mg=r.runDashboardsTabsUpdate??hg,jg=r.runDashboardsTabsReadNote??rg,Zg=r.runDashboardsTabsUpdateNote??ng,Vg=r.runDashboardsUpdate??Bh,ve=r.scheduledReportCommands??xg,Ft=r.dashboardSnapshotCommands??Oh,Wg=r.runAddDashboardToDefaultArrangement??xh,Gg=r.runDashboardArrangementDashboardsMove??Ch,Jg=r.runDashboardArrangementDashboardsRemove??_h,Bg=r.runDashboardArrangementGroupsCreate??wh,Hg=r.runDashboardArrangementGroupsDelete??Sh,Yg=r.runDashboardArrangementGroupsMove??kh,Qg=r.runDashboardArrangementGroupsUpdate??vh,Xg=r.runDashboardArrangementsGet??gh,ra=r.runDashboardArrangementsHide??bh,ey=r.runDashboardArrangementsReset??yh,ty=r.runUserGroupsList??Cg,ry=r.runUserGroupMembersList??_g,ny=r.runUserGroupMembersAdd??Ag,sy=r.runUserGroupMembersRemove??Og,oy=r.runShareTargetsList??og,iy=r.runVisualisationsCreate??Tg,ay=r.runVisualisationsGet??Eg,na=r.runVisualisationsQuery??Ng,cy=r.runVisualisationsColumnValues??Dg,ly=r.runVisualisationsUpdate??$g,uy=r.runLlmProvidersCreate??bg,py=r.runLlmProvidersUpdate??wg,dy=r.runLlmProvidersGet??vg,my=r.runLlmProvidersList??kg,fy=r.runLlmProvidersDelete??Sg,hy=r.runWorkspacesList??Pg,sa=e.command("workspaces").description("Manage workspaces");sa.command("list").description("List workspaces the signed-in user can read").action(async function(){let h=await t.createAuthenticatedContext();await hy(h.serverUrl,h.accessToken)}),sa.command("select").description("Select the workspace for subsequent commands").argument("<workspace-key>","Workspace key").action(async function(h){let m=await t.createAuthenticatedContext();await(r.runWorkspacesSelect??Ig)(m.serverUrl,m.accessToken,h,t.createStore())}),e.command("api-keys").description("Manage API keys").command("create").description("Create an API key").action(async function(){let h=await t.createWorkspaceContext();await n(h.serverUrl,h.accessToken,h.workspaceKey)});let bt=e.command("apps").description("Manage apps");bt.command("create").description("Create an app").option("--key <key>","Stable app key").option("--display-name <display-name>","App display name").action(async function(h){let m=await t.createWorkspaceContext();await s(m.serverUrl,m.accessToken,m.workspaceKey,{appKey:h.key??await W("App key"),displayName:h.displayName??await W("Display name")})}),bt.command("list").description("List apps").action(async function(){let h=await t.createWorkspaceContext();await o(h.serverUrl,h.accessToken,h.workspaceKey)}),bt.command("get").description("Get an app").argument("<app-key>","App key").action(async function(h){let m=await t.createWorkspaceContext();await i(m.serverUrl,m.accessToken,m.workspaceKey,h)}),bt.command("agent").description("Manage app agent runtime context").command("get").description("Get app agent runtime context").argument("<app-key>","App key").option("--model-key <model-key>","Model key").addOption(new ge("--full","Return every context field without truncation").conflicts("include")).addOption(new ge("--include <fields>","Comma-separated runtime context fields").conflicts("full")).option("--tables <identifiers...>","Exact table identifiers for table-derived context").option("--output-file <file>","Write context JSON to a file").option("--force","Replace an existing output file").action(async function(h,m){let f=await t.createWorkspaceContext();await a(f.serverUrl,f.accessToken,f.workspaceKey,h,m.modelKey??await W("Model key"),{full:m.full,include:m.include,tables:m.tables,outputFile:m.outputFile,force:m.force})}),bt.command("frontend-config").description("Manage app frontend config").command("get").description("Get app frontend config").argument("<app-key>","App key").action(async function(h){let m=await t.createWorkspaceContext();await c(m.serverUrl,m.accessToken,m.workspaceKey,h)}),bt.command("*").description("Manage app settings").argument("<app-key>").argument("<settings-command>").argument("<settings-action>").option("--input-file <input-file>","Settings JSON or YAML file").option("--prompts-dir <prompts-dir>","Folder of agent prompt Markdown files, such as orchestrator-system.md").action(async function(h,m,f,_){if(m!=="settings"||!["get","new"].includes(f))throw Error(`Unknown apps command '${[h,m,f].join(" ")}'.`);let F=await t.createWorkspaceContext();if(f==="get"){await u(F.serverUrl,F.accessToken,F.workspaceKey,h);return}await p(F.serverUrl,F.accessToken,F.workspaceKey,h,{inputFile:_.inputFile??await W("Settings file"),promptsDir:_.promptsDir})}),bt.command("update").description("Update an app").argument("<app-key>","App key").option("--display-name <display-name>","App display name").action(async function(h,m){let f=await t.createWorkspaceContext();await l(f.serverUrl,f.accessToken,f.workspaceKey,h,{displayName:m.displayName??await W("Display name")})});let ce=e.command("dashboards").description("Manage dashboards"),ke=e.command("scheduled-reports").description("Manage scheduled dashboard reports");ke.command("unsubscribe").description("Unsubscribe using a token from a report email").requiredOption("--token-file <file>","File containing the unsubscribe token").action((h)=>ve.unsubscribe(t.getResolvedServerUrl(),h.tokenFile));let Lt=e.command("dashboard-snapshots").description("Create and read frozen dashboard snapshots"),Br=(h)=>h.argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key"),wt=(h)=>Br(h).argument("<schedule-id>","Schedule ID"),Se=async(h)=>{let m=await t.createWorkspaceContext();await h(m.serverUrl,m.accessToken,m.workspaceKey)};Br(ke.command("create").description("Create a report schedule")).requiredOption("--input-file <file>","Schedule JSON file").action((h,m,f)=>Se((..._)=>ve.create(..._,h,m,f.inputFile))),ke.command("list").description("List report schedules across an app").argument("<app-key>","App key").option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((h,m)=>{let f=Number(m.limit);if(!Number.isInteger(f)||f<1||f>100)throw Error("limit must be an integer between 1 and 100.");return Se((..._)=>ve.list(..._,h,f,m.cursor))}),Br(ke.command("dashboard-list").description("List report schedules you created or receive for one dashboard")).option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((h,m,f)=>{let _=Number(f.limit);if(!Number.isInteger(_)||_<1||_>100)throw Error("limit must be an integer between 1 and 100.");return Se((...F)=>ve.dashboardList(...F,h,m,_,f.cursor))}),ke.command("unread").description("Count your unread schedule runs across an app").argument("<app-key>","App key").action((h)=>Se((...m)=>ve.unread(...m,h))),ke.command("audit-list").description("Audit all report schedules across an app").argument("<app-key>","App key").option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((h,m)=>{let f=Number(m.limit);if(!Number.isInteger(f)||f<1||f>100)throw Error("limit must be an integer between 1 and 100.");return Se((..._)=>ve.auditList(..._,h,f,m.cursor))}),wt(ke.command("get").description("Get a report schedule")).action((h,m,f)=>Se((..._)=>ve.get(..._,h,m,f))),wt(ke.command("update").description("Update a report schedule")).requiredOption("--input-file <file>","Schedule patch JSON file").action((h,m,f,_)=>Se((...F)=>ve.update(...F,h,m,f,_.inputFile))),wt(ke.command("delete").description("Delete a report schedule")).action((h,m,f)=>Se((..._)=>ve.delete(..._,h,m,f))),wt(ke.command("run").description("Run a schedule once now to test it; its next scheduled time does not change")).option("--only-me","Email only you instead of every active recipient").action((h,m,f,_)=>Se((...F)=>ve.run(...F,h,m,f,_.onlyMe?"me":"all"))),wt(ke.command("runs-list").description("List schedule runs")).option("--limit <limit>","Page size (1-100)","50").option("--cursor <cursor>","Cursor returned by the previous page").action((h,m,f,_)=>{let F=Number(_.limit);if(!Number.isInteger(F)||F<1||F>100)throw Error("limit must be an integer between 1 and 100.");return Se((...le)=>ve.listRuns(...le,h,m,f,F,_.cursor))}),wt(ke.command("runs-get").description("Get one schedule run")).argument("<run-id>","Run ID").action((h,m,f,_)=>Se((...F)=>ve.getRun(...F,h,m,f,_))),wt(ke.command("runs-read").description("Mark one schedule run read for you")).argument("<run-id>","Run ID").action((h,m,f,_)=>Se((...F)=>ve.readRun(...F,h,m,f,_))),Br(Lt.command("create").description("Create a dashboard snapshot")).option("--input-file <file>","Snapshot filter JSON file").action((h,m,f)=>Se((..._)=>Ft.create(..._,h,m,f.inputFile))),Lt.command("get").description("Get a public frozen dashboard snapshot").argument("<public-id>","Public snapshot ID").action((h)=>Ft.get(t.getResolvedServerUrl(),h)),Lt.command("visualisation-get").description("Get one frozen visualisation result").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").action((h,m)=>Ft.getVisualisation(t.getResolvedServerUrl(),h,m)),Lt.command("visualisation-render").description("Get one frozen visualisation result shaped for drawing, without its raw rows").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").action((h,m)=>Ft.getVisualisation(t.getResolvedServerUrl(),h,m,!0)),Lt.command("pdf-download").description("Download the complete frozen dashboard as PDF").argument("<public-id>","Public snapshot ID").requiredOption("--output <file>","Destination PDF file").action((h,m)=>Ft.downloadPdf(t.getResolvedServerUrl(),h,m.output)),Lt.command("csv-download").description("Download a frozen visualisation CSV").argument("<public-id>","Public snapshot ID").argument("<visualisation-key>","Visualisation key").requiredOption("--output <file>","Destination CSV file").action((h,m,f)=>Ft.downloadCsv(t.getResolvedServerUrl(),h,m,f.output));let ar=()=>new ge("--scope <scope>","Dashboard arrangement scope").choices(["default","personal"]).default("personal"),zt=e.command("dashboard-arrangements").description("Manage dashboard navigation arrangements");zt.command("get").description("Get and reconcile the current personal arrangement").argument("<app-key>","App key").addOption(new ge("--scope <scope>","Dashboard arrangement scope").choices(["current","default"]).default("current")).action(async function(h,m){let f=await t.createWorkspaceContext();await Xg(f.serverUrl,f.accessToken,f.workspaceKey,h,m.scope)}),zt.command("reset").description("Reset the personal dashboard arrangement").argument("<app-key>","App key").action(async function(h){let m=await t.createWorkspaceContext();await ey(m.serverUrl,m.accessToken,m.workspaceKey,h)}),zt.command("hide").description("Hide a dashboard from the personal arrangement").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await ra(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),zt.command("show").description("Show a hidden dashboard in the personal arrangement again").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await ra(f.serverUrl,f.accessToken,f.workspaceKey,h,m,!1)});let Hr=zt.command("groups").description("Manage dashboard arrangement groups");Hr.command("create").description("Create a dashboard group").argument("<app-key>","App key").addOption(ar()).requiredOption("--name <json>",'Dashboard group name as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).action(async function(h,m){let f=await t.createWorkspaceContext();await Bg(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),Hr.command("update").description("Update a dashboard group").argument("<app-key>","App key").addOption(ar()).requiredOption("--group-id <group-id>","Dashboard group ID").requiredOption("--name <json>","Dashboard group name changes as a JSON map of locale tag to text; null removes a locale",dt).action(async function(h,m){let f=await t.createWorkspaceContext();await Qg(f.serverUrl,f.accessToken,f.workspaceKey,h,{scope:m.scope,dashboardGroupId:m.groupId,name:m.name})}),Hr.command("move").description("Move a dashboard group by identity anchor").argument("<app-key>","App key").addOption(ar()).requiredOption("--group-id <group-id>","Dashboard group ID").addOption(new ge("--before <group-id>","Place before this group ID").conflicts("after")).addOption(new ge("--after <group-id>","Place after this group ID").conflicts("before")).action(async function(h,m){let f=await t.createWorkspaceContext();await Yg(f.serverUrl,f.accessToken,f.workspaceKey,h,{scope:m.scope,dashboardGroupId:m.groupId,beforeDashboardGroupId:m.before,afterDashboardGroupId:m.after})}),Hr.command("delete").description("Delete a dashboard group").argument("<app-key>","App key").addOption(ar()).requiredOption("--group-id <group-id>","Dashboard group ID").action(async function(h,m){let f=await t.createWorkspaceContext();await Hg(f.serverUrl,f.accessToken,f.workspaceKey,h,{scope:m.scope,dashboardGroupId:m.groupId})});let ys=zt.command("dashboards").description("Manage dashboards in an arrangement");ys.command("add").description("Add a dashboard to the app default arrangement").argument("<app-key>","App key").requiredOption("--dashboard-key <dashboard-key>","Dashboard key").option("--group-id <group-id>","Dashboard group ID").action(async function(h,m){let f=await t.createWorkspaceContext();await Wg(f.serverUrl,f.accessToken,f.workspaceKey,h,{dashboardKey:m.dashboardKey,dashboardGroupId:m.groupId})}),ys.command("move").description("Move a dashboard by identity anchor").argument("<app-key>","App key").addOption(ar()).requiredOption("--dashboard-key <dashboard-key>","Dashboard key").addOption(new ge("--group-id <group-id>","Move into this group").conflicts("ungrouped")).addOption(new ge("--ungrouped","Move into the ungrouped group").conflicts("groupId")).addOption(new ge("--before <dashboard-key>","Place before this dashboard").conflicts("after")).addOption(new ge("--after <dashboard-key>","Place after this dashboard").conflicts("before")).action(async function(h,m){let f=await t.createWorkspaceContext();await Gg(f.serverUrl,f.accessToken,f.workspaceKey,h,{scope:m.scope,dashboardKey:m.dashboardKey,dashboardGroupId:m.ungrouped?null:m.groupId,beforeDashboardKey:m.before,afterDashboardKey:m.after})}),ys.command("remove").description("Remove a dashboard from the app default arrangement").argument("<app-key>","App key").requiredOption("--dashboard-key <dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await Jg(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("create").description("Create a dashboard for an app").argument("<app-key>","App key").option("--title <json>",'Dashboard title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--visualisation-keys <visualisation-keys>","Comma-separated existing visualisation keys to pin").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(h,m){let f=await t.createWorkspaceContext(),_=m.visualisationKeys?.split(",").map((F)=>F.trim()).filter(Boolean);await g(f.serverUrl,f.accessToken,f.workspaceKey,h,{...m.agentContextFile?{agentContextFile:m.agentContextFile}:{},title:m.title??Me(await W("Title (JSON map)")),..._?.length?{visualisationKeys:_}:{},minimal:m.minimal})}),ce.command("list").description("List dashboards for an app").argument("<app-key>","App key").option("--shared-with-group <group-key>","Only dashboards shared with this user group").addOption(new ge("--sort <sort>","Dashboard ordering").choices(["recently-pinned"])).addOption(new ge("--hidden <hidden>","Include dashboards hidden from your personal arrangement, or list only them").choices(["include","only"])).addOption(new ge("--view <view>","Dashboard response detail").choices(["summary","full"])).option("--editable-only","Only dashboards you can edit").option("--limit <limit>","Page size, 1–100 (enables pagination)",Number).option("--cursor <cursor>","Continue from a dashboard page cursor").action(async function(h,m){let f=await t.createWorkspaceContext();await d(f.serverUrl,f.accessToken,f.workspaceKey,h,{sharedWithGroup:m.sharedWithGroup,...m.sort?{sort:m.sort}:{},...m.hidden?{hidden:m.hidden}:{},...m.view?{view:m.view}:{},...m.editableOnly!==void 0?{editableOnly:m.editableOnly}:{},...m.limit!==void 0?{limit:m.limit}:{},...m.cursor?{cursor:m.cursor}:{}})}),ce.command("get").description("Get a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--view <view>","full (default) or layout: tabs and tiles in save format, without chart SQL or settings").action(async function(h,m,f){let _=await t.createWorkspaceContext();await T(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f.view)}),ce.command("available-filters").description("Get dashboard filters with availability status").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await N(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("filter-values").description("Search values for an available dashboard dimension filter").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<filter-key>","Dimension filter key").option("--search <text>","Case-insensitive value search").option("--limit <number>","Page size",(h)=>Number.parseInt(h,10)).option("--cursor <cursor>","Next-page cursor").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await x(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_)}),ce.command("delete").description("Delete a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await b(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("update").description("Update a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--title <json>","Dashboard title changes as a JSON map of locale tag to text; null removes a locale",dt).option("--icon <icon>","Dashboard icon key").option("--filter-key <filter-keys...>","Configured dashboard filter keys").option("--clear-filters","Remove every configured dashboard filter").option("--filter-views-file <path>","Saved filter views JSON file").option("--clear-filter-views","Remove every saved filter view").option("--default-filter-view-key <key>","Default filter view key").option("--clear-default-filter-view","Remove the default filter view").action(async function(h,m,f){if(f.filterKey&&f.clearFilters)throw Error("Use --filter-key or --clear-filters, not both.");if(f.filterViewsFile&&f.clearFilterViews)throw Error("Use --filter-views-file or --clear-filter-views, not both.");if(f.defaultFilterViewKey&&f.clearDefaultFilterView)throw Error("Use --default-filter-view-key or --clear-default-filter-view, not both.");if(!f.title&&!f.icon&&!f.filterKey&&!f.clearFilters&&!f.filterViewsFile&&!f.clearFilterViews&&!f.defaultFilterViewKey&&!f.clearDefaultFilterView)throw Error("Provide a dashboard field to update.");let _=await t.createWorkspaceContext();await Vg(_.serverUrl,_.accessToken,_.workspaceKey,h,m,{...f.title?{title:f.title}:{},...f.icon?{icon:f.icon}:{},...f.filterKey?{filterKeys:f.filterKey}:{},...f.clearFilters?{filterKeys:[]}:{},...f.filterViewsFile?{filterViews:JSON.parse(p$(f.filterViewsFile,"utf8"))}:{},...f.clearFilterViews?{filterViews:[],defaultFilterViewKey:null}:{},...f.defaultFilterViewKey?{defaultFilterViewKey:f.defaultFilterViewKey}:{},...f.clearDefaultFilterView?{defaultFilterViewKey:null}:{}})}),ce.command("save").description("Save a dashboard document").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--input-file <input-file>","Dashboard save JSON file").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f){let _=await t.createWorkspaceContext();await K(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f.inputFile??await W("Save file"),f.minimal)}),ce.command("draft").description("Create or reopen your private draft when another audience already has direct read access").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await w(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("publish").description("Publish a draft onto its published dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await P(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("discard").description("Discard a private draft without publishing").argument("<app-key>","App key").argument("<dashboard-key>","Published dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await y(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("shares-list").description("List shares for a dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await C(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("shares-create").description("Share a dashboard with a user or user group").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<target-type>","Target type: user or user_group").argument("<target-key>","Target key").option("--mode <mode>","Share mode: read or personalise","read").action(async function(h,m,f,_,F){if(f!=="user"&&f!=="user_group")throw Error("target-type must be user or user_group");if(F.mode!=="read"&&F.mode!=="personalise")throw Error("mode must be read or personalise");let le=await t.createWorkspaceContext();await E(le.serverUrl,le.accessToken,le.workspaceKey,h,m,f,_,F.mode)}),ce.command("personalise").description("Create a personal copy of a shared dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").action(async function(h,m){let f=await t.createWorkspaceContext();await D(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("reset-to-default").description("Delete your personal copy and restore the source dashboard").argument("<app-key>","App key").argument("<dashboard-key>","Personal copy key shown in the dashboard list").action(async function(h,m){let f=await t.createWorkspaceContext();await L(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),ce.command("shares-delete").description("Remove a dashboard share").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<target-type>","Target type: user or user_group").argument("<target-key>","Target key").action(async function(h,m,f,_){if(f!=="user"&&f!=="user_group")throw Error("target-type must be user or user_group");let F=await t.createWorkspaceContext();await O(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_)}),ce.command("share-targets").description("List available share targets for an app").argument("<app-key>","App key").option("--dashboard <dashboardKey>","Return users and groups with dashboard share status (max 50)").option("--target-type <targetType>","Target type: user_group or user").option("--q <q>","Search text").option("--limit <limit>","Max results (1-50 with --dashboard; otherwise 1-1000)").option("--cursor <cursor>","Opaque cursor for the next page").action(async function(h,m){if(m.dashboard&&(m.targetType||m.cursor))throw Error("--dashboard cannot be combined with --target-type or --cursor");if(!m.dashboard&&m.targetType!=="user_group"&&m.targetType!=="user")throw Error("--target-type must be user_group or user");let f=await t.createWorkspaceContext();await oy(f.serverUrl,f.accessToken,f.workspaceKey,h,{...m.dashboard?{dashboard:m.dashboard}:{targetType:m.targetType},...m.q?{q:m.q}:{},...m.limit!==void 0?{limit:Number.parseInt(m.limit,10)}:{},...m.cursor?{cursor:m.cursor}:{}})}),ce.command("pin").description("Pin multiple visualisations to dashboard tabs").argument("<app-key>","App key").requiredOption("--input-file <path>","JSON bulk pin request").option("--remove-incompatible-filters","Remove incompatible filters on requested dashboards").option("--minimal","Return only the keys and version needed next").action(async(h,m)=>{let f=await t.createWorkspaceContext();await Ug(f.serverUrl,f.accessToken,f.workspaceKey,h,m.inputFile,Boolean(m.removeIncompatibleFilters),m.minimal)});let Ae=ce.command("tabs").description("Manage dashboard tabs");Ae.command("create").description("Create a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--title <json>",'Tab title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).action(async function(h,m,f){let _=await t.createWorkspaceContext();await v(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f.title??Me(await W("Title (JSON map)")))}),Ae.command("update").description("Update a dashboard tab title").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--title <json>","Tab title changes as a JSON map of locale tag to text; null removes a locale",dt).action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await Mg(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_.title??dt(await W("Title (JSON map)")))}),Ae.command("order").description("Update dashboard tab order").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").option("--ordered-tab-keys <ordered-tab-keys>","Comma-separated tab keys in display order").action(async function(h,m,f){let _=await t.createWorkspaceContext(),F=(f.orderedTabKeys??await W("Ordered tab keys")).split(",").map((le)=>le.trim()).filter(Boolean);await Kg(_.serverUrl,_.accessToken,_.workspaceKey,h,m,F)}),Ae.command("delete").description("Delete a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").action(async function(h,m,f){let _=await t.createWorkspaceContext();await G(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f)}),Ae.command("pin").description("Pin a visualisation to a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<visualisation-key>","Visualisation key").option("--remove-incompatible-filters","Remove configured filters made unavailable by the pin").action(async function(h,m,f,_,F){let le=await t.createWorkspaceContext();await Rg(le.serverUrl,le.accessToken,le.workspaceKey,h,m,f,_,Boolean(F.removeIncompatibleFilters))}),Ae.command("create-visualisation").description("Create a visualisation and pin it to a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--title <json>",'Visualisation title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--type <type>","Visualisation type","table").option("--model-key <model-key>","Model key").option("--sql-file <sql-file>","SQL file").option("--config-file <config-file>","Visualisation config JSON file").option("--reasoning-text <reasoning-text>","Reasoning text").option("--remove-incompatible-filters","Remove all dashboard filters when the visualisation uses another model").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await U(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,{title:_.title??Me(await W("Title (JSON map)")),type:_.type,modelKey:_.modelKey??await W("Model key"),sqlFile:_.sqlFile??await W("SQL file"),..._.configFile?{configFile:_.configFile}:{},..._.reasoningText?{reasoningText:_.reasoningText}:{},..._.removeIncompatibleFilters?{removeIncompatibleFilters:!0}:{}})}),Ae.command("create-note").description("Create a note on a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--content-file <content-file>","Note content JSON file: a map of locale tag to a Quill Delta document").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await A(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_.contentFile??await W("Content file"),_.agentContextFile,_.minimal)}),Ae.command("read-note").description("Read a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await jg(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_)}),Ae.command("update-note").description("Update a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").option("--content-file <content-file>","Note content changes: a map of locale tag to a Quill Delta document; null removes a locale").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f,_,F){let le=await t.createWorkspaceContext();await Zg(le.serverUrl,le.accessToken,le.workspaceKey,h,m,f,_,F.contentFile??await W("Content file"),F.agentContextFile,F.minimal)}),Ae.command("delete-note").description("Delete a dashboard note").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<note-key>","Note key").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await B(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_)}),Ae.command("layout").description("Update a dashboard tab layout").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").option("--input-file <input-file>","Layout JSON file").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await ye(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_.inputFile??await W("Layout file"),_.minimal)}),Ae.command("delete-placement").description("Remove a visualisation from a dashboard tab").argument("<app-key>","App key").argument("<dashboard-key>","Dashboard key").argument("<tab-key>","Tab key").argument("<dashboard-visualisation-id>","Dashboard visualisation ID").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f,_,F){let le=await t.createWorkspaceContext();await Le(le.serverUrl,le.accessToken,le.workspaceKey,h,m,f,_,F.minimal)});let qt=e.command("visualisations").description("Manage visualisations");qt.command("create").description("Create a visualisation for an app").argument("<app-key>","App key").option("--title <json>",'Visualisation title as a JSON map of locale tag to text, for example {"en-US":"Sales"}',Me).option("--type <type>","Visualisation type","table").option("--model-key <model-key>","Model key").option("--sql-file <sql-file>","SQL file").option("--query-key <query-key>","Stored model query key").option("--config-file <config-file>","Visualisation config JSON file").option("--reasoning-text <reasoning-text>","Reasoning text").option("--filters-config-file <filters-config-file>","Filters config JSON file").option("--freshness-file <freshness-file>","Freshness JSON file").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(h,m){let f=await t.createWorkspaceContext();await iy(f.serverUrl,f.accessToken,f.workspaceKey,h,{...m.agentContextFile?{agentContextFile:m.agentContextFile}:{},title:m.title??Me(await W("Title (JSON map)")),type:m.type,modelKey:m.modelKey??await W("Model key"),...m.sqlFile?{sqlFile:m.sqlFile}:{},...m.queryKey?{queryKey:m.queryKey}:{},...m.configFile?{configFile:m.configFile}:{},...m.reasoningText?{reasoningText:m.reasoningText}:{},...m.freshnessFile?{freshnessFile:m.freshnessFile}:{},...m.filtersConfigFile?{filtersConfigFile:m.filtersConfigFile}:{},minimal:m.minimal})}),qt.command("read").description("Read a saved visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").action(async function(h,m){let f=await t.createWorkspaceContext();await ay(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),qt.command("query").description("Query a saved visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--filters <filters>","Filters JSON array").option("--column-filters <json>",'Table column filters JSON array, such as [{"column":"CITY","operator":"in","values":["Riyadh"]},{"column":"NET_SALES","operator":"gte","values":["1000"]}]').option("--force-refresh","Skip the query execution store and run the warehouse query").option("--name <name>","Run this HTML tile secondary query instead").option("--param <column=value>","Secondary query param; repeat for each column",(h,m=[])=>[...m,h]).action(async function(h,m,f){let _=await t.createWorkspaceContext();await na(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f)}),qt.command("render").description("Render a saved visualisation: its result shaped for drawing, without raw rows").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--filters <filters>","Filters JSON array").option("--column-filters <json>",'Table column filters JSON array, such as [{"column":"CITY","operator":"in","values":["Riyadh"]},{"column":"NET_SALES","operator":"gte","values":["1000"]}]').option("--force-refresh","Skip the query execution store and run the warehouse query").action(async function(h,m,f){let _=await t.createWorkspaceContext();await na(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f,"render")}),qt.command("column-values").description("Search the values of a table visualisation's column").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").argument("<column>","Result column").option("--search <text>","Case-insensitive value search").option("--limit <number>","Page size",(h)=>Number.parseInt(h,10)).option("--cursor <cursor>","Next-page cursor").option("--filters <filters>","Dashboard filters JSON array that narrows the values, as on the table").option("--column-filters <json>","Other columns' filters JSON array that narrows the values; the column's own is ignored").action(async function(h,m,f,_){let F=await t.createWorkspaceContext();await cy(F.serverUrl,F.accessToken,F.workspaceKey,h,m,f,_)}),qt.command("update").description("Update a visualisation").argument("<app-key>","App key").argument("<visualisation-key>","Visualisation key").option("--title <json>","Visualisation title changes as a JSON map of locale tag to text; null removes a locale",dt).option("--config-file <config-file>","Visualisation config JSON file").option("--sql-file <sql-file>","SQL file").option("--query-key <query-key>","Stored model query key").option("--reasoning-text <reasoning-text>","Reasoning text").option("--filters-config-file <filters-config-file>","Filters config JSON file").option("--freshness-file <freshness-file>","Freshness JSON file").option("--agent-context-file <file>","Thread, run, and tool-call metadata JSON").option("--minimal","Return only the keys and version needed next").action(async function(h,m,f){let _=await t.createWorkspaceContext();await ly(_.serverUrl,_.accessToken,_.workspaceKey,h,m,{...f.agentContextFile?{agentContextFile:f.agentContextFile}:{},...f.title?{title:f.title}:{},...f.configFile?{configFile:f.configFile}:{},...f.sqlFile?{sqlFile:f.sqlFile}:{},...f.queryKey?{queryKey:f.queryKey}:{},...f.reasoningText?{reasoningText:f.reasoningText}:{},...f.filtersConfigFile?{filtersConfigFile:f.filtersConfigFile}:{},...f.freshnessFile?{freshnessFile:f.freshnessFile}:{},minimal:f.minimal})});let cr=e.command("llm-providers").description("Manage workspace LLM providers");cr.command("create").description("Create a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").option("--api-key <api-key>","LLM provider API key").option("--display-name <display-name>","Display name for this credential").action(async function(h){let m=await t.createWorkspaceContext();await uy(m.serverUrl,m.accessToken,m.workspaceKey,{providerKey:h.provider??await W("Provider (e.g. openai)"),apiKey:h.apiKey??await W("API key"),displayName:h.displayName??await W("Display name")})}),cr.command("update").description("Update a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").option("--api-key <api-key>","New LLM provider API key").action(async function(h){if(!h.apiKey)throw Error("Provide --api-key.");let m=await t.createWorkspaceContext();await py(m.serverUrl,m.accessToken,m.workspaceKey,{providerKey:h.provider??await W("Provider (e.g. openai)"),apiKey:h.apiKey})}),cr.command("get").description("Get a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").action(async function(h){let m=await t.createWorkspaceContext();await dy(m.serverUrl,m.accessToken,m.workspaceKey,h.provider??await W("Provider (e.g. openai)"))}),cr.command("list").description("List workspace LLM providers").action(async function(){let h=await t.createWorkspaceContext();await my(h.serverUrl,h.accessToken,h.workspaceKey)}),cr.command("delete").description("Delete a workspace LLM provider").option("--provider <provider>","LLM provider key (e.g. openai)").action(async function(h){let m=await t.createWorkspaceContext();await fy(m.serverUrl,m.accessToken,m.workspaceKey,h.provider??await W("Provider (e.g. openai)"))});let oa=e.command("user-groups").description("Manage app user groups");oa.command("list").description("List user groups in an app").argument("<app-key>","App key").action(async function(h){let m=await t.createWorkspaceContext();await ty(m.serverUrl,m.accessToken,m.workspaceKey,h)});let bs=oa.command("members").description("Manage members of a user group");bs.command("list").description("List members of a user group").argument("<app-key>","App key").argument("<group-key>","User group key").action(async function(h,m){let f=await t.createWorkspaceContext();await ry(f.serverUrl,f.accessToken,f.workspaceKey,h,m)}),bs.command("add").description("Add a user to a user group").argument("<app-key>","App key").argument("<group-key>","User group key").argument("<user-id>","User id").action(async function(h,m,f){let _=await t.createWorkspaceContext();await ny(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f)}),bs.command("remove").description("Remove a user from a user group").argument("<app-key>","App key").argument("<group-key>","User group key").argument("<user-id>","User id").action(async function(h,m,f){let _=await t.createWorkspaceContext();await sy(_.serverUrl,_.accessToken,_.workspaceKey,h,m,f)})}function Lg(e,t,r=process.env[t]){let n=e?.trim()||r?.trim();if(!n)throw Error(`Missing server URL. Provide --server-url or set ${t}.`);try{return{serverUrl:new URL(n).toString().replace(/\/$/,"")}}catch{throw Error(`Invalid server URL: ${n}`)}}var gs="S_CLI_SERVER_URL",ta="S_CLI_PROFILE";function zg(e,t=process.env[gs],r){return Lg(e,gs,t?.trim()||r)}function qg(e={}){let t=e.createStore??(()=>new Gr(Hi(n.opts().profile?.trim()||process.env[ta]?.trim()))),r=null,n=new ip;n.name("s").version(e.version??"0.2.0").option("--server-url <url>","Target server URL").option("--profile <name>",`Use this named session instead of the default one (or set ${ta})`).option("--non-interactive","Fail instead of prompting when required input is missing").option("--json-errors","Print failures as stable JSON on stderr").option("--locale <tag>","Add each localized text's version for this locale, such as ar-SA, next to it in dashboard, visualisation, and arrangement output",(c)=>{let l=St(c);if(!l)throw new gn("Use a locale tag such as en-US or ar-SA.");return l}),n.configureOutput({outputError:(c,l)=>l(process.argv.includes("--json-errors")?`${ks(c.trim())}
230
+ `:c)}),n.hook("preAction",(c,l)=>{if(l.parent===n&&l.name()==="logout")return;let u=l.optsWithGlobals();yf({nonInteractive:Boolean(u.nonInteractive)}),of(u.locale);let p=process.env[gs];r=zg(u.serverUrl,p,u.serverUrl?.trim()||p?.trim()?void 0:t().load()?.serverUrl).serverUrl});function s(){if(!r)throw Error("Resolved server URL is unavailable.");return r}async function o(){return pa(s(),{store:t(),loadAuthConfig:wn,createApiClient:V})}async function i(){let c=await o();if(!c.workspaceKey)throw Error("No workspace selected. Run `s workspaces select <workspace-key>`.");return c}let a={getResolvedServerUrl:s,createAuthenticatedContext:o,createWorkspaceContext:i,createStore:t};return oh(n,a,e,e.registerSignupCommands),Fg(n,a,e),wp(n,a,e),uf(n,a,e),Uf(n,a,e),ff(n,a,e),df(n,a,e),n}var d$=qg();try{await d$.parseAsync(process.argv)}catch(e){la(e,{json:process.argv.includes("--json-errors")}),process.exitCode=1}