mmx-cli 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -19
- package/dist/index.d.ts +3 -86
- package/dist/mmx.mjs +287 -292
- package/dist/sdk.mjs +458 -411
- package/package.json +1 -1
package/dist/mmx.mjs
CHANGED
|
@@ -1,340 +1,335 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
`)}if(typeof
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
`);return{}}}async function
|
|
7
|
-
`,{mode:384}),
|
|
2
|
+
import{createRequire as qi}from"node:module";var Ii=Object.create;var{getPrototypeOf:Ti,defineProperty:vt,getOwnPropertyNames:Mi}=Object;var Oi=Object.prototype.hasOwnProperty;function Pi(e){return this[e]}var Ni,Li,ze=(e,t,o)=>{var n=e!=null&&typeof e==="object";if(n){var i=t?Ni??=new WeakMap:Li??=new WeakMap,s=i.get(e);if(s)return s}o=e!=null?Ii(Ti(e)):{};let r=t||!e||!e.__esModule?vt(o,"default",{value:e,enumerable:!0}):o;if(e&&typeof e==="object"||typeof e==="function"){for(let u of Mi(e))if(!Oi.call(r,u))vt(r,u,{get:Pi.bind(e,u),enumerable:!0})}if(n)i.set(e,r);return r};var vr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ui=(e)=>e;function Gi(e,t){this[e]=Ui.bind(null,t)}var $t=(e,t)=>{for(var o in t)vt(e,o,{get:t[o],enumerable:!0,configurable:!0,set:Gi.bind(t,o)})};var C=(e,t)=>()=>(e&&(t=e(e=0)),t);var Be=qi(import.meta.url);var d;var S=C(()=>{d={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10}});var m;var R=C(()=>{S();m=class m extends Error{exitCode;hint;constructor(e,t=d.GENERAL,o){super(e);this.name="CLIError",this.exitCode=t,this.hint=o}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}});function zi(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let t=e;if(typeof t.access_token!=="string"||!t.access_token)return;if(typeof t.refresh_token!=="string")return;if(typeof t.expires_at!=="string")return;let o={access_token:t.access_token,refresh_token:t.refresh_token,expires_at:t.expires_at};if(typeof t.region==="string"&&Ar.has(t.region))o.region=t.region;if(typeof t.resource_url==="string"&&t.resource_url.startsWith("http"))o.resource_url=t.resource_url;if(typeof t.account==="string"&&t.account.length>0)o.account=t.account;return o}function Sr(e){if(!e||typeof e!=="object"||Array.isArray(e))return{};let t=e,o={};if(typeof t.api_key==="string")o.api_key=t.api_key;if(typeof t.region==="string"&&Ar.has(t.region))o.region=t.region;if(typeof t.base_url==="string"&&t.base_url.startsWith("http"))o.base_url=t.base_url;if(typeof t.output==="string"&&Ki.has(t.output))o.output=t.output;if(typeof t.timeout==="number"&&t.timeout>0)o.timeout=t.timeout;if(typeof t.proxy==="string"&&t.proxy.startsWith("http"))o.proxy=t.proxy;let n=zi(t.oauth);if(n)o.oauth=n;if(typeof t.default_text_model==="string"&&t.default_text_model.length>0)o.default_text_model=t.default_text_model;if(typeof t.default_speech_model==="string"&&t.default_speech_model.length>0)o.default_speech_model=t.default_speech_model;if(typeof t.default_video_model==="string"&&t.default_video_model.length>0)o.default_video_model=t.default_video_model;return o}var U,Le,Je,Ar,Ki;var re=C(()=>{U={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},Le={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Je={global:"https://account.minimax.io",cn:"https://account.minimaxi.com"},Ar=new Set(["global","cn"]),Ki=new Set(["text","json"])});function w(e){return{name:e.name,description:e.description,usage:e.usage,options:e.options,examples:e.examples,apiDocs:e.apiDocs,execute:e.run}}var Ye;var T=C(()=>{Ye=[{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 Ji}from"os";import{join as kr}from"path";function Xe(){if(process.env.MMX_CONFIG_DIR)return process.env.MMX_CONFIG_DIR;return kr(Ji(),Yi)}function oe(){return kr(Xe(),"config.json")}async function Rr(){let e=Xe();await(await import("fs/promises")).mkdir(e,{recursive:!0,mode:448})}var Yi=".mmx";var Ie=()=>{};var Ir={};$t(Ir,{formatKeyValue:()=>Qe,formatTable:()=>Br,formatText:()=>St});function St(e){if(e===null||e===void 0)return"";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e)){if(e.length===0)return"(empty)";if(typeof e[0]==="object"&&e[0]!==null)return Br(e);return e.map(String).join(`
|
|
3
|
+
`)}if(typeof e==="object")return Qe(e);return String(e)}function Qe(e,t=0){let o=" ".repeat(t),n=[];for(let[i,s]of Object.entries(e)){if(s===null||s===void 0)continue;if(Array.isArray(s)){n.push(`${o}${i}:`);for(let r of s)if(typeof r==="object"&&r!==null)n.push(`${o} - ${Qe(r,t+4).trimStart()}`);else n.push(`${o} - ${String(r)}`)}else if(typeof s==="object")n.push(`${o}${i}:`),n.push(Qe(s,t+2));else n.push(`${o}${i}: ${String(s)}`)}return n.join(`
|
|
4
|
+
`)}function Br(e){if(e.length===0)return"(empty)";let t=Object.keys(e[0]),o=t.map((r)=>Math.max(r.length,...e.map((u)=>String(u[r]??"").length))),n=t.map((r,u)=>r.toUpperCase().padEnd(o[u])).join(" "),i=o.map((r)=>"-".repeat(r)).join(" "),s=e.map((r)=>t.map((u,a)=>String(r[u]??"").padEnd(o[a])).join(" "));return[n,i,...s].join(`
|
|
5
|
+
`)}function Tr(e){return JSON.stringify(e,null,2)}function _(e){if(e==="json"||e==="text")return e;if(!process.stdout.isTTY)return"json";return"text"}function F(e,t){switch(t){case"json":return Tr(e);case"text":return St(e)}}function le(e,t){if(!e.dryRun)return!1;return console.log(F({request:t},_(e.output))),!0}var N=()=>{};import{copyFileSync as Xi,existsSync as Qi,readFileSync as Zi,renameSync as es,unlinkSync as ts,writeFileSync as rs}from"fs";function os(e){return e instanceof Error&&"code"in e&&e.code==="EXDEV"}function ns(e,t,o={rename:es,copy:Xi,unlink:ts}){try{o.rename(e,t)}catch(n){if(!os(n))throw n;o.copy(e,t),o.unlink(e)}}function P(){let e=oe();if(!Qi(e))return{};try{return Sr(JSON.parse(Zi(e,"utf-8")))}catch(t){let o=t;if(o instanceof SyntaxError||o.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
|
|
6
|
+
`);return{}}}async function K(e,t){await Rr();let o=oe(),n=o+".tmp";rs(n,JSON.stringify(e,null,2)+`
|
|
7
|
+
`,{mode:384}),ns(n,o,t)}function kt(e){let t=P(),o=e.apiKey||void 0,n=t.api_key,i=e.region||process.env.MINIMAX_REGION||void 0;if(i&&!(i in U))throw new m(`Invalid region "${i}". Valid values: ${Object.keys(U).join(", ")}`,d.USAGE);let s=t.region,r=i||s||"global",u=o||n,a=!i&&(!s||u!==void 0&&u!==t.api_key),l=e.baseUrl||process.env.MINIMAX_BASE_URL||t.base_url||t.oauth?.resource_url||U[r]||U.global,p=_(e.output||process.env.MINIMAX_OUTPUT||t.output),f=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,D=f!==void 0&&Number.isFinite(f)&&f>0?f:void 0,h=e.timeout??D??t.timeout??300;return{apiKey:o,fileApiKey:n,fileRegion:t.region,configPath:oe(),region:r,baseUrl:l,output:p,timeout:h,defaultTextModel:t.default_text_model,defaultSpeechModel:t.default_speech_model,defaultVideoModel:t.default_video_model,verbose:e.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:e.quiet||!1,noColor:e.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:e.yes||!1,dryRun:e.dryRun||!1,nonInteractive:e.nonInteractive||!1,async:e.async||!1,needsRegionDetection:a}}var se=C(()=>{re();Ie();N();R();S()});function G(e){if(e?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}var Bt=vr(function(Ic,Mr){var Rt={to(e,t){if(!t)return`\x1B[${e+1}G`;return`\x1B[${t+1};${e+1}H`},move(e,t){let o="";if(e<0)o+=`\x1B[${-e}D`;else if(e>0)o+=`\x1B[${e}C`;if(t<0)o+=`\x1B[${-t}A`;else if(t>0)o+=`\x1B[${t}B`;return o},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},is={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},ss={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let o=0;o<e;o++)t+=this.line+(o<e-1?Rt.up():"");if(e)t+=Rt.left;return t}};Mr.exports={cursor:Rt,scroll:is,erase:ss,beep:"\x07"}});var Tt=vr(function(Tc,It){var et=process||{},Or=et.argv||[],Ze=et.env||{},us=!(!!Ze.NO_COLOR||Or.includes("--no-color"))&&(!!Ze.FORCE_COLOR||Or.includes("--color")||et.platform==="win32"||(et.stdout||{}).isTTY&&Ze.TERM!=="dumb"||!!Ze.CI),as=(e,t,o=e)=>(n)=>{let i=""+n,s=i.indexOf(t,e.length);return~s?e+cs(i,t,o,s)+t:e+i+t},cs=(e,t,o,n)=>{let i="",s=0;do i+=e.substring(s,n)+o,s=n+t.length,n=e.indexOf(t,s);while(~n);return i+e.substring(s)},Pr=(e=us)=>{let t=e?as:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};It.exports=Pr();It.exports.createColors=Pr});import{stdin as Xr,stdout as Qr}from"node:process";import*as me from"node:readline";import Nr from"node:readline";import{WriteStream as ls}from"node:tty";function ms({onlyFirst:e=!1}={}){let t=["[\\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(t,e?void 0:"g")}function Zr(e){if(typeof e!="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(ds,"")}function eo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ue(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Zr(e),e.length===0))return 0;e=e.replace(hs()," ");let o=t.ambiguousIsNarrow?1:2,n=0;for(let i of e){let s=i.codePointAt(0);if(s<=31||s>=127&&s<=159||s>=768&&s<=879)continue;switch(Ds.eastAsianWidth(i)){case"F":case"W":n+=2;break;case"A":n+=o;break;default:n+=1}}return n}function ys(){let e=new Map;for(let[t,o]of Object.entries(O)){for(let[n,i]of Object.entries(o))O[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},o[n]=O[n],e.set(i[0],i[1]);Object.defineProperty(O,t,{value:o,enumerable:!1})}return Object.defineProperty(O,"codes",{value:e,enumerable:!1}),O.color.close="\x1B[39m",O.bgColor.close="\x1B[49m",O.color.ansi=Lr(),O.color.ansi256=Ur(),O.color.ansi16m=Gr(),O.bgColor.ansi=Lr(Mt),O.bgColor.ansi256=Ur(Mt),O.bgColor.ansi16m=Gr(Mt),Object.defineProperties(O,{rgbToAnsi256:{value:(t,o,n)=>t===o&&o===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:(t)=>{let o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!o)return[0,0,0];let[n]=o;n.length===3&&(n=[...n].map((s)=>s+s).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(t)=>O.rgbToAnsi256(...O.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value:(t)=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let o,n,i;if(t>=232)o=((t-232)*10+8)/255,n=o,i=o;else{t-=16;let u=t%36;o=Math.floor(t/36)/5,n=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(o,n,i)*2;if(s===0)return 30;let r=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(o));return s===2&&(r+=60),r},enumerable:!1},rgbToAnsi:{value:(t,o,n)=>O.ansi256ToAnsi(O.rgbToAnsi256(t,o,n)),enumerable:!1},hexToAnsi:{value:(t)=>O.ansi256ToAnsi(O.hexToAnsi256(t)),enumerable:!1}}),O}function jr(e,t,o){return String(e).normalize().replace(/\r\n/g,`
|
|
8
8
|
`).split(`
|
|
9
|
-
`).map((
|
|
10
|
-
`)}function
|
|
11
|
-
`),
|
|
12
|
-
`),
|
|
13
|
-
`),
|
|
14
|
-
`).length-1;this.output.write(
|
|
15
|
-
`);this.output.write(
|
|
16
|
-
`).slice(
|
|
17
|
-
`)),this._prevFrame=t;return}this.output.write(l.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function _i({input:t=ii,output:e=ri,overwrite:i=!0,hideCursor:r=!0}={}){let o=$t.createInterface({input:t,output:e,prompt:"",tabSize:1});$t.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let m=(n,{name:p})=>{if(String(n)==="\x03"){r&&e.write(l.cursor.show),process.exit(0);return}if(!i)return;$t.moveCursor(e,p==="return"?0:-1,p==="return"?-1:0,()=>{$t.clearLine(e,1,()=>{t.once("keypress",m)})})};return r&&e.write(l.cursor.hide),t.once("keypress",m),()=>{t.off("keypress",m),r&&e.write(l.cursor.show),t.isTTY&&!Hm&&t.setRawMode(!1),o.terminal=!1,o.close()}}var l,yt,cm,pi,xm,_m,ym=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},wm,He=10,fn=(t=0)=>(e)=>`\x1B[${e+t}m`,Pn=(t=0)=>(e)=>`\x1B[${38+t};5;${e}m`,In=(t=0)=>(e,i,r)=>`\x1B[${38+t};2;${e};${i};${r}m`,X,Mm,vm,Rm,oe,bm=39,le="\x07",$i="[",Sm="]",ui="m",fe,En=(t)=>`${oe.values().next().value}${$i}${t}${ui}`,Ln=(t)=>`${oe.values().next().value}${fe}${t}${le}`,Gm=(t)=>t.split(" ").map((e)=>Wt(e)),Ke=(t,e,i)=>{let r=[...e],o=!1,m=!1,n=Wt(oi(t[t.length-1]));for(let[p,u]of r.entries()){let x=Wt(u);if(n+x<=i?t[t.length-1]+=u:(t.push(u),n=0),oe.has(u)&&(o=!0,m=r.slice(p+1).join("").startsWith(fe)),o){m?u===le&&(o=!1,m=!1):u===ui&&(o=!1);continue}n+=x,n===i&&p<r.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},Am=(t)=>{let e=t.split(" "),i=e.length;for(;i>0&&!(Wt(e[i-1])>0);)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},Bm=(t,e,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,m,n=Gm(t),p=[""];for(let[x,y]of t.split(" ").entries()){i.trim!==!1&&(p[p.length-1]=p[p.length-1].trimStart());let w=Wt(p[p.length-1]);if(x!==0&&(w>=e&&(i.wordWrap===!1||i.trim===!1)&&(p.push(""),w=0),(w>0||i.trim===!1)&&(p[p.length-1]+=" ",w++)),i.hard&&n[x]>e){let _=e-w,M=1+Math.floor((n[x]-_-1)/e);Math.floor((n[x]-1)/e)<M&&p.push(""),Ke(p,y,e);continue}if(w+n[x]>e&&w>0&&n[x]>0){if(i.wordWrap===!1&&w<e){Ke(p,y,e);continue}p.push("")}if(w+n[x]>e&&i.wordWrap===!1){Ke(p,y,e);continue}p[p.length-1]+=y}i.trim!==!1&&(p=p.map((x)=>Am(x)));let u=[...p.join(`
|
|
18
|
-
`)];for(let[
|
|
19
|
-
`?(
|
|
20
|
-
`&&(o&&w&&(r+=En(o)),m&&(r+=Ln(m)))}return r},Vm,qm=(t,e,i)=>(e in t)?Vm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,F=(t,e,i)=>(qm(t,typeof e!="symbol"?e+"":e,i),i),si,Cn,dm,Pe,km,Um=(t,e,i)=>(e in t)?km(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,gn=(t,e,i)=>(Um(t,typeof e!="symbol"?e+"":e,i),i),Ie,am,Tm=(t,e,i)=>(e in t)?am(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dn=(t,e,i)=>(Tm(t,typeof e!="symbol"?e+"":e,i),i),ci,Jm,Xm=(t,e,i)=>(e in t)?Jm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ti=(t,e,i)=>(Xm(t,typeof e!="symbol"?e+"":e,i),i),Ee,Ym,Qm=(t,e,i)=>(e in t)?Ym(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ei=(t,e,i)=>(Qm(t,typeof e!="symbol"?e+"":e,i),i),xi,zm,Zm=(t,e,i)=>(e in t)?zm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ni=(t,e,i)=>(Zm(t,typeof e!="symbol"?e+"":e,i),i),Le,Nm,Om=(t,e,i)=>(e in t)?Nm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Wm=(t,e,i)=>(Om(t,typeof e!="symbol"?e+"":e,i),i),Fe,Hm;var Ce=h(()=>{l=Ft(Ne(),1),yt=Ft(We(),1);cm=sm();pi={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(r){var o=r.charCodeAt(0),m=r.length==2?r.charCodeAt(1):0,n=o;return 55296<=o&&o<=56319&&56320<=m&&m<=57343&&(o&=1023,m&=1023,n=o<<10|m,n+=65536),n==12288||65281<=n&&n<=65376||65504<=n&&n<=65510?"F":n==8361||65377<=n&&n<=65470||65474<=n&&n<=65479||65482<=n&&n<=65487||65490<=n&&n<=65495||65498<=n&&n<=65500||65512<=n&&n<=65518?"H":4352<=n&&n<=4447||4515<=n&&n<=4519||4602<=n&&n<=4607||9001<=n&&n<=9002||11904<=n&&n<=11929||11931<=n&&n<=12019||12032<=n&&n<=12245||12272<=n&&n<=12283||12289<=n&&n<=12350||12353<=n&&n<=12438||12441<=n&&n<=12543||12549<=n&&n<=12589||12593<=n&&n<=12686||12688<=n&&n<=12730||12736<=n&&n<=12771||12784<=n&&n<=12830||12832<=n&&n<=12871||12880<=n&&n<=13054||13056<=n&&n<=19903||19968<=n&&n<=42124||42128<=n&&n<=42182||43360<=n&&n<=43388||44032<=n&&n<=55203||55216<=n&&n<=55238||55243<=n&&n<=55291||63744<=n&&n<=64255||65040<=n&&n<=65049||65072<=n&&n<=65106||65108<=n&&n<=65126||65128<=n&&n<=65131||110592<=n&&n<=110593||127488<=n&&n<=127490||127504<=n&&n<=127546||127552<=n&&n<=127560||127568<=n&&n<=127569||131072<=n&&n<=194367||177984<=n&&n<=196605||196608<=n&&n<=262141?"W":32<=n&&n<=126||162<=n&&n<=163||165<=n&&n<=166||n==172||n==175||10214<=n&&n<=10221||10629<=n&&n<=10630?"Na":n==161||n==164||167<=n&&n<=168||n==170||173<=n&&n<=174||176<=n&&n<=180||182<=n&&n<=186||188<=n&&n<=191||n==198||n==208||215<=n&&n<=216||222<=n&&n<=225||n==230||232<=n&&n<=234||236<=n&&n<=237||n==240||242<=n&&n<=243||247<=n&&n<=250||n==252||n==254||n==257||n==273||n==275||n==283||294<=n&&n<=295||n==299||305<=n&&n<=307||n==312||319<=n&&n<=322||n==324||328<=n&&n<=331||n==333||338<=n&&n<=339||358<=n&&n<=359||n==363||n==462||n==464||n==466||n==468||n==470||n==472||n==474||n==476||n==593||n==609||n==708||n==711||713<=n&&n<=715||n==717||n==720||728<=n&&n<=731||n==733||n==735||768<=n&&n<=879||913<=n&&n<=929||931<=n&&n<=937||945<=n&&n<=961||963<=n&&n<=969||n==1025||1040<=n&&n<=1103||n==1105||n==8208||8211<=n&&n<=8214||8216<=n&&n<=8217||8220<=n&&n<=8221||8224<=n&&n<=8226||8228<=n&&n<=8231||n==8240||8242<=n&&n<=8243||n==8245||n==8251||n==8254||n==8308||n==8319||8321<=n&&n<=8324||n==8364||n==8451||n==8453||n==8457||n==8467||n==8470||8481<=n&&n<=8482||n==8486||n==8491||8531<=n&&n<=8532||8539<=n&&n<=8542||8544<=n&&n<=8555||8560<=n&&n<=8569||n==8585||8592<=n&&n<=8601||8632<=n&&n<=8633||n==8658||n==8660||n==8679||n==8704||8706<=n&&n<=8707||8711<=n&&n<=8712||n==8715||n==8719||n==8721||n==8725||n==8730||8733<=n&&n<=8736||n==8739||n==8741||8743<=n&&n<=8748||n==8750||8756<=n&&n<=8759||8764<=n&&n<=8765||n==8776||n==8780||n==8786||8800<=n&&n<=8801||8804<=n&&n<=8807||8810<=n&&n<=8811||8814<=n&&n<=8815||8834<=n&&n<=8835||8838<=n&&n<=8839||n==8853||n==8857||n==8869||n==8895||n==8978||9312<=n&&n<=9449||9451<=n&&n<=9547||9552<=n&&n<=9587||9600<=n&&n<=9615||9618<=n&&n<=9621||9632<=n&&n<=9633||9635<=n&&n<=9641||9650<=n&&n<=9651||9654<=n&&n<=9655||9660<=n&&n<=9661||9664<=n&&n<=9665||9670<=n&&n<=9672||n==9675||9678<=n&&n<=9681||9698<=n&&n<=9701||n==9711||9733<=n&&n<=9734||n==9737||9742<=n&&n<=9743||9748<=n&&n<=9749||n==9756||n==9758||n==9792||n==9794||9824<=n&&n<=9825||9827<=n&&n<=9829||9831<=n&&n<=9834||9836<=n&&n<=9837||n==9839||9886<=n&&n<=9887||9918<=n&&n<=9919||9924<=n&&n<=9933||9935<=n&&n<=9953||n==9955||9960<=n&&n<=9983||n==10045||n==10071||10102<=n&&n<=10111||11093<=n&&n<=11097||12872<=n&&n<=12879||57344<=n&&n<=63743||65024<=n&&n<=65039||n==65533||127232<=n&&n<=127242||127248<=n&&n<=127277||127280<=n&&n<=127337||127344<=n&&n<=127386||917760<=n&&n<=917999||983040<=n&&n<=1048573||1048576<=n&&n<=1114109?"A":"N"},e.characterLength=function(r){var o=this.eastAsianWidth(r);return o=="F"||o=="W"||o=="A"?2:1};function i(r){return r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}e.length=function(r){for(var o=i(r),m=0,n=0;n<o.length;n++)m=m+this.characterLength(o[n]);return m},e.slice=function(r,o,m){textLen=e.length(r),o=o||0,m=m||1,o<0&&(o=textLen+o),m<0&&(m=textLen+m);for(var n="",p=0,u=i(r),x=0;x<u.length;x++){var y=u[x],w=e.length(y);if(p>=o-(w==2?1:0))if(p+w<=m)n+=y;else break;p+=w}return n}})(pi);xm=pi.exports,_m=mi(xm),wm=mi(ym);X={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(X.modifier);Mm=Object.keys(X.color),vm=Object.keys(X.bgColor);[...Mm,...vm];Rm=hm(),oe=new Set(["\x1B",""]),fe=`${Sm}8;;`;Vm=Object.defineProperty;si=Symbol("clack:cancel");Cn=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),dm=new Set(["up","down","left","right","space","enter"]);Pe=class Pe extends ut{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",(e)=>{this.output.write(l.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};km=Object.defineProperty;Ie=class Ie extends ut{constructor(t){super(t,!1),gn(this,"options"),gn(this,"cursor",0);let{options:e}=t;this.options=Object.entries(e).flatMap(([i,r])=>[{value:i,group:!0,label:i},...r.map((o)=>({...o,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((e)=>e.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((e)=>this.value.includes(e.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let e=t.value,i=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter((r)=>i.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let e=this.value.includes(t.value);this.value=e?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};am=Object.defineProperty,ci=class extends ut{constructor(t){super(t,!1),Dn(this,"options"),Dn(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:e})=>e===t.cursorAt),0),this.on("key",(e)=>{e==="a"&&this.toggleAll()}),this.on("cursor",(e)=>{switch(e){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((e)=>e.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((e)=>e!==this._value):[...this.value,this._value]}},Jm=Object.defineProperty;Ee=class Ee extends ut{constructor({mask:t,...e}){super(e),ti(this,"valueWithCursor",""),ti(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)}};Ym=Object.defineProperty,xi=class extends ut{constructor(t){super(t,!1),ei(this,"options"),ei(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:e})=>e===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(e)=>{switch(e){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}},zm=Object.defineProperty;Le=class Le extends ut{constructor(t){super(t,!1),ni(this,"options"),ni(this,"cursor",0),this.options=t.options;let e=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(e.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!e.includes(i))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};Nm=Object.defineProperty;Fe=class Fe extends ut{constructor(t){super(t),Wm(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 e=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${e}${yt.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};Hm=globalThis.process.platform.startsWith("win")});var vt={};Ct(vt,{text:()=>tp,spinner:()=>cp,selectKey:()=>rp,select:()=>ip,password:()=>ep,outro:()=>sp,note:()=>pp,multiselect:()=>op,log:()=>wt,isCancel:()=>me,intro:()=>up,groupMultiselect:()=>mp,group:()=>_p,confirm:()=>np,cancel:()=>$p});import D from"node:process";function Km(){return D.platform!=="win32"?D.env.TERM!=="linux":Boolean(D.env.CI)||Boolean(D.env.WT_SESSION)||Boolean(D.env.TERMINUS_SUBLIME)||D.env.ConEmuTask==="{cmd::Cmder}"||D.env.TERM_PROGRAM==="Terminus-Sublime"||D.env.TERM_PROGRAM==="vscode"||D.env.TERM==="xterm-256color"||D.env.TERM==="alacritty"||D.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function xp(){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 $,Ut,De,z=(t,e)=>De?t:e,lm,wi,Mi,pe,fm,R,P,tn,en,nn,Ht,vi,Pm,yi,Im,Em,Lm,Fm,Cm,gm,Dm,Mt=(t)=>{switch(t){case"initial":case"active":return $.default.cyan(lm);case"cancel":return $.default.red(wi);case"error":return $.default.yellow(Mi);case"submit":return $.default.green(pe)}},tp=(t)=>new Fe({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let e=`${$.default.gray(R)}
|
|
21
|
-
${
|
|
22
|
-
`,
|
|
23
|
-
${
|
|
24
|
-
${
|
|
25
|
-
`;case"submit":return`${
|
|
26
|
-
|
|
27
|
-
${
|
|
28
|
-
`}}}).prompt(),
|
|
29
|
-
${
|
|
30
|
-
`,
|
|
31
|
-
${
|
|
32
|
-
${
|
|
33
|
-
`;case"submit":return`${
|
|
34
|
-
|
|
35
|
-
${
|
|
36
|
-
`}}}).prompt(),
|
|
37
|
-
${
|
|
38
|
-
`,
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
`}}}).prompt()},
|
|
42
|
-
${
|
|
43
|
-
`;switch(this.state){case"submit":return`${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
`}}}}).prompt()},
|
|
48
|
-
${
|
|
49
|
-
`;switch(this.state){case"submit":return`${
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
`}}}).prompt()},
|
|
54
|
-
${
|
|
55
|
-
${
|
|
56
|
-
`;switch(this.state){case"submit":return`${
|
|
57
|
-
${
|
|
58
|
-
`).map((
|
|
59
|
-
`);return
|
|
60
|
-
${
|
|
61
|
-
`+
|
|
62
|
-
`}default:return`${
|
|
63
|
-
${
|
|
64
|
-
${
|
|
65
|
-
`}}}).prompt()},
|
|
66
|
-
${
|
|
67
|
-
${
|
|
68
|
-
`;switch(this.state){case"submit":return`${
|
|
69
|
-
${
|
|
70
|
-
`).map((
|
|
71
|
-
`);return`${
|
|
72
|
-
${
|
|
73
|
-
${
|
|
74
|
-
`}default:return`${
|
|
75
|
-
${
|
|
76
|
-
${
|
|
77
|
-
`}}}).prompt()},
|
|
78
|
-
${
|
|
9
|
+
`).map((n)=>vs(n,t,o)).join(`
|
|
10
|
+
`)}function As(e,t){if(e===t)return;let o=e.split(`
|
|
11
|
+
`),n=t.split(`
|
|
12
|
+
`),i=[];for(let s=0;s<Math.max(o.length,n.length);s++)o[s]!==n[s]&&i.push(s);return i}function ot(e){return e===no}function tt(e,t){e.isTTY&&e.setRawMode(t)}class de{constructor({render:e,input:t=Xr,output:o=Qr,...n},i=!0){X(this,"input"),X(this,"output"),X(this,"rl"),X(this,"opts"),X(this,"_track",!1),X(this,"_render"),X(this,"_cursor",0),X(this,"state","initial"),X(this,"value"),X(this,"error",""),X(this,"subscribers",new Map),X(this,"_prevFrame",""),this.opts=n,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=e.bind(this),this._track=i,this.input=t,this.output=o}prompt(){let e=new ls(0);return e._write=(t,o,n)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),n()},this.input.pipe(e),this.rl=Nr.createInterface({input:this.input,output:e,tabSize:2,prompt:"",escapeCodeTimeout:50}),Nr.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),tt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((t,o)=>{this.once("submit",()=>{this.output.write(H.cursor.show),this.output.off("resize",this.render),tt(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(H.cursor.show),this.output.off("resize",this.render),tt(this.input,!1),t(no)})})}on(e,t){let o=this.subscribers.get(e)??[];o.push({cb:t}),this.subscribers.set(e,o)}once(e,t){let o=this.subscribers.get(e)??[];o.push({cb:t,once:!0}),this.subscribers.set(e,o)}emit(e,...t){let o=this.subscribers.get(e)??[],n=[];for(let i of o)i.cb(...t),i.once&&n.push(()=>o.splice(o.indexOf(i),1));for(let i of n)i()}unsubscribe(){this.subscribers.clear()}onKeypress(e,t){if(this.state==="error"&&(this.state="active"),t?.name&&!this._track&&Hr.has(t.name)&&this.emit("cursor",Hr.get(t.name)),t?.name&&Ss.has(t.name)&&this.emit("cursor",t.name),e&&(e.toLowerCase()==="y"||e.toLowerCase()==="n")&&this.emit("confirm",e.toLowerCase()==="y"),e==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),e&&this.emit("key",e.toLowerCase()),t?.name==="return"){if(this.opts.validate){let o=this.opts.validate(this.value);o&&(this.error=o,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}e==="\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
|
+
`),tt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=jr(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
14
|
+
`).length-1;this.output.write(H.cursor.move(-999,e*-1))}render(){let e=jr(this._render(this)??"",process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state==="initial")this.output.write(H.cursor.hide);else{let t=As(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let o=t[0];this.output.write(H.cursor.move(0,o)),this.output.write(H.erase.lines(1));let n=e.split(`
|
|
15
|
+
`);this.output.write(n[o]),this._prevFrame=e,this.output.write(H.cursor.move(0,n.length-o-1));return}else if(t&&t?.length>1){let o=t[0];this.output.write(H.cursor.move(0,o)),this.output.write(H.erase.down());let n=e.split(`
|
|
16
|
+
`).slice(o);this.output.write(n.join(`
|
|
17
|
+
`)),this._prevFrame=e;return}this.output.write(H.erase.down())}this.output.write(e),this.state==="initial"&&(this.state="active"),this._prevFrame=e}}}function uo({input:e=Xr,output:t=Qr,overwrite:o=!0,hideCursor:n=!0}={}){let i=me.createInterface({input:e,output:t,prompt:"",tabSize:1});me.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let s=(r,{name:u})=>{if(String(r)==="\x03"){n&&t.write(H.cursor.show),process.exit(0);return}if(!o)return;me.moveCursor(t,u==="return"?0:-1,u==="return"?-1:0,()=>{me.clearLine(t,1,()=>{e.once("keypress",s)})})};return n&&t.write(H.cursor.hide),e.once("keypress",s),()=>{e.off("keypress",s),n&&t.write(H.cursor.show),e.isTTY&&!Vs&&e.setRawMode(!1),i.terminal=!1,i.close()}}var H,Ce,ds,to,ps,Ds,fs=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},hs,Mt=10,Lr=(e=0)=>(t)=>`\x1B[${t+e}m`,Ur=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Gr=(e=0)=>(t,o,n)=>`\x1B[${38+e};2;${t};${o};${n}m`,O,gs,Cs,bs,rt,Es=39,Pt="\x07",ro="[",Fs="]",oo="m",Nt,qr=(e)=>`${rt.values().next().value}${ro}${e}${oo}`,Vr=(e)=>`${rt.values().next().value}${Nt}${e}${Pt}`,xs=(e)=>e.split(" ").map((t)=>Ue(t)),Ot=(e,t,o)=>{let n=[...t],i=!1,s=!1,r=Ue(Zr(e[e.length-1]));for(let[u,a]of n.entries()){let l=Ue(a);if(r+l<=o?e[e.length-1]+=a:(e.push(a),r=0),rt.has(a)&&(i=!0,s=n.slice(u+1).join("").startsWith(Nt)),i){s?a===Pt&&(i=!1,s=!1):a===oo&&(i=!1);continue}r+=l,r===o&&u<n.length-1&&(e.push(""),r=0)}!r&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ws=(e)=>{let t=e.split(" "),o=t.length;for(;o>0&&!(Ue(t[o-1])>0);)o--;return o===t.length?e:t.slice(0,o).join(" ")+t.slice(o).join("")},vs=(e,t,o={})=>{if(o.trim!==!1&&e.trim()==="")return"";let n="",i,s,r=xs(e),u=[""];for(let[l,p]of e.split(" ").entries()){o.trim!==!1&&(u[u.length-1]=u[u.length-1].trimStart());let f=Ue(u[u.length-1]);if(l!==0&&(f>=t&&(o.wordWrap===!1||o.trim===!1)&&(u.push(""),f=0),(f>0||o.trim===!1)&&(u[u.length-1]+=" ",f++)),o.hard&&r[l]>t){let D=t-f,h=1+Math.floor((r[l]-D-1)/t);Math.floor((r[l]-1)/t)<h&&u.push(""),Ot(u,p,t);continue}if(f+r[l]>t&&f>0&&r[l]>0){if(o.wordWrap===!1&&f<t){Ot(u,p,t);continue}u.push("")}if(f+r[l]>t&&o.wordWrap===!1){Ot(u,p,t);continue}u[u.length-1]+=p}o.trim!==!1&&(u=u.map((l)=>ws(l)));let a=[...u.join(`
|
|
18
|
+
`)];for(let[l,p]of a.entries()){if(n+=p,rt.has(p)){let{groups:D}=new RegExp(`(?:\\${ro}(?<code>\\d+)m|\\${Nt}(?<uri>.*)${Pt})`).exec(a.slice(l).join(""))||{groups:{}};if(D.code!==void 0){let h=Number.parseFloat(D.code);i=h===Es?void 0:h}else D.uri!==void 0&&(s=D.uri.length===0?void 0:D.uri)}let f=bs.codes.get(Number(i));a[l+1]===`
|
|
19
|
+
`?(s&&(n+=Vr("")),i&&f&&(n+=qr(f))):p===`
|
|
20
|
+
`&&(i&&f&&(n+=qr(i)),s&&(n+=Vr(s)))}return n},$s,_s=(e,t,o)=>(t in e)?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,X=(e,t,o)=>(_s(e,typeof t!="symbol"?t+"":t,o),o),no,Hr,Ss,Lt,ks,Rs=(e,t,o)=>(t in e)?ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Wr=(e,t,o)=>(Rs(e,typeof t!="symbol"?t+"":t,o),o),Ut,Bs,Is=(e,t,o)=>(t in e)?Bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Kr=(e,t,o)=>(Is(e,typeof t!="symbol"?t+"":t,o),o),io,Ts,Ms=(e,t,o)=>(t in e)?Ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,zr=(e,t,o)=>(Ms(e,typeof t!="symbol"?t+"":t,o),o),Gt,Os,Ps=(e,t,o)=>(t in e)?Os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Jr=(e,t,o)=>(Ps(e,typeof t!="symbol"?t+"":t,o),o),so,Ns,Ls=(e,t,o)=>(t in e)?Ns(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,Yr=(e,t,o)=>(Ls(e,typeof t!="symbol"?t+"":t,o),o),qt,Us,Gs=(e,t,o)=>(t in e)?Us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,qs=(e,t,o)=>(Gs(e,typeof t!="symbol"?t+"":t,o),o),Vt,Vs;var jt=C(()=>{H=ze(Bt(),1),Ce=ze(Tt(),1);ds=ms();to={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(n){var i=n.charCodeAt(0),s=n.length==2?n.charCodeAt(1):0,r=i;return 55296<=i&&i<=56319&&56320<=s&&s<=57343&&(i&=1023,s&=1023,r=i<<10|s,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"},t.characterLength=function(n){var i=this.eastAsianWidth(n);return i=="F"||i=="W"||i=="A"?2:1};function o(n){return n.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(n){for(var i=o(n),s=0,r=0;r<i.length;r++)s=s+this.characterLength(i[r]);return s},t.slice=function(n,i,s){textLen=t.length(n),i=i||0,s=s||1,i<0&&(i=textLen+i),s<0&&(s=textLen+s);for(var r="",u=0,a=o(n),l=0;l<a.length;l++){var p=a[l],f=t.length(p);if(u>=i-(f==2?1:0))if(u+f<=s)r+=p;else break;u+=f}return r}})(to);ps=to.exports,Ds=eo(ps),hs=eo(fs);O={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(O.modifier);gs=Object.keys(O.color),Cs=Object.keys(O.bgColor);[...gs,...Cs];bs=ys(),rt=new Set(["\x1B",""]),Nt=`${Fs}8;;`;$s=Object.defineProperty;no=Symbol("clack:cancel");Hr=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),Ss=new Set(["up","down","left","right","space","enter"]);Lt=class Lt extends de{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(t)=>{this.output.write(H.cursor.move(0,-1)),this.value=t,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};ks=Object.defineProperty;Ut=class Ut extends de{constructor(e){super(e,!1),Wr(this,"options"),Wr(this,"cursor",0);let{options:t}=e;this.options=Object.entries(t).flatMap(([o,n])=>[{value:o,group:!0,label:o},...n.map((i)=>({...i,group:o}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:o})=>o===e.cursorAt),0),this.on("cursor",(o)=>{switch(o){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(e){return this.options.filter((t)=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every((t)=>this.value.includes(t.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,o=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter((n)=>o.findIndex((i)=>i.value===n)===-1):this.value=[...this.value,...o.map((n)=>n.value)],this.value=Array.from(new Set(this.value))}else{let t=this.value.includes(e.value);this.value=t?this.value.filter((o)=>o!==e.value):[...this.value,e.value]}}};Bs=Object.defineProperty,io=class extends de{constructor(e){super(e,!1),Kr(this,"options"),Kr(this,"cursor",0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on("key",(t)=>{t==="a"&&this.toggleAll()}),this.on("cursor",(t)=>{switch(t){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 e=this.value.length===this.options.length;this.value=e?[]:this.options.map((t)=>t.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter((t)=>t!==this._value):[...this.value,this._value]}},Ts=Object.defineProperty;Gt=class Gt extends de{constructor({mask:e,...t}){super(t),zr(this,"valueWithCursor",""),zr(this,"_mask","•"),this._mask=e??"•",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${Ce.default.inverse(Ce.default.hidden("_"))}`;else{let o=this.masked.slice(0,this.cursor),n=this.masked.slice(this.cursor);this.valueWithCursor=`${o}${Ce.default.inverse(n[0])}${n.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Os=Object.defineProperty,so=class extends de{constructor(e){super(e,!1),Jr(this,"options"),Jr(this,"cursor",0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(t)=>{switch(t){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}},Ns=Object.defineProperty;qt=class qt extends de{constructor(e){super(e,!1),Yr(this,"options"),Yr(this,"cursor",0),this.options=e.options;let t=this.options.map(({value:[o]})=>o?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on("key",(o)=>{if(!t.includes(o))return;let n=this.options.find(({value:[i]})=>i?.toLowerCase()===o);n&&(this.value=n.value,this.state="submit",this.emit("submit"))})}};Us=Object.defineProperty;Vt=class Vt extends de{constructor(e){super(e),qs(this,"valueWithCursor",""),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),this.valueWithCursor=this.value}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.value}${Ce.default.inverse(Ce.default.hidden("_"))}`;else{let t=this.value.slice(0,this.cursor),o=this.value.slice(this.cursor);this.valueWithCursor=`${t}${Ce.default.inverse(o[0])}${o.slice(1)}`}})}get cursor(){return this._cursor}};Vs=globalThis.process.platform.startsWith("win")});var Ee={};$t(Ee,{cancel:()=>cu,confirm:()=>ou,group:()=>Du,groupMultiselect:()=>uu,intro:()=>lu,isCancel:()=>ot,log:()=>ye,multiselect:()=>su,note:()=>au,outro:()=>mu,password:()=>ru,select:()=>nu,selectKey:()=>iu,spinner:()=>du,text:()=>tu});import ee from"node:process";function js(){return ee.platform!=="win32"?ee.env.TERM!=="linux":Boolean(ee.env.CI)||Boolean(ee.env.WT_SESSION)||Boolean(ee.env.TERMINUS_SUBLIME)||ee.env.ConEmuTask==="{cmd::Cmder}"||ee.env.TERM_PROGRAM==="Terminus-Sublime"||ee.env.TERM_PROGRAM==="vscode"||ee.env.TERM==="xterm-256color"||ee.env.TERM==="alacritty"||ee.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function pu(){let e=["[\\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(e,"g")}var c,Te,Wt,L=(e,t)=>Wt?e:t,Hs,co,lo,nt,Ws,b,z,Kt,zt,Jt,Ge,mo,Ks,ao,zs,Js,Ys,Xs,Qs,Zs,eu,be=(e)=>{switch(e){case"initial":case"active":return c.default.cyan(Hs);case"cancel":return c.default.red(co);case"error":return c.default.yellow(lo);case"submit":return c.default.green(nt)}},tu=(e)=>new Vt({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${c.default.gray(b)}
|
|
21
|
+
${be(this.state)} ${e.message}
|
|
22
|
+
`,o=e.placeholder?c.default.inverse(e.placeholder[0])+c.default.dim(e.placeholder.slice(1)):c.default.inverse(c.default.hidden("_")),n=this.value?this.valueWithCursor:o;switch(this.state){case"error":return`${t.trim()}
|
|
23
|
+
${c.default.yellow(b)} ${n}
|
|
24
|
+
${c.default.yellow(z)} ${c.default.yellow(this.error)}
|
|
25
|
+
`;case"submit":return`${t}${c.default.gray(b)} ${c.default.dim(this.value||e.placeholder)}`;case"cancel":return`${t}${c.default.gray(b)} ${c.default.strikethrough(c.default.dim(this.value??""))}${this.value?.trim()?`
|
|
26
|
+
`+c.default.gray(b):""}`;default:return`${t}${c.default.cyan(b)} ${n}
|
|
27
|
+
${c.default.cyan(z)}
|
|
28
|
+
`}}}).prompt(),ru=(e)=>new Gt({validate:e.validate,mask:e.mask??Ks,render(){let t=`${c.default.gray(b)}
|
|
29
|
+
${be(this.state)} ${e.message}
|
|
30
|
+
`,o=this.valueWithCursor,n=this.masked;switch(this.state){case"error":return`${t.trim()}
|
|
31
|
+
${c.default.yellow(b)} ${n}
|
|
32
|
+
${c.default.yellow(z)} ${c.default.yellow(this.error)}
|
|
33
|
+
`;case"submit":return`${t}${c.default.gray(b)} ${c.default.dim(n)}`;case"cancel":return`${t}${c.default.gray(b)} ${c.default.strikethrough(c.default.dim(n??""))}${n?`
|
|
34
|
+
`+c.default.gray(b):""}`;default:return`${t}${c.default.cyan(b)} ${o}
|
|
35
|
+
${c.default.cyan(z)}
|
|
36
|
+
`}}}).prompt(),ou=(e)=>{let t=e.active??"Yes",o=e.inactive??"No";return new Lt({active:t,inactive:o,initialValue:e.initialValue??!0,render(){let n=`${c.default.gray(b)}
|
|
37
|
+
${be(this.state)} ${e.message}
|
|
38
|
+
`,i=this.value?t:o;switch(this.state){case"submit":return`${n}${c.default.gray(b)} ${c.default.dim(i)}`;case"cancel":return`${n}${c.default.gray(b)} ${c.default.strikethrough(c.default.dim(i))}
|
|
39
|
+
${c.default.gray(b)}`;default:return`${n}${c.default.cyan(b)} ${this.value?`${c.default.green(Kt)} ${t}`:`${c.default.dim(zt)} ${c.default.dim(t)}`} ${c.default.dim("/")} ${this.value?`${c.default.dim(zt)} ${c.default.dim(o)}`:`${c.default.green(Kt)} ${o}`}
|
|
40
|
+
${c.default.cyan(z)}
|
|
41
|
+
`}}}).prompt()},nu=(e)=>{let t=(n,i)=>{let s=n.label??String(n.value);return i==="active"?`${c.default.green(Kt)} ${s} ${n.hint?c.default.dim(`(${n.hint})`):""}`:i==="selected"?`${c.default.dim(s)}`:i==="cancelled"?`${c.default.strikethrough(c.default.dim(s))}`:`${c.default.dim(zt)} ${c.default.dim(s)}`},o=0;return new so({options:e.options,initialValue:e.initialValue,render(){let n=`${c.default.gray(b)}
|
|
42
|
+
${be(this.state)} ${e.message}
|
|
43
|
+
`;switch(this.state){case"submit":return`${n}${c.default.gray(b)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${n}${c.default.gray(b)} ${t(this.options[this.cursor],"cancelled")}
|
|
44
|
+
${c.default.gray(b)}`;default:{let i=e.maxItems===void 0?1/0:Math.max(e.maxItems,5);this.cursor>=o+i-3?o=Math.max(Math.min(this.cursor-i+3,this.options.length-i),0):this.cursor<o+2&&(o=Math.max(this.cursor-2,0));let s=i<this.options.length&&o>0,r=i<this.options.length&&o+i<this.options.length;return`${n}${c.default.cyan(b)} ${this.options.slice(o,o+i).map((u,a,l)=>a===0&&s?c.default.dim("..."):a===l.length-1&&r?c.default.dim("..."):t(u,a+o===this.cursor?"active":"inactive")).join(`
|
|
45
|
+
${c.default.cyan(b)} `)}
|
|
46
|
+
${c.default.cyan(z)}
|
|
47
|
+
`}}}}).prompt()},iu=(e)=>{let t=(o,n="inactive")=>{let i=o.label??String(o.value);return n==="selected"?`${c.default.dim(i)}`:n==="cancelled"?`${c.default.strikethrough(c.default.dim(i))}`:n==="active"?`${c.default.bgCyan(c.default.gray(` ${o.value} `))} ${i} ${o.hint?c.default.dim(`(${o.hint})`):""}`:`${c.default.gray(c.default.bgWhite(c.default.inverse(` ${o.value} `)))} ${i} ${o.hint?c.default.dim(`(${o.hint})`):""}`};return new qt({options:e.options,initialValue:e.initialValue,render(){let o=`${c.default.gray(b)}
|
|
48
|
+
${be(this.state)} ${e.message}
|
|
49
|
+
`;switch(this.state){case"submit":return`${o}${c.default.gray(b)} ${t(this.options.find((n)=>n.value===this.value),"selected")}`;case"cancel":return`${o}${c.default.gray(b)} ${t(this.options[0],"cancelled")}
|
|
50
|
+
${c.default.gray(b)}`;default:return`${o}${c.default.cyan(b)} ${this.options.map((n,i)=>t(n,i===this.cursor?"active":"inactive")).join(`
|
|
51
|
+
${c.default.cyan(b)} `)}
|
|
52
|
+
${c.default.cyan(z)}
|
|
53
|
+
`}}}).prompt()},su=(e)=>{let t=(o,n)=>{let i=o.label??String(o.value);return n==="active"?`${c.default.cyan(Jt)} ${i} ${o.hint?c.default.dim(`(${o.hint})`):""}`:n==="selected"?`${c.default.green(Ge)} ${c.default.dim(i)}`:n==="cancelled"?`${c.default.strikethrough(c.default.dim(i))}`:n==="active-selected"?`${c.default.green(Ge)} ${i} ${o.hint?c.default.dim(`(${o.hint})`):""}`:n==="submitted"?`${c.default.dim(i)}`:`${c.default.dim(mo)} ${c.default.dim(i)}`};return new io({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(o){if(this.required&&o.length===0)return`Please select at least one option.
|
|
54
|
+
${c.default.reset(c.default.dim(`Press ${c.default.gray(c.default.bgWhite(c.default.inverse(" space ")))} to select, ${c.default.gray(c.default.bgWhite(c.default.inverse(" enter ")))} to submit`))}`},render(){let o=`${c.default.gray(b)}
|
|
55
|
+
${be(this.state)} ${e.message}
|
|
56
|
+
`;switch(this.state){case"submit":return`${o}${c.default.gray(b)} ${this.options.filter(({value:n})=>this.value.includes(n)).map((n)=>t(n,"submitted")).join(c.default.dim(", "))||c.default.dim("none")}`;case"cancel":{let n=this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>t(i,"cancelled")).join(c.default.dim(", "));return`${o}${c.default.gray(b)} ${n.trim()?`${n}
|
|
57
|
+
${c.default.gray(b)}`:""}`}case"error":{let n=this.error.split(`
|
|
58
|
+
`).map((i,s)=>s===0?`${c.default.yellow(z)} ${c.default.yellow(i)}`:` ${i}`).join(`
|
|
59
|
+
`);return o+c.default.yellow(b)+" "+this.options.map((i,s)=>{let r=this.value.includes(i.value),u=s===this.cursor;return u&&r?t(i,"active-selected"):r?t(i,"selected"):t(i,u?"active":"inactive")}).join(`
|
|
60
|
+
${c.default.yellow(b)} `)+`
|
|
61
|
+
`+n+`
|
|
62
|
+
`}default:return`${o}${c.default.cyan(b)} ${this.options.map((n,i)=>{let s=this.value.includes(n.value),r=i===this.cursor;return r&&s?t(n,"active-selected"):s?t(n,"selected"):t(n,r?"active":"inactive")}).join(`
|
|
63
|
+
${c.default.cyan(b)} `)}
|
|
64
|
+
${c.default.cyan(z)}
|
|
65
|
+
`}}}).prompt()},uu=(e)=>{let t=(o,n,i=[])=>{let s=o.label??String(o.value),r=typeof o.group=="string",u=r&&(i[i.indexOf(o)+1]??{group:!0}),a=r&&u.group===!0,l=r?`${a?z:b} `:"";return n==="active"?`${c.default.dim(l)}${c.default.cyan(Jt)} ${s} ${o.hint?c.default.dim(`(${o.hint})`):""}`:n==="group-active"?`${l}${c.default.cyan(Jt)} ${c.default.dim(s)}`:n==="group-active-selected"?`${l}${c.default.green(Ge)} ${c.default.dim(s)}`:n==="selected"?`${c.default.dim(l)}${c.default.green(Ge)} ${c.default.dim(s)}`:n==="cancelled"?`${c.default.strikethrough(c.default.dim(s))}`:n==="active-selected"?`${c.default.dim(l)}${c.default.green(Ge)} ${s} ${o.hint?c.default.dim(`(${o.hint})`):""}`:n==="submitted"?`${c.default.dim(s)}`:`${c.default.dim(l)}${c.default.dim(mo)} ${c.default.dim(s)}`};return new Ut({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(o){if(this.required&&o.length===0)return`Please select at least one option.
|
|
66
|
+
${c.default.reset(c.default.dim(`Press ${c.default.gray(c.default.bgWhite(c.default.inverse(" space ")))} to select, ${c.default.gray(c.default.bgWhite(c.default.inverse(" enter ")))} to submit`))}`},render(){let o=`${c.default.gray(b)}
|
|
67
|
+
${be(this.state)} ${e.message}
|
|
68
|
+
`;switch(this.state){case"submit":return`${o}${c.default.gray(b)} ${this.options.filter(({value:n})=>this.value.includes(n)).map((n)=>t(n,"submitted")).join(c.default.dim(", "))}`;case"cancel":{let n=this.options.filter(({value:i})=>this.value.includes(i)).map((i)=>t(i,"cancelled")).join(c.default.dim(", "));return`${o}${c.default.gray(b)} ${n.trim()?`${n}
|
|
69
|
+
${c.default.gray(b)}`:""}`}case"error":{let n=this.error.split(`
|
|
70
|
+
`).map((i,s)=>s===0?`${c.default.yellow(z)} ${c.default.yellow(i)}`:` ${i}`).join(`
|
|
71
|
+
`);return`${o}${c.default.yellow(b)} ${this.options.map((i,s,r)=>{let u=this.value.includes(i.value)||i.group===!0&&this.isGroupSelected(`${i.value}`),a=s===this.cursor;return!a&&typeof i.group=="string"&&this.options[this.cursor].value===i.group?t(i,u?"group-active-selected":"group-active",r):a&&u?t(i,"active-selected",r):u?t(i,"selected",r):t(i,a?"active":"inactive",r)}).join(`
|
|
72
|
+
${c.default.yellow(b)} `)}
|
|
73
|
+
${n}
|
|
74
|
+
`}default:return`${o}${c.default.cyan(b)} ${this.options.map((n,i,s)=>{let r=this.value.includes(n.value)||n.group===!0&&this.isGroupSelected(`${n.value}`),u=i===this.cursor;return!u&&typeof n.group=="string"&&this.options[this.cursor].value===n.group?t(n,r?"group-active-selected":"group-active",s):u&&r?t(n,"active-selected",s):r?t(n,"selected",s):t(n,u?"active":"inactive",s)}).join(`
|
|
75
|
+
${c.default.cyan(b)} `)}
|
|
76
|
+
${c.default.cyan(z)}
|
|
77
|
+
`}}}).prompt()},Ht=(e)=>e.replace(pu(),""),au=(e="",t="")=>{let o=`
|
|
78
|
+
${e}
|
|
79
79
|
`.split(`
|
|
80
|
-
`),
|
|
81
|
-
`);process.stdout.write(`${
|
|
82
|
-
${
|
|
83
|
-
${
|
|
84
|
-
${
|
|
85
|
-
`)}
|
|
80
|
+
`),n=Ht(t).length,i=Math.max(o.reduce((r,u)=>(u=Ht(u),u.length>r?u.length:r),0),n)+2,s=o.map((r)=>`${c.default.gray(b)} ${c.default.dim(r)}${" ".repeat(i-Ht(r).length)}${c.default.gray(b)}`).join(`
|
|
81
|
+
`);process.stdout.write(`${c.default.gray(b)}
|
|
82
|
+
${c.default.green(nt)} ${c.default.reset(t)} ${c.default.gray(ao.repeat(Math.max(i-n-1,1))+zs)}
|
|
83
|
+
${s}
|
|
84
|
+
${c.default.gray(Js+ao.repeat(i+2)+Ys)}
|
|
85
|
+
`)},cu=(e="")=>{process.stdout.write(`${c.default.gray(z)} ${c.default.red(e)}
|
|
86
86
|
|
|
87
|
-
`)},
|
|
88
|
-
`)},
|
|
89
|
-
${
|
|
87
|
+
`)},lu=(e="")=>{process.stdout.write(`${c.default.gray(Ws)} ${e}
|
|
88
|
+
`)},mu=(e="")=>{process.stdout.write(`${c.default.gray(b)}
|
|
89
|
+
${c.default.gray(z)} ${e}
|
|
90
90
|
|
|
91
|
-
`)},
|
|
92
|
-
`);let
|
|
93
|
-
`),
|
|
94
|
-
`);
|
|
91
|
+
`)},ye,du=()=>{let e=Wt?["◒","◐","◓","◑"]:["•","o","O","0"],t=Wt?80:120,o,n,i=!1,s="",r=(p="")=>{i=!0,o=uo(),s=p.replace(/\.+$/,""),process.stdout.write(`${c.default.gray(b)}
|
|
92
|
+
`);let f=0,D=0;n=setInterval(()=>{let h=c.default.magenta(e[f]),E=".".repeat(Math.floor(D)).slice(0,3);process.stdout.write(Te.cursor.move(-999,0)),process.stdout.write(Te.erase.down(1)),process.stdout.write(`${h} ${s}${E}`),f=f+1<e.length?f+1:0,D=D<e.length?D+0.125:0},t)},u=(p="",f=0)=>{s=p??s,i=!1,clearInterval(n);let D=f===0?c.default.green(nt):f===1?c.default.red(co):c.default.red(lo);process.stdout.write(Te.cursor.move(-999,0)),process.stdout.write(Te.erase.down(1)),process.stdout.write(`${D} ${s}
|
|
93
|
+
`),o()},a=(p="")=>{s=p??s},l=(p)=>{let f=p>1?"Something went wrong":"Canceled";i&&u(f,p)};return process.on("uncaughtExceptionMonitor",()=>l(2)),process.on("unhandledRejection",()=>l(2)),process.on("SIGINT",()=>l(1)),process.on("SIGTERM",()=>l(1)),process.on("exit",l),{start:r,stop:u,message:a}},Du=async(e,t)=>{let o={},n=Object.keys(e);for(let i of n){let s=e[i],r=await s({results:o})?.catch((u)=>{throw u});if(typeof t?.onCancel=="function"&&ot(r)){o[i]="canceled",t.onCancel({results:o});continue}o[i]=r}return o};var Fe=C(()=>{jt();jt();c=ze(Tt(),1),Te=ze(Bt(),1);Wt=js(),Hs=L("◆","*"),co=L("■","x"),lo=L("▲","x"),nt=L("◇","o"),Ws=L("┌","T"),b=L("│","|"),z=L("└","—"),Kt=L("●",">"),zt=L("○"," "),Jt=L("◻","[•]"),Ge=L("◼","[+]"),mo=L("◻","[ ]"),Ks=L("▪","•"),ao=L("─","-"),zs=L("╮","+"),Js=L("├","+"),Ys=L("╯","+"),Xs=L("●","•"),Qs=L("◆","*"),Zs=L("▲","!"),eu=L("■","x"),ye={message:(e="",{symbol:t=c.default.gray(b)}={})=>{let o=[`${c.default.gray(b)}`];if(e){let[n,...i]=e.split(`
|
|
94
|
+
`);o.push(`${t} ${n}`,...i.map((s)=>`${c.default.gray(b)} ${s}`))}process.stdout.write(`${o.join(`
|
|
95
95
|
`)}
|
|
96
|
-
`)},info:(
|
|
96
|
+
`)},info:(e)=>{ye.message(e,{symbol:c.default.blue(Xs)})},success:(e)=>{ye.message(e,{symbol:c.default.green(Qs)})},step:(e)=>{ye.message(e,{symbol:c.default.green(nt)})},warn:(e)=>{ye.message(e,{symbol:c.default.yellow(Zs)})},warning:(e)=>{ye.warn(e)},error:(e)=>{ye.message(e,{symbol:c.default.red(eu)})}}});async function te(e){if(!G())return;let{defaultValue:t,message:o}=e,i=await(await Promise.resolve().then(() => (Fe(),Ee))).text({message:o,default:t,placeholder:t});if(typeof i==="symbol")return;return i}async function po(e){if(!G())return;let{message:t}=e,n=await(await Promise.resolve().then(() => (Fe(),Ee))).confirm({message:t});if(typeof n==="symbol")return;return n}function xe(e,t){throw new m(`Missing required argument: --${e}
|
|
97
97
|
Hint: In non-interactive (CI / agent) environments all required flags must be provided.
|
|
98
|
-
In an interactive terminal, run without --${
|
|
99
|
-
`),process.exit(1);return
|
|
100
|
-
Opened: ${
|
|
101
|
-
`),process.stderr.write(`Code: ${
|
|
102
|
-
`),process.stderr.write(`Client: ${
|
|
98
|
+
In an interactive terminal, run without --${e} and the CLI will prompt for it.`,d.USAGE,t)}async function it(e){if(e.value)return e.value;if(G({nonInteractive:e.nonInteractive})){let t=await te({message:e.message});if(!t)process.stderr.write(e.cancelMessage+`
|
|
99
|
+
`),process.exit(1);return t}xe(e.flagName,e.usageHint)}var pe=C(()=>{R();S()});function J(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:"***"}async function fo(e){let t=Je[e],{randomBytes:o,createHash:n}=await import("crypto"),i=o(32).toString("base64url"),s=n("sha256").update(i).digest("base64url"),r=o(16).toString("base64url"),u=await fetch(`${t}/oauth2/device/code`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:Do,scope:hu.join(" "),code_challenge:s,code_challenge_method:"S256",state:r})});if(!u.ok){let f=await u.text().catch(()=>"");throw new m(`Failed to start device-code flow (HTTP ${u.status}).`,d.AUTH,f||`URL: ${t}/oauth2/device/code`)}let a=await u.json();if(a.state!==r)throw new m("OAuth state mismatch.",d.AUTH);Cu(a.verification_uri),process.stderr.write(`
|
|
100
|
+
Opened: ${a.verification_uri}
|
|
101
|
+
`),process.stderr.write(`Code: ${a.user_code}
|
|
102
|
+
`),process.stderr.write(`Client: ${fu}
|
|
103
103
|
`),process.stderr.write(`Waiting for authorization...
|
|
104
|
-
`);let
|
|
105
|
-
${
|
|
106
|
-
`)});function
|
|
104
|
+
`);let l=a.expired_in,p=a.interval||3000;while(Date.now()<l){await gu(p);let f=await fetch(`${t}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:Do,user_code:a.user_code,code_verifier:i})});if(!f.ok)throw new m(`Device-code authorization failed (HTTP ${f.status}).`,d.AUTH);let D=await f.json();if(D.status==="pending")continue;if(D.status==="success"&&D.access_token)return{access_token:D.access_token,refresh_token:D.refresh_token??"",expires_at:new Date(D.expired_in??Date.now()).toISOString(),region:e,resource_url:D.resource_url};throw new m(`Device-code authorization failed: ${D.status}`,d.AUTH)}throw new m("Device-code authorization timed out.",d.TIMEOUT)}function gu(e){return new Promise((t)=>setTimeout(t,e))}function Cu(e){let{execFile:t,spawn:o}=Be("child_process");if(process.platform==="darwin")t("open",[e]);else if(process.platform==="win32")o("cmd.exe",["/c","start","",e],{shell:!1,detached:!0});else t("xdg-open",[e])}var Do="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",fu="MiniMax CLI",hu;var ho=C(()=>{re();R();S();hu=["openid","profile","coding_plan"]});async function Y(){return P().oauth??null}async function st(e){let t=P();t.oauth=e,await K(t)}async function go(){let e=P();if(!("oauth"in e))return;delete e.oauth,await K(e)}var De=C(()=>{se()});function ut(e){return`Looked for credentials in: ${e??oe()}
|
|
105
|
+
${yu}`}var yu;var Yt=C(()=>{Ie();yu=["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 Me(e){return e.replace(/^https?:\/\//,"")}async function yo(e){if(e.apiKey||e.fileApiKey)return;if(await Y())return;let t=process.env.MINIMAX_API_KEY;if(t){if(!G({nonInteractive:e.nonInteractive}))return;if(await po({message:`Found MINIMAX_API_KEY in environment (${J(t)}). Save to config file?`}))await Co(e,t);return}if(!G({nonInteractive:e.nonInteractive}))throw new m("No credentials found.",d.AUTH,ut(e.configPath));let o=await Xt();if(o==="api-key"){let n=await te({message:"Enter your MiniMax API key:"});if(!n)throw new m("API key is required.",d.AUTH);await Co(e,n);return}await Qt(o==="oauth-cn"?"cn":"global")}async function Xt(){let{select:e,isCancel:t}=await Promise.resolve().then(() => (Fe(),Ee)),o=await e({message:"How would you like to authenticate?",options:bu.map((n)=>({value:n.value,label:n.label}))});if(t(o))throw new m("Authentication cancelled.",d.AUTH);return o}async function bo(){let{select:e,isCancel:t}=await Promise.resolve().then(() => (Fe(),Ee)),o=await e({message:"Select an OAuth region:",options:[{value:"global",label:`Global → ${Me(U.global)}`},{value:"cn",label:`China → ${Me(U.cn)}`}]});if(t(o))throw new m("Authentication cancelled.",d.AUTH);return o}async function Qt(e){let t=await fo(e),o=P();delete o.api_key,o.oauth=t,o.region=e,await K(o),process.stderr.write(`Logged in successfully.
|
|
107
107
|
`),process.stderr.write(`Credentials saved to ~/.mmx/config.json
|
|
108
|
-
`)}async function
|
|
109
|
-
`)}var
|
|
110
|
-
Re-authenticate: mmx auth login`)}async function
|
|
108
|
+
`)}async function Co(e,t){let o={...P(),api_key:t};await K(o),e.fileApiKey=t,process.stderr.write(`API key saved to ${e.configPath??"~/.mmx/config.json"}
|
|
109
|
+
`)}var bu;var Zt=C(()=>{re();se();pe();R();S();ho();De();Yt();bu=[{value:"oauth-global",label:`MiniMax (OAuth login → ${Me(U.global)})`},{value:"oauth-cn",label:`MiniMax (OAuth login → ${Me(U.cn)})`},{value:"api-key",label:`API key (${Me(U.global)} or ${Me(U.cn)})`}]});async function er(e,t="global"){let o=`${Je[t]}/oauth2/token`,n=null;for(let i=0;i<=Eo;i++){if(i>0)await new Promise((u)=>setTimeout(u,Fu*i));let s;try{s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:e,client_id:Eu}),signal:AbortSignal.timeout(xu)})}catch(u){let a=u instanceof Error&&(u.name==="AbortError"||u.name==="TimeoutError"||u.message.includes("timed out"));n=Error(a?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${u instanceof Error?u.message:String(u)}`);continue}if(!s.ok){if(s.status>=400&&s.status<500)throw new m("OAuth session expired and could not be refreshed.",d.AUTH,"Re-authenticate: mmx auth login");n=Error(`Token refresh failed: HTTP ${s.status}`);continue}let r=await s.json();if(r.status!=="success"||!r.access_token)throw new m(`OAuth refresh failed: ${r.status}.`,d.AUTH,"Re-authenticate: mmx auth login");return{access_token:r.access_token,refresh_token:r.refresh_token??e,expires_at:new Date(r.expired_in??Date.now()).toISOString(),resource_url:r.resource_url}}throw new m(`Token refresh failed after ${Eo+1} attempts: ${n?.message}`,d.AUTH,`Check your network connection.
|
|
110
|
+
Re-authenticate: mmx auth login`)}async function Fo(e){let t=new Date(e.expires_at).getTime();if(Date.now()<t-wu)return e.access_token;let o=await er(e.refresh_token,e.region??"global"),n={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:o.expires_at,region:e.region,resource_url:o.resource_url??e.resource_url,account:e.account};return await st(n),n.access_token}var Eu="659cf4c1-615c-45f6-a5f6-4bf15eb476e5",Eo=2,Fu=500,xu=1e4,wu=300000;var tr=C(()=>{re();De();R();S()});async function at(e){if(e.apiKey)return{token:e.apiKey,method:"api-key",source:"flag"};let t=await Y();if(t)return{token:await Fo(t),method:"oauth",source:"config.json"};if(e.fileApiKey)return{token:e.fileApiKey,method:"api-key",source:"config.json"};throw new m("No credentials found.",d.AUTH,ut(e.configPath))}var rr=C(()=>{De();tr();R();S();Yt()});function xo(e){if(!e)return"";if(e.includes("/t2a"))return`
|
|
111
111
|
|
|
112
|
-
Speech models require the Plus plan or above.`;if(
|
|
112
|
+
Speech models require the Plus plan or above.`;if(e.includes("/image_generation"))return`
|
|
113
113
|
|
|
114
|
-
image-01 requires the Plus plan or above.`;if(
|
|
114
|
+
image-01 requires the Plus plan or above.`;if(e.includes("/video_generation")||e.includes("/query/video_generation"))return`
|
|
115
115
|
|
|
116
|
-
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`)
|
|
123
|
-
`),
|
|
124
|
-
|
|
125
|
-
`);
|
|
126
|
-
|
|
127
|
-
`)
|
|
128
|
-
|
|
129
|
-
`)
|
|
130
|
-
|
|
131
|
-
`)}let m=Q();delete m.oauth,m.api_key=e,m.region=r,await f(m),process.stderr.write(`API key saved to ${it()}
|
|
132
|
-
`),await tr(o)}var er;var nr=h(()=>{J();k();d();pn();O();Re();_n();kt();mt();nt();er=A({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,e){let i=process.env.MINIMAX_API_KEY;if(i&&!e.apiKey){let m=E(i);if(N({nonInteractive:t.nonInteractive})){let{confirm:n,isCancel:p}=await Promise.resolve().then(() => (ht(),vt)),u=await n({message:`MINIMAX_API_KEY is set (${m}). Configure persistent credentials anyway?`,initialValue:!1});if(p(u)||!u)process.stdout.write(`Login skipped. Using environment variable.
|
|
116
|
+
Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;return""}function wo(e){return`${e?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function qe(e,t,o){let n=t.base_resp?.status_msg||t.error?.message||`HTTP ${e}`,i=t.base_resp?.status_code||t.error?.code,s=t.error?.type;if(e===401||e===403)return new m(`API key rejected (HTTP ${e}).`,d.AUTH,`Check status: mmx auth status
|
|
117
|
+
Re-authenticate: mmx auth login`);if(e===429)return new m(`Rate limit or quota exceeded. ${n}`,d.QUOTA,"Check usage: mmx quota show");if(e===402||s==="insufficient_balance_error")return new m(`Quota or balance exhausted. ${n}`,d.QUOTA,"Check your MiniMax account balance and billing settings.");if(e===408||e===504)return new m(`Request timed out (HTTP ${e}).`,d.TIMEOUT,"Try increasing --timeout or retry later.");let r=e===422&&s==="unprocessable_entity_error"&&(/sensitive content/i.test(n)||/(?:^|\D)1026(?:\D|$)/.test(n));if(i===1002||i===1039||r){let u=t.base_resp?.status_msg||t.error?.message||"content sensitivity";return new m(`Input content flagged by sensitivity filter (${u}).`,d.CONTENT_FILTER)}if(i===1028||i===1030){let u=xo(o);return new m(`Quota exhausted. ${n}`,d.QUOTA,`Check usage: mmx quota show${u}
|
|
118
|
+
Upgrade plan: ${wo(o)}`)}if(i===2061){let u=xo(o);return new m(`This model is not available on your current Token Plan. ${n}`,d.QUOTA,`Check usage: mmx quota show${u}
|
|
119
|
+
Upgrade plan: ${wo(o)}`)}return new m(`API error: ${n} (HTTP ${e})`,d.GENERAL)}var or=C(()=>{R();S()});import{homedir as vo}from"os";function ku(e){return e.startsWith(vo())?e.replace(vo(),"~"):e}function Ru(e){return e.replace(/^https?:\/\//,"")}function _o(e,t,o){if(e.quiet||$o||!process.stderr.isTTY)return;$o=!0;let n=e.configPath?ku(e.configPath):"~/.mmx/config.json",i=Ru(e.baseUrl),s=e.apiKey?"(flag)":"(file)",r=J(t),u=o?` ${fe}|${Q} ${fe}Model:${Q} ${_u}${o}${Q}`:"";process.stderr.write(`${vu}${$u}MINIMAX${Q} ${fe}${n}${Q} ${fe}|${Q} ${fe}URL:${Q} ${Au}${i}${Q} ${fe}|${Q} ${fe}Key:${Q} ${Su}${r}${Q} ${fe}${s}${Q}${u}
|
|
120
|
+
`)}var $o=!1,Q="\x1B[0m",fe="\x1B[2m",vu="\x1B[1m",$u="\x1B[38;2;43;82;255m",_u="\x1B[38;2;147;51;234m",Au="\x1B[38;2;6;184;212m",Su="\x1B[38;2;236;72;153m";var Ao=()=>{};var So=()=>{};var we="1.0.21";var ct=C(()=>{So()});function ko(e){return new DOMException(e,"TimeoutError")}function Bu(e,t,o){if(!e.body)return e;let n=e.body.getReader(),i=!1,s=()=>{if(i)return;i=!0,n.releaseLock()},r=async(l)=>{if(!o.signal.aborted)o.abort(l);try{await n.cancel(l)}finally{s()}},u=new ReadableStream({async pull(l){let p;try{let f=await new Promise((D,h)=>{p=setTimeout(()=>{let E=ko(`Stream received no data for ${t}ms.`);o.abort(E),h(E)},t),n.read().then(D,h)});if(f.done)s(),l.close();else l.enqueue(f.value)}catch(f){await r(f).catch(()=>{}),l.error(f)}finally{if(p)clearTimeout(p)}},cancel(l){return r(l)}}),a=new Response(u,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(a,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),a}async function ve(e,t){let o=typeof FormData<"u"&&t.body instanceof FormData,n={"User-Agent":`mmx-cli/${we}`,...t.headers};if(!o&&!n["Content-Type"])n["Content-Type"]="application/json";if(!t.noAuth){let a=await at(e);if(t.authStyle==="x-api-key")n["x-api-key"]=a.token;else n.Authorization=`Bearer ${a.token}`;if(e.verbose)process.stderr.write(`> ${t.method??"GET"} ${t.url}
|
|
121
|
+
`),process.stderr.write(`> Auth: ${a.token.slice(0,8)}...
|
|
122
|
+
`);let l=t.body&&typeof t.body==="object"&&"model"in t.body?String(t.body.model):void 0;_o(e,a.token,l)}let i=(t.timeout??e.timeout)*1000,s=t.stream?new AbortController:void 0,r=s?setTimeout(()=>{s.abort(ko(`Request headers were not received within ${i}ms.`))},i):void 0,u;try{u=await fetch(t.url,{method:t.method??"GET",headers:n,body:t.body?o?t.body:JSON.stringify(t.body):void 0,signal:s?.signal??AbortSignal.timeout(i)})}finally{if(r)clearTimeout(r)}if(s)u=Bu(u,i,s);if(e.verbose)process.stderr.write(`< ${u.status} ${u.statusText}
|
|
123
|
+
`);if(!u.ok){let a={};try{a=await u.json()}catch{}throw qe(u.status,a,t.url)}return u}async function A(e,t){let o=await ve(e,t),n;try{n=await o.json()}catch{let i=o.headers.get("content-type")||"";throw new m(`API returned non-JSON response (${i||"unknown type"}). Server may be experiencing issues.`,d.GENERAL)}if(n.base_resp?.status_code&&n.base_resp.status_code!==0)throw qe(200,{base_resp:n.base_resp},t.url);return n}var V=C(()=>{R();S();rr();or();Ao();ct()});function lt(e){return`${e}/anthropic/v1/messages`}function Ro(e){return`${e}/v1/t2a_v2`}function Bo(e){return`${e}/v1/get_voice`}function Io(e){return`${e}/v1/image_generation`}function To(e){return`${e}/v1/video_generation`}function Mo(e){return`${e}/v2/video_generation`}function mt(e,t){return`${e}/v1/query/video_generation?task_id=${t}`}function dt(e,t){return`${e}/v2/query/video_generation/${t}`}function pt(e,t){return`${e}/v1/files/retrieve?file_id=${t}`}function Oo(e){return`${e}/v1/coding_plan/search`}function Po(e){return`${e}/v1/coding_plan/vlm`}function $e(e){return`${e}/v1/token_plan/remains`}function Iu(e){return`${e}/account/query_balance`}function nr(e){return e.startsWith("sk-api-")}function ne(e,t){return nr(t)?Iu(e):$e(e)}function No(e){return`${e}/v1/files/upload`}function Lo(e){return`${e}/v1/files/list`}function Uo(e){return`${e}/v1/files/delete`}function Tu(e){return e?"on":"off"}function Go(e,t){if(console.log("Account Balance:"),console.log(` Available: ${e.available_amount}`),console.log(` Cash: ${e.cash_balance}`),console.log(` Voucher: ${e.voucher_balance}`),console.log(` Credit: ${e.credit_balance}`),console.log(` Owed: ${e.owed_amount}`),console.log(` Alert: ${Tu(e.balance_alert_switch)}`),e.balance_alert_threshold)console.log(` Threshold: ${e.balance_alert_threshold}`)}function Wo(e){if(e>=50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(e>=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 Nu(e,t){if(t!=="cn")return e;return Pu[e]??e}function Lu(e,t){if(e<=0)return t;let o=Math.floor(e/3600000),n=Math.floor(e%3600000/60000);return o>0?`${o}h ${n}m`:`${n}m`}function qo(e){return new Date(e).toISOString().slice(0,10)}function Uu(e){return e>=11904&&e<=40959||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65281&&e<=65376||e>=131072&&e<=195103}function Z(e){let t=e.replace(/\x1b\[[0-9;]*m/g,""),o=0;for(let n of t)o+=Uu(n.codePointAt(0))?2:1;return o}function Vu(e){return e===3}function ju(e){return e.current_interval_total_count===0&&e.current_weekly_total_count===0&&e.current_interval_status===3&&e.current_weekly_status===3}function ir(e){return Math.max(0,Math.min(qu,Math.round(e)))}function Hu(e){if(e===void 0||e===null)return 1;return Math.max(0,e)/1000}function Wu(e,t,o,n){let i=Hu(n);if(e!==void 0&&e!==null)return ir(e*i);return o>0?ir(t/o*100*i):0}function Ku(e,t,o=Gu,n=!0){let i=ir(e),s=Math.min(1,i/100),r=Math.round(o*s),u=o-r,a=`${i}%`.padStart(4);if(!t){let D=`[${"█".repeat(r)}${".".repeat(u)}]`;return n?`${D} ${a}`:D}let[l,p]=Wo(i),f=`${p}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(u)}\x1B[0m`;return n?`${f} ${l}\x1B[1m${a}\x1B[0m`:f}function Vo(e,t,o,n,i,s,r,u){if(r){let f=(u??zu).padStart(4);if(i){let h=`\x1B[48;2;22;163;74m${" ".repeat(Ve)}\x1B[0m`;return`\x1B[2m${e}\x1B[0m ${h} \x1B[38;2;74;222;128m\x1B[1m${f}\x1B[0m`}let D=`[${"█".repeat(Ve)}]`;return`${e} ${D} ${f}`}let a=Wu(n,t,o,s),l=Ku(a,i,Ve,o<=0);if(o>0){let p=`${t.toLocaleString()} / ${o.toLocaleString()}`;return i?`\x1B[2m${e}\x1B[0m ${l} ${Wo(a)[0]}${p}\x1B[0m`:`${e} ${l} ${p}`}return`${e} ${l}`}function jo(e,t,o){if(o){let n=`\x1B[48;2;55;65;81m${" ".repeat(Ve)}\x1B[0m`;return`\x1B[2m${e}\x1B[0m ${n} \x1B[38;2;248;113;113m\x1B[1m${t}\x1B[0m`}return`${e} [${".".repeat(Ve)}] ${t}`}function Dt(e,t,o,n,i){return i?`\x1B[2m${t}${o.repeat(e)}${n}\x1B[0m`:`+${"-".repeat(e)}+`}function Ho(e,t,o,n){let i=Math.max(0,t-2-o);return n?`${"\x1B[2m"}│${"\x1B[0m"} ${e}${" ".repeat(i)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${e}${" ".repeat(i)} |`}function Ko(e,t){let o=!t.noColor&&process.stdout.isTTY===!0,n=t.region==="cn"?Ou:Mu,i=e.map((g)=>{let y=Nu(g.model_name,t.region),v=ju(g),k=v?jo(n.current,n.notInPlan,o):Vo(n.current,g.current_interval_usage_count,g.current_interval_total_count,g.current_interval_remaining_percent,o),B=v?jo(n.weekly,n.notInPlan,o):Vo(n.weekly,g.current_weekly_usage_count,g.current_weekly_total_count,g.current_weekly_remaining_percent,o,g.weekly_boost_permille,Vu(g.current_weekly_status),t.region==="cn"?Ju:Yu),M=v?`${n.resetsIn} —`:`${n.resetsIn} ${Lu(g.remains_time,n.now)}`;return{displayName:y,current:k,weekly:B,reset:M}}),s=Math.max(6,...i.map((g)=>Z(g.displayName))),r=Math.max(...i.map((g)=>Z(g.current)),18),u=Math.max(...i.map((g)=>Z(g.weekly)),18),a=Math.max(...i.map((g)=>Z(g.reset)),10),l=Math.max(72,s+2+r+2+u+2+a+4),p=e.length>0?`${qo(e[0].weekly_start_time)} — ${qo(e[0].weekly_end_time)}`:"",f=`MINIMAX ${n.dashboard}`,D=`${n.week}: ${p}`,h=Math.max(2,l-2-Z(f)-Z(D)),E=o?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${n.dashboard}\x1B[0m${" ".repeat(h)}\x1B[2m${n.week}:\x1B[0m \x1B[38;2;6;184;212m${p}\x1B[0m`:`${f}${" ".repeat(h)}${D}`,x=Z(f)+h+Z(D);if(console.log(""),console.log(Dt(l,"╭","─","╮",o)),console.log(Ho(E,l,x,o)),e.length===0){console.log(Dt(l,"╰","─","╯",o)),console.log(`
|
|
124
|
+
${n.noData}
|
|
125
|
+
`);return}for(let g of i){console.log(Dt(l,"├","─","┤",o));let v=`${o?`\x1B[1m${g.displayName}\x1B[0m`:g.displayName}${" ".repeat(Math.max(1,s-Z(g.displayName)+2))}${g.current}${" ".repeat(Math.max(1,r-Z(g.current)+2))}${g.weekly}${" ".repeat(Math.max(1,u-Z(g.weekly)+2))}`+g.reset;console.log(Ho(v,l,Z(v),o))}console.log(Dt(l,"╰","─","╯",o)),console.log("")}var Mu,Ou,Pu,Gu=16,Ve=10,qu=200,zu="∞",Ju="无限",Yu="unlimited";var zo=C(()=>{Mu={dashboard:"TokenPlan Quota",week:"Week",current:"Left",weekly:"Wk left",resetsIn:"Reset",noData:"No quota data available.",now:"now",notInPlan:"not in plan"},Ou={dashboard:"TokenPlan 配额面板",week:"周期",current:"剩余",weekly:"周剩余",resetsIn:"重置",noData:"暂无配额数据",now:"即将",notInPlan:"不在当前套餐中"},Pu={general:"通用",video:"视频"}});function ue(e,t,o){if(o&&nr(o)){Go(e,t);return}Ko(e.model_remains||[],t)}var ft=C(()=>{zo()});async function Xu(e,t,o){let n=[{Authorization:`Bearer ${t}`},{"x-api-key":t}],i=!1,s=!1;for(let r of n){let u;try{u=await fetch(ne(U[e],t),{headers:{...r,"Content-Type":"application/json"},signal:AbortSignal.timeout(o)})}catch{i=!0;continue}if(u.status===401||u.status===403)continue;if(!u.ok){s=!0;continue}try{if((await u.json()).base_resp?.status_code===0)return"authorized";s=!0}catch{s=!0}}if(s)return"inconclusive";if(i)return"unreachable";return"unauthorized"}async function ht(e){process.stderr.write("Detecting region...");let t=Object.keys(U),o=await Promise.all(t.map(async(s)=>({region:s,result:await Xu(s,e,5000)}))),n=o.find((s)=>s.result==="authorized");if(!n){process.stderr.write(` failed
|
|
126
|
+
`);let s=e.startsWith("sk-api-")?"No credentials were changed. Check that the key is valid and belongs to an API secret key.":"No credentials were changed. Check that the key is valid and belongs to a Token Plan.";if(o.every((r)=>r.result==="unauthorized"))throw new m("API key was rejected by all regions.",d.AUTH,s);if(o.some((r)=>r.result==="unreachable"))throw new m("Could not reach the regional API endpoints.",d.NETWORK,"No region was changed. Check the network or proxy, then retry or pass --region global|cn explicitly.");throw new m("Could not determine the API key region.",d.GENERAL,"No region was changed because the API returned an inconclusive response. Retry later or pass --region global|cn explicitly.")}let i=n.region;return process.stderr.write(` ${i}
|
|
127
|
+
`),i}async function Jo(e){let t=P();t.region=e,await K(t)}var sr=C(()=>{re();se();R();S()});function Qu(e){if(e instanceof m)return e.exitCode===d.NETWORK||e.exitCode===d.TIMEOUT;if(!(e instanceof Error))return!1;if(e.name==="AbortError"||e.name==="TimeoutError")return!0;let t=e.message.toLowerCase(),o="code"in e?String(e.code).toLowerCase():"";return e instanceof TypeError&&t==="fetch failed"||t.includes("failed to fetch")||t.includes("unable to connect")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||o==="connectionrefused"||o==="econnrefused"||o==="econnreset"||o==="enotfound"||o==="etimedout"}async function Zu(e){try{let t=e.apiKey||e.fileApiKey;if(t&&t.startsWith("sk-api-")){let i=ne(e.baseUrl,t),s=await A(e,{url:i});ue(s,e,t);return}let o=$e(e.baseUrl),n=await A(e,{url:o});ue(n,e)}catch{}}async function Qo(e){let{registry:t}=await Promise.resolve().then(() => (gt(),tn));t.printHelp([],process.stderr,e.region),await Zu(e)}async function Yo(e,t){await Qt(t);let o=P(),n={...e,region:t,baseUrl:o.oauth?.resource_url||U[t]};await Qo(n)}async function Xo(e,t,o){if(e.dryRun){console.log("Would validate and save API key.");return}let n=o??await ht(t),i={...e,region:n,baseUrl:U[n],apiKey:t},s=ne(i.baseUrl,t);try{await A(i,{url:s})}catch(u){if(u instanceof m&&u.exitCode===d.AUTH){let l=t.startsWith("sk-api-")?"Check that your key is valid and belongs to an API secret key.":"Check that your key is valid and belongs to a Token Plan.";throw new m("API key validation failed.",d.AUTH,l)}if(!o)throw u;let a=Qu(u)?`the ${n} API endpoint is unreachable`:`the ${n} API endpoint returned an inconclusive response`;process.stderr.write(`Warning: Could not validate the API key because ${a}.
|
|
128
|
+
Saving the explicitly selected region "${n}". Requests may fail until validation succeeds.
|
|
129
|
+
`)}let r=P();delete r.oauth,r.api_key=t,r.region=n,await K(r),process.stderr.write(`API key saved to ${oe()}
|
|
130
|
+
`),await Qo(i)}var Zo;var en=C(()=>{T();R();S();Zt();V();ft();sr();Ie();se();re();Zo=w({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--api-key <key>] [--recommend] [--region=global|cn]",options:[{flag:"--api-key <key>",description:"Skip the menu and save this API key directly"},{flag:"--recommend",description:"Skip the menu, go straight to OAuth (combine with --region= to skip the region picker)"}],examples:["mmx auth login","mmx auth login --api-key sk-cp-xxxxx","mmx auth login --recommend","mmx auth login --recommend --region=global","mmx auth login --recommend --region=cn"],async run(e,t){let o=process.env.MINIMAX_API_KEY;if(o&&!t.apiKey){let s=J(o);if(G({nonInteractive:e.nonInteractive})){let{confirm:r,isCancel:u}=await Promise.resolve().then(() => (Fe(),Ee)),a=await r({message:`MINIMAX_API_KEY is set (${s}). Configure persistent credentials anyway?`,initialValue:!1});if(u(a)||!a)process.stdout.write(`Login skipped. Using environment variable.
|
|
133
131
|
`),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
|
|
134
|
-
`)}if(
|
|
135
|
-
`);try{let
|
|
136
|
-
Or set $MINIMAX_API_KEY`},
|
|
137
|
-
`);return}if(
|
|
138
|
-
`);if(
|
|
139
|
-
`)}}})});async function*
|
|
140
|
-
${
|
|
141
|
-
`);
|
|
142
|
-
`),process.exit(1);
|
|
132
|
+
`)}if(t.apiKey){await Xo(e,t.apiKey,t.region);return}if(e.dryRun){console.log("Would prompt for auth method (oauth-global, oauth-cn, api-key).");return}if(!G({nonInteractive:e.nonInteractive}))throw new m("--api-key is required in non-interactive mode.",d.USAGE,"mmx auth login --api-key sk-xxxxx");if(t.recommend){let s=t.region||await bo();await Yo(e,s);return}let n=await Xt();if(n==="api-key"){let{text:s,isCancel:r}=await Promise.resolve().then(() => (Fe(),Ee)),u=await s({message:"Paste your MiniMax API key:",validate:(a)=>a&&a.length>0?void 0:"API key cannot be empty."});if(r(u))throw new m("Authentication cancelled.",d.AUTH);await Xo(e,u,t.region);return}let i=t.region||(n==="oauth-cn"?"cn":"global");await Yo(e,i)}})});var rn;var on=C(()=>{T();rr();De();N();V();ft();rn=w({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(e,t){try{let o=await at(e),n=_(e.output);if(n!=="text"){let s={method:o.method,source:o.source};if(o.method==="oauth"){let r=await Y();if(r){if(s.token_expires=r.expires_at,r.account)s.account=r.account}}else{s.key=J(o.token);let r=ne(e.baseUrl,o.token),u=await A(e,{url:r});s.usage=u}console.log(F(s,n));return}console.log("Authentication Status:"),console.log(` Method: ${o.method}`),console.log(` Source: ${o.source}`);let i=o.token;if(console.log(` Key: ${J(i)}`),o.method==="oauth"){let s=await Y();if(s){if(s.account)console.log(` Account: ${s.account}`);let r=new Date(s.expires_at),u=Math.round((r.getTime()-Date.now())/60000);console.log(` Expires in: ${u} minutes`)}}else{let s=ne(e.baseUrl,i);try{let r=await A(e,{url:s});ue(r,e,i)}catch(r){console.log(` Quota fetch failed: ${r.message}`)}return}process.stderr.write(`Fetching quota snapshot...
|
|
133
|
+
`);try{let s=$e(e.baseUrl),r=await A(e,{url:s,method:"GET"});ue(r,e)}catch(s){console.log(` Quota fetch failed: ${s.message}`)}}catch{let o=_(e.output);console.log(F({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
|
|
134
|
+
Or set $MINIMAX_API_KEY`},o))}}})});var nn;var sn=C(()=>{T();R();S();De();tr();N();nn=w({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(e,t){let o=await Y();if(!o)throw new m("Not applicable: not authenticated via OAuth.",d.USAGE,"Run mmx auth login first.");if(e.dryRun){console.log("Would refresh OAuth token.");return}let n=await er(o.refresh_token,o.region??"global"),i={access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at,region:o.region,resource_url:n.resource_url??o.resource_url,account:o.account};await st(i);let s=_(e.output);if(e.quiet){console.log(i.expires_at);return}console.log(F({status:"Token refreshed",expires:i.expires_at},s))}})});var un;var an=C(()=>{T();De();se();un=w({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(e,t){let o=await Y(),i=!!P().api_key;if(e.dryRun){if(o)console.log("Would clear oauth from ~/.mmx/config.json");if(i)console.log("Would clear api_key from ~/.mmx/config.json");if(!o&&!i)console.log("No credentials to clear.");console.log("No changes made.");return}if(!o&&!i){process.stderr.write(`No credentials to clear.
|
|
135
|
+
`);return}if(o)await go(),process.stderr.write(`Cleared oauth from ~/.mmx/config.json
|
|
136
|
+
`);if(i){let s=P();delete s.api_key,await K(s),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
|
|
137
|
+
`)}}})});async function*Oe(e){let t=e.body?.getReader();if(!t)return;let o=new TextDecoder,n="",i={},s=(r)=>{let u=r.endsWith("\r")?r.slice(0,-1):r;if(u===""){let f=i.data!==void 0?{data:i.data,event:i.event,id:i.id}:void 0;return i={},f}if(u.startsWith(":"))return;let a=u.indexOf(":");if(a===-1)return;let l=u.slice(0,a),p=u.slice(a+1).trimStart();switch(l){case"data":i.data=i.data!==void 0?`${i.data}
|
|
138
|
+
${p}`:p;break;case"event":i.event=p;break;case"id":i.id=p;break}return};try{while(!0){let{done:r,value:u}=await t.read();if(r)break;n+=o.decode(u,{stream:!0});let a=n.split(`
|
|
139
|
+
`);n=a.pop()||"";for(let l of a){let p=s(l);if(p)yield p}}if(n+=o.decode(),n.length>0){let r=s(n);if(r)yield r}if(i.data!==void 0)yield{data:i.data,event:i.event,id:i.id}}finally{t.releaseLock()}}import{readFileSync as ur}from"fs";function ln(e,t,o){let n=(1-Math.abs(2*o-1))*t,i=n*(1-Math.abs(e/60%2-1)),s=o-n/2,r=0,u=0,a=0;if(e<60)r=n,u=i;else if(e<120)r=i,u=n;else if(e<180)u=n,a=i;else if(e<240)u=i,a=n;else if(e<300)r=i,a=n;else r=n,a=i;return[Math.round((r+s)*255),Math.round((u+s)*255),Math.round((a+s)*255)]}class mn{frame=0;startTime=0;timer=null;out;noColor;constructor(e,t){this.out=e,this.noColor=t}start(){this.frame=0,this.startTime=Date.now(),this.tick(),this.timer=setInterval(()=>this.tick(),80)}stop(){if(this.timer)clearInterval(this.timer),this.timer=null;this.out.write("\r\x1B[0K")}tick(){let e=cn[this.frame%cn.length],t=Math.floor((Date.now()-this.startTime)/1000),o=t>=60?`Thinking (${Math.floor(t/60)}m ${t%60}s)`:`Thinking (${t}s)`;if(this.frame++,this.noColor)this.out.write(`\r${e} ${o}\x1B[0K`);else{let[n,i,s]=ln(this.frame*17%360,0.85,0.55),[r,u,a]=ln((this.frame*17+40)%360,0.85,0.55);this.out.write(`\r\x1B[38;2;${n};${i};${s}m${e}\x1B[0m \x1B[38;2;${r};${u};${a}m${o}\x1B[0m\x1B[0K`)}}}function ea(e){let t=[],o;if(e.system)o=e.system;if(e.messagesFile){let n=e.messagesFile,i=n==="-"?ur("/dev/stdin","utf-8"):ur(n,"utf-8"),s=JSON.parse(i);for(let r of s)if(r.role==="system")o=typeof r.content==="string"?r.content:"";else t.push(r)}if(!e.message&&e.prompt)e.message=Array.isArray(e.prompt)?e.prompt:[e.prompt];if(e.message){let n=new Set(["system","user","assistant"]),i=e.message;for(let s of i){let r=s.indexOf(":"),u=r!==-1?s.slice(0,r):"";if(n.has(u)){let a=s.slice(r+1);if(u==="system")o=a;else t.push({role:u,content:a})}else t.push({role:"user",content:s})}}return{system:o,messages:t}}function ta(e){return e.filter((t)=>t.type==="text").map((t)=>t.text).join("")}var cn,dn;var pn=C(()=>{T();V();N();R();S();pe();cn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];dn=w({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(e,t){let{system:o,messages:n}=ea(t),i=n;if(i.length===0)if(G({nonInteractive:e.nonInteractive})){let p=await te({message:"Enter your message:"});if(!p)process.stderr.write(`Chat cancelled.
|
|
140
|
+
`),process.exit(1);i=[{role:"user",content:p}]}else xe("message","mmx text chat --message <text>");let s=t.model||e.defaultTextModel||"MiniMax-M3",r=_(e.output),u=t.stream===!0||t.stream===void 0&&r!=="json"&&process.stdout.isTTY,a={model:s,messages:i,max_tokens:t.maxTokens??4096,stream:u};if(o)a.system=o;if(t.temperature!==void 0)a.temperature=t.temperature;if(t.topP!==void 0)a.top_p=t.topP;if(t.tool){let p=t.tool.map((f)=>{try{return JSON.parse(f)}catch{try{let D=ur(f,"utf-8");return JSON.parse(D)}catch{throw new m(`Invalid tool definition: "${f}" is neither valid JSON nor a readable file.`,d.USAGE)}}});a.tools=p}if(e.dryRun){console.log(F({request:a},r));return}let l=lt(e.baseUrl);if(u){let p=await ve(e,{url:l,method:"POST",body:a,stream:!0,authStyle:"x-api-key"}),f=p.headers.get("content-type")||"";if(!f.includes("text/event-stream")&&!f.includes("stream"))throw new m(`Expected SSE stream but got content-type "${f}". Server may be experiencing issues.`,d.GENERAL);let D="",h=!1,E=e.noColor?"":"\x1B[2m",x=e.noColor?"":"\x1B[0m",g=r==="json",v=process.stdout.isTTY&&!g?process.stderr:process.stderr,k=g?void 0:process.stdout,B=new mn(v,e.noColor);for await(let M of Oe(p)){if(M.data==="[DONE]")break;try{let I=JSON.parse(M.data);if(I.type==="content_block_start"){if(I.content_block.type==="thinking")h=!0,B.start();else if(I.content_block.type==="text"&&h)B.stop(),h=!1,v.write(`${x}
|
|
143
141
|
Response:
|
|
144
|
-
`)}else if(
|
|
145
|
-
${
|
|
146
|
-
`)}}if(
|
|
147
|
-
`)}else{let
|
|
142
|
+
`)}else if(I.type==="content_block_delta"){if(I.delta.type==="text_delta")D+=I.delta.text,k?.write(I.delta.text)}}catch(I){process.stderr.write(`
|
|
143
|
+
${E}[warning] Failed to parse stream chunk: ${I instanceof Error?I.message:String(I)}${x}
|
|
144
|
+
`)}}if(h)B.stop();if(r==="json")console.log(F({content:D},r));else k?.write(`
|
|
145
|
+
`)}else{let p=await A(e,{url:l,method:"POST",body:a,authStyle:"x-api-key"}),f=ta(p.content);if(e.quiet||r==="text")console.log(f);else console.log(F(p,r))}}})});import{writeFileSync as ra}from"node:fs";function Dn(e){return`\x1B[${e}A`}function oa(e){return`\x1B[${e}B`}function ar(e){return`\x1B[${e}G`}function Ct(){return"\x1B[2K"}function na(){return"\x1B[0J"}function ua(){process.stdout.write(`
|
|
148
146
|
Available commands:
|
|
149
|
-
`);for(let[t
|
|
147
|
+
`);for(let[e,t]of Object.entries(lr))process.stdout.write(` ${e.padEnd(fn+2)} ${t}
|
|
150
148
|
`);process.stdout.write(`
|
|
151
|
-
`)}class
|
|
152
|
-
`){let
|
|
153
|
-
`),this.lastTotal=0;let
|
|
154
|
-
`,
|
|
155
|
-
`,
|
|
156
|
-
`,
|
|
157
|
-
`;if(
|
|
158
|
-
${
|
|
159
|
-
`),process.stdout.write(`${
|
|
160
|
-
`),
|
|
161
|
-
`);process.stdout.write(`${
|
|
162
|
-
`);let{stdin:
|
|
163
|
-
`);return}let
|
|
164
|
-
`);else if(
|
|
149
|
+
`)}class hn{buffer="";cursor=0;history=[];historyIdx=-1;out;promptLen;dim;reset;width;lastTotal=0;resolve=null;constructor(e,t,o,n){this.out=e,this.promptLen=t.length,this.dim=o,this.reset=n,this.width=e.columns||80}readLine(){return new Promise((e)=>{this.buffer="",this.cursor=0,this.lastTotal=0,this.resolve=e,this.render()})}feed(e){let t=e.toString(),o=0;while(o<t.length){let n=t[o];if(n==="\x1B"&&o+1<t.length&&t[o+1]==="["){let i=t.slice(o,o+3);if(i==="\x1B[A"){this.historyUp(),o+=3;continue}if(i==="\x1B[B"){this.historyDown(),o+=3;continue}if(i==="\x1B[C"){if(this.cursor<this.buffer.length)this.cursor++;this.render(),o+=3;continue}if(i==="\x1B[D"){if(this.cursor>0)this.cursor--;this.render(),o+=3;continue}if(i==="\x1B[H"){this.cursor=0,this.render(),o+=3;continue}if(i==="\x1B[F"){this.cursor=this.buffer.length,this.render(),o+=3;continue}if(o+3<t.length&&t.slice(o,o+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(),o+=4;continue}o+=1;continue}if(n==="\r"||n===`
|
|
150
|
+
`){let i=this.buffer;if(i.trim())this.history.push(i),this.historyIdx=-1;let s=this.lastTotal>0?this.lastTotal-1:0;this.out.write(oa(s)+`
|
|
151
|
+
`),this.lastTotal=0;let r=this.resolve;if(this.resolve=null,r)r(i);o++;continue}if(n===""||n==="\b"){if(this.cursor>0)this.buffer=this.buffer.slice(0,this.cursor-1)+this.buffer.slice(this.cursor),this.cursor--;this.render(),o++;continue}if(n==="\x01"){this.cursor=0,this.render(),o++;continue}if(n==="\x05"){this.cursor=this.buffer.length,this.render(),o++;continue}if(n==="\x15"){this.buffer="",this.cursor=0,this.render(),o++;continue}if(n==="\x17"){let i=this.buffer.slice(0,this.cursor),s=this.buffer.slice(this.cursor),r=i.replace(/\S+\s*$/,"");this.cursor=r.length,this.buffer=r+s,this.render(),o++;continue}if(n==="\t"){if(this.buffer.startsWith("/")){let i=cr.filter((s)=>s.startsWith(this.buffer));if(i.length===1)this.buffer=i[0],this.cursor=this.buffer.length,this.render()}o++;continue}if(n.charCodeAt(0)>=32){this.buffer=this.buffer.slice(0,this.cursor)+n+this.buffer.slice(this.cursor),this.cursor++,this.render(),o++;continue}o++}}historyUp(){if(this.history.length===0)return;if(this.historyIdx===-1)this.historyIdx=this.history.length-1;else if(this.historyIdx>0)this.historyIdx--;this.buffer=this.history[this.historyIdx],this.cursor=this.buffer.length,this.render()}historyDown(){if(this.historyIdx===-1)return;if(this.historyIdx<this.history.length-1)this.historyIdx++,this.buffer=this.history[this.historyIdx];else this.historyIdx=-1,this.buffer="";this.cursor=this.buffer.length,this.render()}border(){return this.dim+"─".repeat(this.width)+this.reset}render(){let e=this.buffer.startsWith("/")?cr.filter((r)=>r.startsWith(this.buffer)):[],t=e.length===1&&e[0]===this.buffer,o=e.length>0&&!t,n=o?e.length:0,i=3+n,s="";if(this.lastTotal>0)s+=Dn(1);if(s+=ar(1)+Ct()+this.border()+`
|
|
152
|
+
`,s+=Ct()+"> "+this.buffer+`
|
|
153
|
+
`,s+=ar(1)+Ct()+this.border()+`
|
|
154
|
+
`,o)for(let r of e)s+=Ct()+` ${this.dim}${r.padEnd(fn+2)} ${lr[r]}${this.reset}
|
|
155
|
+
`;if(i<this.lastTotal)s+=na();s+=Dn(n+2),s+=ar(this.promptLen+this.cursor+1),this.out.write(s),this.lastTotal=i}}var ia="\x1B[?25l",sa="\x1B[?25h",lr,cr,fn,gn;var Cn=C(()=>{T();V();R();S();lr={"/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"},cr=Object.keys(lr),fn=Math.max(...cr.map((e)=>e.length));gn=w({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(e,t){if(!G({nonInteractive:e.nonInteractive}))throw new m("The repl command requires an interactive terminal.",d.USAGE,"mmx text repl");if(!process.stdin.isTTY)throw new m("The repl command requires a TTY.",d.USAGE);let o=e.noColor?"":"\x1B[2m",n=e.noColor?"":"\x1B[0m",i={messages:[],system:t.system,model:t.model||e.defaultTextModel||"MiniMax-M3",maxTokens:t.maxTokens??4096,temperature:t.temperature!==void 0?t.temperature:void 0,topP:t.topP!==void 0?t.topP:void 0},s=e.noColor?"":"\x1B[1m";if(process.stdout.write(`
|
|
156
|
+
${s}MiniMax Chat REPL${n}
|
|
157
|
+
`),process.stdout.write(`${o}Model: ${i.model}${n}
|
|
158
|
+
`),i.system)process.stdout.write(`${o}System: ${i.system.slice(0,80)}${i.system.length>80?"...":""}${n}
|
|
159
|
+
`);process.stdout.write(`${o}Type / to see commands, /exit to quit.${n}
|
|
160
|
+
`);let{stdin:r,stdout:u}=process;if(typeof r.setRawMode==="function")r.setRawMode(!0);r.resume(),r.setEncoding("utf8");let a=!1,l=0;async function p(){if(i.messages.length===0){u.write(`${o}No messages to send. Type something first.${n}
|
|
161
|
+
`);return}let x={model:i.model,messages:i.messages,max_tokens:i.maxTokens,stream:!0};if(i.system)x.system=i.system;if(i.temperature!==void 0)x.temperature=i.temperature;if(i.topP!==void 0)x.top_p=i.topP;a=!0;let g=lt(e.baseUrl);try{let y=await ve(e,{url:g,method:"POST",body:x,stream:!0,authStyle:"x-api-key"}),v=y.headers.get("content-type")||"";if(!v.includes("text/event-stream")&&!v.includes("stream"))throw new m(`Expected SSE stream but got content-type "${v}".`,d.GENERAL);let k="",B=!1;for await(let M of Oe(y)){if(M.data==="[DONE]")break;try{let I=JSON.parse(M.data);if(I.type==="content_block_start"){if(I.content_block.type==="thinking")B=!0,u.write(`${o}Thinking:
|
|
162
|
+
`);else if(I.content_block.type==="text"&&B)u.write(`${n}
|
|
165
163
|
Response:
|
|
166
|
-
`),
|
|
167
|
-
`);else
|
|
168
|
-
`)}catch(
|
|
169
|
-
`)}finally{
|
|
170
|
-
`),"exit";case"/help":return
|
|
171
|
-
`),"ok";case"/system":{if(
|
|
172
|
-
`);else if(
|
|
173
|
-
${
|
|
174
|
-
`);else
|
|
175
|
-
`);return"ok"}case"/model":{if(
|
|
176
|
-
`);else
|
|
177
|
-
`);return"ok"}case"/save":{if(!
|
|
178
|
-
`),"ok";try{let
|
|
179
|
-
`)}catch(
|
|
180
|
-
`)}return"ok"}case"/history":{if(
|
|
181
|
-
`),"ok";if(
|
|
182
|
-
`);let
|
|
183
|
-
`),
|
|
184
|
-
`),"ok"}default:if(
|
|
185
|
-
`),"ok";return"ok"}}let
|
|
186
|
-
${
|
|
187
|
-
`),
|
|
188
|
-
${
|
|
189
|
-
`),
|
|
190
|
-
${
|
|
191
|
-
`)};process.on("SIGINT",
|
|
192
|
-
`)}}})});import{writeFileSync as
|
|
193
|
-
`);if(
|
|
194
|
-
${
|
|
195
|
-
${
|
|
164
|
+
`),B=!1}else if(I.type==="content_block_delta"){if(I.delta.type==="text_delta")k+=I.delta.text,u.write(I.delta.text);else if(I.delta.type==="thinking_delta")u.write(I.delta.thinking)}}catch{}}if(B)u.write(n);if(k)i.messages.push({role:"assistant",content:k}),u.write(`
|
|
165
|
+
`);else u.write(`${o}[empty response]${n}
|
|
166
|
+
`)}catch(y){u.write(`${o}[error] ${y instanceof Error?y.message:String(y)}${n}
|
|
167
|
+
`)}finally{a=!1,l=0}}function f(x){let g=x.trim().split(/\s+/),y=g[0],v=g.slice(1).join(" ");switch(y){case"/exit":return u.write(`${o}Goodbye!${n}
|
|
168
|
+
`),"exit";case"/help":return ua(),"ok";case"/clear":return i.messages=[],u.write(`${o}Conversation cleared.${n}
|
|
169
|
+
`),"ok";case"/system":{if(v)i.system=v,u.write(`${o}System prompt set.${n}
|
|
170
|
+
`);else if(i.system)u.write(`${o}System prompt:${n}
|
|
171
|
+
${i.system}
|
|
172
|
+
`);else u.write(`${o}No system prompt set.${n}
|
|
173
|
+
`);return"ok"}case"/model":{if(v)i.model=v,u.write(`${o}Model set to: ${i.model}${n}
|
|
174
|
+
`);else u.write(`${o}Current model: ${i.model}${n}
|
|
175
|
+
`);return"ok"}case"/save":{if(!v)return u.write(`${o}Usage: /save <file-path>${n}
|
|
176
|
+
`),"ok";try{let k=[];if(i.system)k.push({role:"system",content:i.system});for(let B of i.messages)k.push({role:B.role,content:typeof B.content==="string"?B.content:JSON.stringify(B.content)});ra(v,JSON.stringify(k,null,2),"utf-8"),u.write(`${o}Conversation saved to ${v} (${k.length} messages)${n}
|
|
177
|
+
`)}catch(k){u.write(`${o}[error] Failed to save: ${k instanceof Error?k.message:String(k)}${n}
|
|
178
|
+
`)}return"ok"}case"/history":{if(i.messages.length===0)return u.write(`${o}No messages in conversation.${n}
|
|
179
|
+
`),"ok";if(i.system)u.write(`${o}[system] ${i.system.slice(0,100)}${i.system.length>100?"...":""}${n}
|
|
180
|
+
`);let k=1;for(let B of i.messages){let M=B.role==="user"?"user":"assistant",I=typeof B.content==="string"?B.content:"[structured content]",Pe=(I.length>120?I.slice(0,120)+"...":I).replace(/\n/g,"↵"),Ke=` ${String(k).padStart(2)} ${M.padEnd(11)}`;u.write(`${o}${Ke}${n}${Pe}
|
|
181
|
+
`),k++}return u.write(`${o}── ${k-1} messages ──${n}
|
|
182
|
+
`),"ok"}default:if(y.startsWith("/"))return u.write(`${o}Unknown command: ${y}. Type /help for available commands.${n}
|
|
183
|
+
`),"ok";return"ok"}}let D=()=>{if(a){u.write(`
|
|
184
|
+
${o}[interrupted]${n}
|
|
185
|
+
`),l=0,a=!1;return}if(l++,l>=2){if(u.write(`
|
|
186
|
+
${o}Goodbye!${n}
|
|
187
|
+
`),E=!1,typeof r.setRawMode==="function")r.setRawMode(!1);r.pause(),process.removeListener("SIGINT",D),process.exit(0)}else u.write(`
|
|
188
|
+
${o}Press Ctrl+C again or type /exit to quit.${n}
|
|
189
|
+
`)};process.on("SIGINT",D);let h=new hn(u,"> ",o,n),E=!0;r.on("data",(x)=>{h.feed(x)}),u.write(ia);try{while(E){let x=await h.readLine();if(!E)break;let g=x.trim();if(!g)continue;if(g.startsWith("/")){if(f(g)==="exit"){E=!1;break}continue}i.messages.push({role:"user",content:g}),await p()}}finally{if(u.write(sa),typeof r.setRawMode==="function")r.setRawMode(!1);r.pause(),process.removeListener("SIGINT",D),r.removeAllListeners("data"),u.write(`
|
|
190
|
+
`)}}})});import{writeFileSync as aa}from"fs";function yn(e,t,o,n){if(t){let i=e.data.audio;if(!i)throw new m("API response missing audio data (audio field is empty).",d.GENERAL);if(!/^[0-9a-fA-F]*$/.test(i))throw new m("API returned invalid audio data (not valid hex).",d.GENERAL);if(i.length%2!==0)throw new m("API returned truncated audio data (odd-length hex string).",d.GENERAL);try{aa(t,Buffer.from(i,"hex"))}catch(s){if(s.code==="ENOSPC")throw new m("Disk full — cannot write audio file.",d.GENERAL,"Free up disk space and try again.");throw s}if(n)console.log(t);else console.log(F({saved:t,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size,sample_rate:e.extra_info?.audio_sample_rate},o))}else{let i=e.data.audio_url??e.data.audio;if(n)console.log(i);else console.log(F({url:i,duration_ms:e.extra_info?.audio_length,size_bytes:e.extra_info?.audio_size},o))}}var bn=C(()=>{N();R();S()});import{readFileSync as ca}from"fs";function En(e){return ca(e==="-"?"/dev/stdin":e,"utf-8")}var Fn=()=>{};function dr(e){return e.join(", ")}function xn(e,t){if(!t.includes(e))throw new m(`Invalid audio format "${e}". Supported: ${dr(t)}`,d.USAGE)}function wn(e,t){return la[e]??t}function vn(e,t){if(t&&e==="wav")throw new m("wav format is not supported in streaming mode.",d.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var mr,la;var $n=C(()=>{R();S();mr=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"];la={opus:24000,pcmu_raw:8000,pcmu_wav:8000}});function _n(e){if(!/^[0-9a-fA-F]+$/.test(e))throw new m("API returned invalid audio data (not valid hex).",d.GENERAL);if(e.length%2!==0)throw new m("API returned truncated audio data (odd-length hex string).",d.GENERAL);return Uint8Array.from(Buffer.from(e,"hex"))}function An(e,t){let o=t.base_resp?.status_code;if(o!==void 0&&o!==0||t.error)throw qe(e.status,t,e.url||void 0)}function Sn(){return new m("API stream ended without audio data.",d.GENERAL)}async function*ma(e){let t=e.headers.get("content-type")||"";if(!t.toLowerCase().includes("text/event-stream")){let n;try{n=await e.json()}catch{throw new m(`Expected SSE audio stream but got content-type "${t||"unknown"}".`,d.GENERAL)}An(e,n);let i=n.data?.audio;if(!i)throw Sn();yield _n(i);return}let o=!1;for await(let n of Oe(e)){if(!n.data||n.data==="[DONE]")break;let i;try{i=JSON.parse(n.data)}catch(r){throw new m(`Failed to parse audio stream chunk: ${r instanceof Error?r.message:String(r)}`,d.GENERAL)}An(e,i);let s=i.data?.audio;if(s)o=!0,yield _n(s);if(i.data?.status===2)break}if(!o)throw Sn()}async function kn(e){process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);throw t});for await(let t of ma(e))if(!process.stdout.write(t))await new Promise((o)=>process.stdout.once("drain",o))}var Rn=C(()=>{or();R();S()});import{writeFileSync as da}from"fs";var pr;var Bn=C(()=>{T();R();S();V();N();bn();Fn();$n();Rn();pr=w({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",apiDocs:"/docs/api-reference/speech-t2a-http",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--emotion <emotion>",description:"Emotion: happy, sad, angry, fearful, disgusted, surprised, calm, fluent, whisper (passed through as-is; see API Reference below for new values)"},{flag:"--text-normalization",description:"Enable Chinese/English text normalization"},{flag:"--latex-read",description:"Read LaTeX formulas ($$...$$, Chinese only)"},{flag:"--format <fmt>",description:`Audio format: ${dr(mr)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','mmx speech synthesize --text "Hello" --subtitles --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(e,t){let o=t.text??t._positional?.[0];if(t.textFile)o=En(t.textFile);if(!o)throw new m("--text or --text-file is required.",d.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let n=t.model||e.defaultSpeechModel||"speech-2.8-hd",i=t.voice||"English_expressive_narrator",s=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),r=t.format||"mp3";xn(r,mr),vn(r,t.stream===!0);let u=t.out??`speech_${s}.${r}`,a="hex",l={model:n,text:o,voice_setting:{voice_id:i,speed:t.speed??void 0,vol:t.volume??void 0,pitch:t.pitch??void 0,emotion:t.emotion||void 0,text_normalization:t.textNormalization===!0?!0:void 0,latex_read:t.latexRead===!0?!0:void 0},audio_setting:{format:t.format||"mp3",sample_rate:t.sampleRate??wn(r,32000),bitrate:t.bitrate??128000,channel:t.channels??1},output_format:a,stream:t.stream===!0};if(t.language)l.language_boost=t.language;if(t.subtitles)l.subtitle_enable=!0;if(t.pronunciation)l.pronunciation_dict={tone:t.pronunciation};if(le(e,l))return;let p=_(e.output),f=Ro(e.baseUrl);if(t.stream){let h=await ve(e,{url:f,method:"POST",body:l,stream:!0});await kn(h);return}let D=await A(e,{url:f,method:"POST",body:l});if(!e.quiet)process.stderr.write(`[Model: ${n}]
|
|
191
|
+
`);if(yn(D,u,p,e.quiet),t.subtitles&&D.data.subtitle_file)try{let h=await fetch(D.data.subtitle_file);if(!h.ok)throw new m(`Failed to download subtitle file: ${h.status}`,d.GENERAL);let E=await h.json();if(E?.length){let x=u.replace(/\.[^.]+$/,"")+".srt",g=E.map((y,v)=>{let k=(B)=>{let M=String(Math.floor(B/3600000)).padStart(2,"0"),I=String(Math.floor(B%3600000/60000)).padStart(2,"0"),We=String(Math.floor(B%60000/1000)).padStart(2,"0"),Pe=String(Math.round(B%1000)).padStart(3,"0");return`${M}:${I}:${We},${Pe}`};return`${v+1}
|
|
192
|
+
${k(y.time_begin)} --> ${k(y.time_end)}
|
|
193
|
+
${y.text}`}).join(`
|
|
196
194
|
|
|
197
|
-
`);if(
|
|
198
|
-
`)}else if(
|
|
199
|
-
`)}}})});function
|
|
200
|
-
`)}}}}function
|
|
201
|
-
`)}}}var
|
|
202
|
-
Retry ${
|
|
203
|
-
`);await
|
|
204
|
-
Download attempt ${
|
|
205
|
-
`)}throw new
|
|
206
|
-
`);let
|
|
207
|
-
`);if(
|
|
208
|
-
`);
|
|
209
|
-
`);await
|
|
210
|
-
`));else console.log(
|
|
195
|
+
`);if(da(x,g,"utf-8"),!e.quiet)console.log(F({subtitles:x},p));else console.log(x)}}catch(h){if(!e.quiet)process.stderr.write(`Warning: failed to download subtitles: ${h.message}
|
|
196
|
+
`)}else if(t.subtitles&&!D.data.subtitle_file){if(!e.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
|
|
197
|
+
`)}}})});function pa(e){let t=e.match(/^(.+?)_[A-Z]/);return t?t[1]:e}function Da(e,t){let o=t.toLowerCase();return e.filter((n)=>{let i=pa(n.voice_id).toLowerCase();return i===o||i.startsWith(o+"_")||i.startsWith(o+" (")})}var In;var Tn=C(()=>{T();V();N();In=w({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(e,t){let o=_(e.output);if(e.dryRun){console.log(F({request:{voice_type:"system"}},o));return}let i=(await A(e,{url:Bo(e.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],s=t.language;if(s){let r=Da(i,s);if(o!=="text"){console.log(F(r,o));return}for(let u of r){let a=u.description?.join("; ")||"",l=u.voice_name?` (${u.voice_name})`:"";if(console.log(` ${u.voice_id}${l}`),a)console.log(` ${a}`)}}else{if(o!=="text"){console.log(F(i.map((r)=>r.voice_id),o));return}for(let r of i)console.log(r.voice_id)}}})});function On(e){let t=process.stderr.isTTY,o=0,n=null,i=e;return{start(){if(!t)return;n=setInterval(()=>{process.stderr.write(`\r${Mn[o%Mn.length]} ${i}`),o++},80)},update(s){i=s},stop(s){if(n)clearInterval(n),n=null;if(t){if(process.stderr.write("\r\x1B[K"),s)process.stderr.write(`${s}
|
|
198
|
+
`)}}}}function Pn(e,t=""){let o=process.stderr.isTTY,n=30;return{update(i){if(!o)return;let s=Math.min(1,i/e),r=Math.round(30*s),u=30-r,a="█".repeat(r)+"░".repeat(u),l=`${Math.round(s*100)}%`;process.stderr.write(`\r${t} ${a} ${l}`)},finish(){if(o)process.stderr.write(`
|
|
199
|
+
`)}}}var Mn;var Dr=C(()=>{Mn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{createWriteStream as fa,renameSync as ha,unlinkSync as ga}from"fs";function fr(e,t){if(!Number.isFinite(e)||e<=0)throw new m(`${t} must be a positive number.`,d.USAGE);return e}function Ea(e,t){if(!Number.isInteger(e)||e<0)throw new m(`${t} must be a non-negative integer.`,d.USAGE);return e}function Fa(e,t){if(!Number.isFinite(e)||e<0)throw new m(`${t} must be a non-negative number.`,d.USAGE);return e}function he(e,t){return e.reason instanceof Error?e.reason:new m(t,d.GENERAL)}function xa(e){if(!e)return;let t=Number(e);if(Number.isFinite(t)&&t>=0)return t*1000;let o=Date.parse(e);if(!Number.isFinite(o))return;return Math.max(0,o-Date.now())}function wa(e){if(!e||!/^\d+$/.test(e))return;let t=BigInt(e);return t<=BigInt(Number.MAX_SAFE_INTEGER)?Number(t):Number.POSITIVE_INFINITY}async function va(e,t){if(t.aborted)throw he(t,"Download aborted.");if(e<=0)return;await new Promise((o,n)=>{let i=setTimeout(()=>{t.removeEventListener("abort",s),o()},e),s=()=>{clearTimeout(i),n(he(t,"Download aborted."))};t.addEventListener("abort",s,{once:!0})})}async function bt(e,t,o,n,i=!0){if(t.signal.aborted)throw he(t.signal,"Download aborted.");let s,r,u=new Promise((l,p)=>{s=setTimeout(()=>{let f=i?new _e(`Download idle timeout while ${n} after ${o}ms.`,d.TIMEOUT):new m(`Download idle timeout while ${n} after ${o}ms.`,d.TIMEOUT);t.abort(f),p(f)},o)}),a=new Promise((l,p)=>{r=()=>p(he(t.signal,"Download aborted.")),t.signal.addEventListener("abort",r,{once:!0})});try{return await Promise.race([e,u,a])}catch(l){if(t.signal.aborted)throw he(t.signal,"Download aborted.");throw l}finally{if(s)clearTimeout(s);if(r)t.signal.removeEventListener("abort",r)}}async function $a(e,t,o){let n=new Promise((i,s)=>{let r=()=>l(i),u=(p)=>l(()=>s(p)),a=()=>l(()=>s(Error("File writer closed before draining."))),l=(p)=>{e.off("drain",r),e.off("error",u),e.off("close",a),p()};e.once("drain",r),e.once("error",u),e.once("close",a)});try{await bt(n,t,o,"waiting for disk writes",!1)}catch(i){if(i instanceof m)throw i;throw new m(`Could not write download: ${i instanceof Error?i.message:String(i)}`,d.GENERAL)}}async function _a(e,t,o){let n=new Promise((i,s)=>{let r=()=>l(i),u=(p)=>l(()=>s(p)),a=()=>{if(!e.writableFinished)l(()=>s(Error("File writer closed early.")))},l=(p)=>{e.off("finish",r),e.off("error",u),e.off("close",a),p()};e.once("finish",r),e.once("error",u),e.once("close",a),e.end()});try{await bt(n,t,o,"finishing disk writes",!1)}catch(i){if(i instanceof m)throw i;throw new m(`Could not write download: ${i instanceof Error?i.message:String(i)}`,d.GENERAL)}}async function Aa(e){if(e.closed)return;await new Promise((t)=>{let o=setTimeout(()=>{e.off("close",n),t()},Ln),n=()=>{clearTimeout(o),t()};e.once("close",n),e.destroy()})}async function Nn(e){let t;if(await Promise.race([e.catch(()=>{return}),new Promise((o)=>{t=setTimeout(o,Ln)})]),t)clearTimeout(t)}async function Sa(e,t,o,n,i){let s=new AbortController,r=()=>s.abort(he(i,"Download aborted."));if(i.aborted)r();else i.addEventListener("abort",r,{once:!0});let u,a,l,p,f=null,D=!1;try{try{u=await bt(fetch(e,{signal:s.signal}),s,n.idleTimeoutMs,"waiting for response headers")}catch(v){if(v instanceof m)throw v;throw new _e(`Download request failed: ${v instanceof Error?v.message:String(v)}`)}if(!u.ok)throw new yt(u.status,xa(u.headers.get("retry-after")));let h=wa(u.headers.get("content-length"));if(h!==void 0&&h>n.maxBytes)throw new m(`Download exceeds maximum size of ${n.maxBytes} bytes (Content-Length: ${h}).`,d.GENERAL);if(a=u.body?.getReader(),!a)throw new m("Download response has no body.",d.GENERAL);let E=u.headers.get("content-encoding")?void 0:h;p=`${t}.tmp-${process.pid}-${Date.now()}-${o}-${Math.random().toString(36).slice(2)}`,l=fa(p),f=E&&!n.quiet?Pn(E,"Downloading"):null;let x,g=new Promise((v,k)=>{l.once("error",(B)=>{x=B,k(B)})});g.catch(()=>{return});let y=0;while(!0){let v;try{v=await bt(Promise.race([a.read(),g]),s,n.idleTimeoutMs,"waiting for response data")}catch(M){if(x)throw new m(`Could not write download: ${x.message}`,d.GENERAL);if(M instanceof m)throw M;throw new _e(`Download stream failed: ${M instanceof Error?M.message:String(M)}`)}if(v.done)break;let k=y+v.value.byteLength;if(k>n.maxBytes)throw new m(`Download exceeds maximum size of ${n.maxBytes} bytes.`,d.GENERAL);let B;try{B=l.write(v.value)}catch(M){throw new m(`Could not write download: ${M instanceof Error?M.message:String(M)}`,d.GENERAL)}if(!B)await $a(l,s,n.idleTimeoutMs);y=k,f?.update(y)}if(E!==void 0&&y!==E)throw new _e(`Download truncated: expected ${E} bytes, received ${y}.`);return await _a(l,s,n.idleTimeoutMs),l=void 0,a.releaseLock(),a=void 0,ha(p,t),p=void 0,D=!0,{size:y}}finally{if(i.removeEventListener("abort",r),f?.finish(),!D){if(a){await Nn(a.cancel(s.signal.reason));try{a.releaseLock()}catch{}}else if(u?.body)await Nn(u.body.cancel(s.signal.reason));if(l)await Aa(l);if(p)try{ga(p)}catch{}}}}async function ge(e,t,o){let n=e.startsWith("http://")?e.replace("http://","https://"):e,i=Ea(o?.retries??3,"retries"),s=Fa(o?.retryDelayMs??1000,"retryDelayMs"),r=fr(o?.overallTimeoutMs??Ca,"overallTimeoutMs"),u=fr(o?.idleTimeoutMs??ya,"idleTimeoutMs"),a=fr(o?.maxBytes??ba,"maxBytes"),l=o?.quiet??!1,p=new AbortController,f=()=>p.abort(he(o.signal,"Download aborted by caller."));if(o?.signal?.aborted)f();else o?.signal?.addEventListener("abort",f,{once:!0});let D=setTimeout(()=>{p.abort(new m(`Download timed out after ${r}ms.`,d.TIMEOUT))},r),h,E;try{for(let g=0;g<=i;g++){if(g>0){let y=s*Math.pow(2,g-1),v=Math.max(y,E??0);if(!l)process.stderr.write(`
|
|
200
|
+
Retry ${g}/${i} in ${v}ms...
|
|
201
|
+
`);await va(v,p.signal)}try{return await Sa(n,t,g,{quiet:l,idleTimeoutMs:u,maxBytes:a},p.signal)}catch(y){if(h=y instanceof Error?y:Error(String(y)),p.signal.aborted)throw he(p.signal,"Download aborted.");if(!(y instanceof _e||y instanceof yt&&y.retryable))throw y;if(E=y instanceof yt||y instanceof _e?y.retryAfterMs:void 0,!l)process.stderr.write(`
|
|
202
|
+
Download attempt ${g+1} failed: ${h.message}
|
|
203
|
+
`);if(g===i)break}}}finally{clearTimeout(D),o?.signal?.removeEventListener("abort",f)}let x=h instanceof m?h.exitCode:d.NETWORK;throw new m(`Download failed after ${i+1} attempts: ${h?.message}`,x,x===d.NETWORK?"Check your network connection and proxy settings.":void 0)}function Et(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}var Ca=1800000,ya=60000,ba=5368709120,Ln=1000,_e,yt;var Ft=C(()=>{Dr();R();S();_e=class _e extends m{retryAfterMs;constructor(e,t=d.NETWORK,o){super(e,t);this.retryAfterMs=o}};yt=class yt extends m{retryable;retryAfterMs;constructor(e,t){super(`Download failed: HTTP ${e}`,d.GENERAL);this.retryable=e===408||e===429||e>=500,this.retryAfterMs=t}}});import{readFileSync as ka,existsSync as Ra,statSync as Ba}from"fs";import{extname as Un}from"path";function xt(e,t){if(t!==void 0){let s=Ba(e).size;if(s>t)throw new m(`Image file is ${(s/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${t/1024/1024} MB.`,d.USAGE,"Use a public URL or mm_file:// file ID for large images.")}let o=Un(e).toLowerCase(),n=Gn[o]||"image/jpeg",i=ka(e);return`data:${n};base64,${i.toString("base64")}`}function Ae(e,t){return e.startsWith("http")||e.startsWith("data:")||e.startsWith("mm_file://")?e:xt(e,t)}async function qn(e){if(e.startsWith("data:"))return e;if(e.startsWith("http://")||e.startsWith("https://")){let o=await fetch(e);if(!o.ok)throw new m(`Failed to download image: HTTP ${o.status}`,d.GENERAL);let i=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),s=await o.arrayBuffer();if(s.byteLength>Ia)throw new m(`Image too large (${(s.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,d.USAGE);return`data:${i};base64,${Buffer.from(s).toString("base64")}`}if(!Ra(e))throw new m(`File not found: ${e}`,d.USAGE);let t=Un(e).toLowerCase();if(!Gn[t])throw new m(`Unsupported image format "${t}". Supported: jpg, jpeg, png, webp`,d.USAGE);return xt(e)}var Gn,Ia=52428800;var wt=C(()=>{R();S();Gn={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".heic":"image/heic",".heif":"image/heif"}});import{mkdirSync as Vn,existsSync as je,writeFileSync as jn}from"fs";import{dirname as Ta,join as Hn,resolve as hr}from"path";var Wn;var Kn=C(()=>{T();R();S();V();Ft();N();wt();pe();Wn=w({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(e,t){let o=t.prompt??t._positional?.[0];o=await it({value:o,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:e.nonInteractive});let{width:n,height:i}=t;if(n!==void 0&&i===void 0)throw new m("--width requires --height. Both must be specified together.",d.USAGE);if(i!==void 0&&n===void 0)throw new m("--height requires --width. Both must be specified together.",d.USAGE);if(n!==void 0&&i!==void 0){let D=(h,E)=>{if(E<512||E>2048)throw new m(`--${h} must be between 512 and 2048, got ${E}.`,d.USAGE);if(E%8!==0)throw new m(`--${h} must be a multiple of 8, got ${E}.`,d.USAGE)};D("width",n),D("height",i)}let s=t.out;if(s&&t.n>1)throw new m("--out cannot be used with --n > 1. Use --out-dir instead.",d.USAGE);let r=t.responseFormat||"url",u={model:"image-01",prompt:o,aspect_ratio:n!==void 0&&i!==void 0?void 0:t.aspectRatio||void 0,n:t.n??1,seed:t.seed,width:n,height:i,prompt_optimizer:t.promptOptimizer===!0||void 0,aigc_watermark:t.aigcWatermark===!0||void 0,response_format:r};if(t.subjectRef){let D=t.subjectRef,h=Object.fromEntries(D.split(",").map((x)=>{let g=x.indexOf("=");if(g===-1)return[x,""];return[x.slice(0,g),x.slice(g+1)]})),E={type:h.type||"character"};if(h.image)if(h.image.startsWith("http"))E.image_url=h.image;else E.image_file=xt(hr(h.image));u.subject_reference=[E]}if(le(e,u))return;let a=_(e.output),l=Io(e.baseUrl),p=await A(e,{url:l,method:"POST",body:u});if(!e.quiet)process.stderr.write(`[Model: image-01]
|
|
204
|
+
`);let f=[];if(s){let D=Ta(hr(s));if(!je(D))Vn(D,{recursive:!0});let h=hr(s);if(je(h))process.stderr.write(`Warning: overwriting existing file: ${h}
|
|
205
|
+
`);if(r==="base64"){let E=(p.data.image_base64||[])[0];if(E)jn(h,E,"base64")}else{let E=(p.data.image_urls||[])[0];if(E)await ge(E,h,{quiet:e.quiet})}f.push(h)}else{let D=t.outDir??".";if(!je(D))Vn(D,{recursive:!0});let h=t.outPrefix||"image";if(r==="base64"){let E=p.data.image_base64||[];for(let x=0;x<E.length;x++){let g=`${h}_${String(x+1).padStart(3,"0")}.jpg`,y=Hn(D,g);if(je(y))process.stderr.write(`Warning: overwriting existing file: ${y}
|
|
206
|
+
`);jn(y,E[x],"base64"),f.push(y)}}else{let E=p.data.image_urls||[];for(let x=0;x<E.length;x++){let g=`${h}_${String(x+1).padStart(3,"0")}.jpg`,y=Hn(D,g);if(je(y))process.stderr.write(`Warning: overwriting existing file: ${y}
|
|
207
|
+
`);await ge(E[x],y,{quiet:e.quiet}),f.push(y)}}}if(a==="json")console.log(F({id:p.data.task_id,saved:f,success_count:p.data.success_count,failed_count:p.data.failed_count},a));else if(e.quiet)console.log(f.join(`
|
|
208
|
+
`));else console.log(F({id:p.data.task_id,saved:f,success_count:p.data.success_count,failed_count:p.data.failed_count},a))}})});async function gr(e,t){let o=Date.now()+t.timeoutSec*1000,n=On("Polling...");if(!e.quiet)n.start();try{while(Date.now()<o){let i=await A(e,{url:t.url});if(t.getStatus&&!e.quiet)n.update(`Status: ${t.getStatus(i)}`);if(t.isComplete(i))return n.stop("Done."),i;if(t.isFailed(i)){n.stop("Failed.");let s=t.getStatus?t.getStatus(i):"failed",r=i.base_resp?.status_msg,u=t.getFailureReason?.(i)??r,a=u?` (${u})`:"";throw new m(`Task ${s}.${a}`,d.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((s)=>setTimeout(s,t.intervalSec*1000))}}finally{n.stop()}throw new m("Polling timed out.",d.TIMEOUT,"Try increasing --timeout or check task status manually.")}var zn=C(()=>{V();R();S();Dr()});import{existsSync as Ma,readFileSync as Oa,statSync as Pa}from"fs";import{extname as Na}from"path";function Yn(e){let t=/^data:[^;,]+;base64,([\s\S]*)$/.exec(e);if(!t)return;let o=t[1].replace(/\s/g,""),n=o.endsWith("==")?2:o.endsWith("=")?1:0;return Math.max(0,Math.floor(o.length*3/4)-n)}function Cr(e,t){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mm_file://"))return e;if(e.startsWith("data:"))return t==="audio"?e.replace(/^data:audio\/mpeg;base64,/,"data:audio/mp3;base64,"):e;if(!Ma(e))throw new m(`File not found: ${e}`,d.USAGE);let o=Na(e).toLowerCase(),n=La[t],i=n[o];if(!i){let a=Object.keys(n).map((l)=>l.slice(1)).join(", ");throw new m(`Unsupported ${t} format "${o}". Supported local files: ${a}`,d.USAGE)}let s=Se[t],r=Pa(e).size;if(r>s)throw new m(`${t[0].toUpperCase()}${t.slice(1)} file is ${(r/1024/1024).toFixed(1)} MB; MiniMax-H3 allows at most ${s/1024/1024} MB.`,d.USAGE,"Use a public URL or mm_file:// file ID for large media.");let u=Oa(e);return`data:${i};base64,${u.toString("base64")}`}var La,Se,Jn=67108864;var yr=C(()=>{R();S();La={video:{".mp4":"video/mp4",".mov":"video/quicktime"},audio:{".mp3":"audio/mp3",".wav":"audio/wav"}},Se={image:31457280,video:52428800,audio:15728640}});function ke(e){return e===He}function Xn(e){return ke(e.model)}function Qn(e){let t=e.error?.code?.trim(),o=e.error?.message?.trim();if(t&&o)return`${t}: ${o}`;return o||t}function Zn(e){let t=e.images??[];if(t.length>1&&t.some((r)=>!r.role))throw new q("Each image must specify a role when multiple images are provided.");let o=[{type:"text",text:e.prompt},...t.map((r)=>({type:"image_url",image_url:{url:r.url},role:r.role??"first_frame"})),...(e.referenceVideos??[]).map((r)=>({type:"video_url",video_url:{url:r},role:"reference_video"})),...(e.referenceAudios??[]).map((r)=>({type:"audio_url",audio_url:{url:r},role:"reference_audio"}))],n=o.some((r)=>r.type==="image_url"&&(r.role==="first_frame"||r.role==="last_frame")),i=o.some((r)=>r.type!=="text"&&r.role?.startsWith("reference_")),s={model:He,content:o,resolution:e.resolution??"2K",duration:e.duration??5,ratio:n?"adaptive":e.ratio??(i?"adaptive":"16:9")};if(e.callbackUrl)s.callback_url=e.callbackUrl;return qa(s),s}function qa(e){if(!ke(e.model))throw new q(`Video Generation V2 only supports ${He}.`);let t=e.content.filter((D)=>D.type==="text");if(!t.some((D)=>D.text.trim().length>0))throw new q("MiniMax-H3 requires a non-empty text content item.");if(t.some((D)=>D.text.length>7000))throw new q("MiniMax-H3 text content must not exceed 7000 characters.");if(e.resolution!=="2K")throw new q("MiniMax-H3 currently only supports 2K resolution.");if(!Number.isInteger(e.duration)||e.duration<4||e.duration>15)throw new q("MiniMax-H3 duration must be an integer from 4 to 15 seconds.");if(e.ratio&&!Ua.has(e.ratio))throw new q("MiniMax-H3 ratio must be one of: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.");let o=e.content.filter((D)=>D.type==="image_url"),n=e.content.filter((D)=>D.type==="video_url"),i=e.content.filter((D)=>D.type==="audio_url");if(o.some((D)=>D.role&&!Ga.has(D.role)))throw new q("MiniMax-H3 image role must be one of: first_frame, last_frame, reference_image.");if(n.some((D)=>D.role!=="reference_video"))throw new q("MiniMax-H3 video role must be reference_video.");if(i.some((D)=>D.role!=="reference_audio"))throw new q("MiniMax-H3 audio role must be reference_audio.");for(let D of o)br(D.image_url.url,"image");for(let D of n)br(D.video_url.url,"video");for(let D of i)br(D.audio_url.url,"audio");let s=Buffer.byteLength(JSON.stringify(e));if(s>Jn)throw new q(`MiniMax-H3 request body is ${(s/1024/1024).toFixed(1)} MB; the maximum is 64 MB. Use public URLs or mm_file:// file IDs instead of Base64.`);let r=o.filter((D)=>!D.role||D.role==="first_frame"),u=o.filter((D)=>D.role==="last_frame"),a=o.filter((D)=>D.role==="reference_image"),l=r.length>0||u.length>0,p=a.length>0||n.length>0||i.length>0;if(r.length>1||u.length>1)throw new q("MiniMax-H3 accepts at most one first frame and one last frame.");if(a.length>9||n.length>3||i.length>3)throw new q("MiniMax-H3 accepts up to 9 reference images, 3 reference videos, and 3 reference audios.");if(l&&p)throw new q("MiniMax-H3 frame inputs and reference inputs cannot be used together.");if(i.length>0&&a.length===0&&n.length===0)throw new q("MiniMax-H3 reference audio requires at least one reference image or reference video.");if(e.content.every((D)=>D.type==="text")&&(!e.ratio||e.ratio==="adaptive"))throw new q("MiniMax-H3 text-to-video requires a concrete ratio; adaptive is not supported.")}function br(e,t){let o=Yn(e),n=Se[t];if(o!==void 0&&o>n)throw new q(`MiniMax-H3 ${t} input is ${(o/1024/1024).toFixed(1)} MB; the maximum is ${n/1024/1024} MB.`)}var He="MiniMax-H3",Ua,Ga,q;var Er=C(()=>{yr();Ua=new Set(["adaptive","21:9","16:9","4:3","1:1","3:4","9:16"]),Ga=new Set(["first_frame","last_frame","reference_image"]);q=class q extends Error{constructor(e){super(e);this.name="VideoV2InputError"}}});var ei;var ti=C(()=>{T();R();S();V();zn();Ft();N();wt();yr();pe();Er();ei=w({name:"video generate",description:`Generate a video
|
|
211
209
|
V2: MiniMax-H3 (text/image/video/audio content, 2K)
|
|
212
210
|
T2V: Hailuo-2.3
|
|
213
211
|
I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --image)
|
|
214
212
|
SEF: Hailuo-02 (requires --image and --last-frame)
|
|
215
|
-
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation-v2-create",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. V2: MiniMax-H3. Legacy: MiniMax-Hailuo-2.3 or MiniMax-Hailuo-2.3-Fast. Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--image <path-or-url>",description:"Input image for image-to-video (local path or URL)."},{flag:"--first-frame <path-or-url>",description:"Backward-compatible alias for --image.",hidden:!0},{flag:"--last-frame <path-or-url>",description:"Optional ending image. Legacy SEF also requires --image; MiniMax-H3 supports a last frame alone."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--reference-image <path-or-url>",description:"H3 reference image (repeatable).",type:"array"},{flag:"--reference-video <path-or-url>",description:"H3 reference video (repeatable; local MP4, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--reference-audio <path-or-url>",description:"H3 reference audio (repeatable; requires a reference image or video).",type:"array"},{flag:"--duration <seconds>",description:"Output duration. H3 supports integer values from 4 to 15 (default: 5).",type:"number"},{flag:"--ratio <ratio>",description:"H3 aspect ratio: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# H3 text-to-video (Video Generation V2)",'mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset"',"# H3 image-to-video",'mmx video generate --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg',"# H3 reference-to-video",'mmx video generate --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --image start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(t
|
|
216
|
-
`);if(
|
|
217
|
-
`);return}let
|
|
218
|
-
`)}})});var
|
|
219
|
-
`)
|
|
220
|
-
`);
|
|
221
|
-
`),
|
|
222
|
-
`)
|
|
223
|
-
`)}})});
|
|
224
|
-
`)}
|
|
225
|
-
`)
|
|
226
|
-
`)
|
|
227
|
-
`);
|
|
228
|
-
`);return}process.stdout.write(
|
|
229
|
-
`)}
|
|
230
|
-
`);return}let
|
|
231
|
-
`);
|
|
232
|
-
`)
|
|
233
|
-
`)}
|
|
234
|
-
`)
|
|
235
|
-
`);
|
|
236
|
-
`);return}process.stdout.write(S({file_id:m.file_id,deleted:!0},r)+`
|
|
237
|
-
`)}})});var Ao;var Bo=h(()=>{J();xe();Ao=A({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${bt}
|
|
213
|
+
S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation-v2-create",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. V2: MiniMax-H3. Legacy: MiniMax-Hailuo-2.3 or MiniMax-Hailuo-2.3-Fast. Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--image <path-or-url>",description:"Input image for image-to-video (local path or URL)."},{flag:"--first-frame <path-or-url>",description:"Backward-compatible alias for --image.",hidden:!0},{flag:"--last-frame <path-or-url>",description:"Optional ending image. Legacy SEF also requires --image; MiniMax-H3 supports a last frame alone."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--reference-image <path-or-url>",description:"H3 reference image (repeatable).",type:"array"},{flag:"--reference-video <path-or-url>",description:"H3 reference video (repeatable; local MP4/MOV, URL, data URI, or mm_file:// ID).",type:"array"},{flag:"--reference-audio <path-or-url>",description:"H3 reference audio (repeatable; requires a reference image or video).",type:"array"},{flag:"--duration <seconds>",description:"Output duration. H3 supports integer values from 4 to 15 (default: 5).",type:"number"},{flag:"--ratio <ratio>",description:"H3 aspect ratio: adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# H3 text-to-video (Video Generation V2)",'mmx video generate --model MiniMax-H3 --prompt "Ocean waves at sunset"',"# H3 image-to-video",'mmx video generate --model MiniMax-H3 --prompt "The subject walks forward" --image start.jpg',"# H3 reference-to-video",'mmx video generate --model MiniMax-H3 --prompt "Keep the same character" --reference-image character.png --reference-video motion.mp4',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --image start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(e,t){let o=t.prompt;o=await it({value:o,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:e.nonInteractive});let n=t.model,i=e.defaultVideoModel||"MiniMax-Hailuo-2.3",s=t.image,r=t.firstFrame;if(s&&r)throw new m("--image and --first-frame are aliases; provide only one.",d.USAGE);let u=s??r,a=Boolean(t.referenceImage||t.referenceVideo||t.referenceAudio||t.duration!==void 0||t.ratio),l;if(n)l=n;else if(ke(i))l=He;else if(t.lastFrame)l="MiniMax-Hailuo-02";else if(t.subjectImage)l="S2V-01";else l=i;if(t.lastFrame&&t.subjectImage)throw new m("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",d.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");if(n==="MiniMax-Hailuo-2.3-Fast"&&!u)throw new m("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --image to provide an input image.",d.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --image <path>");let p;if(ke(l)){if(t.subjectImage)throw new m("--subject-image is only supported by the legacy S2V-01 model. Use --reference-image for MiniMax-H3.",d.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text> --reference-image <path>");let ie=[...u?[{url:Ae(u,Se.image),role:"first_frame"}]:[],...t.lastFrame?[{url:Ae(t.lastFrame,Se.image),role:"last_frame"}]:[],...(t.referenceImage??[]).map((j)=>({url:Ae(j,Se.image),role:"reference_image"}))];try{p=Zn({prompt:o,images:ie,referenceVideos:(t.referenceVideo??[]).map((j)=>Cr(j,"video")),referenceAudios:(t.referenceAudio??[]).map((j)=>Cr(j,"audio")),duration:t.duration,ratio:t.ratio,callbackUrl:t.callbackUrl})}catch(j){if(j instanceof q)throw new m(j.message,d.USAGE,"mmx video generate --model MiniMax-H3 --prompt <text>");throw j}}else{if(a)throw new m("--reference-image, --reference-video, --reference-audio, --duration, and --ratio require --model MiniMax-H3.",d.USAGE);if(p={model:l,prompt:o},u)p.first_frame_image=Ae(u);if(t.lastFrame){if(!u)throw new m("--last-frame requires --image (SEF mode).",d.USAGE,"mmx video generate --prompt <text> --image <path> --last-frame <path>");p.last_frame_image=Ae(t.lastFrame)}if(t.subjectImage)p.subject_reference=[{type:"character",image:[Ae(t.subjectImage)]}];if(t.callbackUrl)p.callback_url=t.callbackUrl}if(le(e,p))return;let f=_(e.output),D=Xn(p),h=D?Mo(e.baseUrl):To(e.baseUrl),x=(await A(e,{url:h,method:"POST",body:p})).task_id;if(!e.quiet)process.stderr.write(`[Model: ${l}]
|
|
214
|
+
`);if(t.noWait||e.async){process.stdout.write(JSON.stringify({taskId:x})),process.stdout.write(`
|
|
215
|
+
`);return}let g=t.pollInterval??5,y,v,k;if(D){let ie=dt(e.baseUrl,x),j=await gr(e,{url:ie,intervalSec:g,timeoutSec:e.timeout,isComplete:(ce)=>ce.task.status==="succeeded",isFailed:(ce)=>["failed","cancelled","expired"].includes(ce.task.status),getStatus:(ce)=>ce.task.status,getFailureReason:(ce)=>Qn(ce.task)});k=j.task.status,y=j.task.content?.url}else{let ie=mt(e.baseUrl,x),j=await gr(e,{url:ie,intervalSec:g,timeoutSec:e.timeout,isComplete:(Ne)=>Ne.status==="Success",isFailed:(Ne)=>Ne.status==="Failed",getStatus:(Ne)=>Ne.status});if(k=j.status,v=j.file_id,!v)throw new m("Task completed but no file_id returned.",d.GENERAL);y=(await A(e,{url:pt(e.baseUrl,v)})).file?.download_url}if(!y)throw new m("No download URL available for this file.",d.GENERAL);if(t.download){let ie=t.download,{size:j}=await ge(y,ie,{quiet:e.quiet});if(e.quiet)console.log(ie);else console.log(F({task_id:x,status:k,file_id:v,saved:ie,size:Et(j)},f));return}let B=await import("os"),{join:M}=await import("path"),I=M(B.tmpdir(),"mmx-video"),{existsSync:We,mkdirSync:Pe}=await import("fs");if(!We(I))Pe(I,{recursive:!0});let Ke=M(I,`${x}.mp4`);await ge(y,Ke,{quiet:e.quiet}),process.stdout.write(Ke),process.stdout.write(`
|
|
216
|
+
`)}})});var ri;var oi=C(()=>{T();R();S();V();N();Er();ri=w({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"},{flag:"--model <model>",description:"Use MiniMax-H3 for Video Generation V2 tasks; defaults to the legacy V1 query."}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json","mmx video task get --task-id 424010985738629 --model MiniMax-H3 --output json"],async run(e,t){let o=t.taskId;if(!o)throw new m("--task-id is required.",d.USAGE,"mmx video task get --task-id <id>");if(e.dryRun){console.log(`Would query task: ${o}`);return}let n=_(e.output),i=t.model;if(ke(i)){let u=dt(e.baseUrl,o),l=(await A(e,{url:u})).task;if(e.quiet){console.log(l.status);return}console.log(F({task_id:l.id,model:l.model,status:l.status,url:l.content?.url,resolution:l.resolution,duration:l.duration,ratio:l.ratio,error:l.error},n));return}let s=mt(e.baseUrl,o),r=await A(e,{url:s});if(e.quiet){console.log(r.status);return}console.log(F({task_id:r.task_id,status:r.status,file_id:r.file_id,video_width:r.video_width,video_height:r.video_height},n))}})});var ni;var ii=C(()=>{T();R();S();V();Ft();N();ni=w({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(e,t){let o=t.fileId;if(!o)throw new m("--file-id is required.",d.USAGE,"mmx video download --file-id <id> --out <path>");let n=t.out;if(!n)throw new m("--out is required.",d.USAGE,"mmx video download --file-id <id> --out video.mp4");if(e.dryRun){console.log(`Would download file ${o} to ${n}`);return}let i=pt(e.baseUrl,o),r=(await A(e,{url:i})).file?.download_url;if(!r)throw new m("No download URL available for this file.",d.GENERAL,"The file may still be processing. Check task status first.");let{size:u}=await ge(r,n,{quiet:e.quiet}),a=_(e.output);if(e.quiet){console.log(n);return}console.log(F({saved:n,size:Et(u)},a))}})});var Fr;var si=C(()=>{T();V();N();R();S();Fr=w({name:"search query",description:"Search the web via MiniMax. Note: the underlying /v1/coding_plan/search API returns at most 10 results per call and does not currently support pagination, so refining your --q is the only way to see different results.",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(e,t){let o=t.q??t.query??t._positional?.[0];if(!o)throw new m("--q is required.",d.USAGE,'mmx search query --q "your search query"');let n=_(e.output);if(e.dryRun){console.log(F({request:{q:o}},n));return}let i=Oo(e.baseUrl),s=await A(e,{url:i,method:"POST",body:{q:o}}),r=s.organic||[];if(n!=="text"){console.log(F(s,n));return}if(e.quiet){for(let u of r)console.log(`${u.title} ${u.link}`);return}if(r.length===0){console.log("No results found.");return}for(let u of r){if(console.log(`${u.title}`),console.log(` ${u.link}`),u.snippet)console.log(` ${u.snippet}`);if(u.date)console.log(` ${u.date}`);console.log("")}}})});var ui;var ai=C(()=>{T();V();N();R();S();pe();wt();ui=w({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(e,t){let o=t.image??t.file??t.path??t._positional?.[0],n=t.fileId,i=t.prompt||"Describe the image.";if(!o&&!n)if(G({nonInteractive:e.nonInteractive})){let l=await te({message:"Enter image path, URL, or File ID:"});if(!l)process.stderr.write(`Vision describe cancelled.
|
|
217
|
+
`),process.exit(1);if(!l.includes(".")&&!l.startsWith("http"))n=l;else o=l}else throw new m("Missing required argument. Must provide either --image or --file-id.",d.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(o&&n)throw new m("Conflicting arguments: cannot provide both --image and --file-id.",d.USAGE);if(le(e,{prompt:i,image:o,fileId:n}))return;let s=_(e.output),r=Po(e.baseUrl),u={prompt:i};if(n)u.file_id=n;else if(o){let l=await qn(o);u.image_url=l}let a=await A(e,{url:r,method:"POST",body:u});if(s!=="text"){process.stdout.write(F(a,s)+`
|
|
218
|
+
`);return}process.stdout.write(a.content+`
|
|
219
|
+
`)}})});var ci;var li=C(()=>{T();V();N();ft();ci=w({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(e,t){if(e.dryRun){console.log("Would fetch quota information.");return}let o=_(t.output),n=e.apiKey||e.fileApiKey;if(n&&n.startsWith("sk-api-")){let u=ne(e.baseUrl,n),a=await A(e,{url:u});if(o!=="text"){console.log(F(a,o));return}ue(a,e,n);return}let i=$e(e.baseUrl),s=await A(e,{url:i}),r=s.model_remains||[];if(o!=="text"){console.log(F(s,o));return}if(e.quiet){for(let u of r){let a=u.current_interval_total_count-u.current_interval_usage_count;console.log(`${u.model_name} ${u.current_interval_usage_count} ${u.current_interval_total_count} ${a}`)}return}ue(s,e)}})});var mi;var di=C(()=>{T();se();Ie();N();mi=w({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(e,t){let o=P(),n=_(e.output),i={region:e.region,base_url:e.baseUrl,output:e.output,timeout:e.timeout,config_file:oe()};if(o.api_key)i.api_key=J(o.api_key);if(o.default_text_model)i.default_text_model=o.default_text_model;if(o.default_speech_model)i.default_speech_model=o.default_speech_model;if(o.default_video_model)i.default_video_model=o.default_video_model;if(o.proxy)i.proxy=o.proxy;console.log(F(i,n))}})});function Di(e,t){return e==="api_key"?J(String(t)):t}var pi,Va,fi;var hi=C(()=>{T();R();S();N();se();pi=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model"],Va={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model"};fi=w({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key, proxy, default_text_model, default_speech_model, default_video_model)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key proxy --value http://127.0.0.1:7890","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(e,t){let o=t._positional,n=t.key??o?.[0],i=t.value??o?.[1];if(!n||i===void 0)throw new m("--key and --value are required.",d.USAGE,"mmx config set --key <key> --value <value>");let s=Va[n]||n;if(!pi.includes(s))throw new m(`Invalid config key "${n}". Valid keys: ${pi.join(", ")}`,d.USAGE);let r=s==="api_key"?i.trim():i;if(s==="api_key"&&r.length===0)throw new m("Invalid api_key. The value must not be empty.",d.USAGE);if(s==="region"&&!["global","cn"].includes(i))throw new m(`Invalid region "${i}". Valid values: global, cn`,d.USAGE);if(s==="output"&&!["text","json"].includes(i))throw new m(`Invalid output format "${i}". Valid values: text, json`,d.USAGE);if(s==="base_url"&&!i.startsWith("http"))throw new m(`Invalid base_url "${i}". Must start with http.`,d.USAGE);if(s==="proxy"&&!i.startsWith("http"))throw new m(`Invalid proxy "${i}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,d.USAGE);if(s==="timeout"){let l=Number(i);if(isNaN(l)||l<=0)throw new m(`Invalid timeout "${i}". Must be a positive number.`,d.USAGE)}let u=_(e.output);if(e.dryRun){console.log(F({would_set:{[s]:Di(s,r)}},u));return}let a=P();if(a[s]=s==="timeout"?Number(r):r,s==="api_key")delete a.oauth,delete a.region;if(await K(a),!e.quiet)console.log(F({[s]:Di(s,a[s])},u))}})});function ja(e){let t=e.match(/^--([a-zA-Z0-9-]+)/),o=t?t[1]:"",n=o.replace(/-([a-zA-Z0-9])/g,(r,u)=>u.toUpperCase()),i="string",s=!1;if(!e.includes("<")&&!e.includes("["))i="boolean";else if(e.includes("<n>")||e.includes("<hz>")||e.includes("<bps>")||e.includes("<count>"))i="number";if(e.toLowerCase().includes("repeatable"))s=!0;return{name:n,kebabName:o,inferredType:i,isArray:s}}function xr(e){let o={name:`mmx_${e.name.replace(/ /g,"_")}`,description:e.description,input_schema:{type:"object",properties:{},required:[]}};if(e.options)for(let n of e.options){if(n.hidden)continue;let{name:i,inferredType:s,isArray:r}=ja(n.flag);if(!i)continue;let u=n.type,a=r?"array":u??s,l={description:n.description};if(a==="array")l.type="array",l.items={type:"string"};else l.type=a;let p=o.input_schema;if(p.properties[i]=l,n.required)p.required.push(i)}return o}var Ha,gi;var Ci=C(()=>{T();gt();R();S();Ha=["auth ","config ","update"],gi=w({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(e,t){let o=t.command;if(o){try{let{command:s}=ae.resolve(o.split(" ")),r=xr(s);process.stdout.write(JSON.stringify(r,null,2)+`
|
|
220
|
+
`)}catch{throw new m(`Command "${o}" not found.`,d.USAGE)}return}let i=ae.getAllCommands().filter((s)=>!Ha.some((r)=>s.name.startsWith(r))).map((s)=>xr(s));process.stdout.write(JSON.stringify(i,null,2)+`
|
|
221
|
+
`)}})});import{existsSync as Wa}from"fs";import{readFile as Ka}from"fs/promises";import{resolve as za,basename as Ja}from"path";var yi;var bi=C(()=>{T();R();S();V();N();pe();yi=w({name:"file upload",description:"Upload a file to MiniMax storage",usage:"mmx file upload --file <path> [--purpose <purpose>]",options:[{flag:"--file <path>",description:"Local path to the file",required:!0},{flag:"--purpose <string>",description:"File purpose (default: retrieval)"}],examples:["mmx file upload --file doc.pdf","mmx file upload --file image.png --purpose vision"],async run(e,t){let o=t.file;if(!o)if(G({nonInteractive:e.nonInteractive})){if(o=await te({message:"Enter file path:"}),!o)process.stderr.write(`Upload cancelled.
|
|
222
|
+
`),process.exit(1)}else xe("file","mmx file upload --file <path>");let n=za(o);if(!Wa(n))throw new m(`File not found: ${n}`,d.USAGE);let i=t.purpose||"retrieval",s=_(e.output);if(e.dryRun){process.stdout.write(F({request:{file:n,purpose:i}},s)+`
|
|
223
|
+
`);return}let r=new FormData,u=await Ka(n),a=Ja(n),l=new Blob([u]);r.append("file",l,a),r.append("purpose",i);let p=No(e.baseUrl),f=await A(e,{url:p,method:"POST",body:r});if(e.quiet){process.stdout.write(f.file.file_id+`
|
|
224
|
+
`);return}process.stdout.write(F(f.file,s)+`
|
|
225
|
+
`)}})});var Ei;var Fi=C(()=>{T();V();N();Ei=w({name:"file list",description:"List uploaded files in MiniMax storage",usage:"mmx file list",examples:["mmx file list","mmx file list --output json"],async run(e,t){let o=_(e.output);if(e.dryRun){process.stdout.write(`Would list uploaded files.
|
|
226
|
+
`);return}let n=Lo(e.baseUrl),i=await A(e,{url:n,method:"GET"});if(o!=="text"){process.stdout.write(F(i,o)+`
|
|
227
|
+
`);return}if(!i.files||i.files.length===0){process.stdout.write(`No files found.
|
|
228
|
+
`);return}let s=i.files.map((u)=>({ID:u.file_id,FILENAME:u.filename,PURPOSE:u.purpose,SIZE_KB:(u.bytes/1024).toFixed(1),CREATED:new Date(u.created_at*1000).toISOString().slice(0,16).replace("T"," ")})),{formatTable:r}=await Promise.resolve().then(() => Ir);process.stdout.write(r(s)+`
|
|
229
|
+
`)}})});var xi;var wi=C(()=>{T();V();N();pe();xi=w({name:"file delete",description:"Delete an uploaded file from MiniMax storage",usage:"mmx file delete --file-id <id>",options:[{flag:"--file-id <id>",description:"ID of the file to delete",required:!0}],examples:["mmx file delete --file-id 123456789"],async run(e,t){let o=t.fileId;if(!o)if(G({nonInteractive:e.nonInteractive})){if(o=await te({message:"Enter file ID to delete:"}),!o)process.stderr.write(`Delete cancelled.
|
|
230
|
+
`),process.exit(1)}else xe("file-id","mmx file delete --file-id <id>");let n=_(e.output);if(e.dryRun){process.stdout.write(F({request:{delete_file:o}},n)+`
|
|
231
|
+
`);return}let i=Uo(e.baseUrl),s=await A(e,{url:i,method:"POST",body:{file_id:Number(o)}});if(e.quiet){process.stdout.write(`deleted
|
|
232
|
+
`);return}process.stdout.write(F({file_id:s.file_id,deleted:!0},n)+`
|
|
233
|
+
`)}})});var vi;var $i=C(()=>{T();ct();vi=w({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${we}
|
|
238
234
|
|
|
239
235
|
`),process.stderr.write(`Run:
|
|
240
236
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
241
237
|
|
|
242
|
-
`)}})});var
|
|
238
|
+
`)}})});var Ya,_i;var Ai=C(()=>{T();re();Ya=[{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 search query",title:"Web Search",path:"/docs/api-reference/web-search"},{command:"mmx vision describe",title:"Vision (Image Understanding)",path:"/docs/api-reference/vision"}],_i=w({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(e,t){let o=Le[e.region]||Le.global;process.stdout.write(`
|
|
243
239
|
MiniMax API Documentation Links
|
|
244
240
|
|
|
245
|
-
Official docs: ${
|
|
241
|
+
Official docs: ${o}/docs/api-reference
|
|
246
242
|
|
|
247
|
-
`);for(let
|
|
248
|
-
`),process.stdout.write(` ${" ".repeat(30)} ${
|
|
243
|
+
`);for(let n of Ya)process.stdout.write(` ${n.command.padEnd(30)} ${n.title}
|
|
244
|
+
`),process.stdout.write(` ${" ".repeat(30)} ${o}${n.path}
|
|
249
245
|
|
|
250
|
-
`)}})});var
|
|
251
|
-
`);throw new
|
|
246
|
+
`)}})});var tn={};$t(tn,{registry:()=>ae});class Si{root={children:new Map};constructor(e){for(let[t,o]of Object.entries(e))this.register(t,o)}register(e,t){let o=e.split(" "),n=this.root;for(let i of o){if(!n.children.has(i))n.children.set(i,{children:new Map});n=n.children.get(i)}n.command=t}getAllCommands(){let e=new Set,t=[],o=(n)=>{if(n.command&&!e.has(n.command))e.add(n.command),t.push(n.command);for(let i of n.children.values())o(i)};return o(this.root),t}resolve(e){let t=this.root,o=[];for(let n of e){let i=t.children.get(n);if(!i)break;t=i,o.push(n)}if(t.command)return{command:t.command,extra:e.slice(o.length)};if(o.length>0&&t.children.size===1){let[,n]=t.children.entries().next().value;if(n.command)return{command:n.command,extra:e.slice(o.length)}}if(o.length>0&&t.children.size>1){let i=Array.from(t.children.values()).map((r)=>r.command),s=i[0];if(s&&i.every((r)=>r===s))return{command:s,extra:e.slice(o.length)}}if(o.length>0&&t.children.size>0){let n=Array.from(t.children.entries()).map(([i,s])=>{if(s.command)return` ${o.join(" ")} ${i} ${s.command.description}`;let r=Array.from(s.children.keys()).join(", ");return` ${o.join(" ")} ${i} [${r}]`}).join(`
|
|
247
|
+
`);throw new m(`Unknown command: mmx ${e.join(" ")}
|
|
252
248
|
|
|
253
249
|
Available commands:
|
|
254
|
-
${
|
|
255
|
-
${this.bold("Usage:",
|
|
250
|
+
${n}`,d.USAGE,`mmx ${o.join(" ")} --help`)}throw new m(`Unknown command: mmx ${e.join(" ")}`,d.USAGE,"mmx --help")}bold=(e,t)=>t.isTTY?`\x1B[1m${e}\x1B[0m`:e;accent=(e,t)=>t.isTTY?`\x1B[38;2;248;103;58m${e}\x1B[0m`:e;dim=(e,t)=>t.isTTY?`\x1B[2m${e}\x1B[0m`:e;printHelp(e,t=process.stdout,o="global"){if(e.length===0){this.printRootHelp(t);return}let n=this.root;for(let s of e){let r=n.children.get(s);if(!r){this.printRootHelp(t);return}n=r}if(n.command){this.printCommandHelp(n.command,t,o);return}let i=e.join(" ");t.write(`
|
|
251
|
+
${this.bold("Usage:",t)} mmx ${i} <command> [flags]
|
|
256
252
|
|
|
257
|
-
`),
|
|
258
|
-
`),this.printChildren(
|
|
259
|
-
`)}printRootHelp(
|
|
260
|
-
`);for(let
|
|
261
|
-
`)}else
|
|
262
|
-
`);let
|
|
263
|
-
${
|
|
253
|
+
`),t.write(`${this.bold("Commands:",t)}
|
|
254
|
+
`),this.printChildren(n,i,t),t.write(`
|
|
255
|
+
`)}printRootHelp(e){let t=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],o=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];e.write(`
|
|
256
|
+
`);for(let r=0;r<t.length;r++)if(e.isTTY){let[u,a,l]=o[r];e.write(`\x1B[1;38;2;${u};${a};${l}m${t[r]}\x1B[0m
|
|
257
|
+
`)}else e.write(t[r]+`
|
|
258
|
+
`);let n=(r)=>this.bold(r,e),i=(r)=>this.accent(r,e),s=(r)=>this.dim(r,e);e.write(`
|
|
259
|
+
${n("Usage:")} mmx <resource> <command> [flags]
|
|
264
260
|
|
|
265
|
-
${
|
|
266
|
-
${
|
|
267
|
-
${
|
|
268
|
-
${
|
|
269
|
-
${
|
|
270
|
-
${
|
|
271
|
-
${
|
|
272
|
-
${
|
|
273
|
-
${
|
|
274
|
-
${
|
|
275
|
-
${
|
|
276
|
-
${
|
|
277
|
-
${o("update")} ${m("Update mmx to a newer version")}
|
|
261
|
+
${n("Resources:")}
|
|
262
|
+
${i("auth")} ${s("Authentication (login, status, refresh, logout)")}
|
|
263
|
+
${i("text")} ${s("Text generation (chat)")}
|
|
264
|
+
${i("speech")} ${s("Speech synthesis (synthesize, voices)")}
|
|
265
|
+
${i("image")} ${s("Image generation (generate)")}
|
|
266
|
+
${i("video")} ${s("Video generation (generate, task get, download)")}
|
|
267
|
+
${i("search")} ${s("Web search (query)")}
|
|
268
|
+
${i("vision")} ${s("Image understanding (describe)")}
|
|
269
|
+
${i("quota")} ${s("Usage quotas (show)")}
|
|
270
|
+
${i("config")} ${s("CLI configuration (show, set, export-schema)")}
|
|
271
|
+
${i("file")} ${s("File storage (upload, list, delete)")}
|
|
272
|
+
${i("update")} ${s("Update mmx to a newer version")}
|
|
278
273
|
|
|
279
|
-
${
|
|
280
|
-
${
|
|
281
|
-
${
|
|
282
|
-
${
|
|
283
|
-
${
|
|
284
|
-
${
|
|
285
|
-
${
|
|
286
|
-
${
|
|
287
|
-
${
|
|
288
|
-
${
|
|
289
|
-
${
|
|
290
|
-
${
|
|
291
|
-
${
|
|
274
|
+
${n("Global Flags:")}
|
|
275
|
+
${i("--api-key <key>")} ${s("API key (overrides all other auth)")}
|
|
276
|
+
${i("--region <region>")} ${s("API region: global (default), cn")}
|
|
277
|
+
${i("--base-url <url>")} ${s("API base URL (overrides region)")}
|
|
278
|
+
${i("--output <format>")} ${s("Output format: text, json")}
|
|
279
|
+
${i("--quiet")} ${s("Suppress non-essential output")}
|
|
280
|
+
${i("--verbose")} ${s("Print HTTP request/response details")}
|
|
281
|
+
${i("--timeout <seconds>")} ${s("Request timeout (default: 300)")}
|
|
282
|
+
${i("--no-color")} ${s("Disable ANSI colors and spinners")}
|
|
283
|
+
${i("--dry-run")} ${s("Show what would happen without executing")}
|
|
284
|
+
${i("--non-interactive")} ${s("Disable interactive prompts (CI/agent mode)")}
|
|
285
|
+
${i("--version")} ${s("Print version and exit")}
|
|
286
|
+
${i("--help")} ${s("Show help")}
|
|
292
287
|
|
|
293
|
-
${
|
|
294
|
-
${
|
|
295
|
-
${
|
|
296
|
-
`)}printCommandHelp(t,
|
|
297
|
-
${
|
|
298
|
-
`),
|
|
299
|
-
`);let
|
|
300
|
-
${
|
|
301
|
-
`);for(let
|
|
302
|
-
`)}if(
|
|
303
|
-
${
|
|
304
|
-
`);for(let
|
|
305
|
-
`)}if(
|
|
306
|
-
${
|
|
307
|
-
`);
|
|
308
|
-
${
|
|
309
|
-
`),
|
|
310
|
-
`)}printChildren(t,
|
|
311
|
-
`)}}var
|
|
288
|
+
${n("Getting Help:")}
|
|
289
|
+
${s("Add --help after any command to see its full list of options, defaults,")}
|
|
290
|
+
${s("and usage examples. For example:")} mmx text chat --help
|
|
291
|
+
`)}printCommandHelp(e,t,o="global"){let n=(u)=>this.bold(u,t),i=(u)=>this.accent(u,t),s=(u)=>this.dim(u,t);if(t.write(`
|
|
292
|
+
${e.description}
|
|
293
|
+
`),e.usage)t.write(`${n("Usage:")} ${e.usage}
|
|
294
|
+
`);let r=e.options?.filter((u)=>!u.hidden)??[];if(r.length>0){let u=Math.max(...r.map((a)=>a.flag.length));t.write(`
|
|
295
|
+
${n("Options:")}
|
|
296
|
+
`);for(let a of r)t.write(` ${i(a.flag.padEnd(u+2))} ${s(a.description)}
|
|
297
|
+
`)}if(e.examples&&e.examples.length>0){t.write(`
|
|
298
|
+
${n("Examples:")}
|
|
299
|
+
`);for(let u of e.examples)t.write(` ${s(u)}
|
|
300
|
+
`)}if(e.apiDocs)t.write(`
|
|
301
|
+
${n("API Reference:")} ${s(Le[o]+e.apiDocs)}
|
|
302
|
+
`);t.write(`
|
|
303
|
+
${s("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
|
|
304
|
+
`),t.write(`${s("Run")} mmx --help ${s("for the full list.")}
|
|
305
|
+
`)}printChildren(e,t,o){let n=[],i=(r,u)=>{for(let[a,l]of r.children){if(l.command)n.push({fullName:`${u} ${a}`,description:l.command.description});if(l.children.size>0)i(l,`${u} ${a}`)}};i(e,t);let s=Math.max(...n.map((r)=>r.fullName.length));for(let{fullName:r,description:u}of n)o.write(` ${this.accent(r.padEnd(s),o)} ${this.dim(u,o)}
|
|
306
|
+
`)}}var ae;var gt=C(()=>{R();S();re();en();on();sn();an();pn();Cn();Bn();Tn();Kn();ti();oi();ii();si();ai();li();di();hi();Ci();bi();Fi();wi();$i();Ai();ae=new Si({"auth login":Zo,"auth status":rn,"auth refresh":nn,"auth logout":un,"text chat":dn,"text repl":gn,"speech synthesize":pr,"speech generate":pr,"speech voices":In,"image generate":Wn,"video generate":ei,"video task get":ri,"video download":ni,"search query":Fr,"search web":Fr,"vision describe":ui,"quota show":ci,"config show":mi,"config set":fi,"config export-schema":gi,"file upload":yi,"file list":Ei,"file delete":xi,update:vi,help:_i})});var Vi=new Set(["true","1","yes","on"]),ji=new Set(["false","0","no","off"]);function _t(e){return e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}function Hi(e){let t=e.flag.match(/^--([a-z][a-z0-9-]*)/i);return t?_t(t[1]):null}function Wi(e){if(e.type==="boolean")return!0;if(e.type==="string"||e.type==="number"||e.type==="array")return!1;return!e.flag.includes("<")&&!e.flag.includes("[")}function $r(e){let t=new Set,o=new Set,n=new Set;for(let i of e){let s=Hi(i);if(!s)continue;if(Wi(i))t.add(s);else if(i.type==="number")o.add(s);else if(i.type==="array")n.add(s)}return{booleans:t,numbers:o,arrays:n}}function _r(e,t=[]){let o=$r(t),n=[],i=0;while(i<e.length){let s=e[i];if(s==="--")break;if(s.startsWith("--")){let r=s.indexOf("="),u=r!==-1?s.slice(2,r):s.slice(2),a=_t(u);if(!o.booleans.has(a)&&r===-1)i+=2;else i+=1;continue}if(s.startsWith("-")){i++;continue}n.push(s),i++}return n}function At(e,t){let o=$r(t),n={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},i=0;while(i<e.length){let s=e[i];if(s==="--help"||s==="-h"){n.help=!0,i++;continue}if(s==="--")break;if(s.startsWith("--")){let r=s.indexOf("="),u,a;if(r!==-1)u=s.slice(2,r),a=s.slice(r+1);else u=s.slice(2);let l=_t(u);if(o.booleans.has(l)){if(a===void 0)n[l]=!0;else{let p=a.trim().toLowerCase();if(Vi.has(p))n[l]=!0;else if(ji.has(p))n[l]=!1;else throw Error(`Flag --${u} requires a boolean value (e.g. true/false), got "${a}".`)}i++;continue}if(a===void 0)i++,a=e[i];if(a===void 0)throw Error(`Flag --${u} requires a value.`);if(o.arrays.has(l)){let p=n[l];if(p)p.push(a);else n[l]=[a]}else if(o.numbers.has(l)){let p=Number(a);if(a.trim()===""||!Number.isFinite(p))throw Error(`Flag --${u} requires a numeric value, got "${a}".`);n[l]=p}else n[l]=a}i++}return n}gt();T();R();S();N();function Re(e){if(e instanceof m){if(_(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(e.toJSON(),null,2)+`
|
|
312
307
|
`);else{if(process.stderr.write(`
|
|
313
|
-
Error: ${
|
|
314
|
-
`),
|
|
315
|
-
${
|
|
308
|
+
Error: ${e.message}
|
|
309
|
+
`),e.hint)process.stderr.write(`
|
|
310
|
+
${e.hint.split(`
|
|
316
311
|
`).join(`
|
|
317
312
|
`)}
|
|
318
|
-
`);process.stderr.write(` (exit code ${
|
|
319
|
-
`)}process.exit(
|
|
313
|
+
`);process.stderr.write(` (exit code ${e.exitCode})
|
|
314
|
+
`)}process.exit(e.exitCode)}if(e instanceof Error){if(e.name==="AbortError"||e.name==="TimeoutError"||e.message.includes("timed out")){let i=new m("Request timed out.",d.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
|
|
320
315
|
If this happens on every request with a valid API key, you may be hitting the wrong region.
|
|
321
316
|
`+`Run: mmx auth status — to check your credentials and region.
|
|
322
|
-
`+"Run: mmx config set region global (or cn) — to override the region.");return
|
|
323
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return
|
|
324
|
-
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(
|
|
325
|
-
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let
|
|
326
|
-
Error: ${
|
|
327
|
-
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${
|
|
317
|
+
`+"Run: mmx config set region global (or cn) — to override the region.");return Re(i)}if(e instanceof TypeError&&e.message==="fetch failed"){let i=new m("Network request failed.",d.NETWORK,`Check your network connection.
|
|
318
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return Re(i)}let t=e.message.toLowerCase();if(t.includes("failed to fetch")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("connection reset")||t.includes("econnreset")||t.includes("network error")||t.includes("enotfound")||t.includes("getaddrinfo")||t.includes("proxy")||t.includes("socket")||t.includes("etimedout")||t.includes("timeout")||t.includes("eai_AGAIN")){let i=`Check your network connection.
|
|
319
|
+
To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(t.includes("proxy"))i=`Proxy connection failed — verify your proxy URL and authentication.
|
|
320
|
+
`+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let s=new m("Network request failed.",d.NETWORK,i);return Re(s)}let n=e.code;if(n==="ENOENT"||n==="EACCES"||n==="ENOSPC"||n==="ENOTDIR"||n==="EISDIR"||n==="EPERM"||n==="EBUSY"){let i="Check the file path and permissions.";if(n==="ENOENT")i="File or directory not found.";if(n==="EACCES"||n==="EPERM")i="Permission denied — check file or directory permissions.";if(n==="ENOSPC")i="Disk full — free up space and try again.";let s=new m(`File system error: ${e.message}`,d.GENERAL,i);return Re(s)}else if(typeof n==="string"&&n.startsWith("E")){let i=new m(`File system error: ${e.message}`,d.GENERAL,"Check the file path and permissions.");return Re(i)}if(process.stderr.write(`
|
|
321
|
+
Error: ${e.message}
|
|
322
|
+
`),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${e.stack}
|
|
328
323
|
`)}else process.stderr.write(`
|
|
329
|
-
Error: ${String(
|
|
330
|
-
`);process.exit(
|
|
324
|
+
Error: ${String(e)}
|
|
325
|
+
`);process.exit(d.GENERAL)}se();sr();re();Ie();import{join as Xa}from"path";import{readFileSync as Qa,writeFileSync as Za}from"fs";var ki=()=>Xa(Xe(),"update-state.json"),ec=86400000,tc=3000,rc="MiniMax-AI-Dev/minimax-cli";function oc(){try{let e=Qa(ki(),"utf-8");return JSON.parse(e)}catch{return null}}function nc(e){try{Za(ki(),JSON.stringify(e))}catch{}}async function ic(){try{let e=await fetch(`https://api.github.com/repos/${rc}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(tc)});if(!e.ok)return null;return(await e.json()).tag_name??null}catch{return null}}var wr=null;function Ri(){return wr}async function Bi(e){if(process.env.CI||!process.stderr.isTTY)return;let t=oc(),o=Date.now();if(t&&o-t.lastChecked<ec){if(t.latestVersion&&t.latestVersion!==`v${e}`)wr=t.latestVersion;return}let n=await ic();if(!n)return;if(nc({lastChecked:o,latestVersion:n}),n!==`v${e}`)wr=n}De();Zt();ct();import{ProxyAgent as sc,setGlobalDispatcher as uc}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
|
|
331
326
|
Interrupted. Exiting.
|
|
332
|
-
`),process.exit(130)});process.stdout.on("error",(
|
|
327
|
+
`),process.exit(130)});process.stdout.on("error",(e)=>{if(e.code==="EPIPE")process.exit(0);else throw e});var ac=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function cc(){let e=process.argv.slice(2);if(e.includes("--version")||e.includes("-v"))console.log(`mmx ${we}`),process.exit(0);let t=_r(e,Ye),o=P(),n=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||o.proxy;if(n)uc(new sc(n));if(e.includes("--help")||e.includes("-h")){let f=e.indexOf("--region"),D=f>=0&&e[f+1]||process.env.MINIMAX_REGION||o.region||"global";ae.printHelp(t,process.stderr,D),process.exit(0)}if(t.length===0){ae.printHelp([],process.stderr);let{command:f}=ae.resolve(["quota","show"]),D=At(e,[...Ye,...f.options??[]]),h=kt(D),E=!!(h.apiKey||h.fileApiKey),x=!!await Y();if(E||x)await f.execute(h,D);else process.stderr.write(` Not logged in.
|
|
333
328
|
`),process.stderr.write(` mmx auth login Choose MiniMax OAuth (Global/China) or paste an API key
|
|
334
329
|
`),process.stderr.write(` mmx auth login --api-key Save an API key directly
|
|
335
330
|
|
|
336
|
-
`);process.exit(0)}let{command:
|
|
337
|
-
Update available: ${
|
|
331
|
+
`);process.exit(0)}let{command:i,extra:s}=ae.resolve(t),r=At(e,[...Ye,...i.options??[]]);if(s.length>0)r._positional=s;let u=kt(r);if(!ac.some((f)=>f.every((D,h)=>t[h]===D)))await yo(u);if(u.needsRegionDetection){let f=u.apiKey||u.fileApiKey;if(f){let D=await ht(f);u.region=D,u.baseUrl=U[D],u.needsRegionDetection=!1,await Jo(D)}}let l=Bi(we).catch(()=>{});await i.execute(u,r),await l;let p=Ri();if(p&&!u.quiet)process.stderr.write(`
|
|
332
|
+
Update available: ${p}
|
|
338
333
|
`),process.stderr.write(` npm update -g mmx-cli
|
|
339
334
|
|
|
340
|
-
`)}
|
|
335
|
+
`)}cc().catch(Re);
|