mmx-cli 1.0.17 → 1.0.18

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/dist/mmx.mjs CHANGED
@@ -1,85 +1,85 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as S$}from"node:module";var _$=Object.create;var{getPrototypeOf:c$,defineProperty:An,getOwnPropertyNames:w$}=Object;var v$=Object.prototype.hasOwnProperty;function b$(t){return this[t]}var M$,s$,Nt=(t,n,r)=>{var i=t!=null&&typeof t==="object";if(i){var $=n?M$??=new WeakMap:s$??=new WeakMap,p=$.get(t);if(p)return p}r=t!=null?_$(c$(t)):{};let e=n||!t||!t.__esModule?An(r,"default",{value:t,enumerable:!0}):r;for(let m of w$(t))if(!v$.call(e,m))An(e,m,{get:b$.bind(t,m),enumerable:!0});if(i)$.set(t,e);return e};var be=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var R$=(t)=>t;function G$(t,n){this[t]=R$.bind(null,n)}var Ot=(t,n)=>{for(var r in n)An(t,r,{get:n[r],enumerable:!0,configurable:!0,set:G$.bind(n,r)})};var s=(t,n)=>()=>(t&&(n=t(t=0)),n);var St=S$(import.meta.url);var x;var k=s(()=>{x={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var J=s(()=>{k();y=class y extends Error{exitCode;hint;constructor(t,n=x.GENERAL,r){super(t);this.name="CLIError",this.exitCode=n,this.hint=r}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function k$(t){if(!t||typeof t!=="object"||Array.isArray(t))return;let n=t;if(typeof n.access_token!=="string"||!n.access_token)return;if(typeof n.refresh_token!=="string")return;if(typeof n.expires_at!=="string")return;let r={access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at};if(typeof n.region==="string"&&Re.has(n.region))r.region=n.region;if(typeof n.resource_url==="string"&&n.resource_url.startsWith("http"))r.resource_url=n.resource_url;if(typeof n.account==="string"&&n.account.length>0)r.account=n.account;return r}function Ge(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let n=t,r={};if(typeof n.api_key==="string")r.api_key=n.api_key;if(typeof n.region==="string"&&Re.has(n.region))r.region=n.region;if(typeof n.base_url==="string"&&n.base_url.startsWith("http"))r.base_url=n.base_url;if(typeof n.output==="string"&&B$.has(n.output))r.output=n.output;if(typeof n.timeout==="number"&&n.timeout>0)r.timeout=n.timeout;if(typeof n.proxy==="string"&&n.proxy.startsWith("http"))r.proxy=n.proxy;let i=k$(n.oauth);if(i)r.oauth=i;if(typeof n.default_text_model==="string"&&n.default_text_model.length>0)r.default_text_model=n.default_text_model;if(typeof n.default_speech_model==="string"&&n.default_speech_model.length>0)r.default_speech_model=n.default_speech_model;if(typeof n.default_video_model==="string"&&n.default_video_model.length>0)r.default_video_model=n.default_video_model;if(typeof n.default_music_model==="string"&&n.default_music_model.length>0)r.default_music_model=n.default_music_model;return r}var W,Ut,Wt,Re,B$;var tt=s(()=>{W={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Ut={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Wt={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},Re=new Set(["global","cn"]),B$=new Set(["text","json"])});function S(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var Ht;var Z=s(()=>{Ht=[{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 J$}from"os";import{join as Se}from"path";function Kt(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return Se(J$(),V$)}function nt(){return Se(Kt(),"config.json")}async function Ae(){let t=Kt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}var V$=".mmx";var At=()=>{};var he={};Ot(he,{formatText:()=>jn,formatTable:()=>qe,formatKeyValue:()=>It});function jn(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return qe(t);return t.map(String).join(`
3
- `)}if(typeof t==="object")return It(t);return String(t)}function It(t,n=0){let r=" ".repeat(n),i=[];for(let[$,p]of Object.entries(t)){if(p===null||p===void 0)continue;if(Array.isArray(p)){i.push(`${r}${$}:`);for(let e of p)if(typeof e==="object"&&e!==null)i.push(`${r} - ${It(e,n+4).trimStart()}`);else i.push(`${r} - ${String(e)}`)}else if(typeof p==="object")i.push(`${r}${$}:`),i.push(It(p,n+2));else i.push(`${r}${$}: ${String(p)}`)}return i.join(`
4
- `)}function qe(t){if(t.length===0)return"(empty)";let n=Object.keys(t[0]),r=n.map((e)=>Math.max(e.length,...t.map((m)=>String(m[e]??"").length))),i=n.map((e,m)=>e.toUpperCase().padEnd(r[m])).join(" "),$=r.map((e)=>"-".repeat(e)).join(" "),p=t.map((e)=>n.map((m,u)=>String(e[m]??"").padEnd(r[u])).join(" "));return[i,$,...p].join(`
5
- `)}function je(t){return JSON.stringify(t,null,2)}function j(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function A(t,n){switch(n){case"json":return je(t);case"text":return jn(t)}}function et(t,n){if(!t.dryRun)return!1;return console.log(A({request:n},j(t.output))),!0}var Y=()=>{};import{copyFileSync as X$,existsSync as U$,readFileSync as Q$,renameSync as Z$,unlinkSync as T$,writeFileSync as Y$}from"fs";function z$(t){return t instanceof Error&&"code"in t&&t.code==="EXDEV"}function N$(t,n,r={rename:Z$,copy:X$,unlink:T$}){try{r.rename(t,n)}catch(i){if(!z$(i))throw i;r.copy(t,n),r.unlink(t)}}function z(){let t=nt();if(!U$(t))return{};try{return Ge(JSON.parse(Q$(t,"utf-8")))}catch(n){let r=n;if(r instanceof SyntaxError||r.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
6
- `);return{}}}async function P(t,n){await Ae();let r=nt(),i=r+".tmp";Y$(i,JSON.stringify(t,null,2)+`
7
- `,{mode:384}),N$(i,r,n)}function Bn(t){let n=z(),r=t.apiKey||void 0,i=n.api_key,$=t.region||process.env.MINIMAX_REGION||void 0;if($&&!($ in W))throw new y(`Invalid region "${$}". Valid values: ${Object.keys(W).join(", ")}`,x.USAGE);let p=n.region,e=$||p||"global",m=r||i,u=!$&&(!p||m!==void 0&&m!==n.api_key),_=t.baseUrl||process.env.MINIMAX_BASE_URL||n.base_url||n.oauth?.resource_url||W[e]||W.global,c=j(t.output||process.env.MINIMAX_OUTPUT||n.output),w=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,v=w!==void 0&&Number.isFinite(w)&&w>0?w:void 0,b=t.timeout??v??n.timeout??300;return{apiKey:r,fileApiKey:i,fileRegion:n.region,configPath:nt(),region:e,baseUrl:_,output:c,timeout:b,defaultTextModel:n.default_text_model,defaultSpeechModel:n.default_speech_model,defaultVideoModel:n.default_video_model,defaultMusicModel:n.default_music_model,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:u}}var rt=s(()=>{tt();At();Y();J();k()});function H(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}var Jn=be((lo,Be)=>{var kn={to(t,n){if(!n)return`\x1B[${t+1}G`;return`\x1B[${n+1};${t+1}H`},move(t,n){let r="";if(t<0)r+=`\x1B[${-t}D`;else if(t>0)r+=`\x1B[${t}C`;if(n<0)r+=`\x1B[${-n}A`;else if(n>0)r+=`\x1B[${n}B`;return r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},O$={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},W$={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let n="";for(let r=0;r<t;r++)n+=this.line+(r<t-1?kn.up():"");if(t)n+=kn.left;return n}};Be.exports={cursor:kn,scroll:O$,erase:W$,beep:"\x07"}});var Xn=be((Eo,Vn)=>{var dt=process||{},ke=dt.argv||[],Pt=dt.env||{},H$=!(!!Pt.NO_COLOR||ke.includes("--no-color"))&&(!!Pt.FORCE_COLOR||ke.includes("--color")||dt.platform==="win32"||(dt.stdout||{}).isTTY&&Pt.TERM!=="dumb"||!!Pt.CI),K$=(t,n,r=t)=>(i)=>{let $=""+i,p=$.indexOf(n,t.length);return~p?t+I$($,n,r,p)+n:t+$+n},I$=(t,n,r,i)=>{let $="",p=0;do $+=t.substring(p,i)+r,p=i+n.length,i=t.indexOf(n,p);while(~i);return $+t.substring(p)},Je=(t=H$)=>{let n=t?K$:()=>String;return{isColorSupported:t,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};Vn.exports=Je();Vn.exports.createColors=Je});import{stdin as Ie,stdout as Pe}from"node:process";import*as $t from"node:readline";import Ve from"node:readline";import{WriteStream as P$}from"node:tty";function d$({onlyFirst:t=!1}={}){let n=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(n,t?void 0:"g")}function de(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(l$,"")}function le(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Qt(t,n={}){if(typeof t!="string"||t.length===0||(n={ambiguousIsNarrow:!0,...n},t=de(t),t.length===0))return 0;t=t.replace(a$()," ");let r=n.ambiguousIsNarrow?1:2,i=0;for(let $ of t){let p=$.codePointAt(0);if(p<=31||p>=127&&p<=159||p>=768&&p<=879)continue;switch(L$.eastAsianWidth($)){case"F":case"W":i+=2;break;case"A":i+=r;break;default:i+=1}}return i}function g$(){let t=new Map;for(let[n,r]of Object.entries(T)){for(let[i,$]of Object.entries(r))T[i]={open:`\x1B[${$[0]}m`,close:`\x1B[${$[1]}m`},r[i]=T[i],t.set($[0],$[1]);Object.defineProperty(T,n,{value:r,enumerable:!1})}return Object.defineProperty(T,"codes",{value:t,enumerable:!1}),T.color.close="\x1B[39m",T.bgColor.close="\x1B[49m",T.color.ansi=Xe(),T.color.ansi256=Ue(),T.color.ansi16m=Qe(),T.bgColor.ansi=Xe(Un),T.bgColor.ansi256=Ue(Un),T.bgColor.ansi16m=Qe(Un),Object.defineProperties(T,{rgbToAnsi256:{value:(n,r,i)=>n===r&&r===i?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5),enumerable:!1},hexToRgb:{value:(n)=>{let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map((p)=>p+p).join(""));let $=Number.parseInt(i,16);return[$>>16&255,$>>8&255,$&255]},enumerable:!1},hexToAnsi256:{value:(n)=>T.rgbToAnsi256(...T.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:(n)=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,i,$;if(n>=232)r=((n-232)*10+8)/255,i=r,$=r;else{n-=16;let m=n%36;r=Math.floor(n/36)/5,i=Math.floor(m/6)/5,$=m%6/5}let p=Math.max(r,i,$)*2;if(p===0)return 30;let e=30+(Math.round($)<<2|Math.round(i)<<1|Math.round(r));return p===2&&(e+=60),e},enumerable:!1},rgbToAnsi:{value:(n,r,i)=>T.ansi256ToAnsi(T.rgbToAnsi256(n,r,i)),enumerable:!1},hexToAnsi:{value:(n)=>T.ansi256ToAnsi(T.hexToAnsi256(n)),enumerable:!1}}),T}function Ye(t,n,r){return String(t).normalize().replace(/\r\n/g,`
2
+ import{createRequire as S$}from"node:module";var c$=Object.create;var{getPrototypeOf:_$,defineProperty:An,getOwnPropertyNames:w$}=Object;var v$=Object.prototype.hasOwnProperty;function M$(t){return this[t]}var b$,s$,Nt=(t,n,i)=>{var r=t!=null&&typeof t==="object";if(r){var $=n?b$??=new WeakMap:s$??=new WeakMap,p=$.get(t);if(p)return p}i=t!=null?c$(_$(t)):{};let e=n||!t||!t.__esModule?An(i,"default",{value:t,enumerable:!0}):i;for(let m of w$(t))if(!v$.call(e,m))An(e,m,{get:M$.bind(t,m),enumerable:!0});if(r)$.set(t,e);return e};var Me=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var R$=(t)=>t;function G$(t,n){this[t]=R$.bind(null,n)}var Ot=(t,n)=>{for(var i in n)An(t,i,{get:n[i],enumerable:!0,configurable:!0,set:G$.bind(n,i)})};var s=(t,n)=>()=>(t&&(n=t(t=0)),n);var St=S$(import.meta.url);var x;var k=s(()=>{x={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var y;var J=s(()=>{k();y=class y extends Error{exitCode;hint;constructor(t,n=x.GENERAL,i){super(t);this.name="CLIError",this.exitCode=n,this.hint=i}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function k$(t){if(!t||typeof t!=="object"||Array.isArray(t))return;let n=t;if(typeof n.access_token!=="string"||!n.access_token)return;if(typeof n.refresh_token!=="string")return;if(typeof n.expires_at!=="string")return;let i={access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at};if(typeof n.region==="string"&&Re.has(n.region))i.region=n.region;if(typeof n.resource_url==="string"&&n.resource_url.startsWith("http"))i.resource_url=n.resource_url;if(typeof n.account==="string"&&n.account.length>0)i.account=n.account;return i}function Ge(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let n=t,i={};if(typeof n.api_key==="string")i.api_key=n.api_key;if(typeof n.region==="string"&&Re.has(n.region))i.region=n.region;if(typeof n.base_url==="string"&&n.base_url.startsWith("http"))i.base_url=n.base_url;if(typeof n.output==="string"&&B$.has(n.output))i.output=n.output;if(typeof n.timeout==="number"&&n.timeout>0)i.timeout=n.timeout;if(typeof n.proxy==="string"&&n.proxy.startsWith("http"))i.proxy=n.proxy;let r=k$(n.oauth);if(r)i.oauth=r;if(typeof n.default_text_model==="string"&&n.default_text_model.length>0)i.default_text_model=n.default_text_model;if(typeof n.default_speech_model==="string"&&n.default_speech_model.length>0)i.default_speech_model=n.default_speech_model;if(typeof n.default_video_model==="string"&&n.default_video_model.length>0)i.default_video_model=n.default_video_model;if(typeof n.default_music_model==="string"&&n.default_music_model.length>0)i.default_music_model=n.default_music_model;return i}var W,Ut,Wt,Re,B$;var tt=s(()=>{W={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Ut={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Wt={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},Re=new Set(["global","cn"]),B$=new Set(["text","json"])});function S(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var Ht;var Z=s(()=>{Ht=[{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 J$}from"os";import{join as Se}from"path";function Kt(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return Se(J$(),V$)}function nt(){return Se(Kt(),"config.json")}async function Ae(){let t=Kt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}var V$=".mmx";var At=()=>{};var qe={};Ot(qe,{formatText:()=>jn,formatTable:()=>he,formatKeyValue:()=>It});function jn(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return he(t);return t.map(String).join(`
3
+ `)}if(typeof t==="object")return It(t);return String(t)}function It(t,n=0){let i=" ".repeat(n),r=[];for(let[$,p]of Object.entries(t)){if(p===null||p===void 0)continue;if(Array.isArray(p)){r.push(`${i}${$}:`);for(let e of p)if(typeof e==="object"&&e!==null)r.push(`${i} - ${It(e,n+4).trimStart()}`);else r.push(`${i} - ${String(e)}`)}else if(typeof p==="object")r.push(`${i}${$}:`),r.push(It(p,n+2));else r.push(`${i}${$}: ${String(p)}`)}return r.join(`
4
+ `)}function he(t){if(t.length===0)return"(empty)";let n=Object.keys(t[0]),i=n.map((e)=>Math.max(e.length,...t.map((m)=>String(m[e]??"").length))),r=n.map((e,m)=>e.toUpperCase().padEnd(i[m])).join(" "),$=i.map((e)=>"-".repeat(e)).join(" "),p=t.map((e)=>n.map((m,u)=>String(e[m]??"").padEnd(i[u])).join(" "));return[r,$,...p].join(`
5
+ `)}function je(t){return JSON.stringify(t,null,2)}function j(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function A(t,n){switch(n){case"json":return je(t);case"text":return jn(t)}}function et(t,n){if(!t.dryRun)return!1;return console.log(A({request:n},j(t.output))),!0}var Y=()=>{};import{copyFileSync as X$,existsSync as U$,readFileSync as Q$,renameSync as Z$,unlinkSync as T$,writeFileSync as Y$}from"fs";function z$(t){return t instanceof Error&&"code"in t&&t.code==="EXDEV"}function N$(t,n,i={rename:Z$,copy:X$,unlink:T$}){try{i.rename(t,n)}catch(r){if(!z$(r))throw r;i.copy(t,n),i.unlink(t)}}function z(){let t=nt();if(!U$(t))return{};try{return Ge(JSON.parse(Q$(t,"utf-8")))}catch(n){let i=n;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
6
+ `);return{}}}async function P(t,n){await Ae();let i=nt(),r=i+".tmp";Y$(r,JSON.stringify(t,null,2)+`
7
+ `,{mode:384}),N$(r,i,n)}function Bn(t){let n=z(),i=t.apiKey||void 0,r=n.api_key,$=t.region||process.env.MINIMAX_REGION||void 0;if($&&!($ in W))throw new y(`Invalid region "${$}". Valid values: ${Object.keys(W).join(", ")}`,x.USAGE);let p=n.region,e=$||p||"global",m=i||r,u=!$&&(!p||m!==void 0&&m!==n.api_key),c=t.baseUrl||process.env.MINIMAX_BASE_URL||n.base_url||n.oauth?.resource_url||W[e]||W.global,_=j(t.output||process.env.MINIMAX_OUTPUT||n.output),w=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,v=w!==void 0&&Number.isFinite(w)&&w>0?w:void 0,M=t.timeout??v??n.timeout??300;return{apiKey:i,fileApiKey:r,fileRegion:n.region,configPath:nt(),region:e,baseUrl:c,output:_,timeout:M,defaultTextModel:n.default_text_model,defaultSpeechModel:n.default_speech_model,defaultVideoModel:n.default_video_model,defaultMusicModel:n.default_music_model,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:u}}var it=s(()=>{tt();At();Y();J();k()});function H(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}var Jn=Me((lo,Be)=>{var kn={to(t,n){if(!n)return`\x1B[${t+1}G`;return`\x1B[${n+1};${t+1}H`},move(t,n){let i="";if(t<0)i+=`\x1B[${-t}D`;else if(t>0)i+=`\x1B[${t}C`;if(n<0)i+=`\x1B[${-n}A`;else if(n>0)i+=`\x1B[${n}B`;return i},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},O$={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},W$={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let n="";for(let i=0;i<t;i++)n+=this.line+(i<t-1?kn.up():"");if(t)n+=kn.left;return n}};Be.exports={cursor:kn,scroll:O$,erase:W$,beep:"\x07"}});var Xn=Me((Eo,Vn)=>{var dt=process||{},ke=dt.argv||[],Pt=dt.env||{},H$=!(!!Pt.NO_COLOR||ke.includes("--no-color"))&&(!!Pt.FORCE_COLOR||ke.includes("--color")||dt.platform==="win32"||(dt.stdout||{}).isTTY&&Pt.TERM!=="dumb"||!!Pt.CI),K$=(t,n,i=t)=>(r)=>{let $=""+r,p=$.indexOf(n,t.length);return~p?t+I$($,n,i,p)+n:t+$+n},I$=(t,n,i,r)=>{let $="",p=0;do $+=t.substring(p,r)+i,p=r+n.length,r=t.indexOf(n,p);while(~r);return $+t.substring(p)},Je=(t=H$)=>{let n=t?K$:()=>String;return{isColorSupported:t,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};Vn.exports=Je();Vn.exports.createColors=Je});import{stdin as Ie,stdout as Pe}from"node:process";import*as $t from"node:readline";import Ve from"node:readline";import{WriteStream as P$}from"node:tty";function d$({onlyFirst:t=!1}={}){let n=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(n,t?void 0:"g")}function de(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(l$,"")}function le(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Qt(t,n={}){if(typeof t!="string"||t.length===0||(n={ambiguousIsNarrow:!0,...n},t=de(t),t.length===0))return 0;t=t.replace(a$()," ");let i=n.ambiguousIsNarrow?1:2,r=0;for(let $ of t){let p=$.codePointAt(0);if(p<=31||p>=127&&p<=159||p>=768&&p<=879)continue;switch(L$.eastAsianWidth($)){case"F":case"W":r+=2;break;case"A":r+=i;break;default:r+=1}}return r}function g$(){let t=new Map;for(let[n,i]of Object.entries(T)){for(let[r,$]of Object.entries(i))T[r]={open:`\x1B[${$[0]}m`,close:`\x1B[${$[1]}m`},i[r]=T[r],t.set($[0],$[1]);Object.defineProperty(T,n,{value:i,enumerable:!1})}return Object.defineProperty(T,"codes",{value:t,enumerable:!1}),T.color.close="\x1B[39m",T.bgColor.close="\x1B[49m",T.color.ansi=Xe(),T.color.ansi256=Ue(),T.color.ansi16m=Qe(),T.bgColor.ansi=Xe(Un),T.bgColor.ansi256=Ue(Un),T.bgColor.ansi16m=Qe(Un),Object.defineProperties(T,{rgbToAnsi256:{value:(n,i,r)=>n===i&&i===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(n)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!i)return[0,0,0];let[r]=i;r.length===3&&(r=[...r].map((p)=>p+p).join(""));let $=Number.parseInt(r,16);return[$>>16&255,$>>8&255,$&255]},enumerable:!1},hexToAnsi256:{value:(n)=>T.rgbToAnsi256(...T.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:(n)=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let i,r,$;if(n>=232)i=((n-232)*10+8)/255,r=i,$=i;else{n-=16;let m=n%36;i=Math.floor(n/36)/5,r=Math.floor(m/6)/5,$=m%6/5}let p=Math.max(i,r,$)*2;if(p===0)return 30;let e=30+(Math.round($)<<2|Math.round(r)<<1|Math.round(i));return p===2&&(e+=60),e},enumerable:!1},rgbToAnsi:{value:(n,i,r)=>T.ansi256ToAnsi(T.rgbToAnsi256(n,i,r)),enumerable:!1},hexToAnsi:{value:(n)=>T.ansi256ToAnsi(T.hexToAnsi256(n)),enumerable:!1}}),T}function Ye(t,n,i){return String(t).normalize().replace(/\r\n/g,`
8
8
  `).split(`
9
- `).map((i)=>ip(i,n,r)).join(`
10
- `)}function mp(t,n){if(t===n)return;let r=t.split(`
11
- `),i=n.split(`
12
- `),$=[];for(let p=0;p<Math.max(r.length,i.length);p++)r[p]!==i[p]&&$.push(p);return $}function Lt(t){return t===ae}function lt(t,n){t.isTTY&&t.setRawMode(n)}class pt{constructor({render:t,input:n=Ie,output:r=Pe,...i},$=!0){C(this,"input"),C(this,"output"),C(this,"rl"),C(this,"opts"),C(this,"_track",!1),C(this,"_render"),C(this,"_cursor",0),C(this,"state","initial"),C(this,"value"),C(this,"error",""),C(this,"subscribers",new Map),C(this,"_prevFrame",""),this.opts=i,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=$,this.input=n,this.output=r}prompt(){let t=new P$(0);return t._write=(n,r,i)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),i()},this.input.pipe(t),this.rl=Ve.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),Ve.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),lt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((n,r)=>{this.once("submit",()=>{this.output.write(I.cursor.show),this.output.off("resize",this.render),lt(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(I.cursor.show),this.output.off("resize",this.render),lt(this.input,!1),n(ae)})})}on(t,n){let r=this.subscribers.get(t)??[];r.push({cb:n}),this.subscribers.set(t,r)}once(t,n){let r=this.subscribers.get(t)??[];r.push({cb:n,once:!0}),this.subscribers.set(t,r)}emit(t,...n){let r=this.subscribers.get(t)??[],i=[];for(let $ of r)$.cb(...n),$.once&&i.push(()=>r.splice(r.indexOf($),1));for(let $ of i)$()}unsubscribe(){this.subscribers.clear()}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&!this._track&&ze.has(n.name)&&this.emit("cursor",ze.get(n.name)),n?.name&&op.has(n.name)&&this.emit("cursor",n.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),n?.name==="return"){if(this.opts.validate){let r=this.opts.validate(this.value);r&&(this.error=r,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(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(`
9
+ `).map((r)=>rp(r,n,i)).join(`
10
+ `)}function mp(t,n){if(t===n)return;let i=t.split(`
11
+ `),r=n.split(`
12
+ `),$=[];for(let p=0;p<Math.max(i.length,r.length);p++)i[p]!==r[p]&&$.push(p);return $}function Lt(t){return t===ae}function lt(t,n){t.isTTY&&t.setRawMode(n)}class pt{constructor({render:t,input:n=Ie,output:i=Pe,...r},$=!0){C(this,"input"),C(this,"output"),C(this,"rl"),C(this,"opts"),C(this,"_track",!1),C(this,"_render"),C(this,"_cursor",0),C(this,"state","initial"),C(this,"value"),C(this,"error",""),C(this,"subscribers",new Map),C(this,"_prevFrame",""),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=$,this.input=n,this.output=i}prompt(){let t=new P$(0);return t._write=(n,i,r)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),r()},this.input.pipe(t),this.rl=Ve.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),Ve.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),lt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((n,i)=>{this.once("submit",()=>{this.output.write(I.cursor.show),this.output.off("resize",this.render),lt(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(I.cursor.show),this.output.off("resize",this.render),lt(this.input,!1),n(ae)})})}on(t,n){let i=this.subscribers.get(t)??[];i.push({cb:n}),this.subscribers.set(t,i)}once(t,n){let i=this.subscribers.get(t)??[];i.push({cb:n,once:!0}),this.subscribers.set(t,i)}emit(t,...n){let i=this.subscribers.get(t)??[],r=[];for(let $ of i)$.cb(...n),$.once&&r.push(()=>i.splice(i.indexOf($),1));for(let $ of r)$()}unsubscribe(){this.subscribers.clear()}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&!this._track&&ze.has(n.name)&&this.emit("cursor",ze.get(n.name)),n?.name&&op.has(n.name)&&this.emit("cursor",n.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),n?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(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(`
13
13
  `),lt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=Ye(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
14
- `).length-1;this.output.write(I.cursor.move(-999,t*-1))}render(){let t=Ye(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(I.cursor.hide);else{let n=mp(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){let r=n[0];this.output.write(I.cursor.move(0,r)),this.output.write(I.erase.lines(1));let i=t.split(`
15
- `);this.output.write(i[r]),this._prevFrame=t,this.output.write(I.cursor.move(0,i.length-r-1));return}else if(n&&n?.length>1){let r=n[0];this.output.write(I.cursor.move(0,r)),this.output.write(I.erase.down());let i=t.split(`
16
- `).slice(r);this.output.write(i.join(`
17
- `)),this._prevFrame=t;return}this.output.write(I.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function ge({input:t=Ie,output:n=Pe,overwrite:r=!0,hideCursor:i=!0}={}){let $=$t.createInterface({input:t,output:n,prompt:"",tabSize:1});$t.emitKeypressEvents(t,$),t.isTTY&&t.setRawMode(!0);let p=(e,{name:m})=>{if(String(e)==="\x03"){i&&n.write(I.cursor.show),process.exit(0);return}if(!r)return;$t.moveCursor(n,m==="return"?0:-1,m==="return"?-1:0,()=>{$t.clearLine(n,1,()=>{t.once("keypress",p)})})};return i&&n.write(I.cursor.hide),t.once("keypress",p),()=>{t.off("keypress",p),i&&n.write(I.cursor.show),t.isTTY&&!Ap&&t.setRawMode(!1),$.terminal=!1,$.close()}}var I,yt,l$,Ee,E$,L$,C$=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},a$,Un=10,Xe=(t=0)=>(n)=>`\x1B[${n+t}m`,Ue=(t=0)=>(n)=>`\x1B[${38+t};5;${n}m`,Qe=(t=0)=>(n,r,i)=>`\x1B[${38+t};2;${n};${r};${i}m`,T,f$,F$,D$,Et,tp=39,Zn="\x07",Le="[",np="]",Ce="m",Tn,Ze=(t)=>`${Et.values().next().value}${Le}${t}${Ce}`,Te=(t)=>`${Et.values().next().value}${Tn}${t}${Zn}`,ep=(t)=>t.split(" ").map((n)=>Qt(n)),Qn=(t,n,r)=>{let i=[...n],$=!1,p=!1,e=Qt(de(t[t.length-1]));for(let[m,u]of i.entries()){let _=Qt(u);if(e+_<=r?t[t.length-1]+=u:(t.push(u),e=0),Et.has(u)&&($=!0,p=i.slice(m+1).join("").startsWith(Tn)),$){p?u===Zn&&($=!1,p=!1):u===Ce&&($=!1);continue}e+=_,e===r&&m<i.length-1&&(t.push(""),e=0)}!e&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},rp=(t)=>{let n=t.split(" "),r=n.length;for(;r>0&&!(Qt(n[r-1])>0);)r--;return r===n.length?t:n.slice(0,r).join(" ")+n.slice(r).join("")},ip=(t,n,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let i="",$,p,e=ep(t),m=[""];for(let[_,c]of t.split(" ").entries()){r.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let w=Qt(m[m.length-1]);if(_!==0&&(w>=n&&(r.wordWrap===!1||r.trim===!1)&&(m.push(""),w=0),(w>0||r.trim===!1)&&(m[m.length-1]+=" ",w++)),r.hard&&e[_]>n){let v=n-w,b=1+Math.floor((e[_]-v-1)/n);Math.floor((e[_]-1)/n)<b&&m.push(""),Qn(m,c,n);continue}if(w+e[_]>n&&w>0&&e[_]>0){if(r.wordWrap===!1&&w<n){Qn(m,c,n);continue}m.push("")}if(w+e[_]>n&&r.wordWrap===!1){Qn(m,c,n);continue}m[m.length-1]+=c}r.trim!==!1&&(m=m.map((_)=>rp(_)));let u=[...m.join(`
18
- `)];for(let[_,c]of u.entries()){if(i+=c,Et.has(c)){let{groups:v}=new RegExp(`(?:\\${Le}(?<code>\\d+)m|\\${Tn}(?<uri>.*)${Zn})`).exec(u.slice(_).join(""))||{groups:{}};if(v.code!==void 0){let b=Number.parseFloat(v.code);$=b===tp?void 0:b}else v.uri!==void 0&&(p=v.uri.length===0?void 0:v.uri)}let w=D$.codes.get(Number($));u[_+1]===`
19
- `?(p&&(i+=Te("")),$&&w&&(i+=Ze(w))):c===`
20
- `&&($&&w&&(i+=Ze($)),p&&(i+=Te(p)))}return i},$p,pp=(t,n,r)=>(n in t)?$p(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,C=(t,n,r)=>(pp(t,typeof n!="symbol"?n+"":n,r),r),ae,ze,op,Yn,up,xp=(t,n,r)=>(n in t)?up(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,Ne=(t,n,r)=>(xp(t,typeof n!="symbol"?n+"":n,r),r),zn,yp,_p=(t,n,r)=>(n in t)?yp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,Oe=(t,n,r)=>(_p(t,typeof n!="symbol"?n+"":n,r),r),fe,cp,wp=(t,n,r)=>(n in t)?cp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,We=(t,n,r)=>(wp(t,typeof n!="symbol"?n+"":n,r),r),Nn,vp,bp=(t,n,r)=>(n in t)?vp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,He=(t,n,r)=>(bp(t,typeof n!="symbol"?n+"":n,r),r),Fe,Mp,sp=(t,n,r)=>(n in t)?Mp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,Ke=(t,n,r)=>(sp(t,typeof n!="symbol"?n+"":n,r),r),On,Rp,Gp=(t,n,r)=>(n in t)?Rp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,Sp=(t,n,r)=>(Gp(t,typeof n!="symbol"?n+"":n,r),r),Wn,Ap;var Hn=s(()=>{I=Nt(Jn(),1),yt=Nt(Xn(),1);l$=d$();Ee={exports:{}};(function(t){var n={};t.exports=n,n.eastAsianWidth=function(i){var $=i.charCodeAt(0),p=i.length==2?i.charCodeAt(1):0,e=$;return 55296<=$&&$<=56319&&56320<=p&&p<=57343&&($&=1023,p&=1023,e=$<<10|p,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&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||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},n.characterLength=function(i){var $=this.eastAsianWidth(i);return $=="F"||$=="W"||$=="A"?2:1};function r(i){return i.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}n.length=function(i){for(var $=r(i),p=0,e=0;e<$.length;e++)p=p+this.characterLength($[e]);return p},n.slice=function(i,$,p){textLen=n.length(i),$=$||0,p=p||1,$<0&&($=textLen+$),p<0&&(p=textLen+p);for(var e="",m=0,u=r(i),_=0;_<u.length;_++){var c=u[_],w=n.length(c);if(m>=$-(w==2?1:0))if(m+w<=p)e+=c;else break;m+=w}return e}})(Ee);E$=Ee.exports,L$=le(E$),a$=le(C$);T={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(T.modifier);f$=Object.keys(T.color),F$=Object.keys(T.bgColor);[...f$,...F$];D$=g$(),Et=new Set(["\x1B","›"]),Tn=`${np}8;;`;$p=Object.defineProperty;ae=Symbol("clack:cancel");ze=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),op=new Set(["up","down","left","right","space","enter"]);Yn=class Yn extends pt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(n)=>{this.output.write(I.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};up=Object.defineProperty;zn=class zn extends pt{constructor(t){super(t,!1),Ne(this,"options"),Ne(this,"cursor",0);let{options:n}=t;this.options=Object.entries(n).flatMap(([r,i])=>[{value:r,group:!0,label:r},...i.map(($)=>({...$,group:r}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:r})=>r===t.cursorAt),0),this.on("cursor",(r)=>{switch(r){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((n)=>n.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((n)=>this.value.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let n=t.value,r=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((i)=>r.findIndex(($)=>$.value===i)===-1):this.value=[...this.value,...r.map((i)=>i.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((r)=>r!==t.value):[...this.value,t.value]}}};yp=Object.defineProperty,fe=class extends pt{constructor(t){super(t,!1),Oe(this,"options"),Oe(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("key",(n)=>{n==="a"&&this.toggleAll()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((n)=>n.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((n)=>n!==this._value):[...this.value,this._value]}},cp=Object.defineProperty;Nn=class Nn extends pt{constructor({mask:t,...n}){super(n),We(this,"valueWithCursor",""),We(this,"_mask","•"),this._mask=t??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${yt.default.inverse(yt.default.hidden("_"))}`;else{let r=this.masked.slice(0,this.cursor),i=this.masked.slice(this.cursor);this.valueWithCursor=`${r}${yt.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};vp=Object.defineProperty,Fe=class extends pt{constructor(t){super(t,!1),He(this,"options"),He(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Mp=Object.defineProperty;On=class On extends pt{constructor(t){super(t,!1),Ke(this,"options"),Ke(this,"cursor",0),this.options=t.options;let n=this.options.map(({value:[r]})=>r?.toLowerCase());this.cursor=Math.max(n.indexOf(t.initialValue),0),this.on("key",(r)=>{if(!n.includes(r))return;let i=this.options.find(({value:[$]})=>$?.toLowerCase()===r);i&&(this.value=i.value,this.state="submit",this.emit("submit"))})}};Rp=Object.defineProperty;Wn=class Wn extends pt{constructor(t){super(t),Sp(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${yt.default.inverse(yt.default.hidden("_"))}`;else{let n=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor);this.valueWithCursor=`${n}${yt.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}};Ap=globalThis.process.platform.startsWith("win")});var wt={};Ot(wt,{text:()=>Tp,spinner:()=>lp,selectKey:()=>Op,select:()=>Np,password:()=>Yp,outro:()=>dp,note:()=>Kp,multiselect:()=>Wp,log:()=>_t,isCancel:()=>Lt,intro:()=>Pp,groupMultiselect:()=>Hp,group:()=>Lp,confirm:()=>zp,cancel:()=>Ip});import F from"node:process";function qp(){return F.platform!=="win32"?F.env.TERM!=="linux":Boolean(F.env.CI)||Boolean(F.env.WT_SESSION)||Boolean(F.env.TERMINUS_SUBLIME)||F.env.ConEmuTask==="{cmd::Cmder}"||F.env.TERM_PROGRAM==="Terminus-Sublime"||F.env.TERM_PROGRAM==="vscode"||F.env.TERM==="xterm-256color"||F.env.TERM==="alacritty"||F.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Ep(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var o,qt,In,O=(t,n)=>In?t:n,hp,tr,nr,Ct,jp,R,d,Pn,dn,ln,Zt,er,Bp,De,kp,Jp,Vp,Xp,Up,Qp,Zp,ct=(t)=>{switch(t){case"initial":case"active":return o.default.cyan(hp);case"cancel":return o.default.red(tr);case"error":return o.default.yellow(nr);case"submit":return o.default.green(Ct)}},Tp=(t)=>new Wn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let n=`${o.default.gray(R)}
21
- ${ct(this.state)} ${t.message}
22
- `,r=t.placeholder?o.default.inverse(t.placeholder[0])+o.default.dim(t.placeholder.slice(1)):o.default.inverse(o.default.hidden("_")),i=this.value?this.valueWithCursor:r;switch(this.state){case"error":return`${n.trim()}
23
- ${o.default.yellow(R)} ${i}
14
+ `).length-1;this.output.write(I.cursor.move(-999,t*-1))}render(){let t=Ye(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(I.cursor.hide);else{let n=mp(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){let i=n[0];this.output.write(I.cursor.move(0,i)),this.output.write(I.erase.lines(1));let r=t.split(`
15
+ `);this.output.write(r[i]),this._prevFrame=t,this.output.write(I.cursor.move(0,r.length-i-1));return}else if(n&&n?.length>1){let i=n[0];this.output.write(I.cursor.move(0,i)),this.output.write(I.erase.down());let r=t.split(`
16
+ `).slice(i);this.output.write(r.join(`
17
+ `)),this._prevFrame=t;return}this.output.write(I.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function ge({input:t=Ie,output:n=Pe,overwrite:i=!0,hideCursor:r=!0}={}){let $=$t.createInterface({input:t,output:n,prompt:"",tabSize:1});$t.emitKeypressEvents(t,$),t.isTTY&&t.setRawMode(!0);let p=(e,{name:m})=>{if(String(e)==="\x03"){r&&n.write(I.cursor.show),process.exit(0);return}if(!i)return;$t.moveCursor(n,m==="return"?0:-1,m==="return"?-1:0,()=>{$t.clearLine(n,1,()=>{t.once("keypress",p)})})};return r&&n.write(I.cursor.hide),t.once("keypress",p),()=>{t.off("keypress",p),r&&n.write(I.cursor.show),t.isTTY&&!Ap&&t.setRawMode(!1),$.terminal=!1,$.close()}}var I,yt,l$,Ee,E$,L$,C$=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},a$,Un=10,Xe=(t=0)=>(n)=>`\x1B[${n+t}m`,Ue=(t=0)=>(n)=>`\x1B[${38+t};5;${n}m`,Qe=(t=0)=>(n,i,r)=>`\x1B[${38+t};2;${n};${i};${r}m`,T,F$,f$,D$,Et,tp=39,Zn="\x07",Le="[",np="]",Ce="m",Tn,Ze=(t)=>`${Et.values().next().value}${Le}${t}${Ce}`,Te=(t)=>`${Et.values().next().value}${Tn}${t}${Zn}`,ep=(t)=>t.split(" ").map((n)=>Qt(n)),Qn=(t,n,i)=>{let r=[...n],$=!1,p=!1,e=Qt(de(t[t.length-1]));for(let[m,u]of r.entries()){let c=Qt(u);if(e+c<=i?t[t.length-1]+=u:(t.push(u),e=0),Et.has(u)&&($=!0,p=r.slice(m+1).join("").startsWith(Tn)),$){p?u===Zn&&($=!1,p=!1):u===Ce&&($=!1);continue}e+=c,e===i&&m<r.length-1&&(t.push(""),e=0)}!e&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},ip=(t)=>{let n=t.split(" "),i=n.length;for(;i>0&&!(Qt(n[i-1])>0);)i--;return i===n.length?t:n.slice(0,i).join(" ")+n.slice(i).join("")},rp=(t,n,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",$,p,e=ep(t),m=[""];for(let[c,_]of t.split(" ").entries()){i.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let w=Qt(m[m.length-1]);if(c!==0&&(w>=n&&(i.wordWrap===!1||i.trim===!1)&&(m.push(""),w=0),(w>0||i.trim===!1)&&(m[m.length-1]+=" ",w++)),i.hard&&e[c]>n){let v=n-w,M=1+Math.floor((e[c]-v-1)/n);Math.floor((e[c]-1)/n)<M&&m.push(""),Qn(m,_,n);continue}if(w+e[c]>n&&w>0&&e[c]>0){if(i.wordWrap===!1&&w<n){Qn(m,_,n);continue}m.push("")}if(w+e[c]>n&&i.wordWrap===!1){Qn(m,_,n);continue}m[m.length-1]+=_}i.trim!==!1&&(m=m.map((c)=>ip(c)));let u=[...m.join(`
18
+ `)];for(let[c,_]of u.entries()){if(r+=_,Et.has(_)){let{groups:v}=new RegExp(`(?:\\${Le}(?<code>\\d+)m|\\${Tn}(?<uri>.*)${Zn})`).exec(u.slice(c).join(""))||{groups:{}};if(v.code!==void 0){let M=Number.parseFloat(v.code);$=M===tp?void 0:M}else v.uri!==void 0&&(p=v.uri.length===0?void 0:v.uri)}let w=D$.codes.get(Number($));u[c+1]===`
19
+ `?(p&&(r+=Te("")),$&&w&&(r+=Ze(w))):_===`
20
+ `&&($&&w&&(r+=Ze($)),p&&(r+=Te(p)))}return r},$p,pp=(t,n,i)=>(n in t)?$p(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,C=(t,n,i)=>(pp(t,typeof n!="symbol"?n+"":n,i),i),ae,ze,op,Yn,up,xp=(t,n,i)=>(n in t)?up(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Ne=(t,n,i)=>(xp(t,typeof n!="symbol"?n+"":n,i),i),zn,yp,cp=(t,n,i)=>(n in t)?yp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Oe=(t,n,i)=>(cp(t,typeof n!="symbol"?n+"":n,i),i),Fe,_p,wp=(t,n,i)=>(n in t)?_p(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,We=(t,n,i)=>(wp(t,typeof n!="symbol"?n+"":n,i),i),Nn,vp,Mp=(t,n,i)=>(n in t)?vp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,He=(t,n,i)=>(Mp(t,typeof n!="symbol"?n+"":n,i),i),fe,bp,sp=(t,n,i)=>(n in t)?bp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Ke=(t,n,i)=>(sp(t,typeof n!="symbol"?n+"":n,i),i),On,Rp,Gp=(t,n,i)=>(n in t)?Rp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Sp=(t,n,i)=>(Gp(t,typeof n!="symbol"?n+"":n,i),i),Wn,Ap;var Hn=s(()=>{I=Nt(Jn(),1),yt=Nt(Xn(),1);l$=d$();Ee={exports:{}};(function(t){var n={};t.exports=n,n.eastAsianWidth=function(r){var $=r.charCodeAt(0),p=r.length==2?r.charCodeAt(1):0,e=$;return 55296<=$&&$<=56319&&56320<=p&&p<=57343&&($&=1023,p&=1023,e=$<<10|p,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&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||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},n.characterLength=function(r){var $=this.eastAsianWidth(r);return $=="F"||$=="W"||$=="A"?2:1};function i(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}n.length=function(r){for(var $=i(r),p=0,e=0;e<$.length;e++)p=p+this.characterLength($[e]);return p},n.slice=function(r,$,p){textLen=n.length(r),$=$||0,p=p||1,$<0&&($=textLen+$),p<0&&(p=textLen+p);for(var e="",m=0,u=i(r),c=0;c<u.length;c++){var _=u[c],w=n.length(_);if(m>=$-(w==2?1:0))if(m+w<=p)e+=_;else break;m+=w}return e}})(Ee);E$=Ee.exports,L$=le(E$),a$=le(C$);T={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(T.modifier);F$=Object.keys(T.color),f$=Object.keys(T.bgColor);[...F$,...f$];D$=g$(),Et=new Set(["\x1B","›"]),Tn=`${np}8;;`;$p=Object.defineProperty;ae=Symbol("clack:cancel");ze=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),op=new Set(["up","down","left","right","space","enter"]);Yn=class Yn extends pt{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(n)=>{this.output.write(I.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};up=Object.defineProperty;zn=class zn extends pt{constructor(t){super(t,!1),Ne(this,"options"),Ne(this,"cursor",0);let{options:n}=t;this.options=Object.entries(n).flatMap(([i,r])=>[{value:i,group:!0,label:i},...r.map(($)=>({...$,group:i}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:i})=>i===t.cursorAt),0),this.on("cursor",(i)=>{switch(i){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}getGroupItems(t){return this.options.filter((n)=>n.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((n)=>this.value.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let n=t.value,i=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((r)=>i.findIndex(($)=>$.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};yp=Object.defineProperty,Fe=class extends pt{constructor(t){super(t,!1),Oe(this,"options"),Oe(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("key",(n)=>{n==="a"&&this.toggleAll()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((n)=>n.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((n)=>n!==this._value):[...this.value,this._value]}},_p=Object.defineProperty;Nn=class Nn extends pt{constructor({mask:t,...n}){super(n),We(this,"valueWithCursor",""),We(this,"_mask","•"),this._mask=t??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${yt.default.inverse(yt.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${yt.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};vp=Object.defineProperty,fe=class extends pt{constructor(t){super(t,!1),He(this,"options"),He(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},bp=Object.defineProperty;On=class On extends pt{constructor(t){super(t,!1),Ke(this,"options"),Ke(this,"cursor",0),this.options=t.options;let n=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(n.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!n.includes(i))return;let r=this.options.find(({value:[$]})=>$?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};Rp=Object.defineProperty;Wn=class Wn extends pt{constructor(t){super(t),Sp(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${yt.default.inverse(yt.default.hidden("_"))}`;else{let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${n}${yt.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};Ap=globalThis.process.platform.startsWith("win")});var wt={};Ot(wt,{text:()=>Tp,spinner:()=>lp,selectKey:()=>Op,select:()=>Np,password:()=>Yp,outro:()=>dp,note:()=>Kp,multiselect:()=>Wp,log:()=>ct,isCancel:()=>Lt,intro:()=>Pp,groupMultiselect:()=>Hp,group:()=>Lp,confirm:()=>zp,cancel:()=>Ip});import f from"node:process";function hp(){return f.platform!=="win32"?f.env.TERM!=="linux":Boolean(f.env.CI)||Boolean(f.env.WT_SESSION)||Boolean(f.env.TERMINUS_SUBLIME)||f.env.ConEmuTask==="{cmd::Cmder}"||f.env.TERM_PROGRAM==="Terminus-Sublime"||f.env.TERM_PROGRAM==="vscode"||f.env.TERM==="xterm-256color"||f.env.TERM==="alacritty"||f.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function Ep(){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}var o,ht,In,O=(t,n)=>In?t:n,qp,ti,ni,Ct,jp,R,d,Pn,dn,ln,Zt,ei,Bp,De,kp,Jp,Vp,Xp,Up,Qp,Zp,_t=(t)=>{switch(t){case"initial":case"active":return o.default.cyan(qp);case"cancel":return o.default.red(ti);case"error":return o.default.yellow(ni);case"submit":return o.default.green(Ct)}},Tp=(t)=>new Wn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let n=`${o.default.gray(R)}
21
+ ${_t(this.state)} ${t.message}
22
+ `,i=t.placeholder?o.default.inverse(t.placeholder[0])+o.default.dim(t.placeholder.slice(1)):o.default.inverse(o.default.hidden("_")),r=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()}
23
+ ${o.default.yellow(R)} ${r}
24
24
  ${o.default.yellow(d)} ${o.default.yellow(this.error)}
25
25
  `;case"submit":return`${n}${o.default.gray(R)} ${o.default.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${o.default.gray(R)} ${o.default.strikethrough(o.default.dim(this.value??""))}${this.value?.trim()?`
26
- `+o.default.gray(R):""}`;default:return`${n}${o.default.cyan(R)} ${i}
26
+ `+o.default.gray(R):""}`;default:return`${n}${o.default.cyan(R)} ${r}
27
27
  ${o.default.cyan(d)}
28
28
  `}}}).prompt(),Yp=(t)=>new Nn({validate:t.validate,mask:t.mask??Bp,render(){let n=`${o.default.gray(R)}
29
- ${ct(this.state)} ${t.message}
30
- `,r=this.valueWithCursor,i=this.masked;switch(this.state){case"error":return`${n.trim()}
31
- ${o.default.yellow(R)} ${i}
29
+ ${_t(this.state)} ${t.message}
30
+ `,i=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${n.trim()}
31
+ ${o.default.yellow(R)} ${r}
32
32
  ${o.default.yellow(d)} ${o.default.yellow(this.error)}
33
- `;case"submit":return`${n}${o.default.gray(R)} ${o.default.dim(i)}`;case"cancel":return`${n}${o.default.gray(R)} ${o.default.strikethrough(o.default.dim(i??""))}${i?`
34
- `+o.default.gray(R):""}`;default:return`${n}${o.default.cyan(R)} ${r}
33
+ `;case"submit":return`${n}${o.default.gray(R)} ${o.default.dim(r)}`;case"cancel":return`${n}${o.default.gray(R)} ${o.default.strikethrough(o.default.dim(r??""))}${r?`
34
+ `+o.default.gray(R):""}`;default:return`${n}${o.default.cyan(R)} ${i}
35
35
  ${o.default.cyan(d)}
36
- `}}}).prompt(),zp=(t)=>{let n=t.active??"Yes",r=t.inactive??"No";return new Yn({active:n,inactive:r,initialValue:t.initialValue??!0,render(){let i=`${o.default.gray(R)}
37
- ${ct(this.state)} ${t.message}
38
- `,$=this.value?n:r;switch(this.state){case"submit":return`${i}${o.default.gray(R)} ${o.default.dim($)}`;case"cancel":return`${i}${o.default.gray(R)} ${o.default.strikethrough(o.default.dim($))}
39
- ${o.default.gray(R)}`;default:return`${i}${o.default.cyan(R)} ${this.value?`${o.default.green(Pn)} ${n}`:`${o.default.dim(dn)} ${o.default.dim(n)}`} ${o.default.dim("/")} ${this.value?`${o.default.dim(dn)} ${o.default.dim(r)}`:`${o.default.green(Pn)} ${r}`}
36
+ `}}}).prompt(),zp=(t)=>{let n=t.active??"Yes",i=t.inactive??"No";return new Yn({active:n,inactive:i,initialValue:t.initialValue??!0,render(){let r=`${o.default.gray(R)}
37
+ ${_t(this.state)} ${t.message}
38
+ `,$=this.value?n:i;switch(this.state){case"submit":return`${r}${o.default.gray(R)} ${o.default.dim($)}`;case"cancel":return`${r}${o.default.gray(R)} ${o.default.strikethrough(o.default.dim($))}
39
+ ${o.default.gray(R)}`;default:return`${r}${o.default.cyan(R)} ${this.value?`${o.default.green(Pn)} ${n}`:`${o.default.dim(dn)} ${o.default.dim(n)}`} ${o.default.dim("/")} ${this.value?`${o.default.dim(dn)} ${o.default.dim(i)}`:`${o.default.green(Pn)} ${i}`}
40
40
  ${o.default.cyan(d)}
41
- `}}}).prompt()},Np=(t)=>{let n=(i,$)=>{let p=i.label??String(i.value);return $==="active"?`${o.default.green(Pn)} ${p} ${i.hint?o.default.dim(`(${i.hint})`):""}`:$==="selected"?`${o.default.dim(p)}`:$==="cancelled"?`${o.default.strikethrough(o.default.dim(p))}`:`${o.default.dim(dn)} ${o.default.dim(p)}`},r=0;return new Fe({options:t.options,initialValue:t.initialValue,render(){let i=`${o.default.gray(R)}
42
- ${ct(this.state)} ${t.message}
43
- `;switch(this.state){case"submit":return`${i}${o.default.gray(R)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${i}${o.default.gray(R)} ${n(this.options[this.cursor],"cancelled")}
44
- ${o.default.gray(R)}`;default:{let $=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=r+$-3?r=Math.max(Math.min(this.cursor-$+3,this.options.length-$),0):this.cursor<r+2&&(r=Math.max(this.cursor-2,0));let p=$<this.options.length&&r>0,e=$<this.options.length&&r+$<this.options.length;return`${i}${o.default.cyan(R)} ${this.options.slice(r,r+$).map((m,u,_)=>u===0&&p?o.default.dim("..."):u===_.length-1&&e?o.default.dim("..."):n(m,u+r===this.cursor?"active":"inactive")).join(`
41
+ `}}}).prompt()},Np=(t)=>{let n=(r,$)=>{let p=r.label??String(r.value);return $==="active"?`${o.default.green(Pn)} ${p} ${r.hint?o.default.dim(`(${r.hint})`):""}`:$==="selected"?`${o.default.dim(p)}`:$==="cancelled"?`${o.default.strikethrough(o.default.dim(p))}`:`${o.default.dim(dn)} ${o.default.dim(p)}`},i=0;return new fe({options:t.options,initialValue:t.initialValue,render(){let r=`${o.default.gray(R)}
42
+ ${_t(this.state)} ${t.message}
43
+ `;switch(this.state){case"submit":return`${r}${o.default.gray(R)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${o.default.gray(R)} ${n(this.options[this.cursor],"cancelled")}
44
+ ${o.default.gray(R)}`;default:{let $=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+$-3?i=Math.max(Math.min(this.cursor-$+3,this.options.length-$),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));let p=$<this.options.length&&i>0,e=$<this.options.length&&i+$<this.options.length;return`${r}${o.default.cyan(R)} ${this.options.slice(i,i+$).map((m,u,c)=>u===0&&p?o.default.dim("..."):u===c.length-1&&e?o.default.dim("..."):n(m,u+i===this.cursor?"active":"inactive")).join(`
45
45
  ${o.default.cyan(R)} `)}
46
46
  ${o.default.cyan(d)}
47
- `}}}}).prompt()},Op=(t)=>{let n=(r,i="inactive")=>{let $=r.label??String(r.value);return i==="selected"?`${o.default.dim($)}`:i==="cancelled"?`${o.default.strikethrough(o.default.dim($))}`:i==="active"?`${o.default.bgCyan(o.default.gray(` ${r.value} `))} ${$} ${r.hint?o.default.dim(`(${r.hint})`):""}`:`${o.default.gray(o.default.bgWhite(o.default.inverse(` ${r.value} `)))} ${$} ${r.hint?o.default.dim(`(${r.hint})`):""}`};return new On({options:t.options,initialValue:t.initialValue,render(){let r=`${o.default.gray(R)}
48
- ${ct(this.state)} ${t.message}
49
- `;switch(this.state){case"submit":return`${r}${o.default.gray(R)} ${n(this.options.find((i)=>i.value===this.value),"selected")}`;case"cancel":return`${r}${o.default.gray(R)} ${n(this.options[0],"cancelled")}
50
- ${o.default.gray(R)}`;default:return`${r}${o.default.cyan(R)} ${this.options.map((i,$)=>n(i,$===this.cursor?"active":"inactive")).join(`
47
+ `}}}}).prompt()},Op=(t)=>{let n=(i,r="inactive")=>{let $=i.label??String(i.value);return r==="selected"?`${o.default.dim($)}`:r==="cancelled"?`${o.default.strikethrough(o.default.dim($))}`:r==="active"?`${o.default.bgCyan(o.default.gray(` ${i.value} `))} ${$} ${i.hint?o.default.dim(`(${i.hint})`):""}`:`${o.default.gray(o.default.bgWhite(o.default.inverse(` ${i.value} `)))} ${$} ${i.hint?o.default.dim(`(${i.hint})`):""}`};return new On({options:t.options,initialValue:t.initialValue,render(){let i=`${o.default.gray(R)}
48
+ ${_t(this.state)} ${t.message}
49
+ `;switch(this.state){case"submit":return`${i}${o.default.gray(R)} ${n(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${i}${o.default.gray(R)} ${n(this.options[0],"cancelled")}
50
+ ${o.default.gray(R)}`;default:return`${i}${o.default.cyan(R)} ${this.options.map((r,$)=>n(r,$===this.cursor?"active":"inactive")).join(`
51
51
  ${o.default.cyan(R)} `)}
52
52
  ${o.default.cyan(d)}
53
- `}}}).prompt()},Wp=(t)=>{let n=(r,i)=>{let $=r.label??String(r.value);return i==="active"?`${o.default.cyan(ln)} ${$} ${r.hint?o.default.dim(`(${r.hint})`):""}`:i==="selected"?`${o.default.green(Zt)} ${o.default.dim($)}`:i==="cancelled"?`${o.default.strikethrough(o.default.dim($))}`:i==="active-selected"?`${o.default.green(Zt)} ${$} ${r.hint?o.default.dim(`(${r.hint})`):""}`:i==="submitted"?`${o.default.dim($)}`:`${o.default.dim(er)} ${o.default.dim($)}`};return new fe({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option.
54
- ${o.default.reset(o.default.dim(`Press ${o.default.gray(o.default.bgWhite(o.default.inverse(" space ")))} to select, ${o.default.gray(o.default.bgWhite(o.default.inverse(" enter ")))} to submit`))}`},render(){let r=`${o.default.gray(R)}
55
- ${ct(this.state)} ${t.message}
56
- `;switch(this.state){case"submit":return`${r}${o.default.gray(R)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>n(i,"submitted")).join(o.default.dim(", "))||o.default.dim("none")}`;case"cancel":{let i=this.options.filter(({value:$})=>this.value.includes($)).map(($)=>n($,"cancelled")).join(o.default.dim(", "));return`${r}${o.default.gray(R)} ${i.trim()?`${i}
57
- ${o.default.gray(R)}`:""}`}case"error":{let i=this.error.split(`
53
+ `}}}).prompt()},Wp=(t)=>{let n=(i,r)=>{let $=i.label??String(i.value);return r==="active"?`${o.default.cyan(ln)} ${$} ${i.hint?o.default.dim(`(${i.hint})`):""}`:r==="selected"?`${o.default.green(Zt)} ${o.default.dim($)}`:r==="cancelled"?`${o.default.strikethrough(o.default.dim($))}`:r==="active-selected"?`${o.default.green(Zt)} ${$} ${i.hint?o.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${o.default.dim($)}`:`${o.default.dim(ei)} ${o.default.dim($)}`};return new Fe({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
54
+ ${o.default.reset(o.default.dim(`Press ${o.default.gray(o.default.bgWhite(o.default.inverse(" space ")))} to select, ${o.default.gray(o.default.bgWhite(o.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${o.default.gray(R)}
55
+ ${_t(this.state)} ${t.message}
56
+ `;switch(this.state){case"submit":return`${i}${o.default.gray(R)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"submitted")).join(o.default.dim(", "))||o.default.dim("none")}`;case"cancel":{let r=this.options.filter(({value:$})=>this.value.includes($)).map(($)=>n($,"cancelled")).join(o.default.dim(", "));return`${i}${o.default.gray(R)} ${r.trim()?`${r}
57
+ ${o.default.gray(R)}`:""}`}case"error":{let r=this.error.split(`
58
58
  `).map(($,p)=>p===0?`${o.default.yellow(d)} ${o.default.yellow($)}`:` ${$}`).join(`
59
- `);return r+o.default.yellow(R)+" "+this.options.map(($,p)=>{let e=this.value.includes($.value),m=p===this.cursor;return m&&e?n($,"active-selected"):e?n($,"selected"):n($,m?"active":"inactive")}).join(`
59
+ `);return i+o.default.yellow(R)+" "+this.options.map(($,p)=>{let e=this.value.includes($.value),m=p===this.cursor;return m&&e?n($,"active-selected"):e?n($,"selected"):n($,m?"active":"inactive")}).join(`
60
60
  ${o.default.yellow(R)} `)+`
61
- `+i+`
62
- `}default:return`${r}${o.default.cyan(R)} ${this.options.map((i,$)=>{let p=this.value.includes(i.value),e=$===this.cursor;return e&&p?n(i,"active-selected"):p?n(i,"selected"):n(i,e?"active":"inactive")}).join(`
61
+ `+r+`
62
+ `}default:return`${i}${o.default.cyan(R)} ${this.options.map((r,$)=>{let p=this.value.includes(r.value),e=$===this.cursor;return e&&p?n(r,"active-selected"):p?n(r,"selected"):n(r,e?"active":"inactive")}).join(`
63
63
  ${o.default.cyan(R)} `)}
64
64
  ${o.default.cyan(d)}
65
- `}}}).prompt()},Hp=(t)=>{let n=(r,i,$=[])=>{let p=r.label??String(r.value),e=typeof r.group=="string",m=e&&($[$.indexOf(r)+1]??{group:!0}),u=e&&m.group===!0,_=e?`${u?d:R} `:"";return i==="active"?`${o.default.dim(_)}${o.default.cyan(ln)} ${p} ${r.hint?o.default.dim(`(${r.hint})`):""}`:i==="group-active"?`${_}${o.default.cyan(ln)} ${o.default.dim(p)}`:i==="group-active-selected"?`${_}${o.default.green(Zt)} ${o.default.dim(p)}`:i==="selected"?`${o.default.dim(_)}${o.default.green(Zt)} ${o.default.dim(p)}`:i==="cancelled"?`${o.default.strikethrough(o.default.dim(p))}`:i==="active-selected"?`${o.default.dim(_)}${o.default.green(Zt)} ${p} ${r.hint?o.default.dim(`(${r.hint})`):""}`:i==="submitted"?`${o.default.dim(p)}`:`${o.default.dim(_)}${o.default.dim(er)} ${o.default.dim(p)}`};return new zn({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(r){if(this.required&&r.length===0)return`Please select at least one option.
66
- ${o.default.reset(o.default.dim(`Press ${o.default.gray(o.default.bgWhite(o.default.inverse(" space ")))} to select, ${o.default.gray(o.default.bgWhite(o.default.inverse(" enter ")))} to submit`))}`},render(){let r=`${o.default.gray(R)}
67
- ${ct(this.state)} ${t.message}
68
- `;switch(this.state){case"submit":return`${r}${o.default.gray(R)} ${this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>n(i,"submitted")).join(o.default.dim(", "))}`;case"cancel":{let i=this.options.filter(({value:$})=>this.value.includes($)).map(($)=>n($,"cancelled")).join(o.default.dim(", "));return`${r}${o.default.gray(R)} ${i.trim()?`${i}
69
- ${o.default.gray(R)}`:""}`}case"error":{let i=this.error.split(`
65
+ `}}}).prompt()},Hp=(t)=>{let n=(i,r,$=[])=>{let p=i.label??String(i.value),e=typeof i.group=="string",m=e&&($[$.indexOf(i)+1]??{group:!0}),u=e&&m.group===!0,c=e?`${u?d:R} `:"";return r==="active"?`${o.default.dim(c)}${o.default.cyan(ln)} ${p} ${i.hint?o.default.dim(`(${i.hint})`):""}`:r==="group-active"?`${c}${o.default.cyan(ln)} ${o.default.dim(p)}`:r==="group-active-selected"?`${c}${o.default.green(Zt)} ${o.default.dim(p)}`:r==="selected"?`${o.default.dim(c)}${o.default.green(Zt)} ${o.default.dim(p)}`:r==="cancelled"?`${o.default.strikethrough(o.default.dim(p))}`:r==="active-selected"?`${o.default.dim(c)}${o.default.green(Zt)} ${p} ${i.hint?o.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${o.default.dim(p)}`:`${o.default.dim(c)}${o.default.dim(ei)} ${o.default.dim(p)}`};return new zn({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
66
+ ${o.default.reset(o.default.dim(`Press ${o.default.gray(o.default.bgWhite(o.default.inverse(" space ")))} to select, ${o.default.gray(o.default.bgWhite(o.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${o.default.gray(R)}
67
+ ${_t(this.state)} ${t.message}
68
+ `;switch(this.state){case"submit":return`${i}${o.default.gray(R)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"submitted")).join(o.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:$})=>this.value.includes($)).map(($)=>n($,"cancelled")).join(o.default.dim(", "));return`${i}${o.default.gray(R)} ${r.trim()?`${r}
69
+ ${o.default.gray(R)}`:""}`}case"error":{let r=this.error.split(`
70
70
  `).map(($,p)=>p===0?`${o.default.yellow(d)} ${o.default.yellow($)}`:` ${$}`).join(`
71
- `);return`${r}${o.default.yellow(R)} ${this.options.map(($,p,e)=>{let m=this.value.includes($.value)||$.group===!0&&this.isGroupSelected(`${$.value}`),u=p===this.cursor;return!u&&typeof $.group=="string"&&this.options[this.cursor].value===$.group?n($,m?"group-active-selected":"group-active",e):u&&m?n($,"active-selected",e):m?n($,"selected",e):n($,u?"active":"inactive",e)}).join(`
71
+ `);return`${i}${o.default.yellow(R)} ${this.options.map(($,p,e)=>{let m=this.value.includes($.value)||$.group===!0&&this.isGroupSelected(`${$.value}`),u=p===this.cursor;return!u&&typeof $.group=="string"&&this.options[this.cursor].value===$.group?n($,m?"group-active-selected":"group-active",e):u&&m?n($,"active-selected",e):m?n($,"selected",e):n($,u?"active":"inactive",e)}).join(`
72
72
  ${o.default.yellow(R)} `)}
73
- ${i}
74
- `}default:return`${r}${o.default.cyan(R)} ${this.options.map((i,$,p)=>{let e=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),m=$===this.cursor;return!m&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?n(i,e?"group-active-selected":"group-active",p):m&&e?n(i,"active-selected",p):e?n(i,"selected",p):n(i,m?"active":"inactive",p)}).join(`
73
+ ${r}
74
+ `}default:return`${i}${o.default.cyan(R)} ${this.options.map((r,$,p)=>{let e=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),m=$===this.cursor;return!m&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,e?"group-active-selected":"group-active",p):m&&e?n(r,"active-selected",p):e?n(r,"selected",p):n(r,m?"active":"inactive",p)}).join(`
75
75
  ${o.default.cyan(R)} `)}
76
76
  ${o.default.cyan(d)}
77
- `}}}).prompt()},Kn=(t)=>t.replace(Ep(),""),Kp=(t="",n="")=>{let r=`
77
+ `}}}).prompt()},Kn=(t)=>t.replace(Ep(),""),Kp=(t="",n="")=>{let i=`
78
78
  ${t}
79
79
  `.split(`
80
- `),i=Kn(n).length,$=Math.max(r.reduce((e,m)=>(m=Kn(m),m.length>e?m.length:e),0),i)+2,p=r.map((e)=>`${o.default.gray(R)} ${o.default.dim(e)}${" ".repeat($-Kn(e).length)}${o.default.gray(R)}`).join(`
80
+ `),r=Kn(n).length,$=Math.max(i.reduce((e,m)=>(m=Kn(m),m.length>e?m.length:e),0),r)+2,p=i.map((e)=>`${o.default.gray(R)} ${o.default.dim(e)}${" ".repeat($-Kn(e).length)}${o.default.gray(R)}`).join(`
81
81
  `);process.stdout.write(`${o.default.gray(R)}
82
- ${o.default.green(Ct)} ${o.default.reset(n)} ${o.default.gray(De.repeat(Math.max($-i-1,1))+kp)}
82
+ ${o.default.green(Ct)} ${o.default.reset(n)} ${o.default.gray(De.repeat(Math.max($-r-1,1))+kp)}
83
83
  ${p}
84
84
  ${o.default.gray(Jp+De.repeat($+2)+Vp)}
85
85
  `)},Ip=(t="")=>{process.stdout.write(`${o.default.gray(d)} ${o.default.red(t)}
@@ -88,26 +88,26 @@ ${o.default.gray(Jp+De.repeat($+2)+Vp)}
88
88
  `)},dp=(t="")=>{process.stdout.write(`${o.default.gray(R)}
89
89
  ${o.default.gray(d)} ${t}
90
90
 
91
- `)},_t,lp=()=>{let t=In?["◒","◐","◓","◑"]:["•","o","O","0"],n=In?80:120,r,i,$=!1,p="",e=(c="")=>{$=!0,r=ge(),p=c.replace(/\.+$/,""),process.stdout.write(`${o.default.gray(R)}
92
- `);let w=0,v=0;i=setInterval(()=>{let b=o.default.magenta(t[w]),G=".".repeat(Math.floor(v)).slice(0,3);process.stdout.write(qt.cursor.move(-999,0)),process.stdout.write(qt.erase.down(1)),process.stdout.write(`${b} ${p}${G}`),w=w+1<t.length?w+1:0,v=v<t.length?v+0.125:0},n)},m=(c="",w=0)=>{p=c??p,$=!1,clearInterval(i);let v=w===0?o.default.green(Ct):w===1?o.default.red(tr):o.default.red(nr);process.stdout.write(qt.cursor.move(-999,0)),process.stdout.write(qt.erase.down(1)),process.stdout.write(`${v} ${p}
93
- `),r()},u=(c="")=>{p=c??p},_=(c)=>{let w=c>1?"Something went wrong":"Canceled";$&&m(w,c)};return process.on("uncaughtExceptionMonitor",()=>_(2)),process.on("unhandledRejection",()=>_(2)),process.on("SIGINT",()=>_(1)),process.on("SIGTERM",()=>_(1)),process.on("exit",_),{start:e,stop:m,message:u}},Lp=async(t,n)=>{let r={},i=Object.keys(t);for(let $ of i){let p=t[$],e=await p({results:r})?.catch((m)=>{throw m});if(typeof n?.onCancel=="function"&&Lt(e)){r[$]="canceled",n.onCancel({results:r});continue}r[$]=e}return r};var vt=s(()=>{Hn();Hn();o=Nt(Xn(),1),qt=Nt(Jn(),1);In=qp(),hp=O("◆","*"),tr=O("■","x"),nr=O("▲","x"),Ct=O("◇","o"),jp=O("┌","T"),R=O("│","|"),d=O("└","—"),Pn=O("●",">"),dn=O("○"," "),ln=O("◻","[•]"),Zt=O("◼","[+]"),er=O("◻","[ ]"),Bp=O("▪","•"),De=O("─","-"),kp=O("╮","+"),Jp=O("├","+"),Vp=O("╯","+"),Xp=O("●","•"),Up=O("◆","*"),Qp=O("▲","!"),Zp=O("■","x"),_t={message:(t="",{symbol:n=o.default.gray(R)}={})=>{let r=[`${o.default.gray(R)}`];if(t){let[i,...$]=t.split(`
94
- `);r.push(`${n} ${i}`,...$.map((p)=>`${o.default.gray(R)} ${p}`))}process.stdout.write(`${r.join(`
91
+ `)},ct,lp=()=>{let t=In?["◒","◐","◓","◑"]:["•","o","O","0"],n=In?80:120,i,r,$=!1,p="",e=(_="")=>{$=!0,i=ge(),p=_.replace(/\.+$/,""),process.stdout.write(`${o.default.gray(R)}
92
+ `);let w=0,v=0;r=setInterval(()=>{let M=o.default.magenta(t[w]),G=".".repeat(Math.floor(v)).slice(0,3);process.stdout.write(ht.cursor.move(-999,0)),process.stdout.write(ht.erase.down(1)),process.stdout.write(`${M} ${p}${G}`),w=w+1<t.length?w+1:0,v=v<t.length?v+0.125:0},n)},m=(_="",w=0)=>{p=_??p,$=!1,clearInterval(r);let v=w===0?o.default.green(Ct):w===1?o.default.red(ti):o.default.red(ni);process.stdout.write(ht.cursor.move(-999,0)),process.stdout.write(ht.erase.down(1)),process.stdout.write(`${v} ${p}
93
+ `),i()},u=(_="")=>{p=_??p},c=(_)=>{let w=_>1?"Something went wrong":"Canceled";$&&m(w,_)};return process.on("uncaughtExceptionMonitor",()=>c(2)),process.on("unhandledRejection",()=>c(2)),process.on("SIGINT",()=>c(1)),process.on("SIGTERM",()=>c(1)),process.on("exit",c),{start:e,stop:m,message:u}},Lp=async(t,n)=>{let i={},r=Object.keys(t);for(let $ of r){let p=t[$],e=await p({results:i})?.catch((m)=>{throw m});if(typeof n?.onCancel=="function"&&Lt(e)){i[$]="canceled",n.onCancel({results:i});continue}i[$]=e}return i};var vt=s(()=>{Hn();Hn();o=Nt(Xn(),1),ht=Nt(Jn(),1);In=hp(),qp=O("◆","*"),ti=O("■","x"),ni=O("▲","x"),Ct=O("◇","o"),jp=O("┌","T"),R=O("│","|"),d=O("└","—"),Pn=O("●",">"),dn=O("○"," "),ln=O("◻","[•]"),Zt=O("◼","[+]"),ei=O("◻","[ ]"),Bp=O("▪","•"),De=O("─","-"),kp=O("╮","+"),Jp=O("├","+"),Vp=O("╯","+"),Xp=O("●","•"),Up=O("◆","*"),Qp=O("▲","!"),Zp=O("■","x"),ct={message:(t="",{symbol:n=o.default.gray(R)}={})=>{let i=[`${o.default.gray(R)}`];if(t){let[r,...$]=t.split(`
94
+ `);i.push(`${n} ${r}`,...$.map((p)=>`${o.default.gray(R)} ${p}`))}process.stdout.write(`${i.join(`
95
95
  `)}
96
- `)},info:(t)=>{_t.message(t,{symbol:o.default.blue(Xp)})},success:(t)=>{_t.message(t,{symbol:o.default.green(Up)})},step:(t)=>{_t.message(t,{symbol:o.default.green(Ct)})},warn:(t)=>{_t.message(t,{symbol:o.default.yellow(Qp)})},warning:(t)=>{_t.warn(t)},error:(t)=>{_t.message(t,{symbol:o.default.red(Zp)})}}});async function g(t){if(!H())return;let{defaultValue:n,message:r}=t,$=await(await Promise.resolve().then(() => (vt(),wt))).text({message:r,default:n,placeholder:n});if(typeof $==="symbol")return;return $}async function rr(t){if(!H())return;let{message:n}=t,i=await(await Promise.resolve().then(() => (vt(),wt))).confirm({message:n});if(typeof i==="symbol")return;return i}function bt(t,n){throw new y(`Missing required argument: --${t}
96
+ `)},info:(t)=>{ct.message(t,{symbol:o.default.blue(Xp)})},success:(t)=>{ct.message(t,{symbol:o.default.green(Up)})},step:(t)=>{ct.message(t,{symbol:o.default.green(Ct)})},warn:(t)=>{ct.message(t,{symbol:o.default.yellow(Qp)})},warning:(t)=>{ct.warn(t)},error:(t)=>{ct.message(t,{symbol:o.default.red(Zp)})}}});async function g(t){if(!H())return;let{defaultValue:n,message:i}=t,$=await(await Promise.resolve().then(() => (vt(),wt))).text({message:i,default:n,placeholder:n});if(typeof $==="symbol")return;return $}async function ii(t){if(!H())return;let{message:n}=t,r=await(await Promise.resolve().then(() => (vt(),wt))).confirm({message:n});if(typeof r==="symbol")return;return r}function Mt(t,n){throw new y(`Missing required argument: --${t}
97
97
  Hint: In non-interactive (CI / agent) environments all required flags must be provided.
98
98
  In an interactive terminal, run without --${t} and the CLI will prompt for it.`,x.USAGE,n)}async function at(t){if(t.value)return t.value;if(H({nonInteractive:t.nonInteractive})){let n=await g({message:t.message});if(!n)process.stderr.write(t.cancelMessage+`
99
- `),process.exit(1);return n}bt(t.flagName,t.usageHint)}var mt=s(()=>{J();k()});function E(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}async function $r(t){let n=Wt[t],{randomBytes:r,createHash:i}=await import("crypto"),$=r(32).toString("base64url"),p=i("sha256").update($).digest("base64url"),e=r(16).toString("base64url"),m=await fetch(`${n}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:ir,scope:ap.join(" "),code_challenge:p,code_challenge_method:"S256",state:e})});if(!m.ok){let w=await m.text().catch(()=>"");throw new y(`Failed to start device-code flow (HTTP ${m.status}).`,x.AUTH,w||`URL: ${n}/oauth2/device/code`)}let u=await m.json();if(u.state!==e)throw new y("OAuth state mismatch.",x.AUTH);Fp(u.verification_uri),process.stderr.write(`
99
+ `),process.exit(1);return n}Mt(t.flagName,t.usageHint)}var mt=s(()=>{J();k()});function E(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}async function $i(t){let n=Wt[t],{randomBytes:i,createHash:r}=await import("crypto"),$=i(32).toString("base64url"),p=r("sha256").update($).digest("base64url"),e=i(16).toString("base64url"),m=await fetch(`${n}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:ri,scope:ap.join(" "),code_challenge:p,code_challenge_method:"S256",state:e})});if(!m.ok){let w=await m.text().catch(()=>"");throw new y(`Failed to start device-code flow (HTTP ${m.status}).`,x.AUTH,w||`URL: ${n}/oauth2/device/code`)}let u=await m.json();if(u.state!==e)throw new y("OAuth state mismatch.",x.AUTH);fp(u.verification_uri),process.stderr.write(`
100
100
  Opened: ${u.verification_uri}
101
101
  `),process.stderr.write(`Code: ${u.user_code}
102
102
  `),process.stderr.write(`Client: ${Cp}
103
103
  `),process.stderr.write(`Waiting for authorization...
104
- `);let _=u.expired_in,c=u.interval||3000;while(Date.now()<_){await fp(c);let w=await fetch(`${n}/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:ir,user_code:u.user_code,code_verifier:$})});if(!w.ok)throw new y(`Device-code authorization failed (HTTP ${w.status}).`,x.AUTH);let v=await w.json();if(v.status==="pending")continue;if(v.status==="success"&&v.access_token)return{access_token:v.access_token,refresh_token:v.refresh_token??"",expires_at:new Date(v.expired_in??Date.now()).toISOString(),region:t,resource_url:v.resource_url};throw new y(`Device-code authorization failed: ${v.status}`,x.AUTH)}throw new y("Device-code authorization timed out.",x.TIMEOUT)}function fp(t){return new Promise((n)=>setTimeout(n,t))}function Fp(t){let{execFile:n,spawn:r}=St("child_process");if(process.platform==="darwin")n("open",[t]);else if(process.platform==="win32")r("cmd.exe",["/c","start","",t],{shell:!1,detached:!0});else n("xdg-open",[t])}var ir="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Cp="MiniMax CLI",ap;var pr=s(()=>{tt();J();k();ap=["openid","profile","coding_plan"]});async function L(){return z().oauth??null}async function ft(t){let n=z();n.oauth=t,await P(n)}async function mr(){let t=z();if(!("oauth"in t))return;delete t.oauth,await P(t)}var ot=s(()=>{rt()});function Ft(t){return`Looked for credentials in: ${t??nt()}
104
+ `);let c=u.expired_in,_=u.interval||3000;while(Date.now()<c){await Fp(_);let w=await fetch(`${n}/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:ri,user_code:u.user_code,code_verifier:$})});if(!w.ok)throw new y(`Device-code authorization failed (HTTP ${w.status}).`,x.AUTH);let v=await w.json();if(v.status==="pending")continue;if(v.status==="success"&&v.access_token)return{access_token:v.access_token,refresh_token:v.refresh_token??"",expires_at:new Date(v.expired_in??Date.now()).toISOString(),region:t,resource_url:v.resource_url};throw new y(`Device-code authorization failed: ${v.status}`,x.AUTH)}throw new y("Device-code authorization timed out.",x.TIMEOUT)}function Fp(t){return new Promise((n)=>setTimeout(n,t))}function fp(t){let{execFile:n,spawn:i}=St("child_process");if(process.platform==="darwin")n("open",[t]);else if(process.platform==="win32")i("cmd.exe",["/c","start","",t],{shell:!1,detached:!0});else n("xdg-open",[t])}var ri="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Cp="MiniMax CLI",ap;var pi=s(()=>{tt();J();k();ap=["openid","profile","coding_plan"]});async function L(){return z().oauth??null}async function Ft(t){let n=z();n.oauth=t,await P(n)}async function mi(){let t=z();if(!("oauth"in t))return;delete t.oauth,await P(t)}var ot=s(()=>{it()});function ft(t){return`Looked for credentials in: ${t??nt()}
105
105
  ${gp}`}var gp;var En=s(()=>{At();gp=["Log in: mmx auth login","Pass per-call: --api-key sk-xxxxx","Or set env var: MMX_CONFIG_DIR=/path/to/.mmx"].join(`
106
- `)});function ht(t){return t.replace(/^https?:\/\//,"")}async function ur(t){if(t.apiKey||t.fileApiKey)return;if(await L())return;let n=process.env.MINIMAX_API_KEY;if(n){if(!H({nonInteractive:t.nonInteractive}))return;if(await rr({message:`Found MINIMAX_API_KEY in environment (${E(n)}). Save to config file?`}))await or(t,n);return}if(!H({nonInteractive:t.nonInteractive}))throw new y("No credentials found.",x.AUTH,Ft(t.configPath));let r=await Ln();if(r==="api-key"){let i=await g({message:"Enter your MiniMax API key:"});if(!i)throw new y("API key is required.",x.AUTH);await or(t,i);return}await Cn(r==="oauth-cn"?"cn":"global")}async function Ln(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (vt(),wt)),r=await t({message:"How would you like to authenticate?",options:Dp.map((i)=>({value:i.value,label:i.label}))});if(n(r))throw new y("Authentication cancelled.",x.AUTH);return r}async function xr(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (vt(),wt)),r=await t({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${ht(W.global)}`},{value:"cn",label:`China → ${ht(W.cn)}`}]});if(n(r))throw new y("Authentication cancelled.",x.AUTH);return r}async function Cn(t){let n=await $r(t),r=z();delete r.api_key,r.oauth=n,r.region=t,await P(r),process.stderr.write(`Logged in successfully.
106
+ `)});function qt(t){return t.replace(/^https?:\/\//,"")}async function ui(t){if(t.apiKey||t.fileApiKey)return;if(await L())return;let n=process.env.MINIMAX_API_KEY;if(n){if(!H({nonInteractive:t.nonInteractive}))return;if(await ii({message:`Found MINIMAX_API_KEY in environment (${E(n)}). Save to config file?`}))await oi(t,n);return}if(!H({nonInteractive:t.nonInteractive}))throw new y("No credentials found.",x.AUTH,ft(t.configPath));let i=await Ln();if(i==="api-key"){let r=await g({message:"Enter your MiniMax API key:"});if(!r)throw new y("API key is required.",x.AUTH);await oi(t,r);return}await Cn(i==="oauth-cn"?"cn":"global")}async function Ln(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (vt(),wt)),i=await t({message:"How would you like to authenticate?",options:Dp.map((r)=>({value:r.value,label:r.label}))});if(n(i))throw new y("Authentication cancelled.",x.AUTH);return i}async function xi(){let{select:t,isCancel:n}=await Promise.resolve().then(() => (vt(),wt)),i=await t({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${qt(W.global)}`},{value:"cn",label:`China → ${qt(W.cn)}`}]});if(n(i))throw new y("Authentication cancelled.",x.AUTH);return i}async function Cn(t){let n=await $i(t),i=z();delete i.api_key,i.oauth=n,i.region=t,await P(i),process.stderr.write(`Logged in successfully.
107
107
  `),process.stderr.write(`Credentials saved to ~/.mmx/config.json
108
- `)}async function or(t,n){let r={...z(),api_key:n};await P(r),t.fileApiKey=n,process.stderr.write(`API key saved to ${t.configPath??"~/.mmx/config.json"}
109
- `)}var Dp;var an=s(()=>{tt();rt();mt();J();k();pr();ot();En();Dp=[{value:"oauth-global",label:`MiniMax (OAuth login → ${ht(W.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${ht(W.cn)})`},{value:"api-key",label:`API key (${ht(W.global)} or ${ht(W.cn)})`}]});async function fn(t,n="global"){let r=`${Wt[n]}/oauth2/token`,i=null;for(let $=0;$<=yr;$++){if($>0)await new Promise((m)=>setTimeout(m,nm*$));let p;try{p=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t,client_id:tm}),signal:AbortSignal.timeout(em)})}catch(m){let u=m instanceof Error&&(m.name==="AbortError"||m.name==="TimeoutError"||m.message.includes("timed out"));i=Error(u?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${m instanceof Error?m.message:String(m)}`);continue}if(!p.ok){if(p.status>=400&&p.status<500)throw new y("OAuth session expired and could not be refreshed.",x.AUTH,"Re-authenticate: mmx auth login");i=Error(`Token refresh failed: HTTP ${p.status}`);continue}let e=await p.json();if(e.status!=="success"||!e.access_token)throw new y(`OAuth refresh failed: ${e.status}.`,x.AUTH,"Re-authenticate: mmx auth login");return{access_token:e.access_token,refresh_token:e.refresh_token??t,expires_at:new Date(e.expired_in??Date.now()).toISOString(),resource_url:e.resource_url}}throw new y(`Token refresh failed after ${yr+1} attempts: ${i?.message}`,x.AUTH,`Check your network connection.
110
- Re-authenticate: mmx auth login`)}async function _r(t){let n=new Date(t.expires_at).getTime();if(Date.now()<n-rm)return t.access_token;let r=await fn(t.refresh_token,t.region??"global"),i={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:r.expires_at,region:t.region,resource_url:r.resource_url??t.resource_url,account:t.account};return await ft(i),i.access_token}var tm="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",yr=2,nm=500,em=1e4,rm=300000;var Fn=s(()=>{tt();ot();J();k()});async function gt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let n=await L();if(n)return{token:await _r(n),method:"oauth",source:"config.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new y("No credentials found.",x.AUTH,Ft(t.configPath))}var gn=s(()=>{ot();Fn();J();k();En()});function cr(t){if(!t)return"";if(t.includes("/t2a"))return`
108
+ `)}async function oi(t,n){let i={...z(),api_key:n};await P(i),t.fileApiKey=n,process.stderr.write(`API key saved to ${t.configPath??"~/.mmx/config.json"}
109
+ `)}var Dp;var an=s(()=>{tt();it();mt();J();k();pi();ot();En();Dp=[{value:"oauth-global",label:`MiniMax (OAuth login → ${qt(W.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${qt(W.cn)})`},{value:"api-key",label:`API key (${qt(W.global)} or ${qt(W.cn)})`}]});async function Fn(t,n="global"){let i=`${Wt[n]}/oauth2/token`,r=null;for(let $=0;$<=yi;$++){if($>0)await new Promise((m)=>setTimeout(m,nm*$));let p;try{p=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t,client_id:tm}),signal:AbortSignal.timeout(em)})}catch(m){let u=m instanceof Error&&(m.name==="AbortError"||m.name==="TimeoutError"||m.message.includes("timed out"));r=Error(u?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${m instanceof Error?m.message:String(m)}`);continue}if(!p.ok){if(p.status>=400&&p.status<500)throw new y("OAuth session expired and could not be refreshed.",x.AUTH,"Re-authenticate: mmx auth login");r=Error(`Token refresh failed: HTTP ${p.status}`);continue}let e=await p.json();if(e.status!=="success"||!e.access_token)throw new y(`OAuth refresh failed: ${e.status}.`,x.AUTH,"Re-authenticate: mmx auth login");return{access_token:e.access_token,refresh_token:e.refresh_token??t,expires_at:new Date(e.expired_in??Date.now()).toISOString(),resource_url:e.resource_url}}throw new y(`Token refresh failed after ${yi+1} attempts: ${r?.message}`,x.AUTH,`Check your network connection.
110
+ Re-authenticate: mmx auth login`)}async function ci(t){let n=new Date(t.expires_at).getTime();if(Date.now()<n-im)return t.access_token;let i=await Fn(t.refresh_token,t.region??"global"),r={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:t.region,resource_url:i.resource_url??t.resource_url,account:t.account};return await Ft(r),r.access_token}var tm="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",yi=2,nm=500,em=1e4,im=300000;var fn=s(()=>{tt();ot();J();k()});async function gt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let n=await L();if(n)return{token:await ci(n),method:"oauth",source:"config.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new y("No credentials found.",x.AUTH,ft(t.configPath))}var gn=s(()=>{ot();fn();J();k();En()});function _i(t){if(!t)return"";if(t.includes("/t2a"))return`
111
111
 
112
112
  Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
113
113
 
@@ -115,153 +115,153 @@ image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t
115
115
 
116
116
  Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
117
117
 
118
- Music-2.6 requires the Max plan or above.`;return""}function wr(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Tt(t,n,r){let i=n.base_resp?.status_msg||n.error?.message||`HTTP ${t}`,$=n.base_resp?.status_code||n.error?.code;if(t===401||t===403)return new y(`API key rejected (HTTP ${t}).`,x.AUTH,`Check status: mmx auth status
119
- Re-authenticate: mmx auth login`);if(t===429)return new y(`Rate limit or quota exceeded. ${i}`,x.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new y(`Request timed out (HTTP ${t}).`,x.TIMEOUT,"Try increasing --timeout or retry later.");if($===1002||$===1039){let p=n.base_resp?.status_msg||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${p}).`,x.CONTENT_FILTER)}if($===1028||$===1030){let p=cr(r);return new y(`Quota exhausted. ${i}`,x.QUOTA,`Check usage: mmx quota show${p}
120
- Upgrade plan: ${wr(r)}`)}if($===2061){let p=cr(r);return new y(`This model is not available on your current Token Plan. ${i}`,x.QUOTA,`Check usage: mmx quota show${p}
121
- Upgrade plan: ${wr(r)}`)}return new y(`API error: ${i} (HTTP ${t})`,x.GENERAL)}var Dn=s(()=>{J();k()});import{homedir as vr}from"os";function um(t){return t.startsWith(vr())?t.replace(vr(),"~"):t}function xm(t){return t.replace(/^https?:\/\//,"")}function Mr(t,n,r){if(t.quiet||br||!process.stderr.isTTY)return;br=!0;let i=t.configPath?um(t.configPath):"~/.mmx/config.json",$=xm(t.baseUrl),p=t.apiKey?"(flag)":"(file)",e=E(n),m=r?` ${ut}|${a} ${ut}Model:${a} ${pm}${r}${a}`:"";process.stderr.write(`${im}${$m}MINIMAX${a} ${ut}${i}${a} ${ut}|${a} ${ut}URL:${a} ${mm}${$}${a} ${ut}|${a} ${ut}Key:${a} ${om}${e}${a} ${ut}${p}${a}${m}
122
- `)}var br=!1,a="\x1B[0m",ut="\x1B[2m",im="\x1B[1m",$m="\x1B[38;2;43;82;255m",pm="\x1B[38;2;147;51;234m",mm="\x1B[38;2;6;184;212m",om="\x1B[38;2;236;72;153m";var sr=()=>{};var Rr=()=>{};var Mt="1.0.17";var Dt=s(()=>{Rr()});async function D(t,n){let r=typeof FormData<"u"&&n.body instanceof FormData,i={"User-Agent":`mmx-cli/${Mt}`,...n.headers};if(!r&&!i["Content-Type"])i["Content-Type"]="application/json";if(!n.noAuth){let e=await gt(t);if(n.authStyle==="x-api-key")i["x-api-key"]=e.token;else i.Authorization=`Bearer ${e.token}`;if(t.verbose)process.stderr.write(`> ${n.method??"GET"} ${n.url}
118
+ Music-2.6 requires the Max plan or above.`;return""}function wi(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Tt(t,n,i){let r=n.base_resp?.status_msg||n.error?.message||`HTTP ${t}`,$=n.base_resp?.status_code||n.error?.code;if(t===401||t===403)return new y(`API key rejected (HTTP ${t}).`,x.AUTH,`Check status: mmx auth status
119
+ Re-authenticate: mmx auth login`);if(t===429)return new y(`Rate limit or quota exceeded. ${r}`,x.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new y(`Request timed out (HTTP ${t}).`,x.TIMEOUT,"Try increasing --timeout or retry later.");if($===1002||$===1039){let p=n.base_resp?.status_msg||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${p}).`,x.CONTENT_FILTER)}if($===1028||$===1030){let p=_i(i);return new y(`Quota exhausted. ${r}`,x.QUOTA,`Check usage: mmx quota show${p}
120
+ Upgrade plan: ${wi(i)}`)}if($===2061){let p=_i(i);return new y(`This model is not available on your current Token Plan. ${r}`,x.QUOTA,`Check usage: mmx quota show${p}
121
+ Upgrade plan: ${wi(i)}`)}return new y(`API error: ${r} (HTTP ${t})`,x.GENERAL)}var Dn=s(()=>{J();k()});import{homedir as vi}from"os";function um(t){return t.startsWith(vi())?t.replace(vi(),"~"):t}function xm(t){return t.replace(/^https?:\/\//,"")}function bi(t,n,i){if(t.quiet||Mi||!process.stderr.isTTY)return;Mi=!0;let r=t.configPath?um(t.configPath):"~/.mmx/config.json",$=xm(t.baseUrl),p=t.apiKey?"(flag)":"(file)",e=E(n),m=i?` ${ut}|${a} ${ut}Model:${a} ${pm}${i}${a}`:"";process.stderr.write(`${rm}${$m}MINIMAX${a} ${ut}${r}${a} ${ut}|${a} ${ut}URL:${a} ${mm}${$}${a} ${ut}|${a} ${ut}Key:${a} ${om}${e}${a} ${ut}${p}${a}${m}
122
+ `)}var Mi=!1,a="\x1B[0m",ut="\x1B[2m",rm="\x1B[1m",$m="\x1B[38;2;43;82;255m",pm="\x1B[38;2;147;51;234m",mm="\x1B[38;2;6;184;212m",om="\x1B[38;2;236;72;153m";var si=()=>{};var Ri=()=>{};var bt="1.0.18";var Dt=s(()=>{Ri()});async function D(t,n){let i=typeof FormData<"u"&&n.body instanceof FormData,r={"User-Agent":`mmx-cli/${bt}`,...n.headers};if(!i&&!r["Content-Type"])r["Content-Type"]="application/json";if(!n.noAuth){let e=await gt(t);if(n.authStyle==="x-api-key")r["x-api-key"]=e.token;else r.Authorization=`Bearer ${e.token}`;if(t.verbose)process.stderr.write(`> ${n.method??"GET"} ${n.url}
123
123
  `),process.stderr.write(`> Auth: ${e.token.slice(0,8)}...
124
- `);let m=n.body&&typeof n.body==="object"&&"model"in n.body?String(n.body.model):void 0;Mr(t,e.token,m)}let $=(n.timeout??t.timeout)*1000,p=await fetch(n.url,{method:n.method??"GET",headers:i,body:n.body?r?n.body:JSON.stringify(n.body):void 0,signal:n.stream?void 0:AbortSignal.timeout($)});if(t.verbose)process.stderr.write(`< ${p.status} ${p.statusText}
125
- `);if(!p.ok){let e={};try{e=await p.json()}catch{}throw Tt(p.status,e,n.url)}return p}async function B(t,n){let r=await D(t,n),i;try{i=await r.json()}catch{let $=r.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${$||"unknown type"}). Server may be experiencing issues.`,x.GENERAL)}if(i.base_resp?.status_code&&i.base_resp.status_code!==0)throw Tt(200,{base_resp:i.base_resp},n.url);return i}var K=s(()=>{J();k();gn();Dn();sr();Dt()});function tn(t){return`${t}/anthropic/v1/messages`}function Gr(t){return`${t}/v1/t2a_v2`}function Sr(t){return`${t}/v1/get_voice`}function Ar(t){return`${t}/v1/image_generation`}function qr(t){return`${t}/v1/video_generation`}function nn(t,n){return`${t}/v1/query/video_generation?task_id=${n}`}function en(t,n){return`${t}/v1/files/retrieve?file_id=${n}`}function rn(t){return`${t}/v1/music_generation`}function hr(t){return`${t}/v1/music_cover_preprocess`}function jr(t){return`${t}/v1/coding_plan/search`}function Br(t){return`${t}/v1/coding_plan/vlm`}function st(t){return`${t}/v1/token_plan/remains`}function kr(t){return`${t}/v1/files/upload`}function Jr(t){return`${t}/v1/files/list`}function Vr(t){return`${t}/v1/files/delete`}function Zr(t){if(t>=50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t>=20)return["\x1B[38;2;250;204;21m","\x1B[48;2;202;138;4m"];return["\x1B[38;2;248;113;113m","\x1B[48;2;220;38;38m"]}function wm(t,n){if(n!=="cn")return t;return cm[t]??t}function vm(t,n){if(t<=0)return n;let r=Math.floor(t/3600000),i=Math.floor(t%3600000/60000);return r>0?`${r}h ${i}m`:`${i}m`}function Xr(t){return new Date(t).toISOString().slice(0,10)}function bm(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function f(t){let n=t.replace(/\x1b\[[0-9;]*m/g,""),r=0;for(let i of n)r+=bm(i.codePointAt(0))?2:1;return r}function Rm(t){return t===3}function ne(t){return Math.max(0,Math.min(sm,Math.round(t)))}function Gm(t){if(t===void 0||t===null)return 1;return Math.max(0,t)/1000}function Sm(t,n,r,i){let $=Gm(i);if(t!==void 0&&t!==null)return ne(t*$);return r>0?ne(n/r*100*$):0}function Am(t,n,r=Mm,i=!0){let $=ne(t),p=Math.min(1,$/100),e=Math.round(r*p),m=r-e,u=`${$}%`.padStart(4);if(!n){let v=`[${"█".repeat(e)}${".".repeat(m)}]`;return i?`${v} ${u}`:v}let[_,c]=Zr($),w=`${c}${" ".repeat(e)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(m)}\x1B[0m`;return i?`${w} ${_}\x1B[1m${u}\x1B[0m`:w}function Ur(t,n,r,i,$,p,e,m){if(e){let w=(m??qm).padStart(4);if($){let b=`\x1B[48;2;22;163;74m${" ".repeat(te)}\x1B[0m`;return`\x1B[2m${t}\x1B[0m ${b} \x1B[38;2;74;222;128m\x1B[1m${w}\x1B[0m`}let v=`[${"█".repeat(te)}]`;return`${t} ${v} ${w}`}let u=Sm(i,n,r,p),_=Am(u,$,te,r<=0);if(r>0){let c=`${n.toLocaleString()} / ${r.toLocaleString()}`;return $?`\x1B[2m${t}\x1B[0m ${_} ${Zr(u)[0]}${c}\x1B[0m`:`${t} ${_} ${c}`}return`${t} ${_}`}function $n(t,n,r,i,$){return $?`\x1B[2m${n}${r.repeat(t)}${i}\x1B[0m`:`+${"-".repeat(t)}+`}function Qr(t,n,r,i){let $=Math.max(0,n-2-r);return i?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat($)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat($)} |`}function jt(t,n){let r=!n.noColor&&process.stdout.isTTY===!0,i=n.region==="cn"?_m:ym,$=t.map((M)=>{let h=wm(M.model_name,n.region),V=Ur(i.current,M.current_interval_usage_count,M.current_interval_total_count,M.current_interval_remaining_percent,r),X=Ur(i.weekly,M.current_weekly_usage_count,M.current_weekly_total_count,M.current_weekly_remaining_percent,r,M.weekly_boost_permille,Rm(M.current_weekly_status),n.region==="cn"?hm:jm),Q=`${i.resetsIn} ${vm(M.remains_time,i.now)}`;return{displayName:h,current:V,weekly:X,reset:Q}}),p=Math.max(6,...$.map((M)=>f(M.displayName))),e=Math.max(...$.map((M)=>f(M.current)),18),m=Math.max(...$.map((M)=>f(M.weekly)),18),u=Math.max(...$.map((M)=>f(M.reset)),10),_=Math.max(72,p+2+e+2+m+2+u+4),c=t.length>0?`${Xr(t[0].weekly_start_time)} — ${Xr(t[0].weekly_end_time)}`:"",w=`MINIMAX ${i.dashboard}`,v=`${i.week}: ${c}`,b=Math.max(2,_-2-f(w)-f(v)),G=r?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${i.dashboard}\x1B[0m${" ".repeat(b)}\x1B[2m${i.week}:\x1B[0m \x1B[38;2;6;184;212m${c}\x1B[0m`:`${w}${" ".repeat(b)}${v}`,q=f(w)+b+f(v);if(console.log(""),console.log($n(_,"╭","─","╮",r)),console.log(Qr(G,_,q,r)),t.length===0){console.log($n(_,"╰","─","╯",r)),console.log(`
126
- ${i.noData}
127
- `);return}for(let M of $){console.log($n(_,"├","─","┤",r));let V=`${r?`\x1B[1m${M.displayName}\x1B[0m`:M.displayName}${" ".repeat(Math.max(1,p-f(M.displayName)+2))}${M.current}${" ".repeat(Math.max(1,e-f(M.current)+2))}${M.weekly}${" ".repeat(Math.max(1,m-f(M.weekly)+2))}`+M.reset;console.log(Qr(V,_,f(V),r))}console.log($n(_,"╰","─","╯",r)),console.log("")}var ym,_m,cm,Mm=16,te=10,sm=200,qm="∞",hm="无限",jm="unlimited";var pn=s(()=>{ym={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now"},_m={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将"},cm={general:"通用",video:"视频"}});function km(t){return W[t]+Bm}async function Jm(t,n,r){let i=[{Authorization:`Bearer ${n}`},{"x-api-key":n}],$=!1,p=!1;for(let e of i){let m;try{m=await fetch(km(t),{headers:{...e,"Content-Type":"application/json"},signal:AbortSignal.timeout(r)})}catch{$=!0;continue}if(m.status===401||m.status===403)continue;if(!m.ok){p=!0;continue}try{if((await m.json()).base_resp?.status_code===0)return"authorized";p=!0}catch{p=!0}}if(p)return"inconclusive";if($)return"unreachable";return"unauthorized"}async function mn(t){process.stderr.write("Detecting region...");let n=Object.keys(W),r=await Promise.all(n.map(async(p)=>({region:p,result:await Jm(p,t,5000)}))),i=r.find((p)=>p.result==="authorized");if(!i){if(process.stderr.write(` failed
128
- `),r.every((p)=>p.result==="unauthorized"))throw new y("API key was rejected by all regions.",x.AUTH,"No credentials were changed. Check that the key is valid and belongs to a Token Plan.");if(r.some((p)=>p.result==="unreachable"))throw new y("Could not reach the regional API endpoints.",x.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.",x.GENERAL,"No region was changed because the API returned an inconclusive response. Retry later or pass --region global|cn explicitly.")}let $=i.region;return process.stderr.write(` ${$}
129
- `),$}async function Tr(t){let n=z();n.region=t,await P(n)}var Bm="/v1/token_plan/remains";var ee=s(()=>{tt();rt();J();k()});function Vm(t){if(t instanceof y)return t.exitCode===x.NETWORK||t.exitCode===x.TIMEOUT;if(!(t instanceof Error))return!1;if(t.name==="AbortError"||t.name==="TimeoutError")return!0;let n=t.message.toLowerCase(),r="code"in t?String(t.code).toLowerCase():"";return t instanceof TypeError&&n==="fetch failed"||n.includes("failed to fetch")||n.includes("unable to connect")||n.includes("connection refused")||n.includes("econnrefused")||n.includes("connection reset")||n.includes("econnreset")||n.includes("network error")||n.includes("enotfound")||n.includes("getaddrinfo")||n.includes("proxy")||n.includes("socket")||n.includes("etimedout")||r==="connectionrefused"||r==="econnrefused"||r==="econnreset"||r==="enotfound"||r==="etimedout"}async function Xm(t){try{let n=st(t.baseUrl),r=await B(t,{url:n});jt(r.model_remains||[],t)}catch{}}async function Nr(t){let{registry:n}=await Promise.resolve().then(() => (on(),Hr));n.printHelp([],process.stderr,t.region),await Xm(t)}async function Yr(t,n){await Cn(n);let r=z(),i={...t,region:n,baseUrl:r.oauth?.resource_url||W[n]};await Nr(i)}async function zr(t,n,r){if(t.dryRun){console.log("Would validate and save API key.");return}let i=r??await mn(n),$={...t,region:i,baseUrl:W[i],apiKey:n};try{await B($,{url:st($.baseUrl)})}catch(e){if(e instanceof y&&e.exitCode===x.AUTH)throw new y("API key validation failed.",x.AUTH,"Check that your key is valid and belongs to a Token Plan.");if(!r)throw e;let m=Vm(e)?`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 ${m}.
130
- Saving the explicitly selected region "${i}". Requests may fail until validation succeeds.
131
- `)}let p=z();delete p.oauth,p.api_key=n,p.region=i,await P(p),process.stderr.write(`API key saved to ${nt()}
132
- `),await Nr($)}var Or;var Wr=s(()=>{Z();J();k();an();K();pn();ee();At();rt();tt();Or=S({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(t,n){let r=process.env.MINIMAX_API_KEY;if(r&&!n.apiKey){let p=E(r);if(H({nonInteractive:t.nonInteractive})){let{confirm:e,isCancel:m}=await Promise.resolve().then(() => (vt(),wt)),u=await e({message:`MINIMAX_API_KEY is set (${p}). Configure persistent credentials anyway?`,initialValue:!1});if(m(u)||!u)process.stdout.write(`Login skipped. Using environment variable.
124
+ `);let m=n.body&&typeof n.body==="object"&&"model"in n.body?String(n.body.model):void 0;bi(t,e.token,m)}let $=(n.timeout??t.timeout)*1000,p=await fetch(n.url,{method:n.method??"GET",headers:r,body:n.body?i?n.body:JSON.stringify(n.body):void 0,signal:n.stream?void 0:AbortSignal.timeout($)});if(t.verbose)process.stderr.write(`< ${p.status} ${p.statusText}
125
+ `);if(!p.ok){let e={};try{e=await p.json()}catch{}throw Tt(p.status,e,n.url)}return p}async function B(t,n){let i=await D(t,n),r;try{r=await i.json()}catch{let $=i.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${$||"unknown type"}). Server may be experiencing issues.`,x.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw Tt(200,{base_resp:r.base_resp},n.url);return r}var K=s(()=>{J();k();gn();Dn();si();Dt()});function tn(t){return`${t}/anthropic/v1/messages`}function Gi(t){return`${t}/v1/t2a_v2`}function Si(t){return`${t}/v1/get_voice`}function Ai(t){return`${t}/v1/image_generation`}function hi(t){return`${t}/v1/video_generation`}function nn(t,n){return`${t}/v1/query/video_generation?task_id=${n}`}function en(t,n){return`${t}/v1/files/retrieve?file_id=${n}`}function rn(t){return`${t}/v1/music_generation`}function qi(t){return`${t}/v1/music_cover_preprocess`}function ji(t){return`${t}/v1/coding_plan/search`}function Bi(t){return`${t}/v1/coding_plan/vlm`}function st(t){return`${t}/v1/token_plan/remains`}function ki(t){return`${t}/v1/files/upload`}function Ji(t){return`${t}/v1/files/list`}function Vi(t){return`${t}/v1/files/delete`}function Zi(t){if(t>=50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t>=20)return["\x1B[38;2;250;204;21m","\x1B[48;2;202;138;4m"];return["\x1B[38;2;248;113;113m","\x1B[48;2;220;38;38m"]}function wm(t,n){if(n!=="cn")return t;return _m[t]??t}function vm(t,n){if(t<=0)return n;let i=Math.floor(t/3600000),r=Math.floor(t%3600000/60000);return i>0?`${i}h ${r}m`:`${r}m`}function Xi(t){return new Date(t).toISOString().slice(0,10)}function Mm(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function F(t){let n=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of n)i+=Mm(r.codePointAt(0))?2:1;return i}function Rm(t){return t===3}function ne(t){return Math.max(0,Math.min(sm,Math.round(t)))}function Gm(t){if(t===void 0||t===null)return 1;return Math.max(0,t)/1000}function Sm(t,n,i,r){let $=Gm(r);if(t!==void 0&&t!==null)return ne(t*$);return i>0?ne(n/i*100*$):0}function Am(t,n,i=bm,r=!0){let $=ne(t),p=Math.min(1,$/100),e=Math.round(i*p),m=i-e,u=`${$}%`.padStart(4);if(!n){let v=`[${"█".repeat(e)}${".".repeat(m)}]`;return r?`${v} ${u}`:v}let[c,_]=Zi($),w=`${_}${" ".repeat(e)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(m)}\x1B[0m`;return r?`${w} ${c}\x1B[1m${u}\x1B[0m`:w}function Ui(t,n,i,r,$,p,e,m){if(e){let w=(m??hm).padStart(4);if($){let M=`\x1B[48;2;22;163;74m${" ".repeat(te)}\x1B[0m`;return`\x1B[2m${t}\x1B[0m ${M} \x1B[38;2;74;222;128m\x1B[1m${w}\x1B[0m`}let v=`[${"█".repeat(te)}]`;return`${t} ${v} ${w}`}let u=Sm(r,n,i,p),c=Am(u,$,te,i<=0);if(i>0){let _=`${n.toLocaleString()} / ${i.toLocaleString()}`;return $?`\x1B[2m${t}\x1B[0m ${c} ${Zi(u)[0]}${_}\x1B[0m`:`${t} ${c} ${_}`}return`${t} ${c}`}function $n(t,n,i,r,$){return $?`\x1B[2m${n}${i.repeat(t)}${r}\x1B[0m`:`+${"-".repeat(t)}+`}function Qi(t,n,i,r){let $=Math.max(0,n-2-i);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat($)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat($)} |`}function jt(t,n){let i=!n.noColor&&process.stdout.isTTY===!0,r=n.region==="cn"?cm:ym,$=t.map((b)=>{let q=wm(b.model_name,n.region),V=Ui(r.current,b.current_interval_usage_count,b.current_interval_total_count,b.current_interval_remaining_percent,i),X=Ui(r.weekly,b.current_weekly_usage_count,b.current_weekly_total_count,b.current_weekly_remaining_percent,i,b.weekly_boost_permille,Rm(b.current_weekly_status),n.region==="cn"?qm:jm),Q=`${r.resetsIn} ${vm(b.remains_time,r.now)}`;return{displayName:q,current:V,weekly:X,reset:Q}}),p=Math.max(6,...$.map((b)=>F(b.displayName))),e=Math.max(...$.map((b)=>F(b.current)),18),m=Math.max(...$.map((b)=>F(b.weekly)),18),u=Math.max(...$.map((b)=>F(b.reset)),10),c=Math.max(72,p+2+e+2+m+2+u+4),_=t.length>0?`${Xi(t[0].weekly_start_time)} — ${Xi(t[0].weekly_end_time)}`:"",w=`MINIMAX ${r.dashboard}`,v=`${r.week}: ${_}`,M=Math.max(2,c-2-F(w)-F(v)),G=i?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat(M)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${_}\x1B[0m`:`${w}${" ".repeat(M)}${v}`,h=F(w)+M+F(v);if(console.log(""),console.log($n(c,"╭","─","╮",i)),console.log(Qi(G,c,h,i)),t.length===0){console.log($n(c,"╰","─","╯",i)),console.log(`
126
+ ${r.noData}
127
+ `);return}for(let b of $){console.log($n(c,"├","─","┤",i));let V=`${i?`\x1B[1m${b.displayName}\x1B[0m`:b.displayName}${" ".repeat(Math.max(1,p-F(b.displayName)+2))}${b.current}${" ".repeat(Math.max(1,e-F(b.current)+2))}${b.weekly}${" ".repeat(Math.max(1,m-F(b.weekly)+2))}`+b.reset;console.log(Qi(V,c,F(V),i))}console.log($n(c,"╰","─","╯",i)),console.log("")}var ym,cm,_m,bm=16,te=10,sm=200,hm="∞",qm="无限",jm="unlimited";var pn=s(()=>{ym={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now"},cm={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将"},_m={general:"通用",video:"视频"}});function km(t){return W[t]+Bm}async function Jm(t,n,i){let r=[{Authorization:`Bearer ${n}`},{"x-api-key":n}],$=!1,p=!1;for(let e of r){let m;try{m=await fetch(km(t),{headers:{...e,"Content-Type":"application/json"},signal:AbortSignal.timeout(i)})}catch{$=!0;continue}if(m.status===401||m.status===403)continue;if(!m.ok){p=!0;continue}try{if((await m.json()).base_resp?.status_code===0)return"authorized";p=!0}catch{p=!0}}if(p)return"inconclusive";if($)return"unreachable";return"unauthorized"}async function mn(t){process.stderr.write("Detecting region...");let n=Object.keys(W),i=await Promise.all(n.map(async(p)=>({region:p,result:await Jm(p,t,5000)}))),r=i.find((p)=>p.result==="authorized");if(!r){if(process.stderr.write(` failed
128
+ `),i.every((p)=>p.result==="unauthorized"))throw new y("API key was rejected by all regions.",x.AUTH,"No credentials were changed. Check that the key is valid and belongs to a Token Plan.");if(i.some((p)=>p.result==="unreachable"))throw new y("Could not reach the regional API endpoints.",x.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.",x.GENERAL,"No region was changed because the API returned an inconclusive response. Retry later or pass --region global|cn explicitly.")}let $=r.region;return process.stderr.write(` ${$}
129
+ `),$}async function Ti(t){let n=z();n.region=t,await P(n)}var Bm="/v1/token_plan/remains";var ee=s(()=>{tt();it();J();k()});function Vm(t){if(t instanceof y)return t.exitCode===x.NETWORK||t.exitCode===x.TIMEOUT;if(!(t instanceof Error))return!1;if(t.name==="AbortError"||t.name==="TimeoutError")return!0;let n=t.message.toLowerCase(),i="code"in t?String(t.code).toLowerCase():"";return t instanceof TypeError&&n==="fetch failed"||n.includes("failed to fetch")||n.includes("unable to connect")||n.includes("connection refused")||n.includes("econnrefused")||n.includes("connection reset")||n.includes("econnreset")||n.includes("network error")||n.includes("enotfound")||n.includes("getaddrinfo")||n.includes("proxy")||n.includes("socket")||n.includes("etimedout")||i==="connectionrefused"||i==="econnrefused"||i==="econnreset"||i==="enotfound"||i==="etimedout"}async function Xm(t){try{let n=st(t.baseUrl),i=await B(t,{url:n});jt(i.model_remains||[],t)}catch{}}async function Ni(t){let{registry:n}=await Promise.resolve().then(() => (on(),Hi));n.printHelp([],process.stderr,t.region),await Xm(t)}async function Yi(t,n){await Cn(n);let i=z(),r={...t,region:n,baseUrl:i.oauth?.resource_url||W[n]};await Ni(r)}async function zi(t,n,i){if(t.dryRun){console.log("Would validate and save API key.");return}let r=i??await mn(n),$={...t,region:r,baseUrl:W[r],apiKey:n};try{await B($,{url:st($.baseUrl)})}catch(e){if(e instanceof y&&e.exitCode===x.AUTH)throw new y("API key validation failed.",x.AUTH,"Check that your key is valid and belongs to a Token Plan.");if(!i)throw e;let m=Vm(e)?`the ${r} API endpoint is unreachable`:`the ${r} API endpoint returned an inconclusive response`;process.stderr.write(`Warning: Could not validate the API key because ${m}.
130
+ Saving the explicitly selected region "${r}". Requests may fail until validation succeeds.
131
+ `)}let p=z();delete p.oauth,p.api_key=n,p.region=r,await P(p),process.stderr.write(`API key saved to ${nt()}
132
+ `),await Ni($)}var Oi;var Wi=s(()=>{Z();J();k();an();K();pn();ee();At();it();tt();Oi=S({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(t,n){let i=process.env.MINIMAX_API_KEY;if(i&&!n.apiKey){let p=E(i);if(H({nonInteractive:t.nonInteractive})){let{confirm:e,isCancel:m}=await Promise.resolve().then(() => (vt(),wt)),u=await e({message:`MINIMAX_API_KEY is set (${p}). Configure persistent credentials anyway?`,initialValue:!1});if(m(u)||!u)process.stdout.write(`Login skipped. Using environment variable.
133
133
  `),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
134
- `)}if(n.apiKey){await zr(t,n.apiKey,n.region);return}if(t.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!H({nonInteractive:t.nonInteractive}))throw new y("--api-key is required in non-interactive mode.",x.USAGE,"mmx auth login --api-key sk-xxxxx");if(n.recommend){let p=n.region||await xr();await Yr(t,p);return}let i=await Ln();if(i==="api-key"){let{text:p,isCancel:e}=await Promise.resolve().then(() => (vt(),wt)),m=await p({message:"Paste your MiniMax API key:",validate:(u)=>u&&u.length>0?void 0:"API key cannot be empty."});if(e(m))throw new y("Authentication cancelled.",x.AUTH);await zr(t,m,n.region);return}let $=n.region||(i==="oauth-cn"?"cn":"global");await Yr(t,$)}})});var Kr;var Ir=s(()=>{Z();gn();ot();Y();K();pn();Kr=S({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(t,n){try{let r=await gt(t),i=j(t.output);if(i!=="text"){let p={method:r.method,source:r.source};if(r.method==="oauth"){let e=await L();if(e){if(p.token_expires=e.expires_at,e.account)p.account=e.account}}else p.key=E(r.token);console.log(A(p,i));return}console.log("Authentication Status:"),console.log(` Method: ${r.method}`),console.log(` Source: ${r.source}`);let $=r.token;if(console.log(` Key: ${E($)}`),r.method==="oauth"){let p=await L();if(p){if(p.account)console.log(` Account: ${p.account}`);let e=new Date(p.expires_at),m=Math.round((e.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
135
- `);try{let p=st(t.baseUrl),e=await B(t,{url:p,method:"GET"});jt(e.model_remains||[],t)}catch(p){console.log(` Quota fetch failed: ${p.message}`)}}catch{let r=j(t.output);console.log(A({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
136
- Or set $MINIMAX_API_KEY`},r))}}})});var Pr;var dr=s(()=>{Z();J();k();ot();Fn();Y();Pr=S({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,n){let r=await L();if(!r)throw new y("Not applicable: not authenticated via OAuth.",x.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let i=await fn(r.refresh_token,r.region??"global"),$={access_token:i.access_token,refresh_token:i.refresh_token,expires_at:i.expires_at,region:r.region,resource_url:i.resource_url??r.resource_url,account:r.account};await ft($);let p=j(t.output);if(t.quiet){console.log($.expires_at);return}console.log(A({status:"Token refreshed",expires:$.expires_at},p))}})});var lr;var Er=s(()=>{Z();ot();rt();lr=S({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(t,n){let r=await L(),$=!!z().api_key;if(t.dryRun){if(r)console.log("Would clear oauth from ~/.mmx/config.json");if($)console.log("Would clear api_key from ~/.mmx/config.json");if(!r&&!$)console.log("No credentials to clear.");console.log("No changes made.");return}if(!r&&!$){process.stderr.write(`No credentials to clear.
137
- `);return}if(r)await mr(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
134
+ `)}if(n.apiKey){await zi(t,n.apiKey,n.region);return}if(t.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!H({nonInteractive:t.nonInteractive}))throw new y("--api-key is required in non-interactive mode.",x.USAGE,"mmx auth login --api-key sk-xxxxx");if(n.recommend){let p=n.region||await xi();await Yi(t,p);return}let r=await Ln();if(r==="api-key"){let{text:p,isCancel:e}=await Promise.resolve().then(() => (vt(),wt)),m=await p({message:"Paste your MiniMax API key:",validate:(u)=>u&&u.length>0?void 0:"API key cannot be empty."});if(e(m))throw new y("Authentication cancelled.",x.AUTH);await zi(t,m,n.region);return}let $=n.region||(r==="oauth-cn"?"cn":"global");await Yi(t,$)}})});var Ki;var Ii=s(()=>{Z();gn();ot();Y();K();pn();Ki=S({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(t,n){try{let i=await gt(t),r=j(t.output);if(r!=="text"){let p={method:i.method,source:i.source};if(i.method==="oauth"){let e=await L();if(e){if(p.token_expires=e.expires_at,e.account)p.account=e.account}}else p.key=E(i.token);console.log(A(p,r));return}console.log("Authentication Status:"),console.log(` Method: ${i.method}`),console.log(` Source: ${i.source}`);let $=i.token;if(console.log(` Key: ${E($)}`),i.method==="oauth"){let p=await L();if(p){if(p.account)console.log(` Account: ${p.account}`);let e=new Date(p.expires_at),m=Math.round((e.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
135
+ `);try{let p=st(t.baseUrl),e=await B(t,{url:p,method:"GET"});jt(e.model_remains||[],t)}catch(p){console.log(` Quota fetch failed: ${p.message}`)}}catch{let i=j(t.output);console.log(A({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
136
+ Or set $MINIMAX_API_KEY`},i))}}})});var Pi;var di=s(()=>{Z();J();k();ot();fn();Y();Pi=S({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,n){let i=await L();if(!i)throw new y("Not applicable: not authenticated via OAuth.",x.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let r=await Fn(i.refresh_token,i.region??"global"),$={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:r.expires_at,region:i.region,resource_url:r.resource_url??i.resource_url,account:i.account};await Ft($);let p=j(t.output);if(t.quiet){console.log($.expires_at);return}console.log(A({status:"Token refreshed",expires:$.expires_at},p))}})});var li;var Ei=s(()=>{Z();ot();it();li=S({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(t,n){let i=await L(),$=!!z().api_key;if(t.dryRun){if(i)console.log("Would clear oauth from ~/.mmx/config.json");if($)console.log("Would clear api_key from ~/.mmx/config.json");if(!i&&!$)console.log("No credentials to clear.");console.log("No changes made.");return}if(!i&&!$){process.stderr.write(`No credentials to clear.
137
+ `);return}if(i)await mi(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
138
138
  `);if($){let p=z();delete p.api_key,await P(p),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
139
- `)}}})});async function*Bt(t){let n=t.body?.getReader();if(!n)return;let r=new TextDecoder,i="",$={},p=(e)=>{let m=e.endsWith("\r")?e.slice(0,-1):e;if(m===""){let w=$.data!==void 0?{data:$.data,event:$.event,id:$.id}:void 0;return $={},w}if(m.startsWith(":"))return;let u=m.indexOf(":");if(u===-1)return;let _=m.slice(0,u),c=m.slice(u+1).trimStart();switch(_){case"data":$.data=$.data!==void 0?`${$.data}
140
- ${c}`:c;break;case"event":$.event=c;break;case"id":$.id=c;break}return};try{while(!0){let{done:e,value:m}=await n.read();if(e)break;i+=r.decode(m,{stream:!0});let u=i.split(`
141
- `);i=u.pop()||"";for(let _ of u){let c=p(_);if(c)yield c}}if(i+=r.decode(),i.length>0){let e=p(i);if(e)yield e}if($.data!==void 0)yield{data:$.data,event:$.event,id:$.id}}finally{n.releaseLock()}}import{readFileSync as re}from"fs";function Cr(t,n,r){let i=(1-Math.abs(2*r-1))*n,$=i*(1-Math.abs(t/60%2-1)),p=r-i/2,e=0,m=0,u=0;if(t<60)e=i,m=$;else if(t<120)e=$,m=i;else if(t<180)m=i,u=$;else if(t<240)m=$,u=i;else if(t<300)e=$,u=i;else e=i,u=$;return[Math.round((e+p)*255),Math.round((m+p)*255),Math.round((u+p)*255)]}class ar{frame=0;startTime=0;timer=null;out;noColor;constructor(t,n){this.out=t,this.noColor=n}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 t=Lr[this.frame%Lr.length],n=Math.floor((Date.now()-this.startTime)/1000),r=n>=60?`Thinking (${Math.floor(n/60)}m ${n%60}s)`:`Thinking (${n}s)`;if(this.frame++,this.noColor)this.out.write(`\r${t} ${r}\x1B[0K`);else{let[i,$,p]=Cr(this.frame*17%360,0.85,0.55),[e,m,u]=Cr((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${i};${$};${p}m${t}\x1B[0m \x1B[38;2;${e};${m};${u}m${r}\x1B[0m\x1B[0K`)}}}function Um(t){let n=[],r;if(t.system)r=t.system;if(t.messagesFile){let i=t.messagesFile,$=i==="-"?re("/dev/stdin","utf-8"):re(i,"utf-8"),p=JSON.parse($);for(let e of p)if(e.role==="system")r=typeof e.content==="string"?e.content:"";else n.push(e)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let i=new Set(["system","user","assistant"]),$=t.message;for(let p of $){let e=p.indexOf(":"),m=e!==-1?p.slice(0,e):"";if(i.has(m)){let u=p.slice(e+1);if(m==="system")r=u;else n.push({role:m,content:u})}else n.push({role:"user",content:p})}}return{system:r,messages:n}}function Qm(t){return t.filter((n)=>n.type==="text").map((n)=>n.text).join("")}var Lr,fr;var Fr=s(()=>{Z();K();Y();J();k();mt();Lr=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];fr=S({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: MiniMax-M2.7)"},{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 MiniMax-M2.7-highspeed --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(t,n){let{system:r,messages:i}=Um(n),$=i;if($.length===0)if(H({nonInteractive:t.nonInteractive})){let c=await g({message:"Enter your message:"});if(!c)process.stderr.write(`Chat cancelled.
142
- `),process.exit(1);$=[{role:"user",content:c}]}else bt("message","mmx text chat --message <text>");let p=n.model||t.defaultTextModel||"MiniMax-M2.7",e=j(t.output),m=n.stream===!0||n.stream===void 0&&e!=="json"&&process.stdout.isTTY,u={model:p,messages:$,max_tokens:n.maxTokens??4096,stream:m};if(r)u.system=r;if(n.temperature!==void 0)u.temperature=n.temperature;if(n.topP!==void 0)u.top_p=n.topP;if(n.tool){let c=n.tool.map((w)=>{try{return JSON.parse(w)}catch{try{let v=re(w,"utf-8");return JSON.parse(v)}catch{throw new y(`Invalid tool definition: "${w}" is neither valid JSON nor a readable file.`,x.USAGE)}}});u.tools=c}if(t.dryRun){console.log(A({request:u},e));return}let _=tn(t.baseUrl);if(m){let c=await D(t,{url:_,method:"POST",body:u,stream:!0,authStyle:"x-api-key"}),w=c.headers.get("content-type")||"";if(!w.includes("text/event-stream")&&!w.includes("stream"))throw new y(`Expected SSE stream but got content-type "${w}". Server may be experiencing issues.`,x.GENERAL);let v="",b=!1,G=t.noColor?"":"\x1B[2m",q=t.noColor?"":"\x1B[0m",M=e==="json",V=process.stdout.isTTY&&!M?process.stderr:process.stderr,X=M?void 0:process.stdout,Q=new ar(V,t.noColor);for await(let N of Bt(c)){if(N.data==="[DONE]")break;try{let U=JSON.parse(N.data);if(U.type==="content_block_start"){if(U.content_block.type==="thinking")b=!0,Q.start();else if(U.content_block.type==="text"&&b)Q.stop(),b=!1,V.write(`${q}
139
+ `)}}})});async function*Bt(t){let n=t.body?.getReader();if(!n)return;let i=new TextDecoder,r="",$={},p=(e)=>{let m=e.endsWith("\r")?e.slice(0,-1):e;if(m===""){let w=$.data!==void 0?{data:$.data,event:$.event,id:$.id}:void 0;return $={},w}if(m.startsWith(":"))return;let u=m.indexOf(":");if(u===-1)return;let c=m.slice(0,u),_=m.slice(u+1).trimStart();switch(c){case"data":$.data=$.data!==void 0?`${$.data}
140
+ ${_}`:_;break;case"event":$.event=_;break;case"id":$.id=_;break}return};try{while(!0){let{done:e,value:m}=await n.read();if(e)break;r+=i.decode(m,{stream:!0});let u=r.split(`
141
+ `);r=u.pop()||"";for(let c of u){let _=p(c);if(_)yield _}}if(r+=i.decode(),r.length>0){let e=p(r);if(e)yield e}if($.data!==void 0)yield{data:$.data,event:$.event,id:$.id}}finally{n.releaseLock()}}import{readFileSync as ie}from"fs";function Ci(t,n,i){let r=(1-Math.abs(2*i-1))*n,$=r*(1-Math.abs(t/60%2-1)),p=i-r/2,e=0,m=0,u=0;if(t<60)e=r,m=$;else if(t<120)e=$,m=r;else if(t<180)m=r,u=$;else if(t<240)m=$,u=r;else if(t<300)e=$,u=r;else e=r,u=$;return[Math.round((e+p)*255),Math.round((m+p)*255),Math.round((u+p)*255)]}class ai{frame=0;startTime=0;timer=null;out;noColor;constructor(t,n){this.out=t,this.noColor=n}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 t=Li[this.frame%Li.length],n=Math.floor((Date.now()-this.startTime)/1000),i=n>=60?`Thinking (${Math.floor(n/60)}m ${n%60}s)`:`Thinking (${n}s)`;if(this.frame++,this.noColor)this.out.write(`\r${t} ${i}\x1B[0K`);else{let[r,$,p]=Ci(this.frame*17%360,0.85,0.55),[e,m,u]=Ci((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${r};${$};${p}m${t}\x1B[0m \x1B[38;2;${e};${m};${u}m${i}\x1B[0m\x1B[0K`)}}}function Um(t){let n=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,$=r==="-"?ie("/dev/stdin","utf-8"):ie(r,"utf-8"),p=JSON.parse($);for(let e of p)if(e.role==="system")i=typeof e.content==="string"?e.content:"";else n.push(e)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let r=new Set(["system","user","assistant"]),$=t.message;for(let p of $){let e=p.indexOf(":"),m=e!==-1?p.slice(0,e):"";if(r.has(m)){let u=p.slice(e+1);if(m==="system")i=u;else n.push({role:m,content:u})}else n.push({role:"user",content:p})}}return{system:i,messages:n}}function Qm(t){return t.filter((n)=>n.type==="text").map((n)=>n.text).join("")}var Li,Fi;var fi=s(()=>{Z();K();Y();J();k();mt();Li=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];Fi=S({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: MiniMax-M3)"},{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 MiniMax-M3 --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(t,n){let{system:i,messages:r}=Um(n),$=r;if($.length===0)if(H({nonInteractive:t.nonInteractive})){let _=await g({message:"Enter your message:"});if(!_)process.stderr.write(`Chat cancelled.
142
+ `),process.exit(1);$=[{role:"user",content:_}]}else Mt("message","mmx text chat --message <text>");let p=n.model||t.defaultTextModel||"MiniMax-M3",e=j(t.output),m=n.stream===!0||n.stream===void 0&&e!=="json"&&process.stdout.isTTY,u={model:p,messages:$,max_tokens:n.maxTokens??4096,stream:m};if(i)u.system=i;if(n.temperature!==void 0)u.temperature=n.temperature;if(n.topP!==void 0)u.top_p=n.topP;if(n.tool){let _=n.tool.map((w)=>{try{return JSON.parse(w)}catch{try{let v=ie(w,"utf-8");return JSON.parse(v)}catch{throw new y(`Invalid tool definition: "${w}" is neither valid JSON nor a readable file.`,x.USAGE)}}});u.tools=_}if(t.dryRun){console.log(A({request:u},e));return}let c=tn(t.baseUrl);if(m){let _=await D(t,{url:c,method:"POST",body:u,stream:!0,authStyle:"x-api-key"}),w=_.headers.get("content-type")||"";if(!w.includes("text/event-stream")&&!w.includes("stream"))throw new y(`Expected SSE stream but got content-type "${w}". Server may be experiencing issues.`,x.GENERAL);let v="",M=!1,G=t.noColor?"":"\x1B[2m",h=t.noColor?"":"\x1B[0m",b=e==="json",V=process.stdout.isTTY&&!b?process.stderr:process.stderr,X=b?void 0:process.stdout,Q=new ai(V,t.noColor);for await(let N of Bt(_)){if(N.data==="[DONE]")break;try{let U=JSON.parse(N.data);if(U.type==="content_block_start"){if(U.content_block.type==="thinking")M=!0,Q.start();else if(U.content_block.type==="text"&&M)Q.stop(),M=!1,V.write(`${h}
143
143
  Response:
144
144
  `)}else if(U.type==="content_block_delta"){if(U.delta.type==="text_delta")v+=U.delta.text,X?.write(U.delta.text)}}catch(U){process.stderr.write(`
145
- ${G}[warning] Failed to parse stream chunk: ${U instanceof Error?U.message:String(U)}${q}
146
- `)}}if(b)Q.stop();if(e==="json")console.log(A({content:v},e));else X?.write(`
147
- `)}else{let c=await B(t,{url:_,method:"POST",body:u,authStyle:"x-api-key"}),w=Qm(c.content);if(t.quiet||e==="text")console.log(w);else console.log(A(c,e))}}})});import{writeFileSync as Zm}from"node:fs";function gr(t){return`\x1B[${t}A`}function Tm(t){return`\x1B[${t}B`}function ie(t){return`\x1B[${t}G`}function un(){return"\x1B[2K"}function Ym(){return"\x1B[0J"}function Om(){process.stdout.write(`
145
+ ${G}[warning] Failed to parse stream chunk: ${U instanceof Error?U.message:String(U)}${h}
146
+ `)}}if(M)Q.stop();if(e==="json")console.log(A({content:v},e));else X?.write(`
147
+ `)}else{let _=await B(t,{url:c,method:"POST",body:u,authStyle:"x-api-key"}),w=Qm(_.content);if(t.quiet||e==="text")console.log(w);else console.log(A(_,e))}}})});import{writeFileSync as Zm}from"node:fs";function gi(t){return`\x1B[${t}A`}function Tm(t){return`\x1B[${t}B`}function re(t){return`\x1B[${t}G`}function un(){return"\x1B[2K"}function Ym(){return"\x1B[0J"}function Om(){process.stdout.write(`
148
148
  Available commands:
149
- `);for(let[t,n]of Object.entries(pe))process.stdout.write(` ${t.padEnd(Dr+2)} ${n}
149
+ `);for(let[t,n]of Object.entries(pe))process.stdout.write(` ${t.padEnd(Di+2)} ${n}
150
150
  `);process.stdout.write(`
151
- `)}class ti{buffer="";cursor=0;history=[];historyIdx=-1;out;promptLen;dim;reset;width;lastTotal=0;resolve=null;constructor(t,n,r,i){this.out=t,this.promptLen=n.length,this.dim=r,this.reset=i,this.width=t.columns||80}readLine(){return new Promise((t)=>{this.buffer="",this.cursor=0,this.lastTotal=0,this.resolve=t,this.render()})}feed(t){let n=t.toString(),r=0;while(r<n.length){let i=n[r];if(i==="\x1B"&&r+1<n.length&&n[r+1]==="["){let $=n.slice(r,r+3);if($==="\x1B[A"){this.historyUp(),r+=3;continue}if($==="\x1B[B"){this.historyDown(),r+=3;continue}if($==="\x1B[C"){if(this.cursor<this.buffer.length)this.cursor++;this.render(),r+=3;continue}if($==="\x1B[D"){if(this.cursor>0)this.cursor--;this.render(),r+=3;continue}if($==="\x1B[H"){this.cursor=0,this.render(),r+=3;continue}if($==="\x1B[F"){this.cursor=this.buffer.length,this.render(),r+=3;continue}if(r+3<n.length&&n.slice(r,r+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(),r+=4;continue}r+=1;continue}if(i==="\r"||i===`
151
+ `)}class tr{buffer="";cursor=0;history=[];historyIdx=-1;out;promptLen;dim;reset;width;lastTotal=0;resolve=null;constructor(t,n,i,r){this.out=t,this.promptLen=n.length,this.dim=i,this.reset=r,this.width=t.columns||80}readLine(){return new Promise((t)=>{this.buffer="",this.cursor=0,this.lastTotal=0,this.resolve=t,this.render()})}feed(t){let n=t.toString(),i=0;while(i<n.length){let r=n[i];if(r==="\x1B"&&i+1<n.length&&n[i+1]==="["){let $=n.slice(i,i+3);if($==="\x1B[A"){this.historyUp(),i+=3;continue}if($==="\x1B[B"){this.historyDown(),i+=3;continue}if($==="\x1B[C"){if(this.cursor<this.buffer.length)this.cursor++;this.render(),i+=3;continue}if($==="\x1B[D"){if(this.cursor>0)this.cursor--;this.render(),i+=3;continue}if($==="\x1B[H"){this.cursor=0,this.render(),i+=3;continue}if($==="\x1B[F"){this.cursor=this.buffer.length,this.render(),i+=3;continue}if(i+3<n.length&&n.slice(i,i+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(),i+=4;continue}i+=1;continue}if(r==="\r"||r===`
152
152
  `){let $=this.buffer;if($.trim())this.history.push($),this.historyIdx=-1;let p=this.lastTotal>0?this.lastTotal-1:0;this.out.write(Tm(p)+`
153
- `),this.lastTotal=0;let e=this.resolve;if(this.resolve=null,e)e($);r++;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(),r++;continue}if(i==="\x01"){this.cursor=0,this.render(),r++;continue}if(i==="\x05"){this.cursor=this.buffer.length,this.render(),r++;continue}if(i==="\x15"){this.buffer="",this.cursor=0,this.render(),r++;continue}if(i==="\x17"){let $=this.buffer.slice(0,this.cursor),p=this.buffer.slice(this.cursor),e=$.replace(/\S+\s*$/,"");this.cursor=e.length,this.buffer=e+p,this.render(),r++;continue}if(i==="\t"){if(this.buffer.startsWith("/")){let $=$e.filter((p)=>p.startsWith(this.buffer));if($.length===1)this.buffer=$[0],this.cursor=this.buffer.length,this.render()}r++;continue}if(i.charCodeAt(0)>=32){this.buffer=this.buffer.slice(0,this.cursor)+i+this.buffer.slice(this.cursor),this.cursor++,this.render(),r++;continue}r++}}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 t=this.buffer.startsWith("/")?$e.filter((e)=>e.startsWith(this.buffer)):[],n=t.length===1&&t[0]===this.buffer,r=t.length>0&&!n,i=r?t.length:0,$=3+i,p="";if(this.lastTotal>0)p+=gr(1);if(p+=ie(1)+un()+this.border()+`
153
+ `),this.lastTotal=0;let e=this.resolve;if(this.resolve=null,e)e($);i++;continue}if(r===""||r==="\b"){if(this.cursor>0)this.buffer=this.buffer.slice(0,this.cursor-1)+this.buffer.slice(this.cursor),this.cursor--;this.render(),i++;continue}if(r==="\x01"){this.cursor=0,this.render(),i++;continue}if(r==="\x05"){this.cursor=this.buffer.length,this.render(),i++;continue}if(r==="\x15"){this.buffer="",this.cursor=0,this.render(),i++;continue}if(r==="\x17"){let $=this.buffer.slice(0,this.cursor),p=this.buffer.slice(this.cursor),e=$.replace(/\S+\s*$/,"");this.cursor=e.length,this.buffer=e+p,this.render(),i++;continue}if(r==="\t"){if(this.buffer.startsWith("/")){let $=$e.filter((p)=>p.startsWith(this.buffer));if($.length===1)this.buffer=$[0],this.cursor=this.buffer.length,this.render()}i++;continue}if(r.charCodeAt(0)>=32){this.buffer=this.buffer.slice(0,this.cursor)+r+this.buffer.slice(this.cursor),this.cursor++,this.render(),i++;continue}i++}}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 t=this.buffer.startsWith("/")?$e.filter((e)=>e.startsWith(this.buffer)):[],n=t.length===1&&t[0]===this.buffer,i=t.length>0&&!n,r=i?t.length:0,$=3+r,p="";if(this.lastTotal>0)p+=gi(1);if(p+=re(1)+un()+this.border()+`
154
154
  `,p+=un()+"> "+this.buffer+`
155
- `,p+=ie(1)+un()+this.border()+`
156
- `,r)for(let e of t)p+=un()+` ${this.dim}${e.padEnd(Dr+2)} ${pe[e]}${this.reset}
157
- `;if($<this.lastTotal)p+=Ym();p+=gr(i+2),p+=ie(this.promptLen+this.cursor+1),this.out.write(p),this.lastTotal=$}}var zm="\x1B[?25l",Nm="\x1B[?25h",pe,$e,Dr,ni;var ei=s(()=>{Z();K();J();k();pe={"/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"},$e=Object.keys(pe),Dr=Math.max(...$e.map((t)=>t.length));ni=S({name:"text repl",description:"Start an interactive multi-turn chat session",usage:"mmx text repl [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{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 MiniMax-M2.7-highspeed --system "You are a coding assistant."',"mmx text repl --temperature 0.7 --max-tokens 8192"],async run(t,n){if(!H({nonInteractive:t.nonInteractive}))throw new y("The repl command requires an interactive terminal.",x.USAGE,"mmx text repl");if(!process.stdin.isTTY)throw new y("The repl command requires a TTY.",x.USAGE);let r=t.noColor?"":"\x1B[2m",i=t.noColor?"":"\x1B[0m",$={messages:[],system:n.system,model:n.model||t.defaultTextModel||"MiniMax-M2.7",maxTokens:n.maxTokens??4096,temperature:n.temperature!==void 0?n.temperature:void 0,topP:n.topP!==void 0?n.topP:void 0},p=t.noColor?"":"\x1B[1m";if(process.stdout.write(`
158
- ${p}MiniMax Chat REPL${i}
159
- `),process.stdout.write(`${r}Model: ${$.model}${i}
160
- `),$.system)process.stdout.write(`${r}System: ${$.system.slice(0,80)}${$.system.length>80?"...":""}${i}
161
- `);process.stdout.write(`${r}Type / to see commands, /exit to quit.${i}
162
- `);let{stdin:e,stdout:m}=process;if(typeof e.setRawMode==="function")e.setRawMode(!0);e.resume(),e.setEncoding("utf8");let u=!1,_=0;async function c(){if($.messages.length===0){m.write(`${r}No messages to send. Type something first.${i}
163
- `);return}let q={model:$.model,messages:$.messages,max_tokens:$.maxTokens,stream:!0};if($.system)q.system=$.system;if($.temperature!==void 0)q.temperature=$.temperature;if($.topP!==void 0)q.top_p=$.topP;u=!0;let M=tn(t.baseUrl);try{let h=await D(t,{url:M,method:"POST",body:q,stream:!0,authStyle:"x-api-key"}),V=h.headers.get("content-type")||"";if(!V.includes("text/event-stream")&&!V.includes("stream"))throw new y(`Expected SSE stream but got content-type "${V}".`,x.GENERAL);let X="",Q=!1;for await(let N of Bt(h)){if(N.data==="[DONE]")break;try{let U=JSON.parse(N.data);if(U.type==="content_block_start"){if(U.content_block.type==="thinking")Q=!0,m.write(`${r}Thinking:
164
- `);else if(U.content_block.type==="text"&&Q)m.write(`${i}
155
+ `,p+=re(1)+un()+this.border()+`
156
+ `,i)for(let e of t)p+=un()+` ${this.dim}${e.padEnd(Di+2)} ${pe[e]}${this.reset}
157
+ `;if($<this.lastTotal)p+=Ym();p+=gi(r+2),p+=re(this.promptLen+this.cursor+1),this.out.write(p),this.lastTotal=$}}var zm="\x1B[?25l",Nm="\x1B[?25h",pe,$e,Di,nr;var er=s(()=>{Z();K();J();k();pe={"/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"},$e=Object.keys(pe),Di=Math.max(...$e.map((t)=>t.length));nr=S({name:"text repl",description:"Start an interactive multi-turn chat session",usage:"mmx text repl [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M3)"},{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 MiniMax-M3 --system "You are a coding assistant."',"mmx text repl --temperature 0.7 --max-tokens 8192"],async run(t,n){if(!H({nonInteractive:t.nonInteractive}))throw new y("The repl command requires an interactive terminal.",x.USAGE,"mmx text repl");if(!process.stdin.isTTY)throw new y("The repl command requires a TTY.",x.USAGE);let i=t.noColor?"":"\x1B[2m",r=t.noColor?"":"\x1B[0m",$={messages:[],system:n.system,model:n.model||t.defaultTextModel||"MiniMax-M3",maxTokens:n.maxTokens??4096,temperature:n.temperature!==void 0?n.temperature:void 0,topP:n.topP!==void 0?n.topP:void 0},p=t.noColor?"":"\x1B[1m";if(process.stdout.write(`
158
+ ${p}MiniMax Chat REPL${r}
159
+ `),process.stdout.write(`${i}Model: ${$.model}${r}
160
+ `),$.system)process.stdout.write(`${i}System: ${$.system.slice(0,80)}${$.system.length>80?"...":""}${r}
161
+ `);process.stdout.write(`${i}Type / to see commands, /exit to quit.${r}
162
+ `);let{stdin:e,stdout:m}=process;if(typeof e.setRawMode==="function")e.setRawMode(!0);e.resume(),e.setEncoding("utf8");let u=!1,c=0;async function _(){if($.messages.length===0){m.write(`${i}No messages to send. Type something first.${r}
163
+ `);return}let h={model:$.model,messages:$.messages,max_tokens:$.maxTokens,stream:!0};if($.system)h.system=$.system;if($.temperature!==void 0)h.temperature=$.temperature;if($.topP!==void 0)h.top_p=$.topP;u=!0;let b=tn(t.baseUrl);try{let q=await D(t,{url:b,method:"POST",body:h,stream:!0,authStyle:"x-api-key"}),V=q.headers.get("content-type")||"";if(!V.includes("text/event-stream")&&!V.includes("stream"))throw new y(`Expected SSE stream but got content-type "${V}".`,x.GENERAL);let X="",Q=!1;for await(let N of Bt(q)){if(N.data==="[DONE]")break;try{let U=JSON.parse(N.data);if(U.type==="content_block_start"){if(U.content_block.type==="thinking")Q=!0,m.write(`${i}Thinking:
164
+ `);else if(U.content_block.type==="text"&&Q)m.write(`${r}
165
165
  Response:
166
- `),Q=!1}else if(U.type==="content_block_delta"){if(U.delta.type==="text_delta")X+=U.delta.text,m.write(U.delta.text);else if(U.delta.type==="thinking_delta")m.write(U.delta.thinking)}}catch{}}if(Q)m.write(i);if(X)$.messages.push({role:"assistant",content:X}),m.write(`
167
- `);else m.write(`${r}[empty response]${i}
168
- `)}catch(h){m.write(`${r}[error] ${h instanceof Error?h.message:String(h)}${i}
169
- `)}finally{u=!1,_=0}}function w(q){let M=q.trim().split(/\s+/),h=M[0],V=M.slice(1).join(" ");switch(h){case"/exit":return m.write(`${r}Goodbye!${i}
170
- `),"exit";case"/help":return Om(),"ok";case"/clear":return $.messages=[],m.write(`${r}Conversation cleared.${i}
171
- `),"ok";case"/system":{if(V)$.system=V,m.write(`${r}System prompt set.${i}
172
- `);else if($.system)m.write(`${r}System prompt:${i}
166
+ `),Q=!1}else if(U.type==="content_block_delta"){if(U.delta.type==="text_delta")X+=U.delta.text,m.write(U.delta.text);else if(U.delta.type==="thinking_delta")m.write(U.delta.thinking)}}catch{}}if(Q)m.write(r);if(X)$.messages.push({role:"assistant",content:X}),m.write(`
167
+ `);else m.write(`${i}[empty response]${r}
168
+ `)}catch(q){m.write(`${i}[error] ${q instanceof Error?q.message:String(q)}${r}
169
+ `)}finally{u=!1,c=0}}function w(h){let b=h.trim().split(/\s+/),q=b[0],V=b.slice(1).join(" ");switch(q){case"/exit":return m.write(`${i}Goodbye!${r}
170
+ `),"exit";case"/help":return Om(),"ok";case"/clear":return $.messages=[],m.write(`${i}Conversation cleared.${r}
171
+ `),"ok";case"/system":{if(V)$.system=V,m.write(`${i}System prompt set.${r}
172
+ `);else if($.system)m.write(`${i}System prompt:${r}
173
173
  ${$.system}
174
- `);else m.write(`${r}No system prompt set.${i}
175
- `);return"ok"}case"/model":{if(V)$.model=V,m.write(`${r}Model set to: ${$.model}${i}
176
- `);else m.write(`${r}Current model: ${$.model}${i}
177
- `);return"ok"}case"/save":{if(!V)return m.write(`${r}Usage: /save <file-path>${i}
178
- `),"ok";try{let X=[];if($.system)X.push({role:"system",content:$.system});for(let Q of $.messages)X.push({role:Q.role,content:typeof Q.content==="string"?Q.content:JSON.stringify(Q.content)});Zm(V,JSON.stringify(X,null,2),"utf-8"),m.write(`${r}Conversation saved to ${V} (${X.length} messages)${i}
179
- `)}catch(X){m.write(`${r}[error] Failed to save: ${X instanceof Error?X.message:String(X)}${i}
180
- `)}return"ok"}case"/history":{if($.messages.length===0)return m.write(`${r}No messages in conversation.${i}
181
- `),"ok";if($.system)m.write(`${r}[system] ${$.system.slice(0,100)}${$.system.length>100?"...":""}${i}
182
- `);let X=1;for(let Q of $.messages){let N=Q.role==="user"?"user":"assistant",U=typeof Q.content==="string"?Q.content:"[structured content]",Sn=(U.length>120?U.slice(0,120)+"...":U).replace(/\n/g,"↵"),y$=` ${String(X).padStart(2)} ${N.padEnd(11)}`;m.write(`${r}${y$}${i}${Sn}
183
- `),X++}return m.write(`${r}── ${X-1} messages ──${i}
184
- `),"ok"}default:if(h.startsWith("/"))return m.write(`${r}Unknown command: ${h}. Type /help for available commands.${i}
174
+ `);else m.write(`${i}No system prompt set.${r}
175
+ `);return"ok"}case"/model":{if(V)$.model=V,m.write(`${i}Model set to: ${$.model}${r}
176
+ `);else m.write(`${i}Current model: ${$.model}${r}
177
+ `);return"ok"}case"/save":{if(!V)return m.write(`${i}Usage: /save <file-path>${r}
178
+ `),"ok";try{let X=[];if($.system)X.push({role:"system",content:$.system});for(let Q of $.messages)X.push({role:Q.role,content:typeof Q.content==="string"?Q.content:JSON.stringify(Q.content)});Zm(V,JSON.stringify(X,null,2),"utf-8"),m.write(`${i}Conversation saved to ${V} (${X.length} messages)${r}
179
+ `)}catch(X){m.write(`${i}[error] Failed to save: ${X instanceof Error?X.message:String(X)}${r}
180
+ `)}return"ok"}case"/history":{if($.messages.length===0)return m.write(`${i}No messages in conversation.${r}
181
+ `),"ok";if($.system)m.write(`${i}[system] ${$.system.slice(0,100)}${$.system.length>100?"...":""}${r}
182
+ `);let X=1;for(let Q of $.messages){let N=Q.role==="user"?"user":"assistant",U=typeof Q.content==="string"?Q.content:"[structured content]",Sn=(U.length>120?U.slice(0,120)+"...":U).replace(/\n/g,"↵"),y$=` ${String(X).padStart(2)} ${N.padEnd(11)}`;m.write(`${i}${y$}${r}${Sn}
183
+ `),X++}return m.write(`${i}── ${X-1} messages ──${r}
184
+ `),"ok"}default:if(q.startsWith("/"))return m.write(`${i}Unknown command: ${q}. Type /help for available commands.${r}
185
185
  `),"ok";return"ok"}}let v=()=>{if(u){m.write(`
186
- ${r}[interrupted]${i}
187
- `),_=0,u=!1;return}if(_++,_>=2){if(m.write(`
188
- ${r}Goodbye!${i}
186
+ ${i}[interrupted]${r}
187
+ `),c=0,u=!1;return}if(c++,c>=2){if(m.write(`
188
+ ${i}Goodbye!${r}
189
189
  `),G=!1,typeof e.setRawMode==="function")e.setRawMode(!1);e.pause(),process.removeListener("SIGINT",v),process.exit(0)}else m.write(`
190
- ${r}Press Ctrl+C again or type /exit to quit.${i}
191
- `)};process.on("SIGINT",v);let b=new ti(m,"> ",r,i),G=!0;e.on("data",(q)=>{b.feed(q)}),m.write(zm);try{while(G){let q=await b.readLine();if(!G)break;let M=q.trim();if(!M)continue;if(M.startsWith("/")){if(w(M)==="exit"){G=!1;break}continue}$.messages.push({role:"user",content:M}),await c()}}finally{if(m.write(Nm),typeof e.setRawMode==="function")e.setRawMode(!1);e.pause(),process.removeListener("SIGINT",v),e.removeAllListeners("data"),m.write(`
192
- `)}}})});import{writeFileSync as Wm}from"fs";function kt(t,n,r,i){if(n){let $=t.data.audio;if(!$)throw new y("API response missing audio data (audio field is empty).",x.GENERAL);if(!/^[0-9a-fA-F]*$/.test($))throw new y("API returned invalid audio data (not valid hex).",x.GENERAL);if($.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",x.GENERAL);try{Wm(n,Buffer.from($,"hex"))}catch(p){if(p.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",x.GENERAL,"Free up disk space and try again.");throw p}if(i)console.log(n);else console.log(A({saved:n,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},r))}else{let $=t.data.audio_url??t.data.audio;if(i)console.log($);else console.log(A({url:$,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},r))}}var xn=s(()=>{Y();J();k()});var ri={};Ot(ri,{readTextFromPathOrStdin:()=>Yt});import{readFileSync as Hm}from"fs";function Yt(t){return Hm(t==="-"?"/dev/stdin":t,"utf-8")}var yn=()=>{};function Rt(t){return t.join(", ")}function Vt(t,n){if(!n.includes(t))throw new y(`Invalid audio format "${t}". Supported: ${Rt(n)}`,x.USAGE)}function ii(t,n){return Km[t]??n}function $i(t,n){if(n&&t==="wav")throw new y("wav format is not supported in streaming mode.",x.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var me,Jt,Km;var _n=s(()=>{J();k();me=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"],Jt=["mp3","wav","pcm"];Km={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function pi(t){if(!/^[0-9a-fA-F]+$/.test(t))throw new y("API returned invalid audio data (not valid hex).",x.GENERAL);if(t.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",x.GENERAL);return Uint8Array.from(Buffer.from(t,"hex"))}function mi(t,n){let r=n.base_resp?.status_code;if(r!==void 0&&r!==0||n.error)throw Tt(t.status,n,t.url||void 0)}function oi(){return new y("API stream ended without audio data.",x.GENERAL)}async function*Im(t){let n=t.headers.get("content-type")||"";if(!n.toLowerCase().includes("text/event-stream")){let i;try{i=await t.json()}catch{throw new y(`Expected SSE audio stream but got content-type "${n||"unknown"}".`,x.GENERAL)}mi(t,i);let $=i.data?.audio;if(!$)throw oi();yield pi($);return}let r=!1;for await(let i of Bt(t)){if(!i.data||i.data==="[DONE]")break;let $;try{$=JSON.parse(i.data)}catch(e){throw new y(`Failed to parse audio stream chunk: ${e instanceof Error?e.message:String(e)}`,x.GENERAL)}mi(t,$);let p=$.data?.audio;if(p)r=!0,yield pi(p);if($.data?.status===2)break}if(!r)throw oi()}async function Xt(t){process.stdout.on("error",(n)=>{if(n.code==="EPIPE")process.exit(0);throw n});for await(let n of Im(t))if(!process.stdout.write(n))await new Promise((r)=>process.stdout.once("drain",r))}var cn=s(()=>{Dn();J();k()});import{writeFileSync as Pm}from"fs";var oe;var ui=s(()=>{Z();J();k();K();Y();xn();yn();_n();cn();oe=S({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:"--format <fmt>",description:`Audio format: ${Rt(me)} (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(t,n){let r=n.text??n._positional?.[0];if(n.textFile)r=Yt(n.textFile);if(!r)throw new y("--text or --text-file is required.",x.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let i=n.model||t.defaultSpeechModel||"speech-2.8-hd",$=n.voice||"English_expressive_narrator",p=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),e=n.format||"mp3";Vt(e,me),$i(e,n.stream===!0);let m=n.out??`speech_${p}.${e}`,u="hex",_={model:i,text:r,voice_setting:{voice_id:$,speed:n.speed??void 0,vol:n.volume??void 0,pitch:n.pitch??void 0},audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??ii(e,32000),bitrate:n.bitrate??128000,channel:n.channels??1},output_format:u,stream:n.stream===!0};if(n.language)_.language_boost=n.language;if(n.subtitles)_.subtitle_enable=!0;if(n.pronunciation)_.pronunciation_dict={tone:n.pronunciation};if(et(t,_))return;let c=j(t.output),w=Gr(t.baseUrl);if(n.stream){let b=await D(t,{url:w,method:"POST",body:_,stream:!0});await Xt(b);return}let v=await B(t,{url:w,method:"POST",body:_});if(!t.quiet)process.stderr.write(`[Model: ${i}]
193
- `);if(kt(v,m,c,t.quiet),n.subtitles&&v.data.subtitle_file)try{let b=await fetch(v.data.subtitle_file);if(!b.ok)throw new y(`Failed to download subtitle file: ${b.status}`,x.GENERAL);let G=await b.json();if(G?.length){let q=m.replace(/\.[^.]+$/,"")+".srt",M=G.map((h,V)=>{let X=(Q)=>{let N=String(Math.floor(Q/3600000)).padStart(2,"0"),U=String(Math.floor(Q%3600000/60000)).padStart(2,"0"),ve=String(Math.floor(Q%60000/1000)).padStart(2,"0"),Sn=String(Math.round(Q%1000)).padStart(3,"0");return`${N}:${U}:${ve},${Sn}`};return`${V+1}
194
- ${X(h.time_begin)} --> ${X(h.time_end)}
195
- ${h.text}`}).join(`
190
+ ${i}Press Ctrl+C again or type /exit to quit.${r}
191
+ `)};process.on("SIGINT",v);let M=new tr(m,"> ",i,r),G=!0;e.on("data",(h)=>{M.feed(h)}),m.write(zm);try{while(G){let h=await M.readLine();if(!G)break;let b=h.trim();if(!b)continue;if(b.startsWith("/")){if(w(b)==="exit"){G=!1;break}continue}$.messages.push({role:"user",content:b}),await _()}}finally{if(m.write(Nm),typeof e.setRawMode==="function")e.setRawMode(!1);e.pause(),process.removeListener("SIGINT",v),e.removeAllListeners("data"),m.write(`
192
+ `)}}})});import{writeFileSync as Wm}from"fs";function kt(t,n,i,r){if(n){let $=t.data.audio;if(!$)throw new y("API response missing audio data (audio field is empty).",x.GENERAL);if(!/^[0-9a-fA-F]*$/.test($))throw new y("API returned invalid audio data (not valid hex).",x.GENERAL);if($.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",x.GENERAL);try{Wm(n,Buffer.from($,"hex"))}catch(p){if(p.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",x.GENERAL,"Free up disk space and try again.");throw p}if(r)console.log(n);else console.log(A({saved:n,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},i))}else{let $=t.data.audio_url??t.data.audio;if(r)console.log($);else console.log(A({url:$,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},i))}}var xn=s(()=>{Y();J();k()});var ir={};Ot(ir,{readTextFromPathOrStdin:()=>Yt});import{readFileSync as Hm}from"fs";function Yt(t){return Hm(t==="-"?"/dev/stdin":t,"utf-8")}var yn=()=>{};function Rt(t){return t.join(", ")}function Vt(t,n){if(!n.includes(t))throw new y(`Invalid audio format "${t}". Supported: ${Rt(n)}`,x.USAGE)}function rr(t,n){return Km[t]??n}function $r(t,n){if(n&&t==="wav")throw new y("wav format is not supported in streaming mode.",x.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var me,Jt,Km;var cn=s(()=>{J();k();me=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"],Jt=["mp3","wav","pcm"];Km={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function pr(t){if(!/^[0-9a-fA-F]+$/.test(t))throw new y("API returned invalid audio data (not valid hex).",x.GENERAL);if(t.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",x.GENERAL);return Uint8Array.from(Buffer.from(t,"hex"))}function mr(t,n){let i=n.base_resp?.status_code;if(i!==void 0&&i!==0||n.error)throw Tt(t.status,n,t.url||void 0)}function or(){return new y("API stream ended without audio data.",x.GENERAL)}async function*Im(t){let n=t.headers.get("content-type")||"";if(!n.toLowerCase().includes("text/event-stream")){let r;try{r=await t.json()}catch{throw new y(`Expected SSE audio stream but got content-type "${n||"unknown"}".`,x.GENERAL)}mr(t,r);let $=r.data?.audio;if(!$)throw or();yield pr($);return}let i=!1;for await(let r of Bt(t)){if(!r.data||r.data==="[DONE]")break;let $;try{$=JSON.parse(r.data)}catch(e){throw new y(`Failed to parse audio stream chunk: ${e instanceof Error?e.message:String(e)}`,x.GENERAL)}mr(t,$);let p=$.data?.audio;if(p)i=!0,yield pr(p);if($.data?.status===2)break}if(!i)throw or()}async function Xt(t){process.stdout.on("error",(n)=>{if(n.code==="EPIPE")process.exit(0);throw n});for await(let n of Im(t))if(!process.stdout.write(n))await new Promise((i)=>process.stdout.once("drain",i))}var _n=s(()=>{Dn();J();k()});import{writeFileSync as Pm}from"fs";var oe;var ur=s(()=>{Z();J();k();K();Y();xn();yn();cn();_n();oe=S({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:"--format <fmt>",description:`Audio format: ${Rt(me)} (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(t,n){let i=n.text??n._positional?.[0];if(n.textFile)i=Yt(n.textFile);if(!i)throw new y("--text or --text-file is required.",x.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=n.model||t.defaultSpeechModel||"speech-2.8-hd",$=n.voice||"English_expressive_narrator",p=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),e=n.format||"mp3";Vt(e,me),$r(e,n.stream===!0);let m=n.out??`speech_${p}.${e}`,u="hex",c={model:r,text:i,voice_setting:{voice_id:$,speed:n.speed??void 0,vol:n.volume??void 0,pitch:n.pitch??void 0},audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??rr(e,32000),bitrate:n.bitrate??128000,channel:n.channels??1},output_format:u,stream:n.stream===!0};if(n.language)c.language_boost=n.language;if(n.subtitles)c.subtitle_enable=!0;if(n.pronunciation)c.pronunciation_dict={tone:n.pronunciation};if(et(t,c))return;let _=j(t.output),w=Gi(t.baseUrl);if(n.stream){let M=await D(t,{url:w,method:"POST",body:c,stream:!0});await Xt(M);return}let v=await B(t,{url:w,method:"POST",body:c});if(!t.quiet)process.stderr.write(`[Model: ${r}]
193
+ `);if(kt(v,m,_,t.quiet),n.subtitles&&v.data.subtitle_file)try{let M=await fetch(v.data.subtitle_file);if(!M.ok)throw new y(`Failed to download subtitle file: ${M.status}`,x.GENERAL);let G=await M.json();if(G?.length){let h=m.replace(/\.[^.]+$/,"")+".srt",b=G.map((q,V)=>{let X=(Q)=>{let N=String(Math.floor(Q/3600000)).padStart(2,"0"),U=String(Math.floor(Q%3600000/60000)).padStart(2,"0"),ve=String(Math.floor(Q%60000/1000)).padStart(2,"0"),Sn=String(Math.round(Q%1000)).padStart(3,"0");return`${N}:${U}:${ve},${Sn}`};return`${V+1}
194
+ ${X(q.time_begin)} --> ${X(q.time_end)}
195
+ ${q.text}`}).join(`
196
196
 
197
- `);if(Pm(q,M,"utf-8"),!t.quiet)console.log(A({subtitles:q},c));else console.log(q)}}catch(b){if(!t.quiet)process.stderr.write(`Warning: failed to download subtitles: ${b.message}
197
+ `);if(Pm(h,b,"utf-8"),!t.quiet)console.log(A({subtitles:h},_));else console.log(h)}}catch(M){if(!t.quiet)process.stderr.write(`Warning: failed to download subtitles: ${M.message}
198
198
  `)}else if(n.subtitles&&!v.data.subtitle_file){if(!t.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
199
- `)}}})});function dm(t){let n=t.match(/^(.+?)_[A-Z]/);return n?n[1]:t}function lm(t,n){let r=n.toLowerCase();return t.filter((i)=>{let $=dm(i.voice_id).toLowerCase();return $===r||$.startsWith(r+"_")||$.startsWith(r+" (")})}var xi;var yi=s(()=>{Z();K();Y();xi=S({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(t,n){let r=j(t.output);if(t.dryRun){console.log(A({request:{voice_type:"system"}},r));return}let $=(await B(t,{url:Sr(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],p=n.language;if(p){let e=lm($,p);if(r!=="text"){console.log(A(e,r));return}for(let m of e){let u=m.description?.join("; ")||"",_=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${_}`),u)console.log(` ${u}`)}}else{if(r!=="text"){console.log(A($.map((e)=>e.voice_id),r));return}for(let e of $)console.log(e.voice_id)}}})});function ci(t){let n=process.stderr.isTTY,r=0,i=null,$=t;return{start(){if(!n)return;i=setInterval(()=>{process.stderr.write(`\r${_i[r%_i.length]} ${$}`),r++},80)},update(p){$=p},stop(p){if(i)clearInterval(i),i=null;if(n){if(process.stderr.write("\r\x1B[K"),p)process.stderr.write(`${p}
200
- `)}}}}function wi(t,n=""){let r=process.stderr.isTTY,i=30;return{update($){if(!r)return;let p=Math.min(1,$/t),e=Math.round(30*p),m=30-e,u="█".repeat(e)+"░".repeat(m),_=`${Math.round(p*100)}%`;process.stderr.write(`\r${n} ${u} ${_}`)},finish(){if(r)process.stderr.write(`
201
- `)}}}var _i;var ue=s(()=>{_i=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as Em,renameSync as Lm,unlinkSync as Cm}from"fs";async function xt(t,n,r){let i=t.startsWith("http://")?t.replace("http://","https://"):t,$=r?.retries??3,p=r?.retryDelayMs??1000,e;for(let m=0;m<=$;m++)try{if(m>0){let h=p*Math.pow(2,m-1);if(!r?.quiet)process.stderr.write(`
202
- Retry ${m}/${$} in ${h}ms...
203
- `);await new Promise((V)=>setTimeout(V,h))}let u=await fetch(i);if(!u.ok)throw new y(`Download failed: HTTP ${u.status}`,x.GENERAL);let _=Number(u.headers.get("content-length")||0),c=u.body?.getReader();if(!c)throw new y("No response body",x.GENERAL);let w=`${n}.tmp-${process.pid}-${Date.now()}-${m}-${Math.random().toString(36).slice(2)}`,v=Em(w),b=_>0&&!r?.quiet?wi(_,"Downloading"):null,G=0,q=!1,M=!1;try{let h=new Promise((V,X)=>{v.on("error",X)});while(!0){let{done:V,value:X}=await Promise.race([c.read(),h]);if(V)break;if(!v.write(X))await new Promise((N)=>v.once("drain",N));G+=X.byteLength,b?.update(G)}q=!0}finally{c.releaseLock(),b?.finish();try{if(!v.destroyed)await new Promise((h,V)=>{v.on("finish",h),v.on("error",V),v.end()}),M=q}finally{if(!M)try{Cm(w)}catch{}}}return Lm(w,n),{size:G}}catch(u){if(e=u instanceof Error?u:Error(String(u)),!r?.quiet)process.stderr.write(`
199
+ `)}}})});function dm(t){let n=t.match(/^(.+?)_[A-Z]/);return n?n[1]:t}function lm(t,n){let i=n.toLowerCase();return t.filter((r)=>{let $=dm(r.voice_id).toLowerCase();return $===i||$.startsWith(i+"_")||$.startsWith(i+" (")})}var xr;var yr=s(()=>{Z();K();Y();xr=S({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(t,n){let i=j(t.output);if(t.dryRun){console.log(A({request:{voice_type:"system"}},i));return}let $=(await B(t,{url:Si(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],p=n.language;if(p){let e=lm($,p);if(i!=="text"){console.log(A(e,i));return}for(let m of e){let u=m.description?.join("; ")||"",c=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${c}`),u)console.log(` ${u}`)}}else{if(i!=="text"){console.log(A($.map((e)=>e.voice_id),i));return}for(let e of $)console.log(e.voice_id)}}})});function _r(t){let n=process.stderr.isTTY,i=0,r=null,$=t;return{start(){if(!n)return;r=setInterval(()=>{process.stderr.write(`\r${cr[i%cr.length]} ${$}`),i++},80)},update(p){$=p},stop(p){if(r)clearInterval(r),r=null;if(n){if(process.stderr.write("\r\x1B[K"),p)process.stderr.write(`${p}
200
+ `)}}}}function wr(t,n=""){let i=process.stderr.isTTY,r=30;return{update($){if(!i)return;let p=Math.min(1,$/t),e=Math.round(30*p),m=30-e,u="█".repeat(e)+"░".repeat(m),c=`${Math.round(p*100)}%`;process.stderr.write(`\r${n} ${u} ${c}`)},finish(){if(i)process.stderr.write(`
201
+ `)}}}var cr;var ue=s(()=>{cr=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as Em,renameSync as Lm,unlinkSync as Cm}from"fs";async function xt(t,n,i){let r=t.startsWith("http://")?t.replace("http://","https://"):t,$=i?.retries??3,p=i?.retryDelayMs??1000,e;for(let m=0;m<=$;m++)try{if(m>0){let q=p*Math.pow(2,m-1);if(!i?.quiet)process.stderr.write(`
202
+ Retry ${m}/${$} in ${q}ms...
203
+ `);await new Promise((V)=>setTimeout(V,q))}let u=await fetch(r);if(!u.ok)throw new y(`Download failed: HTTP ${u.status}`,x.GENERAL);let c=Number(u.headers.get("content-length")||0),_=u.body?.getReader();if(!_)throw new y("No response body",x.GENERAL);let w=`${n}.tmp-${process.pid}-${Date.now()}-${m}-${Math.random().toString(36).slice(2)}`,v=Em(w),M=c>0&&!i?.quiet?wr(c,"Downloading"):null,G=0,h=!1,b=!1;try{let q=new Promise((V,X)=>{v.on("error",X)});while(!0){let{done:V,value:X}=await Promise.race([_.read(),q]);if(V)break;if(!v.write(X))await new Promise((N)=>v.once("drain",N));G+=X.byteLength,M?.update(G)}h=!0}finally{_.releaseLock(),M?.finish();try{if(!v.destroyed)await new Promise((q,V)=>{v.on("finish",q),v.on("error",V),v.end()}),b=h}finally{if(!b)try{Cm(w)}catch{}}}return Lm(w,n),{size:G}}catch(u){if(e=u instanceof Error?u:Error(String(u)),!i?.quiet)process.stderr.write(`
204
204
  Download attempt ${m+1} failed: ${e.message}
205
- `)}throw new y(`Download failed after ${$+1} attempts: ${e?.message}`,x.NETWORK,"Check your network connection and proxy settings.")}function wn(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}var vn=s(()=>{ue();J();k()});import{readFileSync as am,existsSync as fm}from"fs";import{extname as vi}from"path";function bn(t){let n=vi(t).toLowerCase(),r=bi[n]||"image/jpeg",i=am(t);return`data:${r};base64,${i.toString("base64")}`}function Mn(t){return t.startsWith("http")?t:bn(t)}async function Mi(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let r=await fetch(t);if(!r.ok)throw new y(`Failed to download image: HTTP ${r.status}`,x.GENERAL);let $=(r.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),p=await r.arrayBuffer();if(p.byteLength>Fm)throw new y(`Image too large (${(p.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,x.USAGE);return`data:${$};base64,${Buffer.from(p).toString("base64")}`}if(!fm(t))throw new y(`File not found: ${t}`,x.USAGE);let n=vi(t).toLowerCase();if(!bi[n])throw new y(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,x.USAGE);return bn(t)}var bi,Fm=52428800;var sn=s(()=>{J();k();bi={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}});import{mkdirSync as si,existsSync as zt,writeFileSync as Ri}from"fs";import{dirname as gm,join as Gi,resolve as xe}from"path";var Si;var Ai=s(()=>{Z();J();k();K();vn();Y();sn();mt();Si=S({name:"image generate",description:"Generate images (image-01 / image-01-live)",apiDocs:"/docs/api-reference/image-generation-t2i",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). Ignored if --width and --height are both specified."},{flag:"--n <count>",description:"Number of images to generate (default: 1)",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. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",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"},{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'],async run(t,n){let r=n.prompt??n._positional?.[0];r=await at({value:r,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:t.nonInteractive});let{width:i,height:$}=n;if(i!==void 0&&$===void 0)throw new y("--width requires --height. Both must be specified together.",x.USAGE);if($!==void 0&&i===void 0)throw new y("--height requires --width. Both must be specified together.",x.USAGE);if(i!==void 0&&$!==void 0){let v=(b,G)=>{if(G<512||G>2048)throw new y(`--${b} must be between 512 and 2048, got ${G}.`,x.USAGE);if(G%8!==0)throw new y(`--${b} must be a multiple of 8, got ${G}.`,x.USAGE)};v("width",i),v("height",$)}let p=n.out;if(p&&n.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",x.USAGE);let e=n.responseFormat||"url",m={model:"image-01",prompt:r,aspect_ratio:i!==void 0&&$!==void 0?void 0:n.aspectRatio||void 0,n:n.n??1,seed:n.seed,width:i,height:$,prompt_optimizer:n.promptOptimizer===!0||void 0,aigc_watermark:n.aigcWatermark===!0||void 0,response_format:e};if(n.subjectRef){let v=n.subjectRef,b=Object.fromEntries(v.split(",").map((q)=>{let M=q.indexOf("=");if(M===-1)return[q,""];return[q.slice(0,M),q.slice(M+1)]})),G={type:b.type||"character"};if(b.image)if(b.image.startsWith("http"))G.image_url=b.image;else G.image_file=bn(xe(b.image));m.subject_reference=[G]}if(et(t,m))return;let u=j(t.output),_=Ar(t.baseUrl),c=await B(t,{url:_,method:"POST",body:m});if(!t.quiet)process.stderr.write(`[Model: image-01]
206
- `);let w=[];if(p){let v=gm(xe(p));if(!zt(v))si(v,{recursive:!0});let b=xe(p);if(zt(b))process.stderr.write(`Warning: overwriting existing file: ${b}
207
- `);if(e==="base64"){let G=(c.data.image_base64||[])[0];if(G)Ri(b,G,"base64")}else{let G=(c.data.image_urls||[])[0];if(G)await xt(G,b,{quiet:t.quiet})}w.push(b)}else{let v=n.outDir??".";if(!zt(v))si(v,{recursive:!0});let b=n.outPrefix||"image";if(e==="base64"){let G=c.data.image_base64||[];for(let q=0;q<G.length;q++){let M=`${b}_${String(q+1).padStart(3,"0")}.jpg`,h=Gi(v,M);if(zt(h))process.stderr.write(`Warning: overwriting existing file: ${h}
208
- `);Ri(h,G[q],"base64"),w.push(h)}}else{let G=c.data.image_urls||[];for(let q=0;q<G.length;q++){let M=`${b}_${String(q+1).padStart(3,"0")}.jpg`,h=Gi(v,M);if(zt(h))process.stderr.write(`Warning: overwriting existing file: ${h}
209
- `);await xt(G[q],h,{quiet:t.quiet}),w.push(h)}}}if(u==="json")console.log(A({id:c.data.task_id,saved:w,success_count:c.data.success_count,failed_count:c.data.failed_count},u));else if(t.quiet)console.log(w.join(`
210
- `));else console.log(A({id:c.data.task_id,saved:w,success_count:c.data.success_count,failed_count:c.data.failed_count},u))}})});async function qi(t,n){let r=Date.now()+n.timeoutSec*1000,i=ci("Polling...");if(!t.quiet)i.start();try{while(Date.now()<r){let $=await B(t,{url:n.url});if(n.getStatus&&!t.quiet)i.update(`Status: ${n.getStatus($)}`);if(n.isComplete($))return i.stop("Done."),$;if(n.isFailed($)){i.stop("Failed.");let p=n.getStatus?n.getStatus($):"failed",e=$?.base_resp?` (${$.base_resp.status_msg})`:"";throw new y(`Task ${p}.${e}`,x.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((p)=>setTimeout(p,n.intervalSec*1000))}}finally{i.stop()}throw new y("Polling timed out.",x.TIMEOUT,"Try increasing --timeout or check task status manually.")}var hi=s(()=>{K();J();k();ue()});var ji;var Bi=s(()=>{Z();J();k();K();hi();vn();Y();sn();mt();ji=S({name:"video generate",description:`Generate a video
205
+ `)}throw new y(`Download failed after ${$+1} attempts: ${e?.message}`,x.NETWORK,"Check your network connection and proxy settings.")}function wn(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}var vn=s(()=>{ue();J();k()});import{readFileSync as am,existsSync as Fm}from"fs";import{extname as vr}from"path";function Mn(t){let n=vr(t).toLowerCase(),i=Mr[n]||"image/jpeg",r=am(t);return`data:${i};base64,${r.toString("base64")}`}function bn(t){return t.startsWith("http")?t:Mn(t)}async function br(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let i=await fetch(t);if(!i.ok)throw new y(`Failed to download image: HTTP ${i.status}`,x.GENERAL);let $=(i.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),p=await i.arrayBuffer();if(p.byteLength>fm)throw new y(`Image too large (${(p.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,x.USAGE);return`data:${$};base64,${Buffer.from(p).toString("base64")}`}if(!Fm(t))throw new y(`File not found: ${t}`,x.USAGE);let n=vr(t).toLowerCase();if(!Mr[n])throw new y(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,x.USAGE);return Mn(t)}var Mr,fm=52428800;var sn=s(()=>{J();k();Mr={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}});import{mkdirSync as sr,existsSync as zt,writeFileSync as Rr}from"fs";import{dirname as gm,join as Gr,resolve as xe}from"path";var Sr;var Ar=s(()=>{Z();J();k();K();vn();Y();sn();mt();Sr=S({name:"image generate",description:"Generate images (image-01 / image-01-live)",apiDocs:"/docs/api-reference/image-generation-t2i",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). Ignored if --width and --height are both specified."},{flag:"--n <count>",description:"Number of images to generate (default: 1)",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. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",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"},{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'],async run(t,n){let i=n.prompt??n._positional?.[0];i=await at({value:i,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:t.nonInteractive});let{width:r,height:$}=n;if(r!==void 0&&$===void 0)throw new y("--width requires --height. Both must be specified together.",x.USAGE);if($!==void 0&&r===void 0)throw new y("--height requires --width. Both must be specified together.",x.USAGE);if(r!==void 0&&$!==void 0){let v=(M,G)=>{if(G<512||G>2048)throw new y(`--${M} must be between 512 and 2048, got ${G}.`,x.USAGE);if(G%8!==0)throw new y(`--${M} must be a multiple of 8, got ${G}.`,x.USAGE)};v("width",r),v("height",$)}let p=n.out;if(p&&n.n>1)throw new y("--out cannot be used with --n > 1. Use --out-dir instead.",x.USAGE);let e=n.responseFormat||"url",m={model:"image-01",prompt:i,aspect_ratio:r!==void 0&&$!==void 0?void 0:n.aspectRatio||void 0,n:n.n??1,seed:n.seed,width:r,height:$,prompt_optimizer:n.promptOptimizer===!0||void 0,aigc_watermark:n.aigcWatermark===!0||void 0,response_format:e};if(n.subjectRef){let v=n.subjectRef,M=Object.fromEntries(v.split(",").map((h)=>{let b=h.indexOf("=");if(b===-1)return[h,""];return[h.slice(0,b),h.slice(b+1)]})),G={type:M.type||"character"};if(M.image)if(M.image.startsWith("http"))G.image_url=M.image;else G.image_file=Mn(xe(M.image));m.subject_reference=[G]}if(et(t,m))return;let u=j(t.output),c=Ai(t.baseUrl),_=await B(t,{url:c,method:"POST",body:m});if(!t.quiet)process.stderr.write(`[Model: image-01]
206
+ `);let w=[];if(p){let v=gm(xe(p));if(!zt(v))sr(v,{recursive:!0});let M=xe(p);if(zt(M))process.stderr.write(`Warning: overwriting existing file: ${M}
207
+ `);if(e==="base64"){let G=(_.data.image_base64||[])[0];if(G)Rr(M,G,"base64")}else{let G=(_.data.image_urls||[])[0];if(G)await xt(G,M,{quiet:t.quiet})}w.push(M)}else{let v=n.outDir??".";if(!zt(v))sr(v,{recursive:!0});let M=n.outPrefix||"image";if(e==="base64"){let G=_.data.image_base64||[];for(let h=0;h<G.length;h++){let b=`${M}_${String(h+1).padStart(3,"0")}.jpg`,q=Gr(v,b);if(zt(q))process.stderr.write(`Warning: overwriting existing file: ${q}
208
+ `);Rr(q,G[h],"base64"),w.push(q)}}else{let G=_.data.image_urls||[];for(let h=0;h<G.length;h++){let b=`${M}_${String(h+1).padStart(3,"0")}.jpg`,q=Gr(v,b);if(zt(q))process.stderr.write(`Warning: overwriting existing file: ${q}
209
+ `);await xt(G[h],q,{quiet:t.quiet}),w.push(q)}}}if(u==="json")console.log(A({id:_.data.task_id,saved:w,success_count:_.data.success_count,failed_count:_.data.failed_count},u));else if(t.quiet)console.log(w.join(`
210
+ `));else console.log(A({id:_.data.task_id,saved:w,success_count:_.data.success_count,failed_count:_.data.failed_count},u))}})});async function hr(t,n){let i=Date.now()+n.timeoutSec*1000,r=_r("Polling...");if(!t.quiet)r.start();try{while(Date.now()<i){let $=await B(t,{url:n.url});if(n.getStatus&&!t.quiet)r.update(`Status: ${n.getStatus($)}`);if(n.isComplete($))return r.stop("Done."),$;if(n.isFailed($)){r.stop("Failed.");let p=n.getStatus?n.getStatus($):"failed",e=$?.base_resp?` (${$.base_resp.status_msg})`:"";throw new y(`Task ${p}.${e}`,x.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((p)=>setTimeout(p,n.intervalSec*1000))}}finally{r.stop()}throw new y("Polling timed out.",x.TIMEOUT,"Try increasing --timeout or check task status manually.")}var qr=s(()=>{K();J();k();ue()});var jr;var Br=s(()=>{Z();J();k();K();qr();vn();Y();sn();mt();jr=S({name:"video generate",description:`Generate a video
211
211
  T2V: Hailuo-2.3
212
212
  I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --first-frame)
213
213
  SEF: Hailuo-02 (requires --first-frame and --last-frame)
214
- S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. T2V: MiniMax-Hailuo-2.3; I2V: MiniMax-Hailuo-2.3 (default) or MiniMax-Hailuo-2.3-Fast (fast, requires --first-frame). Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image (local path or URL). Auto base64-encoded for local files."},{flag:"--last-frame <path-or-url>",description:"Last frame image (local path or URL). Enables SEF (start-end frame) interpolation mode with Hailuo-02 model. Requires --first-frame."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{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',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --first-frame 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(t,n){let r=n.prompt;if(r=await at({value:r,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:t.nonInteractive}),n.lastFrame&&n.subjectImage)throw new y("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",x.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let i=n.model;if(i==="MiniMax-Hailuo-2.3-Fast"&&!n.firstFrame)throw new y("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --first-frame to provide an input image.",x.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --first-frame <image>");let $;if(i)$=i;else if(n.lastFrame)$="MiniMax-Hailuo-02";else if(n.subjectImage)$="S2V-01";else $=t.defaultVideoModel||"MiniMax-Hailuo-2.3";let p={model:$,prompt:r};if(n.firstFrame)p.first_frame_image=Mn(n.firstFrame);if(n.lastFrame){if(!n.firstFrame)throw new y("--last-frame requires --first-frame (SEF mode).",x.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");p.last_frame_image=Mn(n.lastFrame)}if(n.subjectImage)p.subject_reference=[{type:"character",image:[Mn(n.subjectImage)]}];if(n.callbackUrl)p.callback_url=n.callbackUrl;if(et(t,p))return;let e=j(t.output),m=qr(t.baseUrl),_=(await B(t,{url:m,method:"POST",body:p})).task_id;if(!t.quiet)process.stderr.write(`[Model: ${$}]
215
- `);if(n.noWait||t.async){process.stdout.write(JSON.stringify({taskId:_})),process.stdout.write(`
216
- `);return}let c=n.pollInterval??5,w=nn(t.baseUrl,_),v=await qi(t,{url:w,intervalSec:c,timeoutSec:t.timeout,isComplete:(N)=>N.status==="Success",isFailed:(N)=>N.status==="Failed",getStatus:(N)=>N.status});if(!v.file_id)throw new y("Task completed but no file_id returned.",x.GENERAL);let G=(await B(t,{url:en(t.baseUrl,v.file_id)})).file?.download_url;if(!G)throw new y("No download URL available for this file.",x.GENERAL);if(n.download){let N=n.download,{size:U}=await xt(G,N,{quiet:t.quiet});if(t.quiet)console.log(N);else console.log(A({task_id:_,status:"Success",file_id:v.file_id,saved:N,size:wn(U)},e));return}let q=await import("os"),{join:M}=await import("path"),h=M(q.tmpdir(),"mmx-video"),{existsSync:V,mkdirSync:X}=await import("fs");if(!V(h))X(h,{recursive:!0});let Q=M(h,`${_}.mp4`);await xt(G,Q,{quiet:t.quiet}),process.stdout.write(Q),process.stdout.write(`
217
- `)}})});var ki;var Ji=s(()=>{Z();J();k();K();Y();ki=S({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"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,n){let r=n.taskId;if(!r)throw new y("--task-id is required.",x.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${r}`);return}let i=nn(t.baseUrl,r),$=await B(t,{url:i}),p=j(t.output);if(t.quiet){console.log($.status);return}console.log(A({task_id:$.task_id,status:$.status,file_id:$.file_id,video_width:$.video_width,video_height:$.video_height},p))}})});var Vi;var Xi=s(()=>{Z();J();k();K();vn();Y();Vi=S({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(t,n){let r=n.fileId;if(!r)throw new y("--file-id is required.",x.USAGE,"mmx video download --file-id <id> --out <path>");let i=n.out;if(!i)throw new y("--out is required.",x.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${r} to ${i}`);return}let $=en(t.baseUrl,r),e=(await B(t,{url:$})).file?.download_url;if(!e)throw new y("No download URL available for this file.",x.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await xt(e,i,{quiet:t.quiet}),u=j(t.output);if(t.quiet){console.log(i);return}console.log(A({saved:i,size:wn(m)},u))}})});function Ui(t,n){return t.includes(n)}function Qi(t){if(t.defaultMusicModel&&Ui(Rn,t.defaultMusicModel))return t.defaultMusicModel;return"music-2.6"}function Zi(t){if(t.defaultMusicModel&&Ui(Gn,t.defaultMusicModel))return t.defaultMusicModel;return"music-cover"}var Rn,Gn;var ye=s(()=>{Rn=["music-2.6","music-2.6-free","music-2.5+","music-2.5"],Gn=["music-cover","music-cover-free"]});var Ti;var Yi=s(()=>{Z();J();k();K();Y();xn();yn();_n();cn();ye();Ti=S({name:"music generate",description:"Generate a song (music-2.6, including free tier)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.'},{flag:"--lyrics <text>",description:"Song lyrics with structure tags (newline separated). Supported: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo]. Tags must be clean — no descriptions inside brackets (they will be sung). Max 3500 chars."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Same tag rules as --lyrics."},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). music-2.6/music-2.5+: native is_instrumental flag; music-2.5: lyrics workaround. Cannot be used with --lyrics."},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz, electronic"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano, strings"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--model <model>",description:"Model: music-2.6 (default), music-2.6-free, music-2.5+, or music-2.5."},{flag:"--output-format <fmt>",description:"Return format: hex (default, saved to file) or url (24h expiry, download promptly). When --stream, only hex."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:`Audio format: ${Rt(Jt)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Auto-generate lyrics from prompt:",'mmx music generate --prompt "Upbeat pop about summer" --lyrics-optimizer --out summer.mp3',"# Instrumental:",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3',"# URL output (24h expiry — download promptly):",'mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --output-format url',"# Instrumental with music-2.5+:",'mmx music generate --prompt "Cinematic orchestral" --model "music-2.5+" --instrumental --out bgm.mp3',"# Detailed prompt with vocal characteristics:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3'],async run(t,n){let{prompt:r,lyrics:i}=n,$=n.instrumental===!0,p=n.lyricsOptimizer===!0;if(n.lyricsFile)i=Yt(n.lyricsFile);if($&&(i||n.lyricsFile))throw new y("Cannot use --instrumental with --lyrics or --lyrics-file.",x.USAGE,"mmx music generate --prompt <style> --instrumental");if(p&&(i||$))throw new y("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",x.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!r&&!i&&!$&&!p)throw new y("At least one of --prompt or --lyrics is required.",x.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(($||p)&&!r?.trim())throw new y("--prompt is required with --instrumental or --lyrics-optimizer.",x.USAGE,"mmx music generate --prompt <text> --instrumental");if(!$&&!p&&!i?.trim())throw new y("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",x.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let e=[];if(n.vocals)e.push(`Vocals: ${n.vocals}`);if(n.genre)e.push(`Genre: ${n.genre}`);if(n.mood)e.push(`Mood: ${n.mood}`);if(n.instruments)e.push(`Instruments: ${n.instruments}`);if(n.tempo)e.push(`Tempo: ${n.tempo}`);if(n.bpm)e.push(`BPM: ${n.bpm}`);if(n.key)e.push(`Key: ${n.key}`);if(n.avoid)e.push(`Avoid: ${n.avoid}`);if(n.useCase)e.push(`Use case: ${n.useCase}`);if(n.structure)e.push(`Structure: ${n.structure}`);if(n.references)e.push(`References: ${n.references}`);if(n.extra)e.push(`Extra: ${n.extra}`);if(e.length>0){let M=e.join(". ");r=r?`${r}. ${M}`:M}let m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),u=n.format||"mp3";Vt(u,Jt);let _=n.out??`music_${m}.${u}`,c=n.model||Qi(t);if(n.model&&!Rn.includes(c))throw new y(`Invalid model "${c}". Valid models: ${Rn.join(", ")}`,x.USAGE,"mmx music generate --model music-2.6");let w=n.outputFormat||"hex";if(w!=="hex"&&w!=="url")throw new y('--output-format must be "hex" or "url".',x.USAGE,"mmx music generate --output-format url");if(n.stream&&w==="url")throw new y("--stream and --output-format url cannot be used together. Streaming requires hex format.",x.USAGE,"mmx music generate --output-format url");let v={model:c,prompt:r,lyrics:i,is_instrumental:$||void 0,lyrics_optimizer:p||void 0,audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000},output_format:n.stream===!0?"hex":w,stream:n.stream===!0};if(n.aigcWatermark)v.aigc_watermark=!0;if(et(t,v))return;let b=j(t.output),G=rn(t.baseUrl);if(n.stream){let M=await D(t,{url:G,method:"POST",body:v,stream:!0});await Xt(M);return}let q=await B(t,{url:G,method:"POST",body:v});if(!t.quiet)process.stderr.write(`[Model: ${c}]
218
- `);if(w==="url"){if(q.data?.audio_url)console.log(q.data.audio_url);else throw new y("Requested URL output but API did not return audio_url.",x.GENERAL);return}kt(q,_,b,t.quiet)}})});import{readFileSync as Dm}from"fs";var zi;var Ni=s(()=>{Z();J();k();K();Y();xn();_n();cn();ye();zi=S({name:"music cover",description:"Generate a cover version of a song based on reference audio",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model: music-cover (default) or music-cover-free."},{flag:"--prompt <text>",description:'Target cover style, e.g. "Indie folk, acoustic guitar, warm male vocal"'},{flag:"--audio <url>",description:"URL of the reference audio (mp3, wav, flac, etc. — 6s to 6min, max 50MB)"},{flag:"--audio-file <path>",description:"Local reference audio file (auto base64-encoded)"},{flag:"--lyrics <text>",description:"Cover lyrics. If provided, CLI auto-runs cover preprocess first. If omitted, lyrics are extracted from reference audio via ASR."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Triggers cover preprocess automatically."},{flag:"--seed <number>",description:"Random seed 0–1000000 for reproducible results",type:"number"},{flag:"--format <fmt>",description:`Audio format: ${Rt(Jt)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate: 16000, 24000, 32000, 44100 (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate: 32000, 64000, 128000, 256000 (default: 256000)",type:"number"},{flag:"--channel <n>",description:"Channels: 1 (mono) or 2 (stereo, default)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file"}],examples:['mmx music cover --prompt "Indie folk, acoustic guitar, warm male vocal" --audio https://example.com/song.mp3 --out cover.mp3','mmx music cover --prompt "Jazz, piano, slow" --audio-file original.mp3 --lyrics-file lyrics.txt --out jazz_cover.mp3','mmx music cover --prompt "Pop, upbeat" --audio https://example.com/ref.mp3 --seed 42 --out reproducible.mp3','mmx music cover --model music-cover-free --prompt "Jazz, piano, slow" --audio https://example.com/ref.mp3 --out free_cover.mp3'],async run(t,n){let{prompt:r,audio:i,audioFile:$}=n;if(!r)throw new y("--prompt is required.",x.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!i&&!$)throw new y("One of --audio <url> or --audio-file <path> is required.",x.USAGE,"mmx music cover --prompt <text> --audio <url>");if(i&&$)throw new y("Use either --audio or --audio-file, not both.",x.USAGE);let p=n.lyrics;if(n.lyricsFile){let{readTextFromPathOrStdin:h}=await Promise.resolve().then(() => (yn(),ri));p=h(n.lyricsFile)}let e=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),m=n.format||"mp3";Vt(m,Jt);let u=n.out??`cover_${e}.${m}`,_=j(t.output),c=n.model||Zi(t);if(n.model&&!Gn.includes(c))throw new y(`Invalid model "${c}". Valid models: ${Gn.join(", ")}`,x.USAGE,"mmx music cover --model music-cover");let w=i?{audio_url:i}:{audio_base64:Dm($).toString("base64")},v={model:c,prompt:r,lyrics:p,seed:n.seed,audio_setting:{format:m,sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000,channel:n.channel??void 0},output_format:"hex",stream:n.stream===!0,...w},b=Boolean(p?.trim()),G=b?{model:"music-cover",...w}:void 0;if(b)delete v.audio_url,delete v.audio_base64,v.cover_feature_id="__cover_feature_id_from_preprocess__";if(t.dryRun){console.log(A(b?{preprocess_request:G,request:v}:{request:v},_));return}let q=rn(t.baseUrl);if(b){let h=hr(t.baseUrl),V=await B(t,{url:h,method:"POST",body:G});v.cover_feature_id=V.cover_feature_id}if(n.stream){let h=await D(t,{url:q,method:"POST",body:v,stream:!0});await Xt(h);return}let M=await B(t,{url:q,method:"POST",body:v});if(!t.quiet)process.stderr.write(`[Model: ${c}]
219
- `);kt(M,u,_,t.quiet)}})});var _e;var Oi=s(()=>{Z();K();Y();J();k();_e=S({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(t,n){let r=n.q??n.query??n._positional?.[0];if(!r)throw new y("--q is required.",x.USAGE,'mmx search query --q "your search query"');let i=j(t.output);if(t.dryRun){console.log(A({request:{q:r}},i));return}let $=jr(t.baseUrl),p=await B(t,{url:$,method:"POST",body:{q:r}}),e=p.organic||[];if(i!=="text"){console.log(A(p,i));return}if(t.quiet){for(let m of e)console.log(`${m.title} ${m.link}`);return}if(e.length===0){console.log("No results found.");return}for(let m of e){if(console.log(`${m.title}`),console.log(` ${m.link}`),m.snippet)console.log(` ${m.snippet}`);if(m.date)console.log(` ${m.date}`);console.log("")}}})});var Wi;var Hi=s(()=>{Z();K();Y();J();k();mt();sn();Wi=S({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(t,n){let r=n.image??n.file??n.path??n._positional?.[0],i=n.fileId,$=n.prompt||"Describe the image.";if(!r&&!i)if(H({nonInteractive:t.nonInteractive})){let _=await g({message:"Enter image path, URL, or File ID:"});if(!_)process.stderr.write(`Vision describe cancelled.
220
- `),process.exit(1);if(!_.includes(".")&&!_.startsWith("http"))i=_;else r=_}else throw new y("Missing required argument. Must provide either --image or --file-id.",x.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(r&&i)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",x.USAGE);if(et(t,{prompt:$,image:r,fileId:i}))return;let p=j(t.output),e=Br(t.baseUrl),m={prompt:$};if(i)m.file_id=i;else if(r){let _=await Mi(r);m.image_url=_}let u=await B(t,{url:e,method:"POST",body:m});if(p!=="text"){process.stdout.write(A(u,p)+`
214
+ S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. T2V: MiniMax-Hailuo-2.3; I2V: MiniMax-Hailuo-2.3 (default) or MiniMax-Hailuo-2.3-Fast (fast, requires --first-frame). Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image (local path or URL). Auto base64-encoded for local files."},{flag:"--last-frame <path-or-url>",description:"Last frame image (local path or URL). Enables SEF (start-end frame) interpolation mode with Hailuo-02 model. Requires --first-frame."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{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',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --first-frame 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(t,n){let i=n.prompt;if(i=await at({value:i,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:t.nonInteractive}),n.lastFrame&&n.subjectImage)throw new y("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",x.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let r=n.model;if(r==="MiniMax-Hailuo-2.3-Fast"&&!n.firstFrame)throw new y("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --first-frame to provide an input image.",x.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --first-frame <image>");let $;if(r)$=r;else if(n.lastFrame)$="MiniMax-Hailuo-02";else if(n.subjectImage)$="S2V-01";else $=t.defaultVideoModel||"MiniMax-Hailuo-2.3";let p={model:$,prompt:i};if(n.firstFrame)p.first_frame_image=bn(n.firstFrame);if(n.lastFrame){if(!n.firstFrame)throw new y("--last-frame requires --first-frame (SEF mode).",x.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");p.last_frame_image=bn(n.lastFrame)}if(n.subjectImage)p.subject_reference=[{type:"character",image:[bn(n.subjectImage)]}];if(n.callbackUrl)p.callback_url=n.callbackUrl;if(et(t,p))return;let e=j(t.output),m=hi(t.baseUrl),c=(await B(t,{url:m,method:"POST",body:p})).task_id;if(!t.quiet)process.stderr.write(`[Model: ${$}]
215
+ `);if(n.noWait||t.async){process.stdout.write(JSON.stringify({taskId:c})),process.stdout.write(`
216
+ `);return}let _=n.pollInterval??5,w=nn(t.baseUrl,c),v=await hr(t,{url:w,intervalSec:_,timeoutSec:t.timeout,isComplete:(N)=>N.status==="Success",isFailed:(N)=>N.status==="Failed",getStatus:(N)=>N.status});if(!v.file_id)throw new y("Task completed but no file_id returned.",x.GENERAL);let G=(await B(t,{url:en(t.baseUrl,v.file_id)})).file?.download_url;if(!G)throw new y("No download URL available for this file.",x.GENERAL);if(n.download){let N=n.download,{size:U}=await xt(G,N,{quiet:t.quiet});if(t.quiet)console.log(N);else console.log(A({task_id:c,status:"Success",file_id:v.file_id,saved:N,size:wn(U)},e));return}let h=await import("os"),{join:b}=await import("path"),q=b(h.tmpdir(),"mmx-video"),{existsSync:V,mkdirSync:X}=await import("fs");if(!V(q))X(q,{recursive:!0});let Q=b(q,`${c}.mp4`);await xt(G,Q,{quiet:t.quiet}),process.stdout.write(Q),process.stdout.write(`
217
+ `)}})});var kr;var Jr=s(()=>{Z();J();k();K();Y();kr=S({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"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,n){let i=n.taskId;if(!i)throw new y("--task-id is required.",x.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${i}`);return}let r=nn(t.baseUrl,i),$=await B(t,{url:r}),p=j(t.output);if(t.quiet){console.log($.status);return}console.log(A({task_id:$.task_id,status:$.status,file_id:$.file_id,video_width:$.video_width,video_height:$.video_height},p))}})});var Vr;var Xr=s(()=>{Z();J();k();K();vn();Y();Vr=S({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(t,n){let i=n.fileId;if(!i)throw new y("--file-id is required.",x.USAGE,"mmx video download --file-id <id> --out <path>");let r=n.out;if(!r)throw new y("--out is required.",x.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${i} to ${r}`);return}let $=en(t.baseUrl,i),e=(await B(t,{url:$})).file?.download_url;if(!e)throw new y("No download URL available for this file.",x.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await xt(e,r,{quiet:t.quiet}),u=j(t.output);if(t.quiet){console.log(r);return}console.log(A({saved:r,size:wn(m)},u))}})});function Ur(t,n){return t.includes(n)}function Qr(t){if(t.defaultMusicModel&&Ur(Rn,t.defaultMusicModel))return t.defaultMusicModel;return"music-3.0"}function Zr(t){if(t.defaultMusicModel&&Ur(Gn,t.defaultMusicModel))return t.defaultMusicModel;return"music-cover"}var Rn,Gn;var ye=s(()=>{Rn=["music-3.0","music-2.6","music-2.6-free","music-2.5+","music-2.5"],Gn=["music-cover","music-cover-free"]});var Tr;var Yr=s(()=>{Z();J();k();K();Y();xn();yn();cn();_n();ye();Tr=S({name:"music generate",description:"Generate a song (music-3.0)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.'},{flag:"--lyrics <text>",description:"Song lyrics with structure tags (newline separated). Supported: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo]. Tags must be clean — no descriptions inside brackets (they will be sung). Max 3500 chars."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Same tag rules as --lyrics."},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). music-2.6/music-2.5+: native is_instrumental flag; music-2.5: lyrics workaround. Cannot be used with --lyrics."},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz, electronic"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano, strings"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--model <model>",description:"Model: music-3.0 (default), music-2.6, music-2.6-free, music-2.5+, or music-2.5."},{flag:"--output-format <fmt>",description:"Return format: hex (default, saved to file) or url (24h expiry, download promptly). When --stream, only hex."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:`Audio format: ${Rt(Jt)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Auto-generate lyrics from prompt:",'mmx music generate --prompt "Upbeat pop about summer" --lyrics-optimizer --out summer.mp3',"# Instrumental:",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3',"# URL output (24h expiry — download promptly):",'mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --output-format url',"# Instrumental with music-3.0:",'mmx music generate --prompt "Cinematic orchestral" --model "music-3.0" --instrumental --out bgm.mp3',"# Detailed prompt with vocal characteristics:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3'],async run(t,n){let{prompt:i,lyrics:r}=n,$=n.instrumental===!0,p=n.lyricsOptimizer===!0;if(n.lyricsFile)r=Yt(n.lyricsFile);if($&&(r||n.lyricsFile))throw new y("Cannot use --instrumental with --lyrics or --lyrics-file.",x.USAGE,"mmx music generate --prompt <style> --instrumental");if(p&&(r||$))throw new y("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",x.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!i&&!r&&!$&&!p)throw new y("At least one of --prompt or --lyrics is required.",x.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(($||p)&&!i?.trim())throw new y("--prompt is required with --instrumental or --lyrics-optimizer.",x.USAGE,"mmx music generate --prompt <text> --instrumental");if(!$&&!p&&!r?.trim())throw new y("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",x.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let e=[];if(n.vocals)e.push(`Vocals: ${n.vocals}`);if(n.genre)e.push(`Genre: ${n.genre}`);if(n.mood)e.push(`Mood: ${n.mood}`);if(n.instruments)e.push(`Instruments: ${n.instruments}`);if(n.tempo)e.push(`Tempo: ${n.tempo}`);if(n.bpm)e.push(`BPM: ${n.bpm}`);if(n.key)e.push(`Key: ${n.key}`);if(n.avoid)e.push(`Avoid: ${n.avoid}`);if(n.useCase)e.push(`Use case: ${n.useCase}`);if(n.structure)e.push(`Structure: ${n.structure}`);if(n.references)e.push(`References: ${n.references}`);if(n.extra)e.push(`Extra: ${n.extra}`);if(e.length>0){let b=e.join(". ");i=i?`${i}. ${b}`:b}let m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),u=n.format||"mp3";Vt(u,Jt);let c=n.out??`music_${m}.${u}`,_=n.model||Qr(t);if(n.model&&!Rn.includes(_))throw new y(`Invalid model "${_}". Valid models: ${Rn.join(", ")}`,x.USAGE,"mmx music generate --model music-3.0");let w=n.outputFormat||"hex";if(w!=="hex"&&w!=="url")throw new y('--output-format must be "hex" or "url".',x.USAGE,"mmx music generate --output-format url");if(n.stream&&w==="url")throw new y("--stream and --output-format url cannot be used together. Streaming requires hex format.",x.USAGE,"mmx music generate --output-format url");let v={model:_,prompt:i,lyrics:r,is_instrumental:$||void 0,lyrics_optimizer:p||void 0,audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000},output_format:n.stream===!0?"hex":w,stream:n.stream===!0};if(n.aigcWatermark)v.aigc_watermark=!0;if(et(t,v))return;let M=j(t.output),G=rn(t.baseUrl);if(n.stream){let b=await D(t,{url:G,method:"POST",body:v,stream:!0});await Xt(b);return}let h=await B(t,{url:G,method:"POST",body:v});if(!t.quiet)process.stderr.write(`[Model: ${_}]
218
+ `);if(w==="url"){if(h.data?.audio_url)console.log(h.data.audio_url);else throw new y("Requested URL output but API did not return audio_url.",x.GENERAL);return}kt(h,c,M,t.quiet)}})});import{readFileSync as Dm}from"fs";var zr;var Nr=s(()=>{Z();J();k();K();Y();xn();cn();_n();ye();zr=S({name:"music cover",description:"Generate a cover version of a song based on reference audio",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model: music-cover (default) or music-cover-free."},{flag:"--prompt <text>",description:'Target cover style, e.g. "Indie folk, acoustic guitar, warm male vocal"'},{flag:"--audio <url>",description:"URL of the reference audio (mp3, wav, flac, etc. — 6s to 6min, max 50MB)"},{flag:"--audio-file <path>",description:"Local reference audio file (auto base64-encoded)"},{flag:"--lyrics <text>",description:"Cover lyrics. If provided, CLI auto-runs cover preprocess first. If omitted, lyrics are extracted from reference audio via ASR."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Triggers cover preprocess automatically."},{flag:"--seed <number>",description:"Random seed 0–1000000 for reproducible results",type:"number"},{flag:"--format <fmt>",description:`Audio format: ${Rt(Jt)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate: 16000, 24000, 32000, 44100 (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate: 32000, 64000, 128000, 256000 (default: 256000)",type:"number"},{flag:"--channel <n>",description:"Channels: 1 (mono) or 2 (stereo, default)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file"}],examples:['mmx music cover --prompt "Indie folk, acoustic guitar, warm male vocal" --audio https://example.com/song.mp3 --out cover.mp3','mmx music cover --prompt "Jazz, piano, slow" --audio-file original.mp3 --lyrics-file lyrics.txt --out jazz_cover.mp3','mmx music cover --prompt "Pop, upbeat" --audio https://example.com/ref.mp3 --seed 42 --out reproducible.mp3','mmx music cover --model music-cover-free --prompt "Jazz, piano, slow" --audio https://example.com/ref.mp3 --out free_cover.mp3'],async run(t,n){let{prompt:i,audio:r,audioFile:$}=n;if(!i)throw new y("--prompt is required.",x.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!r&&!$)throw new y("One of --audio <url> or --audio-file <path> is required.",x.USAGE,"mmx music cover --prompt <text> --audio <url>");if(r&&$)throw new y("Use either --audio or --audio-file, not both.",x.USAGE);let p=n.lyrics;if(n.lyricsFile){let{readTextFromPathOrStdin:q}=await Promise.resolve().then(() => (yn(),ir));p=q(n.lyricsFile)}let e=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),m=n.format||"mp3";Vt(m,Jt);let u=n.out??`cover_${e}.${m}`,c=j(t.output),_=n.model||Zr(t);if(n.model&&!Gn.includes(_))throw new y(`Invalid model "${_}". Valid models: ${Gn.join(", ")}`,x.USAGE,"mmx music cover --model music-cover");let w=r?{audio_url:r}:{audio_base64:Dm($).toString("base64")},v={model:_,prompt:i,lyrics:p,seed:n.seed,audio_setting:{format:m,sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000,channel:n.channel??void 0},output_format:"hex",stream:n.stream===!0,...w},M=Boolean(p?.trim()),G=M?{model:"music-cover",...w}:void 0;if(M)delete v.audio_url,delete v.audio_base64,v.cover_feature_id="__cover_feature_id_from_preprocess__";if(t.dryRun){console.log(A(M?{preprocess_request:G,request:v}:{request:v},c));return}let h=rn(t.baseUrl);if(M){let q=qi(t.baseUrl),V=await B(t,{url:q,method:"POST",body:G});v.cover_feature_id=V.cover_feature_id}if(n.stream){let q=await D(t,{url:h,method:"POST",body:v,stream:!0});await Xt(q);return}let b=await B(t,{url:h,method:"POST",body:v});if(!t.quiet)process.stderr.write(`[Model: ${_}]
219
+ `);kt(b,u,c,t.quiet)}})});var ce;var Or=s(()=>{Z();K();Y();J();k();ce=S({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(t,n){let i=n.q??n.query??n._positional?.[0];if(!i)throw new y("--q is required.",x.USAGE,'mmx search query --q "your search query"');let r=j(t.output);if(t.dryRun){console.log(A({request:{q:i}},r));return}let $=ji(t.baseUrl),p=await B(t,{url:$,method:"POST",body:{q:i}}),e=p.organic||[];if(r!=="text"){console.log(A(p,r));return}if(t.quiet){for(let m of e)console.log(`${m.title} ${m.link}`);return}if(e.length===0){console.log("No results found.");return}for(let m of e){if(console.log(`${m.title}`),console.log(` ${m.link}`),m.snippet)console.log(` ${m.snippet}`);if(m.date)console.log(` ${m.date}`);console.log("")}}})});var Wr;var Hr=s(()=>{Z();K();Y();J();k();mt();sn();Wr=S({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(t,n){let i=n.image??n.file??n.path??n._positional?.[0],r=n.fileId,$=n.prompt||"Describe the image.";if(!i&&!r)if(H({nonInteractive:t.nonInteractive})){let c=await g({message:"Enter image path, URL, or File ID:"});if(!c)process.stderr.write(`Vision describe cancelled.
220
+ `),process.exit(1);if(!c.includes(".")&&!c.startsWith("http"))r=c;else i=c}else throw new y("Missing required argument. Must provide either --image or --file-id.",x.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(i&&r)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",x.USAGE);if(et(t,{prompt:$,image:i,fileId:r}))return;let p=j(t.output),e=Bi(t.baseUrl),m={prompt:$};if(r)m.file_id=r;else if(i){let c=await br(i);m.image_url=c}let u=await B(t,{url:e,method:"POST",body:m});if(p!=="text"){process.stdout.write(A(u,p)+`
221
221
  `);return}process.stdout.write(u.content+`
222
- `)}})});var Ki;var Ii=s(()=>{Z();K();Y();pn();Ki=S({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(t,n){if(t.dryRun){console.log("Would fetch quota information.");return}let r=st(t.baseUrl),i=await B(t,{url:r}),$=i.model_remains||[],p=j(n.output);if(p!=="text"){console.log(A(i,p));return}if(t.quiet){for(let e of $){let m=e.current_interval_total_count-e.current_interval_usage_count;console.log(`${e.model_name} ${e.current_interval_usage_count} ${e.current_interval_total_count} ${m}`)}return}jt($,t)}})});var Pi;var di=s(()=>{Z();rt();At();Y();Pi=S({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,n){let r=z(),i=j(t.output),$={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:nt()};if(r.api_key)$.api_key=E(r.api_key);if(r.default_text_model)$.default_text_model=r.default_text_model;if(r.default_speech_model)$.default_speech_model=r.default_speech_model;if(r.default_video_model)$.default_video_model=r.default_video_model;if(r.default_music_model)$.default_music_model=r.default_music_model;if(r.proxy)$.proxy=r.proxy;console.log(A($,i))}})});function Ei(t,n){return t==="api_key"?E(String(n)):n}var li,to,Li;var Ci=s(()=>{Z();J();k();Y();rt();li=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model","default_music_model"],to={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"};Li=S({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, default_music_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(t,n){let r=n._positional,i=n.key??r?.[0],$=n.value??r?.[1];if(!i||$===void 0)throw new y("--key and --value are required.",x.USAGE,"mmx config set --key <key> --value <value>");let p=to[i]||i;if(!li.includes(p))throw new y(`Invalid config key "${i}". Valid keys: ${li.join(", ")}`,x.USAGE);let e=p==="api_key"?$.trim():$;if(p==="api_key"&&e.length===0)throw new y("Invalid api_key. The value must not be empty.",x.USAGE);if(p==="region"&&!["global","cn"].includes($))throw new y(`Invalid region "${$}". Valid values: global, cn`,x.USAGE);if(p==="output"&&!["text","json"].includes($))throw new y(`Invalid output format "${$}". Valid values: text, json`,x.USAGE);if(p==="base_url"&&!$.startsWith("http"))throw new y(`Invalid base_url "${$}". Must start with http.`,x.USAGE);if(p==="proxy"&&!$.startsWith("http"))throw new y(`Invalid proxy "${$}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,x.USAGE);if(p==="timeout"){let _=Number($);if(isNaN(_)||_<=0)throw new y(`Invalid timeout "${$}". Must be a positive number.`,x.USAGE)}let m=j(t.output);if(t.dryRun){console.log(A({would_set:{[p]:Ei(p,e)}},m));return}let u=z();if(u[p]=p==="timeout"?Number(e):e,p==="api_key")delete u.oauth,delete u.region;if(await P(u),!t.quiet)console.log(A({[p]:Ei(p,u[p])},m))}})});function no(t){let n=t.match(/^--([a-zA-Z0-9-]+)/),r=n?n[1]:"",i=r.replace(/-([a-zA-Z0-9])/g,(e,m)=>m.toUpperCase()),$="string",p=!1;if(!t.includes("<")&&!t.includes("["))$="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))$="number";if(t.toLowerCase().includes("repeatable"))p=!0;return{name:i,kebabName:r,inferredType:$,isArray:p}}function ce(t){let r={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let i of t.options){let{name:$,inferredType:p,isArray:e}=no(i.flag);if(!$)continue;let m=i.type,u=e?"array":m??p,_={description:i.description};if(u==="array")_.type="array",_.items={type:"string"};else _.type=u;let c=r.input_schema;if(c.properties[$]=_,i.required)c.required.push($)}return r}var eo,ai;var fi=s(()=>{Z();on();J();k();eo=["auth ","config ","update"],ai=S({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(t,n){let r=n.command;if(r){try{let{command:p}=it.resolve(r.split(" ")),e=ce(p);process.stdout.write(JSON.stringify(e,null,2)+`
223
- `)}catch{throw new y(`Command "${r}" not found.`,x.USAGE)}return}let $=it.getAllCommands().filter((p)=>!eo.some((e)=>p.name.startsWith(e))).map((p)=>ce(p));process.stdout.write(JSON.stringify($,null,2)+`
224
- `)}})});import{existsSync as ro}from"fs";import{readFile as io}from"fs/promises";import{resolve as $o,basename as po}from"path";var Fi;var gi=s(()=>{Z();J();k();K();Y();mt();Fi=S({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(t,n){let r=n.file;if(!r)if(H({nonInteractive:t.nonInteractive})){if(r=await g({message:"Enter file path:"}),!r)process.stderr.write(`Upload cancelled.
225
- `),process.exit(1)}else bt("file","mmx file upload --file <path>");let i=$o(r);if(!ro(i))throw new y(`File not found: ${i}`,x.USAGE);let $=n.purpose||"retrieval",p=j(t.output);if(t.dryRun){process.stdout.write(A({request:{file:i,purpose:$}},p)+`
226
- `);return}let e=new FormData,m=await io(i),u=po(i),_=new Blob([m]);e.append("file",_,u),e.append("purpose",$);let c=kr(t.baseUrl),w=await B(t,{url:c,method:"POST",body:e});if(t.quiet){process.stdout.write(w.file.file_id+`
222
+ `)}})});var Kr;var Ir=s(()=>{Z();K();Y();pn();Kr=S({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(t,n){if(t.dryRun){console.log("Would fetch quota information.");return}let i=st(t.baseUrl),r=await B(t,{url:i}),$=r.model_remains||[],p=j(n.output);if(p!=="text"){console.log(A(r,p));return}if(t.quiet){for(let e of $){let m=e.current_interval_total_count-e.current_interval_usage_count;console.log(`${e.model_name} ${e.current_interval_usage_count} ${e.current_interval_total_count} ${m}`)}return}jt($,t)}})});var Pr;var dr=s(()=>{Z();it();At();Y();Pr=S({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,n){let i=z(),r=j(t.output),$={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:nt()};if(i.api_key)$.api_key=E(i.api_key);if(i.default_text_model)$.default_text_model=i.default_text_model;if(i.default_speech_model)$.default_speech_model=i.default_speech_model;if(i.default_video_model)$.default_video_model=i.default_video_model;if(i.default_music_model)$.default_music_model=i.default_music_model;if(i.proxy)$.proxy=i.proxy;console.log(A($,r))}})});function Er(t,n){return t==="api_key"?E(String(n)):n}var lr,to,Lr;var Cr=s(()=>{Z();J();k();Y();it();lr=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model","default_music_model"],to={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"};Lr=S({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, default_music_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(t,n){let i=n._positional,r=n.key??i?.[0],$=n.value??i?.[1];if(!r||$===void 0)throw new y("--key and --value are required.",x.USAGE,"mmx config set --key <key> --value <value>");let p=to[r]||r;if(!lr.includes(p))throw new y(`Invalid config key "${r}". Valid keys: ${lr.join(", ")}`,x.USAGE);let e=p==="api_key"?$.trim():$;if(p==="api_key"&&e.length===0)throw new y("Invalid api_key. The value must not be empty.",x.USAGE);if(p==="region"&&!["global","cn"].includes($))throw new y(`Invalid region "${$}". Valid values: global, cn`,x.USAGE);if(p==="output"&&!["text","json"].includes($))throw new y(`Invalid output format "${$}". Valid values: text, json`,x.USAGE);if(p==="base_url"&&!$.startsWith("http"))throw new y(`Invalid base_url "${$}". Must start with http.`,x.USAGE);if(p==="proxy"&&!$.startsWith("http"))throw new y(`Invalid proxy "${$}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,x.USAGE);if(p==="timeout"){let c=Number($);if(isNaN(c)||c<=0)throw new y(`Invalid timeout "${$}". Must be a positive number.`,x.USAGE)}let m=j(t.output);if(t.dryRun){console.log(A({would_set:{[p]:Er(p,e)}},m));return}let u=z();if(u[p]=p==="timeout"?Number(e):e,p==="api_key")delete u.oauth,delete u.region;if(await P(u),!t.quiet)console.log(A({[p]:Er(p,u[p])},m))}})});function no(t){let n=t.match(/^--([a-zA-Z0-9-]+)/),i=n?n[1]:"",r=i.replace(/-([a-zA-Z0-9])/g,(e,m)=>m.toUpperCase()),$="string",p=!1;if(!t.includes("<")&&!t.includes("["))$="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))$="number";if(t.toLowerCase().includes("repeatable"))p=!0;return{name:r,kebabName:i,inferredType:$,isArray:p}}function _e(t){let i={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let r of t.options){let{name:$,inferredType:p,isArray:e}=no(r.flag);if(!$)continue;let m=r.type,u=e?"array":m??p,c={description:r.description};if(u==="array")c.type="array",c.items={type:"string"};else c.type=u;let _=i.input_schema;if(_.properties[$]=c,r.required)_.required.push($)}return i}var eo,ar;var Fr=s(()=>{Z();on();J();k();eo=["auth ","config ","update"],ar=S({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(t,n){let i=n.command;if(i){try{let{command:p}=rt.resolve(i.split(" ")),e=_e(p);process.stdout.write(JSON.stringify(e,null,2)+`
223
+ `)}catch{throw new y(`Command "${i}" not found.`,x.USAGE)}return}let $=rt.getAllCommands().filter((p)=>!eo.some((e)=>p.name.startsWith(e))).map((p)=>_e(p));process.stdout.write(JSON.stringify($,null,2)+`
224
+ `)}})});import{existsSync as io}from"fs";import{readFile as ro}from"fs/promises";import{resolve as $o,basename as po}from"path";var fr;var gr=s(()=>{Z();J();k();K();Y();mt();fr=S({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(t,n){let i=n.file;if(!i)if(H({nonInteractive:t.nonInteractive})){if(i=await g({message:"Enter file path:"}),!i)process.stderr.write(`Upload cancelled.
225
+ `),process.exit(1)}else Mt("file","mmx file upload --file <path>");let r=$o(i);if(!io(r))throw new y(`File not found: ${r}`,x.USAGE);let $=n.purpose||"retrieval",p=j(t.output);if(t.dryRun){process.stdout.write(A({request:{file:r,purpose:$}},p)+`
226
+ `);return}let e=new FormData,m=await ro(r),u=po(r),c=new Blob([m]);e.append("file",c,u),e.append("purpose",$);let _=ki(t.baseUrl),w=await B(t,{url:_,method:"POST",body:e});if(t.quiet){process.stdout.write(w.file.file_id+`
227
227
  `);return}process.stdout.write(A(w.file,p)+`
228
- `)}})});var Di;var t$=s(()=>{Z();K();Y();Di=S({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(t,n){let r=j(t.output);if(t.dryRun){process.stdout.write(`Would list uploaded files.
229
- `);return}let i=Jr(t.baseUrl),$=await B(t,{url:i,method:"GET"});if(r!=="text"){process.stdout.write(A($,r)+`
228
+ `)}})});var Dr;var t$=s(()=>{Z();K();Y();Dr=S({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(t,n){let i=j(t.output);if(t.dryRun){process.stdout.write(`Would list uploaded files.
229
+ `);return}let r=Ji(t.baseUrl),$=await B(t,{url:r,method:"GET"});if(i!=="text"){process.stdout.write(A($,i)+`
230
230
  `);return}if(!$.files||$.files.length===0){process.stdout.write(`No files found.
231
- `);return}let p=$.files.map((m)=>({ID:m.file_id,FILENAME:m.filename,PURPOSE:m.purpose,SIZE_KB:(m.bytes/1024).toFixed(1),CREATED:new Date(m.created_at*1000).toISOString().slice(0,16).replace("T"," ")})),{formatTable:e}=await Promise.resolve().then(() => he);process.stdout.write(e(p)+`
232
- `)}})});var n$;var e$=s(()=>{Z();K();Y();mt();n$=S({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(t,n){let r=n.fileId;if(!r)if(H({nonInteractive:t.nonInteractive})){if(r=await g({message:"Enter file ID to delete:"}),!r)process.stderr.write(`Delete cancelled.
233
- `),process.exit(1)}else bt("file-id","mmx file delete --file-id <id>");let i=j(t.output);if(t.dryRun){process.stdout.write(A({request:{delete_file:r}},i)+`
234
- `);return}let $=Vr(t.baseUrl),p=await B(t,{url:$,method:"POST",body:{file_id:Number(r)}});if(t.quiet){process.stdout.write(`deleted
235
- `);return}process.stdout.write(A({file_id:p.file_id,deleted:!0},i)+`
236
- `)}})});var r$;var i$=s(()=>{Z();Dt();r$=S({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${Mt}
231
+ `);return}let p=$.files.map((m)=>({ID:m.file_id,FILENAME:m.filename,PURPOSE:m.purpose,SIZE_KB:(m.bytes/1024).toFixed(1),CREATED:new Date(m.created_at*1000).toISOString().slice(0,16).replace("T"," ")})),{formatTable:e}=await Promise.resolve().then(() => qe);process.stdout.write(e(p)+`
232
+ `)}})});var n$;var e$=s(()=>{Z();K();Y();mt();n$=S({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(t,n){let i=n.fileId;if(!i)if(H({nonInteractive:t.nonInteractive})){if(i=await g({message:"Enter file ID to delete:"}),!i)process.stderr.write(`Delete cancelled.
233
+ `),process.exit(1)}else Mt("file-id","mmx file delete --file-id <id>");let r=j(t.output);if(t.dryRun){process.stdout.write(A({request:{delete_file:i}},r)+`
234
+ `);return}let $=Vi(t.baseUrl),p=await B(t,{url:$,method:"POST",body:{file_id:Number(i)}});if(t.quiet){process.stdout.write(`deleted
235
+ `);return}process.stdout.write(A({file_id:p.file_id,deleted:!0},r)+`
236
+ `)}})});var i$;var r$=s(()=>{Z();Dt();i$=S({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${bt}
237
237
 
238
238
  `),process.stderr.write(`Run:
239
239
  `),process.stderr.write(` npm update -g mmx-cli
240
240
 
241
- `)}})});var mo,$$;var p$=s(()=>{Z();tt();mo=[{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 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 music generate",title:"Music Generation",path:"/docs/api-reference/music-generation"},{command:"mmx music cover",title:"Music Cover (via Music Generation)",path:"/docs/api-reference/music-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"}],$$=S({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(t,n){let r=Ut[t.region]||Ut.global;process.stdout.write(`
241
+ `)}})});var mo,$$;var p$=s(()=>{Z();tt();mo=[{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 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 music generate",title:"Music Generation",path:"/docs/api-reference/music-generation"},{command:"mmx music cover",title:"Music Cover (via Music Generation)",path:"/docs/api-reference/music-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"}],$$=S({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(t,n){let i=Ut[t.region]||Ut.global;process.stdout.write(`
242
242
  MiniMax API Documentation Links
243
243
 
244
- Official docs: ${r}/docs/api-reference
244
+ Official docs: ${i}/docs/api-reference
245
245
 
246
- `);for(let i of mo)process.stdout.write(` ${i.command.padEnd(30)} ${i.title}
247
- `),process.stdout.write(` ${" ".repeat(30)} ${r}${i.path}
246
+ `);for(let r of mo)process.stdout.write(` ${r.command.padEnd(30)} ${r.title}
247
+ `),process.stdout.write(` ${" ".repeat(30)} ${i}${r.path}
248
248
 
249
- `)}})});var Hr={};Ot(Hr,{registry:()=>it});class m${root={children:new Map};constructor(t){for(let[n,r]of Object.entries(t))this.register(n,r)}register(t,n){let r=t.split(" "),i=this.root;for(let $ of r){if(!i.children.has($))i.children.set($,{children:new Map});i=i.children.get($)}i.command=n}getAllCommands(){let t=[],n=(r)=>{if(r.command)t.push(r.command);for(let i of r.children.values())n(i)};return n(this.root),t}resolve(t){let n=this.root,r=[];for(let i of t){let $=n.children.get(i);if(!$)break;n=$,r.push(i)}if(n.command)return{command:n.command,extra:t.slice(r.length)};if(r.length>0&&n.children.size===1){let[,i]=n.children.entries().next().value;if(i.command)return{command:i.command,extra:t.slice(r.length)}}if(r.length>0&&n.children.size>1){let $=Array.from(n.children.values()).map((e)=>e.command),p=$[0];if(p&&$.every((e)=>e===p))return{command:p,extra:t.slice(r.length)}}if(r.length>0&&n.children.size>0){let i=Array.from(n.children.entries()).map(([$,p])=>{if(p.command)return` ${r.join(" ")} ${$} ${p.command.description}`;let e=Array.from(p.children.keys()).join(", ");return` ${r.join(" ")} ${$} [${e}]`}).join(`
249
+ `)}})});var Hi={};Ot(Hi,{registry:()=>rt});class m${root={children:new Map};constructor(t){for(let[n,i]of Object.entries(t))this.register(n,i)}register(t,n){let i=t.split(" "),r=this.root;for(let $ of i){if(!r.children.has($))r.children.set($,{children:new Map});r=r.children.get($)}r.command=n}getAllCommands(){let t=[],n=(i)=>{if(i.command)t.push(i.command);for(let r of i.children.values())n(r)};return n(this.root),t}resolve(t){let n=this.root,i=[];for(let r of t){let $=n.children.get(r);if(!$)break;n=$,i.push(r)}if(n.command)return{command:n.command,extra:t.slice(i.length)};if(i.length>0&&n.children.size===1){let[,r]=n.children.entries().next().value;if(r.command)return{command:r.command,extra:t.slice(i.length)}}if(i.length>0&&n.children.size>1){let $=Array.from(n.children.values()).map((e)=>e.command),p=$[0];if(p&&$.every((e)=>e===p))return{command:p,extra:t.slice(i.length)}}if(i.length>0&&n.children.size>0){let r=Array.from(n.children.entries()).map(([$,p])=>{if(p.command)return` ${i.join(" ")} ${$} ${p.command.description}`;let e=Array.from(p.children.keys()).join(", ");return` ${i.join(" ")} ${$} [${e}]`}).join(`
250
250
  `);throw new y(`Unknown command: mmx ${t.join(" ")}
251
251
 
252
252
  Available commands:
253
- ${i}`,x.USAGE,`mmx ${r.join(" ")} --help`)}throw new y(`Unknown command: mmx ${t.join(" ")}`,x.USAGE,"mmx --help")}bold=(t,n)=>n.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,n)=>n.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,n)=>n.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,n=process.stdout,r="global"){if(t.length===0){this.printRootHelp(n);return}let i=this.root;for(let p of t){let e=i.children.get(p);if(!e){this.printRootHelp(n);return}i=e}if(i.command){this.printCommandHelp(i.command,n,r);return}let $=t.join(" ");n.write(`
253
+ ${r}`,x.USAGE,`mmx ${i.join(" ")} --help`)}throw new y(`Unknown command: mmx ${t.join(" ")}`,x.USAGE,"mmx --help")}bold=(t,n)=>n.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,n)=>n.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,n)=>n.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,n=process.stdout,i="global"){if(t.length===0){this.printRootHelp(n);return}let r=this.root;for(let p of t){let e=r.children.get(p);if(!e){this.printRootHelp(n);return}r=e}if(r.command){this.printCommandHelp(r.command,n,i);return}let $=t.join(" ");n.write(`
254
254
  ${this.bold("Usage:",n)} mmx ${$} <command> [flags]
255
255
 
256
256
  `),n.write(`${this.bold("Commands:",n)}
257
- `),this.printChildren(i,$,n),n.write(`
258
- `)}printRootHelp(t){let n=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],r=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
259
- `);for(let e=0;e<n.length;e++)if(t.isTTY){let[m,u,_]=r[e];t.write(`\x1B[1;38;2;${m};${u};${_}m${n[e]}\x1B[0m
257
+ `),this.printChildren(r,$,n),n.write(`
258
+ `)}printRootHelp(t){let n=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],i=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
259
+ `);for(let e=0;e<n.length;e++)if(t.isTTY){let[m,u,c]=i[e];t.write(`\x1B[1;38;2;${m};${u};${c}m${n[e]}\x1B[0m
260
260
  `)}else t.write(n[e]+`
261
- `);let i=(e)=>this.bold(e,t),$=(e)=>this.accent(e,t),p=(e)=>this.dim(e,t);t.write(`
262
- ${i("Usage:")} mmx <resource> <command> [flags]
261
+ `);let r=(e)=>this.bold(e,t),$=(e)=>this.accent(e,t),p=(e)=>this.dim(e,t);t.write(`
262
+ ${r("Usage:")} mmx <resource> <command> [flags]
263
263
 
264
- ${i("Resources:")}
264
+ ${r("Resources:")}
265
265
  ${$("auth")} ${p("Authentication (login, status, refresh, logout)")}
266
266
  ${$("text")} ${p("Text generation (chat)")}
267
267
  ${$("speech")} ${p("Speech synthesis (synthesize, voices)")}
@@ -275,7 +275,7 @@ ${i("Resources:")}
275
275
  ${$("file")} ${p("File storage (upload, list, delete)")}
276
276
  ${$("update")} ${p("Update mmx to a newer version")}
277
277
 
278
- ${i("Global Flags:")}
278
+ ${r("Global Flags:")}
279
279
  ${$("--api-key <key>")} ${p("API key (overrides all other auth)")}
280
280
  ${$("--region <region>")} ${p("API region: global (default), cn")}
281
281
  ${$("--base-url <url>")} ${p("API base URL (overrides region)")}
@@ -289,25 +289,25 @@ ${i("Global Flags:")}
289
289
  ${$("--version")} ${p("Print version and exit")}
290
290
  ${$("--help")} ${p("Show help")}
291
291
 
292
- ${i("Getting Help:")}
292
+ ${r("Getting Help:")}
293
293
  ${p("Add --help after any command to see its full list of options, defaults,")}
294
294
  ${p("and usage examples. For example:")} mmx text chat --help
295
- `)}printCommandHelp(t,n,r="global"){let i=(e)=>this.bold(e,n),$=(e)=>this.accent(e,n),p=(e)=>this.dim(e,n);if(n.write(`
295
+ `)}printCommandHelp(t,n,i="global"){let r=(e)=>this.bold(e,n),$=(e)=>this.accent(e,n),p=(e)=>this.dim(e,n);if(n.write(`
296
296
  ${t.description}
297
- `),t.usage)n.write(`${i("Usage:")} ${t.usage}
297
+ `),t.usage)n.write(`${r("Usage:")} ${t.usage}
298
298
  `);if(t.options&&t.options.length>0){let e=Math.max(...t.options.map((m)=>m.flag.length));n.write(`
299
- ${i("Options:")}
299
+ ${r("Options:")}
300
300
  `);for(let m of t.options)n.write(` ${$(m.flag.padEnd(e+2))} ${p(m.description)}
301
301
  `)}if(t.examples&&t.examples.length>0){n.write(`
302
- ${i("Examples:")}
302
+ ${r("Examples:")}
303
303
  `);for(let e of t.examples)n.write(` ${p(e)}
304
304
  `)}if(t.apiDocs)n.write(`
305
- ${i("API Reference:")} ${p(Ut[r]+t.apiDocs)}
305
+ ${r("API Reference:")} ${p(Ut[i]+t.apiDocs)}
306
306
  `);n.write(`
307
307
  ${p("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
308
308
  `),n.write(`${p("Run")} mmx --help ${p("for the full list.")}
309
- `)}printChildren(t,n,r){let i=[],$=(e,m)=>{for(let[u,_]of e.children){if(_.command)i.push({fullName:`${m} ${u}`,description:_.command.description});if(_.children.size>0)$(_,`${m} ${u}`)}};$(t,n);let p=Math.max(...i.map((e)=>e.fullName.length));for(let{fullName:e,description:m}of i)r.write(` ${this.accent(e.padEnd(p),r)} ${this.dim(m,r)}
310
- `)}}var it;var on=s(()=>{J();k();tt();Wr();Ir();dr();Er();Fr();ei();ui();yi();Ai();Bi();Ji();Xi();Yi();Ni();Oi();Hi();Ii();di();Ci();fi();gi();t$();e$();i$();p$();it=new m$({"auth login":Or,"auth status":Kr,"auth refresh":Pr,"auth logout":lr,"text chat":fr,"text repl":ni,"speech synthesize":oe,"speech generate":oe,"speech voices":xi,"image generate":Si,"video generate":ji,"video task get":ki,"video download":Vi,"music generate":Ti,"music cover":zi,"search query":_e,"search web":_e,"vision describe":Wi,"quota show":Ki,"config show":Pi,"config set":Li,"config export-schema":ai,"file upload":Fi,"file list":Di,"file delete":n$,update:r$,help:$$})});var A$=new Set(["true","1","yes","on"]),q$=new Set(["false","0","no","off"]);function qn(t){return t.replace(/-([a-z])/g,(n,r)=>r.toUpperCase())}function h$(t){let n=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return n?qn(n[1]):null}function j$(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function Me(t){let n=new Set,r=new Set,i=new Set;for(let $ of t){let p=h$($);if(!p)continue;if(j$($))n.add(p);else if($.type==="number")r.add(p);else if($.type==="array")i.add(p)}return{booleans:n,numbers:r,arrays:i}}function se(t,n=[]){let r=Me(n),i=[],$=0;while($<t.length){let p=t[$];if(p==="--")break;if(p.startsWith("--")){let e=p.indexOf("="),m=e!==-1?p.slice(2,e):p.slice(2),u=qn(m);if(!r.booleans.has(u)&&e===-1)$+=2;else $+=1;continue}if(p.startsWith("-")){$++;continue}i.push(p),$++}return i}function hn(t,n){let r=Me(n),i={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},$=0;while($<t.length){let p=t[$];if(p==="--help"||p==="-h"){i.help=!0,$++;continue}if(p==="--")break;if(p.startsWith("--")){let e=p.indexOf("="),m,u;if(e!==-1)m=p.slice(2,e),u=p.slice(e+1);else m=p.slice(2);let _=qn(m);if(r.booleans.has(_)){if(u===void 0)i[_]=!0;else{let c=u.trim().toLowerCase();if(A$.has(c))i[_]=!0;else if(q$.has(c))i[_]=!1;else throw Error(`Flag --${m} requires a boolean value (e.g. true/false), got "${u}".`)}$++;continue}if(u===void 0)$++,u=t[$];if(u===void 0)throw Error(`Flag --${m} requires a value.`);if(r.arrays.has(_)){let c=i[_];if(c)c.push(u);else i[_]=[u]}else if(r.numbers.has(_)){let c=Number(u);if(u.trim()===""||!Number.isFinite(c))throw Error(`Flag --${m} requires a numeric value, got "${u}".`);i[_]=c}else i[_]=u}$++}return i}on();Z();J();k();Y();function Gt(t){if(t instanceof y){if(j(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
309
+ `)}printChildren(t,n,i){let r=[],$=(e,m)=>{for(let[u,c]of e.children){if(c.command)r.push({fullName:`${m} ${u}`,description:c.command.description});if(c.children.size>0)$(c,`${m} ${u}`)}};$(t,n);let p=Math.max(...r.map((e)=>e.fullName.length));for(let{fullName:e,description:m}of r)i.write(` ${this.accent(e.padEnd(p),i)} ${this.dim(m,i)}
310
+ `)}}var rt;var on=s(()=>{J();k();tt();Wi();Ii();di();Ei();fi();er();ur();yr();Ar();Br();Jr();Xr();Yr();Nr();Or();Hr();Ir();dr();Cr();Fr();gr();t$();e$();r$();p$();rt=new m$({"auth login":Oi,"auth status":Ki,"auth refresh":Pi,"auth logout":li,"text chat":Fi,"text repl":nr,"speech synthesize":oe,"speech generate":oe,"speech voices":xr,"image generate":Sr,"video generate":jr,"video task get":kr,"video download":Vr,"music generate":Tr,"music cover":zr,"search query":ce,"search web":ce,"vision describe":Wr,"quota show":Kr,"config show":Pr,"config set":Lr,"config export-schema":ar,"file upload":fr,"file list":Dr,"file delete":n$,update:i$,help:$$})});var A$=new Set(["true","1","yes","on"]),h$=new Set(["false","0","no","off"]);function hn(t){return t.replace(/-([a-z])/g,(n,i)=>i.toUpperCase())}function q$(t){let n=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return n?hn(n[1]):null}function j$(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function be(t){let n=new Set,i=new Set,r=new Set;for(let $ of t){let p=q$($);if(!p)continue;if(j$($))n.add(p);else if($.type==="number")i.add(p);else if($.type==="array")r.add(p)}return{booleans:n,numbers:i,arrays:r}}function se(t,n=[]){let i=be(n),r=[],$=0;while($<t.length){let p=t[$];if(p==="--")break;if(p.startsWith("--")){let e=p.indexOf("="),m=e!==-1?p.slice(2,e):p.slice(2),u=hn(m);if(!i.booleans.has(u)&&e===-1)$+=2;else $+=1;continue}if(p.startsWith("-")){$++;continue}r.push(p),$++}return r}function qn(t,n){let i=be(n),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},$=0;while($<t.length){let p=t[$];if(p==="--help"||p==="-h"){r.help=!0,$++;continue}if(p==="--")break;if(p.startsWith("--")){let e=p.indexOf("="),m,u;if(e!==-1)m=p.slice(2,e),u=p.slice(e+1);else m=p.slice(2);let c=hn(m);if(i.booleans.has(c)){if(u===void 0)r[c]=!0;else{let _=u.trim().toLowerCase();if(A$.has(_))r[c]=!0;else if(h$.has(_))r[c]=!1;else throw Error(`Flag --${m} requires a boolean value (e.g. true/false), got "${u}".`)}$++;continue}if(u===void 0)$++,u=t[$];if(u===void 0)throw Error(`Flag --${m} requires a value.`);if(i.arrays.has(c)){let _=r[c];if(_)_.push(u);else r[c]=[u]}else if(i.numbers.has(c)){let _=Number(u);if(u.trim()===""||!Number.isFinite(_))throw Error(`Flag --${m} requires a numeric value, got "${u}".`);r[c]=_}else r[c]=u}$++}return r}on();Z();J();k();Y();function Gt(t){if(t instanceof y){if(j(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
311
311
  `);else{if(process.stderr.write(`
312
312
  Error: ${t.message}
313
313
  `),t.hint)process.stderr.write(`
@@ -321,19 +321,19 @@ If this happens on every request with a valid API key, you may be hitting the wr
321
321
  `+"Run: mmx config set region global (or cn) — to override the region.");return Gt($)}if(t instanceof TypeError&&t.message==="fetch failed"){let $=new y("Network request failed.",x.NETWORK,`Check your network connection.
322
322
  To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Gt($)}let n=t.message.toLowerCase();if(n.includes("failed to fetch")||n.includes("connection refused")||n.includes("econnrefused")||n.includes("connection reset")||n.includes("econnreset")||n.includes("network error")||n.includes("enotfound")||n.includes("getaddrinfo")||n.includes("proxy")||n.includes("socket")||n.includes("etimedout")||n.includes("timeout")||n.includes("eai_AGAIN")){let $=`Check your network connection.
323
323
  To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(n.includes("proxy"))$=`Proxy connection failed — verify your proxy URL and authentication.
324
- `+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let p=new y("Network request failed.",x.NETWORK,$);return Gt(p)}let i=t.code;if(i==="ENOENT"||i==="EACCES"||i==="ENOSPC"||i==="ENOTDIR"||i==="EISDIR"||i==="EPERM"||i==="EBUSY"){let $="Check the file path and permissions.";if(i==="ENOENT")$="File or directory not found.";if(i==="EACCES"||i==="EPERM")$="Permission denied — check file or directory permissions.";if(i==="ENOSPC")$="Disk full — free up space and try again.";let p=new y(`File system error: ${t.message}`,x.GENERAL,$);return Gt(p)}else if(typeof i==="string"&&i.startsWith("E")){let $=new y(`File system error: ${t.message}`,x.GENERAL,"Check the file path and permissions.");return Gt($)}if(process.stderr.write(`
324
+ `+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let p=new y("Network request failed.",x.NETWORK,$);return Gt(p)}let r=t.code;if(r==="ENOENT"||r==="EACCES"||r==="ENOSPC"||r==="ENOTDIR"||r==="EISDIR"||r==="EPERM"||r==="EBUSY"){let $="Check the file path and permissions.";if(r==="ENOENT")$="File or directory not found.";if(r==="EACCES"||r==="EPERM")$="Permission denied — check file or directory permissions.";if(r==="ENOSPC")$="Disk full — free up space and try again.";let p=new y(`File system error: ${t.message}`,x.GENERAL,$);return Gt(p)}else if(typeof r==="string"&&r.startsWith("E")){let $=new y(`File system error: ${t.message}`,x.GENERAL,"Check the file path and permissions.");return Gt($)}if(process.stderr.write(`
325
325
  Error: ${t.message}
326
326
  `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
327
327
  `)}else process.stderr.write(`
328
328
  Error: ${String(t)}
329
- `);process.exit(x.GENERAL)}rt();ee();tt();At();import{join as oo}from"path";import{readFileSync as uo,writeFileSync as xo}from"fs";var o$=()=>oo(Kt(),"update-state.json"),yo=86400000,_o=3000,co="MiniMax-AI-Dev/minimax-cli";function wo(){try{let t=uo(o$(),"utf-8");return JSON.parse(t)}catch{return null}}function vo(t){try{xo(o$(),JSON.stringify(t))}catch{}}async function bo(){try{let t=await fetch(`https://api.github.com/repos/${co}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(_o)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var we=null;function u$(){return we}async function x$(t){if(process.env.CI||!process.stderr.isTTY)return;let n=wo(),r=Date.now();if(n&&r-n.lastChecked<yo){if(n.latestVersion&&n.latestVersion!==`v${t}`)we=n.latestVersion;return}let i=await bo();if(!i)return;if(vo({lastChecked:r,latestVersion:i}),i!==`v${t}`)we=i}ot();an();Dt();import{ProxyAgent as Mo,setGlobalDispatcher as so}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
329
+ `);process.exit(x.GENERAL)}it();ee();tt();At();import{join as oo}from"path";import{readFileSync as uo,writeFileSync as xo}from"fs";var o$=()=>oo(Kt(),"update-state.json"),yo=86400000,co=3000,_o="MiniMax-AI-Dev/minimax-cli";function wo(){try{let t=uo(o$(),"utf-8");return JSON.parse(t)}catch{return null}}function vo(t){try{xo(o$(),JSON.stringify(t))}catch{}}async function Mo(){try{let t=await fetch(`https://api.github.com/repos/${_o}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(co)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var we=null;function u$(){return we}async function x$(t){if(process.env.CI||!process.stderr.isTTY)return;let n=wo(),i=Date.now();if(n&&i-n.lastChecked<yo){if(n.latestVersion&&n.latestVersion!==`v${t}`)we=n.latestVersion;return}let r=await Mo();if(!r)return;if(vo({lastChecked:i,latestVersion:r}),r!==`v${t}`)we=r}ot();an();Dt();import{ProxyAgent as bo,setGlobalDispatcher as so}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
330
330
  Interrupted. Exiting.
331
- `),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var Ro=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Go(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${Mt}`),process.exit(0);let n=se(t,Ht),r=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||r.proxy;if(i)so(new Mo(i));if(t.includes("--help")||t.includes("-h")){let w=t.indexOf("--region"),v=w>=0&&t[w+1]||process.env.MINIMAX_REGION||r.region||"global";it.printHelp(n,process.stderr,v),process.exit(0)}if(n.length===0){it.printHelp([],process.stderr);let{command:w}=it.resolve(["quota","show"]),v=hn(t,[...Ht,...w.options??[]]),b=Bn(v),G=!!(b.apiKey||b.fileApiKey),q=!!await L();if(G||q)await w.execute(b,v);else process.stderr.write(` Not logged in.
331
+ `),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var Ro=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function Go(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${bt}`),process.exit(0);let n=se(t,Ht),i=z(),r=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||i.proxy;if(r)so(new bo(r));if(t.includes("--help")||t.includes("-h")){let w=t.indexOf("--region"),v=w>=0&&t[w+1]||process.env.MINIMAX_REGION||i.region||"global";rt.printHelp(n,process.stderr,v),process.exit(0)}if(n.length===0){rt.printHelp([],process.stderr);let{command:w}=rt.resolve(["quota","show"]),v=qn(t,[...Ht,...w.options??[]]),M=Bn(v),G=!!(M.apiKey||M.fileApiKey),h=!!await L();if(G||h)await w.execute(M,v);else process.stderr.write(` Not logged in.
332
332
  `),process.stderr.write(` mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key
333
333
  `),process.stderr.write(` mmx auth login --api-key Save an API key directly
334
334
 
335
- `);process.exit(0)}let{command:$,extra:p}=it.resolve(n),e=hn(t,[...Ht,...$.options??[]]);if(p.length>0)e._positional=p;let m=Bn(e);if(!Ro.some((w)=>w.every((v,b)=>n[b]===v)))await ur(m);if(m.needsRegionDetection){let w=m.apiKey||m.fileApiKey;if(w){let v=await mn(w);m.region=v,m.baseUrl=W[v],m.needsRegionDetection=!1,await Tr(v)}}let _=x$(Mt).catch(()=>{});await $.execute(m,e),await _;let c=u$();if(c&&!m.quiet)process.stderr.write(`
336
- Update available: ${c}
335
+ `);process.exit(0)}let{command:$,extra:p}=rt.resolve(n),e=qn(t,[...Ht,...$.options??[]]);if(p.length>0)e._positional=p;let m=Bn(e);if(!Ro.some((w)=>w.every((v,M)=>n[M]===v)))await ui(m);if(m.needsRegionDetection){let w=m.apiKey||m.fileApiKey;if(w){let v=await mn(w);m.region=v,m.baseUrl=W[v],m.needsRegionDetection=!1,await Ti(v)}}let c=x$(bt).catch(()=>{});await $.execute(m,e),await c;let _=u$();if(_&&!m.quiet)process.stderr.write(`
336
+ Update available: ${_}
337
337
  `),process.stderr.write(` npm update -g mmx-cli
338
338
 
339
339
  `)}Go().catch(Gt);