mmx-cli 1.0.30 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/mmx.mjs +312 -306
- package/package.json +1 -1
package/dist/mmx.mjs
CHANGED
|
@@ -1,171 +1,171 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
`)}if(typeof e==="object")return
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
`);return{}}}async function
|
|
7
|
-
`,{mode:384}),
|
|
2
|
+
import{createRequire as zm}from"node:module";var Vm=Object.create;var{getPrototypeOf:Hm,defineProperty:nl,getOwnPropertyNames:Km}=Object;var il=Object.prototype.hasOwnProperty;function Wm(e){return this[e]}var Ym,Jm,qt=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?Ym??=new WeakMap:Jm??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Vm(Hm(e)):{};let o=t||!e||!e.__esModule||!il.call(e,"default")?nl(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Km(e))if(!il.call(o,a))nl(o,a,{get:Wm.bind(e,a),enumerable:!0})}if(i)r.set(e,o);return o};var M=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var T=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var ln=zm(import.meta.url);var b;var j=T(()=>{b={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var G=T(()=>{j();y=class y extends Error{exitCode;hint;constructor(e,t=b.GENERAL,n){super(e);this.name="CLIError",this.exitCode=t,this.hint=n}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function nh(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;if(typeof t.access_token!=="string"||!t.access_token)return;if(typeof t.refresh_token!=="string")return;if(typeof t.expires_at!=="string")return;let n={access_token:t.access_token,refresh_token:t.refresh_token,expires_at:t.expires_at};if(typeof t.region==="string"&&sl.has(t.region))n.region=t.region;if(typeof t.resource_url==="string"&&t.resource_url.startsWith("http"))n.resource_url=t.resource_url;if(typeof t.account==="string"&&t.account.length>0)n.account=t.account;return n}function ol(e){if(!e||typeof e!=="object"||Array.isArray(e))return{};let t=e,n={};if(typeof t.api_key==="string")n.api_key=t.api_key;if(typeof t.region==="string"&&sl.has(t.region))n.region=t.region;if(typeof t.base_url==="string"&&t.base_url.startsWith("http"))n.base_url=t.base_url;if(typeof t.output==="string"&&th.has(t.output))n.output=t.output;if(typeof t.timeout==="number"&&t.timeout>0)n.timeout=t.timeout;if(typeof t.proxy==="string"&&t.proxy.startsWith("http"))n.proxy=t.proxy;let i=nh(t.oauth);if(i)n.oauth=i;if(typeof t.default_text_model==="string"&&t.default_text_model.length>0)n.default_text_model=t.default_text_model;if(typeof t.default_speech_model==="string"&&t.default_speech_model.length>0)n.default_speech_model=t.default_speech_model;if(typeof t.default_video_model==="string"&&t.default_video_model.length>0)n.default_video_model=t.default_video_model;return n}var ne,ht,li,sl,th;var Ee=T(()=>{ne={global:"https://api.minimax.io",cn:"https://api.minimax.cn"},ht={global:"https://platform.minimax.io",cn:"https://platform.minimax.cn"},li={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},sl=new Set(["global","cn"]),th=new Set(["text","json"])});function C(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var cn;var X=T(()=>{cn=[{flag:"--api-key <key>",description:"API key"},{flag:"--region <region>",description:"API region: global, cn"},{flag:"--base-url <url>",description:"API base URL"},{flag:"--output <format>",description:"Output format: text, json"},{flag:"--timeout <seconds>",description:"Request timeout",type:"number"},{flag:"--quiet",description:"Suppress non-essential output"},{flag:"--verbose",description:"Print HTTP request/response details"},{flag:"--no-color",description:"Disable ANSI colors"},{flag:"--dry-run",description:"Dry run mode"},{flag:"--non-interactive",description:"Disable interactive prompts"},{flag:"--help",description:"Show help"},{flag:"--version",description:"Print version"}]});import{homedir as ih}from"os";import{join as al}from"path";function ci(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return al(ih(),rh)}function de(){return al(ci(),"config.json")}async function ll(e=ci()){let t=await import("fs/promises");await t.mkdir(e,{recursive:!0,mode:448})}var rh=".mmx";var Xe=()=>{};function cl(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"(empty)";if(typeof e[0]==="object"&&e[0]!==null)return ts(e);return e.map(String).join(`
|
|
3
|
+
`)}if(typeof e==="object")return es(e);return String(e)}function es(e,t=0){let n=" ".repeat(t),i=[];for(let[r,s]of Object.entries(e)){if(s===null||s===void 0)continue;if(Array.isArray(s)){i.push(`${n}${r}:`);for(let o of s)if(typeof o==="object"&&o!==null)i.push(`${n} - ${es(o,t+4).trimStart()}`);else i.push(`${n} - ${String(o)}`)}else if(typeof s==="object")i.push(`${n}${r}:`),i.push(es(s,t+2));else i.push(`${n}${r}: ${String(s)}`)}return i.join(`
|
|
4
|
+
`)}function ts(e){if(e.length===0)return"(empty)";let t=Object.keys(e[0]),n=t.map((o)=>Math.max(o.length,...e.map((a)=>String(a[o]??"").length))),i=t.map((o,a)=>o.toUpperCase().padEnd(n[a])).join(" "),r=n.map((o)=>"-".repeat(o)).join(" "),s=e.map((o)=>t.map((a,l)=>String(o[a]??"").padEnd(n[l])).join(" "));return[i,r,...s].join(`
|
|
5
|
+
`)}function ul(e){return JSON.stringify(e,null,2)}function F(e){if(e==="json"||e==="text")return e;if(!process.stdout.isTTY)return"json";return"text"}function O(e,t){switch(t){case"json":return ul(e);case"text":return cl(e)}}function Ae(e,t){if(!e.dryRun)return!1;return console.log(O({request:t},F(e.output))),!0}var ee=()=>{};import{copyFileSync as sh,existsSync as oh,readFileSync as ah,renameSync as lh,unlinkSync as ch,writeFileSync as uh}from"fs";import{dirname as fh}from"path";function dh(e){return e instanceof Error&&"code"in e&&e.code==="EXDEV"}function ph(e,t,n={rename:lh,copy:sh,unlink:ch}){try{n.rename(e,t)}catch(i){if(!dh(i))throw i;n.copy(e,t),n.unlink(e)}}function Z(e=de()){if(!oh(e))return{};try{return ol(JSON.parse(ah(e,"utf-8")))}catch(t){let n=t;if(n instanceof SyntaxError||n.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
|
|
6
|
+
`);return{}}}async function pe(e,t,n=de()){await ll(fh(n));let i=n+".tmp";uh(i,JSON.stringify(e,null,2)+`
|
|
7
|
+
`,{mode:384}),ph(i,n,t)}function ns(e){let t=Z(),n=e.apiKey||void 0,i=t.api_key,r=e.region||process.env.MINIMAX_REGION||void 0;if(r&&!(r in ne))throw new y(`Invalid region "${r}". Valid values: ${Object.keys(ne).join(", ")}`,b.USAGE);let s=t.region,o=r||s||"global",a=n||i,l=!r&&(!s||a!==void 0&&a!==t.api_key),c=e.baseUrl||process.env.MINIMAX_BASE_URL||t.base_url||(!n?t.oauth?.resource_url:void 0)||ne[o]||ne.global,f=F(e.output||process.env.MINIMAX_OUTPUT||t.output),u=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,d=u!==void 0&&Number.isFinite(u)&&u>0?u:void 0,g=e.timeout??d??t.timeout??300;return{apiKey:n,fileApiKey:i,fileRegion:t.region,configPath:de(),region:o,baseUrl:c,output:f,timeout:g,defaultTextModel:t.default_text_model,defaultSpeechModel:t.default_speech_model,defaultVideoModel:t.default_video_model,verbose:e.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:e.quiet||!1,noColor:e.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:e.yes||!1,dryRun:e.dryRun||!1,nonInteractive:e.nonInteractive||!1,async:e.async||!1,needsRegionDetection:l}}var Re=T(()=>{Ee();Xe();ee();G();j()});var un=M(function(Kk,is){var fi=process||{},fl=fi.argv||[],ui=fi.env||{},mh=!(!!ui.NO_COLOR||fl.includes("--no-color"))&&(!!ui.FORCE_COLOR||fl.includes("--color")||fi.platform==="win32"||(fi.stdout||{}).isTTY&&ui.TERM!=="dumb"||!!ui.CI),hh=(e,t,n=e)=>(i)=>{let r=""+i,s=r.indexOf(t,e.length);return~s?e+gh(r,t,n,s)+t:e+r+t},gh=(e,t,n,i)=>{let r="",s=0;do r+=e.substring(s,i)+n,s=i+t.length,i=e.indexOf(t,s);while(~i);return r+e.substring(s)},dl=(e=mh)=>{let t=e?hh:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};is.exports=dl();is.exports.createColors=dl});function Q(e){if(e?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}var ss=M(function(Yk,pl){var rs={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`\x1B[${-e}D`;else if(e>0)n+=`\x1B[${e}C`;if(t<0)n+=`\x1B[${-t}A`;else if(t>0)n+=`\x1B[${t}B`;return n},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},yh={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},bh={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?rs.up():"");if(e)t+=rs.left;return t}};pl.exports={cursor:rs,scroll:yh,erase:bh,beep:"\x07"}});import{stdout as fs,stdin as wl}from"node:process";import*as Qe from"node:readline";import wh from"node:readline";import{ReadStream as ml}from"node:tty";function cs(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
8
8
|
`,`
|
|
9
9
|
`).split(`
|
|
10
|
-
`).map((i)=>
|
|
11
|
-
`)}function
|
|
10
|
+
`).map((i)=>Oh(i,t,n)).join(`
|
|
11
|
+
`)}function ms(e,t){if(typeof e=="string")return Le.aliases.get(e)===t;for(let n of e)if(n!==void 0&&ms(n,t))return!0;return!1}function Ch(e,t){if(e===t)return;let n=e.split(`
|
|
12
12
|
`),i=t.split(`
|
|
13
|
-
`),r=Math.max(n.length,i.length),s=[];for(let o=0;o<r;o++)n[o]!==i[o]&&s.push(o);return{lines:s,numLinesBefore:n.length,numLinesAfter:i.length,numLines:r}}function
|
|
13
|
+
`),r=Math.max(n.length,i.length),s=[];for(let o=0;o<r;o++)n[o]!==i[o]&&s.push(o);return{lines:s,numLinesBefore:n.length,numLinesAfter:i.length,numLines:r}}function Pe(e){return e===us}function hi(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function _l({input:e=wl,output:t=fs,overwrite:n=!0,hideCursor:i=!0}={}){let r=Qe.createInterface({input:e,output:t,prompt:"",tabSize:1});Qe.emitKeypressEvents(e,r),e instanceof ml&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:l})=>{let c=String(o);if(ms([c,a,l],"cancel")){i&&t.write(ue.cursor.show),process.exit(0);return}if(!n)return;Qe.moveCursor(t,a==="return"?0:-1,a==="return"?-1:0,()=>{Qe.clearLine(t,1,()=>{e.once("keypress",s)})})};return i&&t.write(ue.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(ue.cursor.show),e instanceof ml&&e.isTTY&&!Rh&&e.setRawMode(!1),r.terminal=!1,r.close()}}function yt(e,t,n,i=n){let r=dn(e??fs);return cs(t,r-n.length,{hard:!0,trim:!1}).split(`
|
|
14
14
|
`).map((s,o)=>`${o===0?i:n}${s}`).join(`
|
|
15
|
-
`)}class
|
|
16
|
-
`),
|
|
17
|
-
`).length-1;this.output.write(
|
|
18
|
-
`);this.output.write(o[s]),this._prevFrame=e,this.output.write(
|
|
15
|
+
`)}class pn{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:n=wl,output:i=fs,render:r,signal:s,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=r.bind(this),this._track=t,this._abortSignal=s,this.input=n,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],i=[];for(let r of n)r.cb(...t),r.once&&i.push(()=>n.splice(n.indexOf(r),1));for(let r of i)r()}prompt(){return new Promise((e)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(us);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=wh.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),hi(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(ue.cursor.show),this.output.off("resize",this.render),hi(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(ue.cursor.show),this.output.off("resize",this.render),hi(this.input,!1),e(us)})})}_isActionKey(e,t){return e==="\t"}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&t.name!=="return"&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),t?.name&&(!this._track&&Le.aliases.has(t.name)&&this.emit("cursor",Le.aliases.get(t.name)),Le.actions.has(t.name)&&this.emit("cursor",t.name)),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),this.emit("key",e?.toLowerCase(),t),t?.name==="return"){if(this.opts.validate){let n=this.opts.validate(this.value);n&&(this.error=n instanceof Error?n.message:n,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}ms([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
16
|
+
`),hi(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=cs(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
17
|
+
`).length-1;this.output.write(ue.cursor.move(-999,e*-1))}render(){let e=cs(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(ue.cursor.hide);else{let t=Ch(this._prevFrame,e),n=hs(this.output);if(this.restoreCursor(),t){let i=Math.max(0,t.numLinesAfter-n),r=Math.max(0,t.numLinesBefore-n),s=t.lines.find((o)=>o>=i);if(s===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(ue.cursor.move(0,s-r)),this.output.write(ue.erase.lines(1));let o=e.split(`
|
|
18
|
+
`);this.output.write(o[s]),this._prevFrame=e,this.output.write(ue.cursor.move(0,o.length-s-1));return}else if(t.lines.length>1){if(i<r)s=i;else{let a=s-r;a>0&&this.output.write(ue.cursor.move(0,a))}this.output.write(ue.erase.down());let o=e.split(`
|
|
19
19
|
`).slice(s);this.output.write(o.join(`
|
|
20
|
-
`)),this._prevFrame=e;return}}this.output.write(
|
|
21
|
-
`),
|
|
22
|
-
`?(s&&(i+=
|
|
23
|
-
`&&(r&&m&&(i+=
|
|
20
|
+
`)),this._prevFrame=e;return}}this.output.write(ue.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function gt(e,t,n){let i=e+t,r=Math.max(n.length-1,0),s=i<0?r:i>r?0:i;return n[s].disabled?gt(s,t<0?-1:1,n):s}var bl,ue,xh=(e)=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,vh=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Sh=(e)=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,os,di,pi,as,mi,$h,_h,xl=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?xl(r,_h,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,f=n.emojiWidth??2,u=n.fullWidthWidth??2,d=n.regularWidth??1,g=n.wideWidth??2,h=0,p=0,m=e.length,v=0,w=!1,x=m,E=Math.max(0,i-s),A=0,_=0,S=0,k=0;e:for(;;){if(_>A||p>=m&&p>h){let R=e.slice(A,_)||e.slice(h,p);v=0;for(let U of R.replaceAll($h,"")){let D=U.codePointAt(0)||0;if(vh(D)?k=u:Sh(D)?k=g:c!==d&&xh(D)?k=c:k=d,S+k>E&&(x=Math.min(x,Math.max(A,h)+v)),S+k>i){w=!0;break e}v+=U.length,S+=k}A=_=0}if(p>=m)break;if(mi.lastIndex=p,mi.test(e)){if(v=mi.lastIndex-p,k=v*d,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/d))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=mi.lastIndex;continue}if(os.lastIndex=p,os.test(e)){if(S+o>E&&(x=Math.min(x,p)),S+o>i){w=!0;break}S+=o,A=h,_=p,p=h=os.lastIndex;continue}if(di.lastIndex=p,di.test(e)){if(v=di.lastIndex-p,k=v*a,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=di.lastIndex;continue}if(pi.lastIndex=p,pi.test(e)){if(v=pi.lastIndex-p,k=v*l,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=pi.lastIndex;continue}if(as.lastIndex=p,as.test(e)){if(S+f>E&&(x=Math.min(x,p)),S+f>i){w=!0;break}S+=f,A=h,_=p,p=h=as.lastIndex;continue}p+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},Eh,fn=(e,t={})=>xl(e,Eh,t).width,gi="\x1B",vl="",Ah=39,ds="\x07",Sl="[",kh="]",$l="m",ps,hl,Ih=(e)=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},gl=(e)=>`${gi}${Sl}${e}${$l}`,yl=(e)=>`${gi}${ps}${e}${ds}`,Th=(e)=>e.map((t)=>fn(t)),ls=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:fn(o),l=i.next(),c=i.next(),f=0;for(;!l.done;){let u=l.value,d=fn(u);a+d<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===gi||u===vl)&&(r=!0,s=t.startsWith(ps,f+1)),r?s?u===ds&&(r=!1,s=!1):u===$l&&(r=!1):(a+=d,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),f+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Mh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(fn(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Oh=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=Th(o),l=[""];for(let[h,p]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=fn(l.at(-1)??"");if(h!==0&&(m>=t&&(n.wordWrap===!1||n.trim===!1)&&(l.push(""),m=0),(m>0||n.trim===!1)&&(l[l.length-1]+=" ",m++)),n.hard&&a[h]>t){let v=t-m,w=1+Math.floor((a[h]-v-1)/t);Math.floor((a[h]-1)/t)<w&&l.push(""),ls(l,p,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){ls(l,p,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){ls(l,p,t);continue}l[l.length-1]+=p}n.trim!==!1&&(l=l.map((h)=>Mh(h)));let c=l.join(`
|
|
21
|
+
`),f=c[Symbol.iterator](),u=f.next(),d=f.next(),g=0;for(;!u.done;){let h=u.value,p=d.value;if(i+=h,h===gi||h===vl){hl.lastIndex=g+1;let v=hl.exec(c)?.groups;if(v?.code!==void 0){let w=Number.parseFloat(v.code);r=w===Ah?void 0:w}else v?.uri!==void 0&&(s=v.uri.length===0?void 0:v.uri)}let m=r?Ih(r):void 0;p===`
|
|
22
|
+
`?(s&&(i+=yl("")),r&&m&&(i+=gl(m))):h===`
|
|
23
|
+
`&&(r&&m&&(i+=gl(r)),s&&(i+=yl(s))),g+=h.length,u=d,d=f.next()}return i},Nh,Le,Rh,us,dn=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,hs=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20,gs,ys,bs,mn;var yi=T(()=>{bl=qt(un(),1),ue=qt(ss(),1),os=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,di=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pi=/\t{1,1000}/y,as=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,mi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$h=/\p{M}+/gu,_h={limit:1/0,ellipsis:""},Eh={limit:1/0,ellipsis:"",ellipsisWidth:0},ps=`${kh}8;;`,hl=new RegExp(`(?:\\${Sl}(?<code>\\d+)m|\\${ps}(?<uri>.*)${ds})`,"y");Nh=["up","down","left","right","space","enter","cancel"],Le={actions:new Set(Nh),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};Rh=globalThis.process.platform.startsWith("win"),us=Symbol("clack:cancel");gs=class gs extends pn{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(ue.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};ys=class ys extends pn{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter((e)=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map((n)=>n.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter((n)=>!e.includes(n.value));this.value=t.map((n)=>n.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:n})=>n===e.cursorAt),0);this.cursor=this.options[t].disabled?gt(t,1,this.options):t,this.on("key",(n)=>{n==="a"&&this.toggleAll(),n==="i"&&this.toggleInvert()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=gt(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=gt(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};bs=class bs extends pn{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:i})=>i===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n].disabled?gt(n,1,this.options):n,this.changeValue(),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=gt(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=gt(this.cursor,1,this.options);break}this.changeValue()})}};mn=class mn extends pn{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}█`;let t=e.slice(0,this.cursor),[n,...i]=e.slice(this.cursor);return`${t}${bl.default.inverse(n)}${i.join("")}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",(t)=>{this._setValue(t)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.value===void 0&&(this.value="")})}}});import xe from"node:process";function Lh(){return xe.platform!=="win32"?xe.env.TERM!=="linux":!!xe.env.CI||!!xe.env.WT_SESSION||!!xe.env.TERMINUS_SUBLIME||xe.env.ConEmuTask==="{cmd::Cmder}"||xe.env.TERM_PROGRAM==="Terminus-Sublime"||xe.env.TERM_PROGRAM==="vscode"||xe.env.TERM==="xterm-256color"||xe.env.TERM==="alacritty"||xe.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function yn(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
24
24
|
`,`
|
|
25
25
|
`).split(`
|
|
26
|
-
`).map((i)=>
|
|
27
|
-
`)}var
|
|
28
|
-
`),
|
|
29
|
-
`?(s&&(i+=
|
|
30
|
-
`&&(r&&m&&(i+=
|
|
31
|
-
`);w.push(k),x+=k.length}if(x>
|
|
32
|
-
${
|
|
33
|
-
`,r=this.value?t:n;switch(this.state){case"submit":return`${i}${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
`}}}).prompt()},
|
|
26
|
+
`).map((i)=>eg(i,t,n)).join(`
|
|
27
|
+
`)}var I,gn,Ss,Ph=()=>process.env.CI==="true",J=(e,t)=>Ss?e:t,Fh,Ol,Nl,Es,o2,K,Ut,a2,l2,$s,Si,Dh,El,Al,c2,kl,qh,Uh,jh,Gh,u2,f2,d2,p2,m2,$i=(e)=>{switch(e){case"initial":case"active":return I.default.cyan(Fh);case"cancel":return I.default.red(Ol);case"error":return I.default.yellow(Nl);case"submit":return I.default.green(Es)}},Cl=(e)=>{switch(e){case"initial":case"active":return I.default.cyan(K);case"cancel":return I.default.red(K);case"error":return I.default.yellow(K);case"submit":return I.default.green(K)}},Bh=(e)=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Vh=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Hh=(e)=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,ws,bi,wi,xs,xi,Kh,Wh,Rl=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?Rl(r,Wh,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,f=n.emojiWidth??2,u=n.fullWidthWidth??2,d=n.regularWidth??1,g=n.wideWidth??2,h=0,p=0,m=e.length,v=0,w=!1,x=m,E=Math.max(0,i-s),A=0,_=0,S=0,k=0;e:for(;;){if(_>A||p>=m&&p>h){let R=e.slice(A,_)||e.slice(h,p);v=0;for(let U of R.replaceAll(Kh,"")){let D=U.codePointAt(0)||0;if(Vh(D)?k=u:Hh(D)?k=g:c!==d&&Bh(D)?k=c:k=d,S+k>E&&(x=Math.min(x,Math.max(A,h)+v)),S+k>i){w=!0;break e}v+=U.length,S+=k}A=_=0}if(p>=m)break;if(xi.lastIndex=p,xi.test(e)){if(v=xi.lastIndex-p,k=v*d,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/d))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=xi.lastIndex;continue}if(ws.lastIndex=p,ws.test(e)){if(S+o>E&&(x=Math.min(x,p)),S+o>i){w=!0;break}S+=o,A=h,_=p,p=h=ws.lastIndex;continue}if(bi.lastIndex=p,bi.test(e)){if(v=bi.lastIndex-p,k=v*a,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=bi.lastIndex;continue}if(wi.lastIndex=p,wi.test(e)){if(v=wi.lastIndex-p,k=v*l,S+k>E&&(x=Math.min(x,p+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=p,p=h=wi.lastIndex;continue}if(xs.lastIndex=p,xs.test(e)){if(S+f>E&&(x=Math.min(x,p)),S+f>i){w=!0;break}S+=f,A=h,_=p,p=h=xs.lastIndex;continue}p+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},Yh,Fe=(e,t={})=>Rl(e,Yh,t).width,_i="\x1B",Ll="",Jh=39,As="\x07",Pl="[",zh="]",Fl="m",ks,Il,Xh=(e)=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Tl=(e)=>`${_i}${Pl}${e}${Fl}`,Ml=(e)=>`${_i}${ks}${e}${As}`,Qh=(e)=>e.map((t)=>Fe(t)),vs=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:Fe(o),l=i.next(),c=i.next(),f=0;for(;!l.done;){let u=l.value,d=Fe(u);a+d<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===_i||u===Ll)&&(r=!0,s=t.startsWith(ks,f+1)),r?s?u===As&&(r=!1,s=!1):u===Fl&&(r=!1):(a+=d,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),f+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Zh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(Fe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},eg=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=Qh(o),l=[""];for(let[h,p]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=Fe(l.at(-1)??"");if(h!==0&&(m>=t&&(n.wordWrap===!1||n.trim===!1)&&(l.push(""),m=0),(m>0||n.trim===!1)&&(l[l.length-1]+=" ",m++)),n.hard&&a[h]>t){let v=t-m,w=1+Math.floor((a[h]-v-1)/t);Math.floor((a[h]-1)/t)<w&&l.push(""),vs(l,p,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){vs(l,p,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){vs(l,p,t);continue}l[l.length-1]+=p}n.trim!==!1&&(l=l.map((h)=>Zh(h)));let c=l.join(`
|
|
28
|
+
`),f=c[Symbol.iterator](),u=f.next(),d=f.next(),g=0;for(;!u.done;){let h=u.value,p=d.value;if(i+=h,h===_i||h===Ll){Il.lastIndex=g+1;let v=Il.exec(c)?.groups;if(v?.code!==void 0){let w=Number.parseFloat(v.code);r=w===Jh?void 0:w}else v?.uri!==void 0&&(s=v.uri.length===0?void 0:v.uri)}let m=r?Xh(r):void 0;p===`
|
|
29
|
+
`?(s&&(i+=Ml("")),r&&m&&(i+=Tl(m))):h===`
|
|
30
|
+
`&&(r&&m&&(i+=Tl(r)),s&&(i+=Ml(s))),g+=h.length,u=d,d=f.next()}return i},tg=(e,t,n,i,r)=>{let s=t,o=0;for(let a=n;a<i;a++){let l=e[a];if(s=s-l.length,o++,s<=r)break}return{lineCount:s,removals:o}},_s=(e)=>{let{cursor:t,options:n,style:i}=e,r=e.output??process.stdout,s=dn(r),o=e.columnPadding??0,a=e.rowPadding??4,l=s-o,c=hs(r),f=I.default.dim("..."),u=e.maxItems??Number.POSITIVE_INFINITY,d=Math.max(c-a,0),g=Math.max(Math.min(u,d),5),h=0;t>=g-3&&(h=Math.max(Math.min(t-g+3,n.length-g),0));let p=g<n.length&&h>0,m=g<n.length&&h+g<n.length,v=Math.min(h+g,n.length),w=[],x=0;p&&x++,m&&x++;let E=h+(p?1:0),A=v-(m?1:0);for(let S=E;S<A;S++){let k=yn(i(n[S],S===t),l,{hard:!0,trim:!1}).split(`
|
|
31
|
+
`);w.push(k),x+=k.length}if(x>d){let S=0,k=0,R=x,U=t-E,D=(P,N)=>tg(w,R,P,N,d);p?({lineCount:R,removals:S}=D(0,U),R>d&&({lineCount:R,removals:k}=D(U+1,w.length))):({lineCount:R,removals:k}=D(U+1,w.length),R>d&&({lineCount:R,removals:S}=D(0,U))),S>0&&(p=!0,w.splice(0,S)),k>0&&(m=!0,w.splice(w.length-k,k))}let _=[];p&&_.push(f);for(let S of w)for(let k of S)_.push(k);return m&&_.push(f),_},Is=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new gs({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=`${I.default.gray(K)}
|
|
32
|
+
${$i(this.state)} ${e.message}
|
|
33
|
+
`,r=this.value?t:n;switch(this.state){case"submit":return`${i}${I.default.gray(K)} ${I.default.dim(r)}`;case"cancel":return`${i}${I.default.gray(K)} ${I.default.strikethrough(I.default.dim(r))}
|
|
34
|
+
${I.default.gray(K)}`;default:return`${i}${I.default.cyan(K)} ${this.value?`${I.default.green($s)} ${t}`:`${I.default.dim(Si)} ${I.default.dim(t)}`} ${I.default.dim("/")} ${this.value?`${I.default.dim(Si)} ${I.default.dim(n)}`:`${I.default.green($s)} ${n}`}
|
|
35
|
+
${I.default.cyan(Ut)}
|
|
36
|
+
`}}}).prompt()},hn=(e,t)=>e.split(`
|
|
37
37
|
`).map((n)=>t(n)).join(`
|
|
38
|
-
`),
|
|
39
|
-
${
|
|
38
|
+
`),ng=(e)=>{let t=(i,r)=>{let s=i.label??String(i.value);return r==="disabled"?`${I.default.gray(Al)} ${hn(s,(o)=>I.default.strikethrough(I.default.gray(o)))}${i.hint?` ${I.default.dim(`(${i.hint??"disabled"})`)}`:""}`:r==="active"?`${I.default.cyan(Dh)} ${s}${i.hint?` ${I.default.dim(`(${i.hint})`)}`:""}`:r==="selected"?`${I.default.green(El)} ${hn(s,I.default.dim)}${i.hint?` ${I.default.dim(`(${i.hint})`)}`:""}`:r==="cancelled"?`${hn(s,(o)=>I.default.strikethrough(I.default.dim(o)))}`:r==="active-selected"?`${I.default.green(El)} ${s}${i.hint?` ${I.default.dim(`(${i.hint})`)}`:""}`:r==="submitted"?`${hn(s,I.default.dim)}`:`${I.default.dim(Al)} ${hn(s,I.default.dim)}`},n=e.required??!0;return new ys({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:n,cursorAt:e.cursorAt,validate(i){if(n&&(i===void 0||i.length===0))return`Please select at least one option.
|
|
39
|
+
${I.default.reset(I.default.dim(`Press ${I.default.gray(I.default.bgWhite(I.default.inverse(" space ")))} to select, ${I.default.gray(I.default.bgWhite(I.default.inverse(" enter ")))} to submit`))}`},render(){let i=yt(e.output,e.message,`${Cl(this.state)} `,`${$i(this.state)} `),r=`${I.default.gray(K)}
|
|
40
40
|
${i}
|
|
41
|
-
`,s=this.value??[],o=(a,l)=>{if(a.disabled)return t(a,"disabled");let c=s.includes(a.value);return l&&c?t(a,"active-selected"):c?t(a,"selected"):t(a,l?"active":"inactive")};switch(this.state){case"submit":{let a=this.options.filter(({value:c})=>s.includes(c)).map((c)=>t(c,"submitted")).join(
|
|
42
|
-
${
|
|
43
|
-
`).map((u,
|
|
41
|
+
`,s=this.value??[],o=(a,l)=>{if(a.disabled)return t(a,"disabled");let c=s.includes(a.value);return l&&c?t(a,"active-selected"):c?t(a,"selected"):t(a,l?"active":"inactive")};switch(this.state){case"submit":{let a=this.options.filter(({value:c})=>s.includes(c)).map((c)=>t(c,"submitted")).join(I.default.dim(", "))||I.default.dim("none"),l=yt(e.output,a,`${I.default.gray(K)} `);return`${r}${l}`}case"cancel":{let a=this.options.filter(({value:c})=>s.includes(c)).map((c)=>t(c,"cancelled")).join(I.default.dim(", "));if(a.trim()==="")return`${r}${I.default.gray(K)}`;let l=yt(e.output,a,`${I.default.gray(K)} `);return`${r}${l}
|
|
42
|
+
${I.default.gray(K)}`}case"error":{let a=`${I.default.yellow(K)} `,l=this.error.split(`
|
|
43
|
+
`).map((u,d)=>d===0?`${I.default.yellow(Ut)} ${I.default.yellow(u)}`:` ${u}`).join(`
|
|
44
44
|
`),c=r.split(`
|
|
45
|
-
`).length,
|
|
46
|
-
`).length+1;return`${r}${a}${
|
|
45
|
+
`).length,f=l.split(`
|
|
46
|
+
`).length+1;return`${r}${a}${_s({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:c+f,style:o}).join(`
|
|
47
47
|
${a}`)}
|
|
48
48
|
${l}
|
|
49
|
-
`}default:{let a=`${
|
|
50
|
-
`).length;return`${r}${a}${
|
|
49
|
+
`}default:{let a=`${I.default.cyan(K)} `,l=r.split(`
|
|
50
|
+
`).length;return`${r}${a}${_s({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:l+2,style:o}).join(`
|
|
51
51
|
${a}`)}
|
|
52
|
-
${
|
|
53
|
-
`}}}}).prompt()},
|
|
54
|
-
`),s=r.reduce((l,c)=>Math.max(
|
|
55
|
-
`).map(s),""],a=
|
|
56
|
-
`),
|
|
57
|
-
`:"",u=r?
|
|
52
|
+
${I.default.cyan(Ut)}
|
|
53
|
+
`}}}}).prompt()},ig=(e)=>I.default.dim(e),rg=(e,t,n)=>{let i={hard:!0,trim:!1},r=yn(e,t,i).split(`
|
|
54
|
+
`),s=r.reduce((l,c)=>Math.max(Fe(c),l),0),o=r.map(n).reduce((l,c)=>Math.max(Fe(c),l),0),a=t-(o-s);return yn(e,a,i)},sg=(e="",t="",n)=>{let i=n?.output??xe.stdout,r=(n?.withGuide??Le.withGuide)!==!1,s=n?.format??ig,o=["",...rg(e,dn(i)-6,s).split(`
|
|
55
|
+
`).map(s),""],a=Fe(t),l=Math.max(o.reduce((d,g)=>{let h=Fe(g);return h>d?h:d},0),a)+2,c=o.map((d)=>`${I.default.gray(K)} ${d}${" ".repeat(l-Fe(d))}${I.default.gray(K)}`).join(`
|
|
56
|
+
`),f=r?`${I.default.gray(K)}
|
|
57
|
+
`:"",u=r?Uh:Gh;i.write(`${f}${I.default.green(Es)} ${I.default.reset(t)} ${I.default.gray(kl.repeat(Math.max(l-a-1,1))+qh)}
|
|
58
58
|
${c}
|
|
59
|
-
${
|
|
60
|
-
`)},
|
|
61
|
-
`);let
|
|
62
|
-
`);
|
|
63
|
-
`);let L=0,
|
|
64
|
-
`):n.write(`${
|
|
65
|
-
`)),S(),
|
|
59
|
+
${I.default.gray(u+kl.repeat(l+2)+jh)}
|
|
60
|
+
`)},og,Dl=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:i,errorMessage:r,frames:s=Ss?["◒","◐","◓","◑"]:["•","o","O","0"],delay:o=Ss?80:120,signal:a,...l}={})=>{let c=Ph(),f,u,d=!1,g=!1,h="",p,m=performance.now(),v=dn(n),w=l?.styleFrame??og,x=(N)=>{let L=N>1?r??Le.messages.error:i??Le.messages.cancel;g=N===1,d&&(P(L,N),g&&typeof t=="function"&&t())},E=()=>x(2),A=()=>x(1),_=()=>{process.on("uncaughtExceptionMonitor",E),process.on("unhandledRejection",E),process.on("SIGINT",A),process.on("SIGTERM",A),process.on("exit",x),a&&a.addEventListener("abort",A)},S=()=>{process.removeListener("uncaughtExceptionMonitor",E),process.removeListener("unhandledRejection",E),process.removeListener("SIGINT",A),process.removeListener("SIGTERM",A),process.removeListener("exit",x),a&&a.removeEventListener("abort",A)},k=()=>{if(p===void 0)return;c&&n.write(`
|
|
61
|
+
`);let N=yn(p,v,{hard:!0,trim:!1}).split(`
|
|
62
|
+
`);N.length>1&&n.write(gn.cursor.up(N.length-1)),n.write(gn.cursor.to(0)),n.write(gn.erase.down())},R=(N)=>N.replace(/\.+$/,""),U=(N)=>{let L=(performance.now()-N)/1000,Y=Math.floor(L/60),we=Math.floor(L%60);return Y>0?`[${Y}m ${we}s]`:`[${we}s]`},D=(N="")=>{d=!0,f=_l({output:n}),h=R(N),m=performance.now(),n.write(`${I.default.gray(K)}
|
|
63
|
+
`);let L=0,Y=0;_(),u=setInterval(()=>{if(c&&h===p)return;k(),p=h;let we=w(s[L]),We;if(c)We=`${we} ${h}...`;else if(e==="timer")We=`${we} ${h} ${U(m)}`;else{let Bm=".".repeat(Math.floor(Y)).slice(0,3);We=`${we} ${h}${Bm}`}let Gm=yn(We,v,{hard:!0,trim:!1});n.write(Gm),L=L+1<s.length?L+1:0,Y=Y<4?Y+0.125:0},o)},P=(N="",L=0,Y=!1)=>{if(!d)return;d=!1,clearInterval(u),k();let we=L===0?I.default.green(Es):L===1?I.default.red(Ol):I.default.red(Nl);h=N??h,Y||(e==="timer"?n.write(`${we} ${h} ${U(m)}
|
|
64
|
+
`):n.write(`${we} ${h}
|
|
65
|
+
`)),S(),f()};return{start:D,stop:(N="")=>P(N,0),message:(N="")=>{h=R(N??h)},cancel:(N="")=>P(N,1),error:(N="")=>P(N,2),clear:()=>P("",0,!0),get isCancelled(){return g}}},h2,vi=(e,t)=>e.includes(`
|
|
66
66
|
`)?e.split(`
|
|
67
67
|
`).map((n)=>t(n)).join(`
|
|
68
|
-
`):t(e),
|
|
68
|
+
`):t(e),bn=(e)=>{let t=(n,i)=>{let r=n.label??String(n.value);switch(i){case"disabled":return`${I.default.gray(Si)} ${vi(r,I.default.gray)}${n.hint?` ${I.default.dim(`(${n.hint??"disabled"})`)}`:""}`;case"selected":return`${vi(r,I.default.dim)}`;case"active":return`${I.default.green($s)} ${r}${n.hint?` ${I.default.dim(`(${n.hint})`)}`:""}`;case"cancelled":return`${vi(r,(s)=>I.default.strikethrough(I.default.dim(s)))}`;default:return`${I.default.dim(Si)} ${vi(r,I.default.dim)}`}};return new bs({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=`${$i(this.state)} `,i=`${Cl(this.state)} `,r=yt(e.output,e.message,i,n),s=`${I.default.gray(K)}
|
|
69
69
|
${r}
|
|
70
|
-
`;switch(this.state){case"submit":{let o=`${
|
|
71
|
-
${
|
|
72
|
-
`).length;return`${s}${o}${
|
|
70
|
+
`;switch(this.state){case"submit":{let o=`${I.default.gray(K)} `,a=yt(e.output,t(this.options[this.cursor],"selected"),o);return`${s}${a}`}case"cancel":{let o=`${I.default.gray(K)} `,a=yt(e.output,t(this.options[this.cursor],"cancelled"),o);return`${s}${a}
|
|
71
|
+
${I.default.gray(K)}`}default:{let o=`${I.default.cyan(K)} `,a=s.split(`
|
|
72
|
+
`).length;return`${s}${o}${_s({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:o.length,rowPadding:a+2,style:(l,c)=>t(l,l.disabled?"disabled":c?"active":"inactive")}).join(`
|
|
73
73
|
${o}`)}
|
|
74
|
-
${
|
|
75
|
-
`}}}}).prompt()},
|
|
76
|
-
`:""}${
|
|
77
|
-
`,i=e.placeholder?
|
|
74
|
+
${I.default.cyan(Ut)}
|
|
75
|
+
`}}}}).prompt()},g2,Ts=(e)=>new mn({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=(e?.withGuide??Le.withGuide)!==!1,n=`${`${t?`${I.default.gray(K)}
|
|
76
|
+
`:""}${$i(this.state)} `}${e.message}
|
|
77
|
+
`,i=e.placeholder?I.default.inverse(e.placeholder[0])+I.default.dim(e.placeholder.slice(1)):I.default.inverse(I.default.hidden("_")),r=this.userInput?this.userInputWithCursor:i,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${I.default.yellow(this.error)}`:"",a=t?`${I.default.yellow(K)} `:"",l=t?I.default.yellow(Ut):"";return`${n.trim()}
|
|
78
78
|
${a}${r}
|
|
79
79
|
${l}${o}
|
|
80
|
-
`}case"submit":{let o=s?` ${
|
|
81
|
-
${a}`:""}`}default:{let o=t?`${
|
|
80
|
+
`}case"submit":{let o=s?` ${I.default.dim(s)}`:"",a=t?I.default.gray(K):"";return`${n}${a}${o}`}case"cancel":{let o=s?` ${I.default.strikethrough(I.default.dim(s))}`:"",a=t?I.default.gray(K):"";return`${n}${a}${o}${s.trim()?`
|
|
81
|
+
${a}`:""}`}default:{let o=t?`${I.default.cyan(K)} `:"",a=t?I.default.cyan(Ut):"";return`${n}${o}${r}
|
|
82
82
|
${a}
|
|
83
|
-
`}}}}).prompt();var
|
|
84
|
-
${
|
|
85
|
-
${s} ${
|
|
86
|
-
${
|
|
87
|
-
${s} ${
|
|
88
|
-
${
|
|
89
|
-
${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
${
|
|
93
|
-
${
|
|
83
|
+
`}}}}).prompt();var ke=T(()=>{yi();yi();I=qt(un(),1),gn=qt(ss(),1);Ss=Lh(),Fh=J("◆","*"),Ol=J("■","x"),Nl=J("▲","x"),Es=J("◇","o"),o2=J("┌","T"),K=J("│","|"),Ut=J("└","—"),a2=J("┐","T"),l2=J("┘","—"),$s=J("●",">"),Si=J("○"," "),Dh=J("◻","[•]"),El=J("◼","[+]"),Al=J("◻","[ ]"),c2=J("▪","•"),kl=J("─","-"),qh=J("╮","+"),Uh=J("├","+"),jh=J("╯","+"),Gh=J("╰","+"),u2=J("╭","+"),f2=J("●","•"),d2=J("◆","*"),p2=J("▲","!"),m2=J("■","x"),ws=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,bi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,wi=/\t{1,1000}/y,xs=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,xi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Kh=/\p{M}+/gu,Wh={limit:1/0,ellipsis:""},Yh={limit:1/0,ellipsis:"",ellipsisWidth:0},ks=`${zh}8;;`,Il=new RegExp(`(?:\\${Pl}(?<code>\\d+)m|\\${ks}(?<uri>.*)${As})`,"y");og=I.default.magenta,h2={light:J("─","-"),heavy:J("━","="),block:J("█","#")},g2=`${I.default.gray(K)} `});async function Ie(e){if(!Q())return;let{defaultValue:t,message:n}=e,i=await Promise.resolve().then(() => (ke(),{})),r=await Ts({message:n,default:t,placeholder:t});if(typeof r==="symbol")return;return r}function ag(e){if(e.length<=ql)return e;return`${e.slice(0,ql)}.... (${e.length} chars)`}async function Ul(e){if(!Q())return;await Promise.resolve().then(() => yi());let n=await new mn({render(){let i=ag(this.userInput),r=fe.default.inverse(fe.default.hidden("_")),s=fe.default.gray("│");switch(this.state){case"submit":return`${s}
|
|
84
|
+
${fe.default.green("◇")} ${e.message}
|
|
85
|
+
${s} ${fe.default.dim(i)}`;case"cancel":return`${s}
|
|
86
|
+
${fe.default.red("■")} ${e.message}
|
|
87
|
+
${s} ${fe.default.strikethrough(fe.default.dim(i))}`;case"error":return`${s}
|
|
88
|
+
${fe.default.yellow("▲")} ${e.message}
|
|
89
|
+
${fe.default.yellow("│")} ${i}${r}
|
|
90
|
+
${fe.default.yellow("└")} ${fe.default.yellow(this.error)}`;default:return`${s}
|
|
91
|
+
${fe.default.cyan("◆")} ${e.message}
|
|
92
|
+
${fe.default.cyan("│")} ${i}${r}
|
|
93
|
+
${fe.default.cyan("└")}`}}}).prompt();if(typeof n==="symbol")return;return n}async function jl(e,t){if(!Q())return t();await Promise.resolve().then(() => ke());let i=Dl();i.start(e.message);try{let r=await t();return i.stop(e.successMessage),r}catch(r){throw i.error(e.errorMessage),r}}async function wn(e){if(!Q())return;let{message:t}=e,n=await Promise.resolve().then(() => (ke(),{})),i=await Is({message:t});if(typeof i==="symbol")return;return i}async function bt(e){if(!Q())return;let t=await Promise.resolve().then(() => (ke(),{}));sg(e.message,e.title)}async function Ei(e){if(!Q())return;let t=await Promise.resolve().then(() => (ke(),{})),n=await bn({message:e.message,options:e.choices,initialValue:e.initialValue});if(typeof n==="symbol")return;return n}async function Ms(e){if(!Q())return;let t=await Promise.resolve().then(() => (ke(),{})),n=await ng({message:e.message,options:e.choices,initialValues:e.initialValues,required:e.required});if(typeof n==="symbol")return;return n}function wt(e,t){throw new y(`Missing required argument: --${e}
|
|
94
94
|
Hint: In non-interactive (CI / agent) environments all required flags must be provided.
|
|
95
|
-
In an interactive terminal, run without --${e} and the CLI will prompt for it.`,b.USAGE,t)}async function
|
|
96
|
-
`),process.exit(1);return t}
|
|
95
|
+
In an interactive terminal, run without --${e} and the CLI will prompt for it.`,b.USAGE,t)}async function jt(e){if(e.value)return e.value;if(Q({nonInteractive:e.nonInteractive})){let t=await Ie({message:e.message});if(!t)process.stderr.write(e.cancelMessage+`
|
|
96
|
+
`),process.exit(1);return t}wt(e.flagName,e.usageHint)}var fe,ql=30;var De=T(()=>{G();j();fe=qt(un(),1)});function he(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}async function Bl(e){let t=li[e],{randomBytes:n,createHash:i}=await import("crypto"),r=n(32).toString("base64url"),s=i("sha256").update(r).digest("base64url"),o=n(16).toString("base64url"),a=await fetch(`${t}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Gl,scope:cg.join(" "),code_challenge:s,code_challenge_method:"S256",state:o})});if(!a.ok){let u=await a.text().catch(()=>"");throw new y(`Failed to start device-code flow (HTTP ${a.status}).`,b.AUTH,u||`URL: ${t}/oauth2/device/code`)}let l=await a.json();if(l.state!==o)throw new y("OAuth state mismatch.",b.AUTH);fg(l.verification_uri),process.stderr.write(`
|
|
97
97
|
Opened: ${l.verification_uri}
|
|
98
98
|
`),process.stderr.write(`Code: ${l.user_code}
|
|
99
|
-
`),process.stderr.write(`Client: ${
|
|
99
|
+
`),process.stderr.write(`Client: ${lg}
|
|
100
100
|
`),process.stderr.write(`Waiting for authorization...
|
|
101
|
-
`);let c=l.expired_in,
|
|
102
|
-
${
|
|
103
|
-
`)});function
|
|
101
|
+
`);let c=l.expired_in,f=l.interval||3000;while(Date.now()<c){await ug(f);let u=await fetch(`${t}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:Gl,user_code:l.user_code,code_verifier:r})});if(!u.ok)throw new y(`Device-code authorization failed (HTTP ${u.status}).`,b.AUTH);let d=await u.json();if(d.status==="pending")continue;if(d.status==="success"&&d.access_token)return{access_token:d.access_token,refresh_token:d.refresh_token??"",expires_at:new Date(d.expired_in??Date.now()).toISOString(),region:e,resource_url:d.resource_url};throw new y(`Device-code authorization failed: ${d.status}`,b.AUTH)}throw new y("Device-code authorization timed out.",b.TIMEOUT)}function ug(e){return new Promise((t)=>setTimeout(t,e))}function fg(e){let{execFile:t,spawn:n}=ln("child_process");if(process.platform==="darwin")t("open",[e]);else if(process.platform==="win32")n("cmd.exe",["/c","start","",e],{shell:!1,detached:!0});else t("xdg-open",[e])}var Gl="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",lg="MiniMax CLI",cg;var Vl=T(()=>{Ee();G();j();cg=["openid","profile","coding_plan"]});async function ge(){return Z().oauth??null}async function Ai(e,t=de()){let n=Z(t);n.oauth=e,await pe(n,void 0,t)}async function Hl(){let e=Z();if(!("oauth"in e))return;delete e.oauth,await pe(e)}var Ze=T(()=>{Re();Xe()});function ki(e){return`Looked for credentials in: ${e??de()}
|
|
102
|
+
${dg}`}var dg;var Os=T(()=>{Xe();dg=["Log in: mmx auth login","Pass per-call: --api-key sk-xxxxx","Or set env var: MMX_CONFIG_DIR=/path/to/.mmx"].join(`
|
|
103
|
+
`)});function Gt(e){return e.replace(/^https?:\/\//,"")}async function Wl(e){if(e.apiKey||e.fileApiKey)return;if(await ge())return;let t=process.env.MINIMAX_API_KEY;if(t){if(!Q({nonInteractive:e.nonInteractive}))return;if(await wn({message:`Found MINIMAX_API_KEY in environment (${he(t)}). Save to config file?`}))await Kl(e,t);return}if(!Q({nonInteractive:e.nonInteractive}))throw new y("No credentials found.",b.AUTH,ki(e.configPath));let n=await Ns();if(n==="api-key"){let i=await Ie({message:"Enter your MiniMax API key:"});if(!i)throw new y("API key is required.",b.AUTH);await Kl(e,i);return}await Cs(n==="oauth-cn"?"cn":"global")}async function Ns(){await Promise.resolve().then(() => ke());let n=await bn({message:"How would you like to authenticate?",options:pg.map((i)=>({value:i.value,label:i.label}))});if(Pe(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Yl(){await Promise.resolve().then(() => ke());let n=await bn({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${Gt(ne.global)}`},{value:"cn",label:`China → ${Gt(ne.cn)}`}]});if(Pe(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Cs(e){let t=await Bl(e),n=Z();delete n.api_key,n.oauth=t,n.region=e,await pe(n),process.stderr.write(`Logged in successfully.
|
|
104
104
|
`),process.stderr.write(`Credentials saved to ~/.mmx/config.json
|
|
105
|
-
`)}async function
|
|
106
|
-
`)}var
|
|
107
|
-
Re-authenticate: mmx auth login`)}async function
|
|
105
|
+
`)}async function Kl(e,t){let n={...Z(),api_key:t};await pe(n),e.fileApiKey=t,process.stderr.write(`API key saved to ${e.configPath??"~/.mmx/config.json"}
|
|
106
|
+
`)}var pg;var Rs=T(()=>{Ee();Re();De();G();j();Vl();Ze();Os();pg=[{value:"oauth-global",label:`MiniMax (OAuth login → ${Gt(ne.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${Gt(ne.cn)})`},{value:"api-key",label:`API key (${Gt(ne.global)} or ${Gt(ne.cn)})`}]});import{resolve as mg}from"path";async function Ps(e,t="global"){let n=`${li[t]}/oauth2/token`,i=null;for(let r=0;r<=Jl;r++){if(r>0)await new Promise((a)=>setTimeout(a,gg*r));let s;try{s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:hg}),signal:AbortSignal.timeout(yg)})}catch(a){let l=a instanceof Error&&(a.name==="AbortError"||a.name==="TimeoutError"||a.message.includes("timed out"));i=Error(l?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${a instanceof Error?a.message:String(a)}`);continue}if(!s.ok){if(s.status>=400&&s.status<500)throw new y("OAuth session expired and could not be refreshed.",b.AUTH,"Re-authenticate: mmx auth login");i=Error(`Token refresh failed: HTTP ${s.status}`);continue}let o=await s.json();if(o.status!=="success"||!o.access_token)throw new y(`OAuth refresh failed: ${o.status}.`,b.AUTH,"Re-authenticate: mmx auth login");return{access_token:o.access_token,refresh_token:o.refresh_token??e,expires_at:new Date(o.expired_in??Date.now()).toISOString(),resource_url:o.resource_url}}throw new y(`Token refresh failed after ${Jl+1} attempts: ${i?.message}`,b.AUTH,`Check your network connection.
|
|
107
|
+
Re-authenticate: mmx auth login`)}async function zl(e){let t=new Date(e.expires_at).getTime();if(Date.now()<t-bg)return e.access_token;let n=mg(de()),i=JSON.stringify([n,e.region??"global",e.refresh_token]),r=Ls.get(i);if(r)return r;let s=(async()=>{let o=await Ps(e.refresh_token,e.region??"global"),a={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:o.expires_at,region:e.region,resource_url:o.resource_url??e.resource_url,account:e.account};return await Ai(a,n),a.access_token})();Ls.set(i,s);try{return await s}finally{Ls.delete(i)}}var hg="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Jl=2,gg=500,yg=1e4,bg=300000,Ls;var Fs=T(()=>{Ee();Xe();Ze();G();j();Ls=new Map});async function Bt(e){if(e.apiKey)return{token:e.apiKey,method:"api-key",source:"flag"};let t=await ge();if(t)return{token:await zl(t),method:"oauth",source:"config.json"};if(e.fileApiKey)return{token:e.fileApiKey,method:"api-key",source:"config.json"};throw new y("No credentials found.",b.AUTH,ki(e.configPath))}var Ii=T(()=>{Ze();Fs();G();j();Os()});function Xl(e){if(!e)return"";if(e.includes("/t2a"))return`
|
|
108
108
|
|
|
109
109
|
Speech models require the Plus plan or above.`;if(e.includes("/image_generation"))return`
|
|
110
110
|
|
|
111
111
|
image-01 requires the Plus plan or above.`;if(e.includes("/video_generation")||e.includes("/query/video_generation"))return`
|
|
112
112
|
|
|
113
|
-
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function
|
|
114
|
-
`):void 0}function
|
|
115
|
-
${i.hint}`:r)}function
|
|
113
|
+
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function Ds(e){return`${e?.includes("api.minimax.cn")||e?.includes("api.minimaxi.com")?"https://platform.minimax.cn":"https://platform.minimax.io"}/subscribe/token-plan`}function wg(e){if(!Array.isArray(e.data))return;let n=e.data.flatMap((i,r)=>i?.error?[`Image ${r+1}${i.error.code!==void 0?` (${i.error.code})`:""}: ${i.error.message??"unknown error"}`]:[]);return n.length>0?n.join(`
|
|
114
|
+
`):void 0}function xn(e,t,n){let i=xg(e,t,n),r=n?.includes("/v1/images/")?wg(t):void 0;if(!r)return i;return new y(i.message,i.exitCode,i.hint?`${r}
|
|
115
|
+
${i.hint}`:r)}function xg(e,t,n){let i=t.base_resp?.status_msg||t.error?.message||`HTTP ${e}`,r=n?.includes("/v1/images/")?t.error?.message?.match(/\((\d{4})\)\s*$/)?.[1]:void 0,s=t.base_resp?.status_code||t.error?.code||(r?Number(r):void 0),o=t.error?.type;if(e===401||e===403)return new y(`API key rejected (HTTP ${e}).`,b.AUTH,`Check status: mmx auth status
|
|
116
116
|
Re-authenticate: mmx auth login`);if(e===429||s===1002&&n?.includes("/v1/images/"))return new y(`Rate limit or quota exceeded. ${i}`,b.QUOTA,"Check usage: mmx quota show");if(s===2068&&n?.includes("/v1/images/"))return new y(`This model is not available on your current plan. ${i}`,b.QUOTA,`Check usage: mmx quota show
|
|
117
|
-
Upgrade plan: ${
|
|
118
|
-
Upgrade plan: ${
|
|
119
|
-
Upgrade plan: ${
|
|
120
|
-
`)}var
|
|
117
|
+
Upgrade plan: ${Ds(n)}`);if(e===402||o==="insufficient_balance_error")return new y(`Quota or balance exhausted. ${i}`,b.QUOTA,"Check your MiniMax account balance and billing settings.");if(e===408||e===504)return new y(`Request timed out (HTTP ${e}).`,b.TIMEOUT,"Try increasing --timeout or retry later.");if(e===422&&n?.includes("/speech_to_text"))return new y(`Input audio flagged by sensitivity filter${i?` (${i})`:""}.`,b.CONTENT_FILTER);if(e===413&&n?.includes("/speech_to_text"))return new y(`Audio file exceeds the speech-to-text size limit (HTTP 413). ${i}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.");let a=e===422&&o==="unprocessable_entity_error"&&(/sensitive content/i.test(i)||/(?:^|\D)1026(?:\D|$)/.test(i));if(s===1002||s===1039||s===1026||a){let l=t.base_resp?.status_msg||t.error?.message||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${l}).`,b.CONTENT_FILTER)}if(s===1028||s===1030){let l=Xl(n);return new y(`Quota exhausted. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
|
|
118
|
+
Upgrade plan: ${Ds(n)}`)}if(s===2061){let l=Xl(n);return new y(`This model is not available on your current Token Plan. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
|
|
119
|
+
Upgrade plan: ${Ds(n)}`)}if(s===1027||/output.*sensitive/i.test(i))return new y(`Output withheld by content moderation (${i}).`,b.CONTENT_FILTER,"Refine your query and try again.");return new y(`API error: ${i} (HTTP ${e})`,b.GENERAL)}var qs=T(()=>{G();j()});import{homedir as Ql}from"os";function Ag(e){return e.startsWith(Ql())?e.replace(Ql(),"~"):e}function kg(e){return e.replace(/^https?:\/\//,"")}function ec(e,t,n){if(e.quiet||Zl||!process.stderr.isTTY)return;Zl=!0;let i=e.configPath?Ag(e.configPath):"~/.mmx/config.json",r=kg(e.baseUrl),s=e.apiKey?"(flag)":"(file)",o=he(t),a=n?` ${et}|${ve} ${et}Model:${ve} ${$g}${n}${ve}`:"";process.stderr.write(`${vg}${Sg}MINIMAX${ve} ${et}${i}${ve} ${et}|${ve} ${et}URL:${ve} ${_g}${r}${ve} ${et}|${ve} ${et}Key:${ve} ${Eg}${o}${ve} ${et}${s}${ve}${a}
|
|
120
|
+
`)}var Zl=!1,ve="\x1B[0m",et="\x1B[2m",vg="\x1B[1m",Sg="\x1B[38;2;43;82;255m",$g="\x1B[38;2;147;51;234m",_g="\x1B[38;2;6;184;212m",Eg="\x1B[38;2;236;72;153m";var tc=()=>{};var nc=()=>{};var xt="1.0.31";var Ti=T(()=>{nc()});function ic(e){return new DOMException(e,"TimeoutError")}function Ig(e,t,n){if(!e.body)return e;let i=e.body.getReader(),r=!1,s=()=>{if(r)return;r=!0,i.releaseLock()},o=async(c)=>{if(!n.signal.aborted)n.abort(c);try{await i.cancel(c)}finally{s()}},a=new ReadableStream({async pull(c){let f;try{let u=await new Promise((d,g)=>{f=setTimeout(()=>{let h=ic(`Stream received no data for ${t}ms.`);n.abort(h),g(h)},t),i.read().then(d,g)});if(u.done)s(),c.close();else c.enqueue(u.value)}catch(u){await o(u).catch(()=>{}),c.error(u)}finally{if(f)clearTimeout(f)}},cancel(c){return o(c)}}),l=new Response(a,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function qe(e,t){let n=typeof FormData<"u"&&t.body instanceof FormData,i={"User-Agent":`mmx-cli/${xt}`,...t.headers};if(!n&&!i["Content-Type"])i["Content-Type"]="application/json";if(!t.noAuth){let l=await Bt(e);if(t.authStyle==="x-api-key")i["x-api-key"]=l.token;else i.Authorization=`Bearer ${l.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
|
|
121
121
|
`),process.stderr.write(`> Auth: ${l.token.slice(0,8)}...
|
|
122
|
-
`);let c=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;
|
|
123
|
-
`);if(!a.ok){let l={};try{l=await a.json()}catch{}throw
|
|
122
|
+
`);let c=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;ec(e,l.token,c)}let r=(t.timeout??e.timeout)*1000,s=t.stream?new AbortController:void 0,o=s?setTimeout(()=>{s.abort(ic(`Request headers were not received within ${r}ms.`))},r):void 0,a;try{a=await fetch(t.url,{method:t.method??"GET",headers:i,body:t.body?n?t.body:JSON.stringify(t.body):void 0,signal:s?.signal??AbortSignal.timeout(r)})}finally{if(o)clearTimeout(o)}if(s)a=Ig(a,r,s);if(e.verbose)process.stderr.write(`< ${a.status} ${a.statusText}
|
|
123
|
+
`);if(!a.ok){let l={};try{l=await a.json()}catch{}throw xn(a.status,l,t.url)}return a}async function q(e,t){let n=await qe(e,t),i;try{i=await n.json()}catch{let r=n.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${r||"unknown type"}). Server may be experiencing issues.`,b.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw xn(200,{base_resp:i.base_resp},t.url);return i}var oe=T(()=>{G();j();Ii();qs();tc();Ti()});function Mi(e){return`${e}/anthropic/v1/messages`}function rc(e){return`${e}/v1/t2a_v2`}function sc(e){return`${e}/v1/speech_to_text`}function oc(e){return`${e}/v1/get_voice`}function ac(e){return`${e}/v1/image_generation`}function lc(e){return`${e}/v1/images/generations`}function cc(e){return`${e}/v1/images/edits`}function uc(e){return`${e}/v1/video_generation`}function fc(e){return`${e}/v2/video_generation`}function Oi(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function Ni(e,t){return`${e}/v2/query/video_generation/${t}`}function Ci(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function dc(e){return`${e}/v1/coding_plan/search`}function pc(e){return`${e}/v1/coding_plan/vlm`}function vn(e){return`${e}/v1/token_plan/remains`}function Tg(e){return`${e}/account/query_balance`}function Us(e){return e.startsWith("sk-api-")}function js(e,t){if(t.method==="api-key"&&Us(t.token))return{url:Tg(e),kind:"account-balance"};return{url:vn(e),kind:"quota"}}function tt(e,t){return js(e,{token:t,method:"api-key"}).url}function mc(e){return`${e}/v1/files/upload`}function hc(e){return`${e}/v1/files/list`}function gc(e){return`${e}/v1/files/delete`}function Mg(e){return e?"on":"off"}function yc(e,t){if(console.log("Account Balance:"),console.log(` Available: ${e.available_amount}`),console.log(` Cash: ${e.cash_balance}`),console.log(` Voucher: ${e.voucher_balance}`),console.log(` Credit: ${e.credit_balance}`),console.log(` Owed: ${e.owed_amount}`),console.log(` Alert: ${Mg(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Ri(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0||e<0||e>t)return;let i=e;if(n!==void 0&&n!==null&&Number.isFinite(n)){let r=e/t*100,s=(t-e)/t*100,o=Math.abs(r-n),a=Math.abs(s-n);if(Math.min(o,a)>1)return;if(a<o)i=t-e}return{used:t-i,remaining:i,total:t}}function Ac(e){if(e>=50)return[Sc,_c];if(e>=20)return[Cg,Rg];return[$c,Lg]}function qg(e,t){if(t!=="cn")return e;return Dg[e]??e}function Ug(e,t){if(e<=0)return t;if(e<60000)return`${Math.max(1,Math.floor(e/1000))}s`;let n=Math.floor(e/3600000),i=Math.floor(e%3600000/60000);return n>0?`${n}h ${i}m`:`${i}m`}function jg(e){if(e<=0)return"";if(e%604800000===0)return`${e/604800000}w`;if(e%86400000===0)return`${e/86400000}d`;if(e>=3600000)return`${Math.round(e/3600000)}h`;return`${Math.max(1,Math.round(e/60000))}m`}function bc(e){return new Date(e).toISOString().slice(0,10)}function Gg(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function Se(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let i of t)n+=Gg(i.codePointAt(0))?2:1;return n}function Hg(e){return e===3}function Kg(e){return e.current_interval_total_count===0&&e.current_weekly_total_count===0&&e.current_interval_status===3&&e.current_weekly_status===3}function Gs(e){return Math.max(0,Math.min(Vg,Math.round(e)))}function Wg(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Yg(e,t,n,i){let r=Wg(i);if(e!==void 0&&e!==null)return Gs(e*r);return n>0?Gs(t/n*100*r):0}function Jg(e,t,n=Bg,i=!0){let r=Gs(e),s=Math.min(1,r/100),o=Math.round(n*s),a=n-o,l=`${r}%`.padStart(4);if(!t){let d=`[${"█".repeat(o)}${".".repeat(a)}]`;return i?`${d} ${l}`:d}let[c,f]=Ac(r),u=`${f}${" ".repeat(o)}${te}${Ec}${" ".repeat(a)}${te}`;return i?`${u} ${c}${$n}${l}${te}`:u}function wc(e,t,n,i,r,s,o,a){if(o){let d=(a??zg).padStart(4);if(r){let h=`${_c}${" ".repeat(Sn)}${te}`;return`${Te}${e}${te} ${h} ${Sc}${$n}${d}${te}`}let g=`[${"█".repeat(Sn)}]`;return`${e} ${g} ${d}`}let l=Yg(i,t,n,s),c=Ri(t,n,i),f=Jg(l,r,Sn,c===void 0);if(c){let u=`${c.remaining.toLocaleString()} / ${c.total.toLocaleString()}`;return r?`${Te}${e}${te} ${f} ${Ac(l)[0]}${u}${te}`:`${e} ${f} ${u}`}return`${e} ${f}`}function xc(e,t,n){if(n){let i=`${Ec}${" ".repeat(Sn)}${te}`;return`${Te}${e}${te} ${i} ${$c}${$n}${t}${te}`}return`${e} [${".".repeat(Sn)}] ${t}`}function Li(e,t,n,i,r,s,o){if(s===void 0||o===void 0)return r?`${Te}${t}${n.repeat(e)}${i}${te}`:`+${"-".repeat(e)}+`;return r?`${Te}${t}${n.repeat(s-1)}${o}${n.repeat(e-s)}${i}${te}`:`+${"-".repeat(s-1)}+${"-".repeat(e-s)}+`}function vc(e,t,n,i){let r=Math.max(0,t-2-n);return i?`${Te}│${te} ${e}${" ".repeat(r)} ${Te}│${te}`:`| ${e}${" ".repeat(r)} |`}function kc(e,t){let n=!t.noColor&&process.stdout.isTTY===!0,i=t.region==="cn"?Fg:Pg,r=e.map((w)=>{let x=qg(w.model_name,t.region),E=Kg(w),A=E?xc(i.current,i.notInPlan,n):wc(i.current,w.current_interval_usage_count,w.current_interval_total_count,w.current_interval_remaining_percent,n),_=E?xc(i.weekly,i.notInPlan,n):wc(i.weekly,w.current_weekly_usage_count,w.current_weekly_total_count,w.current_weekly_remaining_percent,n,w.weekly_boost_permille,Hg(w.current_weekly_status),t.region==="cn"?Xg:Qg),S=E?"":jg(w.end_time-w.start_time),k=S?`${S} ${i.resetsIn}`:i.resetsIn,R=E?"—":Ug(w.remains_time,i.now),U=n?`${Te}${k}${te} ${R}`:`${k} ${R}`;return{displayName:x,current:A,weekly:_,reset:U}}),s=Math.max(6,...r.map((w)=>Se(w.displayName))),o=Math.max(...r.map((w)=>Se(w.current)),18),a=Math.max(...r.map((w)=>Se(w.weekly)),18),l=Math.max(...r.map((w)=>Se(w.reset)),10),c=s+2+o+2+a,f=c+3+l+2;if(f<72)c+=72-f,f=72;let u=c+3,d=e.length>0?`${bc(e[0].weekly_start_time)} — ${bc(e[0].weekly_end_time)}`:"",g=`MINIMAX ${i.dashboard}`,h=`${i.week}: ${d}`,p=Math.max(2,f-2-Se(g)-Se(h)),m=n?`${$n}${Og}MINIMAX${te} ${Te}${i.dashboard}${te}${" ".repeat(p)}${Te}${i.week}:${te} ${Ng}${d}${te}`:`${g}${" ".repeat(p)}${h}`,v=Se(g)+p+Se(h);if(console.log(""),console.log(Li(f,"╭","─","╮",n)),console.log(vc(m,f,v,n)),e.length===0){console.log(Li(f,"╰","─","╯",n)),console.log(`
|
|
124
124
|
${i.noData}
|
|
125
|
-
`);return}r.forEach((w,x)=>{console.log(
|
|
125
|
+
`);return}r.forEach((w,x)=>{console.log(Li(f,"├","─","┤",n,u,x===0?"┬":"┼"));let A=`${n?`${$n}${w.displayName}${te}`:w.displayName}${" ".repeat(Math.max(1,s-Se(w.displayName)+2))}${w.current}${" ".repeat(Math.max(1,o-Se(w.current)+2))}`+w.weekly,_=n?`${Te}│${te}`:"|",S=`${A}${" ".repeat(Math.max(0,c-Se(A)))} ${_} ${w.reset}`;console.log(vc(S,f,Se(S),n))}),console.log(Li(f,"╰","─","╯",n,u,"┴")),console.log("")}var te="\x1B[0m",$n="\x1B[1m",Te="\x1B[2m",Og="\x1B[38;2;43;82;255m",Ng="\x1B[38;2;6;184;212m",Sc="\x1B[38;2;74;222;128m",Cg="\x1B[38;2;250;204;21m",$c="\x1B[38;2;248;113;113m",_c="\x1B[48;2;22;163;74m",Rg="\x1B[48;2;202;138;4m",Lg="\x1B[48;2;220;38;38m",Ec="\x1B[48;2;55;65;81m",Pg,Fg,Dg,Bg=16,Sn=10,Vg=200,zg="∞",Xg="无限",Qg="unlimited";var Ic=T(()=>{Pg={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now",notInPlan:"not in plan"},Fg={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将",notInPlan:"不在当前套餐中"},Dg={general:"通用",video:"视频"}});function Ye(e,t,n){if(n&&Us(n)){yc(e,t);return}kc(e.model_remains||[],t)}var Pi=T(()=>{Ic()});async function Zg(e,t,n){let i=[{Authorization:`Bearer ${t}`},{"x-api-key":t}],r=!1,s=!1;for(let o of i){let a;try{a=await fetch(tt(ne[e],t),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(n)})}catch{r=!0;continue}if(a.status===401||a.status===403)continue;if(!a.ok){s=!0;continue}try{if((await a.json()).base_resp?.status_code===0)return"authorized";s=!0}catch{s=!0}}if(s)return"inconclusive";if(r)return"unreachable";return"unauthorized"}async function Fi(e){process.stderr.write("Detecting region...");let t=Object.keys(ne),n=await Promise.all(t.map(async(s)=>({region:s,result:await Zg(s,e,5000)}))),i=n.find((s)=>s.result==="authorized");if(!i){process.stderr.write(` failed
|
|
126
126
|
`);let s=e.startsWith("sk-api-")?"No credentials were changed. Check that the key is valid and belongs to an API secret key.":"No credentials were changed. Check that the key is valid and belongs to a Token Plan.";if(n.every((o)=>o.result==="unauthorized"))throw new y("API key was rejected by all regions.",b.AUTH,s);if(n.some((o)=>o.result==="unreachable"))throw new y("Could not reach the regional API endpoints.",b.NETWORK,"No region was changed. Check the network or proxy, then retry or pass --region global|cn explicitly.");throw new y("Could not determine the API key region.",b.GENERAL,"No region was changed because the API returned an inconclusive response. Retry later or pass --region global|cn explicitly.")}let r=i.region;return process.stderr.write(` ${r}
|
|
127
|
-
`),r}async function
|
|
127
|
+
`),r}async function Tc(e){let t=Z();t.region=e,await pe(t)}var Bs=T(()=>{Ee();Re();G();j()});function ey(e){if(e instanceof y)return e.exitCode===b.NETWORK||e.exitCode===b.TIMEOUT;if(!(e instanceof Error))return!1;if(e.name==="AbortError"||e.name==="TimeoutError")return!0;let t=e.message.toLowerCase(),n="code"in e?String(e.code).toLowerCase():"";return e instanceof TypeError&&t==="fetch failed"||t.includes("failed to fetch")||t.includes("unable to connect")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||n==="connectionrefused"||n==="econnrefused"||n==="econnreset"||n==="enotfound"||n==="etimedout"}async function ty(e){try{let t=e.apiKey||e.fileApiKey;if(t&&t.startsWith("sk-api-")){let r=tt(e.baseUrl,t),s=await q(e,{url:r});Ye(s,e,t);return}let n=vn(e.baseUrl),i=await q(e,{url:n});Ye(i,e)}catch{}}async function Nc(e){await Promise.resolve().then(() => Di());Me.printHelp([],process.stderr,e.region),await ty(e)}async function Mc(e,t){await Cs(t);let n=Z(),i={...e,region:t,baseUrl:n.oauth?.resource_url||ne[t]};await Nc(i)}async function Oc(e,t,n){if(e.dryRun){console.log("Would validate and save API key.");return}let i=n??await Fi(t),r={...e,region:i,baseUrl:ne[i],apiKey:t},s=tt(r.baseUrl,t);try{await q(r,{url:s})}catch(a){if(a instanceof y&&a.exitCode===b.AUTH){let c=t.startsWith("sk-api-")?"Check that your key is valid and belongs to an API secret key.":"Check that your key is valid and belongs to a Token Plan.";throw new y("API key validation failed.",b.AUTH,c)}if(!n)throw a;let l=ey(a)?`the ${i} API endpoint is unreachable`:`the ${i} API endpoint returned an inconclusive response`;process.stderr.write(`Warning: Could not validate the API key because ${l}.
|
|
128
128
|
Saving the explicitly selected region "${i}". Requests may fail until validation succeeds.
|
|
129
|
-
`)}let o=Z();delete o.oauth,o.api_key=t,o.region=i,await
|
|
130
|
-
`),await
|
|
129
|
+
`)}let o=Z();delete o.oauth,o.api_key=t,o.region=i,await pe(o),process.stderr.write(`API key saved to ${de()}
|
|
130
|
+
`),await Nc(r)}var Cc;var Rc=T(()=>{X();G();j();Rs();oe();Pi();Bs();Xe();Re();Ee();Cc=C({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--api-key <key>] [--recommend] [--region=global|cn]",options:[{flag:"--api-key <key>",description:"Skip the menu and save this API key directly"},{flag:"--recommend",description:"Skip the menu, go straight to OAuth (combine with --region= to skip the region picker)"}],examples:["mmx auth login","mmx auth login --api-key sk-cp-xxxxx","mmx auth login --recommend","mmx auth login --recommend --region=global","mmx auth login --recommend --region=cn"],async run(e,t){let n=process.env.MINIMAX_API_KEY;if(n&&!t.apiKey){let s=he(n);if(Q({nonInteractive:e.nonInteractive})){await Promise.resolve().then(() => ke());let l=await Is({message:`MINIMAX_API_KEY is set (${s}). Configure persistent credentials anyway?`,initialValue:!1});if(Pe(l)||!l)process.stdout.write(`Login skipped. Using environment variable.
|
|
131
131
|
`),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
|
|
132
|
-
`)}if(t.apiKey){await
|
|
133
|
-
`);try{let s=
|
|
134
|
-
Or set $MINIMAX_API_KEY`},n))}}})});var
|
|
135
|
-
`);return}if(n)await
|
|
136
|
-
`);if(r){let s=Z();delete s.api_key,await
|
|
137
|
-
`)}}})});async function*
|
|
138
|
-
${
|
|
139
|
-
`);i=l.pop()||"";for(let c of l){let
|
|
140
|
-
`),process.exit(1);r=[{role:"user",content:
|
|
132
|
+
`)}if(t.apiKey){await Oc(e,t.apiKey,t.region);return}if(e.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!Q({nonInteractive:e.nonInteractive}))throw new y("--api-key is required in non-interactive mode.",b.USAGE,"mmx auth login --api-key sk-xxxxx");if(t.recommend){let s=t.region||await Yl();await Mc(e,s);return}let i=await Ns();if(i==="api-key"){await Promise.resolve().then(() => ke());let a=await Ts({message:"Paste your MiniMax API key:",validate:(l)=>l&&l.length>0?void 0:"API key cannot be empty."});if(Pe(a))throw new y("Authentication cancelled.",b.AUTH);await Oc(e,a,t.region);return}let r=t.region||(i==="oauth-cn"?"cn":"global");await Mc(e,r)}})});var Lc;var Pc=T(()=>{X();Ii();Ze();ee();oe();Pi();Lc=C({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(e,t){try{let n=await Bt(e),i=F(e.output);if(i!=="text"){let s={method:n.method,source:n.source};if(n.method==="oauth"){let o=await ge();if(o){if(s.token_expires=o.expires_at,o.account)s.account=o.account}}else{s.key=he(n.token);let o=tt(e.baseUrl,n.token),a=await q(e,{url:o});s.usage=a}console.log(O(s,i));return}console.log("Authentication Status:"),console.log(` Method: ${n.method}`),console.log(` Source: ${n.source}`);let r=n.token;if(console.log(` Key: ${he(r)}`),n.method==="oauth"){let s=await ge();if(s){if(s.account)console.log(` Account: ${s.account}`);let o=new Date(s.expires_at),a=Math.round((o.getTime()-Date.now())/60000);console.log(` Expires in: ${a} minutes`)}}else{let s=tt(e.baseUrl,r);try{let o=await q(e,{url:s});Ye(o,e,r)}catch(o){console.log(` Quota fetch failed: ${o.message}`)}return}process.stderr.write(`Fetching quota snapshot...
|
|
133
|
+
`);try{let s=vn(e.baseUrl),o=await q(e,{url:s,method:"GET"});Ye(o,e)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let n=F(e.output);console.log(O({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
|
|
134
|
+
Or set $MINIMAX_API_KEY`},n))}}})});var Fc;var Dc=T(()=>{X();G();j();Ze();Fs();ee();Fc=C({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let n=await ge();if(!n)throw new y("Not applicable: not authenticated via OAuth.",b.USAGE,"Run mmx auth login first.");if(e.dryRun){console.log("Would refresh OAuth token.");return}let i=await Ps(n.refresh_token,n.region??"global"),r={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:n.region,resource_url:i.resource_url??n.resource_url,account:n.account};await Ai(r);let s=F(e.output);if(e.quiet){console.log(r.expires_at);return}console.log(O({status:"Token refreshed",expires:r.expires_at},s))}})});var qc;var Uc=T(()=>{X();Ze();Re();qc=C({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(e,t){let n=await ge(),r=!!Z().api_key;if(e.dryRun){if(n)console.log("Would clear oauth from ~/.mmx/config.json");if(r)console.log("Would clear api_key from ~/.mmx/config.json");if(!n&&!r)console.log("No credentials to clear.");console.log("No changes made.");return}if(!n&&!r){process.stderr.write(`No credentials to clear.
|
|
135
|
+
`);return}if(n)await Hl(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
|
|
136
|
+
`);if(r){let s=Z();delete s.api_key,await pe(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
|
|
137
|
+
`)}}})});async function*Ue(e){let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,i="",r={},s=(o)=>{let a=o.endsWith("\r")?o.slice(0,-1):o;if(a===""){let u=r.data!==void 0?{data:r.data,event:r.event,id:r.id}:void 0;return r={},u}if(a.startsWith(":"))return;let l=a.indexOf(":");if(l===-1)return;let c=a.slice(0,l),f=a.slice(l+1).trimStart();switch(c){case"data":r.data=r.data!==void 0?`${r.data}
|
|
138
|
+
${f}`:f;break;case"event":r.event=f;break;case"id":r.id=f;break}return};try{while(!0){let{done:o,value:a}=await t.read();if(o)break;i+=n.decode(a,{stream:!0});let l=i.split(`
|
|
139
|
+
`);i=l.pop()||"";for(let c of l){let f=s(c);if(f)yield f}}if(i+=n.decode(),i.length>0){let o=s(i);if(o)yield o}if(r.data!==void 0)yield{data:r.data,event:r.event,id:r.id}}finally{t.releaseLock()}}var je="MiniMax-M3.1-Flash";import{readFileSync as ny}from"fs";function iy(e){return e==="-"?0:e}function qi(e){return ny(iy(e),"utf-8")}var Vs=()=>{};import{readFileSync as ry}from"fs";function Gc(e,t,n){let i=(1-Math.abs(2*n-1))*t,r=i*(1-Math.abs(e/60%2-1)),s=n-i/2,o=0,a=0,l=0;if(e<60)o=i,a=r;else if(e<120)o=r,a=i;else if(e<180)a=i,l=r;else if(e<240)a=r,l=i;else if(e<300)o=r,l=i;else o=i,l=r;return[Math.round((o+s)*255),Math.round((a+s)*255),Math.round((l+s)*255)]}class Bc{frame=0;startTime=0;timer=null;out;noColor;constructor(e,t){this.out=e,this.noColor=t}start(){this.frame=0,this.startTime=Date.now(),this.tick(),this.timer=setInterval(()=>this.tick(),80)}stop(){if(this.timer)clearInterval(this.timer),this.timer=null;this.out.write("\r\x1B[0K")}tick(){let e=jc[this.frame%jc.length],t=Math.floor((Date.now()-this.startTime)/1000),n=t>=60?`Thinking (${Math.floor(t/60)}m ${t%60}s)`:`Thinking (${t}s)`;if(this.frame++,this.noColor)this.out.write(`\r${e} ${n}\x1B[0K`);else{let[i,r,s]=Gc(this.frame*17%360,0.85,0.55),[o,a,l]=Gc((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${i};${r};${s}m${e}\x1B[0m \x1B[38;2;${o};${a};${l}m${n}\x1B[0m\x1B[0K`)}}}function sy(e){let t=[],n;if(e.system)n=e.system;if(e.messagesFile){let i=e.messagesFile,r=qi(i),s=JSON.parse(r);for(let o of s)if(o.role==="system")n=typeof o.content==="string"?o.content:"";else t.push(o)}if(!e.message&&e.prompt)e.message=Array.isArray(e.prompt)?e.prompt:[e.prompt];if(e.message){let i=new Set(["system","user","assistant"]),r=e.message;for(let s of r){let o=s.indexOf(":"),a=o!==-1?s.slice(0,o):"";if(i.has(a)){let l=s.slice(o+1);if(a==="system")n=l;else t.push({role:a,content:l})}else t.push({role:"user",content:s})}}return{system:n,messages:t}}function oy(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var jc,Vc;var Hc=T(()=>{X();oe();ee();G();j();Vs();De();jc=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Vc=C({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",apiDocs:"/docs/api-reference/text-post",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:`Model ID (default: ${je})`},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"',`mmx text chat --model ${je} --system "You are a coding assistant." --message "Write fizzbuzz in Python"`,'mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(e,t){let{system:n,messages:i}=sy(t),r=i;if(r.length===0)if(Q({nonInteractive:e.nonInteractive})){let f=await Ie({message:"Enter your message:"});if(!f)process.stderr.write(`Chat cancelled.
|
|
140
|
+
`),process.exit(1);r=[{role:"user",content:f}]}else wt("message","mmx text chat --message <text>");let s=t.model||e.defaultTextModel||je,o=F(e.output),a=t.stream===!0||t.stream===void 0&&o!=="json"&&process.stdout.isTTY,l={model:s,messages:r,max_tokens:t.maxTokens??4096,stream:a};if(n)l.system=n;if(t.temperature!==void 0)l.temperature=t.temperature;if(t.topP!==void 0)l.top_p=t.topP;if(t.tool){let f=t.tool.map((u)=>{try{return JSON.parse(u)}catch{try{let d=ry(u,"utf-8");return JSON.parse(d)}catch{throw new y(`Invalid tool definition: "${u}" is neither valid JSON nor a readable file.`,b.USAGE)}}});l.tools=f}if(e.dryRun){console.log(O({request:l},o));return}let c=Mi(e.baseUrl);if(a){let f=await qe(e,{url:c,method:"POST",body:l,stream:!0,authStyle:"x-api-key"}),u=f.headers.get("content-type")||"";if(!u.includes("text/event-stream")&&!u.includes("stream"))throw new y(`Expected SSE stream but got content-type "${u}". Server may be experiencing issues.`,b.GENERAL);let d="",g=!1,h=e.noColor?"":"\x1B[2m",p=e.noColor?"":"\x1B[0m",m=o==="json",w=process.stdout.isTTY&&!m?process.stderr:process.stderr,x=m?void 0:process.stdout,E=new Bc(w,e.noColor);for await(let A of Ue(f)){if(A.data==="[DONE]")break;try{let _=JSON.parse(A.data);if(_.type==="content_block_start"){if(_.content_block.type==="thinking")g=!0,E.start();else if(_.content_block.type==="text"&&g)E.stop(),g=!1,w.write(`${p}
|
|
141
141
|
Response:
|
|
142
|
-
`)}else if(_.type==="content_block_delta"){if(_.delta.type==="text_delta")
|
|
143
|
-
${h}[warning] Failed to parse stream chunk: ${_ instanceof Error?_.message:String(_)}${
|
|
144
|
-
`)}}if(g)E.stop();if(o==="json")console.log(O({content:
|
|
145
|
-
`)}else{let
|
|
142
|
+
`)}else if(_.type==="content_block_delta"){if(_.delta.type==="text_delta")d+=_.delta.text,x?.write(_.delta.text)}}catch(_){process.stderr.write(`
|
|
143
|
+
${h}[warning] Failed to parse stream chunk: ${_ instanceof Error?_.message:String(_)}${p}
|
|
144
|
+
`)}}if(g)E.stop();if(o==="json")console.log(O({content:d},o));else x?.write(`
|
|
145
|
+
`)}else{let f=await q(e,{url:c,method:"POST",body:l,authStyle:"x-api-key"}),u=oy(f.content);if(e.quiet||o==="text")console.log(u);else console.log(O(f,o))}}})});import{writeFileSync as ay}from"node:fs";function Kc(e){return`\x1B[${e}A`}function ly(e){return`\x1B[${e}B`}function Hs(e){return`\x1B[${e}G`}function Ui(){return"\x1B[2K"}function cy(){return"\x1B[0J"}function dy(){process.stdout.write(`
|
|
146
146
|
Available commands:
|
|
147
|
-
`);for(let[e,t]of Object.entries(
|
|
147
|
+
`);for(let[e,t]of Object.entries(Ws))process.stdout.write(` ${e.padEnd(Wc+2)} ${t}
|
|
148
148
|
`);process.stdout.write(`
|
|
149
|
-
`)}class
|
|
150
|
-
`){let r=this.buffer;if(r.trim())this.history.push(r),this.historyIdx=-1;let s=this.lastTotal>0?this.lastTotal-1:0;this.out.write(
|
|
151
|
-
`),this.lastTotal=0;let o=this.resolve;if(this.resolve=null,o)o(r);n++;continue}if(i===""||i==="\b"){if(this.cursor>0)this.buffer=this.buffer.slice(0,this.cursor-1)+this.buffer.slice(this.cursor),this.cursor--;this.render(),n++;continue}if(i==="\x01"){this.cursor=0,this.render(),n++;continue}if(i==="\x05"){this.cursor=this.buffer.length,this.render(),n++;continue}if(i==="\x15"){this.buffer="",this.cursor=0,this.render(),n++;continue}if(i==="\x17"){let r=this.buffer.slice(0,this.cursor),s=this.buffer.slice(this.cursor),o=r.replace(/\S+\s*$/,"");this.cursor=o.length,this.buffer=o+s,this.render(),n++;continue}if(i==="\t"){if(this.buffer.startsWith("/")){let r=
|
|
152
|
-
`,s+=
|
|
153
|
-
`,s+=
|
|
154
|
-
`,n)for(let o of e)s+=
|
|
155
|
-
`;if(r<this.lastTotal)s+=
|
|
149
|
+
`)}class Yc{buffer="";cursor=0;history=[];historyIdx=-1;out;promptLen;dim;reset;width;lastTotal=0;resolve=null;constructor(e,t,n,i){this.out=e,this.promptLen=t.length,this.dim=n,this.reset=i,this.width=e.columns||80}readLine(){return new Promise((e)=>{this.buffer="",this.cursor=0,this.lastTotal=0,this.resolve=e,this.render()})}feed(e){let t=e.toString(),n=0;while(n<t.length){let i=t[n];if(i==="\x1B"&&n+1<t.length&&t[n+1]==="["){let r=t.slice(n,n+3);if(r==="\x1B[A"){this.historyUp(),n+=3;continue}if(r==="\x1B[B"){this.historyDown(),n+=3;continue}if(r==="\x1B[C"){if(this.cursor<this.buffer.length)this.cursor++;this.render(),n+=3;continue}if(r==="\x1B[D"){if(this.cursor>0)this.cursor--;this.render(),n+=3;continue}if(r==="\x1B[H"){this.cursor=0,this.render(),n+=3;continue}if(r==="\x1B[F"){this.cursor=this.buffer.length,this.render(),n+=3;continue}if(n+3<t.length&&t.slice(n,n+4)==="\x1B[3~"){if(this.cursor<this.buffer.length)this.buffer=this.buffer.slice(0,this.cursor)+this.buffer.slice(this.cursor+1);this.render(),n+=4;continue}n+=1;continue}if(i==="\r"||i===`
|
|
150
|
+
`){let r=this.buffer;if(r.trim())this.history.push(r),this.historyIdx=-1;let s=this.lastTotal>0?this.lastTotal-1:0;this.out.write(ly(s)+`
|
|
151
|
+
`),this.lastTotal=0;let o=this.resolve;if(this.resolve=null,o)o(r);n++;continue}if(i===""||i==="\b"){if(this.cursor>0)this.buffer=this.buffer.slice(0,this.cursor-1)+this.buffer.slice(this.cursor),this.cursor--;this.render(),n++;continue}if(i==="\x01"){this.cursor=0,this.render(),n++;continue}if(i==="\x05"){this.cursor=this.buffer.length,this.render(),n++;continue}if(i==="\x15"){this.buffer="",this.cursor=0,this.render(),n++;continue}if(i==="\x17"){let r=this.buffer.slice(0,this.cursor),s=this.buffer.slice(this.cursor),o=r.replace(/\S+\s*$/,"");this.cursor=o.length,this.buffer=o+s,this.render(),n++;continue}if(i==="\t"){if(this.buffer.startsWith("/")){let r=Ks.filter((s)=>s.startsWith(this.buffer));if(r.length===1)this.buffer=r[0],this.cursor=this.buffer.length,this.render()}n++;continue}if(i.charCodeAt(0)>=32){this.buffer=this.buffer.slice(0,this.cursor)+i+this.buffer.slice(this.cursor),this.cursor++,this.render(),n++;continue}n++}}historyUp(){if(this.history.length===0)return;if(this.historyIdx===-1)this.historyIdx=this.history.length-1;else if(this.historyIdx>0)this.historyIdx--;this.buffer=this.history[this.historyIdx],this.cursor=this.buffer.length,this.render()}historyDown(){if(this.historyIdx===-1)return;if(this.historyIdx<this.history.length-1)this.historyIdx++,this.buffer=this.history[this.historyIdx];else this.historyIdx=-1,this.buffer="";this.cursor=this.buffer.length,this.render()}border(){return this.dim+"─".repeat(this.width)+this.reset}render(){let e=this.buffer.startsWith("/")?Ks.filter((o)=>o.startsWith(this.buffer)):[],t=e.length===1&&e[0]===this.buffer,n=e.length>0&&!t,i=n?e.length:0,r=3+i,s="";if(this.lastTotal>0)s+=Kc(1);if(s+=Hs(1)+Ui()+this.border()+`
|
|
152
|
+
`,s+=Ui()+"> "+this.buffer+`
|
|
153
|
+
`,s+=Hs(1)+Ui()+this.border()+`
|
|
154
|
+
`,n)for(let o of e)s+=Ui()+` ${this.dim}${o.padEnd(Wc+2)} ${Ws[o]}${this.reset}
|
|
155
|
+
`;if(r<this.lastTotal)s+=cy();s+=Kc(i+2),s+=Hs(this.promptLen+this.cursor+1),this.out.write(s),this.lastTotal=r}}var uy="\x1B[?25l",fy="\x1B[?25h",Ws,Ks,Wc,Jc;var zc=T(()=>{X();oe();G();j();Ws={"/exit":"Exit the conversation","/clear":"Clear conversation history (keeps system prompt)","/system":"Show or set the system prompt. Usage: /system [new prompt]","/model":"Show or set the model. Usage: /model [model-id]","/save":"Save conversation to a JSON file. Usage: /save <path>","/help":"Show available slash commands","/history":"Show conversation messages with content preview"},Ks=Object.keys(Ws),Wc=Math.max(...Ks.map((e)=>e.length));Jc=C({name:"text repl",description:"Start an interactive multi-turn chat session",usage:"mmx text repl [flags]",options:[{flag:"--model <model>",description:`Model ID (default: ${je})`},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens per response (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"}],examples:["mmx text repl",`mmx text repl --model ${je} --system "You are a coding assistant."`,"mmx text repl --temperature 0.7 --max-tokens 8192"],async run(e,t){if(!Q({nonInteractive:e.nonInteractive}))throw new y("The repl command requires an interactive terminal.",b.USAGE,"mmx text repl");if(!process.stdin.isTTY)throw new y("The repl command requires a TTY.",b.USAGE);let n=e.noColor?"":"\x1B[2m",i=e.noColor?"":"\x1B[0m",r={messages:[],system:t.system,model:t.model||e.defaultTextModel||je,maxTokens:t.maxTokens??4096,temperature:t.temperature!==void 0?t.temperature:void 0,topP:t.topP!==void 0?t.topP:void 0},s=e.noColor?"":"\x1B[1m";if(process.stdout.write(`
|
|
156
156
|
${s}MiniMax Chat REPL${i}
|
|
157
157
|
`),process.stdout.write(`${n}Model: ${r.model}${i}
|
|
158
158
|
`),r.system)process.stdout.write(`${n}System: ${r.system.slice(0,80)}${r.system.length>80?"...":""}${i}
|
|
159
159
|
`);process.stdout.write(`${n}Type / to see commands, /exit to quit.${i}
|
|
160
|
-
`);let o=process.stdin,a=process.stdout;if(typeof o.setRawMode==="function")o.setRawMode(!0);o.resume(),o.setEncoding("utf8");let l=!1,c=0;async function
|
|
161
|
-
`);return}let
|
|
160
|
+
`);let o=process.stdin,a=process.stdout;if(typeof o.setRawMode==="function")o.setRawMode(!0);o.resume(),o.setEncoding("utf8");let l=!1,c=0;async function f(){if(r.messages.length===0){a.write(`${n}No messages to send. Type something first.${i}
|
|
161
|
+
`);return}let p={model:r.model,messages:r.messages,max_tokens:r.maxTokens,stream:!0};if(r.system)p.system=r.system;if(r.temperature!==void 0)p.temperature=r.temperature;if(r.topP!==void 0)p.top_p=r.topP;l=!0;let m=Mi(e.baseUrl);try{let v=await qe(e,{url:m,method:"POST",body:p,stream:!0,authStyle:"x-api-key"}),w=v.headers.get("content-type")||"";if(!w.includes("text/event-stream")&&!w.includes("stream"))throw new y(`Expected SSE stream but got content-type "${w}".`,b.GENERAL);let x="",E=!1;for await(let A of Ue(v)){if(A.data==="[DONE]")break;try{let _=JSON.parse(A.data);if(_.type==="content_block_start"){if(_.content_block.type==="thinking")E=!0,a.write(`${n}Thinking:
|
|
162
162
|
`);else if(_.content_block.type==="text"&&E)a.write(`${i}
|
|
163
163
|
Response:
|
|
164
164
|
`),E=!1}else if(_.type==="content_block_delta"){if(_.delta.type==="text_delta")x+=_.delta.text,a.write(_.delta.text);else if(_.delta.type==="thinking_delta")a.write(_.delta.thinking)}}catch{}}if(E)a.write(i);if(x)r.messages.push({role:"assistant",content:x}),a.write(`
|
|
165
165
|
`);else a.write(`${n}[empty response]${i}
|
|
166
166
|
`)}catch(v){a.write(`${n}[error] ${v instanceof Error?v.message:String(v)}${i}
|
|
167
|
-
`)}finally{l=!1,c=0}}function u(
|
|
168
|
-
`),"exit";case"/help":return
|
|
167
|
+
`)}finally{l=!1,c=0}}function u(p){let m=p.trim().split(/\s+/),v=m[0],w=m.slice(1).join(" ");switch(v){case"/exit":return a.write(`${n}Goodbye!${i}
|
|
168
|
+
`),"exit";case"/help":return dy(),"ok";case"/clear":return r.messages=[],a.write(`${n}Conversation cleared.${i}
|
|
169
169
|
`),"ok";case"/system":{if(w)r.system=w,a.write(`${n}System prompt set.${i}
|
|
170
170
|
`);else if(r.system)a.write(`${n}System prompt:${i}
|
|
171
171
|
${r.system}
|
|
@@ -173,90 +173,90 @@ ${r.system}
|
|
|
173
173
|
`);return"ok"}case"/model":{if(w)r.model=w,a.write(`${n}Model set to: ${r.model}${i}
|
|
174
174
|
`);else a.write(`${n}Current model: ${r.model}${i}
|
|
175
175
|
`);return"ok"}case"/save":{if(!w)return a.write(`${n}Usage: /save <file-path>${i}
|
|
176
|
-
`),"ok";try{let x=[];if(r.system)x.push({role:"system",content:r.system});for(let E of r.messages)x.push({role:E.role,content:typeof E.content==="string"?E.content:JSON.stringify(E.content)});
|
|
176
|
+
`),"ok";try{let x=[];if(r.system)x.push({role:"system",content:r.system});for(let E of r.messages)x.push({role:E.role,content:typeof E.content==="string"?E.content:JSON.stringify(E.content)});ay(w,JSON.stringify(x,null,2),"utf-8"),a.write(`${n}Conversation saved to ${w} (${x.length} messages)${i}
|
|
177
177
|
`)}catch(x){a.write(`${n}[error] Failed to save: ${x instanceof Error?x.message:String(x)}${i}
|
|
178
178
|
`)}return"ok"}case"/history":{if(r.messages.length===0)return a.write(`${n}No messages in conversation.${i}
|
|
179
179
|
`),"ok";if(r.system)a.write(`${n}[system] ${r.system.slice(0,100)}${r.system.length>100?"...":""}${i}
|
|
180
180
|
`);let x=1;for(let E of r.messages){let A=E.role==="user"?"user":"assistant",_=typeof E.content==="string"?E.content:"[structured content]",k=(_.length>120?_.slice(0,120)+"...":_).replace(/\n/g,"↵"),R=` ${String(x).padStart(2)} ${A.padEnd(11)}`;a.write(`${n}${R}${i}${k}
|
|
181
181
|
`),x++}return a.write(`${n}── ${x-1} messages ──${i}
|
|
182
182
|
`),"ok"}default:if(v.startsWith("/"))return a.write(`${n}Unknown command: ${v}. Type /help for available commands.${i}
|
|
183
|
-
`),"ok";return"ok"}}let
|
|
183
|
+
`),"ok";return"ok"}}let d=()=>{if(l){a.write(`
|
|
184
184
|
${n}[interrupted]${i}
|
|
185
185
|
`),c=0,l=!1;return}if(c++,c>=2){if(a.write(`
|
|
186
186
|
${n}Goodbye!${i}
|
|
187
|
-
`),h=!1,typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",
|
|
187
|
+
`),h=!1,typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",d),process.exit(0)}else a.write(`
|
|
188
188
|
${n}Press Ctrl+C again or type /exit to quit.${i}
|
|
189
|
-
`)};process.on("SIGINT",
|
|
190
|
-
`)}}})});import{writeFileSync as
|
|
191
|
-
`);if(
|
|
189
|
+
`)};process.on("SIGINT",d);let g=new Yc(a,"> ",n,i),h=!0;o.on("data",(p)=>{g.feed(p)}),a.write(uy);try{while(h){let p=await g.readLine();if(!h)break;let m=p.trim();if(!m)continue;if(m.startsWith("/")){if(u(m)==="exit"){h=!1;break}continue}r.messages.push({role:"user",content:m}),await f()}}finally{if(a.write(fy),typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",d),o.removeAllListeners("data"),a.write(`
|
|
190
|
+
`)}}})});import{writeFileSync as py}from"fs";function Xc(e,t,n,i){if(t){let r=e.data.audio;if(!r)throw new y("API response missing audio data (audio field is empty).",b.GENERAL);if(!/^[0-9a-fA-F]*$/.test(r))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(r.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);try{py(t,Buffer.from(r,"hex"))}catch(s){if(s.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",b.GENERAL,"Free up disk space and try again.");throw s}if(i)console.log(t);else console.log(O({saved:t,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size,sample_rate:e.extra_info?.audio_sample_rate},n))}else{let r=e.data.audio_url??e.data.audio;if(i)console.log(r);else console.log(O({url:r,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size},n))}}var Qc=T(()=>{ee();G();j()});function Js(e){return e.join(", ")}function eu(e,t){if(!t.includes(e))throw new y(`Invalid audio format "${e}". Supported: ${Js(t)}`,b.USAGE)}function tu(e,t){return Object.hasOwn(Zc,e)?Zc[e]??t:t}function nu(e,t){if(t&&e==="wav")throw new y("wav format is not supported in streaming mode.",b.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var Ys,Zc;var iu=T(()=>{G();j();Ys=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"];Zc={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function ru(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new y("API returned invalid audio data (not valid hex).",b.GENERAL);if(e.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",b.GENERAL);return Uint8Array.from(Buffer.from(e,"hex"))}function su(e,t){let n=t.base_resp?.status_code;if(n!==void 0&&n!==0||t.error)throw xn(e.status,t,e.url||void 0)}function ou(){return new y("API stream ended without audio data.",b.GENERAL)}async function*my(e){let t=e.headers.get("content-type")||"";if(!t.toLowerCase().includes("text/event-stream")){let i;try{i=await e.json()}catch{throw new y(`Expected SSE audio stream but got content-type "${t||"unknown"}".`,b.GENERAL)}su(e,i);let r=i.data?.audio;if(!r)throw ou();yield ru(r);return}let n=!1;for await(let i of Ue(e)){if(!i.data||i.data==="[DONE]")break;let r;try{r=JSON.parse(i.data)}catch(o){throw new y(`Failed to parse audio stream chunk: ${o instanceof Error?o.message:String(o)}`,b.GENERAL)}su(e,r);let s=r.data?.audio;if(s)n=!0,yield ru(s);if(r.data?.status===2)break}if(!n)throw ou()}async function au(e){process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);throw t});for await(let t of my(e))if(!process.stdout.write(t))await new Promise((n)=>process.stdout.once("drain",n))}var lu=T(()=>{qs();G();j()});import{writeFileSync as hy}from"fs";var zs;var cu=T(()=>{X();G();j();oe();ee();Qc();Vs();iu();lu();zs=C({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",apiDocs:"/docs/api-reference/speech-t2a-http",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--emotion <emotion>",description:"Emotion: happy, sad, angry, fearful, disgusted, surprised, calm, fluent, whisper (passed through as-is; see API Reference below for new values)"},{flag:"--text-normalization",description:"Enable Chinese/English text normalization"},{flag:"--latex-read",description:"Read LaTeX formulas ($$...$$, Chinese only)"},{flag:"--format <fmt>",description:`Audio format: ${Js(Ys)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','mmx speech synthesize --text "Hello" --subtitles --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(e,t){let n=t.text??t._positional?.[0];if(t.textFile)n=qi(t.textFile);if(!n)throw new y("--text or --text-file is required.",b.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=t.model||e.defaultSpeechModel||"speech-2.8-hd",r=t.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),o=t.format||"mp3";eu(o,Ys),nu(o,t.stream===!0);let a=t.out??`speech_${s}.${o}`,l="hex",c={model:i,text:n,voice_setting:{voice_id:r,speed:t.speed??void 0,vol:t.volume??void 0,pitch:t.pitch??void 0,emotion:t.emotion||void 0,text_normalization:t.textNormalization===!0?!0:void 0,latex_read:t.latexRead===!0?!0:void 0},audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??tu(o,32000),bitrate:t.bitrate??128000,channel:t.channels??1},output_format:l,stream:t.stream===!0};if(t.language)c.language_boost=t.language;if(t.subtitles)c.subtitle_enable=!0;if(t.pronunciation)c.pronunciation_dict={tone:t.pronunciation};if(Ae(e,c))return;let f=F(e.output),u=rc(e.baseUrl);if(t.stream){let g=await qe(e,{url:u,method:"POST",body:c,stream:!0});await au(g);return}let d=await q(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
|
|
191
|
+
`);if(Xc(d,a,f,e.quiet),t.subtitles&&d.data.subtitle_file)try{let g=await fetch(d.data.subtitle_file);if(!g.ok)throw new y(`Failed to download subtitle file: ${g.status}`,b.GENERAL);let h=await g.json();if(h?.length){let p=a.replace(/\.[^.]+$/,"")+".srt",m=h.map((v,w)=>{let x=(E)=>{let A=String(Math.floor(E/3600000)).padStart(2,"0"),_=String(Math.floor(E%3600000/60000)).padStart(2,"0"),S=String(Math.floor(E%60000/1000)).padStart(2,"0"),k=String(Math.round(E%1000)).padStart(3,"0");return`${A}:${_}:${S},${k}`};return`${w+1}
|
|
192
192
|
${x(v.time_begin)} --> ${x(v.time_end)}
|
|
193
193
|
${v.text}`}).join(`
|
|
194
194
|
|
|
195
|
-
`);if(
|
|
196
|
-
`)}else if(t.subtitles&&!
|
|
197
|
-
`)}}})});import{existsSync as
|
|
195
|
+
`);if(hy(p,m,"utf-8"),!e.quiet)console.log(O({subtitles:p},f));else console.log(p)}}catch(g){if(!e.quiet)process.stderr.write(`Warning: failed to download subtitles: ${g.message}
|
|
196
|
+
`)}else if(t.subtitles&&!d.data.subtitle_file){if(!e.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
|
|
197
|
+
`)}}})});import{existsSync as gy}from"node:fs";import{readFile as yy}from"node:fs/promises";import{basename as by,resolve as wy}from"node:path";function _n(e,t){let n=wy(e);if(!gy(n))throw t(n);return n}async function uu({filePath:e,purpose:t,baseUrl:n,requestJson:i,createFileNotFoundError:r}){let s=_n(e,r),o=await yy(s),a=new FormData;return a.append("file",new Blob([o]),by(s)),a.append("purpose",t),i({url:mc(n),method:"POST",body:a})}var Xs=()=>{};function Qs(e){return xy.includes(e)}function pu({model:e,response_format:t,timestamp_level:n,stream:i}){let r={model:e??Gi,response_format:t??du};if(n)r.timestamp_level=n;if(i)r.stream="true";return r}function mu(e,t=y){if(!ji.includes(e))throw new t(`Invalid response format "${e}". Supported: ${ji.join(", ")}`,b.USAGE)}function hu(e,t,n=y){if(t&&e!==du)throw new n(`response_format "${e}" cannot be combined with stream=true; streaming returns incremental json only.`,b.USAGE)}function gu(e,t,n=y){if(t>fu)throw new n(`Audio file is ${(t/1024/1024).toFixed(1)} MB; speech-to-text allows at most ${fu/1024/1024} MB: ${e}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.")}async function yu({config:e,url:t,form:n,headers:i,responseFormat:r,stream:s}){if(s)return{kind:"stream",res:await qe(e,{url:t,method:"POST",body:n,headers:i,stream:!0})};if(Qs(r))return{kind:"subtitle",document:await(await qe(e,{url:t,method:"POST",body:n,headers:i})).text()};return{kind:"json",response:await q(e,{url:t,method:"POST",body:n,headers:i})}}var Gi="asr-1.0",ji,xy,du="json",fu=52428800;var bu=T(()=>{G();j();oe();ji=["json","verbose_json","srt","vtt"],xy=["srt","vtt"]});import{readFileSync as vy,statSync as Sy,writeFileSync as $y}from"node:fs";import{basename as _y,resolve as Ey}from"node:path";function Zs(e){return e.endsWith(`
|
|
198
198
|
`)?e:`${e}
|
|
199
|
-
`}var
|
|
200
|
-
`);let v=await
|
|
201
|
-
`);continue}if(typeof
|
|
202
|
-
`);if(typeof
|
|
203
|
-
`);let
|
|
204
|
-
`);else process.stdout.write(
|
|
205
|
-
`);return}let w,x;if(v.kind==="subtitle")w=v.document;else x=v.response.duration,w=m==="json"?O(v.response,m):v.response.text;if(
|
|
206
|
-
`)}}}}function
|
|
207
|
-
`)}}}var
|
|
199
|
+
`}var eo;var wu=T(()=>{X();G();j();Xs();ee();bu();De();eo=C({name:"speech transcribe",description:"Transcribe an audio file to text (asr-1.0)",apiDocs:"/docs/api-reference/speech-to-text",usage:"mmx speech transcribe --file <path> [flags]",options:[{flag:"--file <path>",description:"Audio file to transcribe (mp3, wav, m4a, flac, aac, opus, ogg, aiff)",required:!0},{flag:"--model <model>",description:`Model ID (default: ${Gi})`},{flag:"--response-format <fmt>",description:`Transcription format: ${ji.join(", ")} (default: json)`},{flag:"--language <code>",description:"BCP-47 language hint (zh, en, ja, ...); omit for automatic detection"},{flag:"--timestamp-level <level>",description:"Timestamp granularity: sentence, word (verbose_json / srt / vtt only)"},{flag:"--stream",description:"Stream incremental text (json only; pair with --output text when piping)"},{flag:"--out <path>",description:"Write the result to a file instead of stdout"}],examples:["mmx speech transcribe --file meeting.mp3","mmx speech transcribe --file call.mp3 --language zh","mmx speech transcribe --file talk.mp3 --response-format verbose_json --output json","mmx speech transcribe --file talk.mp3 --response-format srt --out talk.srt","mmx speech transcribe --file long.mp3 --stream"],async run(e,t){let n=t.file??t._positional?.[0],i=await jt({value:n,message:"Enter audio file path:",cancelMessage:"Transcription cancelled.",flagName:"file",usageHint:"mmx speech transcribe --file <path>",nonInteractive:e.nonInteractive}),r=_n(i,(E)=>new y(`File not found: ${E}`,b.USAGE)),s=t.model||Gi,o=t.responseFormat||"json",a=t.language||void 0,l=t.timestampLevel||void 0,c=t.stream===!0,f=t.out?Ey(t.out):void 0;if(mu(o),gu(r,Sy(r).size),hu(o,c),c&&f)throw new y("--stream and --out cannot be combined.",b.USAGE,"Redirect stdout instead: mmx speech transcribe --file <path> --stream --output text > transcript.txt");let u=pu({model:s,response_format:o,timestamp_level:l,stream:c}),d={...u,file:r};if(a)d.language=a;if(Ae(e,d))return;let g=new FormData;for(let[E,A]of Object.entries(u))g.append(E,A);g.append("file",new Blob([vy(r)]),_y(r));let h={};if(a)h.language=a;let p=sc(e.baseUrl),m=F(e.output);if(!e.quiet)process.stderr.write(`[Model: ${s}]
|
|
200
|
+
`);let v=await yu({config:e,url:p,form:g,headers:h,responseFormat:o,stream:c});if(v.kind==="stream"){let E=v.res,A=E.headers.get("content-type")||"";if(!A.includes("text/event-stream"))throw new y(`Expected SSE stream but got content-type "${A}". Server may be experiencing issues.`,b.GENERAL);let _=[],S=0,k,R=!1,U=m!=="json";try{for await(let P of Ue(E)){if(P.data==="[DONE]")break;let N;try{N=JSON.parse(P.data)}catch(L){process.stderr.write(`[warning] Failed to parse stream chunk: ${L instanceof Error?L.message:String(L)}
|
|
201
|
+
`);continue}if(typeof N.index==="number"&&N.index!==S)process.stderr.write(`[warning] Stream events arrived out of order (expected index ${S}, got ${N.index}).
|
|
202
|
+
`);if(typeof N.index==="number")S=N.index+1;if(N.delta){if(_.push({index:typeof N.index==="number"?N.index:_.length,delta:N.delta}),U)process.stdout.write(N.delta)}if(N.finish){k=N.duration,R=!0;break}}}finally{await E.body?.cancel().catch(()=>{return})}if(!R)process.stderr.write(`[warning] Stream ended before the final event; the transcript may be incomplete.
|
|
203
|
+
`);let D=_.sort((P,N)=>P.index-N.index).map((P)=>P.delta).join("");if(U)process.stdout.write(`
|
|
204
|
+
`);else process.stdout.write(Zs(O({text:D,duration:k},m)));if(!e.quiet&&k!==void 0)process.stderr.write(`[Duration: ${k}s]
|
|
205
|
+
`);return}let w,x;if(v.kind==="subtitle")w=v.document;else x=v.response.duration,w=m==="json"?O(v.response,m):v.response.text;if(f){try{$y(f,Qs(o)?w:Zs(w),"utf-8")}catch(E){if(E.code==="ENOSPC")throw new y("Disk full — cannot write transcript file.",b.GENERAL,"Free up disk space and try again.");throw E}if(e.quiet)console.log(f);else{let E={saved:f};if(x!==void 0)E.duration=x;console.log(O(E,m))}return}process.stdout.write(Zs(w))}})});function Ay(e){let t=e.match(/^(.+?)_[A-Z]/);return t?t[1]:e}function ky(e,t){let n=t.toLowerCase();return e.filter((i)=>{let r=Ay(i.voice_id).toLowerCase();return r===n||r.startsWith(n+"_")||r.startsWith(n+" (")})}var xu;var vu=T(()=>{X();oe();ee();xu=C({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(e,t){let n=F(e.output);if(e.dryRun){console.log(O({request:{voice_type:"system"}},n));return}let r=(await q(e,{url:oc(e.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=t.language;if(s){let o=ky(r,s);if(n!=="text"){console.log(O(o,n));return}for(let a of o){let l=a.description?.join("; ")||"",c=a.voice_name?` (${a.voice_name})`:"";if(console.log(` ${a.voice_id}${c}`),l)console.log(` ${l}`)}}else{if(n!=="text"){console.log(O(r.map((o)=>o.voice_id),n));return}for(let o of r)console.log(o.voice_id)}}})});function $u(e){let t=process.stderr.isTTY,n=0,i=null,r=e;return{start(){if(!t)return;i=setInterval(()=>{process.stderr.write(`\r${Su[n%Su.length]} ${r}`),n++},80)},update(s){r=s},stop(s){if(i)clearInterval(i),i=null;if(t){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
|
|
206
|
+
`)}}}}function _u(e,t=""){let n=process.stderr.isTTY,i=30;return{update(r){if(!n)return;let s=Math.min(1,r/e),o=Math.round(30*s),a=30-o,l="█".repeat(o)+"░".repeat(a),c=`${Math.round(s*100)}%`;process.stderr.write(`\r${t} ${l} ${c}`)},finish(){if(n)process.stderr.write(`
|
|
207
|
+
`)}}}var Su;var to=T(()=>{Su=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as Iy,renameSync as Ty,unlinkSync as My}from"fs";function no(e,t){if(!Number.isFinite(e)||e<=0)throw new y(`${t} must be a positive number.`,b.USAGE);return e}function Ry(e,t){if(!Number.isInteger(e)||e<0)throw new y(`${t} must be a non-negative integer.`,b.USAGE);return e}function Ly(e,t){if(!Number.isFinite(e)||e<0)throw new y(`${t} must be a non-negative number.`,b.USAGE);return e}function nt(e,t){return e.reason instanceof Error?e.reason:new y(t,b.GENERAL)}function Py(e){if(!e)return;let t=Number(e);if(Number.isFinite(t)&&t>=0)return t*1000;let n=Date.parse(e);if(!Number.isFinite(n))return;return Math.max(0,n-Date.now())}function Fy(e){if(!e||!/^\d+$/.test(e))return;let t=BigInt(e);return t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):Number.POSITIVE_INFINITY}async function Dy(e,t){if(t.aborted)throw nt(t,"Download aborted.");if(e<=0)return;await new Promise((n,i)=>{let r=setTimeout(()=>{t.removeEventListener("abort",s),n()},e),s=()=>{clearTimeout(r),i(nt(t,"Download aborted."))};t.addEventListener("abort",s,{once:!0})})}async function Vi(e,t,n,i,r=!0){if(t.signal.aborted)throw nt(t.signal,"Download aborted.");let s,o,a=new Promise((c,f)=>{s=setTimeout(()=>{let u=r?new vt(`Download idle timeout while ${i} after ${n}ms.`,b.TIMEOUT):new y(`Download idle timeout while ${i} after ${n}ms.`,b.TIMEOUT);t.abort(u),f(u)},n)}),l=new Promise((c,f)=>{o=()=>f(nt(t.signal,"Download aborted.")),t.signal.addEventListener("abort",o,{once:!0})});try{return await Promise.race([e,a,l])}catch(c){if(t.signal.aborted)throw nt(t.signal,"Download aborted.");throw c}finally{if(s)clearTimeout(s);if(o)t.signal.removeEventListener("abort",o)}}async function qy(e,t,n){let i=new Promise((r,s)=>{let o=()=>c(r),a=(f)=>c(()=>s(f)),l=()=>c(()=>s(Error("File writer closed before draining."))),c=(f)=>{e.off("drain",o),e.off("error",a),e.off("close",l),f()};e.once("drain",o),e.once("error",a),e.once("close",l)});try{await Vi(i,t,n,"waiting for disk writes",!1)}catch(r){if(r instanceof y)throw r;throw new y(`Could not write download: ${r instanceof Error?r.message:String(r)}`,b.GENERAL)}}async function Uy(e,t,n){let i=new Promise((r,s)=>{let o=()=>c(r),a=(f)=>c(()=>s(f)),l=()=>{if(!e.writableFinished)c(()=>s(Error("File writer closed early.")))},c=(f)=>{e.off("finish",o),e.off("error",a),e.off("close",l),f()};e.once("finish",o),e.once("error",a),e.once("close",l),e.end()});try{await Vi(i,t,n,"finishing disk writes",!1)}catch(r){if(r instanceof y)throw r;throw new y(`Could not write download: ${r instanceof Error?r.message:String(r)}`,b.GENERAL)}}async function jy(e){if(e.closed)return;await new Promise((t)=>{let n=setTimeout(()=>{e.off("close",i),t()},Au),i=()=>{clearTimeout(n),t()};e.once("close",i),e.destroy()})}async function Eu(e){let t;if(await Promise.race([e.catch(()=>{return}),new Promise((n)=>{t=setTimeout(n,Au)})]),t)clearTimeout(t)}async function Gy(e,t,n,i,r){let s=new AbortController,o=()=>s.abort(nt(r,"Download aborted."));if(r.aborted)o();else r.addEventListener("abort",o,{once:!0});let a,l,c,f,u=null,d=!1;try{try{a=await Vi(fetch(e,{signal:s.signal}),s,i.idleTimeoutMs,"waiting for response headers")}catch(w){if(w instanceof y)throw w;throw new vt(`Download request failed: ${w instanceof Error?w.message:String(w)}`)}if(!a.ok)throw new Bi(a.status,Py(a.headers.get("retry-after")));let g=Fy(a.headers.get("content-length"));if(g!==void 0&&g>i.maxBytes)throw new y(`Download exceeds maximum size of ${i.maxBytes} bytes (Content-Length: ${g}).`,b.GENERAL);if(l=a.body?.getReader(),!l)throw new y("Download response has no body.",b.GENERAL);let h=a.headers.get("content-encoding")?void 0:g;f=`${t}.tmp-${process.pid}-${Date.now()}-${n}-${Math.random().toString(36).slice(2)}`,c=Iy(f),u=h&&!i.quiet?_u(h,"Downloading"):null;let p,m=new Promise((w,x)=>{c.once("error",(E)=>{p=E,x(E)})});m.catch(()=>{return});let v=0;while(!0){let w;try{w=await Vi(Promise.race([l.read(),m]),s,i.idleTimeoutMs,"waiting for response data")}catch(A){if(p)throw new y(`Could not write download: ${p.message}`,b.GENERAL);if(A instanceof y)throw A;throw new vt(`Download stream failed: ${A instanceof Error?A.message:String(A)}`)}if(w.done)break;let x=v+w.value.byteLength;if(x>i.maxBytes)throw new y(`Download exceeds maximum size of ${i.maxBytes} bytes.`,b.GENERAL);let E;try{E=c.write(w.value)}catch(A){throw new y(`Could not write download: ${A instanceof Error?A.message:String(A)}`,b.GENERAL)}if(!E)await qy(c,s,i.idleTimeoutMs);v=x,u?.update(v)}if(h!==void 0&&v!==h)throw new vt(`Download truncated: expected ${h} bytes, received ${v}.`);return await Uy(c,s,i.idleTimeoutMs),c=void 0,l.releaseLock(),l=void 0,Ty(f,t),f=void 0,d=!0,{size:v}}finally{if(r.removeEventListener("abort",o),u?.finish(),!d){if(l){await Eu(l.cancel(s.signal.reason));try{l.releaseLock()}catch{}}else if(a?.body)await Eu(a.body.cancel(s.signal.reason));if(c)await jy(c);if(f)try{My(f)}catch{}}}}async function Ge(e,t,n){let i=e.startsWith("http://")?e.replace("http://","https://"):e,r=Ry(n?.retries??3,"retries"),s=Ly(n?.retryDelayMs??1000,"retryDelayMs"),o=no(n?.overallTimeoutMs??Oy,"overallTimeoutMs"),a=no(n?.idleTimeoutMs??Ny,"idleTimeoutMs"),l=no(n?.maxBytes??Cy,"maxBytes"),c=n?.quiet??!1,f=new AbortController,u=()=>f.abort(nt(n.signal,"Download aborted by caller."));if(n?.signal?.aborted)u();else n?.signal?.addEventListener("abort",u,{once:!0});let d=setTimeout(()=>{f.abort(new y(`Download timed out after ${o}ms.`,b.TIMEOUT))},o),g,h;try{for(let m=0;m<=r;m++){if(m>0){let v=s*Math.pow(2,m-1),w=Math.max(v,h??0);if(!c)process.stderr.write(`
|
|
208
208
|
Retry ${m}/${r} in ${w}ms...
|
|
209
|
-
`);await
|
|
209
|
+
`);await Dy(w,f.signal)}try{return await Gy(i,t,m,{quiet:c,idleTimeoutMs:a,maxBytes:l},f.signal)}catch(v){if(g=v instanceof Error?v:Error(String(v)),f.signal.aborted)throw nt(f.signal,"Download aborted.");if(!(v instanceof vt||v instanceof Bi&&v.retryable))throw v;if(h=v instanceof Bi||v instanceof vt?v.retryAfterMs:void 0,!c)process.stderr.write(`
|
|
210
210
|
Download attempt ${m+1} failed: ${g.message}
|
|
211
|
-
`);if(m===r)break}}}finally{clearTimeout(
|
|
212
|
-
`);if(c.b64)
|
|
213
|
-
`);let{saved:
|
|
214
|
-
`);if(a&&
|
|
215
|
-
`)}let h={id:u.request_id,saved:
|
|
216
|
-
`));else console.log(O(h,c))}var
|
|
217
|
-
`);let g=[];if(a){let h=
|
|
218
|
-
`);if(l==="base64"){let m=(
|
|
219
|
-
`);
|
|
220
|
-
`);await
|
|
221
|
-
`));else console.log(O({id:
|
|
211
|
+
`);if(m===r)break}}}finally{clearTimeout(d),n?.signal?.removeEventListener("abort",u)}let p=g instanceof y?g.exitCode:b.NETWORK;throw new y(`Download failed after ${r+1} attempts: ${g?.message}`,p,p===b.NETWORK?"Check your network connection and proxy settings.":void 0)}function Hi(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}var Oy=1800000,Ny=60000,Cy=5368709120,Au=1000,vt,Bi;var En=T(()=>{to();G();j();vt=class vt extends y{retryAfterMs;constructor(e,t=b.NETWORK,n){super(e,t);this.retryAfterMs=n}};Bi=class Bi extends y{retryable;retryAfterMs;constructor(e,t){super(`Download failed: HTTP ${e}`,b.GENERAL);this.retryable=e===408||e===429||e>=500,this.retryAfterMs=t}}});import{readFileSync as By,existsSync as Vy,statSync as Hy}from"fs";import{extname as ku}from"path";function Vt(e,t){if(t!==void 0){let s=Hy(e).size;if(s>t)throw new y(`Image file is ${(s/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${t/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large images.")}let n=ku(e).toLowerCase(),i=Ki[n]||"image/jpeg",r=By(e);return`data:${i};base64,${r.toString("base64")}`}function St(e,t){return e.startsWith("http")||e.startsWith("data:")||e.startsWith("mm_file://")?e:Vt(e,t)}async function Iu(e){if(e.startsWith("data:"))return e;if(e.startsWith("http://")||e.startsWith("https://")){let n=await fetch(e);if(!n.ok)throw new y(`Failed to download image: HTTP ${n.status}`,b.GENERAL);let r=(n.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),s=await n.arrayBuffer();if(s.byteLength>Ky)throw new y(`Image too large (${(s.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,b.USAGE);return`data:${r};base64,${Buffer.from(s).toString("base64")}`}if(!Vy(e))throw new y(`File not found: ${e}`,b.USAGE);let t=ku(e).toLowerCase();if(!Ki[t])throw new y(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,b.USAGE);return Vt(e)}var Ki,Ky=52428800;var An=T(()=>{G();j();Ki={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".heic":"image/heic",".heif":"image/heif"}});import{existsSync as Wy,readFileSync as Yy,statSync as Jy}from"fs";import{extname as zy}from"path";function Wi(e){let t=/^data:[^;,]+;base64,([\s\S]*)$/.exec(e);if(!t)return;let n=t[1].replace(/\s/g,""),i=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.max(0,Math.floor(n.length*3/4)-i)}function io(e,t){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mm_file://"))return e;if(e.startsWith("data:"))return t==="audio"?e.replace(/^data:audio\/mpeg;base64,/,"data:audio/mp3;base64,"):e;if(!Wy(e))throw new y(`File not found: ${e}`,b.USAGE);let n=zy(e).toLowerCase(),i=Xy[t],r=i[n];if(!r){let l=Object.keys(i).map((c)=>c.slice(1)).join(", ");throw new y(`Unsupported ${t} format "${n}". Supported local files: ${l}`,b.USAGE)}let s=$t[t],o=Jy(e).size;if(o>s)throw new y(`${t[0].toUpperCase()}${t.slice(1)} file is ${(o/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${s/1024/1024} MB.`,b.USAGE,"Use a public URL or mm_file:// file ID for large media.");let a=Yy(e);return`data:${r};base64,${a.toString("base64")}`}var Xy,$t,Tu=67108864;var Yi=T(()=>{G();j();Xy={video:{".mp4":"video/mp4",".mov":"video/quicktime"},audio:{".mp3":"audio/mp3",".wav":"audio/wav"}},$t={image:31457280,video:52428800,audio:15728640}});import{existsSync as ro,mkdirSync as Qy,writeFileSync as Zy}from"fs";import{dirname as eb,extname as tb,join as nb,resolve as Mu}from"path";function so(e){return e===_t}function oo(e){return Array.isArray(e.images)}function ao(e){if(e==="png"||e==="webp")return e;return"jpg"}function db(e){return e==="base64"?"b64_json":e}function Fu(e){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("mm_file://"))return e;if(!ro(e))throw new z(`Reference image not found: ${e}`);let t=tb(e).toLowerCase();if(!Ki[t])throw new z(`Unsupported reference image format "${t}". Supported: jpg, jpeg, png, webp, heic, heif.`);return Vt(e,Pu)}function Du(e){let t={model:_t,prompt:e.prompt,n:e.n,size:e.size,aspect_ratio:e.aspectRatio,area:e.area,output_format:e.outputFormat,output_compression:e.outputCompression,response_format:db(e.responseFormat),aigc_watermark:e.aigcWatermark||void 0},n=e.images??[],i;if(n.length>0){if(e.disablePromptEnhanced)throw new z("Prompt enhancement is always on for image edits; --no-prompt-enhance only applies to text-to-image.");i={...t,images:n.map((r)=>({image_url:r}))}}else i={...t,disable_prompt_enhanced:e.disablePromptEnhanced||void 0};for(let r of Object.keys(i))if(i[r]===void 0)delete i[r];return mb(i),i}function pb(e){let t=/^(\d+):(\d+)$/.exec(e);if(!t)return;return[Number(t[1]),Number(t[2])]}function Ru(e,t){return Math.max(e,t)<=3*Math.min(e,t)}function mb(e){if(!so(e.model))throw new z(`Only ${_t} is supported by /v1/images/*.`);let t=typeof e.prompt==="string"?e.prompt.trim():"";if(!t)throw new z("MiniMax-H3-Image requires a non-empty prompt.");if([...t].length>Ou)throw new z(`MiniMax-H3-Image prompt must not exceed ${Ou} characters.`);if(e.n!==void 0&&(!Number.isInteger(e.n)||e.n<1||e.n>Nu))throw new z(`MiniMax-H3-Image n must be an integer from 1 to ${Nu}.`);let n=e.size,i=n!==void 0&&n!=="auto";if(i){let o=/^(\d+)x(\d+)$/.exec(n);if(!o)throw new z('MiniMax-H3-Image size must be "auto" or WIDTHxHEIGHT, e.g. 2720x1536.');let a=Number(o[1]),l=Number(o[2]),c=a*l;if(a<1||l<1||c<ib||c>rb)throw new z(`MiniMax-H3-Image size area (width x height) must be between 655,360 and 20,000,000 pixels, got ${c.toLocaleString("en-US")}.`);if(!Ru(a,l))throw new z("MiniMax-H3-Image size aspect ratio must be between 1:3 and 3:1.");if(e.aspect_ratio!==void 0||e.area!==void 0)throw new z("MiniMax-H3-Image size WIDTHxHEIGHT cannot be combined with aspect ratio or area.")}let r=e.aspect_ratio;if(r!==void 0&&r!=="auto"){let o=pb(r);if(!o||o.some((a)=>a<1||a>300))throw new z('MiniMax-H3-Image aspect ratio must be "auto" or X:Y with integers from 1 to 300.');if(!Ru(o[0],o[1]))throw new z("MiniMax-H3-Image aspect ratio must be between 1:3 and 3:1.")}if(e.area!==void 0&&!cb.has(e.area))throw new z("MiniMax-H3-Image area must be one of: 1K, 2K, 4K.");if(e.output_format!==void 0&&!ub.has(e.output_format))throw new z("MiniMax-H3-Image output format must be one of: jpg, jpeg, png, webp.");if(e.output_compression!==void 0&&(!Number.isInteger(e.output_compression)||e.output_compression<0||e.output_compression>100))throw new z("MiniMax-H3-Image output compression must be an integer from 0 to 100.");if(e.response_format!==void 0&&!fb.has(e.response_format))throw new z("MiniMax-H3-Image response format must be url or b64_json (alias: base64).");if(e.response_format==="b64_json"){let o=i?Number(n.split("x")[0])*Number(n.split("x")[1]):ob[e.area??"4K"],a=(e.n??1)*o,l=e.output_format==="png",c=l?ab:lb;if(a>c)throw new z(`MiniMax-H3-Image b64_json total output area (n x width x height) is ${a.toLocaleString("en-US")} px; the limit for ${l?"png":"jpeg/webp"} is ${c.toLocaleString("en-US")} px. Lower n or the size/area, or use the url response format.`)}if(oo(e)){if(e.disable_prompt_enhanced!==void 0)throw new z("disable_prompt_enhanced is not supported for image edits (enhancement is always on).");let o=e.images.length;if(o<1||o>Cu)throw new z(`MiniMax-H3-Image accepts 1 to ${Cu} reference images.`);for(let a of e.images){if(typeof a?.image_url!=="string"||!a.image_url)throw new z("Each reference image needs a non-empty image_url.");let l=Wi(a.image_url);if(l!==void 0&&l>Pu)throw new z(`MiniMax-H3-Image reference image is ${(l/1024/1024).toFixed(1)} MB; the maximum is 64 MB.`)}}else if(e.disable_prompt_enhanced){if(!i&&!(r!==void 0&&r!=="auto"))throw new z("With prompt enhancement disabled, MiniMax-H3-Image needs an explicit size (WIDTHxHEIGHT) or aspect ratio (X:Y).")}let s=Buffer.byteLength(JSON.stringify(e));if(s>sb)throw new z(`MiniMax-H3-Image request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of local files.`)}async function qu(e,t={}){let n=ao(e.output_format),i=[],r=[];if(e.data.forEach((c,f)=>{if(c.url||c.b64_json)r.push({index:f,url:c.url,b64:c.b64_json});else i.push({index:f,code:c.error?.code,message:c.error?.message})}),t.out&&r.length>1)throw new z("Cannot use `out` with multiple images. Use `outDir` instead.");let s=[],o=t.quiet??!0,a=Mu(t.outDir||"."),l=t.prefix||"image";for(let c of r){let f=t.out?Mu(t.out):nb(a,`${l}_${String(c.index+1).padStart(3,"0")}.${n}`),u=eb(f);if(!ro(u))Qy(u,{recursive:!0});if(t.warnOverwrite&&ro(f))process.stderr.write(`Warning: overwriting existing file: ${f}
|
|
212
|
+
`);if(c.b64)Zy(f,c.b64,"base64");else await Ge(c.url,f,{quiet:o});s.push(f)}return{saved:s,failures:i}}var _t="MiniMax-H3-Image",Lu=600,Ou=32000,Nu=10,Cu=16,ib=655360,rb=20000000,Pu=67108864,sb=67108864,ob,ab=20000000,lb=80000000,cb,ub,fb,z;var Uu=T(()=>{En();An();Yi();ob={"1K":1048576,"2K":4194304,"4K":16777216},cb=new Set(["1K","2K","4K"]),ub=new Set(["png","jpeg","jpg","webp"]),fb=new Set(["url","b64_json"]);z=class z extends Error{constructor(e){super(e);this.name="ImageH3InputError"}}});import{mkdirSync as ju,existsSync as kn,writeFileSync as Gu}from"fs";import{dirname as hb,extname as gb,join as Bu,resolve as lo}from"path";function Vu(e,t){let n=e;return t.filter(([i])=>n[i]!==void 0&&n[i]!==!1).map(([,i])=>i)}async function wb(e,t,n){let i=Vu(t,bb);if(i.length>0)throw new y(`${i.join(", ")} ${i.length>1?"are":"is"} not supported by ${_t}.`,b.USAGE,"Use --image for reference images; prompt enhancement is on by default (--no-prompt-enhance to disable).");let{width:r,height:s}=t;if(r===void 0!==(s===void 0))throw new y("--width and --height must be specified together.",b.USAGE,Ji);let o=t.size;if(r!==void 0&&s!==void 0){if(o!==void 0)throw new y("Use either --size or --width/--height, not both.",b.USAGE,Ji);o=`${r}x${s}`}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l;try{let p=(t.image??[]).map(Fu);l=Du({prompt:n,images:p,n:t.n,size:o,aspectRatio:t.aspectRatio,area:t.area,outputFormat:t.outputFormat,outputCompression:t.outputCompression,responseFormat:t.responseFormat,disablePromptEnhanced:t.noPromptEnhance===!0,aigcWatermark:t.aigcWatermark===!0})}catch(p){if(p instanceof z)throw new y(p.message,b.USAGE,Ji);throw p}if(Ae(e,l))return;let c=F(e.output),f=oo(l),u=await q(e,{url:f?cc(e.baseUrl):lc(e.baseUrl),method:"POST",body:l,timeout:Math.max(e.timeout,Lu)});if(!e.quiet)process.stderr.write(`[Model: ${_t}${f?" (edit)":""}]
|
|
213
|
+
`);let{saved:d,failures:g}=await qu(u,{out:a,outDir:t.outDir,prefix:t.outPrefix,quiet:e.quiet,warnOverwrite:!0});for(let p of g)process.stderr.write(`Warning: image ${p.index+1} failed${p.code?` (${p.code})`:""}: ${p.message??"unknown error"}
|
|
214
|
+
`);if(a&&d.length>0){let p=ao(u.output_format),m=gb(a).toLowerCase().replace(/^\./,"").replace(/^jpeg$/,"jpg");if(m!==p)process.stderr.write(`Warning: --out ${a} has a .${m||"(none)"} extension but the image is ${p}.
|
|
215
|
+
`)}let h={id:u.request_id,saved:d,success_count:d.length,failed_count:g.length};if(g.length>0)h.failures=g;if(c==="json"){if(h.sizes=u.data.map((p)=>p.size??null),h.revised_prompts=u.data.map((p)=>p.revised_prompt??null),u.usage)h.usage=u.usage;console.log(O(h,c))}else if(e.quiet)console.log(d.join(`
|
|
216
|
+
`));else console.log(O(h,c))}var Ji="mmx image generate --model MiniMax-H3-Image --prompt <text>",yb,bb,Hu;var Ku=T(()=>{X();G();j();oe();En();ee();An();De();Uu();yb=[["image","--image"],["size","--size"],["area","--area"],["outputFormat","--output-format"],["outputCompression","--output-compression"],["noPromptEnhance","--no-prompt-enhance"]],bb=[["seed","--seed"],["promptOptimizer","--prompt-optimizer"],["subjectRef","--subject-ref"]];Hu=C({name:"image generate",description:"Generate or edit images (image-01 / MiniMax-H3-Image)",apiDocs:"/docs/guides/image-generation",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID: image-01 (default), image-01-live, or MiniMax-H3-Image. Other values are passed to the image-01 endpoint as-is."},{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--image <path-or-url>",description:"H3: reference image for image editing (repeatable, 1-16; local file, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). image-01: ignored if --width and --height are both specified. H3: auto or X:Y (integers 1-300) between 1:3 and 3:1; cannot be combined with --size/--width/--height."},{flag:"--size <WxH>",description:"H3: output size, auto (default) or WIDTHxHEIGHT (e.g. 2720x1536). Cannot be combined with --aspect-ratio/--area."},{flag:"--area <level>",description:"H3: area level 1K, 2K, or 4K (default: 4K)."},{flag:"--output-format <fmt>",description:"H3: jpg (default), png, or webp."},{flag:"--output-compression <q>",description:"H3: JPEG/WEBP quality 0-100 (default: 95).",type:"number"},{flag:"--no-prompt-enhance",description:"H3 text-to-image: disable prompt enhancement (requires --size or a concrete --aspect-ratio)."},{flag:"--n <count>",description:"Number of images to generate (default: 1; H3: 1-10)",type:"number"},{flag:"--seed <n>",description:"Random seed for reproducible generation (same seed + prompt = identical output)",type:"number"},{flag:"--width <px>",description:"Custom width in pixels. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. image-01: range [512, 2048], multiple of 8, overrides --aspect-ratio. H3: shorthand for --size WIDTHxHEIGHT.",type:"number"},{flag:"--prompt-optimizer",description:"Automatically optimize the prompt before generation for better results."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in the output image."},{flag:"--subject-ref <params>",description:"Subject reference for character consistency. Format: type=character,image=path-or-url"},{flag:"--out <path>",description:"Save image to exact file path (single image only)"},{flag:"--response-format <format>",description:"Response format: url (download), base64 (embed). Default: url. H3 also accepts b64_json; total area n x W x H is limited to 20 MP (png) or 80 MP (jpg/webp)."},{flag:"--out-dir <dir>",description:"Download images to directory"},{flag:"--out-prefix <prefix>",description:"Filename prefix (default: image)"}],examples:['mmx image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9','mmx image generate --prompt "Logo design" --n 3 --out-dir ./generated/','mmx image generate --prompt "Mountain landscape" --quiet',"# Reproducible output with seed",'mmx image generate --prompt "A castle" --seed 42',"# Custom dimensions (must be 512–2048, multiple of 8)",'mmx image generate --prompt "Wide landscape" --width 1920 --height 1080',"# Optimized prompt with watermark",'mmx image generate --prompt "sunset" --prompt-optimizer --aigc-watermark',"# Save to exact path",'mmx image generate --prompt "A cat" --out /tmp/cat.jpg',"# Base64 response (bypasses CDN, useful when image URLs are unreachable)",'mmx image generate --prompt "A cat" --response-format base64',"# MiniMax-H3-Image text-to-image",'mmx image generate --model MiniMax-H3-Image --prompt "An orange cat on a sunny windowsill" --aspect-ratio 16:9 --area 2K','mmx image generate --model MiniMax-H3-Image --prompt "Poster" --size 2720x1536 --output-format png',"# MiniMax-H3-Image image editing (1-16 reference images)",'mmx image generate --model MiniMax-H3-Image --prompt "Replace the cat in Picture 1 with the dog in Picture 2" --image cat.jpg --image https://example.com/dog.png'],async run(e,t){let n=t.prompt??t._positional?.[0];n=await jt({value:n,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:e.nonInteractive});let i=t.model||"image-01";if(so(i)){await wb(e,t,n);return}let r=Vu(t,yb);if(r.length>0)throw new y(`${r.join(", ")} ${r.length>1?"require":"requires"} --model ${_t}.`,b.USAGE,Ji);let{width:s,height:o}=t;if(s!==void 0&&o===void 0)throw new y("--width requires --height. Both must be specified together.",b.USAGE);if(o!==void 0&&s===void 0)throw new y("--height requires --width. Both must be specified together.",b.USAGE);if(s!==void 0&&o!==void 0){let h=(p,m)=>{if(m<512||m>2048)throw new y(`--${p} must be between 512 and 2048, got ${m}.`,b.USAGE);if(m%8!==0)throw new y(`--${p} must be a multiple of 8, got ${m}.`,b.USAGE)};h("width",s),h("height",o)}let a=t.out;if(a&&t.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",b.USAGE);let l=t.responseFormat||"url",c={model:i,prompt:n,aspect_ratio:s!==void 0&&o!==void 0?void 0:t.aspectRatio||void 0,n:t.n??1,seed:t.seed,width:s,height:o,prompt_optimizer:t.promptOptimizer===!0||void 0,aigc_watermark:t.aigcWatermark===!0||void 0,response_format:l};if(t.subjectRef){let h=t.subjectRef,p=Object.fromEntries(h.split(",").map((v)=>{let w=v.indexOf("=");if(w===-1)return[v,""];return[v.slice(0,w),v.slice(w+1)]})),m={type:p.type||"character"};if(p.image)if(p.image.startsWith("http"))m.image_url=p.image;else m.image_file=Vt(lo(p.image));c.subject_reference=[m]}if(Ae(e,c))return;let f=F(e.output),u=ac(e.baseUrl),d=await q(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
|
|
217
|
+
`);let g=[];if(a){let h=hb(lo(a));if(!kn(h))ju(h,{recursive:!0});let p=lo(a);if(kn(p))process.stderr.write(`Warning: overwriting existing file: ${p}
|
|
218
|
+
`);if(l==="base64"){let m=(d.data.image_base64||[])[0];if(m)Gu(p,m,"base64")}else{let m=(d.data.image_urls||[])[0];if(m)await Ge(m,p,{quiet:e.quiet})}g.push(p)}else{let h=t.outDir??".";if(!kn(h))ju(h,{recursive:!0});let p=t.outPrefix||"image";if(l==="base64"){let m=d.data.image_base64||[];for(let v=0;v<m.length;v++){let w=`${p}_${String(v+1).padStart(3,"0")}.jpg`,x=Bu(h,w);if(kn(x))process.stderr.write(`Warning: overwriting existing file: ${x}
|
|
219
|
+
`);Gu(x,m[v],"base64"),g.push(x)}}else{let m=d.data.image_urls||[];for(let v=0;v<m.length;v++){let w=`${p}_${String(v+1).padStart(3,"0")}.jpg`,x=Bu(h,w);if(kn(x))process.stderr.write(`Warning: overwriting existing file: ${x}
|
|
220
|
+
`);await Ge(m[v],x,{quiet:e.quiet}),g.push(x)}}}if(f==="json")console.log(O({id:d.data.task_id,saved:g,success_count:d.data.success_count,failed_count:d.data.failed_count},f));else if(e.quiet)console.log(g.join(`
|
|
221
|
+
`));else console.log(O({id:d.data.task_id,saved:g,success_count:d.data.success_count,failed_count:d.data.failed_count},f))}})});async function co(e,t){let n=Date.now()+t.timeoutSec*1000,i=$u("Polling...");if(!e.quiet)i.start();try{while(Date.now()<n){let r=await q(e,{url:t.url});if(t.getStatus&&!e.quiet)i.update(`Status: ${t.getStatus(r)}`);if(t.isComplete(r))return i.stop("Done."),r;if(t.isFailed(r)){i.stop("Failed.");let s=t.getStatus?t.getStatus(r):"failed",o=r.base_resp?.status_msg,a=t.getFailureReason?.(r)??o,l=a?` (${a})`:"";throw new y(`Task ${s}.${l}`,b.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((s)=>setTimeout(s,Math.min(t.intervalSec*1000,Math.max(0,n-Date.now()))))}}finally{i.stop()}throw new y("Polling timed out.",b.TIMEOUT,"Try increasing --timeout or check task status manually.")}var Wu=T(()=>{oe();G();j();to()});function Et(e){return e===In}function Yu(e){return Et(e.model)}function Ju(e){let t=e.error?.code?.trim(),n=e.error?.message?.trim();if(t&&n)return`${t}: ${n}`;return n||t}function zu(e){let t=e.images??[];if(t.length>1&&t.some((o)=>!o.role))throw new ie("Each image must specify a role when multiple images are provided.");let n=[{type:"text",text:e.prompt},...t.map((o)=>({type:"image_url",image_url:{url:o.url},role:o.role??"first_frame"})),...(e.referenceVideos??[]).map((o)=>({type:"video_url",video_url:{url:o},role:"reference_video"})),...(e.referenceAudios??[]).map((o)=>({type:"audio_url",audio_url:{url:o},role:"reference_audio"}))],i=n.some((o)=>o.type==="image_url"&&(o.role==="first_frame"||o.role==="last_frame")),r=n.some((o)=>o.type!=="text"&&o.role?.startsWith("reference_")),s={model:In,content:n,resolution:e.resolution??"2K",duration:e.duration??5,ratio:i?"adaptive":e.ratio??(r?"adaptive":"16:9")};if(e.callbackUrl)s.callback_url=e.callbackUrl;return $b(s),s}function $b(e){if(!Et(e.model))throw new ie(`Video Generation V2 only supports ${In}.`);let t=e.content.filter((d)=>d.type==="text");if(!t.some((d)=>d.text.trim().length>0))throw new ie("MiniMax-H3 requires a non-empty text content item.");if(t.some((d)=>d.text.length>7000))throw new ie("MiniMax-H3 text content must not exceed 7000 characters.");if(!xb.has(e.resolution))throw new ie("MiniMax-H3 resolution must be one of: 768P, 2K.");if(!Number.isInteger(e.duration)||e.duration<4||e.duration>15)throw new ie("MiniMax-H3 duration must be an integer from 4 to 15 seconds.");if(e.ratio&&!vb.has(e.ratio))throw new ie("MiniMax-H3 ratio must be one of: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.");let n=e.content.filter((d)=>d.type==="image_url"),i=e.content.filter((d)=>d.type==="video_url"),r=e.content.filter((d)=>d.type==="audio_url");if(n.some((d)=>d.role&&!Sb.has(d.role)))throw new ie("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");if(i.some((d)=>d.role!=="reference_video"))throw new ie("MiniMax-H3 video role must be reference_video.");if(r.some((d)=>d.role!=="reference_audio"))throw new ie("MiniMax-H3 audio role must be reference_audio.");for(let d of n)uo(d.image_url.url,"image");for(let d of i)uo(d.video_url.url,"video");for(let d of r)uo(d.audio_url.url,"audio");let s=Buffer.byteLength(JSON.stringify(e));if(s>Tu)throw new ie(`MiniMax-H3 request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of Base64.`);let o=n.filter((d)=>!d.role||d.role==="first_frame"),a=n.filter((d)=>d.role==="last_frame"),l=n.filter((d)=>d.role==="reference_image"),c=o.length>0||a.length>0,f=l.length>0||i.length>0||r.length>0;if(o.length>1||a.length>1)throw new ie("MiniMax-H3 accepts at most one first frame and one last frame.");if(l.length>9||i.length>3||r.length>3)throw new ie("MiniMax-H3 accepts up to 9 reference images, 3 reference videos, and 3 reference audios.");if(c&&f)throw new ie("MiniMax-H3 frame inputs and reference inputs cannot be used together.");if(r.length>0&&l.length===0&&i.length===0)throw new ie("MiniMax-H3 reference audio requires at least one reference image or reference video.");if(e.content.every((d)=>d.type==="text")&&(!e.ratio||e.ratio==="adaptive"))throw new ie("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.")}function uo(e,t){let n=Wi(e),i=$t[t];if(n!==void 0&&n>i)throw new ie(`MiniMax-H3 ${t} input is ${(n/1024/1024).toFixed(1)} MB; the maximum is ${i/1024/1024} MB.`)}var In="MiniMax-H3",xb,vb,Sb,ie;var fo=T(()=>{Yi();xb=new Set(["768P","2K"]),vb=new Set(["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]),Sb=new Set(["first_frame","last_frame","reference_image"]);ie=class ie extends Error{constructor(e){super(e);this.name="VideoV2InputError"}}});var Xu;var Qu=T(()=>{X();G();j();oe();Wu();En();ee();An();Yi();De();fo();Xu=C({name:"video generate",description:`Generate a video
|
|
222
222
|
V2: MiniMax-H3 (text/image/video/audio content, 768P/2K)
|
|
223
223
|
T2V: Hailuo-2.3
|
|
224
224
|
I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --image)
|
|
225
225
|
SEF: Hailuo-02 (requires --image and --last-frame)
|
|
226
|
-
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation-v2-create",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. V2: MiniMax-H3. Legacy: MiniMax-Hailuo-2.3 or MiniMax-Hailuo-2.3-Fast. Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--image <path-or-url>",description:"Input image for image-to-video (local path or URL)."},{flag:"--first-frame <path-or-url>",description:"Backward-compatible alias for --image.",hidden:!0},{flag:"--last-frame <path-or-url>",description:"Optional ending image. Legacy SEF also requires --image; MiniMax-H3 supports a last frame alone."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--reference-image <path-or-url>",description:"H3 reference image (repeatable).",type:"array"},{flag:"--reference-video <path-or-url>",description:"H3 reference video (repeatable; local MP4/MOV, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--reference-audio <path-or-url>",description:"H3 reference audio (repeatable; requires a reference image or video).",type:"array"},{flag:"--duration <seconds>",description:"Output duration. H3 supports integer values from 4 to 15 (default: 5).",type:"number"},{flag:"--resolution <resolution>",description:"H3 output resolution: 768P or 2K (default: 2K)."},{flag:"--ratio <ratio>",description:"H3 aspect ratio: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# H3 text-to-video (Video Generation V2)",'mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset"','mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset" --resolution 768P',"# H3 image-to-video",'mmx video generate --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg',"# H3 reference-to-video",'mmx video generate --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --image start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(e,t){let n=t.prompt;n=await
|
|
227
|
-
`);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:
|
|
228
|
-
`);return}let m=t.pollInterval??5,v,w,x;if(
|
|
229
|
-
`)}})});var
|
|
230
|
-
`),process.exit(1);if(!c.includes(".")&&!c.startsWith("http"))i=c;else n=c}else throw new y("Missing required argument. Must provide either --image or --file-id.",b.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(n&&i)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",b.USAGE);if(
|
|
226
|
+
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation-v2-create",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. V2: MiniMax-H3. Legacy: MiniMax-Hailuo-2.3 or MiniMax-Hailuo-2.3-Fast. Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--image <path-or-url>",description:"Input image for image-to-video (local path or URL)."},{flag:"--first-frame <path-or-url>",description:"Backward-compatible alias for --image.",hidden:!0},{flag:"--last-frame <path-or-url>",description:"Optional ending image. Legacy SEF also requires --image; MiniMax-H3 supports a last frame alone."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--reference-image <path-or-url>",description:"H3 reference image (repeatable).",type:"array"},{flag:"--reference-video <path-or-url>",description:"H3 reference video (repeatable; local MP4/MOV, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--reference-audio <path-or-url>",description:"H3 reference audio (repeatable; requires a reference image or video).",type:"array"},{flag:"--duration <seconds>",description:"Output duration. H3 supports integer values from 4 to 15 (default: 5).",type:"number"},{flag:"--resolution <resolution>",description:"H3 output resolution: 768P or 2K (default: 2K)."},{flag:"--ratio <ratio>",description:"H3 aspect ratio: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# H3 text-to-video (Video Generation V2)",'mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset"','mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset" --resolution 768P',"# H3 image-to-video",'mmx video generate --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg',"# H3 reference-to-video",'mmx video generate --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --image start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(e,t){let n=t.prompt;n=await jt({value:n,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:e.nonInteractive});let i=t.model,r=e.defaultVideoModel||"MiniMax-Hailuo-2.3",{image:s,firstFrame:o}=t;if(s&&o)throw new y("--image and --first-frame are aliases; provide only one.",b.USAGE);let a=s??o,l=Boolean(t.referenceImage||t.referenceVideo||t.referenceAudio||t.resolution!==void 0||t.duration!==void 0||t.ratio),c;if(i)c=i;else if(Et(r))c=In;else if(t.lastFrame)c="MiniMax-Hailuo-02";else if(t.subjectImage)c="S2V-01";else c=r;if(t.lastFrame&&t.subjectImage)throw new y("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",b.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");if(i==="MiniMax-Hailuo-2.3-Fast"&&!a)throw new y("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --image to provide an input image.",b.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --image <path>");let f;if(Et(c)){if(t.subjectImage)throw new y("--subject-image is only supported by the legacy S2V-01 model. Use --reference-image for MiniMax-H3.",b.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text> --reference-image <path>");let U=[...a?[{url:St(a,$t.image),role:"first_frame"}]:[],...t.lastFrame?[{url:St(t.lastFrame,$t.image),role:"last_frame"}]:[],...(t.referenceImage??[]).map((D)=>({url:St(D,$t.image),role:"reference_image"}))];try{f=zu({prompt:n,images:U,referenceVideos:(t.referenceVideo??[]).map((D)=>io(D,"video")),referenceAudios:(t.referenceAudio??[]).map((D)=>io(D,"audio")),resolution:t.resolution,duration:t.duration,ratio:t.ratio,callbackUrl:t.callbackUrl})}catch(D){if(D instanceof ie)throw new y(D.message,b.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text>");throw D}}else{if(l)throw new y("--reference-image, --reference-video, --reference-audio, --resolution, --duration, and --ratio require --model MiniMax-H3.",b.USAGE);if(f={model:c,prompt:n},a)f.first_frame_image=St(a);if(t.lastFrame){if(!a)throw new y("--last-frame requires --image (SEF mode).",b.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");f.last_frame_image=St(t.lastFrame)}if(t.subjectImage)f.subject_reference=[{type:"character",image:[St(t.subjectImage)]}];if(t.callbackUrl)f.callback_url=t.callbackUrl}if(Ae(e,f))return;let u=F(e.output),d=Yu(f),g=d?fc(e.baseUrl):uc(e.baseUrl),p=(await q(e,{url:g,method:"POST",body:f})).task_id;if(!e.quiet)process.stderr.write(`[Model: ${c}]
|
|
227
|
+
`);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:p})),process.stdout.write(`
|
|
228
|
+
`);return}let m=t.pollInterval??5,v,w,x;if(d){let U=Ni(e.baseUrl,p),D=await co(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(P)=>P.task.status==="succeeded",isFailed:(P)=>["failed","cancelled","expired"].includes(P.task.status),getStatus:(P)=>P.task.status,getFailureReason:(P)=>Ju(P.task)});x=D.task.status,v=D.task.content?.url}else{let U=Oi(e.baseUrl,p),D=await co(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(N)=>N.status==="Success",isFailed:(N)=>N.status==="Failed",getStatus:(N)=>N.status});if(x=D.status,w=D.file_id,!w)throw new y("Task completed but no file_id returned.",b.GENERAL);v=(await q(e,{url:Ci(e.baseUrl,w)})).file?.download_url}if(!v)throw new y("No download URL available for this file.",b.GENERAL);if(t.download){let U=t.download,{size:D}=await Ge(v,U,{quiet:e.quiet});if(e.quiet)console.log(U);else console.log(O({task_id:p,status:x,file_id:w,saved:U,size:Hi(D)},u));return}let E=await import("os"),{join:A}=await import("path"),_=A(E.tmpdir(),"mmx-video"),{existsSync:S,mkdirSync:k}=await import("fs");if(!S(_))k(_,{recursive:!0});let R=A(_,`${p}.mp4`);await Ge(v,R,{quiet:e.quiet}),process.stdout.write(R),process.stdout.write(`
|
|
229
|
+
`)}})});var Zu;var ef=T(()=>{X();G();j();oe();ee();fo();Zu=C({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"},{flag:"--model <model>",description:"Use MiniMax-H3 for Video Generation V2 tasks; defaults to the legacy V1 query."}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json","mmx video task get --task-id 424010985738629 --model MiniMax-H3 --output json"],async run(e,t){let n=t.taskId;if(!n)throw new y("--task-id is required.",b.USAGE,"mmx video task get --task-id <id>");if(e.dryRun){console.log(`Would query task: ${n}`);return}let i=F(e.output),r=t.model;if(Et(r)){let a=Ni(e.baseUrl,n),c=(await q(e,{url:a})).task;if(e.quiet){console.log(c.status);return}console.log(O({task_id:c.id,model:c.model,status:c.status,url:c.content?.url,resolution:c.resolution,duration:c.duration,ratio:c.ratio,error:c.error},i));return}let s=Oi(e.baseUrl,n),o=await q(e,{url:s});if(e.quiet){console.log(o.status);return}console.log(O({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},i))}})});var tf;var nf=T(()=>{X();G();j();oe();En();ee();tf=C({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(e,t){let n=t.fileId;if(!n)throw new y("--file-id is required.",b.USAGE,"mmx video download --file-id <id> --out <path>");let i=t.out;if(!i)throw new y("--out is required.",b.USAGE,"mmx video download --file-id <id> --out video.mp4");if(e.dryRun){console.log(`Would download file ${n} to ${i}`);return}let r=Ci(e.baseUrl,n),o=(await q(e,{url:r})).file?.download_url;if(!o)throw new y("No download URL available for this file.",b.GENERAL,"The file may still be processing. Check task status first.");let{size:a}=await Ge(o,i,{quiet:e.quiet}),l=F(e.output);if(e.quiet){console.log(i);return}console.log(O({saved:i,size:Hi(a)},l))}})});var po;var rf=T(()=>{X();oe();ee();G();j();po=C({name:"search query",description:"Search the web via MiniMax. Note: the underlying /v1/coding_plan/search API returns at most 10 results per call and does not currently support pagination, so refining your --q is the only way to see different results.",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(e,t){let n=t.q??t.query??t._positional?.[0];if(!n)throw new y("--q is required.",b.USAGE,'mmx search query --q "your search query"');let i=F(e.output);if(e.dryRun){console.log(O({request:{q:n}},i));return}let r=dc(e.baseUrl),s=await q(e,{url:r,method:"POST",body:{q:n}}),o=s.organic||[];if(i!=="text"){console.log(O(s,i));return}if(e.quiet){for(let a of o)console.log(`${a.title} ${a.link}`);return}if(o.length===0){console.log("No results found.");return}for(let a of o){if(console.log(`${a.title}`),console.log(` ${a.link}`),a.snippet)console.log(` ${a.snippet}`);if(a.date)console.log(` ${a.date}`);console.log("")}}})});var sf;var of=T(()=>{X();oe();ee();G();j();De();An();sf=C({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(e,t){let n=t.image??t.file??t.path??t._positional?.[0],i=t.fileId,r=t.prompt||"Describe the image.";if(!n&&!i)if(Q({nonInteractive:e.nonInteractive})){let c=await Ie({message:"Enter image path, URL, or File ID:"});if(!c)process.stderr.write(`Vision describe cancelled.
|
|
230
|
+
`),process.exit(1);if(!c.includes(".")&&!c.startsWith("http"))i=c;else n=c}else throw new y("Missing required argument. Must provide either --image or --file-id.",b.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(n&&i)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",b.USAGE);if(Ae(e,{prompt:r,image:n,fileId:i}))return;let s=F(e.output),o=pc(e.baseUrl),a={prompt:r};if(i)a.file_id=i;else if(n){let c=await Iu(n);a.image_url=c}let l=await q(e,{url:o,method:"POST",body:a});if(s!=="text"){process.stdout.write(O(l,s)+`
|
|
231
231
|
`);return}process.stdout.write(l.content+`
|
|
232
|
-
`)}})});var
|
|
233
|
-
`)}catch{throw new y(`Command "${n}" not found.`,b.USAGE)}return}let r=
|
|
234
|
-
`)}})});var
|
|
235
|
-
`),process.exit(1)}else
|
|
236
|
-
`);return}let a=await
|
|
232
|
+
`)}})});var af;var lf=T(()=>{X();oe();Ii();ee();Pi();af=C({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(e,t){if(e.dryRun){console.log("Would fetch quota information.");return}let n=F(e.output),i=await Bt(e),r=js(e.baseUrl,i);if(r.kind==="account-balance"){let a=await q(e,{url:r.url});if(n!=="text"){console.log(O(a,n));return}Ye(a,e,i.token);return}let s=await q(e,{url:r.url}),o=s.model_remains||[];if(n!=="text"){console.log(O(s,n));return}if(e.quiet){for(let a of o){let l=Ri(a.current_interval_usage_count,a.current_interval_total_count,a.current_interval_remaining_percent);if(l){console.log(`${a.model_name} ${l.used} ${l.total} ${l.remaining}`);continue}let c=a.current_interval_remaining_percent===void 0||a.current_interval_remaining_percent===null?"-":`${a.current_interval_remaining_percent}%`;console.log(`${a.model_name} - ${a.current_interval_total_count} ${c}`)}return}Ye(s,e)}})});var cf;var uf=T(()=>{X();Re();Xe();ee();cf=C({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(e,t){let n=Z(),i=F(e.output),r={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:de()};if(n.api_key)r.api_key=he(n.api_key);if(n.default_text_model)r.default_text_model=n.default_text_model;if(n.default_speech_model)r.default_speech_model=n.default_speech_model;if(n.default_video_model)r.default_video_model=n.default_video_model;if(n.proxy)r.proxy=n.proxy;console.log(O(r,i))}})});function df(e,t){return e==="api_key"?he(String(t)):t}var ff,_b,pf;var mf=T(()=>{X();G();j();ee();Re();ff=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model"],_b={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model"};pf=C({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key, proxy, default_text_model, default_speech_model, default_video_model)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key proxy --value http://127.0.0.1:7890","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(e,t){let n=t._positional,i=t.key??n?.[0],r=t.value??n?.[1];if(!i||r===void 0)throw new y("--key and --value are required.",b.USAGE,"mmx config set --key <key> --value <value>");let s=_b[i]||i;if(!ff.includes(s))throw new y(`Invalid config key "${i}". Valid keys: ${ff.join(", ")}`,b.USAGE);let o=s==="api_key"?r.trim():r;if(s==="api_key"&&o.length===0)throw new y("Invalid api_key. The value must not be empty.",b.USAGE);if(s==="region"&&!["global","cn"].includes(r))throw new y(`Invalid region "${r}". Valid values: global, cn`,b.USAGE);if(s==="output"&&!["text","json"].includes(r))throw new y(`Invalid output format "${r}". Valid values: text, json`,b.USAGE);if(s==="base_url"&&!r.startsWith("http"))throw new y(`Invalid base_url "${r}". Must start with http.`,b.USAGE);if(s==="proxy"&&!r.startsWith("http"))throw new y(`Invalid proxy "${r}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,b.USAGE);if(s==="timeout"){let c=Number(r);if(isNaN(c)||c<=0)throw new y(`Invalid timeout "${r}". Must be a positive number.`,b.USAGE)}let a=F(e.output);if(e.dryRun){console.log(O({would_set:{[s]:df(s,o)}},a));return}let l=Z();if(l[s]=s==="timeout"?Number(o):o,s==="api_key")delete l.oauth,delete l.region;if(await pe(l),!e.quiet)console.log(O({[s]:df(s,l[s])},a))}})});function Eb(e){let t=e.match(/^--([a-zA-Z0-9-]+)/),n=t?t[1]:"",i=n.replace(/-([a-zA-Z0-9])/g,(o,a)=>a.toUpperCase()),r="string",s=!1;if(!e.includes("<")&&!e.includes("["))r="boolean";else if(e.includes("<n>")||e.includes("<hz>")||e.includes("<bps>")||e.includes("<count>"))r="number";if(e.toLowerCase().includes("repeatable"))s=!0;return{name:i,kebabName:n,inferredType:r,isArray:s}}function mo(e){let n={name:`mmx_${e.name.replace(/ /g,"_")}`,description:e.description,input_schema:{type:"object",properties:{},required:[]}};if(e.options)for(let i of e.options){if(i.hidden)continue;let{name:r,inferredType:s,isArray:o}=Eb(i.flag);if(!r)continue;let a=i.type,l=o?"array":a??s,c={description:i.description};if(l==="array")c.type="array",c.items={type:"string"};else c.type=l;let f=n.input_schema;if(f.properties[r]=c,i.required)f.required.push(r)}return n}var Ab,hf;var gf=T(()=>{X();Di();G();j();Ab=["auth ","config ","update"],hf=C({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(e,t){let n=t.command;if(n){try{let{command:s}=Me.resolve(n.split(" ")),o=mo(s);process.stdout.write(JSON.stringify(o,null,2)+`
|
|
233
|
+
`)}catch{throw new y(`Command "${n}" not found.`,b.USAGE)}return}let r=Me.getAllCommands().filter((s)=>!Ab.some((o)=>s.name.startsWith(o))).map((s)=>mo(s));process.stdout.write(JSON.stringify(r,null,2)+`
|
|
234
|
+
`)}})});var yf;var bf=T(()=>{X();G();j();oe();Xs();ee();De();yf=C({name:"file upload",description:"Upload a file to MiniMax storage",usage:"mmx file upload --file <path> [--purpose <purpose>]",options:[{flag:"--file <path>",description:"Local path to the file",required:!0},{flag:"--purpose <string>",description:"File purpose (default: retrieval)"}],examples:["mmx file upload --file doc.pdf","mmx file upload --file image.png --purpose vision"],async run(e,t){let n=t.file;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ie({message:"Enter file path:"}),!n)process.stderr.write(`Upload cancelled.
|
|
235
|
+
`),process.exit(1)}else wt("file","mmx file upload --file <path>");let i=(l)=>new y(`File not found: ${l}`,b.USAGE),r=_n(n,i),s=t.purpose||"retrieval",o=F(e.output);if(e.dryRun){process.stdout.write(O({request:{file:r,purpose:s}},o)+`
|
|
236
|
+
`);return}let a=await uu({filePath:r,purpose:s,baseUrl:e.baseUrl,requestJson:(l)=>q(e,l),createFileNotFoundError:i});if(e.quiet){process.stdout.write(a.file.file_id+`
|
|
237
237
|
`);return}process.stdout.write(O(a.file,o)+`
|
|
238
|
-
`)}})});var
|
|
239
|
-
`);return}let i=
|
|
238
|
+
`)}})});var wf;var xf=T(()=>{X();oe();ee();wf=C({name:"file list",description:"List uploaded files in MiniMax storage",usage:"mmx file list",examples:["mmx file list","mmx file list --output json"],async run(e,t){let n=F(e.output);if(e.dryRun){process.stdout.write(`Would list uploaded files.
|
|
239
|
+
`);return}let i=hc(e.baseUrl),r=await q(e,{url:i,method:"GET"});if(n!=="text"){process.stdout.write(O(r,n)+`
|
|
240
240
|
`);return}if(!r.files||r.files.length===0){process.stdout.write(`No files found.
|
|
241
|
-
`);return}let s=r.files.map((a)=>({ID:a.file_id,FILENAME:a.filename,PURPOSE:a.purpose,SIZE_KB:(a.bytes/1024).toFixed(1),CREATED:new Date(a.created_at*1000).toISOString().slice(0,16).replace("T"," ")}));await Promise.resolve();process.stdout.write(
|
|
242
|
-
`)}})});var
|
|
243
|
-
`),process.exit(1)}else
|
|
244
|
-
`);return}let r=
|
|
241
|
+
`);return}let s=r.files.map((a)=>({ID:a.file_id,FILENAME:a.filename,PURPOSE:a.purpose,SIZE_KB:(a.bytes/1024).toFixed(1),CREATED:new Date(a.created_at*1000).toISOString().slice(0,16).replace("T"," ")}));await Promise.resolve();process.stdout.write(ts(s)+`
|
|
242
|
+
`)}})});var vf;var Sf=T(()=>{X();oe();ee();De();vf=C({name:"file delete",description:"Delete an uploaded file from MiniMax storage",usage:"mmx file delete --file-id <id>",options:[{flag:"--file-id <id>",description:"ID of the file to delete",required:!0}],examples:["mmx file delete --file-id 123456789"],async run(e,t){let n=t.fileId;if(!n)if(Q({nonInteractive:e.nonInteractive})){if(n=await Ie({message:"Enter file ID to delete:"}),!n)process.stderr.write(`Delete cancelled.
|
|
243
|
+
`),process.exit(1)}else wt("file-id","mmx file delete --file-id <id>");let i=F(e.output);if(e.dryRun){process.stdout.write(O({request:{delete_file:n}},i)+`
|
|
244
|
+
`);return}let r=gc(e.baseUrl),s=await q(e,{url:r,method:"POST",body:{file_id:Number(n)}});if(e.quiet){process.stdout.write(`deleted
|
|
245
245
|
`);return}process.stdout.write(O({file_id:s.file_id,deleted:!0},i)+`
|
|
246
|
-
`)}})});var
|
|
246
|
+
`)}})});var $f;var _f=T(()=>{X();Ti();$f=C({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${xt}
|
|
247
247
|
|
|
248
248
|
`),process.stderr.write(`Run:
|
|
249
249
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
250
250
|
|
|
251
|
-
`)}})});var
|
|
251
|
+
`)}})});var kb,Ef;var Af=T(()=>{X();Ee();kb=[{command:"mmx text chat",title:"Text Generation (Chat Completion)",path:"/docs/api-reference/text-post"},{command:"mmx speech synthesize",title:"Speech T2A (Text-to-Audio)",path:"/docs/api-reference/speech-t2a-http"},{command:"mmx speech transcribe",title:"Speech STT (Speech-to-Text)",path:"/docs/api-reference/speech-to-text"},{command:"mmx image generate",title:"Image Generation (T2I / I2I)",path:"/docs/api-reference/image-generation-t2i"},{command:"mmx video generate",title:"Video Generation (T2V / I2V / S2V)",path:"/docs/api-reference/video-generation"},{command:"mmx search query",title:"Web Search",path:"/docs/api-reference/web-search"},{command:"mmx vision describe",title:"Vision (Image Understanding)",path:"/docs/api-reference/vision"}],Ef=C({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(e,t){let n=ht[e.region]||ht.global;process.stdout.write(`
|
|
252
252
|
MiniMax API Documentation Links
|
|
253
253
|
|
|
254
254
|
Official docs: ${n}/docs/api-reference
|
|
255
255
|
|
|
256
|
-
`);for(let i of
|
|
256
|
+
`);for(let i of kb)process.stdout.write(` ${i.command.padEnd(30)} ${i.title}
|
|
257
257
|
`),process.stdout.write(` ${" ".repeat(30)} ${n}${i.path}
|
|
258
258
|
|
|
259
|
-
`)}})});var
|
|
259
|
+
`)}})});var Ib,it;var ho=T(()=>{/*!
|
|
260
260
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
261
261
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
262
262
|
*
|
|
@@ -282,9 +282,9 @@ MiniMax API Documentation Links
|
|
|
282
282
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
283
283
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
284
284
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
285
|
-
*/
|
|
285
|
+
*/Ib=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;it=class it extends Date{#t=!1;#n=!1;#e=null;constructor(e){let t=!0,n=!0,i="Z";if(typeof e==="string"){let r=e.match(Ib);if(r){if(!r[1])t=!1,e=`0000-01-01T${e}`;if(n=!!r[2],n&&e[10]===" "&&(e=e.replace(" ","T")),r[2]&&+r[2]>23)e="";else if(i=r[3]||null,e=e.toUpperCase(),!i&&n)e+="Z"}else e=""}super(e);if(!isNaN(this.getTime()))this.#t=t,this.#n=n,this.#e=i}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#e===null)return e.slice(0,-1);if(this.#e==="Z")return e;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*60000).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(e,t="Z"){let n=new it(e);return n.#e=t,n}static wrapAsLocalDateTime(e){let t=new it(e);return t.#e=null,t}static wrapAsLocalDate(e){let t=new it(e);return t.#n=!1,t.#e=null,t}static wrapAsLocalTime(e){let t=new it(e);return t.#t=!1,t.#e=null,t}}});function Tb(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function Mb(e,t,n){let i=e.split(/\r\n|\n|\r/g),r="",s=(Math.log10(t+1)|0)+1;for(let o=t-1;o<=t+1;o++){let a=i[o-1];if(!a)continue;if(r+=o.toString().padEnd(s," "),r+=": ",r+=a,r+=`
|
|
286
286
|
`,o===t)r+=" ".repeat(s+n+2),r+=`^
|
|
287
|
-
`}return r}var B;var
|
|
287
|
+
`}return r}var B;var At=T(()=>{/*!
|
|
288
288
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
289
289
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
290
290
|
*
|
|
@@ -310,10 +310,10 @@ MiniMax API Documentation Links
|
|
|
310
310
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
311
311
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
312
312
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
313
|
-
*/B=class B extends Error{line;column;codeblock;constructor(e,t){let[n,i]=
|
|
313
|
+
*/B=class B extends Error{line;column;codeblock;constructor(e,t){let[n,i]=Tb(t.toml,t.ptr),r=Mb(t.toml,n,i);super(`Invalid TOML document: ${e}
|
|
314
314
|
|
|
315
|
-
${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function
|
|
316
|
-
`,t);if(e.charCodeAt(n-1)===13)n--;return n}function
|
|
315
|
+
${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function go(e,t=0){let n=e.indexOf(`
|
|
316
|
+
`,t);if(e.charCodeAt(n-1)===13)n--;return n}function zi(e){for(;e.p<e.s.length;e.p++){let t=e.s.charCodeAt(e.p);if(t===10)break;if(t===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}if(t<32&&t!==9||t===127)throw new B("control characters are not allowed in comments",{toml:e.s,ptr:e.p})}}function Be(e,t,n){let i;while(!0){while((i=e.s.charCodeAt(e.p))===32||i===9||!t&&(i===10||i===13&&e.s.charCodeAt(e.p+1)===10))e.p++;if(n||i!==35)break;zi(e)}}function kf(e,t,n){let i=e.p;if(!n){i=go(e.s,i),e.p=i<0?e.s.length:i;return}for(;e.p<e.s.length;e.p++){let r=e.s.charCodeAt(e.p);if(r===35)zi(e);else if(r===n||r===t)return}throw new B("cannot find end of structure",{toml:e.s,ptr:i})}var Xi=T(()=>{At();/*!
|
|
317
317
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
318
318
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
319
319
|
*
|
|
@@ -339,8 +339,8 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
339
339
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
340
340
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
341
341
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
342
|
-
*/});function
|
|
343
|
-
`;else if(n===102)o+="\f";else if(n===114)o+="\r";else if(n===101)o+="\x1B";else if(n===34)o+='"';else if(n===92)o+="\\";else throw new B("unrecognized escape sequence",{toml:e.s,ptr:e.p});a=e.p+1,l=0}else if(n!==32&&n!==9){if(l===2)throw new B("invalid escape: only line-ending whitespace may be escaped",{toml:e.s,ptr:a});l=!r&&n===92?1:0,a=e.p}throw new B("unfinished string",{toml:e.s,ptr:t})}function
|
|
342
|
+
*/});function Qi(e){let t=e.p,n=e.s.charCodeAt(e.p++),i=n,r=n===39,s=n===e.s.charCodeAt(e.p)&&n===e.s.charCodeAt(e.p+1);if(s){if((n=e.s.charCodeAt(e.p+=2))===10)e.p++;else if(n===13&&e.s.charCodeAt(e.p+1)===10)e.p+=2}let o="",a=e.p,l=0;for(;e.p<e.s.length;e.p++)if(n=e.s.charCodeAt(e.p),s&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10))l=l&&3;else if(n<32&&n!==9||n===127)throw new B("control characters are not allowed in strings",{toml:e.s,ptr:e.p});else if((!l||l===3)&&n===i&&(!s||e.s.charCodeAt(e.p+1)===i&&e.s.charCodeAt(e.p+2)===i)){if(s){if(e.s.charCodeAt(e.p+3)===i)e.p++;if(e.s.charCodeAt(e.p+3)===i)e.p++}if(!l)o+=e.s.slice(a,e.p);return e.p+=s?3:1,o}else if(!l){if(!r&&n===92)o+=e.s.slice(a,a=e.p),l=1}else if(l===1)if(n===120||n===117||n===85){let c=0,f=n===120?2:n===117?4:8;for(let u=0;u<f;u++,e.p++){let d=e.s.charCodeAt(e.p+1),g=d>=48&&d<=57?d-48:d>=65&&d<=70?d-65+10:d>=97&&d<=102?d-97+10:-1;if(g<0)throw new B("invalid non-hex character in unicode escape",{toml:e.s,ptr:e.p+1});c=c<<4|g}if(c<0||c>1114111||c>=55296&&c<=57343)throw new B("invalid unicode escape",{toml:e.s,ptr:e.p});o+=String.fromCodePoint(c),a=e.p+1,l=0}else if(n===32||n===9)l=2;else{if(n===98)o+="\b";else if(n===116)o+="\t";else if(n===110)o+=`
|
|
343
|
+
`;else if(n===102)o+="\f";else if(n===114)o+="\r";else if(n===101)o+="\x1B";else if(n===34)o+='"';else if(n===92)o+="\\";else throw new B("unrecognized escape sequence",{toml:e.s,ptr:e.p});a=e.p+1,l=0}else if(n!==32&&n!==9){if(l===2)throw new B("invalid escape: only line-ending whitespace may be escaped",{toml:e.s,ptr:a});l=!r&&n===92?1:0,a=e.p}throw new B("unfinished string",{toml:e.s,ptr:t})}function Rb(e,t,n){let i=e.s.slice(t,n),r=i.indexOf("#");if(r>0)zi({s:i,p:r,d:0}),i=i.slice(0,r);return i.trimEnd()}function If(e,t,n){let i=e.p,r={toml:e.s,ptr:i};kf(e,44,n);let s=Rb(e,i,e.p);if(!s)throw new B("incomplete declaration: value expected",r);if(s==="-inf")return-1/0;if(s==="inf"||s==="+inf")return 1/0;if(s==="nan"||s==="+nan"||s==="-nan")return NaN;if(s==="-0")return t?0n:0;let o=Ob.test(s);if(o||Nb.test(s)){if(Cb.test(s))throw new B("leading zeroes are not allowed",r);s=s.replace(/_/g,"");let l=+s;if(isNaN(l))throw new B("invalid number",r);if(o){if((o=!Number.isSafeInteger(l))&&!t)throw new B("integer value cannot be represented losslessly",r);if(o||t===!0)l=BigInt(s)}return l}let a=new it(s);if(!a.isValid())throw new B("invalid value",r);return a}var Ob,Nb,Cb;var yo=T(()=>{ho();At();Xi();/*!
|
|
344
344
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
345
345
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
346
346
|
*
|
|
@@ -366,7 +366,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
366
366
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
367
367
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
368
368
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
369
|
-
*/
|
|
369
|
+
*/Ob=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Nb=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Cb=/^[+-]?0[0-9_]/});function Tn(e,t,n){let i=e.p,r=e.s.charCodeAt(i);if(r===91||r===123){if(!e.d--)throw new B("document contains excessively nested structures. aborting.",{toml:e.s,ptr:i});let s=r===91?Mf(e,n):Tf(e,n);return e.d++,s}if(r===34||r===39)return Qi(e);if(r===116){if(e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)throw new B("invalid value",{toml:e.s,ptr:i});return e.p++,!0}if(r===102){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)throw new B("invalid value",{toml:e.s,ptr:i});return e.p++,!1}return If(e,n,t)}var bo=T(()=>{yo();wo();At();/*!
|
|
370
370
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
371
371
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
372
372
|
*
|
|
@@ -392,7 +392,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
392
392
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
393
393
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
394
394
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
395
|
-
*/});function
|
|
395
|
+
*/});function Zi(e,t="="){let n=e.p,i=n-1,r=[],s=e.s.indexOf(t,n);if(s<0)throw new B("incomplete key-value: cannot find end of key",{toml:e.s,ptr:n});do{let o=e.s.charCodeAt(e.p=++i);if(o!==32&&o!==9)if(o===34||o===39){if(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2))throw new B("multiline strings are not allowed in keys",{toml:e.s,ptr:e.p});let a=Qi(e);i=e.s.indexOf(".",e.p);let l=e.s.slice(e.p,i<0||i>s?s:i),c=go(l);if(c>-1)throw new B("newlines are not allowed in keys",{toml:e.s,ptr:c});if(l.trimStart())throw new B("found extra tokens after the string part",{toml:e.s,ptr:e.p});if(s<e.p){if(s=e.s.indexOf(t,e.p),s<0)throw new B("incomplete key-value: cannot find end of key",{toml:e.s,ptr:n})}r.push(a)}else{i=e.s.indexOf(".",e.p);let a=e.s.slice(e.p,i<0||i>s?s:i);if(!Lb.test(a))throw new B("only letter, numbers, dashes and underscores are allowed in keys",{toml:e.s,ptr:e.p});r.push(a.trimEnd())}}while(i+1&&i<s);return e.p=s+1,Be(e,!0,!0),r}function Tf(e,t){let n={},i=new Set,r;e.p++;while(e.p<e.s.length){if(Be(e),(r=e.s.charCodeAt(e.p))===125)return e.p++,n;let s,o=n,a=!1,l=e.p,c=Zi(e);for(let u=0;u<c.length;u++){if(u)o=a?o[s]:o[s]={};if(s=c[u],(a=Object.hasOwn(o,s))&&(typeof o[s]!=="object"||i.has(o[s])))throw new B("trying to redefine an already defined value",{toml:e.s,ptr:l});if(!a&&s==="__proto__")Object.defineProperty(o,s,{enumerable:!0,configurable:!0,writable:!0})}if(a)throw new B("trying to redefine an already defined value",{toml:e.s,ptr:e.p});let f=Tn(e,125,t);if(i.add(o[s]=f),Be(e),(r=e.s.charCodeAt(e.p++))===125)return n;if(r!==44)throw new B("expected comma or end of structure",{toml:e.s,ptr:e.p-1})}throw new B("unfinished table encountered",{toml:e.s,ptr:e.p})}function Mf(e,t){let n=[],i;e.p++;while(e.p<e.s.length){if(Be(e),(i=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(Tn(e,93,t)),Be(e),(i=e.s.charCodeAt(e.p++))===93)return n;if(i!==44)throw new B("expected comma or end of structure",{toml:e.s,ptr:e.p-1})}throw new B("unfinished array encountered",{toml:e.s,ptr:e.p})}var Lb;var wo=T(()=>{yo();bo();Xi();At();/*!
|
|
396
396
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
397
397
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
398
398
|
*
|
|
@@ -418,7 +418,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
418
418
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
419
419
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
420
420
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
421
|
-
*/
|
|
421
|
+
*/Lb=/^[a-zA-Z0-9-_]+[ \t]*$/});function Of(e,t,n,i){let r=t,s=n,o,a=!1,l;for(let c=0;c<e.length;c++){if(c){if(r=a?r[o]:r[o]={},s=(l=s[o]).c,i===0&&(l.t===1||l.t===2))return null;if(l.t===2){let f=r.length-1;r=r[f],s=s[f].c}}if(o=e[c],(a=Object.hasOwn(r,o))&&s[o]?.t===0&&s[o]?.d)return null;if(!a){if(o==="__proto__")Object.defineProperty(r,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0});s[o]={t:c<e.length-1&&i===2?3:i,d:!1,i:0,c:{}}}}if(l=s[o],l.t!==i&&!(i===1&&l.t===3))return null;if(i===2){if(!l.d)l.d=!0,r[o]=[];r[o].push(r={}),l.c[l.i++]=l={t:1,d:!1,i:0,c:{}}}if(l.d)return null;if(l.d=!0,i===1)r=a?r[o]:r[o]={};else if(i===0&&a)return null;return[o,r,l.c]}function kt(e,{maxDepth:t=1000,integersAsBigInt:n}={}){let i={s:e,p:0,d:t},r={},s={},o,a=r,l=s;Be(i);while(i.p<e.length){if(e.charCodeAt(i.p)===91){let c=e.charCodeAt(++i.p)===91;o=i.p+=+c;let f=Zi(i,"]");if(c){if(e.charCodeAt(i.p-1)!==93)throw new B("expected end of table declaration",{toml:e,ptr:i.p-1});i.p++}let u=Of(f,r,s,c?2:1);if(!u)throw new B("trying to redefine an already defined table or value",{toml:e,ptr:o});l=u[2],a=u[1]}else{o=i.p;let c=Zi(i),f=Of(c,a,l,0);if(!f)throw new B("trying to redefine an already defined table or value",{toml:e,ptr:o});f[1][f[0]]=Tn(i,void 0,n)}if(Be(i,!0),i.p<e.length&&(o=e.charCodeAt(i.p))!==10&&o!==13)throw new B("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:i.p});Be(i)}return r}var Nf=T(()=>{wo();bo();Xi();At();/*!
|
|
422
422
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
423
423
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
424
424
|
*
|
|
@@ -444,7 +444,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
444
444
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
445
445
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
446
446
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
447
|
-
*/});var
|
|
447
|
+
*/});var Cf=T(()=>{/*!
|
|
448
448
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
449
449
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
450
450
|
*
|
|
@@ -470,7 +470,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
470
470
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
471
471
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
472
472
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
473
|
-
*/});var
|
|
473
|
+
*/});var xo=T(()=>{Nf();Cf();ho();At();/*!
|
|
474
474
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
475
475
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
476
476
|
*
|
|
@@ -496,215 +496,221 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n
|
|
|
496
496
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
497
497
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
498
498
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
499
|
-
*/});function
|
|
500
|
-
`;break;case 114:x+="\r";break;case 116:x+="\t";break;case 117:let S=
|
|
501
|
-
`;return a++,c=i,o=14}switch(x){case 123:return i++,o=1;case 125:return i++,o=2;case 91:return i++,o=3;case 93:return i++,o=4;case 58:return i++,o=6;case 44:return i++,o=5;case 34:return i++,r=
|
|
499
|
+
*/});function On(e,t=!1){let n=e.length,i=0,r="",s=0,o=16,a=0,l=0,c=0,f=0,u=0;function d(x,E){let A=0,_=0;while(A<x||!E){let S=e.charCodeAt(i);if(S>=48&&S<=57)_=_*16+S-48;else if(S>=65&&S<=70)_=_*16+S-65+10;else if(S>=97&&S<=102)_=_*16+S-97+10;else break;i++,A++}if(A<x)_=-1;return _}function g(x){i=x,r="",s=0,o=16,u=0}function h(){let x=i;if(e.charCodeAt(i)===48)i++;else{i++;while(i<e.length&&Ht(e.charCodeAt(i)))i++}if(i<e.length&&e.charCodeAt(i)===46)if(i++,i<e.length&&Ht(e.charCodeAt(i))){i++;while(i<e.length&&Ht(e.charCodeAt(i)))i++}else return u=3,e.substring(x,i);let E=i;if(i<e.length&&(e.charCodeAt(i)===69||e.charCodeAt(i)===101)){if(i++,i<e.length&&e.charCodeAt(i)===43||e.charCodeAt(i)===45)i++;if(i<e.length&&Ht(e.charCodeAt(i))){i++;while(i<e.length&&Ht(e.charCodeAt(i)))i++;E=i}else u=3}return e.substring(x,E)}function p(){let x="",E=i;while(!0){if(i>=n){x+=e.substring(E,i),u=2;break}let A=e.charCodeAt(i);if(A===34){x+=e.substring(E,i),i++;break}if(A===92){if(x+=e.substring(E,i),i++,i>=n){u=2;break}switch(e.charCodeAt(i++)){case 34:x+='"';break;case 92:x+="\\";break;case 47:x+="/";break;case 98:x+="\b";break;case 102:x+="\f";break;case 110:x+=`
|
|
500
|
+
`;break;case 114:x+="\r";break;case 116:x+="\t";break;case 117:let S=d(4,!0);if(S>=0)x+=String.fromCharCode(S);else u=4;break;default:u=5}E=i;continue}if(A>=0&&A<=31)if(Mn(A)){x+=e.substring(E,i),u=2;break}else u=6;i++}return x}function m(){if(r="",u=0,s=i,l=a,f=c,i>=n)return s=n,o=17;let x=e.charCodeAt(i);if(vo(x)){do i++,r+=String.fromCharCode(x),x=e.charCodeAt(i);while(vo(x));return o=15}if(Mn(x)){if(i++,r+=String.fromCharCode(x),x===13&&e.charCodeAt(i)===10)i++,r+=`
|
|
501
|
+
`;return a++,c=i,o=14}switch(x){case 123:return i++,o=1;case 125:return i++,o=2;case 91:return i++,o=3;case 93:return i++,o=4;case 58:return i++,o=6;case 44:return i++,o=5;case 34:return i++,r=p(),o=10;case 47:let E=i-1;if(e.charCodeAt(i+1)===47){i+=2;while(i<n){if(Mn(e.charCodeAt(i)))break;i++}return r=e.substring(E,i),o=12}if(e.charCodeAt(i+1)===42){i+=2;let A=n-1,_=!1;while(i<A){let S=e.charCodeAt(i);if(S===42&&e.charCodeAt(i+1)===47){i+=2,_=!0;break}if(i++,Mn(S)){if(S===13&&e.charCodeAt(i)===10)i++;a++,c=i}}if(!_)i++,u=1;return r=e.substring(E,i),o=13}return r+=String.fromCharCode(x),i++,o=16;case 45:if(r+=String.fromCharCode(x),i++,i===n||!Ht(e.charCodeAt(i)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=h(),o=11;default:while(i<n&&v(x))i++,x=e.charCodeAt(i);if(s!==i){switch(r=e.substring(s,i),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(x),i++,o=16}}function v(x){if(vo(x)||Mn(x))return!1;switch(x){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function w(){let x;do x=m();while(x>=12&&x<=15);return x}return{setPosition:g,getPosition:()=>i,scan:t?w:m,getToken:()=>o,getTokenValue:()=>r,getTokenOffset:()=>s,getTokenLength:()=>i-s,getTokenStartLine:()=>l,getTokenStartCharacter:()=>s-f,getTokenError:()=>u}}function vo(e){return e===32||e===9}function Mn(e){return e===10||e===13}function Ht(e){return e>=48&&e<=57}var Rf;var er=T(()=>{(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Rf||(Rf={}))});var ye,So,Lf;var Pf=T(()=>{ye=Array(20).fill(0).map((e,t)=>" ".repeat(t)),So={" ":{"\n":Array(200).fill(0).map((e,t)=>`
|
|
502
502
|
`+" ".repeat(t)),"\r":Array(200).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>`\r
|
|
503
503
|
`+" ".repeat(t))},"\t":{"\n":Array(200).fill(0).map((e,t)=>`
|
|
504
504
|
`+"\t".repeat(t)),"\r":Array(200).fill(0).map((e,t)=>"\r"+"\t".repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>`\r
|
|
505
|
-
`+"\t".repeat(t))}},
|
|
505
|
+
`+"\t".repeat(t))}},Lf=[`
|
|
506
506
|
`,"\r",`\r
|
|
507
|
-
`]});function
|
|
507
|
+
`]});function $o(e,t,n){let i,r,s,o,a;if(t){o=t.offset,a=o+t.length,s=o;while(s>0&&!Nn(e,s-1))s--;let A=a;while(A<e.length&&!Nn(e,A))A++;r=e.substring(s,A),i=Fb(r,n)}else r=e,i=0,s=0,o=0,a=e.length;let l=Db(n,e),c=Lf.includes(l),f=0,u=0,d;if(n.insertSpaces)d=ye[n.tabSize||4]??Kt(ye[1],n.tabSize||4);else d="\t";let g=d==="\t"?"\t":" ",h=On(r,!1),p=!1;function m(){if(f>1)return Kt(l,f)+Kt(d,i+u);let A=d.length*(i+u);if(!c||A>So[g][l].length)return l+Kt(d,i+u);if(A<=0)return l;return So[g][l][A]}function v(){let A=h.scan();f=0;while(A===15||A===14){if(A===14&&n.keepLines)f+=1;else if(A===14)f=1;A=h.scan()}return p=A===16||h.getTokenError()!==0,A}let w=[];function x(A,_,S){if(!p&&(!t||_<a&&S>o)&&e.substring(_,S)!==A)w.push({offset:_,length:S-_,content:A})}let E=v();if(n.keepLines&&f>0)x(Kt(l,f),0,0);if(E!==17){let A=h.getTokenOffset()+s,_=d.length*i<20&&n.insertSpaces?ye[d.length*i]:Kt(d,i);x(_,s,A)}while(E!==17){let A=h.getTokenOffset()+h.getTokenLength()+s,_=v(),S="",k=!1;while(f===0&&(_===12||_===13)){let U=h.getTokenOffset()+s;x(ye[1],A,U),A=h.getTokenOffset()+h.getTokenLength()+s,k=_===12,S=k?m():"",_=v()}if(_===2){if(E!==1)u--;if(n.keepLines&&f>0||!n.keepLines&&E!==1)S=m();else if(n.keepLines)S=ye[1]}else if(_===4){if(E!==3)u--;if(n.keepLines&&f>0||!n.keepLines&&E!==3)S=m();else if(n.keepLines)S=ye[1]}else{switch(E){case 3:case 1:if(u++,n.keepLines&&f>0||!n.keepLines)S=m();else S=ye[1];break;case 5:if(n.keepLines&&f>0||!n.keepLines)S=m();else S=ye[1];break;case 12:S=m();break;case 13:if(f>0)S=m();else if(!k)S=ye[1];break;case 6:if(n.keepLines&&f>0)S=m();else if(!k)S=ye[1];break;case 10:if(n.keepLines&&f>0)S=m();else if(_===6&&!k)S="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(n.keepLines&&f>0)S=m();else if((_===12||_===13)&&!k)S=ye[1];else if(_!==5&&_!==17)p=!0;break;case 16:p=!0;break}if(f>0&&(_===12||_===13))S=m()}if(_===17)if(n.keepLines&&f>0)S=m();else S=n.insertFinalNewline?l:"";let R=h.getTokenOffset()+s;x(S,A,R),E=_}return w}function Kt(e,t){let n="";for(let i=0;i<t;i++)n+=e;return n}function Fb(e,t){let n=0,i=0,r=t.tabSize||4;while(n<e.length){let s=e.charAt(n);if(s===ye[1])i++;else if(s==="\t")i+=r;else break;n++}return Math.floor(i/r)}function Db(e,t){for(let n=0;n<t.length;n++){let i=t.charAt(n);if(i==="\r"){if(n+1<t.length&&t.charAt(n+1)===`
|
|
508
508
|
`)return`\r
|
|
509
509
|
`;return"\r"}else if(i===`
|
|
510
510
|
`)return`
|
|
511
511
|
`}return e&&e.eol||`
|
|
512
|
-
`}function
|
|
513
|
-
`.indexOf(e.charAt(t))!==-1}var vo=I(()=>{Xi();Of()});function Cf(e,t=[],n=Cn.DEFAULT){let i=null,r=[],s=[];function o(l){if(Array.isArray(r))r.push(l);else if(i!==null)r[i]=l}return $o(e,{onObjectBegin:()=>{let l={};o(l),s.push(r),r=l,i=null},onObjectProperty:(l)=>{i=l},onObjectEnd:()=>{r=s.pop()},onArrayBegin:()=>{let l=[];o(l),s.push(r),r=l,i=null},onArrayEnd:()=>{r=s.pop()},onLiteralValue:o,onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n),r[0]}function So(e,t=[],n=Cn.DEFAULT){let i={type:"array",offset:-1,length:-1,children:[],parent:void 0};function r(l){if(i.type==="property")i.length=l-i.offset,i=i.parent}function s(l){return i.children.push(l),l}$o(e,{onObjectBegin:(l)=>{i=s({type:"object",offset:l,length:-1,parent:i,children:[]})},onObjectProperty:(l,c,p)=>{i=s({type:"property",offset:c,length:-1,parent:i,children:[]}),i.children.push({type:"string",value:l,offset:c,length:p,parent:i})},onObjectEnd:(l,c)=>{r(l+c),i.length=l+c-i.offset,i=i.parent,r(l+c)},onArrayBegin:(l,c)=>{i=s({type:"array",offset:l,length:-1,parent:i,children:[]})},onArrayEnd:(l,c)=>{i.length=l+c-i.offset,i=i.parent,r(l+c)},onLiteralValue:(l,c,p)=>{s({type:Ob(l),offset:c,length:p,parent:i,value:l}),r(c+p)},onSeparator:(l,c,p)=>{if(i.type==="property"){if(l===":")i.colonOffset=c;else if(l===",")r(c)}},onError:(l,c,p)=>{t.push({error:l,offset:c,length:p})}},n);let a=i.children[0];if(a)delete a.parent;return a}function Qi(e,t){if(!e)return;let n=e;for(let i of t)if(typeof i==="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let r=!1;for(let s of n.children)if(Array.isArray(s.children)&&s.children[0].value===i&&s.children.length===2){n=s.children[1],r=!0;break}if(!r)return}else{let r=i;if(n.type!=="array"||r<0||!Array.isArray(n.children)||r>=n.children.length)return;n=n.children[r]}return n}function $o(e,t,n=Cn.DEFAULT){let i=Mn(e,!1),r=[],s=0;function o(L){return L?()=>s===0&&L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function a(L){return L?(J)=>s===0&&L(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(L){return L?(J)=>s===0&&L(J,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function c(L){return L?()=>{if(s>0)s++;else if(L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1)s=1}:()=>!0}function p(L){return L?()=>{if(s>0)s--;if(s===0)L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}let u=c(t.onObjectBegin),f=l(t.onObjectProperty),g=p(t.onObjectEnd),h=c(t.onArrayBegin),d=p(t.onArrayEnd),m=l(t.onLiteralValue),v=a(t.onSeparator),w=o(t.onComment),x=a(t.onError),E=n&&n.disallowComments,A=n&&n.allowTrailingComma;function _(){while(!0){let L=i.scan();switch(i.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:if(!E)S(11);break;case 2:S(12);break;case 6:S(16);break}switch(L){case 12:case 13:if(E)S(10);else w();break;case 16:S(1);break;case 15:case 14:break;default:return L}}}function S(L,J=[],ye=[]){if(x(L),J.length+ye.length>0){let We=i.getToken();while(We!==17){if(J.indexOf(We)!==-1){_();break}else if(ye.indexOf(We)!==-1)break;We=_()}}}function k(L){let J=i.getTokenValue();if(L)m(J);else f(J),r.push(J);return _(),!0}function R(){switch(i.getToken()){case 11:let L=i.getTokenValue(),J=Number(L);if(isNaN(J))S(2),J=0;m(J);break;case 7:m(null);break;case 8:m(!0);break;case 9:m(!1);break;default:return!1}return _(),!0}function U(){if(i.getToken()!==10)return S(3,[],[2,5]),!1;if(k(!1),i.getToken()===6){if(v(":"),_(),!C())S(4,[],[2,5])}else S(5,[],[2,5]);return r.pop(),!0}function q(){u(),_();let L=!1;while(i.getToken()!==2&&i.getToken()!==17){if(i.getToken()===5){if(!L)S(4,[],[]);if(v(","),_(),i.getToken()===2&&A)break}else if(L)S(6,[],[]);if(!U())S(4,[],[2,5]);L=!0}if(g(),i.getToken()!==2)S(7,[2],[]);else _();return!0}function P(){h(),_();let L=!0,J=!1;while(i.getToken()!==4&&i.getToken()!==17){if(i.getToken()===5){if(!J)S(4,[],[]);if(v(","),_(),i.getToken()===4&&A)break}else if(J)S(6,[],[]);if(L)r.push(0),L=!1;else r[r.length-1]++;if(!C())S(4,[],[4,5]);J=!0}if(d(),!L)r.pop();if(i.getToken()!==4)S(8,[4],[]);else _();return!0}function C(){switch(i.getToken()){case 3:return P();case 1:return q();case 10:return k(!0);default:return R()}}if(_(),i.getToken()===17){if(n.allowEmptyContent)return!0;return S(4,[],[]),!1}if(!C())return S(4,[],[]),!1;if(i.getToken()!==17)S(9,[],[]);return!0}function Ob(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!e)return"null";else if(Array.isArray(e))return"array";return"object"}default:return"null"}}var Cn;var _o=I(()=>{Xi();(function(e){e.DEFAULT={allowTrailingComma:!1}})(Cn||(Cn={}))});function Nf(e,t,n,i){let r=t.slice(),o=So(e,[]),a=void 0,l=void 0;while(r.length>0)if(l=r.pop(),a=Qi(o,r),a===void 0&&n!==void 0)if(typeof l==="string")n={[l]:n};else n=[n];else break;if(!a){if(n===void 0)throw Error("Can not delete in empty document");return At(e,{offset:o?o.offset:0,length:o?o.length:0,content:JSON.stringify(n)},i)}else if(a.type==="object"&&typeof l==="string"&&Array.isArray(a.children)){let c=Qi(a,[l]);if(c!==void 0)if(n===void 0){if(!c.parent)throw Error("Malformed AST");let p=a.children.indexOf(c.parent),u,f=c.parent.offset+c.parent.length;if(p>0){let g=a.children[p-1];u=g.offset+g.length}else if(u=a.offset+1,a.children.length>1)f=a.children[1].offset;return At(e,{offset:u,length:f-u,content:""},i)}else return At(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},i);else{if(n===void 0)return[];let p=`${JSON.stringify(l)}: ${JSON.stringify(n)}`,u=i.getInsertionIndex?i.getInsertionIndex(a.children.map((g)=>g.children[0].value)):a.children.length,f;if(u>0){let g=a.children[u-1];f={offset:g.offset+g.length,length:0,content:","+p}}else if(a.children.length===0)f={offset:a.offset+1,length:0,content:p};else f={offset:a.offset+1,length:0,content:p+","};return At(e,f,i)}}else if(a.type==="array"&&typeof l==="number"&&Array.isArray(a.children)){let c=l;if(c===-1){let p=`${JSON.stringify(n)}`,u;if(a.children.length===0)u={offset:a.offset+1,length:0,content:p};else{let f=a.children[a.children.length-1];u={offset:f.offset+f.length,length:0,content:","+p}}return At(e,u,i)}else if(n===void 0&&a.children.length>=0){let p=l,u=a.children[p],f;if(a.children.length===1)f={offset:a.offset+1,length:a.length-2,content:""};else if(a.children.length-1===p){let g=a.children[p-1],h=g.offset+g.length,d=a.offset+a.length;f={offset:h,length:d-2-h,content:""}}else f={offset:u.offset,length:a.children[p+1].offset-u.offset,content:""};return At(e,f,i)}else if(n!==void 0){let p,u=`${JSON.stringify(n)}`;if(!i.isArrayInsertion&&a.children.length>l){let f=a.children[l];p={offset:f.offset,length:f.length,content:u}}else if(a.children.length===0||l===0)p={offset:a.offset+1,length:0,content:a.children.length===0?u:u+","};else{let f=l>a.children.length?a.children.length:l,g=a.children[f-1];p={offset:g.offset+g.length,length:0,content:","+u}}return At(e,p,i)}else throw Error(`Can not ${n===void 0?"remove":i.isArrayInsertion?"insert":"modify"} Array index ${c} as length is not sufficient`)}else throw Error(`Can not add ${typeof l!=="number"?"index":"property"} to parent of type ${a.type}`)}function At(e,t,n){if(!n.formattingOptions)return[t];let i=Zi(e,t),r=t.offset,s=t.offset+t.content.length;if(t.length===0||t.content.length===0){while(r>0&&!On(i,r-1))r--;while(s<i.length&&!On(i,s))s++}let o=xo(i,{offset:r,length:s-r},{...n.formattingOptions,keepLines:!1});for(let l=o.length-1;l>=0;l--){let c=o[l];i=Zi(i,c),r=Math.min(r,c.offset),s=Math.max(s,c.offset+c.length),s+=c.content.length-c.length}let a=e.length-(i.length-s)-r;return[{offset:r,length:a,content:i.substring(r,s)}]}function Zi(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var Rf=I(()=>{vo();_o()});function Df(e,t,n,i){return Nf(e,t,n,i)}function Uf(e,t){let n=t.slice(0).sort((r,s)=>{let o=r.offset-s.offset;if(o===0)return r.length-s.length;return o}),i=e.length;for(let r=n.length-1;r>=0;r--){let s=n[r];if(s.offset+s.length<=i)e=Zi(e,s);else throw Error("Overlapping edit");i=s.offset}return e}var Lf,Pf,qf,Ff;var jf=I(()=>{vo();Rf();Xi();_o();(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Lf||(Lf={}));(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Pf||(Pf={}));qf=Cf;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Ff||(Ff={}))});var V=M(function(jb){var Eo=Symbol.for("yaml.alias"),Gf=Symbol.for("yaml.document"),er=Symbol.for("yaml.map"),Bf=Symbol.for("yaml.pair"),Ao=Symbol.for("yaml.scalar"),tr=Symbol.for("yaml.seq"),Ye=Symbol.for("yaml.node.type"),Rb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Eo,Lb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Gf,Pb=(e)=>!!e&&typeof e==="object"&&e[Ye]===er,Fb=(e)=>!!e&&typeof e==="object"&&e[Ye]===Bf,Vf=(e)=>!!e&&typeof e==="object"&&e[Ye]===Ao,qb=(e)=>!!e&&typeof e==="object"&&e[Ye]===tr;function Hf(e){if(e&&typeof e==="object")switch(e[Ye]){case er:case tr:return!0}return!1}function Db(e){if(e&&typeof e==="object")switch(e[Ye]){case Eo:case er:case Ao:case tr:return!0}return!1}var Ub=(e)=>(Vf(e)||Hf(e))&&!!e.anchor;jb.ALIAS=Eo;jb.DOC=Gf;jb.MAP=er;jb.NODE_TYPE=Ye;jb.PAIR=Bf;jb.SCALAR=Ao;jb.SEQ=tr;jb.hasAnchor=Ub;jb.isAlias=Rb;jb.isCollection=Hf;jb.isDocument=Lb;jb.isMap=Pb;jb.isNode=Db;jb.isPair=Fb;jb.isScalar=Vf;jb.isSeq=qb});var Nn=M(function(rw){var ae=V(),pe=Symbol("break visit"),Kf=Symbol("skip children"),Ge=Symbol("remove node");function nr(e,t){let n=Wf(t);if(ae.isDocument(e)){if(Ht(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else Ht(null,e,n,Object.freeze([]))}nr.BREAK=pe;nr.SKIP=Kf;nr.REMOVE=Ge;function Ht(e,t,n,i){let r=Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Ht(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=Ht(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=Ht("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=Ht("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}async function ir(e,t){let n=Wf(t);if(ae.isDocument(e)){if(await Kt(null,e.contents,n,Object.freeze([e]))===Ge)e.contents=null}else await Kt(null,e,n,Object.freeze([]))}ir.BREAK=pe;ir.SKIP=Kf;ir.REMOVE=Ge;async function Kt(e,t,n,i){let r=await Jf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return Yf(e,i,r),Kt(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=await Kt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===pe)return pe;else if(o===Ge)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=await Kt("key",t.key,n,i);if(s===pe)return pe;else if(s===Ge)t.key=null;let o=await Kt("value",t.value,n,i);if(o===pe)return pe;else if(o===Ge)t.value=null}}return r}function Wf(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 Jf(e,t,n,i){if(typeof n==="function")return n(e,t,i);if(ae.isMap(t))return n.Map?.(e,t,i);if(ae.isSeq(t))return n.Seq?.(e,t,i);if(ae.isPair(t))return n.Pair?.(e,t,i);if(ae.isScalar(t))return n.Scalar?.(e,t,i);if(ae.isAlias(t))return n.Alias?.(e,t,i);return}function Yf(e,t,n){let i=t[t.length-1];if(ae.isCollection(i))i.items[e]=n;else if(ae.isPair(i))if(e==="key")i.key=n;else i.value=n;else if(ae.isDocument(i))i.contents=n;else{let r=ae.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}rw.visit=nr;rw.visitAsync=ir});var ko=M(function(uw){var zf=V(),aw=Nn(),lw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},cw=(e)=>e.replace(/[!,[\]{}]/g,(t)=>lw[t]);class ve{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ve.defaultYaml,e),this.tags=Object.assign({},ve.defaultTags,t)}clone(){let e=new ve(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new ve(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ve.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ve.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:ve.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ve.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[r,s]=n;return this.tags[r]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let s=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,s),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")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 s}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+cw(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&zf.isNode(e.contents)){let r={};aw.visit(e.contents,(s,o)=>{if(zf.isNode(o)&&o.tag)r[o.tag]=!0}),i=Object.keys(r)}else i=[];for(let[r,s]of n){if(r==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||i.some((o)=>o.startsWith(s)))t.push(`%TAG ${r} ${s}`)}return t.join(`
|
|
514
|
-
`)}}
|
|
515
|
-
`)?
|
|
512
|
+
`}function Nn(e,t){return`\r
|
|
513
|
+
`.indexOf(e.charAt(t))!==-1}var _o=T(()=>{er();Pf()});function Ff(e,t=[],n=Cn.DEFAULT){let i=null,r=[],s=[];function o(l){if(Array.isArray(r))r.push(l);else if(i!==null)r[i]=l}return Ao(e,{onObjectBegin:()=>{let l={};o(l),s.push(r),r=l,i=null},onObjectProperty:(l)=>{i=l},onObjectEnd:()=>{r=s.pop()},onArrayBegin:()=>{let l=[];o(l),s.push(r),r=l,i=null},onArrayEnd:()=>{r=s.pop()},onLiteralValue:o,onError:(l,c,f)=>{t.push({error:l,offset:c,length:f})}},n),r[0]}function Eo(e,t=[],n=Cn.DEFAULT){let i={type:"array",offset:-1,length:-1,children:[],parent:void 0};function r(l){if(i.type==="property")i.length=l-i.offset,i=i.parent}function s(l){return i.children.push(l),l}Ao(e,{onObjectBegin:(l)=>{i=s({type:"object",offset:l,length:-1,parent:i,children:[]})},onObjectProperty:(l,c,f)=>{i=s({type:"property",offset:c,length:-1,parent:i,children:[]}),i.children.push({type:"string",value:l,offset:c,length:f,parent:i})},onObjectEnd:(l,c)=>{r(l+c),i.length=l+c-i.offset,i=i.parent,r(l+c)},onArrayBegin:(l,c)=>{i=s({type:"array",offset:l,length:-1,parent:i,children:[]})},onArrayEnd:(l,c)=>{i.length=l+c-i.offset,i=i.parent,r(l+c)},onLiteralValue:(l,c,f)=>{s({type:Ub(l),offset:c,length:f,parent:i,value:l}),r(c+f)},onSeparator:(l,c,f)=>{if(i.type==="property"){if(l===":")i.colonOffset=c;else if(l===",")r(c)}},onError:(l,c,f)=>{t.push({error:l,offset:c,length:f})}},n);let a=i.children[0];if(a)delete a.parent;return a}function tr(e,t){if(!e)return;let n=e;for(let i of t)if(typeof i==="string"){if(n.type!=="object"||!Array.isArray(n.children))return;let r=!1;for(let s of n.children)if(Array.isArray(s.children)&&s.children[0].value===i&&s.children.length===2){n=s.children[1],r=!0;break}if(!r)return}else{let r=i;if(n.type!=="array"||r<0||!Array.isArray(n.children)||r>=n.children.length)return;n=n.children[r]}return n}function Ao(e,t,n=Cn.DEFAULT){let i=On(e,!1),r=[],s=0;function o(L){return L?()=>s===0&&L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function a(L){return L?(Y)=>s===0&&L(Y,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(L){return L?(Y)=>s===0&&L(Y,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function c(L){return L?()=>{if(s>0)s++;else if(L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1)s=1}:()=>!0}function f(L){return L?()=>{if(s>0)s--;if(s===0)L(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}let u=c(t.onObjectBegin),d=l(t.onObjectProperty),g=f(t.onObjectEnd),h=c(t.onArrayBegin),p=f(t.onArrayEnd),m=l(t.onLiteralValue),v=a(t.onSeparator),w=o(t.onComment),x=a(t.onError),E=n&&n.disallowComments,A=n&&n.allowTrailingComma;function _(){while(!0){let L=i.scan();switch(i.getTokenError()){case 4:S(14);break;case 5:S(15);break;case 3:S(13);break;case 1:if(!E)S(11);break;case 2:S(12);break;case 6:S(16);break}switch(L){case 12:case 13:if(E)S(10);else w();break;case 16:S(1);break;case 15:case 14:break;default:return L}}}function S(L,Y=[],we=[]){if(x(L),Y.length+we.length>0){let We=i.getToken();while(We!==17){if(Y.indexOf(We)!==-1){_();break}else if(we.indexOf(We)!==-1)break;We=_()}}}function k(L){let Y=i.getTokenValue();if(L)m(Y);else d(Y),r.push(Y);return _(),!0}function R(){switch(i.getToken()){case 11:let L=i.getTokenValue(),Y=Number(L);if(isNaN(Y))S(2),Y=0;m(Y);break;case 7:m(null);break;case 8:m(!0);break;case 9:m(!1);break;default:return!1}return _(),!0}function U(){if(i.getToken()!==10)return S(3,[],[2,5]),!1;if(k(!1),i.getToken()===6){if(v(":"),_(),!N())S(4,[],[2,5])}else S(5,[],[2,5]);return r.pop(),!0}function D(){u(),_();let L=!1;while(i.getToken()!==2&&i.getToken()!==17){if(i.getToken()===5){if(!L)S(4,[],[]);if(v(","),_(),i.getToken()===2&&A)break}else if(L)S(6,[],[]);if(!U())S(4,[],[2,5]);L=!0}if(g(),i.getToken()!==2)S(7,[2],[]);else _();return!0}function P(){h(),_();let L=!0,Y=!1;while(i.getToken()!==4&&i.getToken()!==17){if(i.getToken()===5){if(!Y)S(4,[],[]);if(v(","),_(),i.getToken()===4&&A)break}else if(Y)S(6,[],[]);if(L)r.push(0),L=!1;else r[r.length-1]++;if(!N())S(4,[],[4,5]);Y=!0}if(p(),!L)r.pop();if(i.getToken()!==4)S(8,[4],[]);else _();return!0}function N(){switch(i.getToken()){case 3:return P();case 1:return D();case 10:return k(!0);default:return R()}}if(_(),i.getToken()===17){if(n.allowEmptyContent)return!0;return S(4,[],[]),!1}if(!N())return S(4,[],[]),!1;if(i.getToken()!==17)S(9,[],[]);return!0}function Ub(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(!e)return"null";else if(Array.isArray(e))return"array";return"object"}default:return"null"}}var Cn;var ko=T(()=>{er();(function(e){e.DEFAULT={allowTrailingComma:!1}})(Cn||(Cn={}))});function Df(e,t,n,i){let r=t.slice(),o=Eo(e,[]),a=void 0,l=void 0;while(r.length>0)if(l=r.pop(),a=tr(o,r),a===void 0&&n!==void 0)if(typeof l==="string")n={[l]:n};else n=[n];else break;if(!a){if(n===void 0)throw Error("Can not delete in empty document");return It(e,{offset:o?o.offset:0,length:o?o.length:0,content:JSON.stringify(n)},i)}else if(a.type==="object"&&typeof l==="string"&&Array.isArray(a.children)){let c=tr(a,[l]);if(c!==void 0)if(n===void 0){if(!c.parent)throw Error("Malformed AST");let f=a.children.indexOf(c.parent),u,d=c.parent.offset+c.parent.length;if(f>0){let g=a.children[f-1];u=g.offset+g.length}else if(u=a.offset+1,a.children.length>1)d=a.children[1].offset;return It(e,{offset:u,length:d-u,content:""},i)}else return It(e,{offset:c.offset,length:c.length,content:JSON.stringify(n)},i);else{if(n===void 0)return[];let f=`${JSON.stringify(l)}: ${JSON.stringify(n)}`,u=i.getInsertionIndex?i.getInsertionIndex(a.children.map((g)=>g.children[0].value)):a.children.length,d;if(u>0){let g=a.children[u-1];d={offset:g.offset+g.length,length:0,content:","+f}}else if(a.children.length===0)d={offset:a.offset+1,length:0,content:f};else d={offset:a.offset+1,length:0,content:f+","};return It(e,d,i)}}else if(a.type==="array"&&typeof l==="number"&&Array.isArray(a.children)){let c=l;if(c===-1){let f=`${JSON.stringify(n)}`,u;if(a.children.length===0)u={offset:a.offset+1,length:0,content:f};else{let d=a.children[a.children.length-1];u={offset:d.offset+d.length,length:0,content:","+f}}return It(e,u,i)}else if(n===void 0&&a.children.length>=0){let f=l,u=a.children[f],d;if(a.children.length===1)d={offset:a.offset+1,length:a.length-2,content:""};else if(a.children.length-1===f){let g=a.children[f-1],h=g.offset+g.length,p=a.offset+a.length;d={offset:h,length:p-2-h,content:""}}else d={offset:u.offset,length:a.children[f+1].offset-u.offset,content:""};return It(e,d,i)}else if(n!==void 0){let f,u=`${JSON.stringify(n)}`;if(!i.isArrayInsertion&&a.children.length>l){let d=a.children[l];f={offset:d.offset,length:d.length,content:u}}else if(a.children.length===0||l===0)f={offset:a.offset+1,length:0,content:a.children.length===0?u:u+","};else{let d=l>a.children.length?a.children.length:l,g=a.children[d-1];f={offset:g.offset+g.length,length:0,content:","+u}}return It(e,f,i)}else throw Error(`Can not ${n===void 0?"remove":i.isArrayInsertion?"insert":"modify"} Array index ${c} as length is not sufficient`)}else throw Error(`Can not add ${typeof l!=="number"?"index":"property"} to parent of type ${a.type}`)}function It(e,t,n){if(!n.formattingOptions)return[t];let i=nr(e,t),r=t.offset,s=t.offset+t.content.length;if(t.length===0||t.content.length===0){while(r>0&&!Nn(i,r-1))r--;while(s<i.length&&!Nn(i,s))s++}let o=$o(i,{offset:r,length:s-r},{...n.formattingOptions,keepLines:!1});for(let l=o.length-1;l>=0;l--){let c=o[l];i=nr(i,c),r=Math.min(r,c.offset),s=Math.max(s,c.offset+c.length),s+=c.content.length-c.length}let a=e.length-(i.length-s)-r;return[{offset:r,length:a,content:i.substring(r,s)}]}function nr(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var qf=T(()=>{_o();ko()});function Vf(e,t,n,i){return Df(e,t,n,i)}function Hf(e,t){let n=t.slice(0).sort((r,s)=>{let o=r.offset-s.offset;if(o===0)return r.length-s.length;return o}),i=e.length;for(let r=n.length-1;r>=0;r--){let s=n[r];if(s.offset+s.length<=i)e=nr(e,s);else throw Error("Overlapping edit");i=s.offset}return e}var Uf,jf,Bf,Gf;var Kf=T(()=>{_o();qf();er();ko();(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Uf||(Uf={}));(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(jf||(jf={}));Bf=Ff;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Gf||(Gf={}))});var H=M(function(zb){var Io=Symbol.for("yaml.alias"),Wf=Symbol.for("yaml.document"),ir=Symbol.for("yaml.map"),Yf=Symbol.for("yaml.pair"),To=Symbol.for("yaml.scalar"),rr=Symbol.for("yaml.seq"),Je=Symbol.for("yaml.node.type"),Bb=(e)=>!!e&&typeof e==="object"&&e[Je]===Io,Vb=(e)=>!!e&&typeof e==="object"&&e[Je]===Wf,Hb=(e)=>!!e&&typeof e==="object"&&e[Je]===ir,Kb=(e)=>!!e&&typeof e==="object"&&e[Je]===Yf,Jf=(e)=>!!e&&typeof e==="object"&&e[Je]===To,Wb=(e)=>!!e&&typeof e==="object"&&e[Je]===rr;function zf(e){if(e&&typeof e==="object")switch(e[Je]){case ir:case rr:return!0}return!1}function Yb(e){if(e&&typeof e==="object")switch(e[Je]){case Io:case ir:case To:case rr:return!0}return!1}var Jb=(e)=>(Jf(e)||zf(e))&&!!e.anchor;zb.ALIAS=Io;zb.DOC=Wf;zb.MAP=ir;zb.NODE_TYPE=Je;zb.PAIR=Yf;zb.SCALAR=To;zb.SEQ=rr;zb.hasAnchor=Jb;zb.isAlias=Bb;zb.isCollection=zf;zb.isDocument=Vb;zb.isMap=Hb;zb.isNode=Yb;zb.isPair=Kb;zb.isScalar=Jf;zb.isSeq=Wb});var Rn=M(function(pw){var ae=H(),me=Symbol("break visit"),Xf=Symbol("skip children"),Ve=Symbol("remove node");function sr(e,t){let n=Qf(t);if(ae.isDocument(e)){if(Wt(null,e.contents,n,Object.freeze([e]))===Ve)e.contents=null}else Wt(null,e,n,Object.freeze([]))}sr.BREAK=me;sr.SKIP=Xf;sr.REMOVE=Ve;function Wt(e,t,n,i){let r=Zf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return ed(e,i,r),Wt(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=Wt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===me)return me;else if(o===Ve)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=Wt("key",t.key,n,i);if(s===me)return me;else if(s===Ve)t.key=null;let o=Wt("value",t.value,n,i);if(o===me)return me;else if(o===Ve)t.value=null}}return r}async function or(e,t){let n=Qf(t);if(ae.isDocument(e)){if(await Yt(null,e.contents,n,Object.freeze([e]))===Ve)e.contents=null}else await Yt(null,e,n,Object.freeze([]))}or.BREAK=me;or.SKIP=Xf;or.REMOVE=Ve;async function Yt(e,t,n,i){let r=await Zf(e,t,n,i);if(ae.isNode(r)||ae.isPair(r))return ed(e,i,r),Yt(e,r,n,i);if(typeof r!=="symbol"){if(ae.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=await Yt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===me)return me;else if(o===Ve)t.items.splice(s,1),s-=1}}else if(ae.isPair(t)){i=Object.freeze(i.concat(t));let s=await Yt("key",t.key,n,i);if(s===me)return me;else if(s===Ve)t.key=null;let o=await Yt("value",t.value,n,i);if(o===me)return me;else if(o===Ve)t.value=null}}return r}function Qf(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 Zf(e,t,n,i){if(typeof n==="function")return n(e,t,i);if(ae.isMap(t))return n.Map?.(e,t,i);if(ae.isSeq(t))return n.Seq?.(e,t,i);if(ae.isPair(t))return n.Pair?.(e,t,i);if(ae.isScalar(t))return n.Scalar?.(e,t,i);if(ae.isAlias(t))return n.Alias?.(e,t,i);return}function ed(e,t,n){let i=t[t.length-1];if(ae.isCollection(i))i.items[e]=n;else if(ae.isPair(i))if(e==="key")i.key=n;else i.value=n;else if(ae.isDocument(i))i.contents=n;else{let r=ae.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}pw.visit=sr;pw.visitAsync=or});var Mo=M(function(ww){var td=H(),gw=Rn(),yw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},bw=(e)=>e.replace(/[!,[\]{}]/g,(t)=>yw[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 n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[r,s]=n;return this.tags[r]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let s=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,s),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let s=e.slice(2,-1);if(s==="!"||s==="!!")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 s}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);if(!i)t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(s){return t(String(s)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+bw(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&td.isNode(e.contents)){let r={};gw.visit(e.contents,(s,o)=>{if(td.isNode(o)&&o.tag)r[o.tag]=!0}),i=Object.keys(r)}else i=[];for(let[r,s]of n){if(r==="!!"&&s==="tag:yaml.org,2002:")continue;if(!e||i.some((o)=>o.startsWith(s)))t.push(`%TAG ${r} ${s}`)}return t.join(`
|
|
514
|
+
`)}}$e.defaultYaml={explicit:!1,version:"1.2"};$e.defaultTags={"!!":"tag:yaml.org,2002:"};ww.Directives=$e});var ar=M(function(_w){var nd=H(),vw=Rn();function Sw(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function id(e){let t=new Set;return vw.visit(e,{Value(n,i){if(i.anchor)t.add(i.anchor)}}),t}function rd(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function $w(e,t){let n=[],i=new Map,r=null;return{onAnchor:(s)=>{n.push(s),r??(r=id(e));let o=rd(t,r);return r.add(o),o},setAnchors:()=>{for(let s of n){let o=i.get(s);if(typeof o==="object"&&o.anchor&&(nd.isScalar(o.node)||nd.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:i}}_w.anchorIsValid=Sw;_w.anchorNames=id;_w.createNodeAnchors=$w;_w.findNewAnchor=rd});var Oo=M(function(Tw){function Ln(e,t,n,i){if(i&&typeof i==="object")if(Array.isArray(i))for(let r=0,s=i.length;r<s;++r){let o=i[r],a=Ln(e,i,String(r),o);if(a===void 0)delete i[r];else if(a!==o)i[r]=a}else if(i instanceof Map)for(let r of Array.from(i.keys())){let s=i.get(r),o=Ln(e,i,r,s);if(o===void 0)i.delete(r);else if(o!==s)i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let s=Ln(e,i,r,r);if(s===void 0)i.delete(r);else if(s!==r)i.delete(r),i.add(s)}else for(let[r,s]of Object.entries(i)){let o=Ln(e,i,r,s);if(o===void 0)delete i[r];else if(o!==s)i[r]=o}return e.call(t,n,i)}Tw.applyReviver=Ln});var rt=M(function(Nw){var Ow=H();function sd(e,t,n){if(Array.isArray(e))return e.map((i,r)=>sd(i,String(r),n));if(e&&typeof e.toJSON==="function"){if(!n||!Ow.hasAnchor(e))return e.toJSON(t,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=(s)=>{i.res=s,delete n.onCreate};let r=e.toJSON(t,n);if(n.onCreate)n.onCreate(r);return r}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}Nw.toJS=sd});var lr=M(function(Pw){var Rw=Oo(),od=H(),Lw=rt();class ad{constructor(e){Object.defineProperty(this,od.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:n,onAnchor:i,reviver:r}={}){if(!od.isDocument(e))throw TypeError("A document argument is required");let s={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},o=Lw.toJS(this,"",s);if(typeof i==="function")for(let{count:a,res:l}of s.anchors.values())i(l,a);return typeof r==="function"?Rw.applyReviver(r,{"":o},"",o):o}}Pw.NodeBase=ad});var Pn=M(function(Gw){var Dw=ar(),qw=Rn(),Jt=H(),Uw=lr(),jw=rt();class ld extends Uw.NodeBase{constructor(e){super(Jt.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 n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],qw.visit(e,{Node:(r,s)=>{if(Jt.isAlias(s)||Jt.hasAnchor(s))n.push(s)}}),t)t.aliasResolveCache=n;let i=void 0;for(let r of n){if(r===this)break;if(r.anchor===this.source)i=r}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,s=this.resolve(i,t);if(!s){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=n.get(s);if(!o)jw.toJS(s,null,t),o=n.get(s);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=cr(i,s,n);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(Dw.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(r)}if(e.implicitKey)return`${i} `}return i}}function cr(e,t,n){if(Jt.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Jt.isCollection(t)){let i=0;for(let r of t.items){let s=cr(e,r,n);if(s>i)i=s}return i}else if(Jt.isPair(t)){let i=cr(e,t.key,n),r=cr(e,t.value,n);return Math.max(i,r)}return 1}Gw.Alias=ld});var re=M(function(Yw){var Vw=H(),Hw=lr(),Kw=rt(),Ww=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class Tt extends Hw.NodeBase{constructor(e){super(Vw.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Kw.toJS(this.value,e,t)}toString(){return String(this.value)}}Tt.BLOCK_FOLDED="BLOCK_FOLDED";Tt.BLOCK_LITERAL="BLOCK_LITERAL";Tt.PLAIN="PLAIN";Tt.QUOTE_DOUBLE="QUOTE_DOUBLE";Tt.QUOTE_SINGLE="QUOTE_SINGLE";Yw.Scalar=Tt;Yw.isScalarValue=Ww});var Fn=M(function(t0){var Xw=Pn(),Mt=H(),cd=re(),Qw="tag:yaml.org,2002:";function Zw(e,t,n){if(t){let i=n.filter((s)=>s.tag===t),r=i.find((s)=>!s.format)??i[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find((i)=>i.identify?.(e)&&!i.format)}function e0(e,t,n){if(Mt.isDocument(e))e=e.contents;if(Mt.isNode(e))return e;if(Mt.isPair(e)){let u=n.schema[Mt.MAP].createNode?.(n.schema,null,n);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:i,onAnchor:r,onTagObj:s,schema:o,sourceObjects:a}=n,l=void 0;if(i&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new Xw.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=Qw+t.slice(2);let c=Zw(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new cd.Scalar(e);if(l)l.node=u;return u}c=e instanceof Map?o[Mt.MAP]:(Symbol.iterator in Object(e))?o[Mt.SEQ]:o[Mt.MAP]}if(s)s(c),delete n.onTagObj;let f=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(n.schema,e,n):new cd.Scalar(e);if(t)f.tag=t;else if(!c.default)f.tag=c.tag;if(l)l.node=f;return f}t0.createNode=e0});var ur=M(function(s0){var i0=Fn(),He=H(),r0=lr();function No(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){let s=t[r];if(typeof s==="number"&&Number.isInteger(s)&&s>=0){let o=[];o[s]=i,i=o}else i=new Map([[s,i]])}return i0.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var ud=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class fd extends r0.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((n)=>He.isNode(n)||He.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(ud(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(He.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,No(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(He.isCollection(i))return i.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);if(i.length===0)return!t&&He.isScalar(r)?r.value:r;else return He.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!He.isPair(t))return!1;let n=t.value;return n==null||e&&He.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return He.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(He.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,No(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}s0.Collection=fd;s0.collectionFromPath=No;s0.isEmptyPath=ud});var Dn=M(function(f0){var c0=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Co(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var u0=(e,t,n)=>e.endsWith(`
|
|
515
|
+
`)?Co(n,t):n.includes(`
|
|
516
516
|
`)?`
|
|
517
|
-
`+
|
|
518
|
-
`){if(n==="block")
|
|
519
|
-
`&&g!=="\t"){let E=e[
|
|
520
|
-
`&&E!=="\t")
|
|
521
|
-
${t}${e.slice(0,A)}`;else{if(n==="quoted"&&
|
|
522
|
-
${t}${e.slice(E+1,A)}`}}return w}function
|
|
523
|
-
`);i=t,r=t+1,s=e[r]}return i}
|
|
524
|
-
`){if(s-o>i)return!0;if(o=s+1,r-o<=i)return!1}return!0}function qn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=t,r=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(
|
|
517
|
+
`+Co(n,t):(e.endsWith(" ")?"":" ")+n;f0.indentComment=Co;f0.lineComment=u0;f0.stringifyComment=c0});var pd=M(function(g0){function h0(e,t,n="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:s=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;if(r<s)s=0;let l=Math.max(1+s,1+r-t.length);if(e.length<=l)return e;let c=[],f={},u=r-t.length;if(typeof i==="number")if(i>r-Math.max(2,s))c.push(0);else u=r-i;let d=void 0,g=void 0,h=!1,p=-1,m=-1,v=-1;if(n==="block"){if(p=dd(e,p,t.length),p!==-1)u=p+l}for(let x;x=e[p+=1];){if(n==="quoted"&&x==="\\"){switch(m=p,e[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}v=p}if(x===`
|
|
518
|
+
`){if(n==="block")p=dd(e,p,t.length);u=p+t.length+l,d=void 0}else{if(x===" "&&g&&g!==" "&&g!==`
|
|
519
|
+
`&&g!=="\t"){let E=e[p+1];if(E&&E!==" "&&E!==`
|
|
520
|
+
`&&E!=="\t")d=p}if(p>=u)if(d)c.push(d),u=d+l,d=void 0;else if(n==="quoted"){while(g===" "||g==="\t")g=x,x=e[p+=1],h=!0;let E=p>v+1?p-2:m-1;if(f[E])return e;c.push(E),f[E]=!0,u=E+l,d=void 0}else h=!0}g=x}if(h&&a)a();if(c.length===0)return e;if(o)o();let w=e.slice(0,c[0]);for(let x=0;x<c.length;++x){let E=c[x],A=c[x+1]||e.length;if(E===0)w=`
|
|
521
|
+
${t}${e.slice(0,A)}`;else{if(n==="quoted"&&f[E])w+=`${e[E]}\\`;w+=`
|
|
522
|
+
${t}${e.slice(E+1,A)}`}}return w}function dd(e,t,n){let i=t,r=t+1,s=e[r];while(s===" "||s==="\t")if(t<r+n)s=e[++t];else{do s=e[++t];while(s&&s!==`
|
|
523
|
+
`);i=t,r=t+1,s=e[r]}return i}g0.FOLD_BLOCK="block";g0.FOLD_FLOW="flow";g0.FOLD_QUOTED="quoted";g0.foldFlowLines=h0});var Un=M(function(_0){var Oe=re(),st=pd(),dr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),pr=(e)=>/^(%|---|\.\.\.)/m.test(e);function v0(e,t,n){if(!t||t<0)return!1;let i=t-n,r=e.length;if(r<=i)return!1;for(let s=0,o=0;s<r;++s)if(e[s]===`
|
|
524
|
+
`){if(s-o>i)return!0;if(o=s+1,r-o<=i)return!1}return!0}function qn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:i}=t,r=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(pr(e)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l]){if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n")o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\";if(c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:if(f.substr(0,2)==="00")o+="\\x"+f.substr(2);else o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||n[l+2]==='"'||n.length<r)l+=1;else{o+=n.slice(a,l)+`
|
|
525
525
|
|
|
526
526
|
`;while(n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"')o+=`
|
|
527
|
-
`,l+=2;if(o+=s,n[l+2]===" ")o+="\\";l+=1,a=l+1}break;default:l+=1}}return o=a?o+n.slice(a):n,i?o:st.foldFlowLines(o,s,st.FOLD_QUOTED,
|
|
528
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return qn(e,t);let n=t.indent||(
|
|
529
|
-
${n}`)+"'";return t.implicitKey?i:st.foldFlowLines(i,n,st.FOLD_FLOW,
|
|
527
|
+
`,l+=2;if(o+=s,n[l+2]===" ")o+="\\";l+=1,a=l+1}break;default:l+=1}}return o=a?o+n.slice(a):n,i?o:st.foldFlowLines(o,s,st.FOLD_QUOTED,dr(t,!1))}function Ro(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
528
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return qn(e,t);let n=t.indent||(pr(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
529
|
+
${n}`)+"'";return t.implicitKey?i:st.foldFlowLines(i,n,st.FOLD_FLOW,dr(t,!1))}function zt(e,t){let{singleQuote:n}=t.options,i;if(n===!1)i=qn;else{let r=e.includes('"'),s=e.includes("'");if(r&&!s)i=Ro;else if(s&&!r)i=qn;else i=n?Ro:qn}return i(e,t)}var Lo;try{Lo=new RegExp(`(^|(?<!
|
|
530
530
|
))
|
|
531
531
|
+(?!
|
|
532
|
-
|$)`,"g")}catch{
|
|
532
|
+
|$)`,"g")}catch{Lo=/\n+(?!\n|$)/g}function fr({comment:e,type:t,value:n},i,r,s){let{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(n))return zt(n,i);let c=i.indent||(i.forceBlockIndent||pr(n)?" ":""),f=o==="literal"?!0:o==="folded"||t===Oe.Scalar.BLOCK_FOLDED?!1:t===Oe.Scalar.BLOCK_LITERAL?!0:!v0(n,l,c.length);if(!n)return f?`|
|
|
533
533
|
`:`>
|
|
534
|
-
`;let u,
|
|
535
|
-
`&&A!=="\t"&&A!==" ")break}let g=n.substring(
|
|
534
|
+
`;let u,d;for(d=n.length;d>0;--d){let A=n[d-1];if(A!==`
|
|
535
|
+
`&&A!=="\t"&&A!==" ")break}let g=n.substring(d),h=g.indexOf(`
|
|
536
536
|
`);if(h===-1)u="-";else if(n===g||h!==g.length-1){if(u="+",s)s()}else u="";if(g){if(n=n.slice(0,-g.length),g[g.length-1]===`
|
|
537
|
-
`)g=g.slice(0,-1);g=g.replace(
|
|
538
|
-
`)v=m;else break}let w=n.substring(0,v<m?v+1:m);if(w)n=n.substring(w.length),w=w.replace(/\n+/g,`$&${c}`);let E=(
|
|
539
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),_=!1,S=
|
|
537
|
+
`)g=g.slice(0,-1);g=g.replace(Lo,`$&${c}`)}let p=!1,m,v=-1;for(m=0;m<n.length;++m){let A=n[m];if(A===" ")p=!0;else if(A===`
|
|
538
|
+
`)v=m;else break}let w=n.substring(0,v<m?v+1:m);if(w)n=n.substring(w.length),w=w.replace(/\n+/g,`$&${c}`);let E=(p?c?"2":"1":"")+u;if(e){if(E+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r)r()}if(!f){let A=n.replace(/\n+/g,`
|
|
539
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),_=!1,S=dr(i,!0);if(o!=="folded"&&t!==Oe.Scalar.BLOCK_FOLDED)S.onOverflow=()=>{_=!0};let k=st.foldFlowLines(`${w}${A}${g}`,c,st.FOLD_BLOCK,S);if(!_)return`>${E}
|
|
540
540
|
${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
|
|
541
|
-
${c}${w}${n}${g}`}function
|
|
542
|
-
`)||
|
|
543
|
-
`)?
|
|
544
|
-
`))return
|
|
545
|
-
${l}`);if(o){let
|
|
546
|
-
${t.indent}${a}`}
|
|
547
|
-
${a}:`}else if(m=`${m}:`,
|
|
541
|
+
${c}${w}${n}${g}`}function S0(e,t,n,i){let{type:r,value:s}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=t;if(a&&s.includes(`
|
|
542
|
+
`)||f&&/[[\]{},]/.test(s))return zt(s,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||f||!s.includes(`
|
|
543
|
+
`)?zt(s,t):fr(e,t,n,i);if(!a&&!f&&r!==Oe.Scalar.PLAIN&&s.includes(`
|
|
544
|
+
`))return fr(e,t,n,i);if(pr(s)){if(l==="")return t.forceBlockIndent=!0,fr(e,t,n,i);else if(a&&l===c)return zt(s,t)}let u=s.replace(/\n+/g,`$&
|
|
545
|
+
${l}`);if(o){let d=(p)=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(u),{compat:g,tags:h}=t.doc.schema;if(h.some(d)||g?.some(d))return zt(s,t)}return a?u:st.foldFlowLines(u,l,st.FOLD_FLOW,dr(t,!1))}function $0(e,t,n,i){let{implicitKey:r,inFlow:s}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Oe.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=Oe.Scalar.QUOTE_DOUBLE}let l=(f)=>{switch(f){case Oe.Scalar.BLOCK_FOLDED:case Oe.Scalar.BLOCK_LITERAL:return r||s?zt(o.value,t):fr(o,t,n,i);case Oe.Scalar.QUOTE_DOUBLE:return qn(o.value,t);case Oe.Scalar.QUOTE_SINGLE:return Ro(o.value,t);case Oe.Scalar.PLAIN:return S0(o,t,n,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=t.options,d=r&&f||u;if(c=l(d),c===null)throw Error(`Unsupported default string type ${d}`)}return c}_0.stringifyString=$0});var jn=M(function(C0){var A0=ar(),ot=H(),k0=Dn(),I0=Un();function T0(e,t){let n=Object.assign({blockQuote:!0,commentString:k0.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),i;switch(n.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent==="number"?" ".repeat(n.indent):" ",inFlow:i,options:n}}function M0(e,t){if(t.tag){let r=e.filter((s)=>s.tag===t.tag);if(r.length>0)return r.find((s)=>s.format===t.format)??r[0]}let n=void 0,i;if(ot.isScalar(t)){i=t.value;let r=e.filter((s)=>s.identify?.(i));if(r.length>1){let s=r.filter((o)=>o.test);if(s.length>0)r=s}n=r.find((s)=>s.format===t.format)??r.find((s)=>!s.format)}else i=t,n=e.find((r)=>r.nodeClass&&i instanceof r.nodeClass);if(!n){let r=i?.constructor?.name??(i===null?"null":typeof i);throw Error(`Tag not resolved for ${r} value`)}return n}function O0(e,t,{anchors:n,doc:i}){if(!i.directives)return"";let r=[],s=(ot.isScalar(e)||ot.isCollection(e))&&e.anchor;if(s&&A0.anchorIsValid(s))n.add(s),r.push(`&${s}`);let o=e.tag??(t.default?null:t.tag);if(o)r.push(i.directives.tagString(o));return r.join(" ")}function N0(e,t,n,i){if(ot.isPair(e))return e.toString(t,n,i);if(ot.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 r=void 0,s=ot.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>r=l});r??(r=M0(t.doc.schema.tags,s));let o=O0(s,r,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof r.stringify==="function"?r.stringify(s,t,n,i):ot.isScalar(s)?I0.stringifyString(s,t,n,i):s.toString(t,n,i);if(!o)return a;return ot.isScalar(s)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
546
|
+
${t.indent}${a}`}C0.createStringifyContext=T0;C0.stringify=N0});var gd=M(function(F0){var ze=H(),md=re(),hd=jn(),Gn=Dn();function P0({key:e,value:t},n,i,r){let{allNullValues:s,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=n,d=ze.isNode(e)&&e.comment||null;if(u){if(d)throw Error("With simple keys, key nodes cannot have comments");if(ze.isCollection(e)||!ze.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let g=!u&&(!e||d&&t==null&&!n.inFlow||ze.isCollection(e)||(ze.isScalar(e)?e.type===md.Scalar.BLOCK_FOLDED||e.type===md.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!g&&(u||!s),indent:a+l});let h=!1,p=!1,m=hd.stringify(e,n,()=>h=!0,()=>p=!0);if(!g&&!n.inFlow&&m.length>1024){if(u)throw Error("With simple keys, single line scalar must not span more than 1024 characters");g=!0}if(n.inFlow){if(s||t==null){if(h&&i)i();return m===""?"?":g?`? ${m}`:m}}else if(s&&!u||t==null&&g){if(m=`? ${m}`,d&&!h)m+=Gn.lineComment(m,n.indent,c(d));else if(p&&r)r();return m}if(h)d=null;if(g){if(d)m+=Gn.lineComment(m,n.indent,c(d));m=`? ${m}
|
|
547
|
+
${a}:`}else if(m=`${m}:`,d)m+=Gn.lineComment(m,n.indent,c(d));let v,w,x;if(ze.isNode(t))v=!!t.spaceBefore,w=t.commentBefore,x=t.comment;else if(v=!1,w=null,x=null,t&&typeof t==="object")t=o.createNode(t);if(n.implicitKey=!1,!g&&!d&&ze.isScalar(t))n.indentAtStart=m.length+1;if(p=!1,!f&&l.length>=2&&!n.inFlow&&!g&&ze.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)n.indent=n.indent.substring(2);let E=!1,A=hd.stringify(t,n,()=>E=!0,()=>p=!0),_=" ";if(d||v||w){if(_=v?`
|
|
548
548
|
`:"",w){let S=c(w);_+=`
|
|
549
|
-
${
|
|
549
|
+
${Gn.indentComment(S,n.indent)}`}if(A===""&&!n.inFlow){if(_===`
|
|
550
550
|
`&&x)_=`
|
|
551
551
|
|
|
552
552
|
`}else _+=`
|
|
553
553
|
${n.indent}`}else if(!g&&ze.isCollection(t)){let S=A[0],k=A.indexOf(`
|
|
554
|
-
`),R=k!==-1,U=n.inFlow??t.flow??t.items.length===0;if(R||!U){let
|
|
554
|
+
`),R=k!==-1,U=n.inFlow??t.flow??t.items.length===0;if(R||!U){let D=!1;if(R&&(S==="&"||S==="!")){let P=A.indexOf(" ");if(S==="&"&&P!==-1&&P<k&&A[P+1]==="!")P=A.indexOf(" ",P+1);if(P===-1||k<P)D=!0}if(!D)_=`
|
|
555
555
|
${n.indent}`}}else if(A===""||A[0]===`
|
|
556
|
-
`)_="";if(m+=_+A,n.inFlow){if(E&&i)i()}else if(x&&!E)m+=
|
|
557
|
-
${l}${
|
|
556
|
+
`)_="";if(m+=_+A,n.inFlow){if(E&&i)i()}else if(x&&!E)m+=Gn.lineComment(m,n.indent,c(x));else if(p&&r)r();return m}F0.stringifyPair=P0});var Po=M(function(j0){var yd=ln("process");function q0(e,...t){if(e==="debug")console.log(...t)}function U0(e,t){if(e==="debug"||e==="warn")if(typeof yd.emitWarning==="function")yd.emitWarning(t);else console.warn(t)}j0.debug=q0;j0.warn=U0});var yr=M(function(H0){var gr=H(),bd=re(),mr="<<",hr={identify:(e)=>e===mr||typeof e==="symbol"&&e.description===mr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new bd.Scalar(Symbol(mr)),{addToJSMap:wd}),stringify:()=>mr},V0=(e,t)=>(hr.identify(t)||gr.isScalar(t)&&(!t.type||t.type===bd.Scalar.PLAIN)&&hr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===hr.tag&&n.default);function wd(e,t,n){let i=xd(e,n);if(gr.isSeq(i))for(let r of i.items)Fo(e,t,r);else if(Array.isArray(i))for(let r of i)Fo(e,t,r);else Fo(e,t,i)}function Fo(e,t,n){let i=xd(e,n);if(!gr.isMap(i))throw Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,e,Map);for(let[s,o]of r)if(t instanceof Map){if(!t.has(s))t.set(s,o)}else if(t instanceof Set)t.add(s);else if(!Object.prototype.hasOwnProperty.call(t,s))Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function xd(e,t){return e&&gr.isAlias(t)?t.resolve(e.doc,e):t}H0.addMergeToJSMap=wd;H0.isMergeKey=V0;H0.merge=hr});var qo=M(function(Z0){var J0=Po(),vd=yr(),z0=jn(),Sd=H(),Do=rt();function X0(e,t,{key:n,value:i}){if(Sd.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(vd.isMergeKey(e,n))vd.addMergeToJSMap(e,t,i);else{let r=Do.toJS(n,"",e);if(t instanceof Map)t.set(r,Do.toJS(i,r,e));else if(t instanceof Set)t.add(r);else{let s=Q0(n,r,e),o=Do.toJS(i,s,e);if(s in t)Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[s]=o}}return t}function Q0(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(Sd.isNode(e)&&n?.doc){let i=z0.createStringifyContext(n.doc,{});i.anchors=new Set;for(let s of n.anchors.keys())i.anchors.add(s.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=e.toString(i);if(!n.mapKeyWarned){let s=JSON.stringify(r);if(s.length>40)s=s.substring(0,36)+'..."';J0.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}Z0.addPairToJSMap=X0});var at=M(function(r1){var $d=Fn(),t1=gd(),n1=qo(),br=H();function i1(e,t,n){let i=$d.createNode(e,void 0,n),r=$d.createNode(t,void 0,n);return new wr(i,r)}class wr{constructor(e,t=null){Object.defineProperty(this,br.NODE_TYPE,{value:br.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(br.isNode(t))t=t.clone(e);if(br.isNode(n))n=n.clone(e);return new wr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return n1.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?t1.stringifyPair(this,e,t,n):JSON.stringify(this)}}r1.Pair=wr;r1.createPair=i1});var Uo=M(function(u1){var Ot=H(),_d=jn(),xr=Dn();function a1(e,t,n){return(t.inFlow??e.flow?c1:l1)(e,t,n)}function l1({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:s,type:null}),u=!1,d=[];for(let h=0;h<t.length;++h){let p=t[h],m=null;if(Ot.isNode(p)){if(!u&&p.spaceBefore)d.push("");if(vr(n,d,p.commentBefore,u),p.comment)m=p.comment}else if(Ot.isPair(p)){let w=Ot.isNode(p.key)?p.key:null;if(w){if(!u&&w.spaceBefore)d.push("");vr(n,d,w.commentBefore,u)}}u=!1;let v=_d.stringify(p,f,()=>m=null,()=>u=!0);if(m)v+=xr.lineComment(v,s,c(m));if(u&&m)u=!1;d.push(i+v)}let g;if(d.length===0)g=r.start+r.end;else{g=d[0];for(let h=1;h<d.length;++h){let p=d[h];g+=p?`
|
|
557
|
+
${l}${p}`:`
|
|
558
558
|
`}}if(e){if(g+=`
|
|
559
|
-
`+
|
|
560
|
-
`)),h<e.length-1)v+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=u.reduce((w,x)=>w+x.length+2,2)+(v.length+2)>t.options.lineWidth);if(c)v+=","}if(m)v+=
|
|
561
|
-
${s}${r}${
|
|
559
|
+
`+xr.indentComment(c(e),l),a)a()}else if(u&&o)o();return g}function c1({items:e},t,{flowChars:n,itemIndent:i}){let{indent:r,indentStep:s,flowCollectionPadding:o,options:{commentString:a}}=t;i+=s;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let h=0;h<e.length;++h){let p=e[h],m=null;if(Ot.isNode(p)){if(p.spaceBefore)u.push("");if(vr(t,u,p.commentBefore,!1),p.comment)m=p.comment}else if(Ot.isPair(p)){let w=Ot.isNode(p.key)?p.key:null;if(w){if(w.spaceBefore)u.push("");if(vr(t,u,w.commentBefore,!1),w.comment)c=!0}let x=Ot.isNode(p.value)?p.value:null;if(x){if(x.comment)m=x.comment;if(x.commentBefore)c=!0}else if(p.value==null&&w?.comment)m=w.comment}if(m)c=!0;let v=_d.stringify(p,l,()=>m=null);if(c||(c=u.length>f||v.includes(`
|
|
560
|
+
`)),h<e.length-1)v+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=u.reduce((w,x)=>w+x.length+2,2)+(v.length+2)>t.options.lineWidth);if(c)v+=","}if(m)v+=xr.lineComment(v,i,a(m));u.push(v),f=u.length}let{start:d,end:g}=n;if(u.length===0)return d+g;else{if(!c){let h=u.reduce((p,m)=>p+m.length+2,2);c=t.options.lineWidth>0&&h>t.options.lineWidth}if(c){let h=d;for(let p of u)h+=p?`
|
|
561
|
+
${s}${r}${p}`:`
|
|
562
562
|
`;return`${h}
|
|
563
|
-
${r}${g}`}else return`${
|
|
564
|
-
`:" ")}return
|
|
563
|
+
${r}${g}`}else return`${d}${o}${u.join(" ")}${o}${g}`}}function vr({indent:e,options:{commentString:t}},n,i,r){if(i&&r)i=i.replace(/^\n+/,"");if(i){let s=xr.indentComment(t(i),e);n.push(s.trimStart())}}u1.stringifyCollection=a1});var ct=M(function(g1){var d1=Uo(),p1=qo(),m1=ur(),lt=H(),Sr=at(),h1=re();function Bn(e,t){let n=lt.isScalar(t)?t.value:t;for(let i of e)if(lt.isPair(i)){if(i.key===t||i.key===n)return i;if(lt.isScalar(i.key)&&i.key.value===n)return i}return}class Ed extends m1.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(lt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:i,replacer:r}=n,s=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||i)s.items.push(Sr.createPair(a,l,n))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")s.items.sort(e.sortMapEntries);return s}add(e,t){let n;if(lt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new Sr.Pair(e,e?.value);else n=new Sr.Pair(e.key,e.value);let i=Bn(this.items,n.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${n.key} already set`);if(lt.isScalar(i.value)&&h1.isScalarValue(n.value))i.value.value=n.value;else i.value=n.value}else if(r){let s=this.items.findIndex((o)=>r(n,o)<0);if(s===-1)this.items.push(n);else this.items.splice(s,0,n)}else this.items.push(n)}delete(e){let t=Bn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Bn(this.items,e)?.value;return(!t&<.isScalar(i)?i.value:i)??void 0}has(e){return!!Bn(this.items,e)}set(e,t){this.add(new Sr.Pair(e,t),!0)}toJSON(e,t,n){let i=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(i);for(let r of this.items)p1.addPairToJSMap(t,i,r);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(let i of this.items)if(!lt.isPair(i))throw Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return d1.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}g1.YAMLMap=Ed;g1.findPair=Bn});var Xt=M(function(v1){var w1=H(),Ad=ct(),x1={collection:"map",default:!0,nodeClass:Ad.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!w1.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>Ad.YAMLMap.from(e,t,n)};v1.map=x1});var ut=M(function(I1){var $1=Fn(),_1=Uo(),E1=ur(),_r=H(),A1=re(),k1=rt();class kd extends E1.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(_r.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=$r(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=$r(e);if(typeof n!=="number")return;let i=this.items[n];return!t&&_r.isScalar(i)?i.value:i}has(e){let t=$r(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=$r(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[n];if(_r.isScalar(i)&&A1.isScalarValue(t))i.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let i=0;for(let r of this.items)n.push(k1.toJS(r,String(i++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return _1.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t)){let s=0;for(let o of t){if(typeof i==="function"){let a=t instanceof Set?o:String(s++);o=i.call(t,a,o)}r.items.push($1.createNode(o,void 0,n))}}return r}}function $r(e){let t=_r.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}I1.YAMLSeq=kd});var Qt=M(function(N1){var M1=H(),Id=ut(),O1={collection:"seq",default:!0,nodeClass:Id.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!M1.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>Id.YAMLSeq.from(e,t,n)};N1.seq=O1});var Vn=M(function(P1){var R1=Un(),L1={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,i){return t=Object.assign({actualString:!0},t),R1.stringifyString(e,t,n,i)}};P1.string=L1});var Er=M(function(D1){var Td=re(),Md={identify:(e)=>e==null,createNode:()=>new Td.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Td.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&Md.test.test(e)?e:t.options.nullStr};D1.nullTag=Md});var jo=M(function(j1){var U1=re(),Od={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new U1.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Od.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};j1.boolTag=Od});var Zt=M(function(V1){function B1({format:e,minFractionDigits:t,tag:n,value:i}){if(typeof i==="bigint")return String(i);let r=typeof i==="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let s=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let o=s.indexOf(".");if(o<0)o=s.length,s+=".";let a=t-(s.length-o-1);while(a-- >0)s+="0"}return s}V1.stringifyNumber=B1});var Bo=M(function(z1){var K1=re(),Go=Zt(),W1={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:Go.stringifyNumber},Y1={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():Go.stringifyNumber(e)}},J1={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 K1.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:Go.stringifyNumber};z1.float=J1;z1.floatExp=Y1;z1.floatNaN=W1});var Ho=M(function(ix){var Nd=Zt(),Ar=(e)=>typeof e==="bigint"||Number.isInteger(e),Vo=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Cd(e,t,n){let{value:i}=e;if(Ar(i)&&i>=0)return n+i.toString(t);return Nd.stringifyNumber(e)}var ex={identify:(e)=>Ar(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>Vo(e,2,8,n),stringify:(e)=>Cd(e,8,"0o")},tx={identify:Ar,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Vo(e,0,10,n),stringify:Nd.stringifyNumber},nx={identify:(e)=>Ar(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Vo(e,2,16,n),stringify:(e)=>Cd(e,16,"0x")};ix.int=tx;ix.intHex=nx;ix.intOct=ex});var Rd=M(function(px){var ax=Xt(),lx=Er(),cx=Qt(),ux=Vn(),fx=jo(),Ko=Bo(),Wo=Ho(),dx=[ax.map,cx.seq,ux.string,lx.nullTag,fx.boolTag,Wo.intOct,Wo.int,Wo.intHex,Ko.floatNaN,Ko.floatExp,Ko.float];px.schema=dx});var Pd=M(function(vx){var hx=re(),gx=Xt(),yx=Qt();function Ld(e){return typeof e==="bigint"||Number.isInteger(e)}var kr=({value:e})=>JSON.stringify(e),bx=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:kr},{identify:(e)=>e==null,createNode:()=>new hx.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:kr},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:kr},{identify:Ld,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ld(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:kr}],wx={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},xx=[gx.map,yx.seq].concat(bx,wx);vx.schema=xx});var Jo=M(function(Ex){var Hn=ln("buffer"),Yo=re(),$x=Un(),_x={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Hn.Buffer==="function")return Hn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(n.length);for(let r=0;r<n.length;++r)i[r]=n.charCodeAt(r);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},i,r,s){if(!n)return"";let o=n,a;if(typeof Hn.Buffer==="function")a=o instanceof Hn.Buffer?o.toString("base64"):Hn.Buffer.from(o.buffer).toString("base64");else if(typeof btoa==="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Yo.Scalar.BLOCK_LITERAL),t!==Yo.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),f=Array(c);for(let u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(t===Yo.Scalar.BLOCK_LITERAL?`
|
|
564
|
+
`:" ")}return $x.stringifyString({comment:e,type:t,value:a},i,r,s)}};Ex.binary=_x});var Tr=M(function(Mx){var Ir=H(),zo=at(),kx=re(),Ix=ut();function Fd(e,t){if(Ir.isSeq(e))for(let n=0;n<e.items.length;++n){let i=e.items[n];if(Ir.isPair(i))continue;else if(Ir.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let r=i.items[0]||new zo.Pair(new kx.Scalar(null));if(i.commentBefore)r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
|
|
565
565
|
${r.key.commentBefore}`:i.commentBefore;if(i.comment){let s=r.value??r.key;s.comment=s.comment?`${i.comment}
|
|
566
|
-
${s.comment}`:i.comment}i=r}e.items[n]=Er.isPair(i)?i:new Wo.Pair(i)}else t("Expected a sequence for this tag");return e}function Nd(e,t,n){let{replacer:i}=n,r=new wx.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,String(s++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Wo.createPair(a,l,n))}return r}var xx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Cd,createNode:Nd};vx.createPairs=Nd;vx.pairs=xx;vx.resolvePairs=Cd});var Yo=M(function(kx){var Rd=V(),Jo=rt(),Hn=ct(),Ex=ut(),Ld=Ar();class Mt extends Ex.YAMLSeq{constructor(){super();this.add=Hn.YAMLMap.prototype.add.bind(this),this.delete=Hn.YAMLMap.prototype.delete.bind(this),this.get=Hn.YAMLMap.prototype.get.bind(this),this.has=Hn.YAMLMap.prototype.has.bind(this),this.set=Hn.YAMLMap.prototype.set.bind(this),this.tag=Mt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let i of this.items){let r,s;if(Rd.isPair(i))r=Jo.toJS(i.key,"",t),s=Jo.toJS(i.value,r,t);else r=Jo.toJS(i,"",t);if(n.has(r))throw Error("Ordered maps must not include duplicate keys");n.set(r,s)}return n}static from(e,t,n){let i=Ld.createPairs(e,t,n),r=new this;return r.items=i.items,r}}Mt.tag="tag:yaml.org,2002:omap";var Ax={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Mt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Ld.resolvePairs(e,t),i=[];for(let{key:r}of n.items)if(Rd.isScalar(r))if(i.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else i.push(r.value);return Object.assign(new Mt,n)},createNode:(e,t,n)=>Mt.from(e,t,n)};kx.YAMLOMap=Mt;kx.omap=Ax});var Ud=M(function(Mx){var Pd=re();function Fd({value:e,source:t},n){if(t&&(e?qd:Dd).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var qd={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 Pd.Scalar(!0),stringify:Fd},Dd={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 Pd.Scalar(!1),stringify:Fd};Mx.falseTag=Dd;Mx.trueTag=qd});var jd=M(function(Fx){var Nx=re(),zo=Xt(),Rx={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:zo.stringifyNumber},Lx={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():zo.stringifyNumber(e)}},Px={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 Nx.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let i=e.substring(n+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:zo.stringifyNumber};Fx.float=Px;Fx.floatExp=Lx;Fx.floatNaN=Rx});var Bd=M(function(Hx){var Gd=Xt(),Kn=(e)=>typeof e==="bigint"||Number.isInteger(e);function kr(e,t,n,{intAsBigInt:i}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return r==="-"?-1*s:s}function Xo(e,t,n){let{value:i}=e;if(Kn(i)){let r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Gd.stringifyNumber(e)}var jx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>kr(e,2,2,n),stringify:(e)=>Xo(e,2,"0b")},Gx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>kr(e,1,8,n),stringify:(e)=>Xo(e,8,"0")},Bx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>kr(e,0,10,n),stringify:Gd.stringifyNumber},Vx={identify:Kn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>kr(e,2,16,n),stringify:(e)=>Xo(e,16,"0x")};Hx.int=Bx;Hx.intBin=jx;Hx.intHex=Vx;Hx.intOct=Gx});var Qo=M(function(Xx){var Mr=V(),Tr=at(),Ir=ct();class Ot extends Ir.YAMLMap{constructor(e){super(e);this.tag=Ot.tag}add(e){let t;if(Mr.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Tr.Pair(e.key,null);else t=new Tr.Pair(e,null);if(!Ir.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Ir.findPair(this.items,e);return!t&&Mr.isPair(n)?Mr.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Ir.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new Tr.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,s,s);r.items.push(Tr.createPair(s,null,n))}return r}}Ot.tag="tag:yaml.org,2002:set";var zx={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ot,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ot.from(e,t,n),resolve(e,t){if(Mr.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ot,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Xx.YAMLSet=Ot;Xx.set=zx});var ea=M(function(iv){var ev=Xt();function Zo(e,t){let n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function Vd(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return ev.stringifyNumber(e);let i="";if(t<0)i="-",t*=n(-1);let r=n(60),s=[t%r];if(t<60)s.unshift(0);else if(t=(t-s[0])/r,s.unshift(t%r),t>=60)t=(t-s[0])/r,s.unshift(t);return i+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var tv={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:n})=>Zo(e,n),stringify:Vd},nv={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)=>Zo(e,!1),stringify:Vd},Hd={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(Hd.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(n,i-1,r,s||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let u=Zo(p,!1);if(Math.abs(u)<30)u*=60;c-=60000*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};iv.floatTime=nv;iv.intTime=tv;iv.timestamp=Hd});var Wd=M(function(yv){var av=Yt(),lv=Sr(),cv=zt(),uv=Bn(),fv=Ko(),Kd=Ud(),ta=jd(),Or=Bd(),dv=mr(),pv=Yo(),mv=Ar(),hv=Qo(),na=ea(),gv=[av.map,cv.seq,uv.string,lv.nullTag,Kd.trueTag,Kd.falseTag,Or.intBin,Or.intOct,Or.int,Or.intHex,ta.floatNaN,ta.floatExp,ta.float,fv.binary,dv.merge,pv.omap,mv.pairs,hv.set,na.intTime,na.floatTime,na.timestamp];yv.schema=gv});var ip=M(function(Av){var Xd=Yt(),wv=Sr(),Qd=zt(),xv=Bn(),vv=qo(),ia=Uo(),ra=Go(),Sv=Id(),$v=Od(),Zd=Ko(),Wn=mr(),ep=Yo(),tp=Ar(),Jd=Wd(),np=Qo(),Cr=ea(),Yd=new Map([["core",Sv.schema],["failsafe",[Xd.map,Qd.seq,xv.string]],["json",$v.schema],["yaml11",Jd.schema],["yaml-1.1",Jd.schema]]),zd={binary:Zd.binary,bool:vv.boolTag,float:ia.float,floatExp:ia.floatExp,floatNaN:ia.floatNaN,floatTime:Cr.floatTime,int:ra.int,intHex:ra.intHex,intOct:ra.intOct,intTime:Cr.intTime,map:Xd.map,merge:Wn.merge,null:wv.nullTag,omap:ep.omap,pairs:tp.pairs,seq:Qd.seq,set:np.set,timestamp:Cr.timestamp},_v={"tag:yaml.org,2002:binary":Zd.binary,"tag:yaml.org,2002:merge":Wn.merge,"tag:yaml.org,2002:omap":ep.omap,"tag:yaml.org,2002:pairs":tp.pairs,"tag:yaml.org,2002:set":np.set,"tag:yaml.org,2002:timestamp":Cr.timestamp};function Ev(e,t,n){let i=Yd.get(t);if(i&&!e)return n&&!i.includes(Wn.merge)?i.concat(Wn.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let s=Array.from(Yd.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)r=r.concat(s);else if(typeof e==="function")r=e(r.slice());if(n)r=r.concat(Wn.merge);return r.reduce((s,o)=>{let a=typeof o==="string"?zd[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(zd).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!s.includes(a))s.push(a);return s},[])}Av.coreKnownTags=_v;Av.getTags=Ev});var aa=M(function(Nv){var sa=V(),Iv=Yt(),Mv=zt(),Ov=Bn(),Nr=ip(),Cv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class oa{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?Nr.getTags(e,"compat"):e?Nr.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=i?Nr.coreKnownTags:{},this.tags=Nr.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,sa.MAP,{value:Iv.map}),Object.defineProperty(this,sa.SCALAR,{value:Ov.string}),Object.defineProperty(this,sa.SEQ,{value:Mv.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Cv:null}clone(){let e=Object.create(oa.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Nv.Schema=oa});var rp=M(function(Fv){var Lv=V(),la=Un(),Jn=Fn();function Pv(e,t){let n=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)n.push(l),i=!0;else if(e.directives.docStart)i=!0}if(i)n.push("---");let r=la.createStringifyContext(e,t),{commentString:s}=r.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=s(e.commentBefore);n.unshift(Jn.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Lv.isNode(e.contents)){if(e.contents.spaceBefore&&i)n.push("");if(e.contents.commentBefore){let p=s(e.contents.commentBefore);n.push(Jn.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=la.stringify(e.contents,r,()=>a=null,l);if(a)c+=Jn.lineComment(c,"",s(a));if((c[0]==="|"||c[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${c}`;else n.push(c)}else n.push(la.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=s(e.comment);if(l.includes(`
|
|
566
|
+
${s.comment}`:i.comment}i=r}e.items[n]=Ir.isPair(i)?i:new zo.Pair(i)}else t("Expected a sequence for this tag");return e}function Dd(e,t,n){let{replacer:i}=n,r=new Ix.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof i==="function")o=i.call(t,String(s++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(zo.createPair(a,l,n))}return r}var Tx={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Fd,createNode:Dd};Mx.createPairs=Dd;Mx.pairs=Tx;Mx.resolvePairs=Fd});var Qo=M(function(Px){var qd=H(),Xo=rt(),Kn=ct(),Rx=ut(),Ud=Tr();class Nt extends Rx.YAMLSeq{constructor(){super();this.add=Kn.YAMLMap.prototype.add.bind(this),this.delete=Kn.YAMLMap.prototype.delete.bind(this),this.get=Kn.YAMLMap.prototype.get.bind(this),this.has=Kn.YAMLMap.prototype.has.bind(this),this.set=Kn.YAMLMap.prototype.set.bind(this),this.tag=Nt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let i of this.items){let r,s;if(qd.isPair(i))r=Xo.toJS(i.key,"",t),s=Xo.toJS(i.value,r,t);else r=Xo.toJS(i,"",t);if(n.has(r))throw Error("Ordered maps must not include duplicate keys");n.set(r,s)}return n}static from(e,t,n){let i=Ud.createPairs(e,t,n),r=new this;return r.items=i.items,r}}Nt.tag="tag:yaml.org,2002:omap";var Lx={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Nt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Ud.resolvePairs(e,t),i=[];for(let{key:r}of n.items)if(qd.isScalar(r))if(i.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else i.push(r.value);return Object.assign(new Nt,n)},createNode:(e,t,n)=>Nt.from(e,t,n)};Px.YAMLOMap=Nt;Px.omap=Lx});var Hd=M(function(qx){var jd=re();function Gd({value:e,source:t},n){if(t&&(e?Bd:Vd).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var Bd={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 jd.Scalar(!0),stringify:Gd},Vd={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 jd.Scalar(!1),stringify:Gd};qx.falseTag=Vd;qx.trueTag=Bd});var Kd=M(function(Kx){var Gx=re(),Zo=Zt(),Bx={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:Zo.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():Zo.stringifyNumber(e)}},Hx={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 Gx.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let i=e.substring(n+1).replace(/_/g,"");if(i[i.length-1]==="0")t.minFractionDigits=i.length}return t},stringify:Zo.stringifyNumber};Kx.float=Hx;Kx.floatExp=Vx;Kx.floatNaN=Bx});var Yd=M(function(ev){var Wd=Zt(),Wn=(e)=>typeof e==="bigint"||Number.isInteger(e);function Mr(e,t,n,{intAsBigInt:i}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),i){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let s=parseInt(e,n);return r==="-"?-1*s:s}function ea(e,t,n){let{value:i}=e;if(Wn(i)){let r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return Wd.stringifyNumber(e)}var zx={identify:Wn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Mr(e,2,2,n),stringify:(e)=>ea(e,2,"0b")},Xx={identify:Wn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Mr(e,1,8,n),stringify:(e)=>ea(e,8,"0")},Qx={identify:Wn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Mr(e,0,10,n),stringify:Wd.stringifyNumber},Zx={identify:Wn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Mr(e,2,16,n),stringify:(e)=>ea(e,16,"0x")};ev.int=Qx;ev.intBin=zx;ev.intHex=Zx;ev.intOct=Xx});var ta=M(function(ov){var Cr=H(),Or=at(),Nr=ct();class Ct extends Nr.YAMLMap{constructor(e){super(e);this.tag=Ct.tag}add(e){let t;if(Cr.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Or.Pair(e.key,null);else t=new Or.Pair(e,null);if(!Nr.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Nr.findPair(this.items,e);return!t&&Cr.isPair(n)?Cr.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=Nr.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new Or.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:i}=n,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof i==="function")s=i.call(t,s,s);r.items.push(Or.createPair(s,null,n))}return r}}Ct.tag="tag:yaml.org,2002:set";var sv={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Ct,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ct.from(e,t,n),resolve(e,t){if(Cr.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Ct,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};ov.YAMLSet=Ct;ov.set=sv});var ia=M(function(dv){var cv=Zt();function na(e,t){let n=e[0],i=n==="-"||n==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),s=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return n==="-"?r(-1)*s:s}function Jd(e){let{value:t}=e,n=(o)=>o;if(typeof t==="bigint")n=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return cv.stringifyNumber(e);let i="";if(t<0)i="-",t*=n(-1);let r=n(60),s=[t%r];if(t<60)s.unshift(0);else if(t=(t-s[0])/r,s.unshift(t%r),t>=60)t=(t-s[0])/r,s.unshift(t);return i+s.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var uv={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:n})=>na(e,n),stringify:Jd},fv={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)=>na(e,!1),stringify:Jd},zd={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(zd.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,i,r,s,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(n,i-1,r,s||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let u=na(f,!1);if(Math.abs(u)<30)u*=60;c-=60000*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};dv.floatTime=fv;dv.intTime=uv;dv.timestamp=zd});var Qd=M(function(Av){var gv=Xt(),yv=Er(),bv=Qt(),wv=Vn(),xv=Jo(),Xd=Hd(),ra=Kd(),Rr=Yd(),vv=yr(),Sv=Qo(),$v=Tr(),_v=ta(),sa=ia(),Ev=[gv.map,bv.seq,wv.string,yv.nullTag,Xd.trueTag,Xd.falseTag,Rr.intBin,Rr.intOct,Rr.int,Rr.intHex,ra.floatNaN,ra.floatExp,ra.float,xv.binary,vv.merge,Sv.omap,$v.pairs,_v.set,sa.intTime,sa.floatTime,sa.timestamp];Av.schema=Ev});var lp=M(function(Lv){var np=Xt(),Iv=Er(),ip=Qt(),Tv=Vn(),Mv=jo(),oa=Bo(),aa=Ho(),Ov=Rd(),Nv=Pd(),rp=Jo(),Yn=yr(),sp=Qo(),op=Tr(),Zd=Qd(),ap=ta(),Lr=ia(),ep=new Map([["core",Ov.schema],["failsafe",[np.map,ip.seq,Tv.string]],["json",Nv.schema],["yaml11",Zd.schema],["yaml-1.1",Zd.schema]]),tp={binary:rp.binary,bool:Mv.boolTag,float:oa.float,floatExp:oa.floatExp,floatNaN:oa.floatNaN,floatTime:Lr.floatTime,int:aa.int,intHex:aa.intHex,intOct:aa.intOct,intTime:Lr.intTime,map:np.map,merge:Yn.merge,null:Iv.nullTag,omap:sp.omap,pairs:op.pairs,seq:ip.seq,set:ap.set,timestamp:Lr.timestamp},Cv={"tag:yaml.org,2002:binary":rp.binary,"tag:yaml.org,2002:merge":Yn.merge,"tag:yaml.org,2002:omap":sp.omap,"tag:yaml.org,2002:pairs":op.pairs,"tag:yaml.org,2002:set":ap.set,"tag:yaml.org,2002:timestamp":Lr.timestamp};function Rv(e,t,n){let i=ep.get(t);if(i&&!e)return n&&!i.includes(Yn.merge)?i.concat(Yn.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let s=Array.from(ep.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)r=r.concat(s);else if(typeof e==="function")r=e(r.slice());if(n)r=r.concat(Yn.merge);return r.reduce((s,o)=>{let a=typeof o==="string"?tp[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(tp).map((f)=>JSON.stringify(f)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!s.includes(a))s.push(a);return s},[])}Lv.coreKnownTags=Cv;Lv.getTags=Rv});var ua=M(function(Gv){var la=H(),Dv=Xt(),qv=Qt(),Uv=Vn(),Pr=lp(),jv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class ca{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?Pr.getTags(e,"compat"):e?Pr.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=i?Pr.coreKnownTags:{},this.tags=Pr.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,la.MAP,{value:Dv.map}),Object.defineProperty(this,la.SCALAR,{value:Uv.string}),Object.defineProperty(this,la.SEQ,{value:qv.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?jv:null}clone(){let e=Object.create(ca.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Gv.Schema=ca});var cp=M(function(Kv){var Vv=H(),fa=jn(),Jn=Dn();function Hv(e,t){let n=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)n.push(l),i=!0;else if(e.directives.docStart)i=!0}if(i)n.push("---");let r=fa.createStringifyContext(e,t),{commentString:s}=r.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=s(e.commentBefore);n.unshift(Jn.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Vv.isNode(e.contents)){if(e.contents.spaceBefore&&i)n.push("");if(e.contents.commentBefore){let f=s(e.contents.commentBefore);n.push(Jn.indentComment(f,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=fa.stringify(e.contents,r,()=>a=null,l);if(a)c+=Jn.lineComment(c,"",s(a));if((c[0]==="|"||c[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${c}`;else n.push(c)}else n.push(fa.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=s(e.comment);if(l.includes(`
|
|
567
567
|
`))n.push("..."),n.push(Jn.indentComment(l,""));else n.push(`... ${l}`)}else n.push("...");else{let l=e.comment;if(l&&o)l=l.replace(/^\n+/,"");if(l){if((!o||a)&&n[n.length-1]!=="")n.push("");n.push(Jn.indentComment(s(l),""))}}return n.join(`
|
|
568
568
|
`)+`
|
|
569
|
-
`}
|
|
569
|
+
`}Kv.stringifyDocument=Hv});var zn=M(function(tS){var Yv=Pn(),en=ur(),_e=H(),Jv=at(),zv=rt(),Xv=ua(),Qv=cp(),da=ar(),Zv=Oo(),eS=Fn(),pa=Mo();class ma{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,_e.NODE_TYPE,{value:_e.DOC});let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t,t=void 0;let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=r;let{version:s}=r;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)s=this.directives.yaml.version}else this.directives=new pa.Directives({version:s});this.setSchema(s,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(ma.prototype,{[_e.NODE_TYPE]:{value:_e.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=_e.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(tn(this.contents))this.contents.add(e)}addIn(e,t){if(tn(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=da.anchorNames(this);e.anchor=!t||n.has(t)?da.findNewAnchor(t||"a",n):t}return new Yv.Alias(e.anchor)}createNode(e,t,n){let i=void 0;if(typeof t==="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){let p=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,m=t.filter(p).map(String);if(m.length>0)t=t.concat(m);i=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:s,flow:o,keepUndefined:a,onTagObj:l,tag:c}=n??{},{onAnchor:f,setAnchors:u,sourceObjects:d}=da.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:f,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:d},h=eS.createNode(e,c,g);if(o&&_e.isCollection(h))h.flow=!0;return u(),h}createPair(e,t,n={}){let i=this.createNode(e,null,n),r=this.createNode(t,null,n);return new Jv.Pair(i,r)}delete(e){return tn(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(en.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return tn(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return _e.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(en.isEmptyPath(e))return!t&&_e.isScalar(this.contents)?this.contents.value:this.contents;return _e.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return _e.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(en.isEmptyPath(e))return this.contents!==void 0;return _e.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=en.collectionFromPath(this.schema,[e],t);else if(tn(this.contents))this.contents.set(e,t)}setIn(e,t){if(en.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=en.collectionFromPath(this.schema,Array.from(e),t);else if(tn(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new pa.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new pa.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let i=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Xv.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:s}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i==="number"?i:100},a=zv.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof s==="function"?Zv.applyReviver(s,{"":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 Qv.stringifyDocument(this,e)}}function tn(e){if(_e.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}tS.Document=ma});var Xn=M(function(rS){class Fr extends Error{constructor(e,t,n,i){super();this.name=e,this.code=n,this.message=i,this.pos=t}}class up extends Fr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class fp extends Fr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var iS=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:i,col:r}=n.linePos[0];n.message+=` at line ${i}, column ${r}`;let s=r-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(s>=60&&o.length>80){let a=Math.min(s-39,o.length-79);o="…"+o.substring(a),s-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(i>1&&/^ *$/.test(o.substring(0,s))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);if(a.length>80)a=a.substring(0,79)+`…
|
|
570
570
|
`;o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];if(l?.line===i&&l.col>r)a=Math.max(1,Math.min(l.col-r,80-s));let c=" ".repeat(s)+"^".repeat(a);n.message+=`:
|
|
571
571
|
|
|
572
572
|
${o}
|
|
573
573
|
${c}
|
|
574
|
-
`}};
|
|
575
|
-
`))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 n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(
|
|
576
|
-
`+
|
|
577
|
-
`+x.comment;else w.comment=x.comment;let E=new
|
|
578
|
-
`+_.comment;else c.comment=_.comment;u=_.end;continue}if(!o&&n.options.strict&&
|
|
579
|
-
`+S;else k.comment=S;_.comment=_.comment.substring(S.length+1)}}}if(!o&&!E&&!_.found){let S=A?e(n,A,_,r):t(n,_.end,E,null,_,r);if(c.items.push(S),u=S.range[2],
|
|
580
|
-
`+R.comment;else k.comment=R.comment;let
|
|
581
|
-
`+m.comment;else c.comment=m.comment;c.range=[i.offset,
|
|
582
|
-
`.repeat(Math.max(1,o.length-1)):"",m=i+r.length;if(t.source)m+=t.source.length;return{value:
|
|
583
|
-
`;for(let
|
|
584
|
-
`;else if(m.length>l||v[0]==="\t"){if(
|
|
585
|
-
`;else if(!g&&
|
|
586
|
-
`)
|
|
574
|
+
`}};rS.YAMLError=Fr;rS.YAMLParseError=up;rS.YAMLWarning=fp;rS.prettifyError=iS});var Qn=M(function(uS){function cS(e,{flow:t,indicator:n,next:i,offset:r,onError:s,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",g=!1,h=!1,p=null,m=null,v=null,w=null,x=null,E=null,A=null;for(let k of e){if(h){if(k.type!=="space"&&k.type!=="newline"&&k.type!=="comma")s(k.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");h=!1}if(p){if(c&&k.type!=="comment"&&k.type!=="newline")s(p,"TAB_AS_INDENT","Tabs are not allowed as indentation");p=null}switch(k.type){case"space":if(!t&&(n!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes("\t"))p=k;f=!0;break;case"comment":{if(!f)s(k,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let R=k.source.substring(1)||" ";if(!u)u=R;else u+=d+R;d="",c=!1;break}case"newline":if(c){if(u)u+=k.source;else if(!E||n!=="seq-item-ind")l=!0}else d+=k.source;if(c=!0,g=!0,m||v)w=k;f=!0;break;case"anchor":if(m)s(k,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(k.source.endsWith(":"))s(k.offset+k.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);m=k,A??(A=k.offset),c=!1,f=!1,h=!0;break;case"tag":{if(v)s(k,"MULTIPLE_TAGS","A node can have at most one tag");v=k,A??(A=k.offset),c=!1,f=!1,h=!0;break}case n:if(m||v)s(k,"BAD_PROP_ORDER",`Anchors and tags must be after the ${k.source} indicator`);if(E)s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.source} in ${t??"collection"}`);E=k,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(t){if(x)s(k,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=k,c=!1,f=!1;break}default:s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,f=!1}}let _=e[e.length-1],S=_?_.offset+_.source.length:r;if(h&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!==""))s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(p&&(c&&p.indent<=o||i?.type==="block-map"||i?.type==="block-seq"))s(p,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:x,found:E,spaceBefore:l,comment:u,hasNewline:g,anchor:m,tag:v,newlineAfterProp:w,end:S,start:A??S}}uS.resolveProps=cS});var Dr=M(function(dS){function ha(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
575
|
+
`))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 n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(ha(t.key)||ha(t.value))return!0}return!1;default:return!0}}dS.containsNewline=ha});var ga=M(function(gS){var mS=Dr();function hS(e,t,n){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&mS.containsNewline(t))n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}gS.flowIndentCheck=hS});var ya=M(function(wS){var dp=H();function bS(e,t,n){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let r=typeof i==="function"?i:(s,o)=>s===o||dp.isScalar(s)&&dp.isScalar(o)&&s.value===o.value;return t.some((s)=>r(s.key,n))}wS.mapIncludes=bS});var yp=M(function(ES){var pp=at(),vS=ct(),mp=Qn(),SS=Dr(),hp=ga(),$S=ya(),gp="All mapping items must start at the same column";function _S({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??vS.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let l=i.offset,c=null;for(let f of i.items){let{start:u,key:d,sep:g,value:h}=f,p=mp.resolveProps(u,{indicator:"explicit-key-ind",next:d??g?.[0],offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!p.found;if(m){if(d){if(d.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==i.indent)r(l,"BAD_INDENT",gp)}if(!p.anchor&&!p.tag&&!g){if(c=p.end,p.comment)if(a.comment)a.comment+=`
|
|
576
|
+
`+p.comment;else a.comment=p.comment;continue}if(p.newlineAfterProp||SS.containsNewline(d))r(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(p.found?.indent!==i.indent)r(l,"BAD_INDENT",gp);n.atKey=!0;let v=p.end,w=d?e(n,d,p,r):t(n,v,u,null,p,r);if(n.schema.compat)hp.flowIndentCheck(i.indent,d,r);if(n.atKey=!1,$S.mapIncludes(n,a.items,w))r(v,"DUPLICATE_KEY","Map keys must be unique");let x=mp.resolveProps(g??[],{indicator:"map-value-ind",next:h,offset:w.range[2],onError:r,parentIndent:i.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=x.end,x.found){if(m){if(h?.type==="block-map"&&!x.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&p.start<x.found.offset-1024)r(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let E=h?e(n,h,x,r):t(n,l,g,null,x,r);if(n.schema.compat)hp.flowIndentCheck(i.indent,h,r);l=E.range[2];let A=new pp.Pair(w,E);if(n.options.keepSourceTokens)A.srcToken=f;a.items.push(A)}else{if(m)r(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(x.comment)if(w.comment)w.comment+=`
|
|
577
|
+
`+x.comment;else w.comment=x.comment;let E=new pp.Pair(w);if(n.options.keepSourceTokens)E.srcToken=f;a.items.push(E)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[i.offset,l,c??l],a}ES.resolveBlockMap=_S});var bp=M(function(OS){var kS=ut(),IS=Qn(),TS=ga();function MS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??kS.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let l=i.offset,c=null;for(let{start:f,value:u}of i.items){let d=IS.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)if(u?.type==="block-seq")r(d.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=d.end,d.comment)a.comment=d.comment;continue}let g=u?e(n,u,d,r):t(n,d.end,f,null,d,r);if(n.schema.compat)TS.flowIndentCheck(i.indent,u,r);l=g.range[2],a.items.push(g)}return a.range=[i.offset,l,c??l],a}OS.resolveBlockSeq=MS});var nn=M(function(RS){function CS(e,t,n,i){let r="";if(e){let s=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":s=!0;break;case"comment":{if(n&&!s)i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";if(!r)r=f;else r+=o+f;o="";break}case"newline":if(r)o+=l;s=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}RS.resolveEnd=CS});var vp=M(function(BS){var PS=H(),FS=at(),wp=ct(),DS=ut(),qS=nn(),xp=Qn(),US=Dr(),jS=ya(),ba="Block collections are not allowed within flow collections",wa=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function GS({composeNode:e,composeEmptyNode:t},n,i,r,s){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=new(s?.nodeClass??(o?wp.YAMLMap:DS.YAMLSeq))(n.schema);c.flow=!0;let f=n.atRoot;if(f)n.atRoot=!1;if(n.atKey)n.atKey=!1;let u=i.offset+i.start.source.length;for(let m=0;m<i.items.length;++m){let v=i.items[m],{start:w,key:x,sep:E,value:A}=v,_=xp.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:x??E?.[0],offset:u,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!_.found){if(!_.anchor&&!_.tag&&!E&&!A){if(m===0&&_.comma)r(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(m<i.items.length-1)r(_.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(_.comment)if(c.comment)c.comment+=`
|
|
578
|
+
`+_.comment;else c.comment=_.comment;u=_.end;continue}if(!o&&n.options.strict&&US.containsNewline(x))r(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0){if(_.comma)r(_.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!_.comma)r(_.start,"MISSING_CHAR",`Missing , between ${a} items`);if(_.comment){let S="";e:for(let k of w)switch(k.type){case"comma":case"space":break;case"comment":S=k.source.substring(1);break e;default:break e}if(S){let k=c.items[c.items.length-1];if(PS.isPair(k))k=k.value??k.key;if(k.comment)k.comment+=`
|
|
579
|
+
`+S;else k.comment=S;_.comment=_.comment.substring(S.length+1)}}}if(!o&&!E&&!_.found){let S=A?e(n,A,_,r):t(n,_.end,E,null,_,r);if(c.items.push(S),u=S.range[2],wa(A))r(S.range,"BLOCK_IN_FLOW",ba)}else{n.atKey=!0;let S=_.end,k=x?e(n,x,_,r):t(n,S,w,null,_,r);if(wa(x))r(k.range,"BLOCK_IN_FLOW",ba);n.atKey=!1;let R=xp.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:A,offset:k.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(R.found){if(!o&&!_.found&&n.options.strict){if(E)for(let P of E){if(P===R.found)break;if(P.type==="newline"){r(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(_.start<R.found.offset-1024)r(R.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(A)if("source"in A&&A.source?.[0]===":")r(A,"MISSING_CHAR",`Missing space after : in ${a}`);else r(R.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let U=A?e(n,A,R,r):R.found?t(n,R.end,E,null,R,r):null;if(U){if(wa(A))r(U.range,"BLOCK_IN_FLOW",ba)}else if(R.comment)if(k.comment)k.comment+=`
|
|
580
|
+
`+R.comment;else k.comment=R.comment;let D=new FS.Pair(k,U);if(n.options.keepSourceTokens)D.srcToken=v;if(o){let P=c;if(jS.mapIncludes(n,P.items,k))r(S,"DUPLICATE_KEY","Map keys must be unique");P.items.push(D)}else{let P=new wp.YAMLMap(n.schema);P.flow=!0,P.items.push(D);let N=(U??k).range;P.range=[k.range[0],N[1],N[2]],c.items.push(P)}u=U?U.range[2]:R.end}}let d=o?"}":"]",[g,...h]=i.end,p=u;if(g?.source===d)p=g.offset+g.source.length;else{let m=a[0].toUpperCase()+a.substring(1),v=f?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;if(r(u,f?"MISSING_CHAR":"BAD_INDENT",v),g&&g.source.length!==1)h.unshift(g)}if(h.length>0){let m=qS.resolveEnd(h,p,n.options.strict,r);if(m.comment)if(c.comment)c.comment+=`
|
|
581
|
+
`+m.comment;else c.comment=m.comment;c.range=[i.offset,p,m.offset]}else c.range=[i.offset,p,p];return c}BS.resolveFlowCollection=GS});var Sp=M(function(ZS){var HS=H(),KS=re(),WS=ct(),YS=ut(),JS=yp(),zS=bp(),XS=vp();function xa(e,t,n,i,r,s){let o=n.type==="block-map"?JS.resolveBlockMap(e,t,n,i,s):n.type==="block-seq"?zS.resolveBlockSeq(e,t,n,i,s):XS.resolveFlowCollection(e,t,n,i,s),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function QS(e,t,n,i,r){let s=i.tag,o=!s?null:t.directives.tagName(s.source,(d)=>r(s,"TAG_RESOLVE_FAILED",d));if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:g}=i,h=d&&s?d.offset>s.offset?d:s:d??s;if(h&&(!g||g.offset<h.offset))r(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!o||o==="!"||o===WS.YAMLMap.tagName&&a==="map"||o===YS.YAMLSeq.tagName&&a==="seq")return xa(e,t,n,r,o);let l=t.schema.tags.find((d)=>d.tag===o&&d.collection===a);if(!l){let d=t.schema.knownTags[o];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else{if(d)r(s,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return xa(e,t,n,r,o)}}let c=xa(e,t,n,r,o,l),f=l.resolve?.(c,(d)=>r(s,"TAG_RESOLVE_FAILED",d),t.options)??c,u=HS.isNode(f)?f:new KS.Scalar(f);if(u.range=c.range,u.tag=o,l?.format)u.format=l.format;return u}ZS.composeCollection=QS});var Sa=M(function(r$){var va=re();function t$(e,t,n){let i=t.offset,r=n$(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let s=r.mode===">"?va.Scalar.BLOCK_FOLDED:va.Scalar.BLOCK_LITERAL,o=t.source?i$(t.source):[],a=o.length;for(let p=o.length-1;p>=0;--p){let m=o[p][1];if(m===""||m==="\r")a=p;else break}if(a===0){let p=r.chomp==="+"&&o.length>0?`
|
|
582
|
+
`.repeat(Math.max(1,o.length-1)):"",m=i+r.length;if(t.source)m+=t.source.length;return{value:p,type:s,comment:r.comment,range:[i,m,m]}}let l=t.indent+r.indent,c=t.offset+r.length,f=0;for(let p=0;p<a;++p){let[m,v]=o[p];if(v===""||v==="\r"){if(r.indent===0&&m.length>l)l=m.length}else{if(m.length<l)n(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(r.indent===0)l=m.length;if(f=p,l===0&&!e.atRoot)n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+v.length+1}for(let p=o.length-1;p>=a;--p)if(o[p][0].length>l)a=p+1;let u="",d="",g=!1;for(let p=0;p<f;++p)u+=o[p][0].slice(l)+`
|
|
583
|
+
`;for(let p=f;p<a;++p){let[m,v]=o[p];c+=m.length+v.length+1;let w=v[v.length-1]==="\r";if(w)v=v.slice(0,-1);if(v&&m.length<l){let E=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(c-v.length-(w?2:1),"BAD_INDENT",E),m=""}if(s===va.Scalar.BLOCK_LITERAL)u+=d+m.slice(l)+v,d=`
|
|
584
|
+
`;else if(m.length>l||v[0]==="\t"){if(d===" ")d=`
|
|
585
|
+
`;else if(!g&&d===`
|
|
586
|
+
`)d=`
|
|
587
587
|
|
|
588
|
-
`;u+=
|
|
589
|
-
`,g=!0}else if(v==="")if(
|
|
588
|
+
`;u+=d+m.slice(l)+v,d=`
|
|
589
|
+
`,g=!0}else if(v==="")if(d===`
|
|
590
590
|
`)u+=`
|
|
591
|
-
`;else
|
|
592
|
-
`;else u+=
|
|
593
|
-
`+o[
|
|
591
|
+
`;else d=`
|
|
592
|
+
`;else u+=d+v,d=" ",g=!1}switch(r.chomp){case"-":break;case"+":for(let p=a;p<o.length;++p)u+=`
|
|
593
|
+
`+o[p][0].slice(l);if(u[u.length-1]!==`
|
|
594
594
|
`)u+=`
|
|
595
595
|
`;break;default:u+=`
|
|
596
|
-
`}let h=i+r.length+t.source.length;return{value:u,type:s,comment:r.comment,range:[i,h,h]}}function
|
|
596
|
+
`}let h=i+r.length+t.source.length;return{value:u,type:s,comment:r.comment,range:[i,h,h]}}function n$({offset:e,props:t},n,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=t[0],s=r[0],o=0,a="",l=-1;for(let d=1;d<r.length;++d){let g=r[d];if(!a&&(g==="-"||g==="+"))a=g;else{let h=Number(g);if(!o&&h)o=h;else if(l===-1)l=e+d}}if(l!==-1)i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,f="",u=r.length;for(let d=1;d<t.length;++d){let g=t[d];switch(g.type){case"space":c=!0;case"newline":u+=g.source.length;break;case"comment":if(n&&!c)i(g,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");u+=g.source.length,f=g.source.substring(1);break;case"error":i(g,"UNEXPECTED_TOKEN",g.message),u+=g.source.length;break;default:{let h=`Unexpected token in block scalar header: ${g.type}`;i(g,"UNEXPECTED_TOKEN",h);let p=g.source;if(p&&typeof p==="string")u+=p.length}}}return{mode:s,indent:o,chomp:a,comment:f,length:u}}function i$(e){let t=e.split(/\n( *)/),n=t[0],i=n.match(/^( *)/),s=[i?.[1]?[i[1],n.slice(i[1].length)]:["",n]];for(let o=1;o<t.length;o+=2)s.push([t[o],t[o+1]]);return s}r$.resolveBlockScalar=t$});var _a=M(function(m$){var $a=re(),o$=nn();function a$(e,t,n){let{offset:i,type:r,source:s,end:o}=e,a,l,c=(d,g,h)=>n(i+d,g,h);switch(r){case"scalar":a=$a.Scalar.PLAIN,l=l$(s,c);break;case"single-quoted-scalar":a=$a.Scalar.QUOTE_SINGLE,l=c$(s,c);break;case"double-quoted-scalar":a=$a.Scalar.QUOTE_DOUBLE,l=u$(s,c);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+s.length,i+s.length]}}let f=i+s.length,u=o$.resolveEnd(o,f,t,n);return{value:l,type:a,comment:u.comment,range:[i,f,u.offset]}}function l$(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}if(n)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return $p(e)}function c$(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return $p(e.slice(1,-1)).replace(/''/g,"'")}function $p(e){let t,n;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
597
597
|
`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
598
598
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let r=i[1],s=" ",o=t.lastIndex;n.lastIndex=o;while(i=n.exec(e)){if(i[1]==="")if(s===`
|
|
599
599
|
`)r+=s;else s=`
|
|
600
|
-
`;else r+=s+i[1],s=" ";o=n.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),r+s+(i?.[1]??"")}function
|
|
600
|
+
`;else r+=s+i[1],s=" ";o=n.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),r+s+(i?.[1]??"")}function u$(e,t){let n="";for(let i=1;i<e.length-1;++i){let r=e[i];if(r==="\r"&&e[i+1]===`
|
|
601
601
|
`)continue;if(r===`
|
|
602
|
-
`){let{fold:s,offset:o}=
|
|
602
|
+
`){let{fold:s,offset:o}=f$(e,i);n+=s,i=o}else if(r==="\\"){let s=e[++i],o=d$[s];if(o)n+=o;else if(s===`
|
|
603
603
|
`){s=e[i+1];while(s===" "||s==="\t")s=e[++i+1]}else if(s==="\r"&&e[i+1]===`
|
|
604
|
-
`){s=e[++i+1];while(s===" "||s==="\t")s=e[++i+1]}else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=
|
|
604
|
+
`){s=e[++i+1];while(s===" "||s==="\t")s=e[++i+1]}else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=p$(e,i+1,a,t),i+=a}else{let a=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(r===" "||r==="\t"){let s=i,o=e[i+1];while(o===" "||o==="\t")o=e[++i+1];if(o!==`
|
|
605
605
|
`&&!(o==="\r"&&e[i+2]===`
|
|
606
|
-
`))n+=i>s?e.slice(s,i+1):r}else n+=r}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function
|
|
606
|
+
`))n+=i>s?e.slice(s,i+1):r}else n+=r}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function f$(e,t){let n="",i=e[t+1];while(i===" "||i==="\t"||i===`
|
|
607
607
|
`||i==="\r"){if(i==="\r"&&e[t+2]!==`
|
|
608
608
|
`)break;if(i===`
|
|
609
609
|
`)n+=`
|
|
610
|
-
`;t+=1,i=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var
|
|
611
|
-
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function
|
|
610
|
+
`;t+=1,i=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var d$={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
611
|
+
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function p$(e,t,n,i){let r=e.substr(t,n),o=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,n+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}m$.resolveFlowScalar=a$});var Ep=M(function(v$){var Rt=H(),_p=re(),g$=Sa(),y$=_a();function b$(e,t,n,i){let{value:r,type:s,comment:o,range:a}=t.type==="block-scalar"?g$.resolveBlockScalar(e,t,i):y$.resolveFlowScalar(t,e.options.strict,i),l=n?e.directives.tagName(n.source,(u)=>i(n,"TAG_RESOLVE_FAILED",u)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[Rt.SCALAR];else if(l)c=w$(e.schema,r,l,n,i);else if(t.type==="scalar")c=x$(e,r,t,i);else c=e.schema[Rt.SCALAR];let f;try{let u=c.resolve(r,(d)=>i(n??t,"TAG_RESOLVE_FAILED",d),e.options);f=Rt.isScalar(u)?u:new _p.Scalar(u)}catch(u){let d=u instanceof Error?u.message:String(u);i(n??t,"TAG_RESOLVE_FAILED",d),f=new _p.Scalar(r)}if(f.range=a,f.source=r,s)f.type=s;if(l)f.tag=l;if(c.format)f.format=c.format;if(o)f.comment=o;return f}function w$(e,t,n,i,r){if(n==="!")return e[Rt.SCALAR];let s=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(t))return a;let o=e.knownTags[n];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Rt.SCALAR]}function x$({atKey:e,directives:t,schema:n},i,r,s){let o=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||n[Rt.SCALAR];if(n.compat){let a=n.compat.find((l)=>l.default&&l.test?.test(i))??n[Rt.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;s(r,"TAG_RESOLVE_FAILED",f,!0)}}return o}v$.composeScalar=b$});var Ap=M(function(_$){function $$(e,t,n){if(t){n??(n=t.length);for(let i=n-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++i];while(r?.type==="space")e+=r.source.length,r=t[++i];break}}return e}_$.emptyScalarPosition=$$});var Tp=M(function(C$){var A$=Pn(),k$=H(),I$=Sp(),kp=Ep(),T$=nn(),M$=Ap(),O$={composeNode:Ip,composeEmptyNode:Ea};function Ip(e,t,n,i){let r=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:l}=n,c,f=!0;switch(t.type){case"alias":if(c=N$(e,t,i),a||l)i(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(c=kp.composeScalar(e,t,l,i),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=I$.composeCollection(O$,e,t,n,i),a)c.anchor=a.source.substring(1)}catch(u){let d=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",d)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),f=!1}}if(c??(c=Ea(e,t.offset,void 0,null,n,i)),a&&c.anchor==="")i(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!k$.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(s)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&f)c.srcToken=t;return c}function Ea(e,t,n,i,{spaceBefore:r,comment:s,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:M$.emptyScalarPosition(t,n,i),indent:-1,source:""},u=kp.composeScalar(e,f,a,c);if(o){if(u.anchor=o.source.substring(1),u.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)u.spaceBefore=!0;if(s)u.comment=s,u.range[2]=l;return u}function N$({options:e},{offset:t,source:n,end:i},r){let s=new A$.Alias(n.substring(1));if(s.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(s.source.endsWith(":"))r(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+n.length,a=T$.resolveEnd(i,o,e.strict,r);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}C$.composeEmptyNode=Ea;C$.composeNode=Ip});var Op=M(function(U$){var P$=zn(),Mp=Tp(),F$=nn(),D$=Qn();function q$(e,t,{offset:n,start:i,value:r,end:s},o){let a=Object.assign({_directives:t},e),l=new P$.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=D$.resolveProps(i,{indicator:"doc-start",next:r??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(f.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!f.hasNewline)o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?Mp.composeNode(c,r,f,o):Mp.composeEmptyNode(c,f.end,i,null,f,o);let u=l.contents.range[2],d=F$.resolveEnd(s,u,!1,o);if(d.comment)l.comment=d.comment;return l.range=[n,u,d.offset],l}U$.composeDoc=q$});var Aa=M(function(W$){var G$=ln("process"),B$=Mo(),V$=zn(),Zn=Xn(),Np=H(),H$=Op(),K$=nn();function ei(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:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function Cp(e){let t="",n=!1,i=!1;for(let r=0;r<e.length;++r){let s=e[r];switch(s[0]){case"#":t+=(t===""?"":i?`
|
|
612
612
|
|
|
613
613
|
`:`
|
|
614
|
-
`)+(s.substring(1)||" "),n=!0,i=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;n=!1;break;default:if(!n)i=!0;n=!1}}return{comment:t,afterEmptyLine:i}}class
|
|
615
|
-
${n}`:n;else if(i||e.directives.docStart||!r)e.commentBefore=n;else if(
|
|
614
|
+
`)+(s.substring(1)||" "),n=!0,i=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;n=!1;break;default:if(!n)i=!0;n=!1}}return{comment:t,afterEmptyLine:i}}class Rp{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,i,r)=>{let s=ei(t);if(r)this.warnings.push(new Zn.YAMLWarning(s,n,i));else this.errors.push(new Zn.YAMLParseError(s,n,i))},this.directives=new B$.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:i}=Cp(this.prelude);if(n){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
615
|
+
${n}`:n;else if(i||e.directives.docStart||!r)e.commentBefore=n;else if(Np.isCollection(r)&&!r.flow&&r.items.length>0){let s=r.items[0];if(Np.isPair(s))s=s.key;let o=s.commentBefore;s.commentBefore=o?`${n}
|
|
616
616
|
${o}`:n}else{let s=r.commentBefore;r.commentBefore=s?`${n}
|
|
617
|
-
${s}`:n}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
618
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new
|
|
617
|
+
${s}`:n}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Cp(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let i of e)yield*this.next(i);yield*this.end(t,n)}*next(e){if(G$.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{let r=ei(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=H$.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,n=new Zn.YAMLParseError(ei(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Zn.YAMLParseError(ei(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=K$.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
|
|
618
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Zn.YAMLParseError(ei(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 n=Object.assign({_directives:this.directives},this.options),i=new V$.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");i.range=[0,t,t],this.decorate(i,!1),yield i}}}W$.Composer=Rp});var Fp=M(function(n_){var J$=Sa(),z$=_a(),X$=Xn(),Lp=Un();function Q$(e,t=!0,n){if(e){let i=(r,s,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(n)n(a,s,o);else throw new X$.YAMLParseError([a,a+1],s,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return z$.resolveFlowScalar(e,t,i);case"block-scalar":return J$.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Z$(e,t){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:s=-1,type:o="PLAIN"}=t,a=Lp.stringifyString({type:o,value:e},{implicitKey:n,indent:i>0?" ".repeat(i):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
619
619
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
620
|
-
`),
|
|
621
|
-
`,
|
|
622
|
-
`});return{type:"block-scalar",offset:s,indent:i,props:
|
|
620
|
+
`),f=a.substring(0,c),u=a.substring(c+1)+`
|
|
621
|
+
`,d=[{type:"block-scalar-header",offset:s,indent:i,source:f}];if(!Pp(d,l))d.push({type:"newline",offset:-1,indent:i,source:`
|
|
622
|
+
`});return{type:"block-scalar",offset:s,indent:i,props:d,source:u}}case'"':return{type:"double-quoted-scalar",offset:s,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:s,indent:i,source:a,end:l};default:return{type:"scalar",offset:s,indent:i,source:a,end:l}}}function e_(e,t,n={}){let{afterKey:i=!1,implicitKey:r=!1,inFlow:s=!1,type:o}=n,a="indent"in e?e.indent:null;if(i&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Lp.stringifyString({type:o,value:t},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":t_(e,l);break;case'"':ka(e,l,"double-quoted-scalar");break;case"'":ka(e,l,"single-quoted-scalar");break;default:ka(e,l,"scalar")}}function t_(e,t){let n=t.indexOf(`
|
|
623
623
|
`),i=t.substring(0,n),r=t.substring(n+1)+`
|
|
624
|
-
`;if(e.type==="block-scalar"){let s=e.props[0];if(s.type!=="block-scalar-header")throw Error("Invalid block scalar header");s.source=i,e.source=r}else{let{offset:s}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:i}];if(!
|
|
625
|
-
`});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function
|
|
626
|
-
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let i="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((s)=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(e))if(s!=="type"&&s!=="offset")delete e[s];Object.assign(e,{type:n,indent:i,source:t,end:r})}}}
|
|
624
|
+
`;if(e.type==="block-scalar"){let s=e.props[0];if(s.type!=="block-scalar-header")throw Error("Invalid block scalar header");s.source=i,e.source=r}else{let{offset:s}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:s,indent:o,source:i}];if(!Pp(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
|
|
625
|
+
`});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function Pp(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function ka(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),r=t.length;if(e.props[0].type==="block-scalar-header")r-=e.props[0].source.length;for(let s of i)s.offset+=r;delete e.props,Object.assign(e,{type:n,source:t,end:i});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
626
|
+
`};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let i="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((s)=>s.type==="space"||s.type==="comment"||s.type==="newline"):[];for(let s of Object.keys(e))if(s!=="type"&&s!=="offset")delete e[s];Object.assign(e,{type:n,indent:i,source:t,end:r})}}}n_.createScalarToken=Z$;n_.resolveAsScalar=Q$;n_.setScalarValue=e_});var Dp=M(function(a_){var o_=(e)=>("type"in e)?Ur(e):qr(e);function Ur(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=Ur(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=qr(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=qr(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=qr(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function qr({start:e,key:t,sep:n,value:i}){let r="";for(let s of e)r+=s.source;if(t)r+=Ur(t);if(n)for(let s of n)r+=s.source;if(i)r+=Ur(i);return r}a_.stringify=o_});var jp=M(function(u_){var Ia=Symbol("break visit"),c_=Symbol("skip children"),qp=Symbol("remove item");function Lt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Up(Object.freeze([]),e,t)}Lt.BREAK=Ia;Lt.SKIP=c_;Lt.REMOVE=qp;Lt.itemAtPath=(e,t)=>{let n=e;for(let[i,r]of t){let s=n?.[i];if(s&&"items"in s)n=s.items[r];else return}return n};Lt.parentCollection=(e,t)=>{let n=Lt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],r=n?.[i];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function Up(e,t,n){let i=n(t,e);if(typeof i==="symbol")return i;for(let r of["key","value"]){let s=t[r];if(s&&"items"in s){for(let o=0;o<s.items.length;++o){let a=Up(Object.freeze(e.concat([[r,o]])),s.items[o],n);if(typeof a==="number")o=a-1;else if(a===Ia)return Ia;else if(a===qp)s.items.splice(o,1),o-=1}if(typeof i==="function"&&r==="key")i=i(t,e)}}return typeof i==="function"?i(t,e):i}u_.visit=Lt});var jr=M(function(b_){var Ta=Fp(),d_=Dp(),p_=jp(),Ma="\uFEFF",Oa="\x02",Na="\x18",Ca="\x1F",m_=(e)=>!!e&&("items"in e),h_=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function g_(e){switch(e){case Ma:return"<BOM>";case Oa:return"<DOC>";case Na:return"<FLOW_END>";case Ca:return"<SCALAR>";default:return JSON.stringify(e)}}function y_(e){switch(e){case Ma:return"byte-order-mark";case Oa:return"doc-mode";case Na:return"flow-error-end";case Ca:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
627
627
|
`:case`\r
|
|
628
|
-
`: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}
|
|
629
|
-
`:case"\r":case"\t":return!0;default:return!1}}var
|
|
630
|
-
\r `),
|
|
628
|
+
`: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}b_.createScalarToken=Ta.createScalarToken;b_.resolveAsScalar=Ta.resolveAsScalar;b_.setScalarValue=Ta.setScalarValue;b_.stringify=d_.stringify;b_.visit=p_.visit;b_.BOM=Ma;b_.DOCUMENT=Oa;b_.FLOW_END=Na;b_.SCALAR=Ca;b_.isCollection=m_;b_.isScalar=h_;b_.prettyToken=g_;b_.tokenType=y_});var La=M(function(R_){var ti=jr();function Ne(e){switch(e){case void 0:case" ":case`
|
|
629
|
+
`:case"\r":case"\t":return!0;default:return!1}}var Gp=new Set("0123456789ABCDEFabcdef"),N_=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Gr=new Set(",[]{}"),C_=new Set(` ,[]{}
|
|
630
|
+
\r `),Ra=(e)=>!e||C_.has(e);class Bp{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 n=this.next??"stream";while(n&&(t||this.hasChars(1)))n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
|
|
631
631
|
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
632
632
|
`;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;while(t===" ")t=this.buffer[++n+e];if(t==="\r"){let i=this.buffer[n+e+1];if(i===`
|
|
633
633
|
`||!i&&!this.atEnd)return e+n+1}return t===`
|
|
634
|
-
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&
|
|
635
|
-
`,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]===
|
|
634
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&Ne(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(`
|
|
635
|
+
`,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]===ti.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,n=e.indexOf("#");while(n!==-1){let r=e[n-1];if(r===" "||r==="\t"){t=n-1;break}else n=e.indexOf("#",n+1)}while(!0){let r=e[t-1];if(r===" "||r==="\t")t-=1;else break}let i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),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 ti.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==="...")&&Ne(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&&!Ne(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===":")&&Ne(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"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(Ra),"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,n=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=n=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let i=this.getLine();if(i===null)return this.setNext("flow");if(n!==-1&&n<this.indentNext&&i[0]!=="#"||n===0&&(i.startsWith("---")||i.startsWith("..."))&&Ne(i[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield ti.FLOW_END,yield*this.parseLineStart()}let r=0;while(i[r]===",")r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),i[r]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-r),"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(Ra),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||Ne(s)||s===",")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 r=0;while(this.buffer[t-1-r]==="\\")r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}let n=this.buffer.substring(0,t),i=n.indexOf(`
|
|
636
636
|
`,this.pos);if(i!==-1){while(i!==-1){let r=this.continueScalar(i+1);if(r===-1)break;i=n.indexOf(`
|
|
637
|
-
`,r)}if(i!==-1)t=i-(n[i-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)=>
|
|
637
|
+
`,r)}if(i!==-1)t=i-(n[i-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)=>Ne(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case" ":t+=1;break;case`
|
|
638
638
|
`:e=r,t=0;break;case"\r":{let s=this.buffer[r+1];if(!s&&!this.atEnd)return this.setNext("block-scalar");if(s===`
|
|
639
639
|
`)break}default:break e}if(!n&&!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 r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(`
|
|
640
640
|
`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;n=this.buffer[i];while(n===" ")n=this.buffer[++i];if(n==="\t"){while(n==="\t"||n===" "||n==="\r"||n===`
|
|
641
641
|
`)n=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let r=e-1,s=this.buffer[r];if(s==="\r")s=this.buffer[--r];let o=r;while(s===" ")s=this.buffer[--r];if(s===`
|
|
642
|
-
`&&r>=this.pos&&r+1+t>o)e=r;else break}while(!0);return yield
|
|
642
|
+
`&&r>=this.pos&&r+1+t>o)e=r;else break}while(!0);return yield ti.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,i;while(i=this.buffer[++n])if(i===":"){let r=this.buffer[n+1];if(Ne(r)||e&&Gr.has(r))break;t=n}else if(Ne(i)){let r=this.buffer[n+1];if(i==="\r")if(r===`
|
|
643
643
|
`)n+=1,i=`
|
|
644
|
-
`,r=this.buffer[n+1];else t=n;if(r==="#"||e&&
|
|
645
|
-
`){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(e&&
|
|
644
|
+
`,r=this.buffer[n+1];else t=n;if(r==="#"||e&&Gr.has(r))break;if(i===`
|
|
645
|
+
`){let s=this.continueScalar(n+1);if(s===-1)break;n=Math.max(n,s-2)}}else{if(e&&Gr.has(i))break;t=n}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield ti.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 n=this.buffer.slice(this.pos,e);if(n)return yield n,this.pos+=n.length,n.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(Ra),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Ne(n)||t&&Gr.has(n)){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(!Ne(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(N_.has(t))t=this.buffer[++e];else if(t==="%"&&Gp.has(this.buffer[e+1])&&Gp.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===`
|
|
646
646
|
`)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
|
|
647
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n==="\t");let i=t-this.pos;if(i>0)yield this.buffer.substr(this.pos,i),this.pos=t;return i}*pushUntil(e){let t=this.pos,n=this.buffer[t];while(!e(n))n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}
|
|
647
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n==="\t");let i=t-this.pos;if(i>0)yield this.buffer.substr(this.pos,i),this.pos=t;return i}*pushUntil(e){let t=this.pos,n=this.buffer[t];while(!e(n))n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}R_.Lexer=Bp});var Pa=M(function(P_){class Vp{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,n=this.lineStarts.length;while(t<n){let r=t+n>>1;if(this.lineStarts[r]<e)t=r+1;else n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}P_.LineCounter=Vp});var Fa=M(function(U_){var D_=ln("process"),Hp=jr(),q_=La();function ft(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Kp(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 Yp(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 Br(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 rn(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 Vr(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Wp(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!ft(t.start,"explicit-key-ind")&&!ft(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,Yp(t.value))if(t.value.end)Vr(t.value.end,t.sep);else t.value.end=t.sep;else Vr(t.start,t.sep);delete t.sep}}}class Jp{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 q_.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);if(!t)yield*this.end()}*next(e){if(this.source=e,D_.env.LOG_TOKENS)console.log("|",Hp.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Hp.tokenType(e);if(!t){let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,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 n=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in n?n.indent:0;else if(t.type==="flow-collection"&&n.type==="document")t.indent=0;if(t.type==="flow-collection")Wp(t);switch(n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{let i=n.items[n.items.length-1];if(i.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{let i=n.items[n.items.length-1];if(i.value)n.items.push({start:[],value:t});else i.value=t;break}case"flow-collection":{let i=n.items[n.items.length-1];if(!i||i.value)n.items.push({start:[],key:t,sep:[]});else if(i.sep)i.value=t;else Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let i=t.items[t.items.length-1];if(i&&!i.sep&&!i.value&&i.start.length>0&&Kp(i.start)===-1&&(t.indent===0||i.start.every((r)=>r.type!=="comment"||r.indent<t.indent))){if(n.type==="document")n.end=i.start;else n.items.push({start:i.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(Kp(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=Br(this.peek(2)),n=rn(t),i;if(e.end)i=e.end,i.push(this.sourceToken),delete e.end;else i=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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(`
|
|
648
648
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
649
|
-
`,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 n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){
|
|
649
|
+
`,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 n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Vr(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,i=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(i&&t.sep&&!t.value){let s=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":s.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)s.length=0;break;default:s.length=0}}if(s.length>=2)r=t.sep.splice(s[1])}switch(this.type){case"anchor":case"tag":if(i||t.value)r.push(this.sourceToken),e.items.push({start:r}),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(i||t.value)r.push(this.sourceToken),e.items.push({start:r,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(ft(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let s=rn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ft(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Yp(t.key)&&!ft(t.sep,"newline")){let s=rn(t.start),{key:o,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:s,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||i)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ft(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 s=this.flowScalar(this.type);if(i||t.value)e.items.push({start:r,key:s,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(s);else Object.assign(t,{key:s,sep:[]}),this.onKeyLine=!0;return}default:{let s=this.startBlockValue(e);if(s){if(s.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ft(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(n)e.items.push({start:r});this.stack.push(s);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 n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Vr(i,t.start),i.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||ft(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.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 i=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:i,sep:[]});else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);if(n)this.stack.push(n);else yield*this.pop(),yield*this.step()}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let i=Br(n),r=rn(i);Wp(e);let s=e.end.splice(1,e.end.length);s.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
650
650
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
651
|
-
`,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=
|
|
652
|
-
`;
|
|
651
|
+
`,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=Br(e),n=rn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Br(e),n=rn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,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((n)=>n.type==="newline"||n.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()}}}U_.Parser=Jp});var em=M(function(J_){var zp=Aa(),G_=zn(),ni=Xn(),B_=Po(),V_=H(),H_=Pa(),Xp=Fa();function Qp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new H_.LineCounter||null,prettyErrors:t}}function K_(e,t={}){let{lineCounter:n,prettyErrors:i}=Qp(t),r=new Xp.Parser(n?.addNewLine),s=new zp.Composer(t),o=Array.from(s.compose(r.parse(e)));if(i&&n)for(let a of o)a.errors.forEach(ni.prettifyError(e,n)),a.warnings.forEach(ni.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Zp(e,t={}){let{lineCounter:n,prettyErrors:i}=Qp(t),r=new Xp.Parser(n?.addNewLine),s=new zp.Composer(t),o=null;for(let a of s.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ni.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&n)o.errors.forEach(ni.prettifyError(e,n)),o.warnings.forEach(ni.prettifyError(e,n));return o}function W_(e,t,n){let i=void 0;if(typeof t==="function")i=t;else if(n===void 0&&t&&typeof t==="object")n=t;let r=Zp(e,n);if(!r)return null;if(r.warnings.forEach((s)=>B_.warn(r.options.logLevel,s)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:i},n))}function Y_(e,t,n){let i=null;if(typeof t==="function"||Array.isArray(t))i=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let r=Math.round(n);n=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=n??t??{};if(!r)return}if(V_.isDocument(e)&&!i)return e.toString(n);return new G_.Document(e,i,n).toString(n)}J_.parse=W_;J_.parseAllDocuments=K_;J_.parseDocument=Zp;J_.stringify=Y_});var eE,tE,nE,Da,iE,dt,rE,sE,oE,aE,EL,lE,cE,uE,Hr,tm,fE,dE,pE,mE,hE,gE,yE,bE,wE,xE,pt,vE,SE,$E,ii,_E,EE,AE,kE,IE,TE,ME,OE,NE,ri,CE,RE,LE;var nm=T(()=>{eE=Aa(),tE=zn(),nE=ua(),Da=Xn(),iE=Pn(),dt=H(),rE=at(),sE=re(),oE=ct(),aE=ut(),EL=jr(),lE=La(),cE=Pa(),uE=Fa(),Hr=em(),tm=Rn();fE=eE.Composer,dE=tE.Document,pE=nE.Schema,mE=Da.YAMLError,hE=Da.YAMLParseError,gE=Da.YAMLWarning,yE=iE.Alias,bE=dt.isAlias,wE=dt.isCollection,xE=dt.isDocument,pt=dt.isMap,vE=dt.isNode,SE=dt.isPair,$E=dt.isScalar,ii=dt.isSeq,_E=rE.Pair,EE=sE.Scalar,AE=oE.YAMLMap,kE=aE.YAMLSeq,IE=lE.Lexer,TE=cE.LineCounter,ME=uE.Parser,OE=Hr.parse,NE=Hr.parseAllDocuments,ri=Hr.parseDocument,CE=Hr.stringify,RE=tm.visit,LE=tm.visitAsync});var Pt,ce,qa;var Kr=T(()=>{Pt=["claude-code","codex","grok","opencode","hermes","pi","oh-my-pi","zed","deepseek-harness"],ce=[{id:je,contextWindow:524288,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"max",supportedReasoningLevels:[{effort:"low",description:"Low"},{effort:"medium",description:"Medium"},{effort:"high",description:"High"},{effort:"xhigh",description:"Extra high"},{effort:"max",description:"Maximum"}]}},{id:"MiniMax-M4",contextWindow:1e6,maxTokens:131072,input:["text","image"],codex:{defaultReasoningLevel:"max",supportedReasoningLevels:[{effort:"low",description:"Low"},{effort:"medium",description:"Medium"},{effort:"high",description:"High"},{effort:"xhigh",description:"Extra high"},{effort:"max",description:"Maximum"}]}},{id:"MiniMax-M3",contextWindow:1e6,maxTokens:128000,input:["text","image"],codex:{defaultReasoningLevel:"high",supportedReasoningLevels:[{effort:"none",description:"Think-Off"},{effort:"high",description:"Deep"}]}}],qa=ce[0].id});import{chmodSync as Ua,closeSync as im,existsSync as Ft,lstatSync as PE,mkdirSync as FE,openSync as DE,readFileSync as qE,realpathSync as UE,renameSync as jE,rmSync as on,statSync as GE,writeFileSync as Ba}from"fs";import{homedir as lm,tmpdir as BE}from"os";import{basename as Va,dirname as Ha,isAbsolute as cm,join as V,resolve as Yr}from"path";function Ka(e){let t=ce.find((n)=>n.id===e);if(!t)throw new y(`Unsupported MiniMax model: ${e}`,b.USAGE);return t}function ja(e){return e==="MiniMax-M4"||e==="MiniMax-M3.1-Flash"||e==="MiniMax-M3"?`${e}[1m]`:e}function rm(e){return e==="MiniMax-M3"?"minimax":e.toLowerCase().replaceAll(".","-")}function Ce(e){let t=e==="cn"?"https://api.minimax.cn":"https://api.minimax.io";return{anthropic:`${t}/anthropic`,openai:`${t}/v1`}}function mt(e,t,n){if(!e?.trim())return t;return cm(e)?e:Yr(n,e)}function KE(e,t){let n=(t.OMP_PROFILE??t.PI_PROFILE)?.trim(),i=V(e,t.PI_CONFIG_DIR||".omp"),r=(o)=>/^[a-z0-9][a-z0-9._-]{0,63}$/.test(o)&&!o.endsWith(".")&&!/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])(?:\..*)?$/i.test(o),s;if(n&&n!=="default"){if(!r(n))throw new y("Invalid Oh my Pi profile name.",b.USAGE);s=V(i,"profiles",n,"agent")}else{let o=t.PI_PROFILE?.trim(),a=o&&o!=="default"&&r(o)?V(i,"profiles",o,"agent"):void 0,l=t.PI_CODING_AGENT_DIR===a?void 0:t.PI_CODING_AGENT_DIR;s=l?Yr(l):V(i,"agent")}return["models","config"].map((o)=>{let a=V(s,`${o}.yml`),l=V(s,`${o}.yaml`);if(Ft(a))return a;if(Ft(l))return l;let c=V(s,o==="models"?"models.json":"settings.json");if(Ft(c))throw new y("Oh my Pi has legacy JSON configuration that needs migration.",b.GENERAL,"Run omp once with the same profile/environment to migrate it to YAML, then retry. No files were changed.");return a})}function WE(e,t){let n=t.homeDir??lm(),i=t.env??process.env;switch(e){case"claude-code":{let r=mt(i.CLAUDE_CONFIG_DIR,V(n,".claude"),n);return[V(r,"settings.json")]}case"codex":{let r=mt(i.CODEX_HOME,V(n,".codex"),n);return[V(r,"config.toml"),V(r,Wr)]}case"grok":return[V(mt(i.GROK_HOME,V(n,".grok"),n),"config.toml")];case"opencode":{if(i.OPENCODE_CONFIG?.trim()){let l=i.OPENCODE_CONFIG.trim();return[cm(l)?l:Yr(l)]}let r=mt(i.XDG_CONFIG_HOME,V(n,".config"),n),s=V(r,"opencode"),o=V(s,"opencode.json"),a=V(s,"opencode.jsonc");return[Ft(a)?a:o]}case"hermes":{let r=mt(i.HERMES_HOME,V(n,".hermes"),n);return[V(r,"config.yaml"),V(r,".env")]}case"pi":{let r=mt(i.PI_CODING_AGENT_DIR,V(n,".pi","agent"),n);return[V(r,"models.json"),V(r,"settings.json")]}case"oh-my-pi":return KE(n,i);case"deepseek-harness":return[...hm(t),V(Wa(t),".credentials.yaml")];case"zed":{if(process.platform==="win32")return[V(i.APPDATA||V(n,"AppData","Roaming"),"Zed","settings.json")];let r=process.platform==="darwin"?V(n,".config"):i.FLATPAK_XDG_CONFIG_HOME||mt(i.XDG_CONFIG_HOME,V(n,".config"),n);return[V(r,"zed","settings.json")]}}}function sn(e){return Ft(e)?qE(e,"utf8"):null}function be(e){let t=Jr(e);return{targetPath:t,before:sn(t)}}function fm(e,t){W(e,`${t} must contain a JSON object at its root.`)}function W(e,t){if(typeof e!=="object"||e===null||Array.isArray(e))throw new y(t,b.GENERAL,le)}function an(e,t){let n=[],i=Bf(e,n,{allowTrailingComma:!0,disallowComments:!1});if(n.length>0)throw new y(`${t} is not valid JSON/JSONC.`,b.GENERAL,le);return fm(i,t),i}function si(e,t,n){let i=e??`{}
|
|
652
|
+
`;an(i,t);for(let r of n)i=Hf(i,Vf(i,r.path,r.value,{formattingOptions:VE}));return i.endsWith(`
|
|
653
653
|
`)?i:`${i}
|
|
654
|
-
`}function
|
|
654
|
+
`}function YE(e,t){let n=e.match(/.*(?:\r?\n|$)/g)?.filter(Boolean)??[],i=0,r;for(let s of n){let o=s.match(/^\s*\[([^\][\r\n]+)]\s*(?:#.*)?(?:\r?\n)?$/),a=s.match(/^\s*\[\[([^\][\r\n]+)]]\s*(?:#.*)?(?:\r?\n)?$/);if(o||a){if(r)return r.end=i,r;if(o?.[1]?.trim()===t)r={bodyStart:i+s.length,end:e.length}}i+=s.length}return r}function dm(e){let t;for(let n=0;n<e.length;n+=1){let i=e[n];if(t==='"'&&i==="\\"){n+=1;continue}if(t){if(i===t)t=void 0;continue}if(i==='"'||i==="'"){t=i;continue}if(i==="#"){let r=n;while(r>0&&/[ \t]/.test(e[r-1]))r-=1;return e.slice(r)}}return""}function Ga(e,t){let n=e;for(let[i,r]of Object.entries(t)){if(!HE.test(i))throw new y(`Invalid TOML key: ${i}`,b.GENERAL);let s=typeof r==="string"?JSON.stringify(r):String(r),o=`${i} = ${s}`,a=new RegExp(`^(\\s*)${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*=.*$`,"m");if(a.test(n))n=n.replace(a,(l,c)=>`${c}${o}${dm(l)}`);else{if(n.length>0&&!n.endsWith(`
|
|
655
655
|
`))n+=`
|
|
656
656
|
`;n+=`${o}
|
|
657
|
-
`}}return n}function
|
|
657
|
+
`}}return n}function JE(e,t,n){let i=YE(e,t);if(i){let s=e.slice(i.bodyStart,i.end);return e.slice(0,i.bodyStart)+Ga(s,n)+e.slice(i.end)}let r=e;if(r.length>0&&!r.endsWith(`
|
|
658
658
|
`))r+=`
|
|
659
659
|
`;if(r.length>0&&!r.endsWith(`
|
|
660
660
|
|
|
661
661
|
`))r+=`
|
|
662
662
|
`;return r+=`[${t}]
|
|
663
|
-
${
|
|
663
|
+
${Ga("",n)}`,r}function pm(e,t){let n=e.search(/^\s*\[/m),i=n===-1?e.length:n;return Ga(e.slice(0,i),t)+e.slice(i)}function zE(e,t){let n=e.search(/^\s*\[/m),i=n===-1?e.length:n,r=new RegExp(`^([ \\t]*)(?:${t.join("|")})[ \\t]*=.*(?:\\r?\\n|$)`,"gm");return e.slice(0,i).replace(r,(o,a)=>{let l=o.endsWith(`\r
|
|
664
664
|
`)?`\r
|
|
665
665
|
`:o.endsWith(`
|
|
666
666
|
`)?`
|
|
667
|
-
`:"",c=
|
|
667
|
+
`:"",c=dm(o.replace(/\r?\n$/,"")).trimStart();return c?`${a}${c}${l}`:""})+e.slice(i)}function mm(e,t,n,i){let r=e??"";if(r.charCodeAt(0)===65279)r=r.slice(1);try{kt(r)}catch{throw new y(`${t} is not valid TOML.`,b.GENERAL,le)}if(r.includes('"""')||r.includes("'''"))throw new y(`${t} contains a multiline string that mmx cannot safely preserve.`,b.GENERAL,"Update this configuration manually. No files were changed.");r=pm(r,n);for(let s of i)r=JE(r,s.name,s.entries);if(!r.endsWith(`
|
|
668
668
|
`))r+=`
|
|
669
|
-
`;try{
|
|
670
|
-
`);if(r.errors.length>0)throw new y(`Hermes config.yaml is not valid YAML: ${r.errors[0]?.message??"parse error"}`,b.GENERAL,
|
|
669
|
+
`;try{kt(r)}catch{throw new y(`Could not safely merge ${t}.`,b.GENERAL,"No files were changed. Convert inline TOML tables to standard table sections and retry.")}return r}function XE(e,t,n,i){let r=ri(e??`{}
|
|
670
|
+
`);if(r.errors.length>0)throw new y(`Hermes config.yaml is not valid YAML: ${r.errors[0]?.message??"parse error"}`,b.GENERAL,le);let s=r.toJS();if(fm(s,"Hermes config.yaml"),typeof s.model==="string")r.deleteIn(["model"]);else if(s.model!==void 0)W(s.model,"Hermes config.yaml model section must be an object.");if(s.providers!==void 0)W(s.providers,"Hermes config.yaml providers section must be an object.");if(s.model_overrides!==void 0)W(s.model_overrides,"Hermes config.yaml model_overrides section must be an object.");if(s.agent!==void 0)W(s.agent,"Hermes config.yaml agent section must be an object.");let o=s.agent?.reasoning_overrides;if(o!==void 0)W(o,"Hermes config.yaml agent.reasoning_overrides section must be an object.");let a=s.model_overrides?.[t];if(a!==void 0)W(a,`Hermes config.yaml model_overrides.${t} section must be an object.`);let l=a;for(let f of ce){if(l?.[f.id]!==void 0)W(l[f.id],`Hermes model override for ${f.id} must be an object.`);let u=1e6;r.setIn(["model_overrides",t,f.id,"context_window"],u),r.setIn(["model_overrides",t,f.id,"supports_vision"],f.input.some((d)=>d==="image"))}let c=Ka(n);if(r.setIn(["model","default"],n),r.setIn(["model","provider"],t),r.setIn(["model","base_url"],i),r.setIn(["model","context_length"],n==="MiniMax-M3.1-Flash"||n==="MiniMax-M3"?1e6:c.contextWindow),o?.["MiniMax-M3"]===void 0)r.setIn(["agent","reasoning_overrides","MiniMax-M3"],"none");return r.toString()}function QE(e){return/^[A-Za-z0-9_./:-]+$/.test(e)?e:JSON.stringify(e)}function ZE(e,t,n){let i=e??"",r=`${t}=${QE(n)}`,s=new RegExp(`^(?:export\\s+)?${t}=.*$`,"gm"),o=!1,a=i.replace(s,()=>{if(o)return"";return o=!0,r});if(!o){if(a.length>0&&!a.endsWith(`
|
|
671
671
|
`))a+=`
|
|
672
672
|
`;a+=`${r}
|
|
673
673
|
`}return a.endsWith(`
|
|
674
674
|
`)?a:`${a}
|
|
675
|
-
`}function
|
|
676
|
-
`}function
|
|
677
|
-
`);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,b.GENERAL,
|
|
678
|
-
|
|
679
|
-
`
|
|
675
|
+
`}function eA(e,t){let n=be(t),r=an(n.before??"{}","Claude Code settings.json").modelPicker;if(r!==void 0)W(r,"Claude Code settings.json modelPicker section must be an object.");let s=r?.options;if(s!==void 0&&!Array.isArray(s))throw new y("Claude Code settings.json modelPicker.options must be an array.",b.GENERAL,le);let o=r?.replaceBuiltInOptions;if(o!==void 0&&typeof o!=="boolean")throw new y("Claude Code settings.json modelPicker.replaceBuiltInOptions must be a boolean.",b.GENERAL,le);let a=Ce(e.region),l=ja(e.model),c=ce.map((g)=>({model:ja(g.id),label:g.id,description:g.id===e.model?`1M supported · ${g.id==="MiniMax-M3.1-Flash"&&(e.m31ContextWindow??524288)!==1e6?"512K":"1M"} compact`:"1M supported"})),f=new Set(ce.flatMap((g)=>[g.id,ja(g.id)])),u=[];if(s===void 0)u.push({path:["modelPicker","options"],value:c});else{let g=s.flatMap((p,m)=>{if(typeof p!=="object"||p===null||Array.isArray(p))return[];let v=p.model;return typeof v==="string"&&f.has(v)?[m]:[]});for(let p of g.reverse())u.push({path:["modelPicker","options",p],value:void 0});let h=s.length-g.length;c.forEach((p,m)=>{u.push({path:["modelPicker","options",h+m],value:p})})}let d={ANTHROPIC_BASE_URL:a.anthropic,ANTHROPIC_AUTH_TOKEN:e.apiKey,API_TIMEOUT_MS:"3000000",CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1",CLAUDE_CODE_AUTO_COMPACT_WINDOW:String(e.model==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:Ka(e.model).contextWindow),ANTHROPIC_MODEL:l,ANTHROPIC_DEFAULT_SONNET_MODEL:l,ANTHROPIC_DEFAULT_OPUS_MODEL:l,ANTHROPIC_DEFAULT_HAIKU_MODEL:l};return[{agent:"claude-code",path:t,...n,after:si(n.before,"Claude Code settings.json",[...Object.entries(d).map(([g,h])=>({path:["env",g],value:h})),...u,{path:["modelPicker","replaceBuiltInOptions"],value:o??!0}])}]}function tA(e){return`${JSON.stringify({_managed_by:um,models:ce.map((t,n)=>{let i=t.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:t.contextWindow;return{slug:t.id,display_name:t.id,description:t.id==="MiniMax-M3.1-Flash"?"MiniMax M3.1 Flash":"MiniMax",default_reasoning_level:t.codex.defaultReasoningLevel,supported_reasoning_levels:t.codex.supportedReasoningLevels,shell_type:"shell_command",visibility:"list",supported_in_api:!0,priority:n,base_instructions:`You are Codex, a coding agent based on ${t.id}. You and the user share the same workspace and collaborate to achieve the user's goals.`,supports_reasoning_summaries:!0,default_reasoning_summary:"none",support_verbosity:!1,truncation_policy:{mode:"tokens",limit:1e4},supports_parallel_tool_calls:!0,experimental_supported_tools:[],prefer_websockets:!1,apply_patch_tool_type:"freeform",web_search_tool_type:"text",supports_image_detail_original:!1,tool_mode:"code_mode_only",multi_agent_version:"v2",use_responses_lite:!1,effective_context_window_percent:i===1e6?85:95,auto_compact_token_limit:null,reasoning_summary_format:"experimental",supports_search_tool:!0,context_window:i,max_context_window:i,input_modalities:[...t.input]}})},null,2)}
|
|
676
|
+
`}function nA(e,t){let[n,i]=t;if(!n||!i)throw new y("Codex paths are incomplete.",b.GENERAL);let r=be(n),s=Ce(e.region),o=Ka(e.model),a=mm(r.before,"Codex config.toml",{model:e.model,model_reasoning_effort:o.codex.defaultReasoningLevel,model_provider:"minimax"},[{name:"model_providers.minimax",entries:{name:"MiniMax",base_url:s.openai,experimental_bearer_token:e.apiKey,wire_api:"responses"}}]),l=kt(a).model_catalog_json;if(l!==void 0&&l!==Wr)throw new y("Codex config.toml already uses a user-managed model catalog.",b.GENERAL,"Remove model_catalog_json to let mmx manage a MiniMax-only catalog, or configure Codex manually. No files were changed.");let c=be(i);if(c.before!==null){if(an(c.before,"Codex mmx-model-catalog.json")._managed_by!==um)throw new y(`Codex ${Wr} is not managed by mmx.`,b.GENERAL,"Rename or remove that file, then retry. No files were changed.")}return a=zE(a,["model_context_window","model_auto_compact_token_limit"]),a=pm(a,{model_catalog_json:Wr}),[{agent:"codex",path:n,...r,after:a},{agent:"codex",path:i,...c,after:tA(e)}]}function iA(e,t){let n=be(t),i=Ce(e.region),r=ce.map((s)=>({name:`model.${rm(s.id)}`,entries:{model:s.id,base_url:i.openai,name:s.id,api_key:e.apiKey,api_backend:"chat_completions",context_window:s.contextWindow,max_completion_tokens:s.maxTokens}}));return[{agent:"grok",path:t,...n,after:mm(n.before,"Grok config.toml",{},[{name:"models",entries:{default:rm(e.model)}},...r])}]}function rA(e,t){let n=be(t),r=an(n.before??"{}","OpenCode opencode.json").provider;if(r!==void 0)W(r,"OpenCode opencode.json provider section must be an object.");let s=r?.minimax;if(s!==void 0)W(s,"OpenCode opencode.json provider.minimax section must be an object.");for(let f of["options","models"]){let u=s?.[f];if(u!==void 0)W(u,`OpenCode opencode.json provider.minimax.${f} section must be an object.`)}let o=s?.models;for(let f of ce){let u=o?.[f.id];if(u!==void 0)W(u,`OpenCode model definition for ${f.id} must be an object.`);let d=u?.limit;if(d!==void 0)W(d,`OpenCode model definition for ${f.id} limit must be an object.`);let g=u?.modalities;if(g!==void 0)W(g,`OpenCode model definition for ${f.id} modalities must be an object.`);if(f.id!=="MiniMax-M3"){let h=u?.variants;if(h!==void 0)W(h,`OpenCode model definition for ${f.id} variants must be an object.`)}}let a=Ce(e.region),l=ce.flatMap((f)=>{let u=[...f.input];return[{path:["provider","minimax","models",f.id,"name"],value:f.id},{path:["provider","minimax","models",f.id,"reasoning"],value:!0},{path:["provider","minimax","models",f.id,"temperature"],value:!1},{path:["provider","minimax","models",f.id,"attachment"],value:u.includes("image")},{path:["provider","minimax","models",f.id,"modalities","input"],value:u},{path:["provider","minimax","models",f.id,"modalities","output"],value:["text"]},{path:["provider","minimax","models",f.id,"limit","context"],value:f.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:f.contextWindow},{path:["provider","minimax","models",f.id,"limit","output"],value:f.maxTokens}]}),c=["MiniMax-M4","MiniMax-M3.1-Flash"].flatMap((f)=>{let u=["provider","minimax","models",f];return[{path:[...u,"interleaved"],value:{field:"reasoning_content"}},{path:[...u,"variants","none","disabled"],value:!0},{path:[...u,"variants","thinking","disabled"],value:!0},{path:[...u,"variants","default","reasoningEffort"],value:"max"},...["low","medium","high","xhigh","max"].map((d)=>({path:[...u,"variants",d,"reasoningEffort"],value:d}))]});return[{agent:"opencode",path:t,...n,after:si(n.before,"OpenCode opencode.json",[{path:["provider","minimax","npm"],value:"@ai-sdk/openai-compatible"},{path:["provider","minimax","name"],value:"MiniMax"},{path:["provider","minimax","options","baseURL"],value:a.openai},{path:["provider","minimax","options","apiKey"],value:e.apiKey},{path:["provider","minimax","options","setCacheKey"],value:void 0},...l,...c,{path:["model"],value:`minimax/${e.model}`}])}]}function sA(e,t){let[n,i]=t;if(!n||!i)throw new y("Hermes paths are incomplete.",b.GENERAL);let r=be(n),s=be(i),o=Ce(e.region),a=e.region==="cn"?"minimax-cn":"minimax",l=e.region==="cn"?"MINIMAX_CN_API_KEY":"MINIMAX_API_KEY";return[{agent:"hermes",path:n,...r,after:XE(r.before,a,e.model,o.anthropic)},{agent:"hermes",path:i,...s,after:ZE(s.before,l,e.apiKey)}]}function oA(e,t){let[n,i]=t;if(!n||!i)throw new y("Pi paths are incomplete.",b.GENERAL);let r=be(n),s=be(i),o=an(r.before??"{}","Pi models.json"),a=Ce(e.region),l=e.region==="cn"?"minimax-cn":"minimax",c=o.providers;if(c!==void 0)W(c,"Pi models.json providers section must be an object.");let f=c?.[l];if(f!==void 0)W(f,`Pi models.json providers.${l} section must be an object.`);let u=f?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`Pi models.json providers.${l}.models must be an array.`,b.GENERAL,le);let d=[{path:["providers",l,"name"],value:"MiniMax"},{path:["providers",l,"baseUrl"],value:a.anthropic},{path:["providers",l,"apiKey"],value:e.apiKey},{path:["providers",l,"api"],value:"anthropic-messages"}],g=ce.map((h)=>({id:h.id,name:h.id,reasoning:!0,...h.id==="MiniMax-M3"?{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1}}:{compat:{forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{off:null,minimal:null,xhigh:"xhigh",max:"max"}},input:[...h.input],contextWindow:h.contextWindow,maxTokens:h.maxTokens}));if(u===void 0)d.push({path:["providers",l,"models"],value:g});else{let h=u.length;for(let p of g){let m=u.findIndex((w)=>typeof w==="object"&&w!==null&&!Array.isArray(w)&&w.id===p.id),v=["providers",l,"models",m>=0?m:h++];if(m<0){d.push({path:v,value:p});continue}W(u[m],`Pi model definition for ${p.id} must be an object.`);for(let[w,x]of Object.entries(p)){if(w==="id")continue;if(w==="compat"||w==="thinkingLevelMap"){let E=u[m][w];if(E!==void 0)W(E,`Pi ${w} for ${p.id} must be an object.`);for(let[A,_]of Object.entries(x))d.push({path:[...v,w,A],value:_});continue}d.push({path:[...v,w],value:x})}}}return[{agent:"pi",path:n,...r,after:si(r.before,"Pi models.json",d)},{agent:"pi",path:i,...s,after:si(s.before,"Pi settings.json",[{path:["defaultProvider"],value:l},{path:["defaultModel"],value:e.model},...e.model==="MiniMax-M4"?[{path:["defaultThinkingLevel"],value:"max"}]:[]])}]}function aA(e,t){let n=e.region==="cn"?"minimax-cn":"minimax",i=Ce(e.region).anthropic;return t.map((r,s)=>{let o=be(r),a=`Oh my Pi ${Va(r)}`,l=ri(o.before??`{}
|
|
677
|
+
`);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,b.GENERAL,le);if(l.contents===null)l.set(s===0?"providers":"modelRoles",l.createNode({}));let c=l.toJS();if(W(c,`${a} must contain an object at its root.`),s===0){if(c.providers!==void 0)W(c.providers,`${a} providers must be an object.`);let f=c.providers?.[n];if(f!==void 0)W(f,`${a} provider must be an object.`);let u=f?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`${a} models must be an array.`,b.GENERAL,le);let d=u??[];for(let p of d)W(p,`${a} model entries must be objects.`);let g=["providers",n];for(let[p,m]of Object.entries({baseUrl:i,apiKey:e.apiKey,api:"anthropic-messages",auth:"apiKey"}))l.setIn([...g,p],m);if(u===void 0)l.setIn([...g,"models"],l.createNode([]));let h=d.length;for(let p of ce){let m=d.findIndex((x)=>x.id===p.id),v=[...g,"models",m>=0?m:h++],w={id:p.id,name:p.id,api:"anthropic-messages",baseUrl:i,reasoning:!0,input:[...p.input],contextWindow:p.contextWindow,maxTokens:p.maxTokens,...p.id!=="MiniMax-M3"?{thinking:{mode:"anthropic-adaptive",efforts:["low","medium","high","xhigh","max"],defaultLevel:"max",requiresEffort:!0,effortMap:{low:"low",medium:"medium",high:"high"}}}:{}};if(m<0)l.setIn(v,l.createNode(w));else for(let[x,E]of Object.entries(w))l.setIn([...v,x],l.createNode(E))}}else{if(c.modelRoles!==void 0)W(c.modelRoles,`${a} modelRoles must be an object.`);let f=e.model!=="MiniMax-M3"?":max":"";l.setIn(["modelRoles","default"],`${n}/${e.model}${f}`)}return{agent:"oh-my-pi",path:r,...o,after:l.toString()}})}function lA(e,t){let n=be(t),i="Zed settings.json",r=an(n.before??"{}","Zed settings.json"),s=r.language_models;if(s!==void 0)W(s,"Zed settings.json language_models must be an object.");let o=s?.openai_compatible;if(o!==void 0)W(o,"Zed settings.json language_models.openai_compatible must be an object.");let a=o?.minimax;if(a!==void 0)W(a,"Zed settings.json language_models.openai_compatible.minimax must be an object.");let l=a?.available_models;if(l!==void 0&&!Array.isArray(l))throw new y("Zed settings.json minimax available_models must be an array.",b.GENERAL,le);let c=r.agent;if(c!==void 0)W(c,"Zed settings.json agent must be an object.");let f=c?.default_model;if(f!==void 0)W(f,"Zed settings.json agent.default_model must be an object.");let u=(p)=>p!=="MiniMax-M3"?"max":"high",d=["language_models","openai_compatible","minimax"],g=ce.map((p)=>({name:p.id,display_name:p.id,max_tokens:p.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:p.contextWindow,max_output_tokens:p.maxTokens,reasoning_effort:u(p.id),capabilities:{tools:!0,images:p.input.some((m)=>m==="image"),parallel_tool_calls:!0,prompt_cache_key:!1,chat_completions:!0,interleaved_reasoning:!0,max_tokens_parameter:!1}})),h=[{path:[...d,"api_url"],value:Ce(e.region).openai}];if(l===void 0)h.push({path:[...d,"available_models"],value:g});else{let p=l.length;for(let m of g){let v=l.findIndex((w)=>typeof w==="object"&&w!==null&&w.name===m.name);h.push({path:[...d,"available_models",v>=0?v:p++],value:m})}}return h.push({path:["agent","default_model","provider"],value:"minimax"},{path:["agent","default_model","model"],value:e.model},{path:["agent","default_model","enable_thinking"],value:!0},{path:["agent","default_model","effort"],value:u(e.model)}),[{agent:"zed",path:t,...n,after:si(n.before,"Zed settings.json",h)}]}function Wa(e){let t=e.homeDir??lm(),n=e.env??process.env;return mt(n.DSH_HOME,V(t,".dsh"),t)}function hm(e){let t=V(Wa(e),"profiles"),n=[],i=new Set;for(let r of[...uA,...sm]){let s=V(t,r,"cordis.patch.yml");if(sm.includes(r)&&!Ft(s))continue;let o=Jr(s);if(i.has(o))continue;i.add(o),n.push(s)}return n}function gm(e,t,n){let i=ri(e??n);if(i.errors.length>0)throw new y(`${t} is not valid YAML: ${i.errors[0]?.message??"parse error"}`,b.GENERAL,le);return i}function ym(e,t){if(!ii(e.contents))return[];let n=[];return e.contents.items.forEach((i,r)=>{if(pt(i)&&i.get("id")===t)n.push(r)}),n}function om(e,t,n){if(e.contents===null)e.contents=e.createNode([]);if(!ii(e.contents))throw new y(`${n} must be a YAML sequence.`,b.GENERAL,le);if(e.contents.items.length===0)e.contents.flow=!1;let i=ym(e,t);if(i.length>1)throw new y(`${n} has duplicate ${t} overrides.`,b.GENERAL,le);if(i.length===1)return i[0];return e.add(e.createNode({id:t,config:{}})),e.contents.items.length-1}function dA(){return["MiniMax-M4","MiniMax-M3.1-Flash"].map((e)=>({id:e,name:e,contextWindow:1e6,maxTokens:131072,input:["text","image"],reasoningEfforts:{...fA}}))}function pA(e,t,n,i){let r=e.getIn(t);if(r===void 0){e.setIn(t,e.createNode(n));return}if(!ii(r))throw new y(`${i} models must be an array.`,b.GENERAL,le);for(let s of n){let o=r.items.findIndex((a)=>pt(a)&&a.get("id")===s.id);if(o<0){r.add(e.createNode(s));continue}for(let[a,l]of Object.entries(s))e.setIn([...t,o,a],e.createNode(l))}}function mA(e,t,n){let r=gm(e,"DeepSeek Harness cordis.patch.yml",cA),s=t.region==="cn"?"minimax-cn":"minimax",o=t.region==="cn"?"MINIMAX_CN_API_KEY":"MINIMAX_API_KEY",a=om(r,"llm-pi-ai","DeepSeek Harness cordis.patch.yml"),l=r.getIn([a,"config","providers"]);if(l!==void 0&&!pt(l))throw new y("DeepSeek Harness cordis.patch.yml providers must be a mapping.",b.GENERAL,le);let c=[a,"config","providers",s],f=r.getIn(c);if(f!==void 0&&!pt(f))throw new y(`DeepSeek Harness cordis.patch.yml providers.${s} must be a mapping.`,b.GENERAL,le);r.setIn([...c,"displayName"],t.region==="cn"?"MiniMax":"MiniMax en"),r.setIn([...c,"apiKeyEnv"],o),r.setIn([...c,"api"],"openai-completions"),r.setIn([...c,"baseURL"],Ce(t.region).openai),pA(r,[...c,"models"],dA(),"DeepSeek Harness cordis.patch.yml");let u=om(r,"agent-default-model","DeepSeek Harness cordis.patch.yml");if(r.setIn([u,"config","provider"],s),r.setIn([u,"config","model"],t.model),Va(Ha(n))==="headless"&&ym(r,"credentials").length===0)r.add(r.createNode({id:"credentials",disabled:!1}));return r.toString()}function hA(e,t){let i=gm(e,"DeepSeek Harness .credentials.yaml",`version: 1
|
|
678
|
+
refs: {}
|
|
679
|
+
`);if(i.contents===null)i.contents=i.createNode({version:1,refs:{}});if(!pt(i.contents)||i.get("version")!==1)throw new y("DeepSeek Harness .credentials.yaml is not a version 1 credential document.",b.GENERAL,le);let r=i.get("refs");if(r!==void 0&&r!==null&&!pt(r))throw new y("DeepSeek Harness .credentials.yaml refs must be a mapping.",b.GENERAL,le);let s=t.region==="cn"?"MINIMAX_CN_API_KEY":"MINIMAX_API_KEY";return i.setIn(["refs",s],t.apiKey),i.toString()}function gA(e){let t=hm(e).map((r)=>{let s=be(r);return{agent:"deepseek-harness",path:r,...s,after:mA(s.before,e,r)}}),n=V(Wa(e),".credentials.yaml"),i=be(n);return t.push({agent:"deepseek-harness",path:n,...i,after:hA(i.before,e)}),t}function Ya(e){let t=[];for(let n of e.agents){let i=WE(n,e);switch(n){case"claude-code":t.push(...eA(e,i[0]));break;case"codex":t.push(...nA(e,i));break;case"grok":t.push(...iA(e,i[0]));break;case"opencode":t.push(...rA(e,i[0]));break;case"hermes":t.push(...sA(e,i));break;case"pi":t.push(...oA(e,i));break;case"oh-my-pi":t.push(...aA(e,i));break;case"zed":t.push(...lA(e,i[0]));break;case"deepseek-harness":t.push(...gA(e));break}}return bm(t),t}function am(e,t,n){let i=Ha(e);FE(i,{recursive:!0,mode:448});let r=V(i,`.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`),s=()=>{if(Jr(n)!==e)throw new y(`Configuration path changed while mmx was writing it: ${n}`,b.GENERAL)};try{s(),Ba(r,t,{encoding:"utf8",mode:384,flag:"wx"}),s(),jE(r,e)}catch(o){throw on(r,{force:!0}),o}}function yA(e,t,n){for(let i=0;;i+=1){let r=`${e}.bak.${n}${i===0?"":`.${i}`}`;try{return Ba(r,t,{encoding:"utf8",mode:384,flag:"wx"}),r}catch(s){if(s.code==="EEXIST")continue;throw on(r,{force:!0}),s}}}function bA(){return new Date().toISOString().replace(/[-:]/g,"").replace("T","-").replace(/\.\d{3}Z$/,"Z")}function Jr(e){let t=e,n=[];while(!0)try{return V(UE(t),...n)}catch(i){if(i.code!=="ENOENT")throw i;try{if(PE(t).isSymbolicLink())throw new y(`Configuration path contains a dangling symbolic link: ${e}`,b.GENERAL,"Fix the symbolic link and retry. No files were changed.")}catch(s){if(s instanceof y)throw s;if(s.code!=="ENOENT")throw s}let r=Ha(t);if(r===t)return Yr(e);n.unshift(Va(t)),t=r}}function wA(e){return process.platform!=="win32"&&(e&63)!==0}function bm(e){let t=new Set;for(let n of e){if(t.has(n.targetPath))throw new y(`Multiple agent configuration paths resolve to ${n.targetPath}.`,b.GENERAL,"No files were changed. Use distinct configuration paths and retry.");t.add(n.targetPath)}}function xA(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function wm(){let e=typeof process.getuid==="function"?String(process.getuid()):(process.env.USERNAME??process.env.USER??"user").replace(/[^A-Za-z0-9_-]/g,"_"),t=V(BE(),`mmx-agent-setup-${e}.lock`),n=`${process.pid}:${Date.now()}:${Math.random().toString(16).slice(2)}`;try{let i=DE(t,"wx",384);try{Ba(i,`${n}
|
|
680
|
+
`,"utf8")}catch(s){if(im(i),sn(t)?.trim()===n)on(t,{force:!0});throw s}let r=!1;return()=>{if(r)return;if(r=!0,im(i),sn(t)?.trim()===n)on(t,{force:!0})}}catch(i){if(i.code!=="EEXIST")throw i;let s=(sn(t)?.trim()??"").match(/^(\d+):/),o=s?.[1]?Number(s[1]):void 0,a=o!==void 0&&!xA(o);throw new y(a?"A stale mmx agent setup lock exists.":"Another mmx agent setup is already running.",b.GENERAL,a?`Confirm no setup process is running, remove ${t}, then retry. No files were changed.`:"Wait for it to finish, then retry. No files were changed.")}}async function xm(e){let t=wm(),n=new Map,i=()=>{for(let[r,s]of n)process.removeListener(r,s)};for(let[r,s]of[["SIGHUP",129],["SIGINT",130],["SIGTERM",143]]){let o=()=>{i(),t(),process.exit(s)};n.set(r,o),process.once(r,o)}process.once("exit",t);try{return await e()}finally{process.off("exit",t),i(),t()}}function vm(e,t=!1,n=!1){let i=t||n?void 0:wm();try{let r=e.filter((u)=>u.before!==u.after);bm(e);let s=new Map,o=new Map;for(let u of e)if(u.before!==null&&Ft(u.targetPath)){let d=GE(u.targetPath).mode&511;if(s.set(u,d),u.before===u.after&&wA(d))o.set(u,d)}if(t)return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"would-configure"}));let a=(u,d)=>{if(Jr(u.path)!==u.targetPath||sn(u.targetPath)!==u.before)throw new y(`Configuration changed while mmx was preparing it: ${u.path}`,b.GENERAL,d)};for(let u of e)if(u.before!==u.after||o.has(u))a(u,"No files were changed. Retry the command.");let l=bA(),c=new Map,f=[];try{for(let u of r)if(u.before!==null)a(u,"No files were changed. Retry the command."),c.set(u.path,yA(u.targetPath,u.before,l));for(let u of e){if(!o.has(u))continue;a(u,"The completed writes were rolled back. Retry the command."),Ua(u.targetPath,384)}for(let u of r)a(u,"The completed writes were rolled back. Retry the command."),am(u.targetPath,u.after,u.path),f.push({file:u,target:u.targetPath})}catch(u){let d=[],g;for(let{file:h,target:p}of f.reverse())try{if(sn(p)!==h.after){d.push(h.path);continue}if(h.before===null)on(p,{force:!0});else{am(p,h.before,h.path);let m=s.get(h);if(m!==void 0)Ua(p,m)}}catch(m){g??=m}for(let[h,p]of o)try{Ua(h.targetPath,p)}catch(m){g??=m}if(d.length===0&&g===void 0)for(let h of c.values())try{on(h,{force:!0})}catch(p){g??=p}if(d.length>0||g!==void 0)throw new y("Could not fully roll back agent configuration.",b.GENERAL,`Review the affected files${c.size>0?` and backups: ${[...c.values()].join(", ")}`:"."}`);throw u}return e.map((u)=>({agent:u.agent,path:u.path,status:u.before===u.after&&!o.has(u)?"unchanged":"configured",...c.has(u.path)?{backup:c.get(u.path)}:{}}))}finally{i?.()}}var VE,HE,Wr="mmx-model-catalog.json",um="mmx agent setup",le="Fix the existing configuration file and retry. No files were changed.",cA=`# Your patch layer for this dsh profile, applied after every bundle layer:
|
|
681
|
+
# a top-level YAML array of loader patch entries (id-targeted config
|
|
682
|
+
# overrides, disables, and insert lists; \`!!js\` expressions allowed).
|
|
683
|
+
[]
|
|
684
|
+
`,uA,sm,fA;var Ja=T(()=>{Kf();xo();nm();G();j();Kr();VE={insertSpaces:!0,tabSize:2,eol:`
|
|
685
|
+
`},HE=/^[A-Za-z0-9_-]+$/;uA=["web","desktop"],sm=["headless","acp"],fA={low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"}});import{accessSync as vA,constants as Sm,statSync as SA}from"fs";import{delimiter as $A,join as _A}from"path";function kA(e=process.env){let t=process.platform==="win32"?e.PATH??e.Path:e.PATH;if(t===void 0)return new Set;let n=t.split($A).map((s)=>s.replace(/^"|"$/g,"")),i=process.platform==="win32"?(e.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""],r=process.platform==="win32"?Sm.F_OK:Sm.X_OK;return new Set(Pt.filter((s)=>EA[s].some((o)=>n.some((a)=>i.some((l)=>{let c=_A(a,`${o}${l}`);try{if(!SA(c).isFile())return!1;return vA(c,r),!0}catch{return!1}})))))}function $m(e=process.env){let t=kA(e);if(e.CODEX_THREAD_ID?.trim())t.add("codex");for(let n of Pt){let i=AA[n];if(i!==void 0&&e[i[0]]===i[1])t.add(n)}return t}var EA,AA;var _m=T(()=>{Kr();EA={"claude-code":["claude"],codex:["codex"],grok:["grok","grok-build","grok-cli"],opencode:["opencode"],hermes:["hermes"],pi:["pi"],"oh-my-pi":["omp"],zed:["zed","zeditor"],"deepseek-harness":["dsh"]},AA={"claude-code":["CLAUDE_CODE_CHILD_SESSION","1"],opencode:["OPENCODE_CLIENT","desktop"],hermes:["HERMES_AGENT","true"],pi:["PI_CODING_AGENT","true"]}});import{spawn as IA,spawnSync as Im}from"child_process";function qA(e,t){return Im(t==="win32"?"where.exe":e,t==="win32"?[e]:["--version"],{stdio:"ignore",timeout:5000}).status===0}function Xa(e,t={}){let n=t.platform??process.platform,i=t.arch??process.arch,r=t.nodeVersion??process.versions.node,s=t.commandExists??((l)=>qA(l,n));if(e==="zed")return"Install Zed from https://zed.dev/download.";if(e==="deepseek-harness")return"Install DeepSeek Harness with npm install -g @deepseek-ai/dsh.";if(!RA.has(n))return`Automated installation is not supported on ${n}.`;if(e!=="pi"&&!LA.has(i))return`Automated installation is not supported on ${n}/${i}.`;if(e==="pi"){let[l=0,c=0]=r.replace(/^v/,"").split(".").map(Number);if(l<22||l===22&&c<19)return`Pi requires Node.js 22.19 or newer (current: ${r}).`}let a=(e==="claude-code"||e==="grok"||e==="oh-my-pi"?n==="win32"?["powershell.exe"]:["bash","curl"]:e==="hermes"?n==="win32"?["powershell.exe"]:["bash","curl","git"]:n==="win32"?["cmd.exe","npm"]:["npm"]).filter((l)=>!s(l));if(a.length>0)return`Required command not found on PATH: ${a.join(", ")}.`;return}function UA(e,t){if(t==="win32"){let r=OA[e];if(e!=="hermes")return{executable:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",za+`$installer = Invoke-RestMethod '${r}'; & ([scriptblock]::Create($installer))${e==="oh-my-pi"?" -Binary":""}`],display:e==="oh-my-pi"?`& ([scriptblock]::Create((irm ${r}))) -Binary`:`irm ${r} | iex`};let s=CA.map((l)=>`'${l}'`).join(", "),o=`& { ${za}& $env:MMX_HERMES_INSTALLER -Stage $env:MMX_HERMES_STAGE -NonInteractive -SkipComputerUse -HermesHome $env:MMX_HERMES_HOME -InstallDir $env:MMX_HERMES_INSTALL_DIR }`,a="$ErrorActionPreference = 'Stop'; "+za+`$hermesHome = if ($env:HERMES_HOME) { $env:HERMES_HOME } else { Join-Path $env:USERPROFILE '.hermes' }; $installDir = Join-Path $hermesHome 'hermes-agent'; $installer = Join-Path ([IO.Path]::GetTempPath()) ('hermes-install-{0}.ps1' -f [guid]::NewGuid()); Invoke-WebRequest -UseBasicParsing -Uri '${r}' -OutFile $installer; try { foreach ($stage in @(${s})) { $env:MMX_HERMES_INSTALLER = $installer; $env:MMX_HERMES_STAGE = $stage; $env:MMX_HERMES_HOME = $hermesHome; $env:MMX_HERMES_INSTALL_DIR = $installDir; & powershell.exe -NoProfile -ExecutionPolicy Bypass -Command '${o}'; $code = $LASTEXITCODE; if ($code -ne 0) { throw "Hermes installer stage $stage failed with exit code $code." } } } finally { Remove-Item -LiteralPath $installer -Force -ErrorAction SilentlyContinue }`;return{executable:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",a],display:a}}let n=MA[e];if(e==="hermes"){let r=NA.join(" "),s=`set -e; installer=$(mktemp); trap 'rm -f "$installer"' EXIT; curl -fsSL ${n} -o "$installer"; for stage in ${r}; do bash "$installer" --stage "$stage" --non-interactive; done`;return{executable:"bash",args:["-c",s],display:s}}let i=`curl -fsSL ${n} | bash${e==="oh-my-pi"?" -s -- --binary":""}`;return{executable:"bash",args:["-c",`set -o pipefail; ${i}`],display:i}}function Qa(e,t=process.platform){if(e==="claude-code"||e==="grok"||e==="hermes"||e==="oh-my-pi")return UA(e,t);if(e==="zed")throw new y("Install Zed from https://zed.dev/download.",b.USAGE);if(e==="deepseek-harness")throw new y("Install DeepSeek Harness with npm install -g @deepseek-ai/dsh.",b.USAGE);let n=["install","-g",...e==="pi"?["--ignore-scripts","--engine-strict"]:[],TA[e]],i=`npm ${n.join(" ")}`;if(t==="win32")return{executable:"cmd.exe",args:["/d","/s","/c",i],display:i};return{executable:"npm",args:n,display:i}}function jA(e,t=process.platform){if(e==="oh-my-pi"){if(t==="win32")return{executable:"powershell.exe",args:["-NoProfile","-Command","$bin = if ($env:PI_INSTALL_DIR) { $env:PI_INSTALL_DIR } else { Join-Path $env:LOCALAPPDATA 'omp' }; & (Join-Path $bin 'omp.exe') --version"],display:"omp --version"};return{executable:"bash",args:["-c",'exec "${PI_INSTALL_DIR:-$HOME/.local/bin}/omp" --version'],display:"omp --version"}}if(e==="claude-code"||e==="grok"||e==="hermes"){let r=`${e==="claude-code"?"claude":e} --version`;if(t==="win32")return{executable:"powershell.exe",args:["-NoProfile","-Command",e==="claude-code"?"& (Join-Path $env:USERPROFILE '.local\\bin\\claude.exe') --version":e==="grok"?"$bin = if ($env:GROK_BIN_DIR) { $env:GROK_BIN_DIR } else { Join-Path $env:USERPROFILE '.grok\\bin' }; & (Join-Path $bin 'grok.exe') --version":"$home = if ($env:HERMES_HOME) { $env:HERMES_HOME } else { Join-Path $env:USERPROFILE '.hermes' }; $exe = Join-Path $home 'bin\\hermes.exe'; $cmd = Join-Path $home 'bin\\hermes.cmd'; if (Test-Path $exe) { & $exe --version } elseif (Test-Path $cmd) { & $cmd --version } else { exit 127 }"],display:r};return{executable:"bash",args:["-c",e==="claude-code"?'command -v claude >/dev/null 2>&1 && exec claude --version; exec "$HOME/.local/bin/claude" --version':e==="grok"?'command -v grok >/dev/null 2>&1 && exec grok --version; exec "${GROK_BIN_DIR:-$HOME/.grok/bin}/grok" --version':'command -v hermes >/dev/null 2>&1 && exec hermes --version; for bin in "$HOME/.local/bin/hermes" /usr/local/bin/hermes "${PREFIX:+$PREFIX/bin/hermes}"; do [ -n "$bin" ] && [ -x "$bin" ] && exec "$bin" --version; done; exit 127'],display:r}}if(e==="zed")return{executable:"zed",args:["--version"],display:"zed --version"};if(e==="deepseek-harness")return{executable:"dsh",args:["--version"],display:"dsh --version"};let n=`${Em[e]} --version`;if(t==="win32")return{executable:"cmd.exe",args:["/d","/s","/c",n],display:n};return{executable:Em[e],args:["--version"],display:n}}function GA(e){let t={...process.env},n=PA.some((i)=>Boolean(t[i]?.trim()));if(e&&!n)t.HTTPS_PROXY=e,t.https_proxy=e,t.HTTP_PROXY=e,t.http_proxy=e;return t}function BA(e){return e.pid!==void 0&&e.exitCode===null&&e.signalCode===null}function Am(e,t=!1){if(e.pid===void 0)return;if(process.platform==="win32"){if(Im("taskkill.exe",["/pid",String(e.pid),"/t","/f"],{stdio:"ignore",windowsHide:!0,timeout:5000}).status===0)return}else try{process.kill(-e.pid,t?"SIGKILL":"SIGTERM");return}catch(n){if(n.code==="ESRCH")return}if(BA(e))try{e.kill(t?"SIGKILL":"SIGTERM")}catch{}}async function km(e,t){return new Promise((n,i)=>{let r=IA(e.executable,e.args,{detached:process.platform!=="win32",env:GA(t.proxy),stdio:["inherit",process.stderr,"inherit"]}),s=!1,o=["SIGHUP","SIGINT","SIGTERM"],a=new Map,l=()=>{for(let[d,g]of a)process.removeListener(d,g)},c=(d)=>{if(l(),Am(r,!0),process.listenerCount(d)===0)process.kill(process.pid,d)};for(let d of o){let g=()=>c(d);a.set(d,g),process.prependOnceListener(d,g)}let f=setTimeout(()=>{if(s)return;Am(r,!0),r.unref(),s=!0,l(),i(new zr(t.timeoutMs))},t.timeoutMs);f.unref();let u=(d)=>{if(s)return;s=!0,clearTimeout(f),l(),d()};r.once("error",(d)=>u(()=>i(d))),r.once("exit",(d)=>u(()=>n(d??1)))})}async function Tm(e,t={}){let n=Xa(e,t);if(n)throw new y(`Cannot install ${e}: ${n}`,b.GENERAL,"Leave it unselected and continue with configuration only.");let i=Qa(e,t.platform),r=jA(e,t.platform),s="Check internet access, DNS, firewall, and proxy settings, then retry.",o=e==="claude-code"||e==="grok"||e==="hermes"||e==="oh-my-pi"?`Run the official installer manually:
|
|
680
686
|
${i.display}`:`Run the installer manually:
|
|
681
687
|
${i.display}
|
|
682
688
|
For npm permission errors, see: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally`,a=`${s}
|
|
683
|
-
${o}`,l=t.runner??((
|
|
684
|
-
${r.display}`);let g=
|
|
689
|
+
${o}`,l=t.runner??((d)=>km(d,{proxy:t.proxy,timeoutMs:t.installTimeoutMs??FA})),c;try{c=await l(i)}catch(d){if(d instanceof zr)throw new y(`Installation for ${e} timed out after ${Math.ceil(d.timeoutMs/1000)} seconds.`,b.TIMEOUT,`The installer was stopped. ${a}`);let g=d instanceof Error?` ${d.message}`:"";throw new y(`Could not start the installer for ${e}.${g}`,b.GENERAL,a)}if(c!==0)throw new y(`Failed to install ${e} (installer exited with code ${c}).`,b.GENERAL,a);let f=t.runner??((d)=>km(d,{proxy:t.proxy,timeoutMs:DA})),u;try{u=await f(r)}catch(d){if(d instanceof zr)throw new y(`Installed ${e}, but ${r.display} timed out after ${Math.ceil(d.timeoutMs/1000)} seconds.`,b.TIMEOUT,`Open a new terminal and verify the installation manually:
|
|
690
|
+
${r.display}`);let g=d instanceof Error?` ${d.message}`:"";throw new y(`Installed ${e}, but could not start ${r.display}.${g}`,b.GENERAL,`Open a new terminal and verify the installation manually:
|
|
685
691
|
${r.display}`)}if(u!==0)throw new y(`Installed ${e}, but ${r.display} exited with code ${u}.`,b.GENERAL,`Open a new terminal and verify the installation manually:
|
|
686
|
-
${r.display}`)}var
|
|
687
|
-
Technical detail: ${o.code}.`:"",g=`Could not reach ${s}.`,h=b.NETWORK,
|
|
688
|
-
${u}`;else if(r)g=`Connection to ${s} was interrupted while reading the verification response.`,
|
|
689
|
-
${u}`;else if(c)g=`Could not connect to ${s}.`,
|
|
692
|
+
${r.display}`)}var TA,Em,MA,OA,NA,CA,RA,LA,PA,za="$proxyUrl = @($env:HTTPS_PROXY, $env:https_proxy, $env:HTTP_PROXY, $env:http_proxy, $env:ALL_PROXY, $env:all_proxy) | Where-Object { $_ -and $_.Trim() } | Select-Object -First 1; if ($proxyUrl) { $webProxy = [System.Net.WebProxy]::new($proxyUrl); $webProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials; [System.Net.WebRequest]::DefaultWebProxy = $webProxy }; ",FA=900000,DA=30000,zr;var Mm=T(()=>{G();j();TA={codex:"@openai/codex",opencode:"opencode-ai",pi:"@earendil-works/pi-coding-agent"},Em={codex:"codex",opencode:"opencode",pi:"pi"},MA={"claude-code":"https://claude.ai/install.sh",grok:"https://x.ai/cli/install.sh",hermes:"https://hermes-agent.nousresearch.com/install.sh","oh-my-pi":"https://omp.sh/install"},OA={"claude-code":"https://claude.ai/install.ps1",grok:"https://x.ai/cli/install.ps1",hermes:"https://hermes-agent.nousresearch.com/install.ps1","oh-my-pi":"https://omp.sh/install.ps1"},NA=["prerequisites","repository","venv","python-deps","node-deps","path","config","complete"],CA=["uv","python","git","node","system-packages","repository","venv","dependencies","node-deps","path","config-templates","platform-sdks","bootstrap-marker"],RA=new Set(["darwin","linux","win32"]),LA=new Set(["arm64","x64"]),PA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"];zr=class zr extends Error{timeoutMs;constructor(e){super(`Timed out after ${Math.ceil(e/1000)} seconds.`);this.timeoutMs=e;this.name="AgentInstallTimeoutError"}}});function HA(e){let t,n=[],i=[e],r=new Set;while(i.length>0&&r.size<10){let s=i.shift();if(typeof s==="string"){n.push(s);continue}if(typeof s!=="object"||s===null||r.has(s))continue;if(r.add(s),s instanceof Error)n.push(s.name,s.message);let o=s;if(!t&&typeof o.code==="string")t=o.code.toUpperCase();if(o.cause!==void 0)i.push(o.cause);if(Array.isArray(o.errors))i.push(...o.errors)}return{code:t,text:n.join(" ").toLowerCase()}}function Om(e,t,n,i,r=!1){let s=new URL(t).hostname,o=HA(e),a=o.code==="ETIMEDOUT"||o.code==="UND_ERR_CONNECT_TIMEOUT"||o.text.includes("timeouterror")||o.text.includes("aborterror")||o.text.includes("timed out"),l=o.code==="EAI_AGAIN"||o.code==="ENOTFOUND"||o.text.includes("getaddrinfo"),c=o.code==="ECONNREFUSED"||o.code==="ECONNRESET"||o.code==="ENETUNREACH",f="No agent configuration files were changed.",u="If your network uses a proxy, set HTTPS_PROXY and make sure it is available in the current shell or container.",d=o.code?`
|
|
693
|
+
Technical detail: ${o.code}.`:"",g=`Could not reach ${s}.`,h=b.NETWORK,p="Check your internet connection, DNS, firewall, and proxy, then try again.";if(a)g=i?`Connection to ${s} through the configured proxy timed out after ${n} seconds.`:`Connection to ${s} timed out after ${n} seconds.`,h=b.TIMEOUT,p=i?"Check the proxy address and make sure it is reachable from the current shell or container.":`Check your connection, firewall, and selected MiniMax region.
|
|
694
|
+
${u}`;else if(r)g=`Connection to ${s} was interrupted while reading the verification response.`,p="Try again and check your network connection and proxy.";else if(i||o.text.includes("proxy"))g=`Could not reach ${s} through the configured proxy.`,p="Check the proxy address and make sure it is reachable from the current shell or container.";else if(l)g=`Could not resolve ${s}.`,p=`Check DNS and internet access, then try again.
|
|
695
|
+
${u}`;else if(c)g=`Could not connect to ${s}.`,p=`Check your internet connection, firewall, and selected MiniMax region.
|
|
690
696
|
${u}`;return new y(g,h,`No agent configuration files were changed.
|
|
691
|
-
${
|
|
697
|
+
${p}${d}`)}function KA(e){if(e===401||e===403)return new y(`MiniMax rejected the API key (HTTP ${e}).`,b.AUTH,`No agent configuration files were changed.
|
|
692
698
|
Check that the API key type and selected MiniMax region are correct.`);if(e===408||e===504)return new y(`MiniMax verification timed out (HTTP ${e}).`,b.TIMEOUT,`No agent configuration files were changed.
|
|
693
699
|
Check your connection and try again.`);if(e===402)return new y("MiniMax quota or balance is insufficient (HTTP 402).",b.QUOTA,`No agent configuration files were changed.
|
|
694
700
|
Check the quota or balance for this API key.`);if(e===429)return new y("MiniMax verification was rate limited (HTTP 429).",b.QUOTA,`No agent configuration files were changed.
|
|
695
701
|
Wait and try again, or check the quota for this API key.`);if(e>=500)return new y(`MiniMax is temporarily unavailable (HTTP ${e}).`,b.GENERAL,`No agent configuration files were changed.
|
|
696
702
|
Try again later.`);return new y(`MiniMax rejected the agent verification request (HTTP ${e}).`,b.GENERAL,`No agent configuration files were changed.
|
|
697
|
-
Check the selected MiniMax region and model.`)}async function
|
|
703
|
+
Check the selected MiniMax region and model.`)}async function Nm(e){let t=`${Ce(e.region).openai}/responses`,n=e.timeoutSeconds??30,i=VA.map((l)=>process.env[l]?.trim()).find((l)=>Boolean(l)),r=i??e.proxy,s=Boolean(i||e.proxy),o;try{let l={method:"POST",headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({model:e.model,input:"Reply with exactly OK.",max_output_tokens:16,stream:!0}),signal:AbortSignal.timeout(n*1000)};if(r&&process.versions.bun)l.proxy=r;o=await fetch(t,l)}catch(l){throw Om(l,t,n,s)}if(!o.ok)throw await o.body?.cancel().catch(()=>{return}),KA(o.status);let a=!1;try{for await(let l of Ue(o)){let c;try{c=JSON.parse(l.data)}catch{continue}if(typeof c!=="object"||c===null||Array.isArray(c))continue;let f=c,u=f.response;if(f.type==="response.created"&&typeof u==="object"&&u!==null&&!Array.isArray(u)&&typeof u.id==="string"&&typeof u.model==="string"){a=!0;break}}}catch(l){throw Om(l,t,n,s,!0)}finally{await o.body?.cancel().catch(()=>{return})}if(!a)throw new y("MiniMax returned an invalid agent verification response.",b.GENERAL,"No agent configuration files were changed. Check --region, --model, and the API key.");return{region:e.region,model:e.model,endpoint:t,status:"ok"}}var VA;var Cm=T(()=>{G();j();Ja();VA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"]});import{readFileSync as WA}from"fs";import{homedir as YA}from"os";import{isAbsolute as JA,join as Rm,resolve as zA}from"path";function nk(e){if(e.startsWith("sk-cp-"))return"token-plan";if(e.startsWith("sk-api-"))return"paygo";return}function Lm(e){if(!e.includes("codex"))return;let t=YA(),n=process.env.CODEX_HOME?.trim(),i=n?JA(n)?n:zA(t,n):Rm(t,".codex");try{let r=WA(Rm(i,"config.toml"),"utf8"),o=kt(r.charCodeAt(0)===65279?r.slice(1):r).model_providers;if(typeof o!=="object"||o===null||Array.isArray(o))return;let a=o.minimax;if(typeof a!=="object"||a===null||Array.isArray(a))return;let l=a.experimental_bearer_token;return typeof l==="string"&&l.trim()?l.trim():void 0}catch{return}}function ik(e,t,n){if(t==="json"||!n)return O(e,t);let i=oi.default.cyan,r=oi.default.green;return O({[i("verification")]:{[i("region")]:e.verification.region,[i("model")]:e.verification.model,[i("endpoint")]:e.verification.endpoint,[i("status")]:r(e.verification.status)},[i("agents")]:e.agents.map((s)=>r(s)),[i("files")]:e.files.map((s)=>({[i("agent")]:r(s.agent),[i("path")]:s.path,[i("status")]:r(s.status),...s.backup?{[i("backup")]:s.backup}:{}}))},"text")}function el(e){let t=[];for(let n of e){let i=n.trim().toLowerCase(),r=XA[i];if(!r)throw new y(`Unsupported agent "${n}".`,b.USAGE,`Supported agents: ${Pt.join(", ")}`);if(!t.includes(r))t.push(r)}return t}function rk(e){if(e._hasExplicitOptions===!0)return!1;return Object.values(e).every((t)=>t===void 0||t===!1)}async function sk(e,t,n=tk){let i=e.filter((a)=>!t.has(a));if(i.length===0)return[];let r=i.flatMap((a)=>{let l=n.getIssue(a);return l?[{agent:a,issue:l}]:[]});if(r.length>0)await n.note({title:"Unavailable installers",message:r.map(({agent:a,issue:l})=>`${Ke[a]}: ${l}`).join(`
|
|
698
704
|
`)+`
|
|
699
705
|
|
|
700
|
-
These agents will remain configuration-only.`});let s=i.filter((a)=>!r.some((l)=>l.agent===a));if(s.length===0)return[];let o=await n.select({message:"Select missing agents to install",choices:s.map((a)=>({value:a,label:Ke[a]})),initialValues:s,required:!1});if(o===void 0)throw new y("Agent setup cancelled.",b.GENERAL);return
|
|
706
|
+
These agents will remain configuration-only.`});let s=i.filter((a)=>!r.some((l)=>l.agent===a));if(s.length===0)return[];let o=await n.select({message:"Select missing agents to install",choices:s.map((a)=>({value:a,label:Ke[a]})),initialValues:s,required:!1});if(o===void 0)throw new y("Agent setup cancelled.",b.GENERAL);return el(o)}async function ok(e,t,n={},i=ek){for(let r of e){let s=i.getCommand(r);await i.note({title:`Install ${Ke[r]}`,message:`$ ${s.display}`});try{await i.install(r,n),t.add(r)}catch(o){let a=o instanceof y?`${o.message}${o.hint?`
|
|
701
707
|
|
|
702
|
-
${o.hint}`:""}`:o instanceof Error?o.message:String(o);if(await i.note({title:"Installation failed",message:a}),!await i.confirm({message:`Continue and configure ${Ke[r]} without installing it?`}))throw o}}}async function
|
|
708
|
+
${o.hint}`:""}`:o instanceof Error?o.message:String(o);if(await i.note({title:"Installation failed",message:a}),!await i.confirm({message:`Continue and configure ${Ke[r]} without installing it?`}))throw o}}}async function ak(e,t){let n=await Ms({message:"Select agents to configure",choices:Pt.map((p)=>({value:p,label:t.has(p)?Ke[p]:`${Ke[p]} (not detected on PATH)`})),initialValues:ZA.filter((p)=>t.has(p)),required:!0});if(!n?.length)throw new y("Agent setup cancelled.",b.GENERAL);let i=el(n);if(i.includes("codex"))await bt({title:"Codex version recommendation",message:`Use Codex CLI ${oi.default.bold(oi.default.cyan("0.146.0"))} or newer for the complete MiniMax model catalog.`});let r=i.filter((p)=>!t.has(p)),s=await sk(i,t),o=await Ei({message:"Select your MiniMax service region",choices:[{value:"global",label:"Global (minimax.io)"},{value:"cn",label:"Mainland China (minimax.cn)"}],initialValue:e.region});if(o!=="global"&&o!=="cn")throw new y("Agent setup cancelled.",b.GENERAL);let a=524288;if(i.some((p)=>p==="claude-code"||p==="codex"||p==="opencode"||p==="zed")){let p=await Ei({message:"Choose the MiniMax-M3.1-Flash context window",choices:[{value:"512k",label:"512K (Recommended)"},{value:"1m",label:"1M"}],initialValue:"512k"});if(p!=="512k"&&p!=="1m")throw new y("Agent setup cancelled.",b.GENERAL);a=p==="1m"?1e6:524288}let l=Lm(i),c;if(l)await bt({title:"Reusing existing Codex API key",message:`Found an existing MiniMax API key in ~/.codex/config.toml; it will be reused. To replace it, run mmx agent setup ${i.map((p)=>`--agent ${p}`).join(" ")} --region ${o} --api-key <key>.`});else{let p=await Ei({message:"Choose an API key type",choices:Za,initialValue:"token-plan"});if(c=Za.find((m)=>m.value===p),!c)throw new y("Agent setup cancelled.",b.GENERAL);await bt({title:c.noteTitle,message:`${ht[o]}${c.pagePath}
|
|
703
709
|
|
|
704
|
-
Copy the key, then paste it below.`}),l=(await
|
|
705
|
-
Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??
|
|
706
|
-
`,
|
|
707
|
-
`)}})});class
|
|
710
|
+
Copy the key, then paste it below.`}),l=(await Ul({message:c.prompt}))?.trim()}let f=l?nk(l):void 0;if(f&&c&&f!==c.value){let p=Za.find((m)=>m.value===f);if(p)await bt({title:"API key type detected",message:`This looks like ${p.label}. ${p.hint}.`})}if(!l)throw new y("A MiniMax API key is required.",b.USAGE);let u=qa,d=`Configure ${i.map((p)=>Ke[p]).join(", ")}? mmx will write configuration files.`;if(s.length>0)d+=` It will first install ${s.map((p)=>Ke[p]).join(", ")} using their official installers.`;let g=r.filter((p)=>!s.includes(p));if(g.length>0)d+=` Configuration only: ${g.map((p)=>Ke[p]).join(", ")}.`;if(!await wn({message:d}))throw new y("Agent setup cancelled.",b.GENERAL);return{agents:i,agentsToInstall:s,apiKey:l,region:o,model:u,m31ContextWindow:a}}function lk(e){if(e._positional?.length)throw new y("Unexpected positional argument.",b.USAGE,"Select agents with --agent <name> or --all.");let n=el(e.agent??[]),i=e.all?[...Pt]:n;if(i.length===0)throw new y("At least one --agent or --all is required in non-interactive mode.",b.USAGE,"mmx agent setup --agent codex --api-key <key> --region global");let r=e.m31ContextWindow;if(r!==void 0&&r!=="512k"&&r!=="1m")throw new y("Invalid --m31-context-window value.",b.USAGE,"Use --m31-context-window 512k or --m31-context-window 1m.");if(r!==void 0&&!i.some((l)=>l==="claude-code"||l==="codex"||l==="opencode"||l==="zed"))throw new y("--m31-context-window requires Claude Code, Codex, OpenCode, or Zed.",b.USAGE);if(e.region!=="global"&&e.region!=="cn")throw new y("--region global|cn is required in non-interactive mode.",b.USAGE,"Supplying the region makes scripts deterministic and prevents writing configs for the wrong service.");let s=e.apiKey?.trim()||Lm(i);if(!s)throw new y("A MiniMax API key is required in non-interactive mode.",b.USAGE,`Pass --api-key <key>, or configure an existing Codex MiniMax provider Key.
|
|
711
|
+
Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??qa).trim();if(!o)throw new y("--model must not be empty.",b.USAGE);let a=ce.find((l)=>l.id===o)?.id;if(!a)throw new y(`Unsupported MiniMax model "${o}".`,b.USAGE,`Supported models: ${ce.map((l)=>l.id).join(", ")}`);return{agents:i,agentsToInstall:[],apiKey:s,region:e.region,model:a,m31ContextWindow:r==="1m"?1e6:524288}}var oi,XA,Ke,QA=`Zed: paste your MiniMax API key in Agent Panel > Settings > minimax, or start Zed with MINIMAX_API_KEY set.
|
|
712
|
+
`,ZA,ek,tk,Za,Pm;var Fm=T(()=>{xo();X();Ja();_m();Mm();Kr();Cm();Re();Ee();G();j();ee();De();oi=qt(un(),1),XA={claude:"claude-code",claudecode:"claude-code","claude-code":"claude-code",codex:"codex",grok:"grok","grok-build":"grok","grok-cli":"grok",opencode:"opencode",hermes:"hermes",pi:"pi","oh-my-pi":"oh-my-pi",omp:"oh-my-pi",zed:"zed","deepseek-harness":"deepseek-harness",dsh:"deepseek-harness"},Ke={"claude-code":"Claude Code",codex:"Codex",grok:"Grok CLI (Grok Build)",opencode:"OpenCode",hermes:"Hermes Agent",pi:"Pi","oh-my-pi":"Oh my Pi (omp)",zed:"Zed","deepseek-harness":"DeepSeek Harness"},ZA=["claude-code","codex"],ek={getCommand:Qa,install:Tm,note:bt,confirm:wn},tk={select:Ms,note:bt,getIssue:Xa},Za=[{value:"token-plan",label:"Token Plan (sk-cp-...)",hint:"Uses plan quota and Credits",pagePath:"/user-center/payment/token-plan",noteTitle:"Get your Token Plan key",prompt:"Paste your Token Plan key"},{value:"paygo",label:"Pay-as-you-go (sk-api-...)",hint:"Uses account balance",pagePath:"/user-center/basic-information/interface-key",noteTitle:"Create a pay-as-you-go key",prompt:"Paste your pay-as-you-go key"}];Pm=C({name:"agent setup",description:"Configure coding agents using a MiniMax API key and optionally install missing agents",usage:"mmx agent setup [--agent <name> ... | --all] [--api-key <key>] [--region <region>] [--m31-context-window 512k|1m]",options:[{flag:"--agent <name>",description:"Agent: claude-code, codex, grok/grok-build, opencode, hermes, pi, oh-my-pi/omp, zed, deepseek-harness/dsh (repeatable)",type:"array"},{flag:"--api-key <key>",description:"API key; reuses an existing Codex MiniMax provider Key when --api-key is omitted. Token Plan (sk-cp) and pay-as-you-go (sk-api) keys are not interchangeable"},{flag:"--all",description:"Configure every supported agent"},{flag:"--model <model>",description:`Default model (${ce.map((e)=>e.id).join(", ")})`},{flag:"--m31-context-window <size>",description:"MiniMax-M3.1-Flash window for Claude Code, Codex, and OpenCode: 512k (recommended) or 1m"}],examples:["mmx agent setup","mmx agent setup --agent claude-code --agent codex --api-key <key> --region global","mmx agent setup --all --api-key <key> --region cn --output json","mmx agent setup --agent opencode --api-key <key> --region cn --dry-run","mmx agent setup --agent codex --api-key <key> --region cn --m31-context-window 1m"],async run(e,t){let n=$m(),i=rk(t),r=i?await ak(e,n):lk(t),s=Z().proxy,o={region:r.region,model:r.model,endpoint:"",status:"skipped"};if(!e.dryRun){let d=()=>Nm({apiKey:r.apiKey,region:r.region,model:r.model,timeoutSeconds:Math.min(e.timeout,60),proxy:s});o=i?await jl({message:"Verifying API key with MiniMax...",successMessage:"API key verified.",errorMessage:"API key verification failed."},d):await d()}let a=async(d=!1)=>{let g=Ya(r);if(!e.dryRun){if(await ok(r.agentsToInstall,n,{proxy:s}),r.agentsToInstall.length>0)g=Ya(r)}return vm(g,e.dryRun,d)},c=!e.dryRun&&r.agentsToInstall.length>0?await xm(()=>a(!0)):await a(),f=F(e.output);if(console.log(ik({verification:o,agents:r.agents,files:c},f,i&&!e.noColor)),r.agents.includes("zed")&&!e.quiet)process.stderr.write(QA);let u=r.agents.filter((d)=>!n.has(d));if(!i&&u.length>0&&!e.quiet)process.stderr.write(`Warning: Not detected on PATH: ${u.map((d)=>Ke[d]).join(", ")}. mmx can write configuration files for them, but will not download or install them for you.
|
|
713
|
+
`)}})});class Dm{root={children:new Map};constructor(e){for(let[t,n]of Object.entries(e))this.register(t,n)}register(e,t){let n=e.split(" "),i=this.root;for(let r of n){if(!i.children.has(r))i.children.set(r,{children:new Map});i=i.children.get(r)}i.command=t}getAllCommands(){let e=new Set,t=[],n=(i)=>{if(i.command&&!e.has(i.command))e.add(i.command),t.push(i.command);for(let r of i.children.values())n(r)};return n(this.root),t}resolve(e){let t=this.root,n=[];for(let i of e){let r=t.children.get(i);if(!r)break;t=r,n.push(i)}if(t.command)return{command:t.command,extra:e.slice(n.length)};if(n.length>0&&t.children.size===1){let[,i]=t.children.entries().next().value;if(i.command)return{command:i.command,extra:e.slice(n.length)}}if(n.length>0&&t.children.size>1){let r=Array.from(t.children.values()).map((o)=>o.command),s=r[0];if(s&&r.every((o)=>o===s))return{command:s,extra:e.slice(n.length)}}if(n.length>0&&t.children.size>0){let i=Array.from(t.children.entries()).map(([r,s])=>{if(s.command)return` ${n.join(" ")} ${r} ${s.command.description}`;let o=Array.from(s.children.keys()).join(", ");return` ${n.join(" ")} ${r} [${o}]`}).join(`
|
|
708
714
|
`);throw new y(`Unknown command: mmx ${e.join(" ")}
|
|
709
715
|
|
|
710
716
|
Available commands:
|
|
@@ -760,12 +766,12 @@ ${i("Options:")}
|
|
|
760
766
|
${i("Examples:")}
|
|
761
767
|
`);for(let a of e.examples)t.write(` ${s(a)}
|
|
762
768
|
`)}if(e.apiDocs)t.write(`
|
|
763
|
-
${i("API Reference:")} ${s(
|
|
769
|
+
${i("API Reference:")} ${s(ht[n]+e.apiDocs)}
|
|
764
770
|
`);t.write(`
|
|
765
771
|
${s("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
|
|
766
772
|
`),t.write(`${s("Run")} mmx --help ${s("for the full list.")}
|
|
767
773
|
`)}printChildren(e,t,n){let i=[],r=(o,a)=>{for(let[l,c]of o.children){if(c.command)i.push({fullName:`${a} ${l}`,description:c.command.description});if(c.children.size>0)r(c,`${a} ${l}`)}};r(e,t);let s=Math.max(...i.map((o)=>o.fullName.length));for(let{fullName:o,description:a}of i)n.write(` ${this.accent(o.padEnd(s),n)} ${this.dim(a,n)}
|
|
768
|
-
`)}}var
|
|
774
|
+
`)}}var Me;var Di=T(()=>{G();j();Ee();Rc();Pc();Dc();Uc();Hc();zc();cu();wu();vu();Ku();Qu();ef();nf();rf();of();lf();uf();mf();gf();bf();xf();Sf();_f();Af();Fm();Me=new Dm({"auth login":Cc,"auth status":Lc,"auth refresh":Fc,"auth logout":qc,"text chat":Vc,"text repl":Jc,"speech synthesize":zs,"speech generate":zs,"speech transcribe":eo,"speech recognize":eo,"speech voices":xu,"image generate":Hu,"video generate":Xu,"video task get":Zu,"video download":tf,"search query":po,"search web":po,"vision describe":sf,"quota show":af,"config show":cf,"config set":pf,"config export-schema":hf,"file upload":yf,"file list":wf,"file delete":vf,update:$f,help:Ef,"agent setup":Pm})});var Xm=new Set(["true","1","yes","on"]),Qm=new Set(["false","0","no","off"]);function ai(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Zm(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?ai(t[1]):null}function eh(e){if(e.type==="boolean")return!0;if(e.type==="string"||e.type==="number"||e.type==="array")return!1;return!e.flag.includes("<")&&!e.flag.includes("[")}function Xr(e){let t=new Set,n=new Set,i=new Set,r=new Set;for(let s of e){let o=Zm(s);if(!o)continue;if(r.add(o),eh(s))t.add(o);else if(s.type==="number")n.add(o);else if(s.type==="array")i.add(o)}return{booleans:t,numbers:n,arrays:i,keys:r}}function rl(e,t){let n=Xr(t),i=0;while(i<e.length){let r=e[i];if(r==="--")break;if(r.startsWith("--")){let s=r.indexOf("="),o=s===-1?r.slice(2):r.slice(2,s),a=ai(o);if(!n.keys.has(a))return`Unknown option: --${o}`;if(s!==-1&&!n.booleans.has(a)&&r.slice(s+1).trim()==="")return`Option --${o} requires a value.`;if(s===-1&&!n.booleans.has(a)){let l=e[i+1];if(l===void 0||l.startsWith("-"))return`Option --${o} requires a value.`;i+=2;continue}i+=1;continue}if(r.startsWith("-")&&r!=="-h"&&r!=="-v")return`Unknown option: ${r}`;i+=1}return}function Qr(e,t=[]){let n=Xr(t),i=[],r=0;while(r<e.length){let s=e[r];if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a=o!==-1?s.slice(2,o):s.slice(2),l=ai(a);if(!n.booleans.has(l)&&o===-1)r+=2;else r+=1;continue}if(s.startsWith("-")){r++;continue}i.push(s),r++}return i}function Zr(e,t){let n=Xr(t),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},r=0;while(r<e.length){let s=e[r];if(s==="--help"||s==="-h"){i.help=!0,r++;continue}if(s==="--")break;if(s.startsWith("--")){let o=s.indexOf("="),a,l;if(o!==-1)a=s.slice(2,o),l=s.slice(o+1);else a=s.slice(2);let c=ai(a);if(n.booleans.has(c)){if(l===void 0)i[c]=!0;else{let f=l.trim().toLowerCase();if(Xm.has(f))i[c]=!0;else if(Qm.has(f))i[c]=!1;else throw Error(`Flag --${a} requires a boolean value (e.g. true/false), got "${l}".`)}r++;continue}if(l===void 0)r++,l=e[r];if(l===void 0)throw Error(`Flag --${a} requires a value.`);if(n.arrays.has(c)){let f=i[c];if(f)f.push(l);else i[c]=[l]}else if(n.numbers.has(c)){let f=Number(l);if(l.trim()===""||!Number.isFinite(f))throw Error(`Flag --${a} requires a numeric value, got "${l}".`);i[c]=f}else i[c]=l}r++}return i}Di();X();G();j();G();j();ee();function Dt(e){if(e instanceof y){if(F(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
|
|
769
775
|
`);else{if(process.stderr.write(`
|
|
770
776
|
Error: ${e.message}
|
|
771
777
|
`),e.hint)process.stderr.write(`
|
|
@@ -776,22 +782,22 @@ Error: ${e.message}
|
|
|
776
782
|
`)}process.exit(e.exitCode)}if(e instanceof Error){if(e.name==="AbortError"||e.name==="TimeoutError"||e.message.includes("timed out")){let r=new y("Request timed out.",b.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
|
|
777
783
|
If this happens on every request with a valid API key, you may be hitting the wrong region.
|
|
778
784
|
`+`Run: mmx auth status — to check your credentials and region.
|
|
779
|
-
`+"Run: mmx config set region global (or cn) — to override the region.");return
|
|
780
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return
|
|
785
|
+
`+"Run: mmx config set region global (or cn) — to override the region.");return Dt(r)}if(e instanceof TypeError&&e.message==="fetch failed"){let r=new y("Network request failed.",b.NETWORK,`Check your network connection.
|
|
786
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Dt(r)}let t=e.message.toLowerCase();if(t.includes("failed to fetch")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||t.includes("timeout")||t.includes("eai_AGAIN")){let r=`Check your network connection.
|
|
781
787
|
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(t.includes("proxy"))r=`Proxy connection failed — verify your proxy URL and authentication.
|
|
782
|
-
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new y("Network request failed.",b.NETWORK,r);return
|
|
788
|
+
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new y("Network request failed.",b.NETWORK,r);return Dt(s)}let i=e.code;if(i==="ENOENT"||i==="EACCES"||i==="ENOSPC"||i==="ENOTDIR"||i==="EISDIR"||i==="EPERM"||i==="EBUSY"){let r="Check the file path and permissions.";if(i==="ENOENT")r="File or directory not found.";if(i==="EACCES"||i==="EPERM")r="Permission denied — check file or directory permissions.";if(i==="ENOSPC")r="Disk full — free up space and try again.";let s=new y(`File system error: ${e.message}`,b.GENERAL,r);return Dt(s)}else if(typeof i==="string"&&i.startsWith("E")){let r=new y(`File system error: ${e.message}`,b.GENERAL,"Check the file path and permissions.");return Dt(r)}if(process.stderr.write(`
|
|
783
789
|
Error: ${e.message}
|
|
784
790
|
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${e.stack}
|
|
785
791
|
`)}else process.stderr.write(`
|
|
786
792
|
Error: ${String(e)}
|
|
787
|
-
`);process.exit(b.GENERAL)}
|
|
793
|
+
`);process.exit(b.GENERAL)}Re();Bs();Ee();Xe();import{join as ck}from"path";import{readFileSync as uk,writeFileSync as fk}from"fs";var qm=()=>ck(ci(),"update-state.json"),dk=86400000,pk=3000,mk="MiniMax-AI-Dev/minimax-cli";function hk(){try{let e=uk(qm(),"utf-8");return JSON.parse(e)}catch{return null}}function gk(e){try{fk(qm(),JSON.stringify(e))}catch{}}async function yk(){try{let e=await fetch(`https://api.github.com/repos/${mk}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(pk)});if(!e.ok)return null;return(await e.json()).tag_name??null}catch{return null}}var tl=null;function Um(){return tl}async function jm(e){if(process.env.CI||!process.stderr.isTTY)return;let t=hk(),n=Date.now();if(t&&n-t.lastChecked<dk){if(t.latestVersion&&t.latestVersion!==`v${e}`)tl=t.latestVersion;return}let i=await yk();if(!i)return;if(gk({lastChecked:n,latestVersion:i}),i!==`v${e}`)tl=i}Ze();Rs();Ti();import{ProxyAgent as bk,setGlobalDispatcher as wk}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
|
|
788
794
|
Interrupted. Exiting.
|
|
789
|
-
`),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var
|
|
795
|
+
`),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var xk=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function vk(){let e=process.argv.slice(2);if(e.includes("--version")||e.includes("-v"))console.log(`mmx ${xt}`),process.exit(0);let t=Qr(e,cn);if(t[0]==="agent"){let{command:p}=Me.resolve(["agent","setup"]);if(t=Qr(e,[...cn,...p.options??[]]),t.length===1)t.push("setup")}let n=Z(),i=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||n.proxy;if(i)wk(new bk(i));if(e.includes("--help")||e.includes("-h")){let p=e.indexOf("--region"),m=p>=0&&e[p+1]||process.env.MINIMAX_REGION||n.region||"global";Me.printHelp(t,process.stderr,m),process.exit(0)}if(t.length===0){Me.printHelp([],process.stderr);let{command:p}=Me.resolve(["quota","show"]),m=Zr(e,[...cn,...p.options??[]]),v=ns(m),w=!!(v.apiKey||v.fileApiKey),x=!!await ge();if(w||x)await p.execute(v,m);else process.stderr.write(` Not logged in.
|
|
790
796
|
`),process.stderr.write(` mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key
|
|
791
797
|
`),process.stderr.write(` mmx auth login --api-key Save an API key directly
|
|
792
798
|
|
|
793
|
-
`);process.exit(0)}let{command:r,extra:s}=
|
|
799
|
+
`);process.exit(0)}let{command:r,extra:s}=Me.resolve(t),o=r.name==="agent setup",a=[...cn,...r.options??[]];if(o){let p=rl(e,a);if(p)throw new y(p,b.USAGE,"Run mmx agent setup --help to see supported options.")}let l=Zr(e,a),c=o?e.indexOf("--"):-1,f=c>=0?[...s,...e.slice(c+1)]:s;if(f.length>0)l._positional=f;if(o)l._hasExplicitOptions=f.length>0||e.some((p)=>p.startsWith("-"));let u=ns(l);if(!o&&!xk.some((p)=>p.every((m,v)=>t[v]===m)))await Wl(u);if(u.needsRegionDetection&&!o){let p=u.apiKey||u.fileApiKey;if(p){let m=await Fi(p);u.region=m,u.baseUrl=ne[m],u.needsRegionDetection=!1,await Tc(m)}}let g=o&&u.dryRun?Promise.resolve():jm(xt).catch(()=>{});await r.execute(u,l),await g;let h=Um();if(h&&!u.quiet)process.stderr.write(`
|
|
794
800
|
Update available: ${h}
|
|
795
801
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
796
802
|
|
|
797
|
-
`)}
|
|
803
|
+
`)}vk().catch(Dt);
|