mmx-cli 1.0.28 → 1.0.30
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 +17 -6
- package/dist/index.d.ts +73 -2
- package/dist/mmx.mjs +328 -319
- package/dist/sdk.mjs +386 -113
- package/package.json +1 -1
package/dist/mmx.mjs
CHANGED
|
@@ -1,254 +1,262 @@
|
|
|
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 jm}from"node:module";var Lm=Object.create;var{getPrototypeOf:Pm,defineProperty:Xa,getOwnPropertyNames:Fm}=Object;var Qa=Object.prototype.hasOwnProperty;function qm(e){return this[e]}var Dm,Um,Ft=(e,t,n)=>{var i=e!=null&&typeof e==="object";if(i){var r=t?Dm??=new WeakMap:Um??=new WeakMap,s=r.get(e);if(s)return s}n=e!=null?Lm(Pm(e)):{};let o=t||!e||!e.__esModule||!Qa.call(e,"default")?Xa(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of Fm(e))if(!Qa.call(o,a))Xa(o,a,{get:qm.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 I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(i){n=[i]}if(n)throw n[0];return t};var an=jm(import.meta.url);var b;var j=I(()=>{b={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var G=I(()=>{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 Wm(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"&&el.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 tl(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"&&el.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"&&Km.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=Wm(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,pt,si,el,Km;var $e=I(()=>{ne={global:"https://api.minimax.io",cn:"https://api.minimax.cn"},pt={global:"https://platform.minimax.io",cn:"https://platform.minimax.cn"},si={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},el=new Set(["global","cn"]),Km=new Set(["text","json"])});function N(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var ln;var X=I(()=>{ln=[{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 Jm}from"os";import{join as nl}from"path";function oi(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return nl(Jm(),Ym)}function fe(){return nl(oi(),"config.json")}async function il(e=oi()){let t=await import("fs/promises");await t.mkdir(e,{recursive:!0,mode:448})}var Ym=".mmx";var Xe=()=>{};function rl(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 Qr(e);return e.map(String).join(`
|
|
3
|
+
`)}if(typeof e==="object")return Xr(e);return String(e)}function Xr(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} - ${Xr(o,t+4).trimStart()}`);else i.push(`${n} - ${String(o)}`)}else if(typeof s==="object")i.push(`${n}${r}:`),i.push(Xr(s,t+2));else i.push(`${n}${r}: ${String(s)}`)}return i.join(`
|
|
4
|
+
`)}function Qr(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 sl(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 sl(e);case"text":return rl(e)}}function _e(e,t){if(!e.dryRun)return!1;return console.log(O({request:t},F(e.output))),!0}var ee=()=>{};import{copyFileSync as zm,existsSync as Xm,readFileSync as Qm,renameSync as Zm,unlinkSync as eh,writeFileSync as th}from"fs";import{dirname as nh}from"path";function ih(e){return e instanceof Error&&"code"in e&&e.code==="EXDEV"}function rh(e,t,n={rename:Zm,copy:zm,unlink:eh}){try{n.rename(e,t)}catch(i){if(!ih(i))throw i;n.copy(e,t),n.unlink(e)}}function Z(e=fe()){if(!Xm(e))return{};try{return tl(JSON.parse(Qm(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 de(e,t,n=fe()){await il(nh(n));let i=n+".tmp";th(i,JSON.stringify(e,null,2)+`
|
|
7
|
+
`,{mode:384}),rh(i,n,t)}function Zr(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,p=F(e.output||process.env.MINIMAX_OUTPUT||t.output),u=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,f=u!==void 0&&Number.isFinite(u)&&u>0?u:void 0,g=e.timeout??f??t.timeout??300;return{apiKey:n,fileApiKey:i,fileRegion:t.region,configPath:fe(),region:o,baseUrl:c,output:p,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 Ce=I(()=>{$e();Xe();ee();G();j()});var cn=M(function(Ck,es){var li=process||{},ol=li.argv||[],ai=li.env||{},sh=!(!!ai.NO_COLOR||ol.includes("--no-color"))&&(!!ai.FORCE_COLOR||ol.includes("--color")||li.platform==="win32"||(li.stdout||{}).isTTY&&ai.TERM!=="dumb"||!!ai.CI),oh=(e,t,n=e)=>(i)=>{let r=""+i,s=r.indexOf(t,e.length);return~s?e+ah(r,t,n,s)+t:e+r+t},ah=(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)},al=(e=sh)=>{let t=e?oh:()=>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")}};es.exports=al();es.exports.createColors=al});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 ns=M(function(Rk,ll){var ts={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"},lh={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},ch={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?ts.up():"");if(e)t+=ts.left;return t}};ll.exports={cursor:ts,scroll:lh,erase:ch,beep:"\x07"}});import{stdout as ls,stdin as ml}from"node:process";import*as Qe from"node:readline";import uh from"node:readline";import{ReadStream as cl}from"node:tty";function os(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
8
8
|
`,`
|
|
9
9
|
`).split(`
|
|
10
|
-
`).map((i)=>
|
|
11
|
-
`)}function
|
|
10
|
+
`).map((i)=>Sh(i,t,n)).join(`
|
|
11
|
+
`)}function fs(e,t){if(typeof e=="string")return Ne.aliases.get(e)===t;for(let n of e)if(n!==void 0&&fs(n,t))return!0;return!1}function _h(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 Re(e){return e===as}function di(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function wl({input:e=ml,output:t=ls,overwrite:n=!0,hideCursor:i=!0}={}){let r=Qe.createInterface({input:e,output:t,prompt:"",tabSize:1});Qe.emitKeypressEvents(e,r),e instanceof cl&&e.isTTY&&e.setRawMode(!0);let s=(o,{name:a,sequence:l})=>{let c=String(o);if(fs([c,a,l],"cancel")){i&&t.write(ce.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(ce.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),i&&t.write(ce.cursor.show),e instanceof cl&&e.isTTY&&!Eh&&e.setRawMode(!1),r.terminal=!1,r.close()}}function ht(e,t,n,i=n){let r=fn(e??ls);return os(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 dn{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=ml,output:i=ls,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(as);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=uh.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),di(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(ce.cursor.show),this.output.off("resize",this.render),di(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(ce.cursor.show),this.output.off("resize",this.render),di(this.input,!1),e(as)})})}_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&&Ne.aliases.has(t.name)&&this.emit("cursor",Ne.aliases.get(t.name)),Ne.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")}fs([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
|
+
`),di(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=os(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
|
|
17
|
+
`).length-1;this.output.write(ce.cursor.move(-999,e*-1))}render(){let e=os(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(ce.cursor.hide);else{let t=_h(this._prevFrame,e),n=ds(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(ce.cursor.move(0,s-r)),this.output.write(ce.erase.lines(1));let o=e.split(`
|
|
18
|
+
`);this.output.write(o[s]),this._prevFrame=e,this.output.write(ce.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(ce.cursor.move(0,a))}this.output.write(ce.erase.down());let o=e.split(`
|
|
19
19
|
`).slice(s);this.output.write(o.join(`
|
|
20
|
-
`)),this._prevFrame=e;return}}this.output.write(
|
|
21
|
-
`),p=c[Symbol.iterator](),u=p.next(),f=p.next(),
|
|
22
|
-
`?(s&&(i+=
|
|
23
|
-
`&&(r&&
|
|
20
|
+
`)),this._prevFrame=e;return}}this.output.write(ce.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function mt(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?mt(s,t<0?-1:1,n):s}var pl,ce,fh=(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,dh=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ph=(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,is,ci,ui,rs,fi,mh,hh,hl=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?hl(r,hh,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,p=n.emojiWidth??2,u=n.fullWidthWidth??2,f=n.regularWidth??1,g=n.wideWidth??2,h=0,d=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||d>=m&&d>h){let R=e.slice(A,_)||e.slice(h,d);v=0;for(let U of R.replaceAll(mh,"")){let q=U.codePointAt(0)||0;if(dh(q)?k=u:ph(q)?k=g:c!==f&&fh(q)?k=c:k=f,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(d>=m)break;if(fi.lastIndex=d,fi.test(e)){if(v=fi.lastIndex-d,k=v*f,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/f))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=fi.lastIndex;continue}if(is.lastIndex=d,is.test(e)){if(S+o>E&&(x=Math.min(x,d)),S+o>i){w=!0;break}S+=o,A=h,_=d,d=h=is.lastIndex;continue}if(ci.lastIndex=d,ci.test(e)){if(v=ci.lastIndex-d,k=v*a,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=ci.lastIndex;continue}if(ui.lastIndex=d,ui.test(e)){if(v=ui.lastIndex-d,k=v*l,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=ui.lastIndex;continue}if(rs.lastIndex=d,rs.test(e)){if(S+p>E&&(x=Math.min(x,d)),S+p>i){w=!0;break}S+=p,A=h,_=d,d=h=rs.lastIndex;continue}d+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},gh,un=(e,t={})=>hl(e,gh,t).width,pi="\x1B",gl="",yh=39,cs="\x07",yl="[",bh="]",bl="m",us,ul,wh=(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},fl=(e)=>`${pi}${yl}${e}${bl}`,dl=(e)=>`${pi}${us}${e}${cs}`,xh=(e)=>e.map((t)=>un(t)),ss=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:un(o),l=i.next(),c=i.next(),p=0;for(;!l.done;){let u=l.value,f=un(u);a+f<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===pi||u===gl)&&(r=!0,s=t.startsWith(us,p+1)),r?s?u===cs&&(r=!1,s=!1):u===bl&&(r=!1):(a+=f,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},vh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(un(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Sh=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=xh(o),l=[""];for(let[h,d]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=un(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(""),ss(l,d,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){ss(l,d,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){ss(l,d,t);continue}l[l.length-1]+=d}n.trim!==!1&&(l=l.map((h)=>vh(h)));let c=l.join(`
|
|
21
|
+
`),p=c[Symbol.iterator](),u=p.next(),f=p.next(),g=0;for(;!u.done;){let h=u.value,d=f.value;if(i+=h,h===pi||h===gl){ul.lastIndex=g+1;let v=ul.exec(c)?.groups;if(v?.code!==void 0){let w=Number.parseFloat(v.code);r=w===yh?void 0:w}else v?.uri!==void 0&&(s=v.uri.length===0?void 0:v.uri)}let m=r?wh(r):void 0;d===`
|
|
22
|
+
`?(s&&(i+=dl("")),r&&m&&(i+=fl(m))):h===`
|
|
23
|
+
`&&(r&&m&&(i+=fl(r)),s&&(i+=dl(s))),g+=h.length,u=f,f=p.next()}return i},$h,Ne,Eh,as,fn=(e)=>("columns"in e)&&typeof e.columns=="number"?e.columns:80,ds=(e)=>("rows"in e)&&typeof e.rows=="number"?e.rows:20,ps,ms,hs,pn;var mi=I(()=>{pl=Ft(cn(),1),ce=Ft(ns(),1),is=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,ci=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ui=/\t{1,1000}/y,rs=/[\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,fi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,mh=/\p{M}+/gu,hh={limit:1/0,ellipsis:""},gh={limit:1/0,ellipsis:"",ellipsisWidth:0},us=`${bh}8;;`,ul=new RegExp(`(?:\\${yl}(?<code>\\d+)m|\\${us}(?<uri>.*)${cs})`,"y");$h=["up","down","left","right","space","enter","cancel"],Ne={actions:new Set($h),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0};Eh=globalThis.process.platform.startsWith("win"),as=Symbol("clack:cancel");ps=class ps extends dn{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(ce.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};ms=class ms extends dn{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?mt(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=mt(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=mt(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};hs=class hs extends dn{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?mt(n,1,this.options):n,this.changeValue(),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=mt(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=mt(this.cursor,1,this.options);break}this.changeValue()})}};pn=class pn extends dn{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}${pl.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 be from"node:process";function Ah(){return be.platform!=="win32"?be.env.TERM!=="linux":!!be.env.CI||!!be.env.WT_SESSION||!!be.env.TERMINUS_SUBLIME||be.env.ConEmuTask==="{cmd::Cmder}"||be.env.TERM_PROGRAM==="Terminus-Sublime"||be.env.TERM_PROGRAM==="vscode"||be.env.TERM==="xterm-256color"||be.env.TERM==="alacritty"||be.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function gn(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
24
24
|
`,`
|
|
25
25
|
`).split(`
|
|
26
|
-
`).map((i)
|
|
27
|
-
`)}var T,
|
|
28
|
-
`),p=c[Symbol.iterator](),u=p.next(),f=p.next(),
|
|
29
|
-
`?(s&&(i+=
|
|
30
|
-
`&&(r&&
|
|
31
|
-
`);
|
|
32
|
-
${
|
|
33
|
-
`,r=this.value?t:n;switch(this.state){case"submit":return`${i}${T.default.gray(
|
|
34
|
-
${T.default.gray(
|
|
35
|
-
${T.default.cyan(
|
|
36
|
-
`}}}).prompt()},
|
|
26
|
+
`).map((i)=>Hh(i,t,n)).join(`
|
|
27
|
+
`)}var T,hn,ws,kh=()=>process.env.CI==="true",Y=(e,t)=>ws?e:t,Th,Al,kl,Ss,Kk,K,qt,Wk,Jk,xs,wi,Ih,xl,vl,Yk,Sl,Mh,Oh,Ch,Nh,zk,Xk,Qk,Zk,e2,xi=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(Th);case"cancel":return T.default.red(Al);case"error":return T.default.yellow(kl);case"submit":return T.default.green(Ss)}},Tl=(e)=>{switch(e){case"initial":case"active":return T.default.cyan(K);case"cancel":return T.default.red(K);case"error":return T.default.yellow(K);case"submit":return T.default.green(K)}},Rh=(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,Lh=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ph=(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,gs,hi,gi,ys,yi,Fh,qh,Il=(e,t={},n={})=>{let i=t.limit??1/0,r=t.ellipsis??"",s=t?.ellipsisWidth??(r?Il(r,qh,n).width:0),o=n.ansiWidth??0,a=n.controlWidth??0,l=n.tabWidth??8,c=n.ambiguousWidth??1,p=n.emojiWidth??2,u=n.fullWidthWidth??2,f=n.regularWidth??1,g=n.wideWidth??2,h=0,d=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||d>=m&&d>h){let R=e.slice(A,_)||e.slice(h,d);v=0;for(let U of R.replaceAll(Fh,"")){let q=U.codePointAt(0)||0;if(Lh(q)?k=u:Ph(q)?k=g:c!==f&&Rh(q)?k=c:k=f,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(d>=m)break;if(yi.lastIndex=d,yi.test(e)){if(v=yi.lastIndex-d,k=v*f,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/f))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=yi.lastIndex;continue}if(gs.lastIndex=d,gs.test(e)){if(S+o>E&&(x=Math.min(x,d)),S+o>i){w=!0;break}S+=o,A=h,_=d,d=h=gs.lastIndex;continue}if(hi.lastIndex=d,hi.test(e)){if(v=hi.lastIndex-d,k=v*a,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/a))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=hi.lastIndex;continue}if(gi.lastIndex=d,gi.test(e)){if(v=gi.lastIndex-d,k=v*l,S+k>E&&(x=Math.min(x,d+Math.floor((E-S)/l))),S+k>i){w=!0;break}S+=k,A=h,_=d,d=h=gi.lastIndex;continue}if(ys.lastIndex=d,ys.test(e)){if(S+p>E&&(x=Math.min(x,d)),S+p>i){w=!0;break}S+=p,A=h,_=d,d=h=ys.lastIndex;continue}d+=1}return{width:w?E:S,index:w?x:m,truncated:w,ellipsed:w&&i>=s}},Dh,Le=(e,t={})=>Il(e,Dh,t).width,vi="\x1B",Ml="",Uh=39,$s="\x07",Ol="[",jh="]",Cl="m",_s,$l,Gh=(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},_l=(e)=>`${vi}${Ol}${e}${Cl}`,El=(e)=>`${vi}${_s}${e}${$s}`,Bh=(e)=>e.map((t)=>Le(t)),bs=(e,t,n)=>{let i=t[Symbol.iterator](),r=!1,s=!1,o=e.at(-1),a=o===void 0?0:Le(o),l=i.next(),c=i.next(),p=0;for(;!l.done;){let u=l.value,f=Le(u);a+f<=n?e[e.length-1]+=u:(e.push(u),a=0),(u===vi||u===Ml)&&(r=!0,s=t.startsWith(_s,p+1)),r?s?u===$s&&(r=!1,s=!1):u===Cl&&(r=!1):(a+=f,a===n&&!c.done&&(e.push(""),a=0)),l=c,c=i.next(),p+=u.length}o=e.at(-1),!a&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Vh=(e)=>{let t=e.split(" "),n=t.length;for(;n>0&&!(Le(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Hh=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let i="",r,s,o=e.split(" "),a=Bh(o),l=[""];for(let[h,d]of o.entries()){n.trim!==!1&&(l[l.length-1]=(l.at(-1)??"").trimStart());let m=Le(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(""),bs(l,d,t);continue}if(m+a[h]>t&&m>0&&a[h]>0){if(n.wordWrap===!1&&m<t){bs(l,d,t);continue}l.push("")}if(m+a[h]>t&&n.wordWrap===!1){bs(l,d,t);continue}l[l.length-1]+=d}n.trim!==!1&&(l=l.map((h)=>Vh(h)));let c=l.join(`
|
|
28
|
+
`),p=c[Symbol.iterator](),u=p.next(),f=p.next(),g=0;for(;!u.done;){let h=u.value,d=f.value;if(i+=h,h===vi||h===Ml){$l.lastIndex=g+1;let v=$l.exec(c)?.groups;if(v?.code!==void 0){let w=Number.parseFloat(v.code);r=w===Uh?void 0:w}else v?.uri!==void 0&&(s=v.uri.length===0?void 0:v.uri)}let m=r?Gh(r):void 0;d===`
|
|
29
|
+
`?(s&&(i+=El("")),r&&m&&(i+=_l(m))):h===`
|
|
30
|
+
`&&(r&&m&&(i+=_l(r)),s&&(i+=El(s))),g+=h.length,u=f,f=p.next()}return i},Kh=(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}},vs=(e)=>{let{cursor:t,options:n,style:i}=e,r=e.output??process.stdout,s=fn(r),o=e.columnPadding??0,a=e.rowPadding??4,l=s-o,c=ds(r),p=T.default.dim("..."),u=e.maxItems??Number.POSITIVE_INFINITY,f=Math.max(c-a,0),g=Math.max(Math.min(u,f),5),h=0;t>=g-3&&(h=Math.max(Math.min(t-g+3,n.length-g),0));let d=g<n.length&&h>0,m=g<n.length&&h+g<n.length,v=Math.min(h+g,n.length),w=[],x=0;d&&x++,m&&x++;let E=h+(d?1:0),A=v-(m?1:0);for(let S=E;S<A;S++){let k=gn(i(n[S],S===t),l,{hard:!0,trim:!1}).split(`
|
|
31
|
+
`);w.push(k),x+=k.length}if(x>f){let S=0,k=0,R=x,U=t-E,q=(P,C)=>Kh(w,R,P,C,f);d?({lineCount:R,removals:S}=q(0,U),R>f&&({lineCount:R,removals:k}=q(U+1,w.length))):({lineCount:R,removals:k}=q(U+1,w.length),R>f&&({lineCount:R,removals:S}=q(0,U))),S>0&&(d=!0,w.splice(0,S)),k>0&&(m=!0,w.splice(w.length-k,k))}let _=[];d&&_.push(p);for(let S of w)for(let k of S)_.push(k);return m&&_.push(p),_},Es=(e)=>{let t=e.active??"Yes",n=e.inactive??"No";return new ps({active:t,inactive:n,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=`${T.default.gray(K)}
|
|
32
|
+
${xi(this.state)} ${e.message}
|
|
33
|
+
`,r=this.value?t:n;switch(this.state){case"submit":return`${i}${T.default.gray(K)} ${T.default.dim(r)}`;case"cancel":return`${i}${T.default.gray(K)} ${T.default.strikethrough(T.default.dim(r))}
|
|
34
|
+
${T.default.gray(K)}`;default:return`${i}${T.default.cyan(K)} ${this.value?`${T.default.green(xs)} ${t}`:`${T.default.dim(wi)} ${T.default.dim(t)}`} ${T.default.dim("/")} ${this.value?`${T.default.dim(wi)} ${T.default.dim(n)}`:`${T.default.green(xs)} ${n}`}
|
|
35
|
+
${T.default.cyan(qt)}
|
|
36
|
+
`}}}).prompt()},mn=(e,t)=>e.split(`
|
|
37
37
|
`).map((n)=>t(n)).join(`
|
|
38
|
-
`),
|
|
39
|
-
${T.default.reset(T.default.dim(`Press ${T.default.gray(T.default.bgWhite(T.default.inverse(" space ")))} to select, ${T.default.gray(T.default.bgWhite(T.default.inverse(" enter ")))} to submit`))}`},render(){let i=
|
|
38
|
+
`),Wh=(e)=>{let t=(i,r)=>{let s=i.label??String(i.value);return r==="disabled"?`${T.default.gray(vl)} ${mn(s,(o)=>T.default.strikethrough(T.default.gray(o)))}${i.hint?` ${T.default.dim(`(${i.hint??"disabled"})`)}`:""}`:r==="active"?`${T.default.cyan(Ih)} ${s}${i.hint?` ${T.default.dim(`(${i.hint})`)}`:""}`:r==="selected"?`${T.default.green(xl)} ${mn(s,T.default.dim)}${i.hint?` ${T.default.dim(`(${i.hint})`)}`:""}`:r==="cancelled"?`${mn(s,(o)=>T.default.strikethrough(T.default.dim(o)))}`:r==="active-selected"?`${T.default.green(xl)} ${s}${i.hint?` ${T.default.dim(`(${i.hint})`)}`:""}`:r==="submitted"?`${mn(s,T.default.dim)}`:`${T.default.dim(vl)} ${mn(s,T.default.dim)}`},n=e.required??!0;return new ms({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
|
+
${T.default.reset(T.default.dim(`Press ${T.default.gray(T.default.bgWhite(T.default.inverse(" space ")))} to select, ${T.default.gray(T.default.bgWhite(T.default.inverse(" enter ")))} to submit`))}`},render(){let i=ht(e.output,e.message,`${Tl(this.state)} `,`${xi(this.state)} `),r=`${T.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(T.default.dim(", "))||T.default.dim("none"),l=
|
|
42
|
-
${T.default.gray(
|
|
43
|
-
`).map((u,f)=>f===0?`${T.default.yellow(
|
|
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(T.default.dim(", "))||T.default.dim("none"),l=ht(e.output,a,`${T.default.gray(K)} `);return`${r}${l}`}case"cancel":{let a=this.options.filter(({value:c})=>s.includes(c)).map((c)=>t(c,"cancelled")).join(T.default.dim(", "));if(a.trim()==="")return`${r}${T.default.gray(K)}`;let l=ht(e.output,a,`${T.default.gray(K)} `);return`${r}${l}
|
|
42
|
+
${T.default.gray(K)}`}case"error":{let a=`${T.default.yellow(K)} `,l=this.error.split(`
|
|
43
|
+
`).map((u,f)=>f===0?`${T.default.yellow(qt)} ${T.default.yellow(u)}`:` ${u}`).join(`
|
|
44
44
|
`),c=r.split(`
|
|
45
45
|
`).length,p=l.split(`
|
|
46
|
-
`).length+1;return`${r}${a}${
|
|
46
|
+
`).length+1;return`${r}${a}${vs({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:a.length,rowPadding:c+p,style:o}).join(`
|
|
47
47
|
${a}`)}
|
|
48
48
|
${l}
|
|
49
|
-
`}default:{let a=`${T.default.cyan(
|
|
50
|
-
`).length;return`${r}${a}${
|
|
49
|
+
`}default:{let a=`${T.default.cyan(K)} `,l=r.split(`
|
|
50
|
+
`).length;return`${r}${a}${vs({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
|
-
${T.default.cyan(
|
|
53
|
-
`}}}}).prompt()},
|
|
54
|
-
`),s=r.reduce((l,c)=>Math.max(
|
|
55
|
-
`).map(s),""],a=
|
|
56
|
-
`),p=r?`${T.default.gray(
|
|
57
|
-
`:"",u=r?
|
|
52
|
+
${T.default.cyan(qt)}
|
|
53
|
+
`}}}}).prompt()},Jh=(e)=>T.default.dim(e),Yh=(e,t,n)=>{let i={hard:!0,trim:!1},r=gn(e,t,i).split(`
|
|
54
|
+
`),s=r.reduce((l,c)=>Math.max(Le(c),l),0),o=r.map(n).reduce((l,c)=>Math.max(Le(c),l),0),a=t-(o-s);return gn(e,a,i)},zh=(e="",t="",n)=>{let i=n?.output??be.stdout,r=(n?.withGuide??Ne.withGuide)!==!1,s=n?.format??Jh,o=["",...Yh(e,fn(i)-6,s).split(`
|
|
55
|
+
`).map(s),""],a=Le(t),l=Math.max(o.reduce((f,g)=>{let h=Le(g);return h>f?h:f},0),a)+2,c=o.map((f)=>`${T.default.gray(K)} ${f}${" ".repeat(l-Le(f))}${T.default.gray(K)}`).join(`
|
|
56
|
+
`),p=r?`${T.default.gray(K)}
|
|
57
|
+
`:"",u=r?Oh:Nh;i.write(`${p}${T.default.green(Ss)} ${T.default.reset(t)} ${T.default.gray(Sl.repeat(Math.max(l-a-1,1))+Mh)}
|
|
58
58
|
${c}
|
|
59
|
-
${T.default.gray(u+
|
|
60
|
-
`)},
|
|
61
|
-
`);let C=
|
|
62
|
-
`);C.length>1&&n.write(
|
|
63
|
-
`);let L=0,
|
|
64
|
-
`):n.write(`${
|
|
65
|
-
`)),S(),p()};return{start:q,stop:(C="")=>P(C,0),message:(C="")=>{h=R(C??h)},cancel:(C="")=>P(C,1),error:(C="")=>P(C,2),clear:()=>P("",0,!0),get isCancelled(){return
|
|
59
|
+
${T.default.gray(u+Sl.repeat(l+2)+Ch)}
|
|
60
|
+
`)},Xh,Nl=({indicator:e="dots",onCancel:t,output:n=process.stdout,cancelMessage:i,errorMessage:r,frames:s=ws?["◒","◐","◓","◑"]:["•","o","O","0"],delay:o=ws?80:120,signal:a,...l}={})=>{let c=kh(),p,u,f=!1,g=!1,h="",d,m=performance.now(),v=fn(n),w=l?.styleFrame??Xh,x=(C)=>{let L=C>1?r??Ne.messages.error:i??Ne.messages.cancel;g=C===1,f&&(P(L,C),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(d===void 0)return;c&&n.write(`
|
|
61
|
+
`);let C=gn(d,v,{hard:!0,trim:!1}).split(`
|
|
62
|
+
`);C.length>1&&n.write(hn.cursor.up(C.length-1)),n.write(hn.cursor.to(0)),n.write(hn.erase.down())},R=(C)=>C.replace(/\.+$/,""),U=(C)=>{let L=(performance.now()-C)/1000,J=Math.floor(L/60),ye=Math.floor(L%60);return J>0?`[${J}m ${ye}s]`:`[${ye}s]`},q=(C="")=>{f=!0,p=wl({output:n}),h=R(C),m=performance.now(),n.write(`${T.default.gray(K)}
|
|
63
|
+
`);let L=0,J=0;_(),u=setInterval(()=>{if(c&&h===d)return;k(),d=h;let ye=w(s[L]),We;if(c)We=`${ye} ${h}...`;else if(e==="timer")We=`${ye} ${h} ${U(m)}`;else{let Rm=".".repeat(Math.floor(J)).slice(0,3);We=`${ye} ${h}${Rm}`}let Nm=gn(We,v,{hard:!0,trim:!1});n.write(Nm),L=L+1<s.length?L+1:0,J=J<4?J+0.125:0},o)},P=(C="",L=0,J=!1)=>{if(!f)return;f=!1,clearInterval(u),k();let ye=L===0?T.default.green(Ss):L===1?T.default.red(Al):T.default.red(kl);h=C??h,J||(e==="timer"?n.write(`${ye} ${h} ${U(m)}
|
|
64
|
+
`):n.write(`${ye} ${h}
|
|
65
|
+
`)),S(),p()};return{start:q,stop:(C="")=>P(C,0),message:(C="")=>{h=R(C??h)},cancel:(C="")=>P(C,1),error:(C="")=>P(C,2),clear:()=>P("",0,!0),get isCancelled(){return g}}},t2,bi=(e,t)=>e.includes(`
|
|
66
66
|
`)?e.split(`
|
|
67
67
|
`).map((n)=>t(n)).join(`
|
|
68
|
-
`):t(e),
|
|
68
|
+
`):t(e),yn=(e)=>{let t=(n,i)=>{let r=n.label??String(n.value);switch(i){case"disabled":return`${T.default.gray(wi)} ${bi(r,T.default.gray)}${n.hint?` ${T.default.dim(`(${n.hint??"disabled"})`)}`:""}`;case"selected":return`${bi(r,T.default.dim)}`;case"active":return`${T.default.green(xs)} ${r}${n.hint?` ${T.default.dim(`(${n.hint})`)}`:""}`;case"cancelled":return`${bi(r,(s)=>T.default.strikethrough(T.default.dim(s)))}`;default:return`${T.default.dim(wi)} ${bi(r,T.default.dim)}`}};return new hs({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=`${xi(this.state)} `,i=`${Tl(this.state)} `,r=ht(e.output,e.message,i,n),s=`${T.default.gray(K)}
|
|
69
69
|
${r}
|
|
70
|
-
`;switch(this.state){case"submit":{let o=`${T.default.gray(
|
|
71
|
-
${T.default.gray(
|
|
72
|
-
`).length;return`${s}${o}${
|
|
70
|
+
`;switch(this.state){case"submit":{let o=`${T.default.gray(K)} `,a=ht(e.output,t(this.options[this.cursor],"selected"),o);return`${s}${a}`}case"cancel":{let o=`${T.default.gray(K)} `,a=ht(e.output,t(this.options[this.cursor],"cancelled"),o);return`${s}${a}
|
|
71
|
+
${T.default.gray(K)}`}default:{let o=`${T.default.cyan(K)} `,a=s.split(`
|
|
72
|
+
`).length;return`${s}${o}${vs({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
|
-
${T.default.cyan(
|
|
75
|
-
`}}}}).prompt()},
|
|
76
|
-
`:""}${
|
|
77
|
-
`,i=e.placeholder?T.default.inverse(e.placeholder[0])+T.default.dim(e.placeholder.slice(1)):T.default.inverse(T.default.hidden("_")),r=this.userInput?this.userInputWithCursor:i,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${T.default.yellow(this.error)}`:"",a=t?`${T.default.yellow(
|
|
74
|
+
${T.default.cyan(qt)}
|
|
75
|
+
`}}}}).prompt()},n2,As=(e)=>new pn({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??Ne.withGuide)!==!1,n=`${`${t?`${T.default.gray(K)}
|
|
76
|
+
`:""}${xi(this.state)} `}${e.message}
|
|
77
|
+
`,i=e.placeholder?T.default.inverse(e.placeholder[0])+T.default.dim(e.placeholder.slice(1)):T.default.inverse(T.default.hidden("_")),r=this.userInput?this.userInputWithCursor:i,s=this.value??"";switch(this.state){case"error":{let o=this.error?` ${T.default.yellow(this.error)}`:"",a=t?`${T.default.yellow(K)} `:"",l=t?T.default.yellow(qt):"";return`${n.trim()}
|
|
78
78
|
${a}${r}
|
|
79
79
|
${l}${o}
|
|
80
|
-
`}case"submit":{let o=s?` ${T.default.dim(s)}`:"",a=t?T.default.gray(
|
|
81
|
-
${a}`:""}`}default:{let o=t?`${T.default.cyan(
|
|
80
|
+
`}case"submit":{let o=s?` ${T.default.dim(s)}`:"",a=t?T.default.gray(K):"";return`${n}${a}${o}`}case"cancel":{let o=s?` ${T.default.strikethrough(T.default.dim(s))}`:"",a=t?T.default.gray(K):"";return`${n}${a}${o}${s.trim()?`
|
|
81
|
+
${a}`:""}`}default:{let o=t?`${T.default.cyan(K)} `:"",a=t?T.default.cyan(qt):"";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 Ee=I(()=>{mi();mi();T=Ft(cn(),1),hn=Ft(ns(),1);ws=Ah(),Th=Y("◆","*"),Al=Y("■","x"),kl=Y("▲","x"),Ss=Y("◇","o"),Kk=Y("┌","T"),K=Y("│","|"),qt=Y("└","—"),Wk=Y("┐","T"),Jk=Y("┘","—"),xs=Y("●",">"),wi=Y("○"," "),Ih=Y("◻","[•]"),xl=Y("◼","[+]"),vl=Y("◻","[ ]"),Yk=Y("▪","•"),Sl=Y("─","-"),Mh=Y("╮","+"),Oh=Y("├","+"),Ch=Y("╯","+"),Nh=Y("╰","+"),zk=Y("╭","+"),Xk=Y("●","•"),Qk=Y("◆","*"),Zk=Y("▲","!"),e2=Y("■","x"),gs=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,hi=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,gi=/\t{1,1000}/y,ys=/[\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,yi=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Fh=/\p{M}+/gu,qh={limit:1/0,ellipsis:""},Dh={limit:1/0,ellipsis:"",ellipsisWidth:0},_s=`${jh}8;;`,$l=new RegExp(`(?:\\${Ol}(?<code>\\d+)m|\\${_s}(?<uri>.*)${$s})`,"y");Xh=T.default.magenta,t2={light:Y("─","-"),heavy:Y("━","="),block:Y("█","#")},n2=`${T.default.gray(K)} `});async function Ae(e){if(!Q())return;let{defaultValue:t,message:n}=e,i=await Promise.resolve().then(() => (Ee(),{})),r=await As({message:n,default:t,placeholder:t});if(typeof r==="symbol")return;return r}function Qh(e){if(e.length<=Rl)return e;return`${e.slice(0,Rl)}.... (${e.length} chars)`}async function Ll(e){if(!Q())return;await Promise.resolve().then(() => mi());let n=await new pn({render(){let i=Qh(this.userInput),r=ue.default.inverse(ue.default.hidden("_")),s=ue.default.gray("│");switch(this.state){case"submit":return`${s}
|
|
84
|
+
${ue.default.green("◇")} ${e.message}
|
|
85
|
+
${s} ${ue.default.dim(i)}`;case"cancel":return`${s}
|
|
86
|
+
${ue.default.red("■")} ${e.message}
|
|
87
|
+
${s} ${ue.default.strikethrough(ue.default.dim(i))}`;case"error":return`${s}
|
|
88
|
+
${ue.default.yellow("▲")} ${e.message}
|
|
89
|
+
${ue.default.yellow("│")} ${i}${r}
|
|
90
|
+
${ue.default.yellow("└")} ${ue.default.yellow(this.error)}`;default:return`${s}
|
|
91
|
+
${ue.default.cyan("◆")} ${e.message}
|
|
92
|
+
${ue.default.cyan("│")} ${i}${r}
|
|
93
|
+
${ue.default.cyan("└")}`}}}).prompt();if(typeof n==="symbol")return;return n}async function Pl(e,t){if(!Q())return t();await Promise.resolve().then(() => Ee());let i=Nl();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 bn(e){if(!Q())return;let{message:t}=e,n=await Promise.resolve().then(() => (Ee(),{})),i=await Es({message:t});if(typeof i==="symbol")return;return i}async function gt(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{}));zh(e.message,e.title)}async function Si(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await yn({message:e.message,options:e.choices,initialValue:e.initialValue});if(typeof n==="symbol")return;return n}async function ks(e){if(!Q())return;let t=await Promise.resolve().then(() => (Ee(),{})),n=await Wh({message:e.message,options:e.choices,initialValues:e.initialValues,required:e.required});if(typeof n==="symbol")return;return n}function yt(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.`,
|
|
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 Dt(e){if(e.value)return e.value;if(Q({nonInteractive:e.nonInteractive})){let t=await Ae({message:e.message});if(!t)process.stderr.write(e.cancelMessage+`
|
|
96
|
+
`),process.exit(1);return t}yt(e.flagName,e.usageHint)}var ue,Rl=30;var Pe=I(()=>{G();j();ue=Ft(cn(),1)});function me(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}async function ql(e){let t=si[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:Fl,scope:eg.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);ng(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: ${Zh}
|
|
100
100
|
`),process.stderr.write(`Waiting for authorization...
|
|
101
|
-
`);let c=l.expired_in,p=l.interval||3000;while(Date.now()<c){await
|
|
102
|
-
${
|
|
103
|
-
`)});function
|
|
101
|
+
`);let c=l.expired_in,p=l.interval||3000;while(Date.now()<c){await tg(p);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:Fl,user_code:l.user_code,code_verifier:r})});if(!u.ok)throw new y(`Device-code authorization failed (HTTP ${u.status}).`,b.AUTH);let f=await u.json();if(f.status==="pending")continue;if(f.status==="success"&&f.access_token)return{access_token:f.access_token,refresh_token:f.refresh_token??"",expires_at:new Date(f.expired_in??Date.now()).toISOString(),region:e,resource_url:f.resource_url};throw new y(`Device-code authorization failed: ${f.status}`,b.AUTH)}throw new y("Device-code authorization timed out.",b.TIMEOUT)}function tg(e){return new Promise((t)=>setTimeout(t,e))}function ng(e){let{execFile:t,spawn:n}=an("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 Fl="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Zh="MiniMax CLI",eg;var Dl=I(()=>{$e();G();j();eg=["openid","profile","coding_plan"]});async function he(){return Z().oauth??null}async function $i(e,t=fe()){let n=Z(t);n.oauth=e,await de(n,void 0,t)}async function Ul(){let e=Z();if(!("oauth"in e))return;delete e.oauth,await de(e)}var Ze=I(()=>{Ce();Xe()});function _i(e){return`Looked for credentials in: ${e??fe()}
|
|
102
|
+
${ig}`}var ig;var Ts=I(()=>{Xe();ig=["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 Ut(e){return e.replace(/^https?:\/\//,"")}async function Gl(e){if(e.apiKey||e.fileApiKey)return;if(await he())return;let t=process.env.MINIMAX_API_KEY;if(t){if(!Q({nonInteractive:e.nonInteractive}))return;if(await bn({message:`Found MINIMAX_API_KEY in environment (${me(t)}). Save to config file?`}))await jl(e,t);return}if(!Q({nonInteractive:e.nonInteractive}))throw new y("No credentials found.",b.AUTH,_i(e.configPath));let n=await Is();if(n==="api-key"){let i=await Ae({message:"Enter your MiniMax API key:"});if(!i)throw new y("API key is required.",b.AUTH);await jl(e,i);return}await Ms(n==="oauth-cn"?"cn":"global")}async function Is(){await Promise.resolve().then(() => Ee());let n=await yn({message:"How would you like to authenticate?",options:rg.map((i)=>({value:i.value,label:i.label}))});if(Re(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Bl(){await Promise.resolve().then(() => Ee());let n=await yn({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${Ut(ne.global)}`},{value:"cn",label:`China → ${Ut(ne.cn)}`}]});if(Re(n))throw new y("Authentication cancelled.",b.AUTH);return n}async function Ms(e){let t=await ql(e),n=Z();delete n.api_key,n.oauth=t,n.region=e,await de(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 jl(e,t){let n={...Z(),api_key:t};await de(n),e.fileApiKey=t,process.stderr.write(`API key saved to ${e.configPath??"~/.mmx/config.json"}
|
|
106
|
+
`)}var rg;var Os=I(()=>{$e();Ce();Pe();G();j();Dl();Ze();Ts();rg=[{value:"oauth-global",label:`MiniMax (OAuth login → ${Ut(ne.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${Ut(ne.cn)})`},{value:"api-key",label:`API key (${Ut(ne.global)} or ${Ut(ne.cn)})`}]});import{resolve as sg}from"path";async function Ns(e,t="global"){let n=`${si[t]}/oauth2/token`,i=null;for(let r=0;r<=Vl;r++){if(r>0)await new Promise((a)=>setTimeout(a,ag*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:og}),signal:AbortSignal.timeout(lg)})}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 ${Vl+1} attempts: ${i?.message}`,b.AUTH,`Check your network connection.
|
|
107
|
+
Re-authenticate: mmx auth login`)}async function Hl(e){let t=new Date(e.expires_at).getTime();if(Date.now()<t-cg)return e.access_token;let n=sg(fe()),i=JSON.stringify([n,e.region??"global",e.refresh_token]),r=Cs.get(i);if(r)return r;let s=(async()=>{let o=await Ns(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 $i(a,n),a.access_token})();Cs.set(i,s);try{return await s}finally{Cs.delete(i)}}var og="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Vl=2,ag=500,lg=1e4,cg=300000,Cs;var Rs=I(()=>{$e();Xe();Ze();G();j();Cs=new Map});async function jt(e){if(e.apiKey)return{token:e.apiKey,method:"api-key",source:"flag"};let t=await he();if(t)return{token:await Hl(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,_i(e.configPath))}var Ei=I(()=>{Ze();Rs();G();j();Ts()});function Kl(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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function Ls(e){return`${e?.includes("api.minimax.cn")||e?.includes("api.minimaxi.com")?"https://platform.minimax.cn":"https://platform.minimax.io"}/subscribe/token-plan`}function ug(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 wn(e,t,n){let i=fg(e,t,n),r=n?.includes("/v1/images/")?ug(t):void 0;if(!r)return i;return new y(i.message,i.exitCode,i.hint?`${r}
|
|
115
|
+
${i.hint}`:r)}function fg(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
|
+
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: ${Ls(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=Kl(n);return new y(`Quota exhausted. ${i}`,b.QUOTA,`Check usage: mmx quota show${l}
|
|
118
|
+
Upgrade plan: ${Ls(n)}`)}if(s===2061){let l=Kl(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: ${Ls(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 Ps=I(()=>{G();j()});import{homedir as Wl}from"os";function yg(e){return e.startsWith(Wl())?e.replace(Wl(),"~"):e}function bg(e){return e.replace(/^https?:\/\//,"")}function Yl(e,t,n){if(e.quiet||Jl||!process.stderr.isTTY)return;Jl=!0;let i=e.configPath?yg(e.configPath):"~/.mmx/config.json",r=bg(e.baseUrl),s=e.apiKey?"(flag)":"(file)",o=me(t),a=n?` ${et}|${we} ${et}Model:${we} ${mg}${n}${we}`:"";process.stderr.write(`${dg}${pg}MINIMAX${we} ${et}${i}${we} ${et}|${we} ${et}URL:${we} ${hg}${r}${we} ${et}|${we} ${et}Key:${we} ${gg}${o}${we} ${et}${s}${we}${a}
|
|
120
|
+
`)}var Jl=!1,we="\x1B[0m",et="\x1B[2m",dg="\x1B[1m",pg="\x1B[38;2;43;82;255m",mg="\x1B[38;2;147;51;234m",hg="\x1B[38;2;6;184;212m",gg="\x1B[38;2;236;72;153m";var zl=()=>{};var Xl=()=>{};var bt="1.0.30";var Ai=I(()=>{Xl()});function Ql(e){return new DOMException(e,"TimeoutError")}function wg(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 p;try{let u=await new Promise((f,g)=>{p=setTimeout(()=>{let h=Ql(`Stream received no data for ${t}ms.`);n.abort(h),g(h)},t),i.read().then(f,g)});if(u.done)s(),c.close();else c.enqueue(u.value)}catch(u){await o(u).catch(()=>{}),c.error(u)}finally{if(p)clearTimeout(p)}},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 Fe(e,t){let n=typeof FormData<"u"&&t.body instanceof FormData,i={"User-Agent":`mmx-cli/${bt}`,...t.headers};if(!n&&!i["Content-Type"])i["Content-Type"]="application/json";if(!t.noAuth){let l=await jt(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}
|
|
118
121
|
`),process.stderr.write(`> Auth: ${l.token.slice(0,8)}...
|
|
119
|
-
`);let c=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;
|
|
120
|
-
`);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;Yl(e,l.token,c)}let r=(t.timeout??e.timeout)*1000,s=t.stream?new AbortController:void 0,o=s?setTimeout(()=>{s.abort(Ql(`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=wg(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 wn(a.status,l,t.url)}return a}async function D(e,t){let n=await Fe(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 wn(200,{base_resp:i.base_resp},t.url);return i}var oe=I(()=>{G();j();Ei();Ps();zl();Ai()});function ki(e){return`${e}/anthropic/v1/messages`}function Zl(e){return`${e}/v1/t2a_v2`}function ec(e){return`${e}/v1/speech_to_text`}function tc(e){return`${e}/v1/get_voice`}function nc(e){return`${e}/v1/image_generation`}function ic(e){return`${e}/v1/images/generations`}function rc(e){return`${e}/v1/images/edits`}function sc(e){return`${e}/v1/video_generation`}function oc(e){return`${e}/v2/video_generation`}function Ti(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function Ii(e,t){return`${e}/v2/query/video_generation/${t}`}function Mi(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function ac(e){return`${e}/v1/coding_plan/search`}function lc(e){return`${e}/v1/coding_plan/vlm`}function xn(e){return`${e}/v1/token_plan/remains`}function xg(e){return`${e}/account/query_balance`}function Fs(e){return e.startsWith("sk-api-")}function qs(e,t){if(t.method==="api-key"&&Fs(t.token))return{url:xg(e),kind:"account-balance"};return{url:xn(e),kind:"quota"}}function tt(e,t){return qs(e,{token:t,method:"api-key"}).url}function cc(e){return`${e}/v1/files/upload`}function uc(e){return`${e}/v1/files/list`}function fc(e){return`${e}/v1/files/delete`}function vg(e){return e?"on":"off"}function dc(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: ${vg(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Oi(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 vc(e){if(e>=50)return[yc,wc];if(e>=20)return[_g,Eg];return[bc,Ag]}function Mg(e,t){if(t!=="cn")return e;return Ig[e]??e}function Og(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 Cg(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 pc(e){return new Date(e).toISOString().slice(0,10)}function Ng(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function xe(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),n=0;for(let i of t)n+=Ng(i.codePointAt(0))?2:1;return n}function Pg(e){return e===3}function Fg(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 Ds(e){return Math.max(0,Math.min(Lg,Math.round(e)))}function qg(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Dg(e,t,n,i){let r=qg(i);if(e!==void 0&&e!==null)return Ds(e*r);return n>0?Ds(t/n*100*r):0}function Ug(e,t,n=Rg,i=!0){let r=Ds(e),s=Math.min(1,r/100),o=Math.round(n*s),a=n-o,l=`${r}%`.padStart(4);if(!t){let f=`[${"█".repeat(o)}${".".repeat(a)}]`;return i?`${f} ${l}`:f}let[c,p]=vc(r),u=`${p}${" ".repeat(o)}${te}${xc}${" ".repeat(a)}${te}`;return i?`${u} ${c}${Sn}${l}${te}`:u}function mc(e,t,n,i,r,s,o,a){if(o){let f=(a??jg).padStart(4);if(r){let h=`${wc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${h} ${yc}${Sn}${f}${te}`}let g=`[${"█".repeat(vn)}]`;return`${e} ${g} ${f}`}let l=Dg(i,t,n,s),c=Oi(t,n,i),p=Ug(l,r,vn,c===void 0);if(c){let u=`${c.remaining.toLocaleString()} / ${c.total.toLocaleString()}`;return r?`${ke}${e}${te} ${p} ${vc(l)[0]}${u}${te}`:`${e} ${p} ${u}`}return`${e} ${p}`}function hc(e,t,n){if(n){let i=`${xc}${" ".repeat(vn)}${te}`;return`${ke}${e}${te} ${i} ${bc}${Sn}${t}${te}`}return`${e} [${".".repeat(vn)}] ${t}`}function Ci(e,t,n,i,r,s,o){if(s===void 0||o===void 0)return r?`${ke}${t}${n.repeat(e)}${i}${te}`:`+${"-".repeat(e)}+`;return r?`${ke}${t}${n.repeat(s-1)}${o}${n.repeat(e-s)}${i}${te}`:`+${"-".repeat(s-1)}+${"-".repeat(e-s)}+`}function gc(e,t,n,i){let r=Math.max(0,t-2-n);return i?`${ke}│${te} ${e}${" ".repeat(r)} ${ke}│${te}`:`| ${e}${" ".repeat(r)} |`}function Sc(e,t){let n=!t.noColor&&process.stdout.isTTY===!0,i=t.region==="cn"?Tg:kg,r=e.map((w)=>{let x=Mg(w.model_name,t.region),E=Fg(w),A=E?hc(i.current,i.notInPlan,n):mc(i.current,w.current_interval_usage_count,w.current_interval_total_count,w.current_interval_remaining_percent,n),_=E?hc(i.weekly,i.notInPlan,n):mc(i.weekly,w.current_weekly_usage_count,w.current_weekly_total_count,w.current_weekly_remaining_percent,n,w.weekly_boost_permille,Pg(w.current_weekly_status),t.region==="cn"?Gg:Bg),S=E?"":Cg(w.end_time-w.start_time),k=S?`${S} ${i.resetsIn}`:i.resetsIn,R=E?"—":Og(w.remains_time,i.now),U=n?`${ke}${k}${te} ${R}`:`${k} ${R}`;return{displayName:x,current:A,weekly:_,reset:U}}),s=Math.max(6,...r.map((w)=>xe(w.displayName))),o=Math.max(...r.map((w)=>xe(w.current)),18),a=Math.max(...r.map((w)=>xe(w.weekly)),18),l=Math.max(...r.map((w)=>xe(w.reset)),10),c=s+2+o+2+a,p=c+3+l+2;if(p<72)c+=72-p,p=72;let u=c+3,f=e.length>0?`${pc(e[0].weekly_start_time)} — ${pc(e[0].weekly_end_time)}`:"",g=`MINIMAX ${i.dashboard}`,h=`${i.week}: ${f}`,d=Math.max(2,p-2-xe(g)-xe(h)),m=n?`${Sn}${Sg}MINIMAX${te} ${ke}${i.dashboard}${te}${" ".repeat(d)}${ke}${i.week}:${te} ${$g}${f}${te}`:`${g}${" ".repeat(d)}${h}`,v=xe(g)+d+xe(h);if(console.log(""),console.log(Ci(p,"╭","─","╮",n)),console.log(gc(m,p,v,n)),e.length===0){console.log(Ci(p,"╰","─","╯",n)),console.log(`
|
|
121
124
|
${i.noData}
|
|
122
|
-
`);return}r.forEach((
|
|
123
|
-
`);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.",
|
|
124
|
-
`),r}async function
|
|
125
|
+
`);return}r.forEach((w,x)=>{console.log(Ci(p,"├","─","┤",n,u,x===0?"┬":"┼"));let A=`${n?`${Sn}${w.displayName}${te}`:w.displayName}${" ".repeat(Math.max(1,s-xe(w.displayName)+2))}${w.current}${" ".repeat(Math.max(1,o-xe(w.current)+2))}`+w.weekly,_=n?`${ke}│${te}`:"|",S=`${A}${" ".repeat(Math.max(0,c-xe(A)))} ${_} ${w.reset}`;console.log(gc(S,p,xe(S),n))}),console.log(Ci(p,"╰","─","╯",n,u,"┴")),console.log("")}var te="\x1B[0m",Sn="\x1B[1m",ke="\x1B[2m",Sg="\x1B[38;2;43;82;255m",$g="\x1B[38;2;6;184;212m",yc="\x1B[38;2;74;222;128m",_g="\x1B[38;2;250;204;21m",bc="\x1B[38;2;248;113;113m",wc="\x1B[48;2;22;163;74m",Eg="\x1B[48;2;202;138;4m",Ag="\x1B[48;2;220;38;38m",xc="\x1B[48;2;55;65;81m",kg,Tg,Ig,Rg=16,vn=10,Lg=200,jg="∞",Gg="无限",Bg="unlimited";var $c=I(()=>{kg={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now",notInPlan:"not in plan"},Tg={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将",notInPlan:"不在当前套餐中"},Ig={general:"通用",video:"视频"}});function Je(e,t,n){if(n&&Fs(n)){dc(e,t);return}Sc(e.model_remains||[],t)}var Ni=I(()=>{$c()});async function Vg(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 Ri(e){process.stderr.write("Detecting region...");let t=Object.keys(ne),n=await Promise.all(t.map(async(s)=>({region:s,result:await Vg(s,e,5000)}))),i=n.find((s)=>s.result==="authorized");if(!i){process.stderr.write(` failed
|
|
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 _c(e){let t=Z();t.region=e,await de(t)}var Us=I(()=>{$e();Ce();G();j()});function Hg(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 Kg(e){try{let t=e.apiKey||e.fileApiKey;if(t&&t.startsWith("sk-api-")){let r=tt(e.baseUrl,t),s=await D(e,{url:r});Je(s,e,t);return}let n=xn(e.baseUrl),i=await D(e,{url:n});Je(i,e)}catch{}}async function kc(e){await Promise.resolve().then(() => Li());Te.printHelp([],process.stderr,e.region),await Kg(e)}async function Ec(e,t){await Ms(t);let n=Z(),i={...e,region:t,baseUrl:n.oauth?.resource_url||ne[t]};await kc(i)}async function Ac(e,t,n){if(e.dryRun){console.log("Would validate and save API key.");return}let i=n??await Ri(t),r={...e,region:i,baseUrl:ne[i],apiKey:t},s=tt(r.baseUrl,t);try{await D(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=Hg(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}.
|
|
125
128
|
Saving the explicitly selected region "${i}". Requests may fail until validation succeeds.
|
|
126
|
-
`)}let o=
|
|
127
|
-
`),await
|
|
129
|
+
`)}let o=Z();delete o.oauth,o.api_key=t,o.region=i,await de(o),process.stderr.write(`API key saved to ${fe()}
|
|
130
|
+
`),await kc(r)}var Tc;var Ic=I(()=>{X();G();j();Os();oe();Ni();Us();Xe();Ce();$e();Tc=N({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=me(n);if(Q({nonInteractive:e.nonInteractive})){await Promise.resolve().then(() => Ee());let l=await Es({message:`MINIMAX_API_KEY is set (${s}). Configure persistent credentials anyway?`,initialValue:!1});if(Re(l)||!l)process.stdout.write(`Login skipped. Using environment variable.
|
|
128
131
|
`),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
|
|
129
|
-
`)}if(t.apiKey){await
|
|
130
|
-
`);try{let s=
|
|
131
|
-
Or set $MINIMAX_API_KEY`},n))}}})});var
|
|
132
|
-
`);return}if(n)await
|
|
133
|
-
`);if(r){let s=
|
|
134
|
-
`)}}})});async function*
|
|
132
|
+
`)}if(t.apiKey){await Ac(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 Bl();await Ec(e,s);return}let i=await Is();if(i==="api-key"){await Promise.resolve().then(() => Ee());let a=await As({message:"Paste your MiniMax API key:",validate:(l)=>l&&l.length>0?void 0:"API key cannot be empty."});if(Re(a))throw new y("Authentication cancelled.",b.AUTH);await Ac(e,a,t.region);return}let r=t.region||(i==="oauth-cn"?"cn":"global");await Ec(e,r)}})});var Mc;var Oc=I(()=>{X();Ei();Ze();ee();oe();Ni();Mc=N({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 jt(e),i=F(e.output);if(i!=="text"){let s={method:n.method,source:n.source};if(n.method==="oauth"){let o=await he();if(o){if(s.token_expires=o.expires_at,o.account)s.account=o.account}}else{s.key=me(n.token);let o=tt(e.baseUrl,n.token),a=await D(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: ${me(r)}`),n.method==="oauth"){let s=await he();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 D(e,{url:s});Je(o,e,r)}catch(o){console.log(` Quota fetch failed: ${o.message}`)}return}process.stderr.write(`Fetching quota snapshot...
|
|
133
|
+
`);try{let s=xn(e.baseUrl),o=await D(e,{url:s,method:"GET"});Je(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 Cc;var Nc=I(()=>{X();G();j();Ze();Rs();ee();Cc=N({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let n=await he();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 Ns(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 $i(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 Rc;var Lc=I(()=>{X();Ze();Ce();Rc=N({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 he(),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 Ul(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
|
|
136
|
+
`);if(r){let s=Z();delete s.api_key,await de(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
|
|
137
|
+
`)}}})});async function*qe(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),p=a.slice(l+1).trimStart();switch(c){case"data":r.data=r.data!==void 0?`${r.data}
|
|
135
138
|
${p}`:p;break;case"event":r.event=p;break;case"id":r.id=p;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(`
|
|
136
|
-
`);i=l.pop()||"";for(let c of l){let p=s(c);if(p)yield p}}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
|
|
137
|
-
`),process.exit(1);r=[{role:"user",content:p}]}else
|
|
139
|
+
`);i=l.pop()||"";for(let c of l){let p=s(c);if(p)yield p}}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 De="MiniMax-M3.1-Flash";import{readFileSync as Wg}from"fs";function Jg(e){return e==="-"?0:e}function Pi(e){return Wg(Jg(e),"utf-8")}var js=()=>{};import{readFileSync as Yg}from"fs";function Fc(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 qc{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=Pc[this.frame%Pc.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]=Fc(this.frame*17%360,0.85,0.55),[o,a,l]=Fc((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 zg(e){let t=[],n;if(e.system)n=e.system;if(e.messagesFile){let i=e.messagesFile,r=Pi(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 Xg(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var Pc,Dc;var Uc=I(()=>{X();oe();ee();G();j();js();Pe();Pc=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Dc=N({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: ${De})`},{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 ${De} --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}=zg(t),r=i;if(r.length===0)if(Q({nonInteractive:e.nonInteractive})){let p=await Ae({message:"Enter your message:"});if(!p)process.stderr.write(`Chat cancelled.
|
|
140
|
+
`),process.exit(1);r=[{role:"user",content:p}]}else yt("message","mmx text chat --message <text>");let s=t.model||e.defaultTextModel||De,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 p=t.tool.map((u)=>{try{return JSON.parse(u)}catch{try{let f=Yg(u,"utf-8");return JSON.parse(f)}catch{throw new y(`Invalid tool definition: "${u}" is neither valid JSON nor a readable file.`,b.USAGE)}}});l.tools=p}if(e.dryRun){console.log(O({request:l},o));return}let c=ki(e.baseUrl);if(a){let p=await Fe(e,{url:c,method:"POST",body:l,stream:!0,authStyle:"x-api-key"}),u=p.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 f="",g=!1,h=e.noColor?"":"\x1B[2m",d=e.noColor?"":"\x1B[0m",m=o==="json",w=process.stdout.isTTY&&!m?process.stderr:process.stderr,x=m?void 0:process.stdout,E=new qc(w,e.noColor);for await(let A of qe(p)){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(`${d}
|
|
138
141
|
Response:
|
|
139
|
-
`)}else if(
|
|
140
|
-
${h}[warning] Failed to parse stream chunk: ${
|
|
141
|
-
`)}}if(
|
|
142
|
-
`)}else{let p=await
|
|
142
|
+
`)}else if(_.type==="content_block_delta"){if(_.delta.type==="text_delta")f+=_.delta.text,x?.write(_.delta.text)}}catch(_){process.stderr.write(`
|
|
143
|
+
${h}[warning] Failed to parse stream chunk: ${_ instanceof Error?_.message:String(_)}${d}
|
|
144
|
+
`)}}if(g)E.stop();if(o==="json")console.log(O({content:f},o));else x?.write(`
|
|
145
|
+
`)}else{let p=await D(e,{url:c,method:"POST",body:l,authStyle:"x-api-key"}),u=Xg(p.content);if(e.quiet||o==="text")console.log(u);else console.log(O(p,o))}}})});import{writeFileSync as Qg}from"node:fs";function jc(e){return`\x1B[${e}A`}function Zg(e){return`\x1B[${e}B`}function Gs(e){return`\x1B[${e}G`}function Fi(){return"\x1B[2K"}function ey(){return"\x1B[0J"}function iy(){process.stdout.write(`
|
|
143
146
|
Available commands:
|
|
144
|
-
`);for(let[e,t]of Object.entries(
|
|
147
|
+
`);for(let[e,t]of Object.entries(Vs))process.stdout.write(` ${e.padEnd(Gc+2)} ${t}
|
|
145
148
|
`);process.stdout.write(`
|
|
146
|
-
`)}class
|
|
147
|
-
`){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(
|
|
148
|
-
`),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=
|
|
149
|
-
`,s+=
|
|
150
|
-
`,s+=
|
|
151
|
-
`,n)for(let o of e)s+=
|
|
152
|
-
`;if(r<this.lastTotal)s+=
|
|
149
|
+
`)}class Bc{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(Zg(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=Bs.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("/")?Bs.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+=jc(1);if(s+=Gs(1)+Fi()+this.border()+`
|
|
152
|
+
`,s+=Fi()+"> "+this.buffer+`
|
|
153
|
+
`,s+=Gs(1)+Fi()+this.border()+`
|
|
154
|
+
`,n)for(let o of e)s+=Fi()+` ${this.dim}${o.padEnd(Gc+2)} ${Vs[o]}${this.reset}
|
|
155
|
+
`;if(r<this.lastTotal)s+=ey();s+=jc(i+2),s+=Gs(this.promptLen+this.cursor+1),this.out.write(s),this.lastTotal=r}}var ty="\x1B[?25l",ny="\x1B[?25h",Vs,Bs,Gc,Vc;var Hc=I(()=>{X();oe();G();j();Vs={"/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"},Bs=Object.keys(Vs),Gc=Math.max(...Bs.map((e)=>e.length));Vc=N({name:"text repl",description:"Start an interactive multi-turn chat session",usage:"mmx text repl [flags]",options:[{flag:"--model <model>",description:`Model ID (default: ${De})`},{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 ${De} --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||De,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(`
|
|
153
156
|
${s}MiniMax Chat REPL${i}
|
|
154
157
|
`),process.stdout.write(`${n}Model: ${r.model}${i}
|
|
155
158
|
`),r.system)process.stdout.write(`${n}System: ${r.system.slice(0,80)}${r.system.length>80?"...":""}${i}
|
|
156
159
|
`);process.stdout.write(`${n}Type / to see commands, /exit to quit.${i}
|
|
157
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 p(){if(r.messages.length===0){a.write(`${n}No messages to send. Type something first.${i}
|
|
158
|
-
`);return}let d={model:r.model,messages:r.messages,max_tokens:r.maxTokens,stream:!0};if(r.system)d.system=r.system;if(r.temperature!==void 0)d.temperature=r.temperature;if(r.topP!==void 0)d.top_p=r.topP;l=!0;let
|
|
159
|
-
`);else if(
|
|
161
|
+
`);return}let d={model:r.model,messages:r.messages,max_tokens:r.maxTokens,stream:!0};if(r.system)d.system=r.system;if(r.temperature!==void 0)d.temperature=r.temperature;if(r.topP!==void 0)d.top_p=r.topP;l=!0;let m=ki(e.baseUrl);try{let v=await Fe(e,{url:m,method:"POST",body:d,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 qe(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
|
+
`);else if(_.content_block.type==="text"&&E)a.write(`${i}
|
|
160
163
|
Response:
|
|
161
|
-
`),
|
|
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(`
|
|
162
165
|
`);else a.write(`${n}[empty response]${i}
|
|
163
|
-
`)}catch(
|
|
164
|
-
`)}finally{l=!1,c=0}}function u(d){let
|
|
165
|
-
`),"exit";case"/help":return
|
|
166
|
-
`),"ok";case"/system":{if(
|
|
166
|
+
`)}catch(v){a.write(`${n}[error] ${v instanceof Error?v.message:String(v)}${i}
|
|
167
|
+
`)}finally{l=!1,c=0}}function u(d){let m=d.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 iy(),"ok";case"/clear":return r.messages=[],a.write(`${n}Conversation cleared.${i}
|
|
169
|
+
`),"ok";case"/system":{if(w)r.system=w,a.write(`${n}System prompt set.${i}
|
|
167
170
|
`);else if(r.system)a.write(`${n}System prompt:${i}
|
|
168
171
|
${r.system}
|
|
169
172
|
`);else a.write(`${n}No system prompt set.${i}
|
|
170
|
-
`);return"ok"}case"/model":{if(
|
|
173
|
+
`);return"ok"}case"/model":{if(w)r.model=w,a.write(`${n}Model set to: ${r.model}${i}
|
|
171
174
|
`);else a.write(`${n}Current model: ${r.model}${i}
|
|
172
|
-
`);return"ok"}case"/save":{if(!
|
|
173
|
-
`),"ok";try{let
|
|
174
|
-
`)}catch(
|
|
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)});Qg(w,JSON.stringify(x,null,2),"utf-8"),a.write(`${n}Conversation saved to ${w} (${x.length} messages)${i}
|
|
177
|
+
`)}catch(x){a.write(`${n}[error] Failed to save: ${x instanceof Error?x.message:String(x)}${i}
|
|
175
178
|
`)}return"ok"}case"/history":{if(r.messages.length===0)return a.write(`${n}No messages in conversation.${i}
|
|
176
179
|
`),"ok";if(r.system)a.write(`${n}[system] ${r.system.slice(0,100)}${r.system.length>100?"...":""}${i}
|
|
177
|
-
`);let
|
|
178
|
-
`),
|
|
179
|
-
`),"ok"}default:if(
|
|
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
|
+
`),x++}return a.write(`${n}── ${x-1} messages ──${i}
|
|
182
|
+
`),"ok"}default:if(v.startsWith("/"))return a.write(`${n}Unknown command: ${v}. Type /help for available commands.${i}
|
|
180
183
|
`),"ok";return"ok"}}let f=()=>{if(l){a.write(`
|
|
181
184
|
${n}[interrupted]${i}
|
|
182
185
|
`),c=0,l=!1;return}if(c++,c>=2){if(a.write(`
|
|
183
186
|
${n}Goodbye!${i}
|
|
184
187
|
`),h=!1,typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",f),process.exit(0)}else a.write(`
|
|
185
188
|
${n}Press Ctrl+C again or type /exit to quit.${i}
|
|
186
|
-
`)};process.on("SIGINT",f);let
|
|
187
|
-
`)}}})});import{writeFileSync as
|
|
188
|
-
`);if(
|
|
189
|
-
${v
|
|
190
|
-
${
|
|
189
|
+
`)};process.on("SIGINT",f);let g=new Bc(a,"> ",n,i),h=!0;o.on("data",(d)=>{g.feed(d)}),a.write(ty);try{while(h){let d=await g.readLine();if(!h)break;let m=d.trim();if(!m)continue;if(m.startsWith("/")){if(u(m)==="exit"){h=!1;break}continue}r.messages.push({role:"user",content:m}),await p()}}finally{if(a.write(ny),typeof o.setRawMode==="function")o.setRawMode(!1);o.pause(),process.removeListener("SIGINT",f),o.removeAllListeners("data"),a.write(`
|
|
190
|
+
`)}}})});import{writeFileSync as ry}from"fs";function Kc(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{ry(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 Wc=I(()=>{ee();G();j()});function Ks(e){return e.join(", ")}function Yc(e,t){if(!t.includes(e))throw new y(`Invalid audio format "${e}". Supported: ${Ks(t)}`,b.USAGE)}function zc(e,t){return Object.hasOwn(Jc,e)?Jc[e]??t:t}function Xc(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 Hs,Jc;var Qc=I(()=>{G();j();Hs=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"];Jc={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function Zc(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 eu(e,t){let n=t.base_resp?.status_code;if(n!==void 0&&n!==0||t.error)throw wn(e.status,t,e.url||void 0)}function tu(){return new y("API stream ended without audio data.",b.GENERAL)}async function*sy(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)}eu(e,i);let r=i.data?.audio;if(!r)throw tu();yield Zc(r);return}let n=!1;for await(let i of qe(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)}eu(e,r);let s=r.data?.audio;if(s)n=!0,yield Zc(s);if(r.data?.status===2)break}if(!n)throw tu()}async function nu(e){process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);throw t});for await(let t of sy(e))if(!process.stdout.write(t))await new Promise((n)=>process.stdout.once("drain",n))}var iu=I(()=>{Ps();G();j()});import{writeFileSync as oy}from"fs";var Ws;var ru=I(()=>{X();G();j();oe();ee();Wc();js();Qc();iu();Ws=N({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: ${Ks(Hs)} (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=Pi(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";Yc(o,Hs),Xc(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??zc(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(_e(e,c))return;let p=F(e.output),u=Zl(e.baseUrl);if(t.stream){let g=await Fe(e,{url:u,method:"POST",body:c,stream:!0});await nu(g);return}let f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
|
|
191
|
+
`);if(Kc(f,a,p,e.quiet),t.subtitles&&f.data.subtitle_file)try{let g=await fetch(f.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 d=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
|
+
${x(v.time_begin)} --> ${x(v.time_end)}
|
|
193
|
+
${v.text}`}).join(`
|
|
191
194
|
|
|
192
|
-
`);if(
|
|
195
|
+
`);if(oy(d,m,"utf-8"),!e.quiet)console.log(O({subtitles:d},p));else console.log(d)}}catch(g){if(!e.quiet)process.stderr.write(`Warning: failed to download subtitles: ${g.message}
|
|
193
196
|
`)}else if(t.subtitles&&!f.data.subtitle_file){if(!e.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
|
|
194
|
-
`)}}})});import{existsSync as
|
|
197
|
+
`)}}})});import{existsSync as ay}from"node:fs";import{readFile as ly}from"node:fs/promises";import{basename as cy,resolve as uy}from"node:path";function $n(e,t){let n=uy(e);if(!ay(n))throw t(n);return n}async function su({filePath:e,purpose:t,baseUrl:n,requestJson:i,createFileNotFoundError:r}){let s=$n(e,r),o=await ly(s),a=new FormData;return a.append("file",new Blob([o]),cy(s)),a.append("purpose",t),i({url:cc(n),method:"POST",body:a})}var Js=()=>{};function Ys(e){return fy.includes(e)}function lu({model:e,response_format:t,timestamp_level:n,stream:i}){let r={model:e??Di,response_format:t??au};if(n)r.timestamp_level=n;if(i)r.stream="true";return r}function cu(e,t=y){if(!qi.includes(e))throw new t(`Invalid response format "${e}". Supported: ${qi.join(", ")}`,b.USAGE)}function uu(e,t,n=y){if(t&&e!==au)throw new n(`response_format "${e}" cannot be combined with stream=true; streaming returns incremental json only.`,b.USAGE)}function fu(e,t,n=y){if(t>ou)throw new n(`Audio file is ${(t/1024/1024).toFixed(1)} MB; speech-to-text allows at most ${ou/1024/1024} MB: ${e}`,b.USAGE,"Re-encode to compressed mono audio (e.g. mp3 / aac) or split it into smaller files.")}async function du({config:e,url:t,form:n,headers:i,responseFormat:r,stream:s}){if(s)return{kind:"stream",res:await Fe(e,{url:t,method:"POST",body:n,headers:i,stream:!0})};if(Ys(r))return{kind:"subtitle",document:await(await Fe(e,{url:t,method:"POST",body:n,headers:i})).text()};return{kind:"json",response:await D(e,{url:t,method:"POST",body:n,headers:i})}}var Di="asr-1.0",qi,fy,au="json",ou=52428800;var pu=I(()=>{G();j();oe();qi=["json","verbose_json","srt","vtt"],fy=["srt","vtt"]});import{readFileSync as dy,statSync as py,writeFileSync as my}from"node:fs";import{basename as hy,resolve as gy}from"node:path";function zs(e){return e.endsWith(`
|
|
195
198
|
`)?e:`${e}
|
|
196
|
-
`}var
|
|
197
|
-
`);let
|
|
199
|
+
`}var Xs;var mu=I(()=>{X();G();j();Js();ee();pu();Pe();Xs=N({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: ${Di})`},{flag:"--response-format <fmt>",description:`Transcription format: ${qi.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 Dt({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||Di,o=t.responseFormat||"json",a=t.language||void 0,l=t.timestampLevel||void 0,c=t.stream===!0,p=t.out?gy(t.out):void 0;if(cu(o),fu(r,py(r).size),uu(o,c),c&&p)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=lu({model:s,response_format:o,timestamp_level:l,stream:c}),f={...u,file:r};if(a)f.language=a;if(_e(e,f))return;let g=new FormData;for(let[E,A]of Object.entries(u))g.append(E,A);g.append("file",new Blob([dy(r)]),hy(r));let h={};if(a)h.language=a;let d=ec(e.baseUrl),m=F(e.output);if(!e.quiet)process.stderr.write(`[Model: ${s}]
|
|
200
|
+
`);let v=await du({config:e,url:d,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 qe(E)){if(P.data==="[DONE]")break;let C;try{C=JSON.parse(P.data)}catch(L){process.stderr.write(`[warning] Failed to parse stream chunk: ${L instanceof Error?L.message:String(L)}
|
|
198
201
|
`);continue}if(typeof C.index==="number"&&C.index!==S)process.stderr.write(`[warning] Stream events arrived out of order (expected index ${S}, got ${C.index}).
|
|
199
|
-
`);if(typeof C.index==="number")S=C.index+1;if(C.delta){if(
|
|
200
|
-
`);let q=
|
|
201
|
-
`);else process.stdout.write(
|
|
202
|
-
`);return}let
|
|
203
|
-
`)}}}}function
|
|
204
|
-
`)}}}var
|
|
205
|
-
Retry ${
|
|
206
|
-
`);await
|
|
207
|
-
Download attempt ${
|
|
208
|
-
`);if(
|
|
209
|
-
`);let
|
|
210
|
-
`);
|
|
211
|
-
`);
|
|
212
|
-
`)
|
|
213
|
-
`));else console.log(
|
|
214
|
-
|
|
202
|
+
`);if(typeof C.index==="number")S=C.index+1;if(C.delta){if(_.push({index:typeof C.index==="number"?C.index:_.length,delta:C.delta}),U)process.stdout.write(C.delta)}if(C.finish){k=C.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 q=_.sort((P,C)=>P.index-C.index).map((P)=>P.delta).join("");if(U)process.stdout.write(`
|
|
204
|
+
`);else process.stdout.write(zs(O({text:q,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(p){try{my(p,Ys(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(p);else{let E={saved:p};if(x!==void 0)E.duration=x;console.log(O(E,m))}return}process.stdout.write(zs(w))}})});function yy(e){let t=e.match(/^(.+?)_[A-Z]/);return t?t[1]:e}function by(e,t){let n=t.toLowerCase();return e.filter((i)=>{let r=yy(i.voice_id).toLowerCase();return r===n||r.startsWith(n+"_")||r.startsWith(n+" (")})}var hu;var gu=I(()=>{X();oe();ee();hu=N({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 D(e,{url:tc(e.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=t.language;if(s){let o=by(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 bu(e){let t=process.stderr.isTTY,n=0,i=null,r=e;return{start(){if(!t)return;i=setInterval(()=>{process.stderr.write(`\r${yu[n%yu.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 wu(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 yu;var Qs=I(()=>{yu=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as wy,renameSync as xy,unlinkSync as vy}from"fs";function Zs(e,t){if(!Number.isFinite(e)||e<=0)throw new y(`${t} must be a positive number.`,b.USAGE);return e}function Ey(e,t){if(!Number.isInteger(e)||e<0)throw new y(`${t} must be a non-negative integer.`,b.USAGE);return e}function Ay(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 ky(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 Ty(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 Iy(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 ji(e,t,n,i,r=!0){if(t.signal.aborted)throw nt(t.signal,"Download aborted.");let s,o,a=new Promise((c,p)=>{s=setTimeout(()=>{let u=r?new wt(`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),p(u)},n)}),l=new Promise((c,p)=>{o=()=>p(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 My(e,t,n){let i=new Promise((r,s)=>{let o=()=>c(r),a=(p)=>c(()=>s(p)),l=()=>c(()=>s(Error("File writer closed before draining."))),c=(p)=>{e.off("drain",o),e.off("error",a),e.off("close",l),p()};e.once("drain",o),e.once("error",a),e.once("close",l)});try{await ji(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 Oy(e,t,n){let i=new Promise((r,s)=>{let o=()=>c(r),a=(p)=>c(()=>s(p)),l=()=>{if(!e.writableFinished)c(()=>s(Error("File writer closed early.")))},c=(p)=>{e.off("finish",o),e.off("error",a),e.off("close",l),p()};e.once("finish",o),e.once("error",a),e.once("close",l),e.end()});try{await ji(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 Cy(e){if(e.closed)return;await new Promise((t)=>{let n=setTimeout(()=>{e.off("close",i),t()},vu),i=()=>{clearTimeout(n),t()};e.once("close",i),e.destroy()})}async function xu(e){let t;if(await Promise.race([e.catch(()=>{return}),new Promise((n)=>{t=setTimeout(n,vu)})]),t)clearTimeout(t)}async function Ny(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,p,u=null,f=!1;try{try{a=await ji(fetch(e,{signal:s.signal}),s,i.idleTimeoutMs,"waiting for response headers")}catch(w){if(w instanceof y)throw w;throw new wt(`Download request failed: ${w instanceof Error?w.message:String(w)}`)}if(!a.ok)throw new Ui(a.status,ky(a.headers.get("retry-after")));let g=Ty(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;p=`${t}.tmp-${process.pid}-${Date.now()}-${n}-${Math.random().toString(36).slice(2)}`,c=wy(p),u=h&&!i.quiet?wu(h,"Downloading"):null;let d,m=new Promise((w,x)=>{c.once("error",(E)=>{d=E,x(E)})});m.catch(()=>{return});let v=0;while(!0){let w;try{w=await ji(Promise.race([l.read(),m]),s,i.idleTimeoutMs,"waiting for response data")}catch(A){if(d)throw new y(`Could not write download: ${d.message}`,b.GENERAL);if(A instanceof y)throw A;throw new wt(`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 My(c,s,i.idleTimeoutMs);v=x,u?.update(v)}if(h!==void 0&&v!==h)throw new wt(`Download truncated: expected ${h} bytes, received ${v}.`);return await Oy(c,s,i.idleTimeoutMs),c=void 0,l.releaseLock(),l=void 0,xy(p,t),p=void 0,f=!0,{size:v}}finally{if(r.removeEventListener("abort",o),u?.finish(),!f){if(l){await xu(l.cancel(s.signal.reason));try{l.releaseLock()}catch{}}else if(a?.body)await xu(a.body.cancel(s.signal.reason));if(c)await Cy(c);if(p)try{vy(p)}catch{}}}}async function Ue(e,t,n){let i=e.startsWith("http://")?e.replace("http://","https://"):e,r=Ey(n?.retries??3,"retries"),s=Ay(n?.retryDelayMs??1000,"retryDelayMs"),o=Zs(n?.overallTimeoutMs??Sy,"overallTimeoutMs"),a=Zs(n?.idleTimeoutMs??$y,"idleTimeoutMs"),l=Zs(n?.maxBytes??_y,"maxBytes"),c=n?.quiet??!1,p=new AbortController,u=()=>p.abort(nt(n.signal,"Download aborted by caller."));if(n?.signal?.aborted)u();else n?.signal?.addEventListener("abort",u,{once:!0});let f=setTimeout(()=>{p.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
|
+
Retry ${m}/${r} in ${w}ms...
|
|
209
|
+
`);await Iy(w,p.signal)}try{return await Ny(i,t,m,{quiet:c,idleTimeoutMs:a,maxBytes:l},p.signal)}catch(v){if(g=v instanceof Error?v:Error(String(v)),p.signal.aborted)throw nt(p.signal,"Download aborted.");if(!(v instanceof wt||v instanceof Ui&&v.retryable))throw v;if(h=v instanceof Ui||v instanceof wt?v.retryAfterMs:void 0,!c)process.stderr.write(`
|
|
210
|
+
Download attempt ${m+1} failed: ${g.message}
|
|
211
|
+
`);if(m===r)break}}}finally{clearTimeout(f),n?.signal?.removeEventListener("abort",u)}let d=g instanceof y?g.exitCode:b.NETWORK;throw new y(`Download failed after ${r+1} attempts: ${g?.message}`,d,d===b.NETWORK?"Check your network connection and proxy settings.":void 0)}function Gi(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 Sy=1800000,$y=60000,_y=5368709120,vu=1000,wt,Ui;var _n=I(()=>{Qs();G();j();wt=class wt extends y{retryAfterMs;constructor(e,t=b.NETWORK,n){super(e,t);this.retryAfterMs=n}};Ui=class Ui 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 Ry,existsSync as Ly,statSync as Py}from"fs";import{extname as Su}from"path";function Gt(e,t){if(t!==void 0){let s=Py(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=Su(e).toLowerCase(),i=Bi[n]||"image/jpeg",r=Ry(e);return`data:${i};base64,${r.toString("base64")}`}function xt(e,t){return e.startsWith("http")||e.startsWith("data:")||e.startsWith("mm_file://")?e:Gt(e,t)}async function $u(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>Fy)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(!Ly(e))throw new y(`File not found: ${e}`,b.USAGE);let t=Su(e).toLowerCase();if(!Bi[t])throw new y(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,b.USAGE);return Gt(e)}var Bi,Fy=52428800;var En=I(()=>{G();j();Bi={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".heic":"image/heic",".heif":"image/heif"}});import{existsSync as qy,readFileSync as Dy,statSync as Uy}from"fs";import{extname as jy}from"path";function Vi(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 eo(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(!qy(e))throw new y(`File not found: ${e}`,b.USAGE);let n=jy(e).toLowerCase(),i=Gy[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=vt[t],o=Uy(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=Dy(e);return`data:${r};base64,${a.toString("base64")}`}var Gy,vt,_u=67108864;var Hi=I(()=>{G();j();Gy={video:{".mp4":"video/mp4",".mov":"video/quicktime"},audio:{".mp3":"audio/mp3",".wav":"audio/wav"}},vt={image:31457280,video:52428800,audio:15728640}});import{existsSync as to,mkdirSync as By,writeFileSync as Vy}from"fs";import{dirname as Hy,extname as Ky,join as Wy,resolve as Eu}from"path";function no(e){return e===St}function io(e){return Array.isArray(e.images)}function ro(e){if(e==="png"||e==="webp")return e;return"jpg"}function ib(e){return e==="base64"?"b64_json":e}function Cu(e){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("mm_file://"))return e;if(!to(e))throw new z(`Reference image not found: ${e}`);let t=Ky(e).toLowerCase();if(!Bi[t])throw new z(`Unsupported reference image format "${t}". Supported: jpg, jpeg, png, webp, heic, heif.`);return Gt(e,Ou)}function Nu(e){let t={model:St,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:ib(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 sb(i),i}function rb(e){let t=/^(\d+):(\d+)$/.exec(e);if(!t)return;return[Number(t[1]),Number(t[2])]}function Iu(e,t){return Math.max(e,t)<=3*Math.min(e,t)}function sb(e){if(!no(e.model))throw new z(`Only ${St} 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>Au)throw new z(`MiniMax-H3-Image prompt must not exceed ${Au} characters.`);if(e.n!==void 0&&(!Number.isInteger(e.n)||e.n<1||e.n>ku))throw new z(`MiniMax-H3-Image n must be an integer from 1 to ${ku}.`);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<Jy||c>Yy)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(!Iu(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=rb(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(!Iu(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&&!eb.has(e.area))throw new z("MiniMax-H3-Image area must be one of: 1K, 2K, 4K.");if(e.output_format!==void 0&&!tb.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&&!nb.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]):Xy[e.area??"4K"],a=(e.n??1)*o,l=e.output_format==="png",c=l?Qy:Zy;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(io(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>Tu)throw new z(`MiniMax-H3-Image accepts 1 to ${Tu} 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=Vi(a.image_url);if(l!==void 0&&l>Ou)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>zy)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 Ru(e,t={}){let n=ro(e.output_format),i=[],r=[];if(e.data.forEach((c,p)=>{if(c.url||c.b64_json)r.push({index:p,url:c.url,b64:c.b64_json});else i.push({index:p,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=Eu(t.outDir||"."),l=t.prefix||"image";for(let c of r){let p=t.out?Eu(t.out):Wy(a,`${l}_${String(c.index+1).padStart(3,"0")}.${n}`),u=Hy(p);if(!to(u))By(u,{recursive:!0});if(t.warnOverwrite&&to(p))process.stderr.write(`Warning: overwriting existing file: ${p}
|
|
212
|
+
`);if(c.b64)Vy(p,c.b64,"base64");else await Ue(c.url,p,{quiet:o});s.push(p)}return{saved:s,failures:i}}var St="MiniMax-H3-Image",Mu=600,Au=32000,ku=10,Tu=16,Jy=655360,Yy=20000000,Ou=67108864,zy=67108864,Xy,Qy=20000000,Zy=80000000,eb,tb,nb,z;var Lu=I(()=>{_n();En();Hi();Xy={"1K":1048576,"2K":4194304,"4K":16777216},eb=new Set(["1K","2K","4K"]),tb=new Set(["png","jpeg","jpg","webp"]),nb=new Set(["url","b64_json"]);z=class z extends Error{constructor(e){super(e);this.name="ImageH3InputError"}}});import{mkdirSync as Pu,existsSync as An,writeFileSync as Fu}from"fs";import{dirname as ob,extname as ab,join as qu,resolve as so}from"path";function Du(e,t){let n=e;return t.filter(([i])=>n[i]!==void 0&&n[i]!==!1).map(([,i])=>i)}async function ub(e,t,n){let i=Du(t,cb);if(i.length>0)throw new y(`${i.join(", ")} ${i.length>1?"are":"is"} not supported by ${St}.`,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,Ki);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,Ki);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 d=(t.image??[]).map(Cu);l=Nu({prompt:n,images:d,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(d){if(d instanceof z)throw new y(d.message,b.USAGE,Ki);throw d}if(_e(e,l))return;let c=F(e.output),p=io(l),u=await D(e,{url:p?rc(e.baseUrl):ic(e.baseUrl),method:"POST",body:l,timeout:Math.max(e.timeout,Mu)});if(!e.quiet)process.stderr.write(`[Model: ${St}${p?" (edit)":""}]
|
|
213
|
+
`);let{saved:f,failures:g}=await Ru(u,{out:a,outDir:t.outDir,prefix:t.outPrefix,quiet:e.quiet,warnOverwrite:!0});for(let d of g)process.stderr.write(`Warning: image ${d.index+1} failed${d.code?` (${d.code})`:""}: ${d.message??"unknown error"}
|
|
214
|
+
`);if(a&&f.length>0){let d=ro(u.output_format),m=ab(a).toLowerCase().replace(/^\./,"").replace(/^jpeg$/,"jpg");if(m!==d)process.stderr.write(`Warning: --out ${a} has a .${m||"(none)"} extension but the image is ${d}.
|
|
215
|
+
`)}let h={id:u.request_id,saved:f,success_count:f.length,failed_count:g.length};if(g.length>0)h.failures=g;if(c==="json"){if(h.sizes=u.data.map((d)=>d.size??null),h.revised_prompts=u.data.map((d)=>d.revised_prompt??null),u.usage)h.usage=u.usage;console.log(O(h,c))}else if(e.quiet)console.log(f.join(`
|
|
216
|
+
`));else console.log(O(h,c))}var Ki="mmx image generate --model MiniMax-H3-Image --prompt <text>",lb,cb,Uu;var ju=I(()=>{X();G();j();oe();_n();ee();En();Pe();Lu();lb=[["image","--image"],["size","--size"],["area","--area"],["outputFormat","--output-format"],["outputCompression","--output-compression"],["noPromptEnhance","--no-prompt-enhance"]],cb=[["seed","--seed"],["promptOptimizer","--prompt-optimizer"],["subjectRef","--subject-ref"]];Uu=N({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 Dt({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(no(i)){await ub(e,t,n);return}let r=Du(t,lb);if(r.length>0)throw new y(`${r.join(", ")} ${r.length>1?"require":"requires"} --model ${St}.`,b.USAGE,Ki);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=(d,m)=>{if(m<512||m>2048)throw new y(`--${d} must be between 512 and 2048, got ${m}.`,b.USAGE);if(m%8!==0)throw new y(`--${d} 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,d=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:d.type||"character"};if(d.image)if(d.image.startsWith("http"))m.image_url=d.image;else m.image_file=Gt(so(d.image));c.subject_reference=[m]}if(_e(e,c))return;let p=F(e.output),u=nc(e.baseUrl),f=await D(e,{url:u,method:"POST",body:c});if(!e.quiet)process.stderr.write(`[Model: ${i}]
|
|
217
|
+
`);let g=[];if(a){let h=ob(so(a));if(!An(h))Pu(h,{recursive:!0});let d=so(a);if(An(d))process.stderr.write(`Warning: overwriting existing file: ${d}
|
|
218
|
+
`);if(l==="base64"){let m=(f.data.image_base64||[])[0];if(m)Fu(d,m,"base64")}else{let m=(f.data.image_urls||[])[0];if(m)await Ue(m,d,{quiet:e.quiet})}g.push(d)}else{let h=t.outDir??".";if(!An(h))Pu(h,{recursive:!0});let d=t.outPrefix||"image";if(l==="base64"){let m=f.data.image_base64||[];for(let v=0;v<m.length;v++){let w=`${d}_${String(v+1).padStart(3,"0")}.jpg`,x=qu(h,w);if(An(x))process.stderr.write(`Warning: overwriting existing file: ${x}
|
|
219
|
+
`);Fu(x,m[v],"base64"),g.push(x)}}else{let m=f.data.image_urls||[];for(let v=0;v<m.length;v++){let w=`${d}_${String(v+1).padStart(3,"0")}.jpg`,x=qu(h,w);if(An(x))process.stderr.write(`Warning: overwriting existing file: ${x}
|
|
220
|
+
`);await Ue(m[v],x,{quiet:e.quiet}),g.push(x)}}}if(p==="json")console.log(O({id:f.data.task_id,saved:g,success_count:f.data.success_count,failed_count:f.data.failed_count},p));else if(e.quiet)console.log(g.join(`
|
|
221
|
+
`));else console.log(O({id:f.data.task_id,saved:g,success_count:f.data.success_count,failed_count:f.data.failed_count},p))}})});async function oo(e,t){let n=Date.now()+t.timeoutSec*1000,i=bu("Polling...");if(!e.quiet)i.start();try{while(Date.now()<n){let r=await D(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 Gu=I(()=>{oe();G();j();Qs()});function $t(e){return e===kn}function Bu(e){return $t(e.model)}function Vu(e){let t=e.error?.code?.trim(),n=e.error?.message?.trim();if(t&&n)return`${t}: ${n}`;return n||t}function Hu(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:kn,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 mb(s),s}function mb(e){if(!$t(e.model))throw new ie(`Video Generation V2 only supports ${kn}.`);let t=e.content.filter((f)=>f.type==="text");if(!t.some((f)=>f.text.trim().length>0))throw new ie("MiniMax-H3 requires a non-empty text content item.");if(t.some((f)=>f.text.length>7000))throw new ie("MiniMax-H3 text content must not exceed 7000 characters.");if(!fb.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&&!db.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((f)=>f.type==="image_url"),i=e.content.filter((f)=>f.type==="video_url"),r=e.content.filter((f)=>f.type==="audio_url");if(n.some((f)=>f.role&&!pb.has(f.role)))throw new ie("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");if(i.some((f)=>f.role!=="reference_video"))throw new ie("MiniMax-H3 video role must be reference_video.");if(r.some((f)=>f.role!=="reference_audio"))throw new ie("MiniMax-H3 audio role must be reference_audio.");for(let f of n)ao(f.image_url.url,"image");for(let f of i)ao(f.video_url.url,"video");for(let f of r)ao(f.audio_url.url,"audio");let s=Buffer.byteLength(JSON.stringify(e));if(s>_u)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((f)=>!f.role||f.role==="first_frame"),a=n.filter((f)=>f.role==="last_frame"),l=n.filter((f)=>f.role==="reference_image"),c=o.length>0||a.length>0,p=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&&p)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((f)=>f.type==="text")&&(!e.ratio||e.ratio==="adaptive"))throw new ie("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.")}function ao(e,t){let n=Vi(e),i=vt[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 kn="MiniMax-H3",fb,db,pb,ie;var lo=I(()=>{Hi();fb=new Set(["768P","2K"]),db=new Set(["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]),pb=new Set(["first_frame","last_frame","reference_image"]);ie=class ie extends Error{constructor(e){super(e);this.name="VideoV2InputError"}}});var Ku;var Wu=I(()=>{X();G();j();oe();Gu();_n();ee();En();Hi();Pe();lo();Ku=N({name:"video generate",description:`Generate a video
|
|
222
|
+
V2: MiniMax-H3 (text/image/video/audio content, 768P/2K)
|
|
215
223
|
T2V: Hailuo-2.3
|
|
216
224
|
I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --image)
|
|
217
225
|
SEF: Hailuo-02 (requires --image and --last-frame)
|
|
218
|
-
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:"--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"',"# 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
|
|
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 Dt({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($t(r))c=kn;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 p;if($t(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:xt(a,vt.image),role:"first_frame"}]:[],...t.lastFrame?[{url:xt(t.lastFrame,vt.image),role:"last_frame"}]:[],...(t.referenceImage??[]).map((q)=>({url:xt(q,vt.image),role:"reference_image"}))];try{p=Hu({prompt:n,images:U,referenceVideos:(t.referenceVideo??[]).map((q)=>eo(q,"video")),referenceAudios:(t.referenceAudio??[]).map((q)=>eo(q,"audio")),resolution:t.resolution,duration:t.duration,ratio:t.ratio,callbackUrl:t.callbackUrl})}catch(q){if(q instanceof ie)throw new y(q.message,b.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text>");throw q}}else{if(l)throw new y("--reference-image, --reference-video, --reference-audio, --resolution, --duration, and --ratio require --model MiniMax-H3.",b.USAGE);if(p={model:c,prompt:n},a)p.first_frame_image=xt(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>");p.last_frame_image=xt(t.lastFrame)}if(t.subjectImage)p.subject_reference=[{type:"character",image:[xt(t.subjectImage)]}];if(t.callbackUrl)p.callback_url=t.callbackUrl}if(_e(e,p))return;let u=F(e.output),f=Bu(p),g=f?oc(e.baseUrl):sc(e.baseUrl),d=(await D(e,{url:g,method:"POST",body:p})).task_id;if(!e.quiet)process.stderr.write(`[Model: ${c}]
|
|
219
227
|
`);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:d})),process.stdout.write(`
|
|
220
|
-
`);return}let
|
|
221
|
-
`)}})});var
|
|
222
|
-
`),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.",
|
|
228
|
+
`);return}let m=t.pollInterval??5,v,w,x;if(f){let U=Ii(e.baseUrl,d),q=await oo(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)=>Vu(P.task)});x=q.task.status,v=q.task.content?.url}else{let U=Ti(e.baseUrl,d),q=await oo(e,{url:U,intervalSec:m,timeoutSec:e.timeout,isComplete:(C)=>C.status==="Success",isFailed:(C)=>C.status==="Failed",getStatus:(C)=>C.status});if(x=q.status,w=q.file_id,!w)throw new y("Task completed but no file_id returned.",b.GENERAL);v=(await D(e,{url:Mi(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:q}=await Ue(v,U,{quiet:e.quiet});if(e.quiet)console.log(U);else console.log(O({task_id:d,status:x,file_id:w,saved:U,size:Gi(q)},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(_,`${d}.mp4`);await Ue(v,R,{quiet:e.quiet}),process.stdout.write(R),process.stdout.write(`
|
|
229
|
+
`)}})});var Ju;var Yu=I(()=>{X();G();j();oe();ee();lo();Ju=N({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($t(r)){let a=Ii(e.baseUrl,n),c=(await D(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=Ti(e.baseUrl,n),o=await D(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 zu;var Xu=I(()=>{X();G();j();oe();_n();ee();zu=N({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=Mi(e.baseUrl,n),o=(await D(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 Ue(o,i,{quiet:e.quiet}),l=F(e.output);if(e.quiet){console.log(i);return}console.log(O({saved:i,size:Gi(a)},l))}})});var co;var Qu=I(()=>{X();oe();ee();G();j();co=N({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=ac(e.baseUrl),s=await D(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 Zu;var ef=I(()=>{X();oe();ee();G();j();Pe();En();Zu=N({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 Ae({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(_e(e,{prompt:r,image:n,fileId:i}))return;let s=F(e.output),o=lc(e.baseUrl),a={prompt:r};if(i)a.file_id=i;else if(n){let c=await $u(n);a.image_url=c}let l=await D(e,{url:o,method:"POST",body:a});if(s!=="text"){process.stdout.write(O(l,s)+`
|
|
223
231
|
`);return}process.stdout.write(l.content+`
|
|
224
|
-
`)}})});var
|
|
225
|
-
`)}catch{throw new y(`Command "${n}" not found.`,
|
|
226
|
-
`)}})});var
|
|
227
|
-
`),process.exit(1)}else
|
|
228
|
-
`);return}let a=await
|
|
229
|
-
`);return}process.stdout.write(
|
|
230
|
-
`)}})});var
|
|
231
|
-
`);return}let i=
|
|
232
|
+
`)}})});var tf;var nf=I(()=>{X();oe();Ei();ee();Ni();tf=N({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 jt(e),r=qs(e.baseUrl,i);if(r.kind==="account-balance"){let a=await D(e,{url:r.url});if(n!=="text"){console.log(O(a,n));return}Je(a,e,i.token);return}let s=await D(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=Oi(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}Je(s,e)}})});var rf;var sf=I(()=>{X();Ce();Xe();ee();rf=N({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:fe()};if(n.api_key)r.api_key=me(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 af(e,t){return e==="api_key"?me(String(t)):t}var of,hb,lf;var cf=I(()=>{X();G();j();ee();Ce();of=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model"],hb={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model"};lf=N({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=hb[i]||i;if(!of.includes(s))throw new y(`Invalid config key "${i}". Valid keys: ${of.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]:af(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 de(l),!e.quiet)console.log(O({[s]:af(s,l[s])},a))}})});function gb(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 uo(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}=gb(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 p=n.input_schema;if(p.properties[r]=c,i.required)p.required.push(r)}return n}var yb,uf;var ff=I(()=>{X();Li();G();j();yb=["auth ","config ","update"],uf=N({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}=Te.resolve(n.split(" ")),o=uo(s);process.stdout.write(JSON.stringify(o,null,2)+`
|
|
233
|
+
`)}catch{throw new y(`Command "${n}" not found.`,b.USAGE)}return}let r=Te.getAllCommands().filter((s)=>!yb.some((o)=>s.name.startsWith(o))).map((s)=>uo(s));process.stdout.write(JSON.stringify(r,null,2)+`
|
|
234
|
+
`)}})});var df;var pf=I(()=>{X();G();j();oe();Js();ee();Pe();df=N({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 Ae({message:"Enter file path:"}),!n)process.stderr.write(`Upload cancelled.
|
|
235
|
+
`),process.exit(1)}else yt("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 su({filePath:r,purpose:s,baseUrl:e.baseUrl,requestJson:(l)=>D(e,l),createFileNotFoundError:i});if(e.quiet){process.stdout.write(a.file.file_id+`
|
|
237
|
+
`);return}process.stdout.write(O(a.file,o)+`
|
|
238
|
+
`)}})});var mf;var hf=I(()=>{X();oe();ee();mf=N({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=uc(e.baseUrl),r=await D(e,{url:i,method:"GET"});if(n!=="text"){process.stdout.write(O(r,n)+`
|
|
232
240
|
`);return}if(!r.files||r.files.length===0){process.stdout.write(`No files found.
|
|
233
|
-
`);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(
|
|
234
|
-
`)}})});var
|
|
235
|
-
`),process.exit(1)}else
|
|
236
|
-
`);return}let r=
|
|
237
|
-
`);return}process.stdout.write(
|
|
238
|
-
`)}})});var
|
|
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(Qr(s)+`
|
|
242
|
+
`)}})});var gf;var yf=I(()=>{X();oe();ee();Pe();gf=N({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 Ae({message:"Enter file ID to delete:"}),!n)process.stderr.write(`Delete cancelled.
|
|
243
|
+
`),process.exit(1)}else yt("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=fc(e.baseUrl),s=await D(e,{url:r,method:"POST",body:{file_id:Number(n)}});if(e.quiet){process.stdout.write(`deleted
|
|
245
|
+
`);return}process.stdout.write(O({file_id:s.file_id,deleted:!0},i)+`
|
|
246
|
+
`)}})});var bf;var wf=I(()=>{X();Ai();bf=N({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${bt}
|
|
239
247
|
|
|
240
248
|
`),process.stderr.write(`Run:
|
|
241
249
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
242
250
|
|
|
243
|
-
`)}})});var
|
|
251
|
+
`)}})});var bb,xf;var vf=I(()=>{X();$e();bb=[{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"}],xf=N({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(e,t){let n=pt[e.region]||pt.global;process.stdout.write(`
|
|
244
252
|
MiniMax API Documentation Links
|
|
245
253
|
|
|
246
254
|
Official docs: ${n}/docs/api-reference
|
|
247
255
|
|
|
248
|
-
`);for(let i of
|
|
256
|
+
`);for(let i of bb)process.stdout.write(` ${i.command.padEnd(30)} ${i.title}
|
|
249
257
|
`),process.stdout.write(` ${" ".repeat(30)} ${n}${i.path}
|
|
250
258
|
|
|
251
|
-
`)}})});var
|
|
259
|
+
`)}})});var wb,it;var fo=I(()=>{/*!
|
|
252
260
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
253
261
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
254
262
|
*
|
|
@@ -274,9 +282,9 @@ MiniMax API Documentation Links
|
|
|
274
282
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
275
283
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
276
284
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
277
|
-
*/
|
|
285
|
+
*/wb=/^(\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(wb);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 xb(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function vb(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+=`
|
|
278
286
|
`,o===t)r+=" ".repeat(s+n+2),r+=`^
|
|
279
|
-
`}return r}var
|
|
287
|
+
`}return r}var B;var _t=I(()=>{/*!
|
|
280
288
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
281
289
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
282
290
|
*
|
|
@@ -302,10 +310,10 @@ MiniMax API Documentation Links
|
|
|
302
310
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
303
311
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
304
312
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
305
|
-
*/
|
|
313
|
+
*/B=class B extends Error{line;column;codeblock;constructor(e,t){let[n,i]=xb(t.toml,t.ptr),r=vb(t.toml,n,i);super(`Invalid TOML document: ${e}
|
|
306
314
|
|
|
307
|
-
${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function
|
|
308
|
-
`,t);if(e.charCodeAt(n-1)===13)n--;return n}function
|
|
315
|
+
${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function po(e,t=0){let n=e.indexOf(`
|
|
316
|
+
`,t);if(e.charCodeAt(n-1)===13)n--;return n}function Wi(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 je(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;Wi(e)}}function Sf(e,t,n){let i=e.p;if(!n){i=po(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)Wi(e);else if(r===n||r===t)return}throw new B("cannot find end of structure",{toml:e.s,ptr:i})}var Ji=I(()=>{_t();/*!
|
|
309
317
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
310
318
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
311
319
|
*
|
|
@@ -331,8 +339,8 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
331
339
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
332
340
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
333
341
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
334
|
-
*/});function
|
|
335
|
-
`;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
|
|
342
|
+
*/});function Yi(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,p=n===120?2:n===117?4:8;for(let u=0;u<p;u++,e.p++){let f=e.s.charCodeAt(e.p+1),g=f>=48&&f<=57?f-48:f>=65&&f<=70?f-65+10:f>=97&&f<=102?f-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 Eb(e,t,n){let i=e.s.slice(t,n),r=i.indexOf("#");if(r>0)Wi({s:i,p:r,d:0}),i=i.slice(0,r);return i.trimEnd()}function $f(e,t,n){let i=e.p,r={toml:e.s,ptr:i};Sf(e,44,n);let s=Eb(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=Sb.test(s);if(o||$b.test(s)){if(_b.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 Sb,$b,_b;var mo=I(()=>{fo();_t();Ji();/*!
|
|
336
344
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
337
345
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
338
346
|
*
|
|
@@ -358,7 +366,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
358
366
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
359
367
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
360
368
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
361
|
-
*/
|
|
369
|
+
*/Sb=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,$b=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,_b=/^[+-]?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?Ef(e,n):_f(e,n);return e.d++,s}if(r===34||r===39)return Yi(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 $f(e,n,t)}var ho=I(()=>{mo();go();_t();/*!
|
|
362
370
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
363
371
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
364
372
|
*
|
|
@@ -384,7 +392,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
384
392
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
385
393
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
386
394
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
387
|
-
*/});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=Yi(e);i=e.s.indexOf(".",e.p);let l=e.s.slice(e.p,i<0||i>s?s:i),c=po(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(!Ab.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,je(e,!0,!0),r}function _f(e,t){let n={},i=new Set,r;e.p++;while(e.p<e.s.length){if(je(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 p=Tn(e,125,t);if(i.add(o[s]=p),je(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 Ef(e,t){let n=[],i;e.p++;while(e.p<e.s.length){if(je(e),(i=e.s.charCodeAt(e.p))===93)return e.p++,n;if(n.push(Tn(e,93,t)),je(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 Ab;var go=I(()=>{mo();ho();Ji();_t();/*!
|
|
388
396
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
389
397
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
390
398
|
*
|
|
@@ -410,7 +418,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
410
418
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
411
419
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
412
420
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
413
|
-
*/
|
|
421
|
+
*/Ab=/^[a-zA-Z0-9-_]+[ \t]*$/});function Af(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 p=r.length-1;r=r[p],s=s[p].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 Et(e,{maxDepth:t=1000,integersAsBigInt:n}={}){let i={s:e,p:0,d:t},r={},s={},o,a=r,l=s;je(i);while(i.p<e.length){if(e.charCodeAt(i.p)===91){let c=e.charCodeAt(++i.p)===91;o=i.p+=+c;let p=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=Af(p,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),p=Af(c,a,l,0);if(!p)throw new B("trying to redefine an already defined table or value",{toml:e,ptr:o});p[1][p[0]]=Tn(i,void 0,n)}if(je(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});je(i)}return r}var kf=I(()=>{go();ho();Ji();_t();/*!
|
|
414
422
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
415
423
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
416
424
|
*
|
|
@@ -436,7 +444,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
436
444
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
437
445
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
438
446
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
439
|
-
*/});var
|
|
447
|
+
*/});var Tf=I(()=>{/*!
|
|
440
448
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
441
449
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
442
450
|
*
|
|
@@ -462,7 +470,7 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
462
470
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
463
471
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
464
472
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
465
|
-
*/});var
|
|
473
|
+
*/});var yo=I(()=>{kf();Tf();fo();_t();/*!
|
|
466
474
|
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
467
475
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
468
476
|
*
|
|
@@ -488,218 +496,219 @@ ${r}`,t);this.line=n,this.column=i,this.codeblock=r}}});function to(e,t=0){let n
|
|
|
488
496
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
489
497
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
490
498
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
491
|
-
*/});function
|
|
492
|
-
`;break;case 114:
|
|
493
|
-
`;return a++,c=i,o=14}switch(
|
|
499
|
+
*/});function Mn(e,t=!1){let n=e.length,i=0,r="",s=0,o=16,a=0,l=0,c=0,p=0,u=0;function f(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&&Bt(e.charCodeAt(i)))i++}if(i<e.length&&e.charCodeAt(i)===46)if(i++,i<e.length&&Bt(e.charCodeAt(i))){i++;while(i<e.length&&Bt(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&&Bt(e.charCodeAt(i))){i++;while(i<e.length&&Bt(e.charCodeAt(i)))i++;E=i}else u=3}return e.substring(x,E)}function d(){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=f(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(In(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,p=c,i>=n)return s=n,o=17;let x=e.charCodeAt(i);if(bo(x)){do i++,r+=String.fromCharCode(x),x=e.charCodeAt(i);while(bo(x));return o=15}if(In(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=d(),o=10;case 47:let E=i-1;if(e.charCodeAt(i+1)===47){i+=2;while(i<n){if(In(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++,In(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||!Bt(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(bo(x)||In(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-p,getTokenError:()=>u}}function bo(e){return e===32||e===9}function In(e){return e===10||e===13}function Bt(e){return e>=48&&e<=57}var If;var Xi=I(()=>{(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"})(If||(If={}))});var ge,wo,Mf;var Of=I(()=>{ge=Array(20).fill(0).map((e,t)=>" ".repeat(t)),wo={" ":{"\n":Array(200).fill(0).map((e,t)=>`
|
|
494
502
|
`+" ".repeat(t)),"\r":Array(200).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":Array(200).fill(0).map((e,t)=>`\r
|
|
495
503
|
`+" ".repeat(t))},"\t":{"\n":Array(200).fill(0).map((e,t)=>`
|
|
496
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
|
|
497
|
-
`+"\t".repeat(t))}},
|
|
505
|
+
`+"\t".repeat(t))}},Mf=[`
|
|
498
506
|
`,"\r",`\r
|
|
499
|
-
`]});function
|
|
507
|
+
`]});function xo(e,t,n){let i,r,s,o,a;if(t){o=t.offset,a=o+t.length,s=o;while(s>0&&!On(e,s-1))s--;let A=a;while(A<e.length&&!On(e,A))A++;r=e.substring(s,A),i=Tb(r,n)}else r=e,i=0,s=0,o=0,a=e.length;let l=Ib(n,e),c=Mf.includes(l),p=0,u=0,f;if(n.insertSpaces)f=ge[n.tabSize||4]??Vt(ge[1],n.tabSize||4);else f="\t";let g=f==="\t"?"\t":" ",h=Mn(r,!1),d=!1;function m(){if(p>1)return Vt(l,p)+Vt(f,i+u);let A=f.length*(i+u);if(!c||A>wo[g][l].length)return l+Vt(f,i+u);if(A<=0)return l;return wo[g][l][A]}function v(){let A=h.scan();p=0;while(A===15||A===14){if(A===14&&n.keepLines)p+=1;else if(A===14)p=1;A=h.scan()}return d=A===16||h.getTokenError()!==0,A}let w=[];function x(A,_,S){if(!d&&(!t||_<a&&S>o)&&e.substring(_,S)!==A)w.push({offset:_,length:S-_,content:A})}let E=v();if(n.keepLines&&p>0)x(Vt(l,p),0,0);if(E!==17){let A=h.getTokenOffset()+s,_=f.length*i<20&&n.insertSpaces?ge[f.length*i]:Vt(f,i);x(_,s,A)}while(E!==17){let A=h.getTokenOffset()+h.getTokenLength()+s,_=v(),S="",k=!1;while(p===0&&(_===12||_===13)){let U=h.getTokenOffset()+s;x(ge[1],A,U),A=h.getTokenOffset()+h.getTokenLength()+s,k=_===12,S=k?m():"",_=v()}if(_===2){if(E!==1)u--;if(n.keepLines&&p>0||!n.keepLines&&E!==1)S=m();else if(n.keepLines)S=ge[1]}else if(_===4){if(E!==3)u--;if(n.keepLines&&p>0||!n.keepLines&&E!==3)S=m();else if(n.keepLines)S=ge[1]}else{switch(E){case 3:case 1:if(u++,n.keepLines&&p>0||!n.keepLines)S=m();else S=ge[1];break;case 5:if(n.keepLines&&p>0||!n.keepLines)S=m();else S=ge[1];break;case 12:S=m();break;case 13:if(p>0)S=m();else if(!k)S=ge[1];break;case 6:if(n.keepLines&&p>0)S=m();else if(!k)S=ge[1];break;case 10:if(n.keepLines&&p>0)S=m();else if(_===6&&!k)S="";break;case 7:case 8:case 9:case 11:case 2:case 4:if(n.keepLines&&p>0)S=m();else if((_===12||_===13)&&!k)S=ge[1];else if(_!==5&&_!==17)d=!0;break;case 16:d=!0;break}if(p>0&&(_===12||_===13))S=m()}if(_===17)if(n.keepLines&&p>0)S=m();else S=n.insertFinalNewline?l:"";let R=h.getTokenOffset()+s;x(S,A,R),E=_}return w}function Vt(e,t){let n="";for(let i=0;i<t;i++)n+=e;return n}function Tb(e,t){let n=0,i=0,r=t.tabSize||4;while(n<e.length){let s=e.charAt(n);if(s===ge[1])i++;else if(s==="\t")i+=r;else break;n++}return Math.floor(i/r)}function Ib(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)===`
|
|
500
508
|
`)return`\r
|
|
501
509
|
`;return"\r"}else if(i===`
|
|
502
510
|
`)return`
|
|
503
511
|
`}return e&&e.eol||`
|
|
504
|
-
`}function
|
|
505
|
-
`.indexOf(e.charAt(t))!==-1}var co=I(()=>{Gi();af()});function lf(e,t=[],n=An.DEFAULT){let i=null,r=[],s=[];function o(l){if(Array.isArray(r))r.push(l);else if(i!==null)r[i]=l}return fo(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 uo(e,t=[],n=An.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}fo(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:Dy(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 Hi(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 fo(e,t,n=An.DEFAULT){let i=En(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?(K)=>s===0&&L(K,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(L){return L?(K)=>s===0&&L(K,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),m=p(t.onObjectEnd),h=c(t.onArrayBegin),d=p(t.onArrayEnd),g=l(t.onLiteralValue),x=a(t.onSeparator),b=o(t.onComment),v=a(t.onError),k=n&&n.disallowComments,A=n&&n.allowTrailingComma;function E(){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(!k)S(11);break;case 2:S(12);break;case 6:S(16);break}switch(L){case 12:case 13:if(k)S(10);else b();break;case 16:S(1);break;case 15:case 14:break;default:return L}}}function S(L,K=[],he=[]){if(v(L),K.length+he.length>0){let Ve=i.getToken();while(Ve!==17){if(K.indexOf(Ve)!==-1){E();break}else if(he.indexOf(Ve)!==-1)break;Ve=E()}}}function _(L){let K=i.getTokenValue();if(L)g(K);else f(K),r.push(K);return E(),!0}function R(){switch(i.getToken()){case 11:let L=i.getTokenValue(),K=Number(L);if(isNaN(K))S(2),K=0;g(K);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return E(),!0}function D(){if(i.getToken()!==10)return S(3,[],[2,5]),!1;if(_(!1),i.getToken()===6){if(x(":"),E(),!C())S(4,[],[2,5])}else S(5,[],[2,5]);return r.pop(),!0}function q(){u(),E();let L=!1;while(i.getToken()!==2&&i.getToken()!==17){if(i.getToken()===5){if(!L)S(4,[],[]);if(x(","),E(),i.getToken()===2&&A)break}else if(L)S(6,[],[]);if(!D())S(4,[],[2,5]);L=!0}if(m(),i.getToken()!==2)S(7,[2],[]);else E();return!0}function P(){h(),E();let L=!0,K=!1;while(i.getToken()!==4&&i.getToken()!==17){if(i.getToken()===5){if(!K)S(4,[],[]);if(x(","),E(),i.getToken()===4&&A)break}else if(K)S(6,[],[]);if(L)r.push(0),L=!1;else r[r.length-1]++;if(!C())S(4,[],[4,5]);K=!0}if(d(),!L)r.pop();if(i.getToken()!==4)S(8,[4],[]);else E();return!0}function C(){switch(i.getToken()){case 3:return P();case 1:return q();case 10:return _(!0);default:return R()}}if(E(),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 Dy(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 An;var po=I(()=>{Gi();(function(e){e.DEFAULT={allowTrailingComma:!1}})(An||(An={}))});function cf(e,t,n,i){let r=t.slice(),o=uo(e,[]),a=void 0,l=void 0;while(r.length>0)if(l=r.pop(),a=Hi(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 $t(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=Hi(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 m=a.children[p-1];u=m.offset+m.length}else if(u=a.offset+1,a.children.length>1)f=a.children[1].offset;return $t(e,{offset:u,length:f-u,content:""},i)}else return $t(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((m)=>m.children[0].value)):a.children.length,f;if(u>0){let m=a.children[u-1];f={offset:m.offset+m.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 $t(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 $t(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 m=a.children[p-1],h=m.offset+m.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 $t(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,m=a.children[f-1];p={offset:m.offset+m.length,length:0,content:","+u}}return $t(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 $t(e,t,n){if(!n.formattingOptions)return[t];let i=Ki(e,t),r=t.offset,s=t.offset+t.content.length;if(t.length===0||t.content.length===0){while(r>0&&!kn(i,r-1))r--;while(s<i.length&&!kn(i,s))s++}let o=lo(i,{offset:r,length:s-r},{...n.formattingOptions,keepLines:!1});for(let l=o.length-1;l>=0;l--){let c=o[l];i=Ki(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 Ki(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var uf=I(()=>{co();po()});function hf(e,t,n,i){return cf(e,t,n,i)}function gf(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=Ki(e,s);else throw Error("Overlapping edit");i=s.offset}return e}var ff,df,mf,pf;var yf=I(()=>{co();uf();Gi();po();(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"})(ff||(ff={}));(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"})(df||(df={}));mf=lf;(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"})(pf||(pf={}))});var G=O(function(Yy){var mo=Symbol.for("yaml.alias"),wf=Symbol.for("yaml.document"),Wi=Symbol.for("yaml.map"),bf=Symbol.for("yaml.pair"),ho=Symbol.for("yaml.scalar"),Ji=Symbol.for("yaml.seq"),He=Symbol.for("yaml.node.type"),By=(e)=>!!e&&typeof e==="object"&&e[He]===mo,Vy=(e)=>!!e&&typeof e==="object"&&e[He]===wf,Gy=(e)=>!!e&&typeof e==="object"&&e[He]===Wi,Hy=(e)=>!!e&&typeof e==="object"&&e[He]===bf,vf=(e)=>!!e&&typeof e==="object"&&e[He]===ho,Ky=(e)=>!!e&&typeof e==="object"&&e[He]===Ji;function xf(e){if(e&&typeof e==="object")switch(e[He]){case Wi:case Ji:return!0}return!1}function Wy(e){if(e&&typeof e==="object")switch(e[He]){case mo:case Wi:case ho:case Ji:return!0}return!1}var Jy=(e)=>(vf(e)||xf(e))&&!!e.anchor;Yy.ALIAS=mo;Yy.DOC=wf;Yy.MAP=Wi;Yy.NODE_TYPE=He;Yy.PAIR=bf;Yy.SCALAR=ho;Yy.SEQ=Ji;Yy.hasAnchor=Jy;Yy.isAlias=By;Yy.isCollection=xf;Yy.isDocument=Vy;Yy.isMap=Gy;Yy.isNode=Wy;Yy.isPair=Hy;Yy.isScalar=vf;Yy.isSeq=Ky});var _n=O(function(dw){var oe=G(),fe=Symbol("break visit"),Sf=Symbol("skip children"),De=Symbol("remove node");function Yi(e,t){let n=$f(t);if(oe.isDocument(e)){if(jt(null,e.contents,n,Object.freeze([e]))===De)e.contents=null}else jt(null,e,n,Object.freeze([]))}Yi.BREAK=fe;Yi.SKIP=Sf;Yi.REMOVE=De;function jt(e,t,n,i){let r=Ef(e,t,n,i);if(oe.isNode(r)||oe.isPair(r))return kf(e,i,r),jt(e,r,n,i);if(typeof r!=="symbol"){if(oe.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=jt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===fe)return fe;else if(o===De)t.items.splice(s,1),s-=1}}else if(oe.isPair(t)){i=Object.freeze(i.concat(t));let s=jt("key",t.key,n,i);if(s===fe)return fe;else if(s===De)t.key=null;let o=jt("value",t.value,n,i);if(o===fe)return fe;else if(o===De)t.value=null}}return r}async function zi(e,t){let n=$f(t);if(oe.isDocument(e)){if(await Bt(null,e.contents,n,Object.freeze([e]))===De)e.contents=null}else await Bt(null,e,n,Object.freeze([]))}zi.BREAK=fe;zi.SKIP=Sf;zi.REMOVE=De;async function Bt(e,t,n,i){let r=await Ef(e,t,n,i);if(oe.isNode(r)||oe.isPair(r))return kf(e,i,r),Bt(e,r,n,i);if(typeof r!=="symbol"){if(oe.isCollection(t)){i=Object.freeze(i.concat(t));for(let s=0;s<t.items.length;++s){let o=await Bt(s,t.items[s],n,i);if(typeof o==="number")s=o-1;else if(o===fe)return fe;else if(o===De)t.items.splice(s,1),s-=1}}else if(oe.isPair(t)){i=Object.freeze(i.concat(t));let s=await Bt("key",t.key,n,i);if(s===fe)return fe;else if(s===De)t.key=null;let o=await Bt("value",t.value,n,i);if(o===fe)return fe;else if(o===De)t.value=null}}return r}function $f(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 Ef(e,t,n,i){if(typeof n==="function")return n(e,t,i);if(oe.isMap(t))return n.Map?.(e,t,i);if(oe.isSeq(t))return n.Seq?.(e,t,i);if(oe.isPair(t))return n.Pair?.(e,t,i);if(oe.isScalar(t))return n.Scalar?.(e,t,i);if(oe.isAlias(t))return n.Alias?.(e,t,i);return}function kf(e,t,n){let i=t[t.length-1];if(oe.isCollection(i))i.items[e]=n;else if(oe.isPair(i))if(e==="key")i.key=n;else i.value=n;else if(oe.isDocument(i))i.contents=n;else{let r=oe.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}dw.visit=Yi;dw.visitAsync=zi});var go=O(function(ww){var Af=G(),hw=_n(),gw={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},yw=(e)=>e.replace(/[!,[\]{}]/g,(t)=>gw[t]);class be{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},be.defaultYaml,e),this.tags=Object.assign({},be.defaultTags,t)}clone(){let e=new be(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new be(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:be.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},be.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:be.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},be.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+yw(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&&Af.isNode(e.contents)){let r={};hw.visit(e.contents,(s,o)=>{if(Af.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(`
|
|
506
|
-
`)}}
|
|
507
|
-
`)?
|
|
512
|
+
`}function On(e,t){return`\r
|
|
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
|
+
`)}}ve.defaultYaml={explicit:!1,version:"1.2"};ve.defaultTags={"!!":"tag:yaml.org,2002:"};uw.Directives=ve});var rr=M(function(hw){var Xf=V(),dw=Nn();function pw(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 Qf(e){let t=new Set;return dw.visit(e,{Value(n,i){if(i.anchor)t.add(i.anchor)}}),t}function Zf(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function mw(e,t){let n=[],i=new Map,r=null;return{onAnchor:(s)=>{n.push(s),r??(r=Qf(e));let o=Zf(t,r);return r.add(o),o},setAnchors:()=>{for(let s of n){let o=i.get(s);if(typeof o==="object"&&o.anchor&&(Xf.isScalar(o.node)||Xf.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}}hw.anchorIsValid=pw;hw.anchorNames=Qf;hw.createNodeAnchors=mw;hw.findNewAnchor=Zf});var To=M(function(xw){function Rn(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=Rn(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=Rn(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=Rn(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=Rn(e,i,r,s);if(o===void 0)delete i[r];else if(o!==s)i[r]=o}return e.call(t,n,i)}xw.applyReviver=Rn});var rt=M(function($w){var Sw=V();function ed(e,t,n){if(Array.isArray(e))return e.map((i,r)=>ed(i,String(r),n));if(e&&typeof e.toJSON==="function"){if(!n||!Sw.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}$w.toJS=ed});var sr=M(function(kw){var Ew=To(),td=V(),Aw=rt();class nd{constructor(e){Object.defineProperty(this,td.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(!td.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=Aw.toJS(this,"",s);if(typeof i==="function")for(let{count:a,res:l}of s.anchors.values())i(l,a);return typeof r==="function"?Ew.applyReviver(r,{"":o},"",o):o}}kw.NodeBase=nd});var Ln=M(function(Nw){var Iw=rr(),Mw=Nn(),Wt=V(),Ow=sr(),Cw=rt();class id extends Ow.NodeBase{constructor(e){super(Wt.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=[],Mw.visit(e,{Node:(r,s)=>{if(Wt.isAlias(s)||Wt.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)Cw.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=or(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(Iw.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 or(e,t,n){if(Wt.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Wt.isCollection(t)){let i=0;for(let r of t.items){let s=or(e,r,n);if(s>i)i=s}return i}else if(Wt.isPair(t)){let i=or(e,t.key,n),r=or(e,t.value,n);return Math.max(i,r)}return 1}Nw.Alias=id});var re=M(function(Dw){var Lw=V(),Pw=sr(),Fw=rt(),qw=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class kt extends Pw.NodeBase{constructor(e){super(Lw.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Fw.toJS(this.value,e,t)}toString(){return String(this.value)}}kt.BLOCK_FOLDED="BLOCK_FOLDED";kt.BLOCK_LITERAL="BLOCK_LITERAL";kt.PLAIN="PLAIN";kt.QUOTE_DOUBLE="QUOTE_DOUBLE";kt.QUOTE_SINGLE="QUOTE_SINGLE";Dw.Scalar=kt;Dw.isScalarValue=qw});var Pn=M(function(Kw){var Gw=Ln(),Tt=V(),rd=re(),Bw="tag:yaml.org,2002:";function Vw(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 Hw(e,t,n){if(Tt.isDocument(e))e=e.contents;if(Tt.isNode(e))return e;if(Tt.isPair(e)){let u=n.schema[Tt.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 Gw.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=Bw+t.slice(2);let c=Vw(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new rd.Scalar(e);if(l)l.node=u;return u}c=e instanceof Map?o[Tt.MAP]:(Symbol.iterator in Object(e))?o[Tt.SEQ]:o[Tt.MAP]}if(s)s(c),delete n.onTagObj;let p=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(n.schema,e,n):new rd.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}Kw.createNode=Hw});var ar=M(function(zw){var Jw=Pn(),Be=V(),Yw=sr();function Io(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 Jw.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 sd=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class od extends Yw.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)=>Be.isNode(n)||Be.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(sd(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(Be.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(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(Be.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&&Be.isScalar(r)?r.value:r;else return Be.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!Be.isPair(t))return!1;let n=t.value;return n==null||e&&Be.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 Be.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(Be.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,Io(this.schema,i,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}zw.Collection=od;zw.collectionFromPath=Io;zw.isEmptyPath=sd});var Fn=M(function(n0){var e0=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Mo(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var t0=(e,t,n)=>e.endsWith(`
|
|
515
|
+
`)?Mo(n,t):n.includes(`
|
|
508
516
|
`)?`
|
|
509
|
-
`+
|
|
510
|
-
`){if(n==="block")d=
|
|
511
|
-
`&&
|
|
512
|
-
`&&
|
|
513
|
-
${t}${e.slice(0,A)}`;else{if(n==="quoted"&&p[
|
|
514
|
-
${t}${e.slice(
|
|
515
|
-
`);i=t,r=t+1,s=e[r]}return i}
|
|
516
|
-
`){if(s-o>i)return!0;if(o=s+1,r-o<=i)return!1}return!0}function
|
|
517
|
+
`+Mo(n,t):(e.endsWith(" ")?"":" ")+n;n0.indentComment=Mo;n0.lineComment=t0;n0.stringifyComment=e0});var ld=M(function(a0){function o0(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=[],p={},u=r-t.length;if(typeof i==="number")if(i>r-Math.max(2,s))c.push(0);else u=r-i;let f=void 0,g=void 0,h=!1,d=-1,m=-1,v=-1;if(n==="block"){if(d=ad(e,d,t.length),d!==-1)u=d+l}for(let x;x=e[d+=1];){if(n==="quoted"&&x==="\\"){switch(m=d,e[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}v=d}if(x===`
|
|
518
|
+
`){if(n==="block")d=ad(e,d,t.length);u=d+t.length+l,f=void 0}else{if(x===" "&&g&&g!==" "&&g!==`
|
|
519
|
+
`&&g!=="\t"){let E=e[d+1];if(E&&E!==" "&&E!==`
|
|
520
|
+
`&&E!=="\t")f=d}if(d>=u)if(f)c.push(f),u=f+l,f=void 0;else if(n==="quoted"){while(g===" "||g==="\t")g=x,x=e[d+=1],h=!0;let E=d>v+1?d-2:m-1;if(p[E])return e;c.push(E),p[E]=!0,u=E+l,f=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"&&p[E])w+=`${e[E]}\\`;w+=`
|
|
522
|
+
${t}${e.slice(E+1,A)}`}}return w}function ad(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}a0.FOLD_BLOCK="block";a0.FOLD_FLOW="flow";a0.FOLD_QUOTED="quoted";a0.foldFlowLines=o0});var Dn=M(function(h0){var Ie=re(),st=ld(),cr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ur=(e)=>/^(%|---|\.\.\.)/m.test(e);function d0(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||(ur(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 p=n.substr(l+2,4);switch(p){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(p.substr(0,2)==="00")o+="\\x"+p.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)+`
|
|
517
525
|
|
|
518
526
|
`;while(n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"')o+=`
|
|
519
|
-
`,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:
|
|
520
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
521
|
-
${n}`)+"'";return t.implicitKey?i:
|
|
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,cr(t,!1))}function Oo(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||(ur(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
529
|
+
${n}`)+"'";return t.implicitKey?i:st.foldFlowLines(i,n,st.FOLD_FLOW,cr(t,!1))}function Jt(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=Oo;else if(s&&!r)i=qn;else i=n?Oo:qn}return i(e,t)}var Co;try{Co=new RegExp(`(^|(?<!
|
|
522
530
|
))
|
|
523
531
|
+(?!
|
|
524
|
-
|$)`,"g")}catch{
|
|
532
|
+
|$)`,"g")}catch{Co=/\n+(?!\n|$)/g}function lr({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 Jt(n,i);let c=i.indent||(i.forceBlockIndent||ur(n)?" ":""),p=o==="literal"?!0:o==="folded"||t===Ie.Scalar.BLOCK_FOLDED?!1:t===Ie.Scalar.BLOCK_LITERAL?!0:!d0(n,l,c.length);if(!n)return p?`|
|
|
525
533
|
`:`>
|
|
526
534
|
`;let u,f;for(f=n.length;f>0;--f){let A=n[f-1];if(A!==`
|
|
527
|
-
`&&A!=="\t"&&A!==" ")break}let
|
|
528
|
-
`);if(h===-1)u="-";else if(n===
|
|
529
|
-
`)
|
|
530
|
-
`)
|
|
531
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
532
|
-
${c}${
|
|
533
|
-
${c}${
|
|
534
|
-
`)||p&&/[[\]{},]/.test(s))return
|
|
535
|
-
`)?
|
|
536
|
-
`))return
|
|
537
|
-
${l}`);if(o){let f=(d)=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:
|
|
538
|
-
${t.indent}${a}`}
|
|
539
|
-
${a}:`}else if(
|
|
540
|
-
`:"",
|
|
541
|
-
${
|
|
542
|
-
`&&
|
|
535
|
+
`&&A!=="\t"&&A!==" ")break}let g=n.substring(f),h=g.indexOf(`
|
|
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(Co,`$&${c}`)}let d=!1,m,v=-1;for(m=0;m<n.length;++m){let A=n[m];if(A===" ")d=!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=(d?c?"2":"1":"")+u;if(e){if(E+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r)r()}if(!p){let A=n.replace(/\n+/g,`
|
|
539
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),_=!1,S=cr(i,!0);if(o!=="folded"&&t!==Ie.Scalar.BLOCK_FOLDED)S.onOverflow=()=>{_=!0};let k=st.foldFlowLines(`${w}${A}${g}`,c,st.FOLD_BLOCK,S);if(!_)return`>${E}
|
|
540
|
+
${c}${k}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
|
|
541
|
+
${c}${w}${n}${g}`}function p0(e,t,n,i){let{type:r,value:s}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:p}=t;if(a&&s.includes(`
|
|
542
|
+
`)||p&&/[[\]{},]/.test(s))return Jt(s,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||p||!s.includes(`
|
|
543
|
+
`)?Jt(s,t):lr(e,t,n,i);if(!a&&!p&&r!==Ie.Scalar.PLAIN&&s.includes(`
|
|
544
|
+
`))return lr(e,t,n,i);if(ur(s)){if(l==="")return t.forceBlockIndent=!0,lr(e,t,n,i);else if(a&&l===c)return Jt(s,t)}let u=s.replace(/\n+/g,`$&
|
|
545
|
+
${l}`);if(o){let f=(d)=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:g,tags:h}=t.doc.schema;if(h.some(f)||g?.some(f))return Jt(s,t)}return a?u:st.foldFlowLines(u,l,st.FOLD_FLOW,cr(t,!1))}function m0(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!==Ie.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=Ie.Scalar.QUOTE_DOUBLE}let l=(p)=>{switch(p){case Ie.Scalar.BLOCK_FOLDED:case Ie.Scalar.BLOCK_LITERAL:return r||s?Jt(o.value,t):lr(o,t,n,i);case Ie.Scalar.QUOTE_DOUBLE:return qn(o.value,t);case Ie.Scalar.QUOTE_SINGLE:return Oo(o.value,t);case Ie.Scalar.PLAIN:return p0(o,t,n,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:p,defaultStringType:u}=t.options,f=r&&p||u;if(c=l(f),c===null)throw Error(`Unsupported default string type ${f}`)}return c}h0.stringifyString=m0});var Un=M(function(_0){var y0=rr(),ot=V(),b0=Fn(),w0=Dn();function x0(e,t){let n=Object.assign({blockQuote:!0,commentString:b0.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 v0(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 S0(e,t,{anchors:n,doc:i}){if(!i.directives)return"";let r=[],s=(ot.isScalar(e)||ot.isCollection(e))&&e.anchor;if(s&&y0.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 $0(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=v0(t.doc.schema.tags,s));let o=S0(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)?w0.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}`}_0.createStringifyContext=x0;_0.stringify=$0});var fd=M(function(T0){var ze=V(),cd=re(),ud=Un(),jn=Fn();function k0({key:e,value:t},n,i,r){let{allNullValues:s,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:p,simpleKeys:u}}=n,f=ze.isNode(e)&&e.comment||null;if(u){if(f)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||f&&t==null&&!n.inFlow||ze.isCollection(e)||(ze.isScalar(e)?e.type===cd.Scalar.BLOCK_FOLDED||e.type===cd.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!g&&(u||!s),indent:a+l});let h=!1,d=!1,m=ud.stringify(e,n,()=>h=!0,()=>d=!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}`,f&&!h)m+=jn.lineComment(m,n.indent,c(f));else if(d&&r)r();return m}if(h)f=null;if(g){if(f)m+=jn.lineComment(m,n.indent,c(f));m=`? ${m}
|
|
547
|
+
${a}:`}else if(m=`${m}:`,f)m+=jn.lineComment(m,n.indent,c(f));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&&!f&&ze.isScalar(t))n.indentAtStart=m.length+1;if(d=!1,!p&&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=ud.stringify(t,n,()=>E=!0,()=>d=!0),_=" ";if(f||v||w){if(_=v?`
|
|
548
|
+
`:"",w){let S=c(w);_+=`
|
|
549
|
+
${jn.indentComment(S,n.indent)}`}if(A===""&&!n.inFlow){if(_===`
|
|
550
|
+
`&&x)_=`
|
|
543
551
|
|
|
544
|
-
`}else
|
|
545
|
-
${n.indent}`}else if(!
|
|
546
|
-
`),R=
|
|
552
|
+
`}else _+=`
|
|
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 q=!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)q=!0}if(!q)_=`
|
|
547
555
|
${n.indent}`}}else if(A===""||A[0]===`
|
|
548
|
-
`)
|
|
556
|
+
`)_="";if(m+=_+A,n.inFlow){if(E&&i)i()}else if(x&&!E)m+=jn.lineComment(m,n.indent,c(x));else if(d&&r)r();return m}T0.stringifyPair=k0});var No=M(function(C0){var dd=an("process");function M0(e,...t){if(e==="debug")console.log(...t)}function O0(e,t){if(e==="debug"||e==="warn")if(typeof dd.emitWarning==="function")dd.emitWarning(t);else console.warn(t)}C0.debug=M0;C0.warn=O0});var mr=M(function(P0){var pr=V(),pd=re(),fr="<<",dr={identify:(e)=>e===fr||typeof e==="symbol"&&e.description===fr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new pd.Scalar(Symbol(fr)),{addToJSMap:md}),stringify:()=>fr},L0=(e,t)=>(dr.identify(t)||pr.isScalar(t)&&(!t.type||t.type===pd.Scalar.PLAIN)&&dr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===dr.tag&&n.default);function md(e,t,n){let i=hd(e,n);if(pr.isSeq(i))for(let r of i.items)Ro(e,t,r);else if(Array.isArray(i))for(let r of i)Ro(e,t,r);else Ro(e,t,i)}function Ro(e,t,n){let i=hd(e,n);if(!pr.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 hd(e,t){return e&&pr.isAlias(t)?t.resolve(e.doc,e):t}P0.addMergeToJSMap=md;P0.isMergeKey=L0;P0.merge=dr});var Po=M(function(V0){var U0=No(),gd=mr(),j0=Un(),yd=V(),Lo=rt();function G0(e,t,{key:n,value:i}){if(yd.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,i);else if(gd.isMergeKey(e,n))gd.addMergeToJSMap(e,t,i);else{let r=Lo.toJS(n,"",e);if(t instanceof Map)t.set(r,Lo.toJS(i,r,e));else if(t instanceof Set)t.add(r);else{let s=B0(n,r,e),o=Lo.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 B0(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(yd.isNode(e)&&n?.doc){let i=j0.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)+'..."';U0.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)}V0.addPairToJSMap=G0});var at=M(function(Y0){var bd=Pn(),K0=fd(),W0=Po(),hr=V();function J0(e,t,n){let i=bd.createNode(e,void 0,n),r=bd.createNode(t,void 0,n);return new gr(i,r)}class gr{constructor(e,t=null){Object.defineProperty(this,hr.NODE_TYPE,{value:hr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(hr.isNode(t))t=t.clone(e);if(hr.isNode(n))n=n.clone(e);return new gr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return W0.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?K0.stringifyPair(this,e,t,n):JSON.stringify(this)}}Y0.Pair=gr;Y0.createPair=J0});var Fo=M(function(t1){var It=V(),wd=Un(),yr=Fn();function Q0(e,t,n){return(t.inFlow??e.flow?e1:Z0)(e,t,n)}function Z0({comment:e,items:t},n,{blockItemPrefix:i,flowChars:r,itemIndent:s,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,p=Object.assign({},n,{indent:s,type:null}),u=!1,f=[];for(let h=0;h<t.length;++h){let d=t[h],m=null;if(It.isNode(d)){if(!u&&d.spaceBefore)f.push("");if(br(n,f,d.commentBefore,u),d.comment)m=d.comment}else if(It.isPair(d)){let w=It.isNode(d.key)?d.key:null;if(w){if(!u&&w.spaceBefore)f.push("");br(n,f,w.commentBefore,u)}}u=!1;let v=wd.stringify(d,p,()=>m=null,()=>u=!0);if(m)v+=yr.lineComment(v,s,c(m));if(u&&m)u=!1;f.push(i+v)}let g;if(f.length===0)g=r.start+r.end;else{g=f[0];for(let h=1;h<f.length;++h){let d=f[h];g+=d?`
|
|
549
557
|
${l}${d}`:`
|
|
550
|
-
`}}if(e){if(
|
|
551
|
-
`+
|
|
552
|
-
`)),h<e.length-1)
|
|
558
|
+
`}}if(e){if(g+=`
|
|
559
|
+
`+yr.indentComment(c(e),l),a)a()}else if(u&&o)o();return g}function e1({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,p=0,u=[];for(let h=0;h<e.length;++h){let d=e[h],m=null;if(It.isNode(d)){if(d.spaceBefore)u.push("");if(br(t,u,d.commentBefore,!1),d.comment)m=d.comment}else if(It.isPair(d)){let w=It.isNode(d.key)?d.key:null;if(w){if(w.spaceBefore)u.push("");if(br(t,u,w.commentBefore,!1),w.comment)c=!0}let x=It.isNode(d.value)?d.value:null;if(x){if(x.comment)m=x.comment;if(x.commentBefore)c=!0}else if(d.value==null&&w?.comment)m=w.comment}if(m)c=!0;let v=wd.stringify(d,l,()=>m=null);if(c||(c=u.length>p||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+=yr.lineComment(v,i,a(m));u.push(v),p=u.length}let{start:f,end:g}=n;if(u.length===0)return f+g;else{if(!c){let h=u.reduce((d,m)=>d+m.length+2,2);c=t.options.lineWidth>0&&h>t.options.lineWidth}if(c){let h=f;for(let d of u)h+=d?`
|
|
553
561
|
${s}${r}${d}`:`
|
|
554
562
|
`;return`${h}
|
|
555
|
-
${r}${
|
|
556
|
-
`:" ")}return
|
|
563
|
+
${r}${g}`}else return`${f}${o}${u.join(" ")}${o}${g}`}}function br({indent:e,options:{commentString:t}},n,i,r){if(i&&r)i=i.replace(/^\n+/,"");if(i){let s=yr.indentComment(t(i),e);n.push(s.trimStart())}}t1.stringifyCollection=Q0});var ct=M(function(a1){var i1=Fo(),r1=Po(),s1=ar(),lt=V(),wr=at(),o1=re();function Gn(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 xd extends s1.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(wr.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 wr.Pair(e,e?.value);else n=new wr.Pair(e.key,e.value);let i=Gn(this.items,n.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw Error(`Key ${n.key} already set`);if(lt.isScalar(i.value)&&o1.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=Gn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let i=Gn(this.items,e)?.value;return(!t&<.isScalar(i)?i.value:i)??void 0}has(e){return!!Gn(this.items,e)}set(e,t){this.add(new wr.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)r1.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 i1.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}a1.YAMLMap=xd;a1.findPair=Gn});var Yt=M(function(d1){var u1=V(),vd=ct(),f1={collection:"map",default:!0,nodeClass:vd.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!u1.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>vd.YAMLMap.from(e,t,n)};d1.map=f1});var ut=M(function(w1){var m1=Pn(),h1=Fo(),g1=ar(),vr=V(),y1=re(),b1=rt();class Sd extends g1.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vr.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=xr(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=xr(e);if(typeof n!=="number")return;let i=this.items[n];return!t&&vr.isScalar(i)?i.value:i}has(e){let t=xr(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=xr(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let i=this.items[n];if(vr.isScalar(i)&&y1.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(b1.toJS(r,String(i++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return h1.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(m1.createNode(o,void 0,n))}}return r}}function xr(e){let t=vr.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}w1.YAMLSeq=Sd});var zt=M(function($1){var v1=V(),$d=ut(),S1={collection:"seq",default:!0,nodeClass:$d.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!v1.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>$d.YAMLSeq.from(e,t,n)};$1.seq=S1});var Bn=M(function(k1){var E1=Dn(),A1={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),E1.stringifyString(e,t,n,i)}};k1.string=A1});var Sr=M(function(I1){var _d=re(),Ed={identify:(e)=>e==null,createNode:()=>new _d.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _d.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&Ed.test.test(e)?e:t.options.nullStr};I1.nullTag=Ed});var qo=M(function(C1){var O1=re(),Ad={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new O1.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&Ad.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?n.options.trueStr:n.options.falseStr}};C1.boolTag=Ad});var Xt=M(function(L1){function R1({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}L1.stringifyNumber=R1});var Uo=M(function(j1){var F1=re(),Do=Xt(),q1={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:Do.stringifyNumber},D1={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():Do.stringifyNumber(e)}},U1={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 F1.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:Do.stringifyNumber};j1.float=U1;j1.floatExp=D1;j1.floatNaN=q1});var Go=M(function(J1){var kd=Xt(),$r=(e)=>typeof e==="bigint"||Number.isInteger(e),jo=(e,t,n,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),n);function Td(e,t,n){let{value:i}=e;if($r(i)&&i>=0)return n+i.toString(t);return kd.stringifyNumber(e)}var H1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>jo(e,2,8,n),stringify:(e)=>Td(e,8,"0o")},K1={identify:$r,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>jo(e,0,10,n),stringify:kd.stringifyNumber},W1={identify:(e)=>$r(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>jo(e,2,16,n),stringify:(e)=>Td(e,16,"0x")};J1.int=K1;J1.intHex=W1;J1.intOct=H1});var Id=M(function(rx){var Q1=Yt(),Z1=Sr(),ex=zt(),tx=Bn(),nx=qo(),Bo=Uo(),Vo=Go(),ix=[Q1.map,ex.seq,tx.string,Z1.nullTag,nx.boolTag,Vo.intOct,Vo.int,Vo.intHex,Bo.floatNaN,Bo.floatExp,Bo.float];rx.schema=ix});var Od=M(function(dx){var ox=re(),ax=Yt(),lx=zt();function Md(e){return typeof e==="bigint"||Number.isInteger(e)}var _r=({value:e})=>JSON.stringify(e),cx=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:_r},{identify:(e)=>e==null,createNode:()=>new ox.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_r},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:_r},{identify:Md,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})=>Md(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:_r}],ux={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},fx=[ax.map,lx.seq].concat(cx,ux);dx.schema=fx});var Ko=M(function(gx){var Vn=an("buffer"),Ho=re(),mx=Dn(),hx={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Vn.Buffer==="function")return Vn.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 Vn.Buffer==="function")a=o instanceof Vn.Buffer?o.toString("base64"):Vn.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=Ho.Scalar.BLOCK_LITERAL),t!==Ho.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let u=0,f=0;u<c;++u,f+=l)p[u]=a.substr(f,l);a=p.join(t===Ho.Scalar.BLOCK_LITERAL?`
|
|
564
|
+
`:" ")}return mx.stringifyString({comment:e,type:t,value:a},i,r,s)}};gx.binary=hx});var Ar=M(function(vx){var Er=V(),Wo=at(),bx=re(),wx=ut();function Cd(e,t){if(Er.isSeq(e))for(let n=0;n<e.items.length;++n){let i=e.items[n];if(Er.isPair(i))continue;else if(Er.isMap(i)){if(i.items.length>1)t("Each pair must have its own sequence indicator");let r=i.items[0]||new Wo.Pair(new bx.Scalar(null));if(i.commentBefore)r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
|
|
557
565
|
${r.key.commentBefore}`:i.commentBefore;if(i.comment){let s=r.value??r.key;s.comment=s.comment?`${i.comment}
|
|
558
|
-
${s.comment}`:i.comment}i=r}e.items[n]=wr.isPair(i)?i:new Po.Pair(i)}else t("Expected a sequence for this tag");return e}function cd(e,t,n){let{replacer:i}=n,r=new _1.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(Po.createPair(a,l,n))}return r}var T1={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ld,createNode:cd};I1.createPairs=cd;I1.pairs=T1;I1.resolvePairs=ld});var qo=O(function(L1){var ud=G(),Fo=it(),Dn=lt(),N1=ct(),fd=br();class _t extends N1.YAMLSeq{constructor(){super();this.add=Dn.YAMLMap.prototype.add.bind(this),this.delete=Dn.YAMLMap.prototype.delete.bind(this),this.get=Dn.YAMLMap.prototype.get.bind(this),this.has=Dn.YAMLMap.prototype.has.bind(this),this.set=Dn.YAMLMap.prototype.set.bind(this),this.tag=_t.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(ud.isPair(i))r=Fo.toJS(i.key,"",t),s=Fo.toJS(i.value,r,t);else r=Fo.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=fd.createPairs(e,t,n),r=new this;return r.items=i.items,r}}_t.tag="tag:yaml.org,2002:omap";var R1={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:_t,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=fd.resolvePairs(e,t),i=[];for(let{key:r}of n.items)if(ud.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 _t,n)},createNode:(e,t,n)=>_t.from(e,t,n)};L1.YAMLOMap=_t;L1.omap=R1});var gd=O(function(q1){var dd=ie();function pd({value:e,source:t},n){if(t&&(e?md:hd).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var md={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 dd.Scalar(!0),stringify:pd},hd={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 dd.Scalar(!1),stringify:pd};q1.falseTag=hd;q1.trueTag=md});var yd=O(function(H1){var j1=ie(),Do=Wt(),B1={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:Do.stringifyNumber},V1={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():Do.stringifyNumber(e)}},G1={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 j1.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:Do.stringifyNumber};H1.float=G1;H1.floatExp=V1;H1.floatNaN=B1});var bd=O(function(Z1){var wd=Wt(),Un=(e)=>typeof e==="bigint"||Number.isInteger(e);function vr(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 Uo(e,t,n){let{value:i}=e;if(Un(i)){let r=i.toString(t);return i<0?"-"+n+r.substr(1):n+r}return wd.stringifyNumber(e)}var Y1={identify:Un,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>vr(e,2,2,n),stringify:(e)=>Uo(e,2,"0b")},z1={identify:Un,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>vr(e,1,8,n),stringify:(e)=>Uo(e,8,"0")},X1={identify:Un,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>vr(e,0,10,n),stringify:wd.stringifyNumber},Q1={identify:Un,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>vr(e,2,16,n),stringify:(e)=>Uo(e,16,"0x")};Z1.int=X1;Z1.intBin=Y1;Z1.intHex=Q1;Z1.intOct=z1});var jo=O(function(sv){var $r=G(),xr=ot(),Sr=lt();class Tt extends Sr.YAMLMap{constructor(e){super(e);this.tag=Tt.tag}add(e){let t;if($r.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new xr.Pair(e.key,null);else t=new xr.Pair(e,null);if(!Sr.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=Sr.findPair(this.items,e);return!t&&$r.isPair(n)?$r.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=Sr.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new xr.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(xr.createPair(s,null,n))}return r}}Tt.tag="tag:yaml.org,2002:set";var rv={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Tt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Tt.from(e,t,n),resolve(e,t){if($r.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Tt,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};sv.YAMLSet=Tt;sv.set=rv});var Vo=O(function(fv){var lv=Wt();function Bo(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 lv.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 cv={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})=>Bo(e,n),stringify:vd},uv={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)=>Bo(e,!1),stringify:vd},xd={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(xd.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=Bo(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$/,"")??""};fv.floatTime=uv;fv.intTime=cv;fv.timestamp=xd});var $d=O(function(kv){var hv=Ht(),gv=hr(),yv=Kt(),wv=Fn(),bv=Lo(),Sd=gd(),Go=yd(),Er=bd(),vv=ar(),xv=qo(),Sv=br(),$v=jo(),Ho=Vo(),Ev=[hv.map,yv.seq,wv.string,gv.nullTag,Sd.trueTag,Sd.falseTag,Er.intBin,Er.intOct,Er.int,Er.intHex,Go.floatNaN,Go.floatExp,Go.float,bv.binary,vv.merge,xv.omap,Sv.pairs,$v.set,Ho.intTime,Ho.floatTime,Ho.timestamp];kv.schema=Ev});var Nd=O(function(Rv){var _d=Ht(),_v=hr(),Td=Kt(),Tv=Fn(),Iv=_o(),Ko=Io(),Wo=Mo(),Ov=sd(),Mv=ad(),Id=Lo(),jn=ar(),Od=qo(),Md=br(),Ed=$d(),Cd=jo(),kr=Vo(),kd=new Map([["core",Ov.schema],["failsafe",[_d.map,Td.seq,Tv.string]],["json",Mv.schema],["yaml11",Ed.schema],["yaml-1.1",Ed.schema]]),Ad={binary:Id.binary,bool:Iv.boolTag,float:Ko.float,floatExp:Ko.floatExp,floatNaN:Ko.floatNaN,floatTime:kr.floatTime,int:Wo.int,intHex:Wo.intHex,intOct:Wo.intOct,intTime:kr.intTime,map:_d.map,merge:jn.merge,null:_v.nullTag,omap:Od.omap,pairs:Md.pairs,seq:Td.seq,set:Cd.set,timestamp:kr.timestamp},Cv={"tag:yaml.org,2002:binary":Id.binary,"tag:yaml.org,2002:merge":jn.merge,"tag:yaml.org,2002:omap":Od.omap,"tag:yaml.org,2002:pairs":Md.pairs,"tag:yaml.org,2002:set":Cd.set,"tag:yaml.org,2002:timestamp":kr.timestamp};function Nv(e,t,n){let i=kd.get(t);if(i&&!e)return n&&!i.includes(jn.merge)?i.concat(jn.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let s=Array.from(kd.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(jn.merge);return r.reduce((s,o)=>{let a=typeof o==="string"?Ad[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ad).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},[])}Rv.coreKnownTags=Cv;Rv.getTags=Nv});var zo=O(function(jv){var Jo=G(),Fv=Ht(),qv=Kt(),Dv=Fn(),Ar=Nd(),Uv=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Yo{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:s,toStringDefaults:o}){this.compat=Array.isArray(e)?Ar.getTags(e,"compat"):e?Ar.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=i?Ar.coreKnownTags:{},this.tags=Ar.getTags(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Jo.MAP,{value:Fv.map}),Object.defineProperty(this,Jo.SCALAR,{value:Dv.string}),Object.defineProperty(this,Jo.SEQ,{value:qv.seq}),this.sortMapEntries=typeof s==="function"?s:s===!0?Uv:null}clone(){let e=Object.create(Yo.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}jv.Schema=Yo});var Rd=O(function(Hv){var Vv=G(),Xo=Rn(),Bn=Mn();function Gv(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=Xo.createStringifyContext(e,t),{commentString:s}=r.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let l=s(e.commentBefore);n.unshift(Bn.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 p=s(e.contents.commentBefore);n.push(Bn.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Xo.stringify(e.contents,r,()=>a=null,l);if(a)c+=Bn.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(Xo.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=s(e.comment);if(l.includes(`
|
|
559
|
-
`))n.push("..."),n.push(
|
|
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(`
|
|
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(`
|
|
560
568
|
`)+`
|
|
561
|
-
`}
|
|
569
|
+
`}Fv.stringifyDocument=Pv});var Yn=M(function(Kv){var Dv=Ln(),Qt=ar(),Se=V(),Uv=at(),jv=rt(),Gv=aa(),Bv=rp(),ca=rr(),Vv=To(),Hv=Pn(),ua=ko();class fa{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Se.NODE_TYPE,{value:Se.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 ua.Directives({version:s});this.setSchema(s,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let e=Object.create(fa.prototype,{[Se.NODE_TYPE]:{value:Se.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=Se.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Zt(this.contents))this.contents.add(e)}addIn(e,t){if(Zt(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=ca.anchorNames(this);e.anchor=!t||n.has(t)?ca.findNewAnchor(t||"a",n):t}return new Dv.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 d=(v)=>typeof v==="number"||v instanceof String||v instanceof Number,m=t.filter(d).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:p,setAnchors:u,sourceObjects:f}=ca.createNodeAnchors(this,s||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:i,schema:this.schema,sourceObjects:f},h=Hv.createNode(e,c,g);if(o&&Se.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 Uv.Pair(i,r)}delete(e){return Zt(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(Qt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Zt(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Se.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(Qt.isEmptyPath(e))return!t&&Se.isScalar(this.contents)?this.contents.value:this.contents;return Se.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Se.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(Qt.isEmptyPath(e))return this.contents!==void 0;return Se.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,[e],t);else if(Zt(this.contents))this.contents.set(e,t)}setIn(e,t){if(Qt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=Qt.collectionFromPath(this.schema,Array.from(e),t);else if(Zt(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 ua.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 ua.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 Gv.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=jv.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"?Vv.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 Bv.stringifyDocument(this,e)}}function Zt(e){if(Se.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}Kv.Document=fa});var zn=M(function(Yv){class Rr extends Error{constructor(e,t,n,i){super();this.name=e,this.code=n,this.message=i,this.pos=t}}class sp extends Rr{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class op extends Rr{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var Jv=(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)+`…
|
|
562
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+=`:
|
|
563
571
|
|
|
564
572
|
${o}
|
|
565
573
|
${c}
|
|
566
|
-
`}};
|
|
567
|
-
`))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(
|
|
568
|
-
`+d.comment;else a.comment=d.comment;continue}if(d.newlineAfterProp||
|
|
569
|
-
`+
|
|
570
|
-
`+
|
|
571
|
-
`+S;else
|
|
572
|
-
`+R.comment;else
|
|
573
|
-
`+
|
|
574
|
-
`.repeat(Math.max(1,o.length-1)):"",
|
|
575
|
-
`;for(let d=p;d<a;++d){let[
|
|
576
|
-
`;else if(
|
|
577
|
-
`;else if(!
|
|
574
|
+
`}};Yv.YAMLError=Rr;Yv.YAMLParseError=sp;Yv.YAMLWarning=op;Yv.prettifyError=Jv});var Xn=M(function(tS){function eS(e,{flow:t,indicator:n,next:i,offset:r,onError:s,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,u="",f="",g=!1,h=!1,d=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(d){if(c&&k.type!=="comment"&&k.type!=="newline")s(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");d=null}switch(k.type){case"space":if(!t&&(n!=="doc-start"||i?.type!=="flow-collection")&&k.source.includes("\t"))d=k;p=!0;break;case"comment":{if(!p)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+=f+R;f="",c=!1;break}case"newline":if(c){if(u)u+=k.source;else if(!E||n!=="seq-item-ind")l=!0}else f+=k.source;if(c=!0,g=!0,m||v)w=k;p=!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,p=!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,p=!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",p=!1;break;case"comma":if(t){if(x)s(k,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);x=k,c=!1,p=!1;break}default:s(k,"UNEXPECTED_TOKEN",`Unexpected ${k.type} token`),c=!1,p=!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(d&&(c&&d.indent<=o||i?.type==="block-map"||i?.type==="block-seq"))s(d,"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}}tS.resolveProps=eS});var Lr=M(function(iS){function da(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(da(t.key)||da(t.value))return!0}return!1;default:return!0}}iS.containsNewline=da});var pa=M(function(aS){var sS=Lr();function oS(e,t,n){if(t?.type==="flow-collection"){let i=t.end[0];if(i.indent===e&&(i.source==="]"||i.source==="}")&&sS.containsNewline(t))n(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}aS.flowIndentCheck=oS});var ma=M(function(uS){var ap=V();function cS(e,t,n){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let r=typeof i==="function"?i:(s,o)=>s===o||ap.isScalar(s)&&ap.isScalar(o)&&s.value===o.value;return t.some((s)=>r(s.key,n))}uS.mapIncludes=cS});var dp=M(function(gS){var lp=at(),dS=ct(),cp=Xn(),pS=Lr(),up=pa(),mS=ma(),fp="All mapping items must start at the same column";function hS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??dS.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let l=i.offset,c=null;for(let p of i.items){let{start:u,key:f,sep:g,value:h}=p,d=cp.resolveProps(u,{indicator:"explicit-key-ind",next:f??g?.[0],offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0}),m=!d.found;if(m){if(f){if(f.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 f&&f.indent!==i.indent)r(l,"BAD_INDENT",fp)}if(!d.anchor&&!d.tag&&!g){if(c=d.end,d.comment)if(a.comment)a.comment+=`
|
|
576
|
+
`+d.comment;else a.comment=d.comment;continue}if(d.newlineAfterProp||pS.containsNewline(f))r(f??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(d.found?.indent!==i.indent)r(l,"BAD_INDENT",fp);n.atKey=!0;let v=d.end,w=f?e(n,f,d,r):t(n,v,u,null,d,r);if(n.schema.compat)up.flowIndentCheck(i.indent,f,r);if(n.atKey=!1,mS.mapIncludes(n,a.items,w))r(v,"DUPLICATE_KEY","Map keys must be unique");let x=cp.resolveProps(g??[],{indicator:"map-value-ind",next:h,offset:w.range[2],onError:r,parentIndent:i.indent,startOnNewline:!f||f.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&&d.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)up.flowIndentCheck(i.indent,h,r);l=E.range[2];let A=new lp.Pair(w,E);if(n.options.keepSourceTokens)A.srcToken=p;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 lp.Pair(w);if(n.options.keepSourceTokens)E.srcToken=p;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}gS.resolveBlockMap=hS});var pp=M(function(SS){var bS=ut(),wS=Xn(),xS=pa();function vS({composeNode:e,composeEmptyNode:t},n,i,r,s){let a=new(s?.nodeClass??bS.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let l=i.offset,c=null;for(let{start:p,value:u}of i.items){let f=wS.resolveProps(p,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||u)if(u?.type==="block-seq")r(f.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=f.end,f.comment)a.comment=f.comment;continue}let g=u?e(n,u,f,r):t(n,f.end,p,null,f,r);if(n.schema.compat)xS.flowIndentCheck(i.indent,u,r);l=g.range[2],a.items.push(g)}return a.range=[i.offset,l,c??l],a}SS.resolveBlockSeq=vS});var en=M(function(ES){function _S(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 p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;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}}ES.resolveEnd=_S});var gp=M(function(RS){var kS=V(),TS=at(),mp=ct(),IS=ut(),MS=en(),hp=Xn(),OS=Lr(),CS=ma(),ha="Block collections are not allowed within flow collections",ga=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function NS({composeNode:e,composeEmptyNode:t},n,i,r,s){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=new(s?.nodeClass??(o?mp.YAMLMap:IS.YAMLSeq))(n.schema);c.flow=!0;let p=n.atRoot;if(p)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,_=hp.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&&OS.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(kS.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],ga(A))r(S.range,"BLOCK_IN_FLOW",ha)}else{n.atKey=!0;let S=_.end,k=x?e(n,x,_,r):t(n,S,w,null,_,r);if(ga(x))r(k.range,"BLOCK_IN_FLOW",ha);n.atKey=!1;let R=hp.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(ga(A))r(U.range,"BLOCK_IN_FLOW",ha)}else if(R.comment)if(k.comment)k.comment+=`
|
|
580
|
+
`+R.comment;else k.comment=R.comment;let q=new TS.Pair(k,U);if(n.options.keepSourceTokens)q.srcToken=v;if(o){let P=c;if(CS.mapIncludes(n,P.items,k))r(S,"DUPLICATE_KEY","Map keys must be unique");P.items.push(q)}else{let P=new mp.YAMLMap(n.schema);P.flow=!0,P.items.push(q);let C=(U??k).range;P.range=[k.range[0],C[1],C[2]],c.items.push(P)}u=U?U.range[2]:R.end}}let f=o?"}":"]",[g,...h]=i.end,d=u;if(g?.source===f)d=g.offset+g.source.length;else{let m=a[0].toUpperCase()+a.substring(1),v=p?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;if(r(u,p?"MISSING_CHAR":"BAD_INDENT",v),g&&g.source.length!==1)h.unshift(g)}if(h.length>0){let m=MS.resolveEnd(h,d,n.options.strict,r);if(m.comment)if(c.comment)c.comment+=`
|
|
581
|
+
`+m.comment;else c.comment=m.comment;c.range=[i.offset,d,m.offset]}else c.range=[i.offset,d,d];return c}RS.resolveFlowCollection=NS});var yp=M(function(VS){var PS=V(),FS=re(),qS=ct(),DS=ut(),US=dp(),jS=pp(),GS=gp();function ya(e,t,n,i,r,s){let o=n.type==="block-map"?US.resolveBlockMap(e,t,n,i,s):n.type==="block-seq"?jS.resolveBlockSeq(e,t,n,i,s):GS.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 BS(e,t,n,i,r){let s=i.tag,o=!s?null:t.directives.tagName(s.source,(f)=>r(s,"TAG_RESOLVE_FAILED",f));if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:g}=i,h=f&&s?f.offset>s.offset?f:s:f??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===qS.YAMLMap.tagName&&a==="map"||o===DS.YAMLSeq.tagName&&a==="seq")return ya(e,t,n,r,o);let l=t.schema.tags.find((f)=>f.tag===o&&f.collection===a);if(!l){let f=t.schema.knownTags[o];if(f?.collection===a)t.schema.tags.push(Object.assign({},f,{default:!1})),l=f;else{if(f)r(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0);else r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return ya(e,t,n,r,o)}}let c=ya(e,t,n,r,o,l),p=l.resolve?.(c,(f)=>r(s,"TAG_RESOLVE_FAILED",f),t.options)??c,u=PS.isNode(p)?p:new FS.Scalar(p);if(u.range=c.range,u.tag=o,l?.format)u.format=l.format;return u}VS.composeCollection=BS});var wa=M(function(YS){var ba=re();function KS(e,t,n){let i=t.offset,r=WS(t,e.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let s=r.mode===">"?ba.Scalar.BLOCK_FOLDED:ba.Scalar.BLOCK_LITERAL,o=t.source?JS(t.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let m=o[d][1];if(m===""||m==="\r")a=d;else break}if(a===0){let d=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:d,type:s,comment:r.comment,range:[i,m,m]}}let l=t.indent+r.indent,c=t.offset+r.length,p=0;for(let d=0;d<a;++d){let[m,v]=o[d];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(p=d,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 d=o.length-1;d>=a;--d)if(o[d][0].length>l)a=d+1;let u="",f="",g=!1;for(let d=0;d<p;++d)u+=o[d][0].slice(l)+`
|
|
583
|
+
`;for(let d=p;d<a;++d){let[m,v]=o[d];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===ba.Scalar.BLOCK_LITERAL)u+=f+m.slice(l)+v,f=`
|
|
584
|
+
`;else if(m.length>l||v[0]==="\t"){if(f===" ")f=`
|
|
585
|
+
`;else if(!g&&f===`
|
|
578
586
|
`)f=`
|
|
579
587
|
|
|
580
|
-
`;u+=f+
|
|
581
|
-
`,
|
|
588
|
+
`;u+=f+m.slice(l)+v,f=`
|
|
589
|
+
`,g=!0}else if(v==="")if(f===`
|
|
582
590
|
`)u+=`
|
|
583
591
|
`;else f=`
|
|
584
|
-
`;else u+=f+
|
|
592
|
+
`;else u+=f+v,f=" ",g=!1}switch(r.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)u+=`
|
|
585
593
|
`+o[d][0].slice(l);if(u[u.length-1]!==`
|
|
586
594
|
`)u+=`
|
|
587
595
|
`;break;default:u+=`
|
|
588
|
-
`}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 WS({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 f=1;f<r.length;++f){let g=r[f];if(!a&&(g==="-"||g==="+"))a=g;else{let h=Number(g);if(!o&&h)o=h;else if(l===-1)l=e+f}}if(l!==-1)i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,p="",u=r.length;for(let f=1;f<t.length;++f){let g=t[f];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,p=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 d=g.source;if(d&&typeof d==="string")u+=d.length}}}return{mode:s,indent:o,chomp:a,comment:p,length:u}}function JS(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}YS.resolveBlockScalar=KS});var va=M(function(s$){var xa=re(),XS=en();function QS(e,t,n){let{offset:i,type:r,source:s,end:o}=e,a,l,c=(f,g,h)=>n(i+f,g,h);switch(r){case"scalar":a=xa.Scalar.PLAIN,l=ZS(s,c);break;case"single-quoted-scalar":a=xa.Scalar.QUOTE_SINGLE,l=e$(s,c);break;case"double-quoted-scalar":a=xa.Scalar.QUOTE_DOUBLE,l=t$(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 p=i+s.length,u=XS.resolveEnd(o,p,t,n);return{value:l,type:a,comment:u.comment,range:[i,p,u.offset]}}function ZS(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 bp(e)}function e$(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return bp(e.slice(1,-1)).replace(/''/g,"'")}function bp(e){let t,n;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
589
597
|
`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
590
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===`
|
|
591
599
|
`)r+=s;else s=`
|
|
592
|
-
`;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 t$(e,t){let n="";for(let i=1;i<e.length-1;++i){let r=e[i];if(r==="\r"&&e[i+1]===`
|
|
593
601
|
`)continue;if(r===`
|
|
594
|
-
`){let{fold:s,offset:o}=
|
|
602
|
+
`){let{fold:s,offset:o}=n$(e,i);n+=s,i=o}else if(r==="\\"){let s=e[++i],o=i$[s];if(o)n+=o;else if(s===`
|
|
595
603
|
`){s=e[i+1];while(s===" "||s==="\t")s=e[++i+1]}else if(s==="\r"&&e[i+1]===`
|
|
596
|
-
`){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+=r$(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!==`
|
|
597
605
|
`&&!(o==="\r"&&e[i+2]===`
|
|
598
|
-
`))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 n$(e,t){let n="",i=e[t+1];while(i===" "||i==="\t"||i===`
|
|
599
607
|
`||i==="\r"){if(i==="\r"&&e[t+2]!==`
|
|
600
608
|
`)break;if(i===`
|
|
601
609
|
`)n+=`
|
|
602
|
-
`;t+=1,i=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var
|
|
603
|
-
`,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 i$={"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 r$(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}}s$.resolveFlowScalar=QS});var xp=M(function(d$){var Ct=V(),wp=re(),a$=wa(),l$=va();function c$(e,t,n,i){let{value:r,type:s,comment:o,range:a}=t.type==="block-scalar"?a$.resolveBlockScalar(e,t,i):l$.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[Ct.SCALAR];else if(l)c=u$(e.schema,r,l,n,i);else if(t.type==="scalar")c=f$(e,r,t,i);else c=e.schema[Ct.SCALAR];let p;try{let u=c.resolve(r,(f)=>i(n??t,"TAG_RESOLVE_FAILED",f),e.options);p=Ct.isScalar(u)?u:new wp.Scalar(u)}catch(u){let f=u instanceof Error?u.message:String(u);i(n??t,"TAG_RESOLVE_FAILED",f),p=new wp.Scalar(r)}if(p.range=a,p.source=r,s)p.type=s;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function u$(e,t,n,i,r){if(n==="!")return e[Ct.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[Ct.SCALAR]}function f$({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[Ct.SCALAR];if(n.compat){let a=n.compat.find((l)=>l.default&&l.test?.test(i))??n[Ct.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;s(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}d$.composeScalar=c$});var vp=M(function(h$){function m$(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}h$.emptyScalarPosition=m$});var _p=M(function(_$){var y$=Ln(),b$=V(),w$=yp(),Sp=xp(),x$=en(),v$=vp(),S$={composeNode:$p,composeEmptyNode:Sa};function $p(e,t,n,i){let r=e.atKey,{spaceBefore:s,comment:o,anchor:a,tag:l}=n,c,p=!0;switch(t.type){case"alias":if(c=$$(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=Sp.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=w$.composeCollection(S$,e,t,n,i),a)c.anchor=a.source.substring(1)}catch(u){let f=u instanceof Error?u.message:String(u);i(t,"RESOURCE_EXHAUSTION",f)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",u),p=!1}}if(c??(c=Sa(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&&(!b$.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&&p)c.srcToken=t;return c}function Sa(e,t,n,i,{spaceBefore:r,comment:s,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:v$.emptyScalarPosition(t,n,i),indent:-1,source:""},u=Sp.composeScalar(e,p,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 $$({options:e},{offset:t,source:n,end:i},r){let s=new y$.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=x$.resolveEnd(i,o,e.strict,r);if(s.range=[t,o,a.offset],a.comment)s.comment=a.comment;return s}_$.composeEmptyNode=Sa;_$.composeNode=$p});var Ap=M(function(O$){var k$=Yn(),Ep=_p(),T$=en(),I$=Xn();function M$(e,t,{offset:n,start:i,value:r,end:s},o){let a=Object.assign({_directives:t},e),l=new k$.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=I$.resolveProps(i,{indicator:"doc-start",next:r??s?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?Ep.composeNode(c,r,p,o):Ep.composeEmptyNode(c,p.end,i,null,p,o);let u=l.contents.range[2],f=T$.resolveEnd(s,u,!1,o);if(f.comment)l.comment=f.comment;return l.range=[n,u,f.offset],l}O$.composeDoc=M$});var $a=M(function(q$){var N$=an("process"),R$=ko(),L$=Yn(),Qn=zn(),kp=V(),P$=Ap(),F$=en();function Zn(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 Tp(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?`
|
|
604
612
|
|
|
605
613
|
`:`
|
|
606
|
-
`)+(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
|
|
607
|
-
${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 Ip{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,i,r)=>{let s=Zn(t);if(r)this.warnings.push(new Qn.YAMLWarning(s,n,i));else this.errors.push(new Qn.YAMLParseError(s,n,i))},this.directives=new R$.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:i}=Tp(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(kp.isCollection(r)&&!r.flow&&r.items.length>0){let s=r.items[0];if(kp.isPair(s))s=s.key;let o=s.commentBefore;s.commentBefore=o?`${n}
|
|
608
616
|
${o}`:n}else{let s=r.commentBefore;r.commentBefore=s?`${n}
|
|
609
|
-
${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:
|
|
610
|
-
${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:Tp(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(N$.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{let r=Zn(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=P$.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 Qn.YAMLParseError(Zn(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 Qn.YAMLParseError(Zn(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=F$.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 Qn.YAMLParseError(Zn(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 L$.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}}}q$.Composer=Ip});var Cp=M(function(W$){var U$=wa(),j$=va(),G$=zn(),Mp=Dn();function B$(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 G$.YAMLParseError([a,a+1],s,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return j$.resolveFlowScalar(e,t,i);case"block-scalar":return U$.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function V$(e,t){let{implicitKey:n=!1,indent:i,inFlow:r=!1,offset:s=-1,type:o="PLAIN"}=t,a=Mp.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:`
|
|
611
619
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
612
620
|
`),p=a.substring(0,c),u=a.substring(c+1)+`
|
|
613
|
-
`,f=[{type:"block-scalar-header",offset:s,indent:i,source:p}];if(!
|
|
614
|
-
`});return{type:"block-scalar",offset:s,indent:i,props:f,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
|
|
621
|
+
`,f=[{type:"block-scalar-header",offset:s,indent:i,source:p}];if(!Op(f,l))f.push({type:"newline",offset:-1,indent:i,source:`
|
|
622
|
+
`});return{type:"block-scalar",offset:s,indent:i,props:f,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 H$(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=Mp.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">":K$(e,l);break;case'"':_a(e,l,"double-quoted-scalar");break;case"'":_a(e,l,"single-quoted-scalar");break;default:_a(e,l,"scalar")}}function K$(e,t){let n=t.indexOf(`
|
|
615
623
|
`),i=t.substring(0,n),r=t.substring(n+1)+`
|
|
616
|
-
`;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(!
|
|
617
|
-
`});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
|
|
618
|
-
`};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(!Op(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 Op(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 _a(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})}}}W$.createScalarToken=V$;W$.resolveAsScalar=B$;W$.setScalarValue=H$});var Np=M(function(Q$){var X$=(e)=>("type"in e)?Fr(e):Pr(e);function Fr(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=Fr(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=Pr(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=Pr(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=Pr(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 Pr({start:e,key:t,sep:n,value:i}){let r="";for(let s of e)r+=s.source;if(t)r+=Fr(t);if(n)for(let s of n)r+=s.source;if(i)r+=Fr(i);return r}Q$.stringify=X$});var Pp=M(function(t_){var Ea=Symbol("break visit"),e_=Symbol("skip children"),Rp=Symbol("remove item");function Nt(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};Lp(Object.freeze([]),e,t)}Nt.BREAK=Ea;Nt.SKIP=e_;Nt.REMOVE=Rp;Nt.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};Nt.parentCollection=(e,t)=>{let n=Nt.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 Lp(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=Lp(Object.freeze(e.concat([[r,o]])),s.items[o],n);if(typeof a==="number")o=a-1;else if(a===Ea)return Ea;else if(a===Rp)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}t_.visit=Nt});var qr=M(function(c_){var Aa=Cp(),i_=Np(),r_=Pp(),ka="\uFEFF",Ta="\x02",Ia="\x18",Ma="\x1F",s_=(e)=>!!e&&("items"in e),o_=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function a_(e){switch(e){case ka:return"<BOM>";case Ta:return"<DOC>";case Ia:return"<FLOW_END>";case Ma:return"<SCALAR>";default:return JSON.stringify(e)}}function l_(e){switch(e){case ka:return"byte-order-mark";case Ta:return"doc-mode";case Ia:return"flow-error-end";case Ma:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
619
627
|
`:case`\r
|
|
620
|
-
`: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}
|
|
621
|
-
`:case"\r":case"\t":return!0;default:return!1}}var
|
|
622
|
-
\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}c_.createScalarToken=Aa.createScalarToken;c_.resolveAsScalar=Aa.resolveAsScalar;c_.setScalarValue=Aa.setScalarValue;c_.stringify=i_.stringify;c_.visit=r_.visit;c_.BOM=ka;c_.DOCUMENT=Ta;c_.FLOW_END=Ia;c_.SCALAR=Ma;c_.isCollection=s_;c_.isScalar=o_;c_.prettyToken=a_;c_.tokenType=l_});var Ca=M(function(E_){var ei=qr();function Me(e){switch(e){case void 0:case" ":case`
|
|
629
|
+
`:case"\r":case"\t":return!0;default:return!1}}var Fp=new Set("0123456789ABCDEFabcdef"),$_=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Dr=new Set(",[]{}"),__=new Set(` ,[]{}
|
|
630
|
+
\r `),Oa=(e)=>!e||__.has(e);class qp{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===`
|
|
623
631
|
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
624
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===`
|
|
625
633
|
`||!i&&!this.atEnd)return e+n+1}return t===`
|
|
626
|
-
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&
|
|
627
|
-
`,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==="...")&&Me(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]===ei.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 ei.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==="...")&&Me(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&&!Me(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===":")&&Me(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(Oa),"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("..."))&&Me(i[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield ei.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(Oa),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let s=this.charAt(1);if(this.flowKey||Me(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(`
|
|
628
636
|
`,this.pos);if(i!==-1){while(i!==-1){let r=this.continueScalar(i+1);if(r===-1)break;i=n.indexOf(`
|
|
629
|
-
`,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)=>Me(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`
|
|
630
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===`
|
|
631
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(`
|
|
632
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===`
|
|
633
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===`
|
|
634
|
-
`&&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 ei.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(Me(r)||e&&Dr.has(r))break;t=n}else if(Me(i)){let r=this.buffer[n+1];if(i==="\r")if(r===`
|
|
635
643
|
`)n+=1,i=`
|
|
636
|
-
`,r=this.buffer[n+1];else t=n;if(r==="#"||e&&
|
|
637
|
-
`){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&&Dr.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&&Dr.has(i))break;t=n}if(!i&&!this.atEnd)return this.setNext("plain-scalar");return yield ei.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(Oa),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Me(n)||t&&Dr.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(!Me(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($_.has(t))t=this.buffer[++e];else if(t==="%"&&Fp.has(this.buffer[e+1])&&Fp.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===`
|
|
638
646
|
`)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
|
|
639
|
-
`)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)}}E_.Lexer=qp});var Na=M(function(k_){class Dp{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}}}}k_.LineCounter=Dp});var Ra=M(function(O_){var I_=an("process"),Up=qr(),M_=Ca();function ft(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function jp(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 Bp(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 Ur(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 tn(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 jr(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 Gp(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,Bp(t.value))if(t.value.end)jr(t.value.end,t.sep);else t.value.end=t.sep;else jr(t.start,t.sep);delete t.sep}}}class Vp{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 M_.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,I_.env.LOG_TOKENS)console.log("|",Up.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Up.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")Gp(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&&jp(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(jp(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=Ur(this.peek(2)),n=tn(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(`
|
|
640
648
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
641
|
-
`,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)){jr(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=tn(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(Bp(t.key)&&!ft(t.sep,"newline")){let s=tn(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)){jr(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=Ur(n),r=tn(i);Gp(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(`
|
|
642
650
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
643
|
-
`,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=
|
|
644
|
-
`;
|
|
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=Ur(e),n=tn(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=Ur(e),n=tn(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()}}}O_.Parser=Vp});var Yp=M(function(U_){var Hp=$a(),N_=Yn(),ti=zn(),R_=No(),L_=V(),P_=Na(),Kp=Ra();function Wp(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new P_.LineCounter||null,prettyErrors:t}}function F_(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.Composer(t),o=Array.from(s.compose(r.parse(e)));if(i&&n)for(let a of o)a.errors.forEach(ti.prettifyError(e,n)),a.warnings.forEach(ti.prettifyError(e,n));if(o.length>0)return o;return Object.assign([],{empty:!0},s.streamInfo())}function Jp(e,t={}){let{lineCounter:n,prettyErrors:i}=Wp(t),r=new Kp.Parser(n?.addNewLine),s=new Hp.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 ti.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(i&&n)o.errors.forEach(ti.prettifyError(e,n)),o.warnings.forEach(ti.prettifyError(e,n));return o}function q_(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=Jp(e,n);if(!r)return null;if(r.warnings.forEach((s)=>R_.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 D_(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(L_.isDocument(e)&&!i)return e.toString(n);return new N_.Document(e,i,n).toString(n)}U_.parse=q_;U_.parseAllDocuments=F_;U_.parseDocument=Jp;U_.stringify=D_});var H_,K_,W_,La,J_,dt,Y_,z_,X_,Q_,fL,Z_,eE,tE,Gr,zp,nE,iE,rE,sE,oE,aE,lE,cE,uE,fE,dE,pE,mE,hE,gE,yE,bE,wE,xE,vE,SE,$E,_E,EE,Br,AE,kE,TE;var Xp=I(()=>{H_=$a(),K_=Yn(),W_=aa(),La=zn(),J_=Ln(),dt=V(),Y_=at(),z_=re(),X_=ct(),Q_=ut(),fL=qr(),Z_=Ca(),eE=Na(),tE=Ra(),Gr=Yp(),zp=Nn();nE=H_.Composer,iE=K_.Document,rE=W_.Schema,sE=La.YAMLError,oE=La.YAMLParseError,aE=La.YAMLWarning,lE=J_.Alias,cE=dt.isAlias,uE=dt.isCollection,fE=dt.isDocument,dE=dt.isMap,pE=dt.isNode,mE=dt.isPair,hE=dt.isScalar,gE=dt.isSeq,yE=Y_.Pair,bE=z_.Scalar,wE=X_.YAMLMap,xE=Q_.YAMLSeq,vE=Z_.Lexer,SE=eE.LineCounter,$E=tE.Parser,_E=Gr.parse,EE=Gr.parseAllDocuments,Br=Gr.parseDocument,AE=Gr.stringify,kE=zp.visit,TE=zp.visitAsync});var Rt,le,Pa;var Vr=I(()=>{Rt=["claude-code","codex","grok","opencode","hermes","pi","oh-my-pi","zed"],le=[{id:De,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"}]}}],Pa=le[0].id});import{chmodSync as Fa,closeSync as Qp,existsSync as nn,lstatSync as IE,mkdirSync as ME,openSync as OE,readFileSync as CE,realpathSync as NE,renameSync as RE,rmSync as sn,statSync as LE,writeFileSync as Ua}from"fs";import{homedir as PE,tmpdir as FE}from"os";import{basename as tm,dirname as nm,isAbsolute as im,join as H,resolve as Kr}from"path";function ja(e){let t=le.find((n)=>n.id===e);if(!t)throw new y(`Unsupported MiniMax model: ${e}`,b.USAGE);return t}function qa(e){return e==="MiniMax-M4"||e==="MiniMax-M3.1-Flash"||e==="MiniMax-M3"?`${e}[1m]`:e}function Zp(e){return e==="MiniMax-M3"?"minimax":e.toLowerCase().replaceAll(".","-")}function He(e){let t=e==="cn"?"https://api.minimax.cn":"https://api.minimax.io";return{anthropic:`${t}/anthropic`,openai:`${t}/v1`}}function Lt(e,t,n){if(!e?.trim())return t;return im(e)?e:Kr(n,e)}function UE(e,t){let n=(t.OMP_PROFILE??t.PI_PROFILE)?.trim(),i=H(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=H(i,"profiles",n,"agent")}else{let o=t.PI_PROFILE?.trim(),a=o&&o!=="default"&&r(o)?H(i,"profiles",o,"agent"):void 0,l=t.PI_CODING_AGENT_DIR===a?void 0:t.PI_CODING_AGENT_DIR;s=l?Kr(l):H(i,"agent")}return["models","config"].map((o)=>{let a=H(s,`${o}.yml`),l=H(s,`${o}.yaml`);if(nn(a))return a;if(nn(l))return l;let c=H(s,o==="models"?"models.json":"settings.json");if(nn(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 jE(e,t){let n=t.homeDir??PE(),i=t.env??process.env;switch(e){case"claude-code":{let r=Lt(i.CLAUDE_CONFIG_DIR,H(n,".claude"),n);return[H(r,"settings.json")]}case"codex":{let r=Lt(i.CODEX_HOME,H(n,".codex"),n);return[H(r,"config.toml"),H(r,Hr)]}case"grok":return[H(Lt(i.GROK_HOME,H(n,".grok"),n),"config.toml")];case"opencode":{if(i.OPENCODE_CONFIG?.trim()){let l=i.OPENCODE_CONFIG.trim();return[im(l)?l:Kr(l)]}let r=Lt(i.XDG_CONFIG_HOME,H(n,".config"),n),s=H(r,"opencode"),o=H(s,"opencode.json"),a=H(s,"opencode.jsonc");return[nn(a)?a:o]}case"hermes":{let r=Lt(i.HERMES_HOME,H(n,".hermes"),n);return[H(r,"config.yaml"),H(r,".env")]}case"pi":{let r=Lt(i.PI_CODING_AGENT_DIR,H(n,".pi","agent"),n);return[H(r,"models.json"),H(r,"settings.json")]}case"oh-my-pi":return UE(n,i);case"zed":{if(process.platform==="win32")return[H(i.APPDATA||H(n,"AppData","Roaming"),"Zed","settings.json")];let r=process.platform==="darwin"?H(n,".config"):i.FLATPAK_XDG_CONFIG_HOME||Lt(i.XDG_CONFIG_HOME,H(n,".config"),n);return[H(r,"zed","settings.json")]}}}function rn(e){return nn(e)?CE(e,"utf8"):null}function Oe(e){let t=Ba(e);return{targetPath:t,before:rn(t)}}function sm(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,Ve)}function on(e,t){let n=[],i=qf(e,n,{allowTrailingComma:!0,disallowComments:!1});if(n.length>0)throw new y(`${t} is not valid JSON/JSONC.`,b.GENERAL,Ve);return sm(i,t),i}function ni(e,t,n){let i=e??`{}
|
|
652
|
+
`;on(i,t);for(let r of n)i=Uf(i,Df(i,r.path,r.value,{formattingOptions:qE}));return i.endsWith(`
|
|
645
653
|
`)?i:`${i}
|
|
646
|
-
`}function
|
|
654
|
+
`}function GE(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 om(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 Da(e,t){let n=e;for(let[i,r]of Object.entries(t)){if(!DE.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}${om(l)}`);else{if(n.length>0&&!n.endsWith(`
|
|
647
655
|
`))n+=`
|
|
648
656
|
`;n+=`${o}
|
|
649
|
-
`}}return n}function
|
|
657
|
+
`}}return n}function BE(e,t,n){let i=GE(e,t);if(i){let s=e.slice(i.bodyStart,i.end);return e.slice(0,i.bodyStart)+Da(s,n)+e.slice(i.end)}let r=e;if(r.length>0&&!r.endsWith(`
|
|
650
658
|
`))r+=`
|
|
651
659
|
`;if(r.length>0&&!r.endsWith(`
|
|
652
660
|
|
|
653
661
|
`))r+=`
|
|
654
662
|
`;return r+=`[${t}]
|
|
655
|
-
${
|
|
663
|
+
${Da("",n)}`,r}function am(e,t){let n=e.search(/^\s*\[/m),i=n===-1?e.length:n;return Da(e.slice(0,i),t)+e.slice(i)}function VE(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
|
|
656
664
|
`)?`\r
|
|
657
665
|
`:o.endsWith(`
|
|
658
666
|
`)?`
|
|
659
|
-
`:"",c=
|
|
667
|
+
`:"",c=om(o.replace(/\r?\n$/,"")).trimStart();return c?`${a}${c}${l}`:""})+e.slice(i)}function lm(e,t,n,i){let r=e??"";if(r.charCodeAt(0)===65279)r=r.slice(1);try{Et(r)}catch{throw new y(`${t} is not valid TOML.`,b.GENERAL,Ve)}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=am(r,n);for(let s of i)r=BE(r,s.name,s.entries);if(!r.endsWith(`
|
|
660
668
|
`))r+=`
|
|
661
|
-
`;try{
|
|
662
|
-
`);if(r.errors.length>0)throw new y(`Hermes config.yaml is not valid YAML: ${r.errors[0]?.message??"parse error"}`,
|
|
669
|
+
`;try{Et(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 HE(e,t,n,i){let r=Br(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,Ve);let s=r.toJS();if(sm(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 p of le){if(l?.[p.id]!==void 0)W(l[p.id],`Hermes model override for ${p.id} must be an object.`);let u=1e6;r.setIn(["model_overrides",t,p.id,"context_window"],u),r.setIn(["model_overrides",t,p.id,"supports_vision"],p.input.some((f)=>f==="image"))}let c=ja(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 KE(e){return/^[A-Za-z0-9_./:-]+$/.test(e)?e:JSON.stringify(e)}function WE(e,t,n){let i=e??"",r=`${t}=${KE(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(`
|
|
663
671
|
`))a+=`
|
|
664
672
|
`;a+=`${r}
|
|
665
673
|
`}return a.endsWith(`
|
|
666
674
|
`)?a:`${a}
|
|
667
|
-
`}function
|
|
668
|
-
`}function
|
|
669
|
-
`);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,
|
|
670
|
-
`,"utf8")}catch(s){if(
|
|
671
|
-
`},
|
|
675
|
+
`}function JE(e,t){let n=Oe(t),r=on(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,Ve);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,Ve);let a=He(e.region),l=qa(e.model),c=le.map((g)=>({model:qa(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"})),p=new Set(le.flatMap((g)=>[g.id,qa(g.id)])),u=[];if(s===void 0)u.push({path:["modelPicker","options"],value:c});else{let g=s.flatMap((d,m)=>{if(typeof d!=="object"||d===null||Array.isArray(d))return[];let v=d.model;return typeof v==="string"&&p.has(v)?[m]:[]});for(let d of g.reverse())u.push({path:["modelPicker","options",d],value:void 0});let h=s.length-g.length;c.forEach((d,m)=>{u.push({path:["modelPicker","options",h+m],value:d})})}let f={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:ja(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:ni(n.before,"Claude Code settings.json",[...Object.entries(f).map(([g,h])=>({path:["env",g],value:h})),...u,{path:["modelPicker","replaceBuiltInOptions"],value:o??!0}])}]}function YE(e){return`${JSON.stringify({_managed_by:rm,models:le.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 zE(e,t){let[n,i]=t;if(!n||!i)throw new y("Codex paths are incomplete.",b.GENERAL);let r=Oe(n),s=He(e.region),o=ja(e.model),a=lm(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=Et(a).model_catalog_json;if(l!==void 0&&l!==Hr)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=Oe(i);if(c.before!==null){if(on(c.before,"Codex mmx-model-catalog.json")._managed_by!==rm)throw new y(`Codex ${Hr} is not managed by mmx.`,b.GENERAL,"Rename or remove that file, then retry. No files were changed.")}return a=VE(a,["model_context_window","model_auto_compact_token_limit"]),a=am(a,{model_catalog_json:Hr}),[{agent:"codex",path:n,...r,after:a},{agent:"codex",path:i,...c,after:YE(e)}]}function XE(e,t){let n=Oe(t),i=He(e.region),r=le.map((s)=>({name:`model.${Zp(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:lm(n.before,"Grok config.toml",{},[{name:"models",entries:{default:Zp(e.model)}},...r])}]}function QE(e,t){let n=Oe(t),r=on(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 p of["options","models"]){let u=s?.[p];if(u!==void 0)W(u,`OpenCode opencode.json provider.minimax.${p} section must be an object.`)}let o=s?.models;for(let p of le){let u=o?.[p.id];if(u!==void 0)W(u,`OpenCode model definition for ${p.id} must be an object.`);let f=u?.limit;if(f!==void 0)W(f,`OpenCode model definition for ${p.id} limit must be an object.`);let g=u?.modalities;if(g!==void 0)W(g,`OpenCode model definition for ${p.id} modalities must be an object.`);if(p.id!=="MiniMax-M3"){let h=u?.variants;if(h!==void 0)W(h,`OpenCode model definition for ${p.id} variants must be an object.`)}}let a=He(e.region),l=le.flatMap((p)=>{let u=[...p.input];return[{path:["provider","minimax","models",p.id,"name"],value:p.id},{path:["provider","minimax","models",p.id,"reasoning"],value:!0},{path:["provider","minimax","models",p.id,"temperature"],value:!1},{path:["provider","minimax","models",p.id,"attachment"],value:u.includes("image")},{path:["provider","minimax","models",p.id,"modalities","input"],value:u},{path:["provider","minimax","models",p.id,"modalities","output"],value:["text"]},{path:["provider","minimax","models",p.id,"limit","context"],value:p.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:p.contextWindow},{path:["provider","minimax","models",p.id,"limit","output"],value:p.maxTokens}]}),c=["MiniMax-M4","MiniMax-M3.1-Flash"].flatMap((p)=>{let u=["provider","minimax","models",p];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((f)=>({path:[...u,"variants",f,"reasoningEffort"],value:f}))]});return[{agent:"opencode",path:t,...n,after:ni(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 ZE(e,t){let[n,i]=t;if(!n||!i)throw new y("Hermes paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=He(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:HE(r.before,a,e.model,o.anthropic)},{agent:"hermes",path:i,...s,after:WE(s.before,l,e.apiKey)}]}function eA(e,t){let[n,i]=t;if(!n||!i)throw new y("Pi paths are incomplete.",b.GENERAL);let r=Oe(n),s=Oe(i),o=on(r.before??"{}","Pi models.json"),a=He(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 p=c?.[l];if(p!==void 0)W(p,`Pi models.json providers.${l} section must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`Pi models.json providers.${l}.models must be an array.`,b.GENERAL,Ve);let f=[{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=le.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)f.push({path:["providers",l,"models"],value:g});else{let h=u.length;for(let d of g){let m=u.findIndex((w)=>typeof w==="object"&&w!==null&&!Array.isArray(w)&&w.id===d.id),v=["providers",l,"models",m>=0?m:h++];if(m<0){f.push({path:v,value:d});continue}W(u[m],`Pi model definition for ${d.id} must be an object.`);for(let[w,x]of Object.entries(d)){if(w==="id")continue;if(w==="compat"||w==="thinkingLevelMap"){let E=u[m][w];if(E!==void 0)W(E,`Pi ${w} for ${d.id} must be an object.`);for(let[A,_]of Object.entries(x))f.push({path:[...v,w,A],value:_});continue}f.push({path:[...v,w],value:x})}}}return[{agent:"pi",path:n,...r,after:ni(r.before,"Pi models.json",f)},{agent:"pi",path:i,...s,after:ni(s.before,"Pi settings.json",[{path:["defaultProvider"],value:l},{path:["defaultModel"],value:e.model},...e.model==="MiniMax-M4"?[{path:["defaultThinkingLevel"],value:"max"}]:[]])}]}function tA(e,t){let n=e.region==="cn"?"minimax-cn":"minimax",i=He(e.region).anthropic;return t.map((r,s)=>{let o=Oe(r),a=`Oh my Pi ${tm(r)}`,l=Br(o.before??`{}
|
|
677
|
+
`);if(l.errors.length>0)throw new y(`${a} is not valid YAML.`,b.GENERAL,Ve);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 p=c.providers?.[n];if(p!==void 0)W(p,`${a} provider must be an object.`);let u=p?.models;if(u!==void 0&&!Array.isArray(u))throw new y(`${a} models must be an array.`,b.GENERAL,Ve);let f=u??[];for(let d of f)W(d,`${a} model entries must be objects.`);let g=["providers",n];for(let[d,m]of Object.entries({baseUrl:i,apiKey:e.apiKey,api:"anthropic-messages",auth:"apiKey"}))l.setIn([...g,d],m);if(u===void 0)l.setIn([...g,"models"],l.createNode([]));let h=f.length;for(let d of le){let m=f.findIndex((x)=>x.id===d.id),v=[...g,"models",m>=0?m:h++],w={id:d.id,name:d.id,api:"anthropic-messages",baseUrl:i,reasoning:!0,input:[...d.input],contextWindow:d.contextWindow,maxTokens:d.maxTokens,...d.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 p=e.model!=="MiniMax-M3"?":max":"";l.setIn(["modelRoles","default"],`${n}/${e.model}${p}`)}return{agent:"oh-my-pi",path:r,...o,after:l.toString()}})}function nA(e,t){let n=Oe(t),i="Zed settings.json",r=on(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,Ve);let c=r.agent;if(c!==void 0)W(c,"Zed settings.json agent must be an object.");let p=c?.default_model;if(p!==void 0)W(p,"Zed settings.json agent.default_model must be an object.");let u=(d)=>d!=="MiniMax-M3"?"max":"high",f=["language_models","openai_compatible","minimax"],g=le.map((d)=>({name:d.id,display_name:d.id,max_tokens:d.id==="MiniMax-M3.1-Flash"?e.m31ContextWindow??524288:d.contextWindow,max_output_tokens:d.maxTokens,reasoning_effort:u(d.id),capabilities:{tools:!0,images:d.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:[...f,"api_url"],value:He(e.region).openai}];if(l===void 0)h.push({path:[...f,"available_models"],value:g});else{let d=l.length;for(let m of g){let v=l.findIndex((w)=>typeof w==="object"&&w!==null&&w.name===m.name);h.push({path:[...f,"available_models",v>=0?v:d++],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:ni(n.before,"Zed settings.json",h)}]}function Ga(e){let t=[];for(let n of e.agents){let i=jE(n,e);switch(n){case"claude-code":t.push(...JE(e,i[0]));break;case"codex":t.push(...zE(e,i));break;case"grok":t.push(...XE(e,i[0]));break;case"opencode":t.push(...QE(e,i[0]));break;case"hermes":t.push(...ZE(e,i));break;case"pi":t.push(...eA(e,i));break;case"oh-my-pi":t.push(...tA(e,i));break;case"zed":t.push(...nA(e,i[0]));break}}return cm(t),t}function em(e,t,n){let i=nm(e);ME(i,{recursive:!0,mode:448});let r=H(i,`.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`),s=()=>{if(Ba(n)!==e)throw new y(`Configuration path changed while mmx was writing it: ${n}`,b.GENERAL)};try{s(),Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),s(),RE(r,e)}catch(o){throw sn(r,{force:!0}),o}}function iA(e,t,n){for(let i=0;;i+=1){let r=`${e}.bak.${n}${i===0?"":`.${i}`}`;try{return Ua(r,t,{encoding:"utf8",mode:384,flag:"wx"}),r}catch(s){if(s.code==="EEXIST")continue;throw sn(r,{force:!0}),s}}}function rA(){return new Date().toISOString().replace(/[-:]/g,"").replace("T","-").replace(/\.\d{3}Z$/,"Z")}function Ba(e){let t=e,n=[];while(!0)try{return H(NE(t),...n)}catch(i){if(i.code!=="ENOENT")throw i;try{if(IE(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=nm(t);if(r===t)return Kr(e);n.unshift(tm(t)),t=r}}function sA(e){return process.platform!=="win32"&&(e&63)!==0}function cm(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 oA(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function um(){let e=typeof process.getuid==="function"?String(process.getuid()):(process.env.USERNAME??process.env.USER??"user").replace(/[^A-Za-z0-9_-]/g,"_"),t=H(FE(),`mmx-agent-setup-${e}.lock`),n=`${process.pid}:${Date.now()}:${Math.random().toString(16).slice(2)}`;try{let i=OE(t,"wx",384);try{Ua(i,`${n}
|
|
678
|
+
`,"utf8")}catch(s){if(Qp(i),rn(t)?.trim()===n)sn(t,{force:!0});throw s}let r=!1;return()=>{if(r)return;if(r=!0,Qp(i),rn(t)?.trim()===n)sn(t,{force:!0})}}catch(i){if(i.code!=="EEXIST")throw i;let s=(rn(t)?.trim()??"").match(/^(\d+):/),o=s?.[1]?Number(s[1]):void 0,a=o!==void 0&&!oA(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 fm(e){let t=um(),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 dm(e,t=!1,n=!1){let i=t||n?void 0:um();try{let r=e.filter((u)=>u.before!==u.after);cm(e);let s=new Map,o=new Map;for(let u of e)if(u.before!==null&&nn(u.targetPath)){let f=LE(u.targetPath).mode&511;if(s.set(u,f),u.before===u.after&&sA(f))o.set(u,f)}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,f)=>{if(Ba(u.path)!==u.targetPath||rn(u.targetPath)!==u.before)throw new y(`Configuration changed while mmx was preparing it: ${u.path}`,b.GENERAL,f)};for(let u of e)if(u.before!==u.after||o.has(u))a(u,"No files were changed. Retry the command.");let l=rA(),c=new Map,p=[];try{for(let u of r)if(u.before!==null)a(u,"No files were changed. Retry the command."),c.set(u.path,iA(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."),Fa(u.targetPath,384)}for(let u of r)a(u,"The completed writes were rolled back. Retry the command."),em(u.targetPath,u.after,u.path),p.push({file:u,target:u.targetPath})}catch(u){let f=[],g;for(let{file:h,target:d}of p.reverse())try{if(rn(d)!==h.after){f.push(h.path);continue}if(h.before===null)sn(d,{force:!0});else{em(d,h.before,h.path);let m=s.get(h);if(m!==void 0)Fa(d,m)}}catch(m){g??=m}for(let[h,d]of o)try{Fa(h.targetPath,d)}catch(m){g??=m}if(f.length===0&&g===void 0)for(let h of c.values())try{sn(h,{force:!0})}catch(d){g??=d}if(f.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 qE,DE,Hr="mmx-model-catalog.json",rm="mmx agent setup",Ve="Fix the existing configuration file and retry. No files were changed.";var Va=I(()=>{jf();yo();Xp();G();j();Vr();qE={insertSpaces:!0,tabSize:2,eol:`
|
|
679
|
+
`},DE=/^[A-Za-z0-9_-]+$/});import{accessSync as aA,constants as pm,statSync as lA}from"fs";import{delimiter as cA,join as uA}from"path";function pA(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(cA).map((s)=>s.replace(/^"|"$/g,"")),i=process.platform==="win32"?(e.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""],r=process.platform==="win32"?pm.F_OK:pm.X_OK;return new Set(Rt.filter((s)=>fA[s].some((o)=>n.some((a)=>i.some((l)=>{let c=uA(a,`${o}${l}`);try{if(!lA(c).isFile())return!1;return aA(c,r),!0}catch{return!1}})))))}function mm(e=process.env){let t=pA(e);if(e.CODEX_THREAD_ID?.trim())t.add("codex");for(let n of Rt){let i=dA[n];if(i!==void 0&&e[i[0]]===i[1])t.add(n)}return t}var fA,dA;var hm=I(()=>{Vr();fA={"claude-code":["claude"],codex:["codex"],grok:["grok","grok-build","grok-cli"],opencode:["opencode"],hermes:["hermes"],pi:["pi"],"oh-my-pi":["omp"],zed:["zed","zeditor"]},dA={"claude-code":["CLAUDE_CODE_CHILD_SESSION","1"],opencode:["OPENCODE_CLIENT","desktop"],hermes:["HERMES_AGENT","true"],pi:["PI_CODING_AGENT","true"]}});import{spawn as mA,spawnSync as wm}from"child_process";function EA(e,t){return wm(t==="win32"?"where.exe":e,t==="win32"?[e]:["--version"],{stdio:"ignore",timeout:5000}).status===0}function Ka(e,t={}){let n=t.platform??process.platform,i=t.arch??process.arch,r=t.nodeVersion??process.versions.node,s=t.commandExists??((l)=>EA(l,n));if(e==="zed")return"Install Zed from https://zed.dev/download.";if(!xA.has(n))return`Automated installation is not supported on ${n}.`;if(e!=="pi"&&!vA.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 AA(e,t){if(t==="win32"){let r=yA[e];if(e!=="hermes")return{executable:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",Ha+`$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=wA.map((l)=>`'${l}'`).join(", "),o=`& { ${Ha}& $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'; "+Ha+`$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=gA[e];if(e==="hermes"){let r=bA.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 Wa(e,t=process.platform){if(e==="claude-code"||e==="grok"||e==="hermes"||e==="oh-my-pi")return AA(e,t);if(e==="zed")throw new y("Install Zed from https://zed.dev/download.",b.USAGE);let n=["install","-g",...e==="pi"?["--ignore-scripts","--engine-strict"]:[],hA[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 kA(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"};let n=`${gm[e]} --version`;if(t==="win32")return{executable:"cmd.exe",args:["/d","/s","/c",n],display:n};return{executable:gm[e],args:["--version"],display:n}}function TA(e){let t={...process.env},n=SA.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 IA(e){return e.pid!==void 0&&e.exitCode===null&&e.signalCode===null}function ym(e,t=!1){if(e.pid===void 0)return;if(process.platform==="win32"){if(wm("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(IA(e))try{e.kill(t?"SIGKILL":"SIGTERM")}catch{}}async function bm(e,t){return new Promise((n,i)=>{let r=mA(e.executable,e.args,{detached:process.platform!=="win32",env:TA(t.proxy),stdio:["inherit",process.stderr,"inherit"]}),s=!1,o=["SIGHUP","SIGINT","SIGTERM"],a=new Map,l=()=>{for(let[f,g]of a)process.removeListener(f,g)},c=(f)=>{if(l(),ym(r,!0),process.listenerCount(f)===0)process.kill(process.pid,f)};for(let f of o){let g=()=>c(f);a.set(f,g),process.prependOnceListener(f,g)}let p=setTimeout(()=>{if(s)return;ym(r,!0),r.unref(),s=!0,l(),i(new Wr(t.timeoutMs))},t.timeoutMs);p.unref();let u=(f)=>{if(s)return;s=!0,clearTimeout(p),l(),f()};r.once("error",(f)=>u(()=>i(f))),r.once("exit",(f)=>u(()=>n(f??1)))})}async function xm(e,t={}){let n=Ka(e,t);if(n)throw new y(`Cannot install ${e}: ${n}`,b.GENERAL,"Leave it unselected and continue with configuration only.");let i=Wa(e,t.platform),r=kA(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:
|
|
672
680
|
${i.display}`:`Run the installer manually:
|
|
673
681
|
${i.display}
|
|
674
682
|
For npm permission errors, see: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally`,a=`${s}
|
|
675
|
-
${o}`,l=t.runner??((f)=>
|
|
676
|
-
${r.display}`);let
|
|
677
|
-
${r.display}`)}if(u!==0)throw new y(`Installed ${e}, but ${r.display} exited with code ${u}.`,
|
|
678
|
-
${r.display}`)}var
|
|
679
|
-
Technical detail: ${o.code}.`:"",
|
|
680
|
-
${u}`;else if(r)
|
|
681
|
-
${u}`;else if(c)
|
|
682
|
-
${u}`;return new y(
|
|
683
|
-
${d}${f}`)}function
|
|
684
|
-
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}).`,
|
|
685
|
-
Check your connection and try again.`);if(e===402)return new y("MiniMax quota or balance is insufficient (HTTP 402).",
|
|
686
|
-
Check the quota or balance for this API key.`);if(e===429)return new y("MiniMax verification was rate limited (HTTP 429).",
|
|
687
|
-
Wait and try again, or check the quota for this API key.`);if(e>=500)return new y(`MiniMax is temporarily unavailable (HTTP ${e}).`,
|
|
688
|
-
Try again later.`);return new y(`MiniMax rejected the agent verification request (HTTP ${e}).`,
|
|
689
|
-
Check the selected MiniMax region and model.`)}async function
|
|
683
|
+
${o}`,l=t.runner??((f)=>bm(f,{proxy:t.proxy,timeoutMs:t.installTimeoutMs??$A})),c;try{c=await l(i)}catch(f){if(f instanceof Wr)throw new y(`Installation for ${e} timed out after ${Math.ceil(f.timeoutMs/1000)} seconds.`,b.TIMEOUT,`The installer was stopped. ${a}`);let g=f instanceof Error?` ${f.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 p=t.runner??((f)=>bm(f,{proxy:t.proxy,timeoutMs:_A})),u;try{u=await p(r)}catch(f){if(f instanceof Wr)throw new y(`Installed ${e}, but ${r.display} timed out after ${Math.ceil(f.timeoutMs/1000)} seconds.`,b.TIMEOUT,`Open a new terminal and verify the installation manually:
|
|
684
|
+
${r.display}`);let g=f instanceof Error?` ${f.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
|
+
${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 hA,gm,gA,yA,bA,wA,xA,vA,SA,Ha="$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 }; ",$A=900000,_A=30000,Wr;var vm=I(()=>{G();j();hA={codex:"@openai/codex",opencode:"opencode-ai",pi:"@earendil-works/pi-coding-agent"},gm={codex:"codex",opencode:"opencode",pi:"pi"},gA={"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"},yA={"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"},bA=["prerequisites","repository","venv","python-deps","node-deps","path","config","complete"],wA=["uv","python","git","node","system-packages","repository","venv","dependencies","node-deps","path","config-templates","platform-sdks","bootstrap-marker"],xA=new Set(["darwin","linux","win32"]),vA=new Set(["arm64","x64"]),SA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"];Wr=class Wr extends Error{timeoutMs;constructor(e){super(`Timed out after ${Math.ceil(e/1000)} seconds.`);this.timeoutMs=e;this.name="AgentInstallTimeoutError"}}});function OA(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 Sm(e,t,n,i,r=!1){let s=new URL(t).hostname,o=OA(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",p="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.",f=o.code?`
|
|
687
|
+
Technical detail: ${o.code}.`:"",g=`Could not reach ${s}.`,h=b.NETWORK,d="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,d=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.
|
|
688
|
+
${u}`;else if(r)g=`Connection to ${s} was interrupted while reading the verification response.`,d="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.`,d="Check the proxy address and make sure it is reachable from the current shell or container.";else if(l)g=`Could not resolve ${s}.`,d=`Check DNS and internet access, then try again.
|
|
689
|
+
${u}`;else if(c)g=`Could not connect to ${s}.`,d=`Check your internet connection, firewall, and selected MiniMax region.
|
|
690
|
+
${u}`;return new y(g,h,`No agent configuration files were changed.
|
|
691
|
+
${d}${f}`)}function CA(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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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 $m(e){let t=`${He(e.region).openai}/responses`,n=e.timeoutSeconds??30,i=MA.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 Sm(l,t,n,s)}if(!o.ok)throw await o.body?.cancel().catch(()=>{return}),CA(o.status);let a=!1;try{for await(let l of qe(o)){let c;try{c=JSON.parse(l.data)}catch{continue}if(typeof c!=="object"||c===null||Array.isArray(c))continue;let p=c,u=p.response;if(p.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 Sm(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 MA;var _m=I(()=>{G();j();Va();MA=["HTTPS_PROXY","https_proxy","HTTP_PROXY","http_proxy","ALL_PROXY","all_proxy"]});import{readFileSync as NA}from"fs";import{homedir as RA}from"os";import{isAbsolute as LA,join as Em,resolve as PA}from"path";function GA(e){if(e.startsWith("sk-cp-"))return"token-plan";if(e.startsWith("sk-api-"))return"paygo";return}function Am(e){if(!e.includes("codex"))return;let t=RA(),n=process.env.CODEX_HOME?.trim(),i=n?LA(n)?n:PA(t,n):Em(t,".codex");try{let r=NA(Em(i,"config.toml"),"utf8"),o=Et(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 BA(e,t,n){if(t==="json"||!n)return O(e,t);let i=ii.default.cyan,r=ii.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 Ya(e){let t=[];for(let n of e){let i=n.trim().toLowerCase(),r=FA[i];if(!r)throw new y(`Unsupported agent "${n}".`,b.USAGE,`Supported agents: ${Rt.join(", ")}`);if(!t.includes(r))t.push(r)}return t}function VA(e){if(e._hasExplicitOptions===!0)return!1;return Object.values(e).every((t)=>t===void 0||t===!1)}async function HA(e,t,n=jA){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(`
|
|
690
698
|
`)+`
|
|
691
699
|
|
|
692
|
-
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:
|
|
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 Ya(o)}async function KA(e,t,n={},i=UA){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?`
|
|
693
701
|
|
|
694
|
-
${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 ${
|
|
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 WA(e,t){let n=await ks({message:"Select agents to configure",choices:Rt.map((d)=>({value:d,label:t.has(d)?Ke[d]:`${Ke[d]} (not detected on PATH)`})),initialValues:DA.filter((d)=>t.has(d)),required:!0});if(!n?.length)throw new y("Agent setup cancelled.",b.GENERAL);let i=Ya(n);if(i.includes("codex"))await gt({title:"Codex version recommendation",message:`Use Codex CLI ${ii.default.bold(ii.default.cyan("0.146.0"))} or newer for the complete MiniMax model catalog.`});let r=i.filter((d)=>!t.has(d)),s=await HA(i,t),o=await Si({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((d)=>d==="claude-code"||d==="codex"||d==="opencode"||d==="zed")){let d=await Si({message:"Choose the MiniMax-M3.1-Flash context window",choices:[{value:"512k",label:"512K (Recommended)"},{value:"1m",label:"1M"}],initialValue:"512k"});if(d!=="512k"&&d!=="1m")throw new y("Agent setup cancelled.",b.GENERAL);a=d==="1m"?1e6:524288}let l=Am(i),c;if(l)await gt({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((d)=>`--agent ${d}`).join(" ")} --region ${o} --api-key <key>.`});else{let d=await Si({message:"Choose an API key type",choices:Ja,initialValue:"token-plan"});if(c=Ja.find((m)=>m.value===d),!c)throw new y("Agent setup cancelled.",b.GENERAL);await gt({title:c.noteTitle,message:`${pt[o]}${c.pagePath}
|
|
695
703
|
|
|
696
|
-
Copy the key, then paste it below.`}),l=(await
|
|
697
|
-
Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??
|
|
698
|
-
|
|
704
|
+
Copy the key, then paste it below.`}),l=(await Ll({message:c.prompt}))?.trim()}let p=l?GA(l):void 0;if(p&&c&&p!==c.value){let d=Ja.find((m)=>m.value===p);if(d)await gt({title:"API key type detected",message:`This looks like ${d.label}. ${d.hint}.`})}if(!l)throw new y("A MiniMax API key is required.",b.USAGE);let u=Pa,f=`Configure ${i.map((d)=>Ke[d]).join(", ")}? mmx will write configuration files.`;if(s.length>0)f+=` It will first install ${s.map((d)=>Ke[d]).join(", ")} using their official installers.`;let g=r.filter((d)=>!s.includes(d));if(g.length>0)f+=` Configuration only: ${g.map((d)=>Ke[d]).join(", ")}.`;if(!await bn({message:f}))throw new y("Agent setup cancelled.",b.GENERAL);return{agents:i,agentsToInstall:s,apiKey:l,region:o,model:u,m31ContextWindow:a}}function JA(e){if(e._positional?.length)throw new y("Unexpected positional argument.",b.USAGE,"Select agents with --agent <name> or --all.");let n=Ya(e.agent??[]),i=e.all?[...Rt]: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()||Am(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.
|
|
705
|
+
Token Plan keys (sk-cp-...) and pay-as-you-go keys (sk-api-...) use separate quotas.`);let o=(e.model??Pa).trim();if(!o)throw new y("--model must not be empty.",b.USAGE);let a=le.find((l)=>l.id===o)?.id;if(!a)throw new y(`Unsupported MiniMax model "${o}".`,b.USAGE,`Supported models: ${le.map((l)=>l.id).join(", ")}`);return{agents:i,agentsToInstall:[],apiKey:s,region:e.region,model:a,m31ContextWindow:r==="1m"?1e6:524288}}var ii,FA,Ke,qA=`Zed: paste your MiniMax API key in Agent Panel > Settings > minimax, or start Zed with MINIMAX_API_KEY set.
|
|
706
|
+
`,DA,UA,jA,Ja,km;var Tm=I(()=>{yo();X();Va();hm();vm();Vr();_m();Ce();$e();G();j();ee();Pe();ii=Ft(cn(),1),FA={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"},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"},DA=["claude-code","codex"],UA={getCommand:Wa,install:xm,note:gt,confirm:bn},jA={select:ks,note:gt,getIssue:Ka},Ja=[{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"}];km=N({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 (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 (${le.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=mm(),i=VA(t),r=i?await WA(e,n):JA(t),s=Z().proxy,o={region:r.region,model:r.model,endpoint:"",status:"skipped"};if(!e.dryRun){let f=()=>$m({apiKey:r.apiKey,region:r.region,model:r.model,timeoutSeconds:Math.min(e.timeout,60),proxy:s});o=i?await Pl({message:"Verifying API key with MiniMax...",successMessage:"API key verified.",errorMessage:"API key verification failed."},f):await f()}let a=async(f=!1)=>{let g=Ga(r);if(!e.dryRun){if(await KA(r.agentsToInstall,n,{proxy:s}),r.agentsToInstall.length>0)g=Ga(r)}return dm(g,e.dryRun,f)},c=!e.dryRun&&r.agentsToInstall.length>0?await fm(()=>a(!0)):await a(),p=F(e.output);if(console.log(BA({verification:o,agents:r.agents,files:c},p,i&&!e.noColor)),r.agents.includes("zed")&&!e.quiet)process.stderr.write(qA);let u=r.agents.filter((f)=>!n.has(f));if(!i&&u.length>0&&!e.quiet)process.stderr.write(`Warning: Not detected on PATH: ${u.map((f)=>Ke[f]).join(", ")}. mmx can write configuration files for them, but will not download or install them for you.
|
|
707
|
+
`)}})});class Im{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(`
|
|
699
708
|
`);throw new y(`Unknown command: mmx ${e.join(" ")}
|
|
700
709
|
|
|
701
710
|
Available commands:
|
|
702
|
-
${i}`,
|
|
711
|
+
${i}`,b.USAGE,`mmx ${n.join(" ")} --help`)}throw new y(`Unknown command: mmx ${e.join(" ")}`,b.USAGE,"mmx --help")}bold=(e,t)=>t.isTTY?`\x1B[1m${e}\x1B[0m`:e;accent=(e,t)=>t.isTTY?`\x1B[38;2;248;103;58m${e}\x1B[0m`:e;dim=(e,t)=>t.isTTY?`\x1B[2m${e}\x1B[0m`:e;printHelp(e,t=process.stdout,n="global"){if(e.length===0){this.printRootHelp(t);return}let i=this.root;for(let s of e){let o=i.children.get(s);if(!o){this.printRootHelp(t);return}i=o}if(i.command){this.printCommandHelp(i.command,t,n);return}let r=e.join(" ");t.write(`
|
|
703
712
|
${this.bold("Usage:",t)} mmx ${r} <command> [flags]
|
|
704
713
|
|
|
705
714
|
`),t.write(`${this.bold("Commands:",t)}
|
|
@@ -714,7 +723,7 @@ ${i("Resources:")}
|
|
|
714
723
|
${r("auth")} ${s("Authentication (login, status, refresh, logout)")}
|
|
715
724
|
${r("text")} ${s("Text generation (chat)")}
|
|
716
725
|
${r("speech")} ${s("Speech synthesis and transcription (synthesize, voices, transcribe)")}
|
|
717
|
-
${r("image")} ${s("Image generation (generate)")}
|
|
726
|
+
${r("image")} ${s("Image generation and editing (generate)")}
|
|
718
727
|
${r("video")} ${s("Video generation (generate, task get, download)")}
|
|
719
728
|
${r("search")} ${s("Web search (query)")}
|
|
720
729
|
${r("vision")} ${s("Image understanding (describe)")}
|
|
@@ -751,12 +760,12 @@ ${i("Options:")}
|
|
|
751
760
|
${i("Examples:")}
|
|
752
761
|
`);for(let a of e.examples)t.write(` ${s(a)}
|
|
753
762
|
`)}if(e.apiDocs)t.write(`
|
|
754
|
-
${i("API Reference:")} ${s(
|
|
763
|
+
${i("API Reference:")} ${s(pt[n]+e.apiDocs)}
|
|
755
764
|
`);t.write(`
|
|
756
765
|
${s("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
|
|
757
766
|
`),t.write(`${s("Run")} mmx --help ${s("for the full list.")}
|
|
758
767
|
`)}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)}
|
|
759
|
-
`)}}var
|
|
768
|
+
`)}}var Te;var Li=I(()=>{G();j();$e();Ic();Oc();Nc();Lc();Uc();Hc();ru();mu();gu();ju();Wu();Yu();Xu();Qu();ef();nf();sf();cf();ff();pf();hf();yf();wf();vf();Tm();Te=new Im({"auth login":Tc,"auth status":Mc,"auth refresh":Cc,"auth logout":Rc,"text chat":Dc,"text repl":Vc,"speech synthesize":Ws,"speech generate":Ws,"speech transcribe":Xs,"speech recognize":Xs,"speech voices":hu,"image generate":Uu,"video generate":Ku,"video task get":Ju,"video download":zu,"search query":co,"search web":co,"vision describe":Zu,"quota show":tf,"config show":rf,"config set":lf,"config export-schema":uf,"file upload":df,"file list":mf,"file delete":gf,update:bf,help:xf,"agent setup":km})});var Gm=new Set(["true","1","yes","on"]),Bm=new Set(["false","0","no","off"]);function ri(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Vm(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?ri(t[1]):null}function Hm(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 Jr(e){let t=new Set,n=new Set,i=new Set,r=new Set;for(let s of e){let o=Vm(s);if(!o)continue;if(r.add(o),Hm(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 Za(e,t){let n=Jr(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=ri(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 Yr(e,t=[]){let n=Jr(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=ri(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=Jr(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=ri(a);if(n.booleans.has(c)){if(l===void 0)i[c]=!0;else{let p=l.trim().toLowerCase();if(Gm.has(p))i[c]=!0;else if(Bm.has(p))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 p=i[c];if(p)p.push(l);else i[c]=[l]}else if(n.numbers.has(c)){let p=Number(l);if(l.trim()===""||!Number.isFinite(p))throw Error(`Flag --${a} requires a numeric value, got "${l}".`);i[c]=p}else i[c]=l}r++}return i}Li();X();G();j();G();j();ee();function Pt(e){if(e instanceof y){if(F(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
|
|
760
769
|
`);else{if(process.stderr.write(`
|
|
761
770
|
Error: ${e.message}
|
|
762
771
|
`),e.hint)process.stderr.write(`
|
|
@@ -764,25 +773,25 @@ Error: ${e.message}
|
|
|
764
773
|
`).join(`
|
|
765
774
|
`)}
|
|
766
775
|
`);process.stderr.write(` (exit code ${e.exitCode})
|
|
767
|
-
`)}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.",
|
|
776
|
+
`)}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).
|
|
768
777
|
If this happens on every request with a valid API key, you may be hitting the wrong region.
|
|
769
778
|
`+`Run: mmx auth status — to check your credentials and region.
|
|
770
|
-
`+"Run: mmx config set region global (or cn) — to override the region.");return
|
|
771
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return
|
|
779
|
+
`+"Run: mmx config set region global (or cn) — to override the region.");return Pt(r)}if(e instanceof TypeError&&e.message==="fetch failed"){let r=new y("Network request failed.",b.NETWORK,`Check your network connection.
|
|
780
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Pt(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.
|
|
772
781
|
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.
|
|
773
|
-
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new y("Network request failed.",
|
|
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 Pt(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 Pt(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 Pt(r)}if(process.stderr.write(`
|
|
774
783
|
Error: ${e.message}
|
|
775
784
|
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${e.stack}
|
|
776
785
|
`)}else process.stderr.write(`
|
|
777
786
|
Error: ${String(e)}
|
|
778
|
-
`);process.exit(
|
|
787
|
+
`);process.exit(b.GENERAL)}Ce();Us();$e();Xe();import{join as YA}from"path";import{readFileSync as zA,writeFileSync as XA}from"fs";var Mm=()=>YA(oi(),"update-state.json"),QA=86400000,ZA=3000,ek="MiniMax-AI-Dev/minimax-cli";function tk(){try{let e=zA(Mm(),"utf-8");return JSON.parse(e)}catch{return null}}function nk(e){try{XA(Mm(),JSON.stringify(e))}catch{}}async function ik(){try{let e=await fetch(`https://api.github.com/repos/${ek}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(ZA)});if(!e.ok)return null;return(await e.json()).tag_name??null}catch{return null}}var za=null;function Om(){return za}async function Cm(e){if(process.env.CI||!process.stderr.isTTY)return;let t=tk(),n=Date.now();if(t&&n-t.lastChecked<QA){if(t.latestVersion&&t.latestVersion!==`v${e}`)za=t.latestVersion;return}let i=await ik();if(!i)return;if(nk({lastChecked:n,latestVersion:i}),i!==`v${e}`)za=i}Ze();Os();Ai();import{ProxyAgent as rk,setGlobalDispatcher as sk}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
|
|
779
788
|
Interrupted. Exiting.
|
|
780
|
-
`),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var
|
|
789
|
+
`),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var ok=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function ak(){let e=process.argv.slice(2);if(e.includes("--version")||e.includes("-v"))console.log(`mmx ${bt}`),process.exit(0);let t=Yr(e,ln);if(t[0]==="agent"){let{command:d}=Te.resolve(["agent","setup"]);if(t=Yr(e,[...ln,...d.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)sk(new rk(i));if(e.includes("--help")||e.includes("-h")){let d=e.indexOf("--region"),m=d>=0&&e[d+1]||process.env.MINIMAX_REGION||n.region||"global";Te.printHelp(t,process.stderr,m),process.exit(0)}if(t.length===0){Te.printHelp([],process.stderr);let{command:d}=Te.resolve(["quota","show"]),m=zr(e,[...ln,...d.options??[]]),v=Zr(m),w=!!(v.apiKey||v.fileApiKey),x=!!await he();if(w||x)await d.execute(v,m);else process.stderr.write(` Not logged in.
|
|
781
790
|
`),process.stderr.write(` mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key
|
|
782
791
|
`),process.stderr.write(` mmx auth login --api-key Save an API key directly
|
|
783
792
|
|
|
784
|
-
`);process.exit(0)}let{command:r,extra:s}=
|
|
793
|
+
`);process.exit(0)}let{command:r,extra:s}=Te.resolve(t),o=r.name==="agent setup",a=[...ln,...r.options??[]];if(o){let d=Za(e,a);if(d)throw new y(d,b.USAGE,"Run mmx agent setup --help to see supported options.")}let l=zr(e,a),c=o?e.indexOf("--"):-1,p=c>=0?[...s,...e.slice(c+1)]:s;if(p.length>0)l._positional=p;if(o)l._hasExplicitOptions=p.length>0||e.some((d)=>d.startsWith("-"));let u=Zr(l);if(!o&&!ok.some((d)=>d.every((m,v)=>t[v]===m)))await Gl(u);if(u.needsRegionDetection&&!o){let d=u.apiKey||u.fileApiKey;if(d){let m=await Ri(d);u.region=m,u.baseUrl=ne[m],u.needsRegionDetection=!1,await _c(m)}}let g=o&&u.dryRun?Promise.resolve():Cm(bt).catch(()=>{});await r.execute(u,l),await g;let h=Om();if(h&&!u.quiet)process.stderr.write(`
|
|
785
794
|
Update available: ${h}
|
|
786
795
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
787
796
|
|
|
788
|
-
`)}
|
|
797
|
+
`)}ak().catch(Pt);
|