mmx-cli 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mmx.mjs CHANGED
@@ -1,104 +1,104 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as Bi}from"node:module";var vi=Object.create;var{getPrototypeOf:li,defineProperty:Kt,getOwnPropertyNames:Ri}=Object;var ki=Object.prototype.hasOwnProperty;function Si(t){return this[t]}var Mi,Ai,lt=(t,e,i)=>{var r=t!=null&&typeof t==="object";if(r){var o=e?Mi??=new WeakMap:Ai??=new WeakMap,$=o.get(t);if($)return $}i=t!=null?vi(li(t)):{};let n=e||!t||!t.__esModule?Kt(i,"default",{value:t,enumerable:!0}):i;for(let m of Ri(t))if(!ki.call(n,m))Kt(n,m,{get:Si.bind(t,m),enumerable:!0});if(r)o.set(t,n);return n};var Ae=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ji=(t)=>t;function Gi(t,e){this[t]=ji.bind(null,e)}var je=(t,e)=>{for(var i in e)Kt(t,i,{get:e[i],enumerable:!0,configurable:!0,set:Gi.bind(e,i)})};var Ht=(t,e)=>()=>(t&&(e=t(t=0)),e);var $t=Bi(import.meta.url);var gt=Ae((em,De)=>{var Ft={to(t,e){if(!e)return`\x1B[${t+1}G`;return`\x1B[${e+1};${t+1}H`},move(t,e){let i="";if(t<0)i+=`\x1B[${-t}D`;else if(t>0)i+=`\x1B[${t}C`;if(e<0)i+=`\x1B[${-e}A`;else if(e>0)i+=`\x1B[${e}B`;return i},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},rr={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},or={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let i=0;i<t;i++)e+=this.line+(i<t-1?Ft.up():"");if(t)e+=Ft.left;return e}};De.exports={cursor:Ft,scroll:rr,erase:or,beep:"\x07"}});var te=Ae((nm,Dt)=>{var Nt=process||{},tn=Nt.argv||[],qt=Nt.env||{},$r=!(!!qt.NO_COLOR||tn.includes("--no-color"))&&(!!qt.FORCE_COLOR||tn.includes("--color")||Nt.platform==="win32"||(Nt.stdout||{}).isTTY&&qt.TERM!=="dumb"||!!qt.CI),mr=(t,e,i=t)=>(r)=>{let o=""+r,$=o.indexOf(e,t.length);return~$?t+pr(o,e,i,$)+e:t+o+e},pr=(t,e,i,r)=>{let o="",$=0;do o+=t.substring($,r)+i,$=r+e.length,r=t.indexOf(e,$);while(~r);return o+t.substring($)},en=(t=$r)=>{let e=t?mr:()=>String;return{isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};Dt.exports=en();Dt.exports.createColors=en});import{stdin as hn,stdout as bn}from"node:process";import*as F from"node:readline";import nn from"node:readline";import{WriteStream as sr}from"node:tty";function cr({onlyFirst:t=!1}={}){let e=["[\\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(e,t?void 0:"g")}function vn(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(ur,"")}function ln(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _t(t,e={}){if(typeof t!="string"||t.length===0||(e={ambiguousIsNarrow:!0,...e},t=vn(t),t.length===0))return 0;t=t.replace(_r()," ");let i=e.ambiguousIsNarrow?1:2,r=0;for(let o of t){let $=o.codePointAt(0);if($<=31||$>=127&&$<=159||$>=768&&$<=879)continue;switch(xr.eastAsianWidth(o)){case"F":case"W":r+=2;break;case"A":r+=i;break;default:r+=1}}return r}function vr(){let t=new Map;for(let[e,i]of Object.entries(T)){for(let[r,o]of Object.entries(i))T[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},i[r]=T[r],t.set(o[0],o[1]);Object.defineProperty(T,e,{value:i,enumerable:!1})}return Object.defineProperty(T,"codes",{value:t,enumerable:!1}),T.color.close="\x1B[39m",T.bgColor.close="\x1B[49m",T.color.ansi=rn(),T.color.ansi256=on(),T.color.ansi16m=$n(),T.bgColor.ansi=rn(ee),T.bgColor.ansi256=on(ee),T.bgColor.ansi16m=$n(ee),Object.defineProperties(T,{rgbToAnsi256:{value:(e,i,r)=>e===i&&i===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(e)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!i)return[0,0,0];let[r]=i;r.length===3&&(r=[...r].map(($)=>$+$).join(""));let o=Number.parseInt(r,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(e)=>T.rgbToAnsi256(...T.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:(e)=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let i,r,o;if(e>=232)i=((e-232)*10+8)/255,r=i,o=i;else{e-=16;let m=e%36;i=Math.floor(e/36)/5,r=Math.floor(m/6)/5,o=m%6/5}let $=Math.max(i,r,o)*2;if($===0)return 30;let n=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(i));return $===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,i,r)=>T.ansi256ToAnsi(T.rgbToAnsi256(e,i,r)),enumerable:!1},hexToAnsi:{value:(e)=>T.ansi256ToAnsi(T.hexToAnsi256(e)),enumerable:!1}}),T}function sn(t,e,i){return String(t).normalize().replace(/\r\n/g,`
2
+ import{createRequire as Ki}from"node:module";var Xi=Object.create;var{getPrototypeOf:Ji,defineProperty:Et,getOwnPropertyNames:Oi}=Object;var Qi=Object.prototype.hasOwnProperty;function Zi(t){return this[t]}var Vi,zi,At=(t,n,i)=>{var r=t!=null&&typeof t==="object";if(r){var o=n?Vi??=new WeakMap:zi??=new WeakMap,m=o.get(t);if(m)return m}i=t!=null?Xi(Ji(t)):{};let e=n||!t||!t.__esModule?Et(i,"default",{value:t,enumerable:!0}):i;for(let $ of Oi(t))if(!Qi.call(e,$))Et(e,$,{get:Zi.bind(t,$),enumerable:!0});if(r)o.set(t,e);return e};var Jn=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports);var Wi=(t)=>t;function di(t,n){this[t]=Wi.bind(null,n)}var On=(t,n)=>{for(var i in n)Et(t,i,{get:n[i],enumerable:!0,configurable:!0,set:di.bind(n,i)})};var ft=(t,n)=>()=>(t&&(n=t(t=0)),n);var mt=Ki(import.meta.url);var $n=Jn((h$,pe)=>{var mn={to(t,n){if(!n)return`\x1B[${t+1}G`;return`\x1B[${n+1};${t+1}H`},move(t,n){let i="";if(t<0)i+=`\x1B[${-t}D`;else if(t>0)i+=`\x1B[${t}C`;if(n<0)i+=`\x1B[${-n}A`;else if(n>0)i+=`\x1B[${n}B`;return i},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Sr={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},Mr={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let n="";for(let i=0;i<t;i++)n+=this.line+(i<t-1?mn.up():"");if(t)n+=mn.left;return n}};pe.exports={cursor:mn,scroll:Sr,erase:Mr,beep:"\x07"}});var un=Jn((b$,pn)=>{var Jt=process||{},ue=Jt.argv||[],Xt=Jt.env||{},vr=!(!!Xt.NO_COLOR||ue.includes("--no-color"))&&(!!Xt.FORCE_COLOR||ue.includes("--color")||Jt.platform==="win32"||(Jt.stdout||{}).isTTY&&Xt.TERM!=="dumb"||!!Xt.CI),kr=(t,n,i=t)=>(r)=>{let o=""+r,m=o.indexOf(n,t.length);return~m?t+Ar(o,n,i,m)+n:t+o+n},Ar=(t,n,i,r)=>{let o="",m=0;do o+=t.substring(m,r)+i,m=r+n.length,r=t.indexOf(n,m);while(~r);return o+t.substring(m)},ce=(t=vr)=>{let n=t?kr:()=>String;return{isColorSupported:t,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};pn.exports=ce();pn.exports.createColors=ce});import{stdin as je,stdout as Te}from"node:process";import*as L from"node:readline";import se from"node:readline";import{WriteStream as Rr}from"node:tty";function jr({onlyFirst:t=!1}={}){let n=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(n,t?void 0:"g")}function Ge(t){if(typeof t!="string")throw TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(Tr,"")}function le(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ht(t,n={}){if(typeof t!="string"||t.length===0||(n={ambiguousIsNarrow:!0,...n},t=Ge(t),t.length===0))return 0;t=t.replace(qr()," ");let i=n.ambiguousIsNarrow?1:2,r=0;for(let o of t){let m=o.codePointAt(0);if(m<=31||m>=127&&m<=159||m>=768&&m<=879)continue;switch(lr.eastAsianWidth(o)){case"F":case"W":r+=2;break;case"A":r+=i;break;default:r+=1}}return r}function Xr(){let t=new Map;for(let[n,i]of Object.entries(l)){for(let[r,o]of Object.entries(i))l[r]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},i[r]=l[r],t.set(o[0],o[1]);Object.defineProperty(l,n,{value:i,enumerable:!1})}return Object.defineProperty(l,"codes",{value:t,enumerable:!1}),l.color.close="\x1B[39m",l.bgColor.close="\x1B[49m",l.color.ansi=xe(),l.color.ansi256=ye(),l.color.ansi16m=_e(),l.bgColor.ansi=xe(cn),l.bgColor.ansi256=ye(cn),l.bgColor.ansi16m=_e(cn),Object.defineProperties(l,{rgbToAnsi256:{value:(n,i,r)=>n===i&&i===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value:(n)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!i)return[0,0,0];let[r]=i;r.length===3&&(r=[...r].map((m)=>m+m).join(""));let o=Number.parseInt(r,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:(n)=>l.rgbToAnsi256(...l.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:(n)=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let i,r,o;if(n>=232)i=((n-232)*10+8)/255,r=i,o=i;else{n-=16;let $=n%36;i=Math.floor(n/36)/5,r=Math.floor($/6)/5,o=$%6/5}let m=Math.max(i,r,o)*2;if(m===0)return 30;let e=30+(Math.round(o)<<2|Math.round(r)<<1|Math.round(i));return m===2&&(e+=60),e},enumerable:!1},rgbToAnsi:{value:(n,i,r)=>l.ansi256ToAnsi(l.rgbToAnsi256(n,i,r)),enumerable:!1},hexToAnsi:{value:(n)=>l.ansi256ToAnsi(l.hexToAnsi256(n)),enumerable:!1}}),l}function be(t,n,i){return String(t).normalize().replace(/\r\n/g,`
3
3
  `).split(`
4
- `).map((r)=>Ar(r,e,i)).join(`
5
- `)}function Br(t,e){if(t===e)return;let i=t.split(`
6
- `),r=e.split(`
7
- `),o=[];for(let $=0;$<Math.max(i.length,r.length);$++)i[$]!==r[$]&&o.push($);return o}function Qt(t){return t===Mn}function Jt(t,e){t.isTTY&&t.setRawMode(e)}class g{constructor({render:t,input:e=hn,output:i=bn,...r},o=!0){z(this,"input"),z(this,"output"),z(this,"rl"),z(this,"opts"),z(this,"_track",!1),z(this,"_render"),z(this,"_cursor",0),z(this,"state","initial"),z(this,"value"),z(this,"error",""),z(this,"subscribers",new Map),z(this,"_prevFrame",""),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this.input=e,this.output=i}prompt(){let t=new sr(0);return t._write=(e,i,r)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),r()},this.input.pipe(t),this.rl=nn.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),nn.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),Jt(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((e,i)=>{this.once("submit",()=>{this.output.write(X.cursor.show),this.output.off("resize",this.render),Jt(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(X.cursor.show),this.output.off("resize",this.render),Jt(this.input,!1),e(Mn)})})}on(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e}),this.subscribers.set(t,i)}once(t,e){let i=this.subscribers.get(t)??[];i.push({cb:e,once:!0}),this.subscribers.set(t,i)}emit(t,...e){let i=this.subscribers.get(t)??[],r=[];for(let o of i)o.cb(...e),o.once&&r.push(()=>i.splice(i.indexOf(o),1));for(let o of r)o()}unsubscribe(){this.subscribers.clear()}onKeypress(t,e){if(this.state==="error"&&(this.state="active"),e?.name&&!this._track&&cn.has(e.name)&&this.emit("cursor",cn.get(e.name)),e?.name&&Tr.has(e.name)&&this.emit("cursor",e.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),e?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
- `),Jt(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=sn(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
- `).length-1;this.output.write(X.cursor.move(-999,t*-1))}render(){let t=sn(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(X.cursor.hide);else{let e=Br(this._prevFrame,t);if(this.restoreCursor(),e&&e?.length===1){let i=e[0];this.output.write(X.cursor.move(0,i)),this.output.write(X.erase.lines(1));let r=t.split(`
10
- `);this.output.write(r[i]),this._prevFrame=t,this.output.write(X.cursor.move(0,r.length-i-1));return}else if(e&&e?.length>1){let i=e[0];this.output.write(X.cursor.move(0,i)),this.output.write(X.erase.down());let r=t.split(`
4
+ `).map((r)=>zr(r,n,i)).join(`
5
+ `)}function Kr(t,n){if(t===n)return;let i=t.split(`
6
+ `),r=n.split(`
7
+ `),o=[];for(let m=0;m<Math.max(i.length,r.length);m++)i[m]!==r[m]&&o.push(m);return o}function Zt(t){return t===Ye}function Ot(t,n){t.isTTY&&t.setRawMode(n)}class E{constructor({render:t,input:n=je,output:i=Te,...r},o=!0){V(this,"input"),V(this,"output"),V(this,"rl"),V(this,"opts"),V(this,"_track",!1),V(this,"_render"),V(this,"_cursor",0),V(this,"state","initial"),V(this,"value"),V(this,"error",""),V(this,"subscribers",new Map),V(this,"_prevFrame",""),this.opts=r,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=t.bind(this),this._track=o,this.input=n,this.output=i}prompt(){let t=new Rr(0);return t._write=(n,i,r)=>{this._track&&(this.value=this.rl.line.replace(/\t/g,""),this._cursor=this.rl.cursor,this.emit("value",this.value)),r()},this.input.pipe(t),this.rl=se.createInterface({input:this.input,output:t,tabSize:2,prompt:"",escapeCodeTimeout:50}),se.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),Ot(this.input,!0),this.output.on("resize",this.render),this.render(),new Promise((n,i)=>{this.once("submit",()=>{this.output.write(X.cursor.show),this.output.off("resize",this.render),Ot(this.input,!1),n(this.value)}),this.once("cancel",()=>{this.output.write(X.cursor.show),this.output.off("resize",this.render),Ot(this.input,!1),n(Ye)})})}on(t,n){let i=this.subscribers.get(t)??[];i.push({cb:n}),this.subscribers.set(t,i)}once(t,n){let i=this.subscribers.get(t)??[];i.push({cb:n,once:!0}),this.subscribers.set(t,i)}emit(t,...n){let i=this.subscribers.get(t)??[],r=[];for(let o of i)o.cb(...n),o.once&&r.push(()=>i.splice(i.indexOf(o),1));for(let o of r)o()}unsubscribe(){this.subscribers.clear()}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&!this._track&&Se.has(n.name)&&this.emit("cursor",Se.get(n.name)),n?.name&&ar.has(n.name)&&this.emit("cursor",n.name),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),t==="\t"&&this.opts.placeholder&&(this.value||(this.rl.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),t&&this.emit("key",t.toLowerCase()),n?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i,this.state="error",this.rl.write(this.value))}this.state!=="error"&&(this.state="submit")}t==="\x03"&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
8
+ `),Ot(this.input,!1),this.rl.close(),this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let t=be(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
9
+ `).length-1;this.output.write(X.cursor.move(-999,t*-1))}render(){let t=be(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(X.cursor.hide);else{let n=Kr(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){let i=n[0];this.output.write(X.cursor.move(0,i)),this.output.write(X.erase.lines(1));let r=t.split(`
10
+ `);this.output.write(r[i]),this._prevFrame=t,this.output.write(X.cursor.move(0,r.length-i-1));return}else if(n&&n?.length>1){let i=n[0];this.output.write(X.cursor.move(0,i)),this.output.write(X.erase.down());let r=t.split(`
11
11
  `).slice(i);this.output.write(r.join(`
12
- `)),this._prevFrame=t;return}this.output.write(X.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function Gn({input:t=hn,output:e=bn,overwrite:i=!0,hideCursor:r=!0}={}){let o=F.createInterface({input:t,output:e,prompt:"",tabSize:1});F.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let $=(n,{name:m})=>{if(String(n)==="\x03"){r&&e.write(X.cursor.show),process.exit(0);return}if(!i)return;F.moveCursor(e,m==="return"?0:-1,m==="return"?-1:0,()=>{F.clearLine(e,1,()=>{t.once("keypress",$)})})};return r&&e.write(X.cursor.hide),t.once("keypress",$),()=>{t.off("keypress",$),r&&e.write(X.cursor.show),t.isTTY&&!Hr&&t.setRawMode(!1),o.terminal=!1,o.close()}}var X,et,ur,Rn,yr,xr,wr=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},_r,ee=10,rn=(t=0)=>(e)=>`\x1B[${e+t}m`,on=(t=0)=>(e)=>`\x1B[${38+t};5;${e}m`,$n=(t=0)=>(e,i,r)=>`\x1B[${38+t};2;${e};${i};${r}m`,T,hr,br,lr,Xt,Rr=39,ie="\x07",kn="[",kr="]",Sn="m",re,mn=(t)=>`${Xt.values().next().value}${kn}${t}${Sn}`,pn=(t)=>`${Xt.values().next().value}${re}${t}${ie}`,Sr=(t)=>t.split(" ").map((e)=>_t(e)),ne=(t,e,i)=>{let r=[...e],o=!1,$=!1,n=_t(vn(t[t.length-1]));for(let[m,s]of r.entries()){let c=_t(s);if(n+c<=i?t[t.length-1]+=s:(t.push(s),n=0),Xt.has(s)&&(o=!0,$=r.slice(m+1).join("").startsWith(re)),o){$?s===ie&&(o=!1,$=!1):s===Sn&&(o=!1);continue}n+=c,n===i&&m<r.length-1&&(t.push(""),n=0)}!n&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},Mr=(t)=>{let e=t.split(" "),i=e.length;for(;i>0&&!(_t(e[i-1])>0);)i--;return i===e.length?t:e.slice(0,i).join(" ")+e.slice(i).join("")},Ar=(t,e,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,$,n=Sr(t),m=[""];for(let[c,x]of t.split(" ").entries()){i.trim!==!1&&(m[m.length-1]=m[m.length-1].trimStart());let w=_t(m[m.length-1]);if(c!==0&&(w>=e&&(i.wordWrap===!1||i.trim===!1)&&(m.push(""),w=0),(w>0||i.trim===!1)&&(m[m.length-1]+=" ",w++)),i.hard&&n[c]>e){let h=e-w,_=1+Math.floor((n[c]-h-1)/e);Math.floor((n[c]-1)/e)<_&&m.push(""),ne(m,x,e);continue}if(w+n[c]>e&&w>0&&n[c]>0){if(i.wordWrap===!1&&w<e){ne(m,x,e);continue}m.push("")}if(w+n[c]>e&&i.wordWrap===!1){ne(m,x,e);continue}m[m.length-1]+=x}i.trim!==!1&&(m=m.map((c)=>Mr(c)));let s=[...m.join(`
13
- `)];for(let[c,x]of s.entries()){if(r+=x,Xt.has(x)){let{groups:h}=new RegExp(`(?:\\${kn}(?<code>\\d+)m|\\${re}(?<uri>.*)${ie})`).exec(s.slice(c).join(""))||{groups:{}};if(h.code!==void 0){let _=Number.parseFloat(h.code);o=_===Rr?void 0:_}else h.uri!==void 0&&($=h.uri.length===0?void 0:h.uri)}let w=lr.codes.get(Number(o));s[c+1]===`
14
- `?($&&(r+=pn("")),o&&w&&(r+=mn(w))):x===`
15
- `&&(o&&w&&(r+=mn(o)),$&&(r+=pn($)))}return r},jr,Gr=(t,e,i)=>(e in t)?jr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,z=(t,e,i)=>(Gr(t,typeof e!="symbol"?e+"":e,i),i),Mn,cn,Tr,oe,qr,Nr=(t,e,i)=>(e in t)?qr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,un=(t,e,i)=>(Nr(t,typeof e!="symbol"?e+"":e,i),i),$e,Jr,Xr=(t,e,i)=>(e in t)?Jr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,yn=(t,e,i)=>(Xr(t,typeof e!="symbol"?e+"":e,i),i),An,Qr,Or=(t,e,i)=>(e in t)?Qr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xn=(t,e,i)=>(Or(t,typeof e!="symbol"?e+"":e,i),i),me,Yr,Vr=(t,e,i)=>(e in t)?Yr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,wn=(t,e,i)=>(Vr(t,typeof e!="symbol"?e+"":e,i),i),jn,Zr,zr=(t,e,i)=>(e in t)?Zr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,_n=(t,e,i)=>(zr(t,typeof e!="symbol"?e+"":e,i),i),pe,dr,Wr=(t,e,i)=>(e in t)?dr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Kr=(t,e,i)=>(Wr(t,typeof e!="symbol"?e+"":e,i),i),se,Hr;var ce=Ht(()=>{X=lt(gt(),1),et=lt(te(),1);ur=cr();Rn={exports:{}};(function(t){var e={};t.exports=e,e.eastAsianWidth=function(r){var o=r.charCodeAt(0),$=r.length==2?r.charCodeAt(1):0,n=o;return 55296<=o&&o<=56319&&56320<=$&&$<=57343&&(o&=1023,$&=1023,n=o<<10|$,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),$=0,n=0;n<o.length;n++)$=$+this.characterLength(o[n]);return $},e.slice=function(r,o,$){textLen=e.length(r),o=o||0,$=$||1,o<0&&(o=textLen+o),$<0&&($=textLen+$);for(var n="",m=0,s=i(r),c=0;c<s.length;c++){var x=s[c],w=e.length(x);if(m>=o-(w==2?1:0))if(m+w<=$)n+=x;else break;m+=w}return n}})(Rn);yr=Rn.exports,xr=ln(yr),_r=ln(wr);T={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(T.modifier);hr=Object.keys(T.color),br=Object.keys(T.bgColor);[...hr,...br];lr=vr(),Xt=new Set(["\x1B","›"]),re=`${kr}8;;`;jr=Object.defineProperty;Mn=Symbol("clack:cancel");cn=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),Tr=new Set(["up","down","left","right","space","enter"]);oe=class oe extends g{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(X.cursor.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};qr=Object.defineProperty;$e=class $e extends g{constructor(t){super(t,!1),un(this,"options"),un(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]}}};Jr=Object.defineProperty,An=class extends g{constructor(t){super(t,!1),yn(this,"options"),yn(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]}},Qr=Object.defineProperty;me=class me extends g{constructor({mask:t,...e}){super(e),xn(this,"valueWithCursor",""),xn(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}${et.default.inverse(et.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${et.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Yr=Object.defineProperty,jn=class extends g{constructor(t){super(t,!1),wn(this,"options"),wn(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}},Zr=Object.defineProperty;pe=class pe extends g{constructor(t){super(t,!1),_n(this,"options"),_n(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"))})}};dr=Object.defineProperty;se=class se extends g{constructor(t){super(t),Kr(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}${et.default.inverse(et.default.hidden("_"))}`;else{let e=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${e}${et.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};Hr=globalThis.process.platform.startsWith("win")});var Yt={};je(Yt,{text:()=>to,spinner:()=>uo,selectKey:()=>ro,select:()=>io,password:()=>eo,outro:()=>co,note:()=>mo,multiselect:()=>oo,log:()=>nt,isCancel:()=>Qt,intro:()=>so,groupMultiselect:()=>$o,group:()=>xo,confirm:()=>no,cancel:()=>po});import K from"node:process";function Ur(){return K.platform!=="win32"?K.env.TERM!=="linux":Boolean(K.env.CI)||Boolean(K.env.WT_SESSION)||Boolean(K.env.TERMINUS_SUBLIME)||K.env.ConEmuTask==="{cmd::Cmder}"||K.env.TERM_PROGRAM==="Terminus-Sublime"||K.env.TERM_PROGRAM==="vscode"||K.env.TERM==="xterm-256color"||K.env.TERM==="alacritty"||K.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}function yo(){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 p,st,ye,q=(t,e)=>ye?t:e,ar,Tn,qn,Ot,Ir,b,O,xe,we,_e,ht,Nn,Pr,Bn,Cr,Lr,Er,fr,Fr,gr,Dr,it=(t)=>{switch(t){case"initial":case"active":return p.default.cyan(ar);case"cancel":return p.default.red(Tn);case"error":return p.default.yellow(qn);case"submit":return p.default.green(Ot)}},to=(t)=>new se({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let e=`${p.default.gray(b)}
16
- ${it(this.state)} ${t.message}
17
- `,i=t.placeholder?p.default.inverse(t.placeholder[0])+p.default.dim(t.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),r=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${e.trim()}
12
+ `)),this._prevFrame=t;return}this.output.write(X.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}}function Oe({input:t=je,output:n=Te,overwrite:i=!0,hideCursor:r=!0}={}){let o=L.createInterface({input:t,output:n,prompt:"",tabSize:1});L.emitKeypressEvents(t,o),t.isTTY&&t.setRawMode(!0);let m=(e,{name:$})=>{if(String(e)==="\x03"){r&&n.write(X.cursor.show),process.exit(0);return}if(!i)return;L.moveCursor(n,$==="return"?0:-1,$==="return"?-1:0,()=>{L.clearLine(n,1,()=>{t.once("keypress",m)})})};return r&&n.write(X.cursor.hide),t.once("keypress",m),()=>{t.off("keypress",m),r&&n.write(X.cursor.show),t.isTTY&&!eo&&t.setRawMode(!1),o.terminal=!1,o.close()}}var X,tt,Tr,Be,Gr,lr,Br=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},qr,cn=10,xe=(t=0)=>(n)=>`\x1B[${n+t}m`,ye=(t=0)=>(n)=>`\x1B[${38+t};5;${n}m`,_e=(t=0)=>(n,i,r)=>`\x1B[${38+t};2;${n};${i};${r}m`,l,Nr,Yr,Jr,Qt,Or=39,xn="\x07",qe="[",Qr="]",Ne="m",yn,we=(t)=>`${Qt.values().next().value}${qe}${t}${Ne}`,he=(t)=>`${Qt.values().next().value}${yn}${t}${xn}`,Zr=(t)=>t.split(" ").map((n)=>ht(n)),sn=(t,n,i)=>{let r=[...n],o=!1,m=!1,e=ht(Ge(t[t.length-1]));for(let[$,c]of r.entries()){let x=ht(c);if(e+x<=i?t[t.length-1]+=c:(t.push(c),e=0),Qt.has(c)&&(o=!0,m=r.slice($+1).join("").startsWith(yn)),o){m?c===xn&&(o=!1,m=!1):c===Ne&&(o=!1);continue}e+=x,e===i&&$<r.length-1&&(t.push(""),e=0)}!e&&t[t.length-1].length>0&&t.length>1&&(t[t.length-2]+=t.pop())},Vr=(t)=>{let n=t.split(" "),i=n.length;for(;i>0&&!(ht(n[i-1])>0);)i--;return i===n.length?t:n.slice(0,i).join(" ")+n.slice(i).join("")},zr=(t,n,i={})=>{if(i.trim!==!1&&t.trim()==="")return"";let r="",o,m,e=Zr(t),$=[""];for(let[x,y]of t.split(" ").entries()){i.trim!==!1&&($[$.length-1]=$[$.length-1].trimStart());let _=ht($[$.length-1]);if(x!==0&&(_>=n&&(i.wordWrap===!1||i.trim===!1)&&($.push(""),_=0),(_>0||i.trim===!1)&&($[$.length-1]+=" ",_++)),i.hard&&e[x]>n){let w=n-_,h=1+Math.floor((e[x]-w-1)/n);Math.floor((e[x]-1)/n)<h&&$.push(""),sn($,y,n);continue}if(_+e[x]>n&&_>0&&e[x]>0){if(i.wordWrap===!1&&_<n){sn($,y,n);continue}$.push("")}if(_+e[x]>n&&i.wordWrap===!1){sn($,y,n);continue}$[$.length-1]+=y}i.trim!==!1&&($=$.map((x)=>Vr(x)));let c=[...$.join(`
13
+ `)];for(let[x,y]of c.entries()){if(r+=y,Qt.has(y)){let{groups:w}=new RegExp(`(?:\\${qe}(?<code>\\d+)m|\\${yn}(?<uri>.*)${xn})`).exec(c.slice(x).join(""))||{groups:{}};if(w.code!==void 0){let h=Number.parseFloat(w.code);o=h===Or?void 0:h}else w.uri!==void 0&&(m=w.uri.length===0?void 0:w.uri)}let _=Jr.codes.get(Number(o));c[x+1]===`
14
+ `?(m&&(r+=he("")),o&&_&&(r+=we(_))):y===`
15
+ `&&(o&&_&&(r+=we(o)),m&&(r+=he(m)))}return r},Wr,dr=(t,n,i)=>(n in t)?Wr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,V=(t,n,i)=>(dr(t,typeof n!="symbol"?n+"":n,i),i),Ye,Se,ar,_n,Ur,Hr=(t,n,i)=>(n in t)?Ur(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Me=(t,n,i)=>(Hr(t,typeof n!="symbol"?n+"":n,i),i),wn,Ir,Pr=(t,n,i)=>(n in t)?Ir(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,ve=(t,n,i)=>(Pr(t,typeof n!="symbol"?n+"":n,i),i),Xe,Cr,Lr=(t,n,i)=>(n in t)?Cr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,ke=(t,n,i)=>(Lr(t,typeof n!="symbol"?n+"":n,i),i),hn,Er,fr=(t,n,i)=>(n in t)?Er(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Ae=(t,n,i)=>(fr(t,typeof n!="symbol"?n+"":n,i),i),Je,Fr,gr=(t,n,i)=>(n in t)?Fr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,Re=(t,n,i)=>(gr(t,typeof n!="symbol"?n+"":n,i),i),bn,Dr,to=(t,n,i)=>(n in t)?Dr(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,no=(t,n,i)=>(to(t,typeof n!="symbol"?n+"":n,i),i),Sn,eo;var Mn=ft(()=>{X=At($n(),1),tt=At(un(),1);Tr=jr();Be={exports:{}};(function(t){var n={};t.exports=n,n.eastAsianWidth=function(r){var o=r.charCodeAt(0),m=r.length==2?r.charCodeAt(1):0,e=o;return 55296<=o&&o<=56319&&56320<=m&&m<=57343&&(o&=1023,m&=1023,e=o<<10|m,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&e<=359||e==363||e==462||e==464||e==466||e==468||e==470||e==472||e==474||e==476||e==593||e==609||e==708||e==711||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},n.characterLength=function(r){var 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)||[]}n.length=function(r){for(var o=i(r),m=0,e=0;e<o.length;e++)m=m+this.characterLength(o[e]);return m},n.slice=function(r,o,m){textLen=n.length(r),o=o||0,m=m||1,o<0&&(o=textLen+o),m<0&&(m=textLen+m);for(var e="",$=0,c=i(r),x=0;x<c.length;x++){var y=c[x],_=n.length(y);if($>=o-(_==2?1:0))if($+_<=m)e+=y;else break;$+=_}return e}})(Be);Gr=Be.exports,lr=le(Gr),qr=le(Br);l={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(l.modifier);Nr=Object.keys(l.color),Yr=Object.keys(l.bgColor);[...Nr,...Yr];Jr=Xr(),Qt=new Set(["\x1B","›"]),yn=`${Qr}8;;`;Wr=Object.defineProperty;Ye=Symbol("clack:cancel");Se=new Map([["k","up"],["j","down"],["h","left"],["l","right"]]),ar=new Set(["up","down","left","right","space","enter"]);_n=class _n extends E{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(n)=>{this.output.write(X.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Ur=Object.defineProperty;wn=class wn extends E{constructor(t){super(t,!1),Me(this,"options"),Me(this,"cursor",0);let{options:n}=t;this.options=Object.entries(n).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((n)=>n.group===t)}isGroupSelected(t){return this.getGroupItems(t).every((n)=>this.value.includes(n.value))}toggleValue(){let t=this.options[this.cursor];if(t.group===!0){let n=t.value,i=this.getGroupItems(n);this.isGroupSelected(n)?this.value=this.value.filter((r)=>i.findIndex((o)=>o.value===r)===-1):this.value=[...this.value,...i.map((r)=>r.value)],this.value=Array.from(new Set(this.value))}else{let n=this.value.includes(t.value);this.value=n?this.value.filter((i)=>i!==t.value):[...this.value,t.value]}}};Ir=Object.defineProperty,Xe=class extends E{constructor(t){super(t,!1),ve(this,"options"),ve(this,"cursor",0),this.options=t.options,this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:n})=>n===t.cursorAt),0),this.on("key",(n)=>{n==="a"&&this.toggleAll()}),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let t=this.value.length===this.options.length;this.value=t?[]:this.options.map((n)=>n.value)}toggleValue(){let t=this.value.includes(this._value);this.value=t?this.value.filter((n)=>n!==this._value):[...this.value,this._value]}},Cr=Object.defineProperty;hn=class hn extends E{constructor({mask:t,...n}){super(n),ke(this,"valueWithCursor",""),ke(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}${tt.default.inverse(tt.default.hidden("_"))}`;else{let i=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${i}${tt.default.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Er=Object.defineProperty,Je=class extends E{constructor(t){super(t,!1),Ae(this,"options"),Ae(this,"cursor",0),this.options=t.options,this.cursor=this.options.findIndex(({value:n})=>n===t.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(n)=>{switch(n){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Fr=Object.defineProperty;bn=class bn extends E{constructor(t){super(t,!1),Re(this,"options"),Re(this,"cursor",0),this.options=t.options;let n=this.options.map(({value:[i]})=>i?.toLowerCase());this.cursor=Math.max(n.indexOf(t.initialValue),0),this.on("key",(i)=>{if(!n.includes(i))return;let r=this.options.find(({value:[o]})=>o?.toLowerCase()===i);r&&(this.value=r.value,this.state="submit",this.emit("submit"))})}};Dr=Object.defineProperty;Sn=class Sn extends E{constructor(t){super(t),no(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}${tt.default.inverse(tt.default.hidden("_"))}`;else{let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.valueWithCursor=`${n}${tt.default.inverse(i[0])}${i.slice(1)}`}})}get cursor(){return this._cursor}};eo=globalThis.process.platform.startsWith("win")});var zt={};On(zt,{text:()=>_o,spinner:()=>To,selectKey:()=>So,select:()=>bo,password:()=>wo,outro:()=>jo,note:()=>ko,multiselect:()=>Mo,log:()=>nt,isCancel:()=>Zt,intro:()=>Ro,groupMultiselect:()=>vo,group:()=>lo,confirm:()=>ho,cancel:()=>Ao});import d from"node:process";function io(){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 Go(){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 p,ut,kn,q=(t,n)=>kn?t:n,ro,Ze,Ve,Vt,oo,b,O,An,Rn,jn,bt,ze,mo,Qe,$o,po,uo,co,so,xo,yo,et=(t)=>{switch(t){case"initial":case"active":return p.default.cyan(ro);case"cancel":return p.default.red(Ze);case"error":return p.default.yellow(Ve);case"submit":return p.default.green(Vt)}},_o=(t)=>new Sn({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){let n=`${p.default.gray(b)}
16
+ ${et(this.state)} ${t.message}
17
+ `,i=t.placeholder?p.default.inverse(t.placeholder[0])+p.default.dim(t.placeholder.slice(1)):p.default.inverse(p.default.hidden("_")),r=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()}
18
18
  ${p.default.yellow(b)} ${r}
19
19
  ${p.default.yellow(O)} ${p.default.yellow(this.error)}
20
- `;case"submit":return`${e}${p.default.gray(b)} ${p.default.dim(this.value||t.placeholder)}`;case"cancel":return`${e}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
21
- `+p.default.gray(b):""}`;default:return`${e}${p.default.cyan(b)} ${r}
20
+ `;case"submit":return`${n}${p.default.gray(b)} ${p.default.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(this.value??""))}${this.value?.trim()?`
21
+ `+p.default.gray(b):""}`;default:return`${n}${p.default.cyan(b)} ${r}
22
22
  ${p.default.cyan(O)}
23
- `}}}).prompt(),eo=(t)=>new me({validate:t.validate,mask:t.mask??Pr,render(){let e=`${p.default.gray(b)}
24
- ${it(this.state)} ${t.message}
25
- `,i=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${e.trim()}
23
+ `}}}).prompt(),wo=(t)=>new hn({validate:t.validate,mask:t.mask??mo,render(){let n=`${p.default.gray(b)}
24
+ ${et(this.state)} ${t.message}
25
+ `,i=this.valueWithCursor,r=this.masked;switch(this.state){case"error":return`${n.trim()}
26
26
  ${p.default.yellow(b)} ${r}
27
27
  ${p.default.yellow(O)} ${p.default.yellow(this.error)}
28
- `;case"submit":return`${e}${p.default.gray(b)} ${p.default.dim(r)}`;case"cancel":return`${e}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(r??""))}${r?`
29
- `+p.default.gray(b):""}`;default:return`${e}${p.default.cyan(b)} ${i}
28
+ `;case"submit":return`${n}${p.default.gray(b)} ${p.default.dim(r)}`;case"cancel":return`${n}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(r??""))}${r?`
29
+ `+p.default.gray(b):""}`;default:return`${n}${p.default.cyan(b)} ${i}
30
30
  ${p.default.cyan(O)}
31
- `}}}).prompt(),no=(t)=>{let e=t.active??"Yes",i=t.inactive??"No";return new oe({active:e,inactive:i,initialValue:t.initialValue??!0,render(){let r=`${p.default.gray(b)}
32
- ${it(this.state)} ${t.message}
33
- `,o=this.value?e:i;switch(this.state){case"submit":return`${r}${p.default.gray(b)} ${p.default.dim(o)}`;case"cancel":return`${r}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(o))}
34
- ${p.default.gray(b)}`;default:return`${r}${p.default.cyan(b)} ${this.value?`${p.default.green(xe)} ${e}`:`${p.default.dim(we)} ${p.default.dim(e)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(we)} ${p.default.dim(i)}`:`${p.default.green(xe)} ${i}`}
31
+ `}}}).prompt(),ho=(t)=>{let n=t.active??"Yes",i=t.inactive??"No";return new _n({active:n,inactive:i,initialValue:t.initialValue??!0,render(){let r=`${p.default.gray(b)}
32
+ ${et(this.state)} ${t.message}
33
+ `,o=this.value?n:i;switch(this.state){case"submit":return`${r}${p.default.gray(b)} ${p.default.dim(o)}`;case"cancel":return`${r}${p.default.gray(b)} ${p.default.strikethrough(p.default.dim(o))}
34
+ ${p.default.gray(b)}`;default:return`${r}${p.default.cyan(b)} ${this.value?`${p.default.green(An)} ${n}`:`${p.default.dim(Rn)} ${p.default.dim(n)}`} ${p.default.dim("/")} ${this.value?`${p.default.dim(Rn)} ${p.default.dim(i)}`:`${p.default.green(An)} ${i}`}
35
35
  ${p.default.cyan(O)}
36
- `}}}).prompt()},io=(t)=>{let e=(r,o)=>{let $=r.label??String(r.value);return o==="active"?`${p.default.green(xe)} ${$} ${r.hint?p.default.dim(`(${r.hint})`):""}`:o==="selected"?`${p.default.dim($)}`:o==="cancelled"?`${p.default.strikethrough(p.default.dim($))}`:`${p.default.dim(we)} ${p.default.dim($)}`},i=0;return new jn({options:t.options,initialValue:t.initialValue,render(){let r=`${p.default.gray(b)}
37
- ${it(this.state)} ${t.message}
38
- `;switch(this.state){case"submit":return`${r}${p.default.gray(b)} ${e(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${p.default.gray(b)} ${e(this.options[this.cursor],"cancelled")}
39
- ${p.default.gray(b)}`;default:{let o=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+o-3?i=Math.max(Math.min(this.cursor-o+3,this.options.length-o),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));let $=o<this.options.length&&i>0,n=o<this.options.length&&i+o<this.options.length;return`${r}${p.default.cyan(b)} ${this.options.slice(i,i+o).map((m,s,c)=>s===0&&$?p.default.dim("..."):s===c.length-1&&n?p.default.dim("..."):e(m,s+i===this.cursor?"active":"inactive")).join(`
36
+ `}}}).prompt()},bo=(t)=>{let n=(r,o)=>{let m=r.label??String(r.value);return o==="active"?`${p.default.green(An)} ${m} ${r.hint?p.default.dim(`(${r.hint})`):""}`:o==="selected"?`${p.default.dim(m)}`:o==="cancelled"?`${p.default.strikethrough(p.default.dim(m))}`:`${p.default.dim(Rn)} ${p.default.dim(m)}`},i=0;return new Je({options:t.options,initialValue:t.initialValue,render(){let r=`${p.default.gray(b)}
37
+ ${et(this.state)} ${t.message}
38
+ `;switch(this.state){case"submit":return`${r}${p.default.gray(b)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${r}${p.default.gray(b)} ${n(this.options[this.cursor],"cancelled")}
39
+ ${p.default.gray(b)}`;default:{let o=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+o-3?i=Math.max(Math.min(this.cursor-o+3,this.options.length-o),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));let m=o<this.options.length&&i>0,e=o<this.options.length&&i+o<this.options.length;return`${r}${p.default.cyan(b)} ${this.options.slice(i,i+o).map(($,c,x)=>c===0&&m?p.default.dim("..."):c===x.length-1&&e?p.default.dim("..."):n($,c+i===this.cursor?"active":"inactive")).join(`
40
40
  ${p.default.cyan(b)} `)}
41
41
  ${p.default.cyan(O)}
42
- `}}}}).prompt()},ro=(t)=>{let e=(i,r="inactive")=>{let o=i.label??String(i.value);return r==="selected"?`${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active"?`${p.default.bgCyan(p.default.gray(` ${i.value} `))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:`${p.default.gray(p.default.bgWhite(p.default.inverse(` ${i.value} `)))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`};return new pe({options:t.options,initialValue:t.initialValue,render(){let i=`${p.default.gray(b)}
43
- ${it(this.state)} ${t.message}
44
- `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${e(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${i}${p.default.gray(b)} ${e(this.options[0],"cancelled")}
45
- ${p.default.gray(b)}`;default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o)=>e(r,o===this.cursor?"active":"inactive")).join(`
42
+ `}}}}).prompt()},So=(t)=>{let n=(i,r="inactive")=>{let o=i.label??String(i.value);return r==="selected"?`${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active"?`${p.default.bgCyan(p.default.gray(` ${i.value} `))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:`${p.default.gray(p.default.bgWhite(p.default.inverse(` ${i.value} `)))} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`};return new bn({options:t.options,initialValue:t.initialValue,render(){let i=`${p.default.gray(b)}
43
+ ${et(this.state)} ${t.message}
44
+ `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${n(this.options.find((r)=>r.value===this.value),"selected")}`;case"cancel":return`${i}${p.default.gray(b)} ${n(this.options[0],"cancelled")}
45
+ ${p.default.gray(b)}`;default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o)=>n(r,o===this.cursor?"active":"inactive")).join(`
46
46
  ${p.default.cyan(b)} `)}
47
47
  ${p.default.cyan(O)}
48
- `}}}).prompt()},oo=(t)=>{let e=(i,r)=>{let o=i.label??String(i.value);return r==="active"?`${p.default.cyan(_e)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="selected"?`${p.default.green(ht)} ${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active-selected"?`${p.default.green(ht)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(o)}`:`${p.default.dim(Nn)} ${p.default.dim(o)}`};return new An({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
48
+ `}}}).prompt()},Mo=(t)=>{let n=(i,r)=>{let o=i.label??String(i.value);return r==="active"?`${p.default.cyan(jn)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="selected"?`${p.default.green(bt)} ${p.default.dim(o)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(o))}`:r==="active-selected"?`${p.default.green(bt)} ${o} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(o)}`:`${p.default.dim(ze)} ${p.default.dim(o)}`};return new Xe({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
49
49
  ${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(b)}
50
- ${it(this.state)} ${t.message}
51
- `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(b)} ${r.trim()?`${r}
50
+ ${et(this.state)} ${t.message}
51
+ `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"submitted")).join(p.default.dim(", "))||p.default.dim("none")}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>n(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(b)} ${r.trim()?`${r}
52
52
  ${p.default.gray(b)}`:""}`}case"error":{let r=this.error.split(`
53
- `).map((o,$)=>$===0?`${p.default.yellow(O)} ${p.default.yellow(o)}`:` ${o}`).join(`
54
- `);return i+p.default.yellow(b)+" "+this.options.map((o,$)=>{let n=this.value.includes(o.value),m=$===this.cursor;return m&&n?e(o,"active-selected"):n?e(o,"selected"):e(o,m?"active":"inactive")}).join(`
53
+ `).map((o,m)=>m===0?`${p.default.yellow(O)} ${p.default.yellow(o)}`:` ${o}`).join(`
54
+ `);return i+p.default.yellow(b)+" "+this.options.map((o,m)=>{let e=this.value.includes(o.value),$=m===this.cursor;return $&&e?n(o,"active-selected"):e?n(o,"selected"):n(o,$?"active":"inactive")}).join(`
55
55
  ${p.default.yellow(b)} `)+`
56
56
  `+r+`
57
- `}default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o)=>{let $=this.value.includes(r.value),n=o===this.cursor;return n&&$?e(r,"active-selected"):$?e(r,"selected"):e(r,n?"active":"inactive")}).join(`
57
+ `}default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o)=>{let m=this.value.includes(r.value),e=o===this.cursor;return e&&m?n(r,"active-selected"):m?n(r,"selected"):n(r,e?"active":"inactive")}).join(`
58
58
  ${p.default.cyan(b)} `)}
59
59
  ${p.default.cyan(O)}
60
- `}}}).prompt()},$o=(t)=>{let e=(i,r,o=[])=>{let $=i.label??String(i.value),n=typeof i.group=="string",m=n&&(o[o.indexOf(i)+1]??{group:!0}),s=n&&m.group===!0,c=n?`${s?O:b} `:"";return r==="active"?`${p.default.dim(c)}${p.default.cyan(_e)} ${$} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="group-active"?`${c}${p.default.cyan(_e)} ${p.default.dim($)}`:r==="group-active-selected"?`${c}${p.default.green(ht)} ${p.default.dim($)}`:r==="selected"?`${p.default.dim(c)}${p.default.green(ht)} ${p.default.dim($)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim($))}`:r==="active-selected"?`${p.default.dim(c)}${p.default.green(ht)} ${$} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim($)}`:`${p.default.dim(c)}${p.default.dim(Nn)} ${p.default.dim($)}`};return new $e({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
60
+ `}}}).prompt()},vo=(t)=>{let n=(i,r,o=[])=>{let m=i.label??String(i.value),e=typeof i.group=="string",$=e&&(o[o.indexOf(i)+1]??{group:!0}),c=e&&$.group===!0,x=e?`${c?O:b} `:"";return r==="active"?`${p.default.dim(x)}${p.default.cyan(jn)} ${m} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="group-active"?`${x}${p.default.cyan(jn)} ${p.default.dim(m)}`:r==="group-active-selected"?`${x}${p.default.green(bt)} ${p.default.dim(m)}`:r==="selected"?`${p.default.dim(x)}${p.default.green(bt)} ${p.default.dim(m)}`:r==="cancelled"?`${p.default.strikethrough(p.default.dim(m))}`:r==="active-selected"?`${p.default.dim(x)}${p.default.green(bt)} ${m} ${i.hint?p.default.dim(`(${i.hint})`):""}`:r==="submitted"?`${p.default.dim(m)}`:`${p.default.dim(x)}${p.default.dim(ze)} ${p.default.dim(m)}`};return new wn({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
61
61
  ${p.default.reset(p.default.dim(`Press ${p.default.gray(p.default.bgWhite(p.default.inverse(" space ")))} to select, ${p.default.gray(p.default.bgWhite(p.default.inverse(" enter ")))} to submit`))}`},render(){let i=`${p.default.gray(b)}
62
- ${it(this.state)} ${t.message}
63
- `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>e(r,"submitted")).join(p.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>e(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(b)} ${r.trim()?`${r}
62
+ ${et(this.state)} ${t.message}
63
+ `;switch(this.state){case"submit":return`${i}${p.default.gray(b)} ${this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>n(r,"submitted")).join(p.default.dim(", "))}`;case"cancel":{let r=this.options.filter(({value:o})=>this.value.includes(o)).map((o)=>n(o,"cancelled")).join(p.default.dim(", "));return`${i}${p.default.gray(b)} ${r.trim()?`${r}
64
64
  ${p.default.gray(b)}`:""}`}case"error":{let r=this.error.split(`
65
- `).map((o,$)=>$===0?`${p.default.yellow(O)} ${p.default.yellow(o)}`:` ${o}`).join(`
66
- `);return`${i}${p.default.yellow(b)} ${this.options.map((o,$,n)=>{let m=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),s=$===this.cursor;return!s&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?e(o,m?"group-active-selected":"group-active",n):s&&m?e(o,"active-selected",n):m?e(o,"selected",n):e(o,s?"active":"inactive",n)}).join(`
65
+ `).map((o,m)=>m===0?`${p.default.yellow(O)} ${p.default.yellow(o)}`:` ${o}`).join(`
66
+ `);return`${i}${p.default.yellow(b)} ${this.options.map((o,m,e)=>{let $=this.value.includes(o.value)||o.group===!0&&this.isGroupSelected(`${o.value}`),c=m===this.cursor;return!c&&typeof o.group=="string"&&this.options[this.cursor].value===o.group?n(o,$?"group-active-selected":"group-active",e):c&&$?n(o,"active-selected",e):$?n(o,"selected",e):n(o,c?"active":"inactive",e)}).join(`
67
67
  ${p.default.yellow(b)} `)}
68
68
  ${r}
69
- `}default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o,$)=>{let n=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),m=o===this.cursor;return!m&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?e(r,n?"group-active-selected":"group-active",$):m&&n?e(r,"active-selected",$):n?e(r,"selected",$):e(r,m?"active":"inactive",$)}).join(`
69
+ `}default:return`${i}${p.default.cyan(b)} ${this.options.map((r,o,m)=>{let e=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),$=o===this.cursor;return!$&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,e?"group-active-selected":"group-active",m):$&&e?n(r,"active-selected",m):e?n(r,"selected",m):n(r,$?"active":"inactive",m)}).join(`
70
70
  ${p.default.cyan(b)} `)}
71
71
  ${p.default.cyan(O)}
72
- `}}}).prompt()},ue=(t)=>t.replace(yo(),""),mo=(t="",e="")=>{let i=`
72
+ `}}}).prompt()},vn=(t)=>t.replace(Go(),""),ko=(t="",n="")=>{let i=`
73
73
  ${t}
74
74
  `.split(`
75
- `),r=ue(e).length,o=Math.max(i.reduce((n,m)=>(m=ue(m),m.length>n?m.length:n),0),r)+2,$=i.map((n)=>`${p.default.gray(b)} ${p.default.dim(n)}${" ".repeat(o-ue(n).length)}${p.default.gray(b)}`).join(`
75
+ `),r=vn(n).length,o=Math.max(i.reduce((e,$)=>($=vn($),$.length>e?$.length:e),0),r)+2,m=i.map((e)=>`${p.default.gray(b)} ${p.default.dim(e)}${" ".repeat(o-vn(e).length)}${p.default.gray(b)}`).join(`
76
76
  `);process.stdout.write(`${p.default.gray(b)}
77
- ${p.default.green(Ot)} ${p.default.reset(e)} ${p.default.gray(Bn.repeat(Math.max(o-r-1,1))+Cr)}
78
- ${$}
79
- ${p.default.gray(Lr+Bn.repeat(o+2)+Er)}
80
- `)},po=(t="")=>{process.stdout.write(`${p.default.gray(O)} ${p.default.red(t)}
77
+ ${p.default.green(Vt)} ${p.default.reset(n)} ${p.default.gray(Qe.repeat(Math.max(o-r-1,1))+$o)}
78
+ ${m}
79
+ ${p.default.gray(po+Qe.repeat(o+2)+uo)}
80
+ `)},Ao=(t="")=>{process.stdout.write(`${p.default.gray(O)} ${p.default.red(t)}
81
81
 
82
- `)},so=(t="")=>{process.stdout.write(`${p.default.gray(Ir)} ${t}
83
- `)},co=(t="")=>{process.stdout.write(`${p.default.gray(b)}
82
+ `)},Ro=(t="")=>{process.stdout.write(`${p.default.gray(oo)} ${t}
83
+ `)},jo=(t="")=>{process.stdout.write(`${p.default.gray(b)}
84
84
  ${p.default.gray(O)} ${t}
85
85
 
86
- `)},nt,uo=()=>{let t=ye?["◒","◐","◓","◑"]:["•","o","O","0"],e=ye?80:120,i,r,o=!1,$="",n=(x="")=>{o=!0,i=Gn(),$=x.replace(/\.+$/,""),process.stdout.write(`${p.default.gray(b)}
87
- `);let w=0,h=0;r=setInterval(()=>{let _=p.default.magenta(t[w]),R=".".repeat(Math.floor(h)).slice(0,3);process.stdout.write(st.cursor.move(-999,0)),process.stdout.write(st.erase.down(1)),process.stdout.write(`${_} ${$}${R}`),w=w+1<t.length?w+1:0,h=h<t.length?h+0.125:0},e)},m=(x="",w=0)=>{$=x??$,o=!1,clearInterval(r);let h=w===0?p.default.green(Ot):w===1?p.default.red(Tn):p.default.red(qn);process.stdout.write(st.cursor.move(-999,0)),process.stdout.write(st.erase.down(1)),process.stdout.write(`${h} ${$}
88
- `),i()},s=(x="")=>{$=x??$},c=(x)=>{let w=x>1?"Something went wrong":"Canceled";o&&m(w,x)};return process.on("uncaughtExceptionMonitor",()=>c(2)),process.on("unhandledRejection",()=>c(2)),process.on("SIGINT",()=>c(1)),process.on("SIGTERM",()=>c(1)),process.on("exit",c),{start:n,stop:m,message:s}},xo=async(t,e)=>{let i={},r=Object.keys(t);for(let o of r){let $=t[o],n=await $({results:i})?.catch((m)=>{throw m});if(typeof e?.onCancel=="function"&&Qt(n)){i[o]="canceled",e.onCancel({results:i});continue}i[o]=n}return i};var Vt=Ht(()=>{ce();ce();p=lt(te(),1),st=lt(gt(),1);ye=Ur(),ar=q("◆","*"),Tn=q("■","x"),qn=q("▲","x"),Ot=q("◇","o"),Ir=q("┌","T"),b=q("│","|"),O=q("└","—"),xe=q("●",">"),we=q("○"," "),_e=q("◻","[•]"),ht=q("◼","[+]"),Nn=q("◻","[ ]"),Pr=q("▪","•"),Bn=q("─","-"),Cr=q("╮","+"),Lr=q("├","+"),Er=q("╯","+"),fr=q("●","•"),Fr=q("◆","*"),gr=q("▲","!"),Dr=q("■","x"),nt={message:(t="",{symbol:e=p.default.gray(b)}={})=>{let i=[`${p.default.gray(b)}`];if(t){let[r,...o]=t.split(`
89
- `);i.push(`${e} ${r}`,...o.map(($)=>`${p.default.gray(b)} ${$}`))}process.stdout.write(`${i.join(`
86
+ `)},nt,To=()=>{let t=kn?["◒","◐","◓","◑"]:["•","o","O","0"],n=kn?80:120,i,r,o=!1,m="",e=(y="")=>{o=!0,i=Oe(),m=y.replace(/\.+$/,""),process.stdout.write(`${p.default.gray(b)}
87
+ `);let _=0,w=0;r=setInterval(()=>{let h=p.default.magenta(t[_]),S=".".repeat(Math.floor(w)).slice(0,3);process.stdout.write(ut.cursor.move(-999,0)),process.stdout.write(ut.erase.down(1)),process.stdout.write(`${h} ${m}${S}`),_=_+1<t.length?_+1:0,w=w<t.length?w+0.125:0},n)},$=(y="",_=0)=>{m=y??m,o=!1,clearInterval(r);let w=_===0?p.default.green(Vt):_===1?p.default.red(Ze):p.default.red(Ve);process.stdout.write(ut.cursor.move(-999,0)),process.stdout.write(ut.erase.down(1)),process.stdout.write(`${w} ${m}
88
+ `),i()},c=(y="")=>{m=y??m},x=(y)=>{let _=y>1?"Something went wrong":"Canceled";o&&$(_,y)};return process.on("uncaughtExceptionMonitor",()=>x(2)),process.on("unhandledRejection",()=>x(2)),process.on("SIGINT",()=>x(1)),process.on("SIGTERM",()=>x(1)),process.on("exit",x),{start:e,stop:$,message:c}},lo=async(t,n)=>{let i={},r=Object.keys(t);for(let o of r){let m=t[o],e=await m({results:i})?.catch(($)=>{throw $});if(typeof n?.onCancel=="function"&&Zt(e)){i[o]="canceled",n.onCancel({results:i});continue}i[o]=e}return i};var Wt=ft(()=>{Mn();Mn();p=At(un(),1),ut=At($n(),1);kn=io(),ro=q("◆","*"),Ze=q("■","x"),Ve=q("▲","x"),Vt=q("◇","o"),oo=q("┌","T"),b=q("│","|"),O=q("└","—"),An=q("●",">"),Rn=q("○"," "),jn=q("◻","[•]"),bt=q("◼","[+]"),ze=q("◻","[ ]"),mo=q("▪","•"),Qe=q("─","-"),$o=q("╮","+"),po=q("├","+"),uo=q("╯","+"),co=q("●","•"),so=q("◆","*"),xo=q("▲","!"),yo=q("■","x"),nt={message:(t="",{symbol:n=p.default.gray(b)}={})=>{let i=[`${p.default.gray(b)}`];if(t){let[r,...o]=t.split(`
89
+ `);i.push(`${n} ${r}`,...o.map((m)=>`${p.default.gray(b)} ${m}`))}process.stdout.write(`${i.join(`
90
90
  `)}
91
- `)},info:(t)=>{nt.message(t,{symbol:p.default.blue(fr)})},success:(t)=>{nt.message(t,{symbol:p.default.green(Fr)})},step:(t)=>{nt.message(t,{symbol:p.default.green(Ot)})},warn:(t)=>{nt.message(t,{symbol:p.default.yellow(gr)})},warning:(t)=>{nt.warn(t)},error:(t)=>{nt.message(t,{symbol:p.default.red(Dr)})}}});var zn={};je(zn,{readTextFromPathOrStdin:()=>bt});import{readFileSync as bo}from"fs";function bt(t){return bo(t==="-"?"/dev/stdin":t,"utf-8")}var zt=()=>{};function Ut(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}function Ti(t){let e=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return e?Ut(e[1]):null}function qi(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function Ge(t){let e=new Set,i=new Set,r=new Set;for(let o of t){let $=Ti(o);if(!$)continue;if(qi(o))e.add($);else if(o.type==="number")i.add($);else if(o.type==="array")r.add($)}return{booleans:e,numbers:i,arrays:r}}function Be(t,e=[]){let i=Ge(e),r=[],o=0;while(o<t.length){let $=t[o];if($==="--")break;if($.startsWith("--")){let n=$.indexOf("="),m=n!==-1?$.slice(2,n):$.slice(2),s=Ut(m);if(!i.booleans.has(s)&&n===-1)o+=2;else o+=1;continue}if($.startsWith("-")){o++;continue}r.push($),o++}return r}function at(t,e){let i=Ge(e),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<t.length){let $=t[o];if($==="--help"||$==="-h"){r.help=!0,o++;continue}if($==="--")break;if($.startsWith("--")){let n=$.indexOf("="),m,s;if(n!==-1)m=$.slice(2,n),s=$.slice(n+1);else m=$.slice(2);let c=Ut(m);if(i.booleans.has(c)){r[c]=!0,o++;continue}if(s===void 0)o++,s=t[o];if(s===void 0)throw Error(`Flag --${m} requires a value.`);if(i.arrays.has(c)){let x=r[c];if(x)x.push(s);else r[c]=[s]}else if(i.numbers.has(c))r[c]=Number(s);else r[c]=s}o++}return r}var u={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class y extends Error{exitCode;hint;constructor(t,e=u.GENERAL,i){super(t);this.name="CLIError",this.exitCode=e,this.hint=i}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}var C={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},xt={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Ni=new Set(["global","cn"]),Ji=new Set(["text","json"]);function Te(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let e=t,i={};if(typeof e.api_key==="string")i.api_key=e.api_key;if(typeof e.region==="string"&&Ni.has(e.region))i.region=e.region;if(typeof e.base_url==="string"&&e.base_url.startsWith("http"))i.base_url=e.base_url;if(typeof e.output==="string"&&Ji.has(e.output))i.output=e.output;if(typeof e.timeout==="number"&&e.timeout>0)i.timeout=e.timeout;if(typeof e.default_text_model==="string"&&e.default_text_model.length>0)i.default_text_model=e.default_text_model;if(typeof e.default_speech_model==="string"&&e.default_speech_model.length>0)i.default_speech_model=e.default_speech_model;if(typeof e.default_video_model==="string"&&e.default_video_model.length>0)i.default_video_model=e.default_video_model;if(typeof e.default_music_model==="string"&&e.default_music_model.length>0)i.default_music_model=e.default_music_model;return i}function l(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var Rt=[{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{readFileSync as Oi,writeFileSync as Yi,renameSync as Vi,unlinkSync as Zi,existsSync as qe,statSync as zi}from"fs";import{homedir as Xi}from"os";import{join as It}from"path";var Qi=".mmx";function wt(){return It(Xi(),Qi)}function L(){return It(wt(),"config.json")}function kt(){return It(wt(),"credentials.json")}async function St(){let t=wt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}async function d(){let t=kt();if(!qe(t))return null;try{di(t);let e=Oi(t,"utf-8"),i=JSON.parse(e);if(!i.access_token||!i.refresh_token)return null;return i}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: credentials file is corrupted. Run 'mmx auth logout' to reset.
92
- `);return null}}async function mt(t){await St();let e=kt(),i=e+".tmp";Yi(i,JSON.stringify(t,null,2)+`
93
- `,{mode:384}),Vi(i,e)}async function Ne(){let t=kt();if(qe(t))Zi(t)}function di(t){try{let i=zi(t).mode&511;if(i!==384)process.stderr.write(`Warning: ${t} has permissions ${i.toString(8)}, expected 600.
94
- `)}catch{}}var Je={clientId:"mmx-cli",authorizationUrl:"https://platform.minimax.io/oauth/authorize",tokenUrl:"https://api.minimax.io/v1/oauth/token",deviceCodeUrl:"https://api.minimax.io/v1/oauth/device/code",scopes:["api"],callbackPort:18991};async function Xe(t=Je){let{randomBytes:e,createHash:i}=await import("crypto"),r=e(32).toString("base64url"),o=i("sha256").update(r).digest("base64url"),$=e(16).toString("hex"),n=new URLSearchParams({client_id:t.clientId,response_type:"code",redirect_uri:`http://localhost:${t.callbackPort}/callback`,scope:t.scopes.join(" "),state:$,code_challenge:o,code_challenge_method:"S256"}),m=`${t.authorizationUrl}?${n}`,{execFile:s,spawn:c}=await import("child_process"),x=process.platform;if(x==="darwin")s("open",[m]);else if(x==="win32")c("cmd.exe",["/c","start","",m],{shell:!1,detached:!0});else s("xdg-open",[m]);process.stderr.write(`Opening browser to authenticate with MiniMax...
95
- `);let w=await Wi(t.callbackPort,$),h=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:w,client_id:t.clientId,redirect_uri:`http://localhost:${t.callbackPort}/callback`,code_verifier:r})});if(!h.ok){let _=await h.text();throw new y(`OAuth token exchange failed: ${_}`,u.AUTH)}return await h.json()}async function Wi(t,e){return new Promise((i,r)=>{let o=setTimeout(()=>{$.stop(),r(new y("OAuth callback timed out.",u.TIMEOUT))},120000),$=Bun.serve({port:t,fetch(n){let m=new URL(n.url);if(m.pathname!=="/callback")return new Response("Not found",{status:404});let s=m.searchParams.get("code"),c=m.searchParams.get("state"),x=m.searchParams.get("error");if(x)return clearTimeout(o),$.stop(),r(new y(`OAuth error: ${x}`,u.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!s||c!==e)return clearTimeout(o),$.stop(),r(new y("Invalid OAuth callback.",u.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),$.stop(),i(s),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function Qe(t=Je){let e=await fetch(t.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t.clientId,scope:t.scopes.join(" ")})});if(!e.ok)throw new y("Failed to start device code flow.",u.AUTH);let{device_code:i,user_code:r,verification_uri:o,interval:$,expires_in:n}=await e.json();process.stderr.write(`
91
+ `)},info:(t)=>{nt.message(t,{symbol:p.default.blue(co)})},success:(t)=>{nt.message(t,{symbol:p.default.green(so)})},step:(t)=>{nt.message(t,{symbol:p.default.green(Vt)})},warn:(t)=>{nt.message(t,{symbol:p.default.yellow(xo)})},warning:(t)=>{nt.warn(t)},error:(t)=>{nt.message(t,{symbol:p.default.red(yo)})}}});var Pe={};On(Pe,{readTextFromPathOrStdin:()=>St});import{readFileSync as Yo}from"fs";function St(t){return Yo(t==="-"?"/dev/stdin":t,"utf-8")}var at=()=>{};function Ft(t){return t.replace(/-([a-z])/g,(n,i)=>i.toUpperCase())}function ai(t){let n=t.flag.match(/^--([a-z][a-z0-9-]*)/i);return n?Ft(n[1]):null}function Ui(t){if(t.type==="boolean")return!0;if(t.type==="string"||t.type==="number"||t.type==="array")return!1;return!t.flag.includes("<")&&!t.flag.includes("[")}function Qn(t){let n=new Set,i=new Set,r=new Set;for(let o of t){let m=ai(o);if(!m)continue;if(Ui(o))n.add(m);else if(o.type==="number")i.add(m);else if(o.type==="array")r.add(m)}return{booleans:n,numbers:i,arrays:r}}function Zn(t,n=[]){let i=Qn(n),r=[],o=0;while(o<t.length){let m=t[o];if(m==="--")break;if(m.startsWith("--")){let e=m.indexOf("="),$=e!==-1?m.slice(2,e):m.slice(2),c=Ft($);if(!i.booleans.has(c)&&e===-1)o+=2;else o+=1;continue}if(m.startsWith("-")){o++;continue}r.push(m),o++}return r}function gt(t,n){let i=Qn(n),r={quiet:!1,verbose:!1,noColor:!1,yes:!1,dryRun:!1,help:!1,nonInteractive:!1,async:!1},o=0;while(o<t.length){let m=t[o];if(m==="--help"||m==="-h"){r.help=!0,o++;continue}if(m==="--")break;if(m.startsWith("--")){let e=m.indexOf("="),$,c;if(e!==-1)$=m.slice(2,e),c=m.slice(e+1);else $=m.slice(2);let x=Ft($);if(i.booleans.has(x)){r[x]=!0,o++;continue}if(c===void 0)o++,c=t[o];if(c===void 0)throw Error(`Flag --${$} requires a value.`);if(i.arrays.has(x)){let y=r[x];if(y)y.push(c);else r[x]=[c]}else if(i.numbers.has(x)){let y=Number(c);if(c.trim()===""||!Number.isFinite(y))throw Error(`Flag --${$} requires a numeric value, got "${c}".`);r[x]=y}else r[x]=c}o++}return r}var u={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONTENT_FILTER:10};class s extends Error{exitCode;hint;constructor(t,n=u.GENERAL,i){super(t);this.name="CLIError",this.exitCode=n,this.hint=i}toJSON(){return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{}}}}}var H={global:"https://api.minimax.io",cn:"https://api.minimaxi.com"},_t={global:"https://platform.minimax.io",cn:"https://platform.minimaxi.com"},Hi=new Set(["global","cn"]),Ii=new Set(["text","json"]);function Vn(t){if(!t||typeof t!=="object"||Array.isArray(t))return{};let n=t,i={};if(typeof n.api_key==="string")i.api_key=n.api_key;if(typeof n.region==="string"&&Hi.has(n.region))i.region=n.region;if(typeof n.base_url==="string"&&n.base_url.startsWith("http"))i.base_url=n.base_url;if(typeof n.output==="string"&&Ii.has(n.output))i.output=n.output;if(typeof n.timeout==="number"&&n.timeout>0)i.timeout=n.timeout;if(typeof n.proxy==="string"&&n.proxy.startsWith("http"))i.proxy=n.proxy;if(typeof n.default_text_model==="string"&&n.default_text_model.length>0)i.default_text_model=n.default_text_model;if(typeof n.default_speech_model==="string"&&n.default_speech_model.length>0)i.default_speech_model=n.default_speech_model;if(typeof n.default_video_model==="string"&&n.default_video_model.length>0)i.default_video_model=n.default_video_model;if(typeof n.default_music_model==="string"&&n.default_music_model.length>0)i.default_music_model=n.default_music_model;return i}function v(t){return{name:t.name,description:t.description,usage:t.usage,options:t.options,examples:t.examples,apiDocs:t.apiDocs,execute:t.run}}var Rt=[{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{readFileSync as Li,writeFileSync as Ei,renameSync as fi,unlinkSync as Fi,existsSync as zn,statSync as gi}from"fs";import{homedir as Pi}from"os";import{join as Dt}from"path";var Ci=".mmx";function wt(){return Dt(Pi(),Ci)}function I(){return Dt(wt(),"config.json")}function jt(){return Dt(wt(),"credentials.json")}async function Tt(){let t=wt();await(await import("fs/promises")).mkdir(t,{recursive:!0,mode:448})}async function z(){let t=jt();if(!zn(t))return null;try{Di(t);let n=Li(t,"utf-8"),i=JSON.parse(n);if(!i.access_token||!i.refresh_token)return null;return i}catch(n){let i=n;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: credentials file is corrupted. Run 'mmx auth logout' to reset.
92
+ `);return null}}async function $t(t){await Tt();let n=jt(),i=n+".tmp";Ei(i,JSON.stringify(t,null,2)+`
93
+ `,{mode:384}),fi(i,n)}async function Wn(){let t=jt();if(zn(t))Fi(t)}function Di(t){try{let i=gi(t).mode&511;if(i!==384)process.stderr.write(`Warning: ${t} has permissions ${i.toString(8)}, expected 600.
94
+ `)}catch{}}var dn={clientId:"mmx-cli",authorizationUrl:"https://platform.minimax.io/oauth/authorize",tokenUrl:"https://api.minimax.io/v1/oauth/token",deviceCodeUrl:"https://api.minimax.io/v1/oauth/device/code",scopes:["api"],callbackPort:18991};async function Kn(t=dn){let{randomBytes:n,createHash:i}=await import("crypto"),r=n(32).toString("base64url"),o=i("sha256").update(r).digest("base64url"),m=n(16).toString("hex"),e=new URLSearchParams({client_id:t.clientId,response_type:"code",redirect_uri:`http://localhost:${t.callbackPort}/callback`,scope:t.scopes.join(" "),state:m,code_challenge:o,code_challenge_method:"S256"}),$=`${t.authorizationUrl}?${e}`,{execFile:c,spawn:x}=await import("child_process"),y=process.platform;if(y==="darwin")c("open",[$]);else if(y==="win32")x("cmd.exe",["/c","start","",$],{shell:!1,detached:!0});else c("xdg-open",[$]);process.stderr.write(`Opening browser to authenticate with MiniMax...
95
+ `);let _=await tr(t.callbackPort,m),w=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:_,client_id:t.clientId,redirect_uri:`http://localhost:${t.callbackPort}/callback`,code_verifier:r})});if(!w.ok){let h=await w.text();throw new s(`OAuth token exchange failed: ${h}`,u.AUTH)}return await w.json()}async function tr(t,n){return new Promise((i,r)=>{let o=setTimeout(()=>{m.stop(),r(new s("OAuth callback timed out.",u.TIMEOUT))},120000),m=Bun.serve({port:t,fetch(e){let $=new URL(e.url);if($.pathname!=="/callback")return new Response("Not found",{status:404});let c=$.searchParams.get("code"),x=$.searchParams.get("state"),y=$.searchParams.get("error");if(y)return clearTimeout(o),m.stop(),r(new s(`OAuth error: ${y}`,u.AUTH)),new Response("<html><body><h1>Authentication Failed</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}});if(!c||x!==n)return clearTimeout(o),m.stop(),r(new s("Invalid OAuth callback.",u.AUTH)),new Response("Invalid callback",{status:400});return clearTimeout(o),m.stop(),i(c),new Response("<html><body><h1>Authentication Successful</h1><p>You can close this tab.</p></body></html>",{headers:{"Content-Type":"text/html"}})}})})}async function an(t=dn){let n=await fetch(t.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t.clientId,scope:t.scopes.join(" ")})});if(!n.ok)throw new s("Failed to start device code flow.",u.AUTH);let{device_code:i,user_code:r,verification_uri:o,interval:m,expires_in:e}=await n.json();process.stderr.write(`
96
96
  Visit: ${o}
97
97
  `),process.stderr.write(`Enter code: ${r}
98
98
  `),process.stderr.write(`Waiting for authorization...
99
- `);let m=Date.now()+n*1000,s=($||5)*1000;while(Date.now()<m){await new Promise((w)=>setTimeout(w,s));let c=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:i,client_id:t.clientId})});if(c.ok)return await c.json();let x=await c.json();if(x.error==="authorization_pending")continue;if(x.error==="slow_down"){await new Promise((w)=>setTimeout(w,5000));continue}throw new y(`Device code authorization failed: ${x.error}`,u.AUTH)}throw new y("Device code authorization timed out.",u.TIMEOUT)}var Ki="https://api.minimax.io/v1/oauth/token",Oe=2,Hi=500;async function Pt(t){let e=null;for(let i=0;i<=Oe;i++){if(i>0)await new Promise(($)=>setTimeout($,Hi*i));let r;try{r=await fetch(Ki,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t}),signal:AbortSignal.timeout(1e4)})}catch($){let n=$ instanceof Error&&($.name==="AbortError"||$.name==="TimeoutError"||$.message.includes("timed out"));e=Error(n?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${$ instanceof Error?$.message:String($)}`);continue}if(!r.ok){if(r.status>=400&&r.status<500)throw new y("OAuth session expired and could not be refreshed.",u.AUTH,"Re-authenticate: mmx auth login");e=Error(`Token refresh failed: HTTP ${r.status}`);continue}return await r.json()}throw new y(`Token refresh failed after ${Oe+1} attempts: ${e?.message}`,u.AUTH,`Check your network connection.
100
- Re-authenticate: mmx auth login`)}async function Ye(t){let e=new Date(t.expires_at).getTime(),i=300000;if(Date.now()<e-300000)return t.access_token;let r=await Pt(t.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:t.account};return await mt(o),o.access_token}async function Mt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let e=await d();if(e)return{token:await Ye(e),method:"oauth",source:"credentials.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new y("No credentials found.",u.AUTH,`Log in: mmx auth login
101
- Pass directly: --api-key sk-xxxxx`)}function Ve(t){if(!t)return"";if(t.includes("/t2a"))return`
99
+ `);let $=Date.now()+e*1000,c=(m||5)*1000;while(Date.now()<$){await new Promise((_)=>setTimeout(_,c));let x=await fetch(t.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:i,client_id:t.clientId})});if(x.ok)return await x.json();let y=await x.json();if(y.error==="authorization_pending")continue;if(y.error==="slow_down"){await new Promise((_)=>setTimeout(_,5000));continue}throw new s(`Device code authorization failed: ${y.error}`,u.AUTH)}throw new s("Device code authorization timed out.",u.TIMEOUT)}var nr="https://api.minimax.io/v1/oauth/token",Un=2,er=500;async function tn(t){let n=null;for(let i=0;i<=Un;i++){if(i>0)await new Promise((m)=>setTimeout(m,er*i));let r;try{r=await fetch(nr,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:t}),signal:AbortSignal.timeout(1e4)})}catch(m){let e=m instanceof Error&&(m.name==="AbortError"||m.name==="TimeoutError"||m.message.includes("timed out"));n=Error(e?"Token refresh timed out — auth server did not respond within 10 s.":`Token refresh failed: ${m instanceof Error?m.message:String(m)}`);continue}if(!r.ok){if(r.status>=400&&r.status<500)throw new s("OAuth session expired and could not be refreshed.",u.AUTH,"Re-authenticate: mmx auth login");n=Error(`Token refresh failed: HTTP ${r.status}`);continue}return await r.json()}throw new s(`Token refresh failed after ${Un+1} attempts: ${n?.message}`,u.AUTH,`Check your network connection.
100
+ Re-authenticate: mmx auth login`)}async function Hn(t){let n=new Date(t.expires_at).getTime(),i=300000;if(Date.now()<n-300000)return t.access_token;let r=await tn(t.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:t.account};return await $t(o),o.access_token}async function Gt(t){if(t.apiKey)return{token:t.apiKey,method:"api-key",source:"flag"};let n=await z();if(n)return{token:await Hn(n),method:"oauth",source:"credentials.json"};if(t.fileApiKey)return{token:t.fileApiKey,method:"api-key",source:"config.json"};throw new s("No credentials found.",u.AUTH,`Log in: mmx auth login
101
+ Pass directly: --api-key sk-xxxxx`)}function In(t){if(!t)return"";if(t.includes("/t2a"))return`
102
102
 
103
103
  Speech models require the Plus plan or above.`;if(t.includes("/image_generation"))return`
104
104
 
@@ -106,144 +106,152 @@ image-01 requires the Plus plan or above.`;if(t.includes("/video_generation")||t
106
106
 
107
107
  Video models (Hailuo-2.3 / 2.3-Fast) require the Max plan or above.`;if(t.includes("/music_generation"))return`
108
108
 
109
- Music-2.6 requires the Max plan or above.`;return""}function Ze(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function Ct(t,e,i){let r=e.base_resp?.status_msg||e.error?.message||`HTTP ${t}`,o=e.base_resp?.status_code||e.error?.code;if(t===401||t===403)return new y(`API key rejected (HTTP ${t}).`,u.AUTH,`Check status: mmx auth status
110
- Re-authenticate: mmx auth login`);if(t===429)return new y(`Rate limit or quota exceeded. ${r}`,u.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new y(`Request timed out (HTTP ${t}).`,u.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let $=e.base_resp?.status_msg||"content sensitivity";return new y(`Input content flagged by sensitivity filter (${$}).`,u.CONTENT_FILTER)}if(o===1028||o===1030){let $=Ve(i);return new y(`Quota exhausted. ${r}`,u.QUOTA,`Check usage: mmx quota show${$}
111
- Upgrade plan: ${Ze(i)}`)}if(o===2061){let $=Ve(i);return new y(`This model is not available on your current Token Plan. ${r}`,u.QUOTA,`Check usage: mmx quota show${$}
112
- Upgrade plan: ${Ze(i)}`)}return new y(`API error: ${r} (HTTP ${t})`,u.GENERAL)}import{homedir as ze}from"os";function W(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}var de=!1;var Z="\x1B[0m",E="\x1B[2m",Ui="\x1B[1m",ai="\x1B[38;2;43;82;255m",Ii="\x1B[38;2;147;51;234m",Pi="\x1B[38;2;6;184;212m",Ci="\x1B[38;2;236;72;153m";function Li(t){return t.startsWith(ze())?t.replace(ze(),"~"):t}function We(t,e,i){if(t.quiet||de||!process.stderr.isTTY)return;de=!0;let r=t.configPath?Li(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",$=t.apiKey?"(flag)":"(file)",n=W(e),m=i?` ${E}|${Z} ${E}Model:${Z} ${Ii}${i}${Z}`:"";process.stderr.write(`${Ui}${ai}MINIMAX${Z} ${E}${r}${Z} ${E}|${Z} ${E}Region:${Z} ${Pi}${o}${Z} ${E}|${Z} ${E}Key:${Z} ${Ci}${n}${Z} ${E}${$}${Z}${m}
113
- `)}async function P(t,e){let i=typeof FormData<"u"&&e.body instanceof FormData,r="1.0.11",o={"User-Agent":"mmx-cli/1.0.11",...e.headers};if(!i&&!o["Content-Type"])o["Content-Type"]="application/json";if(!e.noAuth){let m=await Mt(t);if(e.authStyle==="x-api-key")o["x-api-key"]=m.token;else o.Authorization=`Bearer ${m.token}`;if(t.verbose)process.stderr.write(`> ${e.method??"GET"} ${e.url}
114
- `),process.stderr.write(`> Auth: ${m.token.slice(0,8)}...
115
- `);let s=e.body&&typeof e.body==="object"&&"model"in e.body?String(e.body.model):void 0;We(t,m.token,s)}let $=(e.timeout??t.timeout)*1000,n=await fetch(e.url,{method:e.method??"GET",headers:o,body:e.body?i?e.body:JSON.stringify(e.body):void 0,signal:AbortSignal.timeout($)});if(t.verbose)process.stderr.write(`< ${n.status} ${n.statusText}
116
- `);if(!n.ok){let m={};try{m=await n.json()}catch{}throw Ct(n.status,m,e.url)}return n}async function A(t,e){let i=await P(t,e),r;try{r=await i.json()}catch{let o=i.headers.get("content-type")||"";throw new y(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,u.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw Ct(200,{base_resp:r.base_resp},e.url);return r}function Ke(t){return`${t}/anthropic/v1/messages`}function He(t){return`${t}/v1/t2a_v2`}function Ue(t){return`${t}/v1/get_voice`}function ae(t){return`${t}/v1/image_generation`}function Ie(t){return`${t}/v1/video_generation`}function At(t,e){return`${t}/v1/query/video_generation?task_id=${e}`}function jt(t,e){return`${t}/v1/files/retrieve?file_id=${e}`}function Gt(t){return`${t}/v1/music_generation`}function Pe(t){return`${t}/v1/coding_plan/search`}function Ce(t){return`${t}/v1/coding_plan/vlm`}function tt(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/token_plan/remains`}function fe(t){if(t<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t<=80)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"]}var Ei={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},fi={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function Fi(t,e){if(t<=0)return e;let i=Math.floor(t/3600000),r=Math.floor(t%3600000/60000);return i>0?`${i}h ${r}m`:`${r}m`}function Le(t){return new Date(t).toISOString().slice(0,10)}function gi(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function f(t){let e=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of e)i+=gi(r.codePointAt(0))?2:1;return i}var Tt=16;function Ee(t,e){let i=Math.max(0,Math.min(100,t))/100,r=Math.round(Tt*i),o=Tt-r,$=`${t}%`.padStart(4);if(!e)return`[${"█".repeat(r)}${".".repeat(o)}] ${$}`;let[n,m]=fe(t);return`${m}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${n}\x1B[1m${$}\x1B[0m`}function Bt(t,e,i,r,o){return o?`\x1B[2m${e}${i.repeat(t)}${r}\x1B[0m`:`+${"-".repeat(t)}+`}function Lt(t,e,i,r){let o=Math.max(0,e-2-i);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(o)} |`}function pt(t,e){let i=!e.noColor&&process.stdout.isTTY===!0,r=e.region==="cn"?fi:Ei,o=t.length>0?Math.max(...t.map((_)=>_.model_name.length)):16,$=i?Tt+5:Tt+7,n=Math.max(68,o+2+15+2+$+2),m=t.length>0?`${Le(t[0].weekly_start_time)} — ${Le(t[0].weekly_end_time)}`:"",s=`MINIMAX ${r.dashboard}`,c=`${r.week}: ${m}`,x=Math.max(2,n-2-f(s)-f(c)),w=i?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat(x)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${m}\x1B[0m`:`${s}${" ".repeat(x)}${c}`,h=f(s)+x+f(c);if(console.log(""),console.log(Bt(n,"╭","─","╮",i)),console.log(Lt(w,n,h,i)),t.length===0){console.log(Bt(n,"╰","─","╯",i)),console.log(`
109
+ Music-2.6 requires the Max plan or above.`;return""}function Pn(t){return`${t?.includes("minimaxi.com")?"https://platform.minimaxi.com":"https://platform.minimax.io"}/subscribe/token-plan`}function nn(t,n,i){let r=n.base_resp?.status_msg||n.error?.message||`HTTP ${t}`,o=n.base_resp?.status_code||n.error?.code;if(t===401||t===403)return new s(`API key rejected (HTTP ${t}).`,u.AUTH,`Check status: mmx auth status
110
+ Re-authenticate: mmx auth login`);if(t===429)return new s(`Rate limit or quota exceeded. ${r}`,u.QUOTA,"Check usage: mmx quota show");if(t===408||t===504)return new s(`Request timed out (HTTP ${t}).`,u.TIMEOUT,"Try increasing --timeout or retry later.");if(o===1002||o===1039){let m=n.base_resp?.status_msg||"content sensitivity";return new s(`Input content flagged by sensitivity filter (${m}).`,u.CONTENT_FILTER)}if(o===1028||o===1030){let m=In(i);return new s(`Quota exhausted. ${r}`,u.QUOTA,`Check usage: mmx quota show${m}
111
+ Upgrade plan: ${Pn(i)}`)}if(o===2061){let m=In(i);return new s(`This model is not available on your current Token Plan. ${r}`,u.QUOTA,`Check usage: mmx quota show${m}
112
+ Upgrade plan: ${Pn(i)}`)}return new s(`API error: ${r} (HTTP ${t})`,u.GENERAL)}import{homedir as Cn}from"os";function W(t){return t.length>8?`${t.slice(0,4)}...${t.slice(-4)}`:"***"}var Ln=!1;var Z="\x1B[0m",P="\x1B[2m",ir="\x1B[1m",rr="\x1B[38;2;43;82;255m",or="\x1B[38;2;147;51;234m",mr="\x1B[38;2;6;184;212m",$r="\x1B[38;2;236;72;153m";function pr(t){return t.startsWith(Cn())?t.replace(Cn(),"~"):t}function En(t,n,i){if(t.quiet||Ln||!process.stderr.isTTY)return;Ln=!0;let r=t.configPath?pr(t.configPath):"~/.mmx/config.json",o=t.fileRegion?`${t.fileRegion} (file)`:"global (default)",m=t.apiKey?"(flag)":"(file)",e=W(n),$=i?` ${P}|${Z} ${P}Model:${Z} ${or}${i}${Z}`:"";process.stderr.write(`${ir}${rr}MINIMAX${Z} ${P}${r}${Z} ${P}|${Z} ${P}Region:${Z} ${mr}${o}${Z} ${P}|${Z} ${P}Key:${Z} ${$r}${e}${Z} ${P}${m}${Z}${$}
113
+ `)}var g="1.0.13";async function U(t,n){let i=typeof FormData<"u"&&n.body instanceof FormData,r={"User-Agent":`mmx-cli/${g}`,...n.headers};if(!i&&!r["Content-Type"])r["Content-Type"]="application/json";if(!n.noAuth){let e=await Gt(t);if(n.authStyle==="x-api-key")r["x-api-key"]=e.token;else r.Authorization=`Bearer ${e.token}`;if(t.verbose)process.stderr.write(`> ${n.method??"GET"} ${n.url}
114
+ `),process.stderr.write(`> Auth: ${e.token.slice(0,8)}...
115
+ `);let $=n.body&&typeof n.body==="object"&&"model"in n.body?String(n.body.model):void 0;En(t,e.token,$)}let o=(n.timeout??t.timeout)*1000,m=await fetch(n.url,{method:n.method??"GET",headers:r,body:n.body?i?n.body:JSON.stringify(n.body):void 0,signal:AbortSignal.timeout(o)});if(t.verbose)process.stderr.write(`< ${m.status} ${m.statusText}
116
+ `);if(!m.ok){let e={};try{e=await m.json()}catch{}throw nn(m.status,e,n.url)}return m}async function T(t,n){let i=await U(t,n),r;try{r=await i.json()}catch{let o=i.headers.get("content-type")||"";throw new s(`API returned non-JSON response (${o||"unknown type"}). Server may be experiencing issues.`,u.GENERAL)}if(r.base_resp?.status_code&&r.base_resp.status_code!==0)throw nn(200,{base_resp:r.base_resp},n.url);return r}function fn(t){return`${t}/anthropic/v1/messages`}function Fn(t){return`${t}/v1/t2a_v2`}function gn(t){return`${t}/v1/get_voice`}function Dn(t){return`${t}/v1/image_generation`}function te(t){return`${t}/v1/video_generation`}function lt(t,n){return`${t}/v1/query/video_generation?task_id=${n}`}function Bt(t,n){return`${t}/v1/files/retrieve?file_id=${n}`}function qt(t){return`${t}/v1/music_generation`}function ne(t){return`${t}/v1/coding_plan/search`}function ee(t){return`${t}/v1/coding_plan/vlm`}function D(t){return`${t.includes("minimaxi.com")?"https://api.minimaxi.com":"https://api.minimax.io"}/v1/token_plan/remains`}function oe(t){if(t<50)return["\x1B[38;2;74;222;128m","\x1B[48;2;22;163;74m"];if(t<=80)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"]}var ur={dashboard:"TokenPlan Quota",week:"Week",weekly:"Weekly",resetsIn:"Resets in",noData:"No quota data available.",now:"now"},cr={dashboard:"TokenPlan 配额面板",week:"周期",weekly:"每周",resetsIn:"重置于",noData:"暂无配额数据",now:"即将"};function sr(t,n){if(t<=0)return n;let i=Math.floor(t/3600000),r=Math.floor(t%3600000/60000);return i>0?`${i}h ${r}m`:`${r}m`}function ie(t){return new Date(t).toISOString().slice(0,10)}function xr(t){return t>=11904&&t<=40959||t>=63744&&t<=64255||t>=65072&&t<=65103||t>=65281&&t<=65376||t>=131072&&t<=195103}function C(t){let n=t.replace(/\x1b\[[0-9;]*m/g,""),i=0;for(let r of n)i+=xr(r.codePointAt(0))?2:1;return i}var Yt=16;function re(t,n){let i=Math.max(0,Math.min(100,t))/100,r=Math.round(Yt*i),o=Yt-r,m=`${t}%`.padStart(4);if(!n)return`[${"█".repeat(r)}${".".repeat(o)}] ${m}`;let[e,$]=oe(t);return`${$}${" ".repeat(r)}\x1B[0m\x1B[48;2;55;65;81m${" ".repeat(o)}\x1B[0m ${e}\x1B[1m${m}\x1B[0m`}function Nt(t,n,i,r,o){return o?`\x1B[2m${n}${i.repeat(t)}${r}\x1B[0m`:`+${"-".repeat(t)}+`}function en(t,n,i,r){let o=Math.max(0,n-2-i);return r?`${"\x1B[2m"}│${"\x1B[0m"} ${t}${" ".repeat(o)} ${"\x1B[2m"}│${"\x1B[0m"}`:`| ${t}${" ".repeat(o)} |`}function pt(t,n){let i=!n.noColor&&process.stdout.isTTY===!0,r=n.region==="cn"?cr:ur,o=t.length>0?Math.max(...t.map((h)=>h.model_name.length)):16,m=i?Yt+5:Yt+7,e=Math.max(68,o+2+15+2+m+2),$=t.length>0?`${ie(t[0].weekly_start_time)} — ${ie(t[0].weekly_end_time)}`:"",c=`MINIMAX ${r.dashboard}`,x=`${r.week}: ${$}`,y=Math.max(2,e-2-C(c)-C(x)),_=i?`\x1B[1m\x1B[38;2;43;82;255mMINIMAX\x1B[0m \x1B[2m${r.dashboard}\x1B[0m${" ".repeat(y)}\x1B[2m${r.week}:\x1B[0m \x1B[38;2;6;184;212m${$}\x1B[0m`:`${c}${" ".repeat(y)}${x}`,w=C(c)+y+C(x);if(console.log(""),console.log(Nt(e,"╭","─","╮",i)),console.log(en(_,e,w,i)),t.length===0){console.log(Nt(e,"╰","─","╯",i)),console.log(`
117
117
  ${r.noData}
118
- `);return}for(let _ of t){console.log(Bt(n,"├","─","┤",i));let{current_interval_usage_count:R,current_interval_total_count:k}=_,j=k>0?Math.round(R/k*100):0,G=_.current_weekly_usage_count,N=_.current_weekly_total_count,Y=Fi(_.remains_time,r.now),B=_.model_name.padEnd(o),M=`${R.toLocaleString()} / ${k.toLocaleString()}`,V=Ee(j,i),a=o+2+15+2+$,I=i?`\x1B[1m\x1B[38;2;255;255;255m${B}\x1B[0m ${fe(j)[0]}${M.padStart(15)}\x1B[0m ${V}`:`${B} ${M.padStart(15)} ${Ee(j,!1)}`;console.log(Lt(I,n,a,i));let yt=`└ ${r.weekly} ${G.toLocaleString()} / ${N.toLocaleString()}`,vt=`${r.resetsIn} ${Y}`,Wt=Math.max(2,n-2-2-f(yt)-f(vt)),hi=2+f(yt)+Wt+f(vt),bi=i?` \x1B[2m${yt}${" ".repeat(Wt)}${vt}\x1B[0m`:` ${yt}${" ".repeat(Wt)}${vt}`;console.log(Lt(bi,n,hi,i))}console.log(Bt(n,"╰","─","╯",i)),console.log("")}import{readFileSync as tr,writeFileSync as er,renameSync as nr,existsSync as ir}from"fs";function Fe(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return Di(t);return t.map(String).join(`
119
- `)}if(typeof t==="object")return Et(t);return String(t)}function Et(t,e=0){let i=" ".repeat(e),r=[];for(let[o,$]of Object.entries(t)){if($===null||$===void 0)continue;if(Array.isArray($)){r.push(`${i}${o}:`);for(let n of $)if(typeof n==="object"&&n!==null)r.push(`${i} - ${Et(n,e+4).trimStart()}`);else r.push(`${i} - ${String(n)}`)}else if(typeof $==="object")r.push(`${i}${o}:`),r.push(Et($,e+2));else r.push(`${i}${o}: ${String($)}`)}return r.join(`
120
- `)}function Di(t){if(t.length===0)return"(empty)";let e=Object.keys(t[0]),i=e.map((n)=>Math.max(n.length,...t.map((m)=>String(m[n]??"").length))),r=e.map((n,m)=>n.toUpperCase().padEnd(i[m])).join(" "),o=i.map((n)=>"-".repeat(n)).join(" "),$=t.map((n)=>e.map((m,s)=>String(n[m]??"").padEnd(i[s])).join(" "));return[r,o,...$].join(`
121
- `)}function ge(t){return JSON.stringify(t,null,2)}function S(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function v(t,e){switch(e){case"json":return ge(t);case"text":return Fe(t)}}function Q(){let t=L();if(!ir(t))return{};try{return Te(JSON.parse(tr(t,"utf-8")))}catch(e){let i=e;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
122
- `);return{}}}async function H(t){await St();let e=L(),i=e+".tmp";er(i,JSON.stringify(t,null,2)+`
123
- `,{mode:384}),nr(i,e)}function ft(t){let e=Q(),i=t.apiKey||void 0,r=e.api_key,o=t.region||process.env.MINIMAX_REGION||void 0,$=e.region,n=o||$||"global",m=i||r,s=!o&&(!$||m!==void 0&&m!==e.api_key),c=t.baseUrl||process.env.MINIMAX_BASE_URL||e.base_url||C[n]||C.global,x=S(t.output||process.env.MINIMAX_OUTPUT||e.output),w=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,h=w!==void 0&&Number.isFinite(w)&&w>0?w:void 0,_=t.timeout??h??e.timeout??300;return{apiKey:i,fileApiKey:r,fileRegion:e.region,configPath:L(),region:n,baseUrl:c,output:x,timeout:_,defaultTextModel:e.default_text_model,defaultSpeechModel:e.default_speech_model,defaultVideoModel:e.default_video_model,defaultMusicModel:e.default_music_model,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:s}}function J(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function Jn(t){try{let e=tt(t.baseUrl),i=await A(t,{url:e});pt(i.model_remains||[],t)}catch{}}var Xn=l({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]",options:[{flag:"--method <method>",description:"Auth method: oauth (default), api-key"},{flag:"--api-key <key>",description:"API key to store"},{flag:"--no-browser",description:"Use device-code flow instead of browser"}],examples:["mmx auth login","mmx auth login --no-browser","mmx auth login --api-key sk-xxxxx","mmx auth login --method api-key --api-key sk-xxxxx"],async run(t,e){let i=process.env.MINIMAX_API_KEY;if(i&&!e.apiKey){let n=W(i);if(J({nonInteractive:t.nonInteractive})){let{confirm:m}=await Promise.resolve().then(() => (Vt(),Yt));if(!await m({message:`Detected MINIMAX_API_KEY in environment (${n}).
118
+ `);return}for(let h of t){console.log(Nt(e,"├","─","┤",i));let{current_interval_usage_count:S,current_interval_total_count:M}=h,R=M>0?Math.round(S/M*100):0,j=h.current_weekly_usage_count,B=h.current_weekly_total_count,N=sr(h.remains_time,r.now),Y=h.model_name.padEnd(o),G=`${S.toLocaleString()} / ${M.toLocaleString()}`,yt=re(R,i),Pt=o+2+15+2+m,Ct=i?`\x1B[1m${Y}\x1B[0m ${oe(R)[0]}${G.padStart(15)}\x1B[0m ${yt}`:`${Y} ${G.padStart(15)} ${re(R,!1)}`;console.log(en(Ct,e,Pt,i));let vt=`└ ${r.weekly} ${j.toLocaleString()} / ${B.toLocaleString()}`,kt=`${r.resetsIn} ${N}`,Lt=Math.max(2,e-2-2-C(vt)-C(kt)),Ni=2+C(vt)+Lt+C(kt),Yi=i?` \x1B[2m${vt}${" ".repeat(Lt)}${kt}\x1B[0m`:` ${vt}${" ".repeat(Lt)}${kt}`;console.log(en(Yi,e,Ni,i))}console.log(Nt(e,"╰","─","╯",i)),console.log("")}import{readFileSync as _r,writeFileSync as wr,renameSync as hr,existsSync as br}from"fs";function me(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);if(Array.isArray(t)){if(t.length===0)return"(empty)";if(typeof t[0]==="object"&&t[0]!==null)return yr(t);return t.map(String).join(`
119
+ `)}if(typeof t==="object")return rn(t);return String(t)}function rn(t,n=0){let i=" ".repeat(n),r=[];for(let[o,m]of Object.entries(t)){if(m===null||m===void 0)continue;if(Array.isArray(m)){r.push(`${i}${o}:`);for(let e of m)if(typeof e==="object"&&e!==null)r.push(`${i} - ${rn(e,n+4).trimStart()}`);else r.push(`${i} - ${String(e)}`)}else if(typeof m==="object")r.push(`${i}${o}:`),r.push(rn(m,n+2));else r.push(`${i}${o}: ${String(m)}`)}return r.join(`
120
+ `)}function yr(t){if(t.length===0)return"(empty)";let n=Object.keys(t[0]),i=n.map((e)=>Math.max(e.length,...t.map(($)=>String($[e]??"").length))),r=n.map((e,$)=>e.toUpperCase().padEnd(i[$])).join(" "),o=i.map((e)=>"-".repeat(e)).join(" "),m=t.map((e)=>n.map(($,c)=>String(e[$]??"").padEnd(i[c])).join(" "));return[r,o,...m].join(`
121
+ `)}function $e(t){return JSON.stringify(t,null,2)}function A(t){if(t==="json"||t==="text")return t;if(!process.stdout.isTTY)return"json";return"text"}function k(t,n){switch(n){case"json":return $e(t);case"text":return me(t)}}function K(t,n){if(!t.dryRun)return!1;return console.log(k({request:n},A(t.output))),!0}function J(){let t=I();if(!br(t))return{};try{return Vn(JSON.parse(_r(t,"utf-8")))}catch(n){let i=n;if(i instanceof SyntaxError||i.message.includes("JSON"))process.stderr.write(`Warning: config file is corrupted. Run 'mmx config set' to reset.
122
+ `);return{}}}async function a(t){await Tt();let n=I(),i=n+".tmp";wr(i,JSON.stringify(t,null,2)+`
123
+ `,{mode:384}),hr(i,n)}function on(t){let n=J(),i=t.apiKey||void 0,r=n.api_key,o=t.region||process.env.MINIMAX_REGION||void 0,m=n.region,e=o||m||"global",$=i||r,c=!o&&(!m||$!==void 0&&$!==n.api_key),x=t.baseUrl||process.env.MINIMAX_BASE_URL||n.base_url||H[e]||H.global,y=A(t.output||process.env.MINIMAX_OUTPUT||n.output),_=process.env.MINIMAX_TIMEOUT?Number(process.env.MINIMAX_TIMEOUT):void 0,w=_!==void 0&&Number.isFinite(_)&&_>0?_:void 0,h=t.timeout??w??n.timeout??300;return{apiKey:i,fileApiKey:r,fileRegion:n.region,configPath:I(),region:e,baseUrl:x,output:y,timeout:h,defaultTextModel:n.default_text_model,defaultSpeechModel:n.default_speech_model,defaultVideoModel:n.default_video_model,defaultMusicModel:n.default_music_model,verbose:t.verbose||process.env.MINIMAX_VERBOSE==="1",quiet:t.quiet||!1,noColor:t.noColor||process.env.NO_COLOR!==void 0||!process.stdout.isTTY,yes:t.yes||!1,dryRun:t.dryRun||!1,nonInteractive:t.nonInteractive||!1,async:t.async||!1,needsRegionDetection:c}}function Q(t){if(t?.nonInteractive===!0)return!1;if(process.env.CI)return!1;return process.stdout.isTTY===!0&&process.stdin.isTTY===!0}async function We(t){try{let n=D(t.baseUrl),i=await T(t,{url:n});pt(i.model_remains||[],t)}catch{}}var de=v({name:"auth login",description:"Authenticate via OAuth or API key",usage:"mmx auth login [--method oauth|api-key] [--api-key <key>] [--no-browser]",options:[{flag:"--method <method>",description:"Auth method: oauth (default), api-key"},{flag:"--api-key <key>",description:"API key to store"},{flag:"--no-browser",description:"Use device-code flow instead of browser"}],examples:["mmx auth login","mmx auth login --no-browser","mmx auth login --api-key sk-xxxxx","mmx auth login --method api-key --api-key sk-xxxxx"],async run(t,n){let i=process.env.MINIMAX_API_KEY;if(i&&!n.apiKey){let e=W(i);if(Q({nonInteractive:t.nonInteractive})){let{confirm:$}=await Promise.resolve().then(() => (Wt(),zt));if(!await $({message:`Detected MINIMAX_API_KEY in environment (${e}).
124
124
  You are already authenticated via env.
125
125
  Do you still want to configure local persistent credentials?`,initialValue:!1}))process.stdout.write(`Login skipped. Using environment variables.
126
126
  `),process.exit(0)}else process.stderr.write(`Warning: MINIMAX_API_KEY is already set in environment.
127
- `)}if((e.apiKey?"api-key":e.method||"oauth")==="api-key"){let n=e.apiKey||t.apiKey;if(!n)throw new y("--api-key is required when using --method api-key.",u.USAGE,"mmx auth login --api-key sk-xxxxx");if(!t.dryRun){process.stderr.write("Testing key... ");try{let s={...t,apiKey:n};await A(s,{url:tt(s.baseUrl)}),process.stderr.write(`Valid
128
- `)}catch{throw new y("API key validation failed.",u.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let m=Q();m.api_key=n,await H(m),process.stderr.write(`API key saved to ${L()}
129
- `),await Jn({...t,apiKey:n})}else console.log("Would validate and save API key.");return}if(t.dryRun){console.log("Would start OAuth login flow.");return}let o;if(e.noBrowser)o=await Qe();else o=await Xe();let $={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:new Date(Date.now()+o.expires_in*1000).toISOString(),token_type:"Bearer"};await mt($),process.stderr.write(`Logged in successfully.
127
+ `)}if((n.apiKey?"api-key":n.method||"oauth")==="api-key"){let e=n.apiKey||t.apiKey;if(!e)throw new s("--api-key is required when using --method api-key.",u.USAGE,"mmx auth login --api-key sk-xxxxx");if(!t.dryRun){process.stderr.write("Testing key... ");try{let c={...t,apiKey:e};await T(c,{url:D(c.baseUrl)}),process.stderr.write(`Valid
128
+ `)}catch{throw new s("API key validation failed.",u.AUTH,"Check that your key is valid and belongs to a Token Plan.")}let $=J();$.api_key=e,await a($),process.stderr.write(`API key saved to ${I()}
129
+ `),await We({...t,apiKey:e})}else console.log("Would validate and save API key.");return}if(t.dryRun){console.log("Would start OAuth login flow.");return}let o;if(n.noBrowser)o=await an();else o=await Kn();let m={access_token:o.access_token,refresh_token:o.refresh_token,expires_at:new Date(Date.now()+o.expires_in*1000).toISOString(),token_type:"Bearer"};await $t(m),process.stderr.write(`Logged in successfully.
130
130
  `),process.stderr.write(`Credentials saved to ~/.mmx/credentials.json
131
- `),await Jn({...t,apiKey:$.access_token})}});var Qn=l({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(t,e){try{let i=await Mt(t),r=S(t.output);if(r!=="text"){let $={method:i.method,source:i.source};if(i.method==="oauth"){let n=await d();if(n){if($.token_expires=n.expires_at,n.account)$.account=n.account}}else $.key=W(i.token);console.log(v($,r));return}console.log("Authentication Status:"),console.log(` Method: ${i.method}`),console.log(` Source: ${i.source}`);let o=i.token;if(console.log(` Key: ${W(o)}`),i.method==="oauth"){let $=await d();if($){if($.account)console.log(` Account: ${$.account}`);let n=new Date($.expires_at),m=Math.round((n.getTime()-Date.now())/60000);console.log(` Expires in: ${m} minutes`)}}process.stderr.write(`Fetching quota snapshot...
132
- `);try{let $=tt(t.baseUrl),n=await A(t,{url:$,method:"GET"});pt(n.model_remains||[],t)}catch($){console.log(` Quota fetch failed: ${$.message}`)}}catch{let i=S(t.output);console.log(v({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
133
- Or set $MINIMAX_API_KEY`},i))}}});var On=l({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,e){let i=await d();if(!i)throw new y("Not applicable: not authenticated via OAuth.",u.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let r=await Pt(i.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:i.account};await mt(o);let $=S(t.output);if(t.quiet){console.log(o.expires_at);return}console.log(v({status:"Token refreshed",expires:o.expires_at},$))}});var Yn=l({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(t,e){let i=await d(),r=Q(),o=!!r.api_key;if(t.dryRun){if(i)console.log("Would remove ~/.mmx/credentials.json");if(o)console.log("Would clear api_key from ~/.mmx/config.json");if(!i&&!o)console.log("No credentials to clear.");console.log("No changes made.");return}if(i)await Ne(),process.stderr.write(`Removed ~/.mmx/credentials.json
134
- `);if(o)try{let $=r;delete $.api_key,await H($),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
131
+ `),await We({...t,apiKey:m.access_token})}});var Ke=v({name:"auth status",description:"Show current authentication state and quota snapshot",usage:"mmx auth status",examples:["mmx auth status","mmx auth status --output json"],async run(t,n){try{let i=await Gt(t),r=A(t.output);if(r!=="text"){let m={method:i.method,source:i.source};if(i.method==="oauth"){let e=await z();if(e){if(m.token_expires=e.expires_at,e.account)m.account=e.account}}else m.key=W(i.token);console.log(k(m,r));return}console.log("Authentication Status:"),console.log(` Method: ${i.method}`),console.log(` Source: ${i.source}`);let o=i.token;if(console.log(` Key: ${W(o)}`),i.method==="oauth"){let m=await z();if(m){if(m.account)console.log(` Account: ${m.account}`);let e=new Date(m.expires_at),$=Math.round((e.getTime()-Date.now())/60000);console.log(` Expires in: ${$} minutes`)}}process.stderr.write(`Fetching quota snapshot...
132
+ `);try{let m=D(t.baseUrl),e=await T(t,{url:m,method:"GET"});pt(e.model_remains||[],t)}catch(m){console.log(` Quota fetch failed: ${m.message}`)}}catch{let i=A(t.output);console.log(k({authenticated:!1,message:"Not authenticated.",hint:`Run: mmx auth login
133
+ Or set $MINIMAX_API_KEY`},i))}}});var ae=v({name:"auth refresh",description:"Manually refresh OAuth token",usage:"mmx auth refresh",examples:["mmx auth refresh"],async run(t,n){let i=await z();if(!i)throw new s("Not applicable: not authenticated via OAuth.",u.USAGE,"Run mmx auth login first.");if(t.dryRun){console.log("Would refresh OAuth token.");return}let r=await tn(i.refresh_token),o={access_token:r.access_token,refresh_token:r.refresh_token,expires_at:new Date(Date.now()+r.expires_in*1000).toISOString(),token_type:"Bearer",account:i.account};await $t(o);let m=A(t.output);if(t.quiet){console.log(o.expires_at);return}console.log(k({status:"Token refreshed",expires:o.expires_at},m))}});var Ue=v({name:"auth logout",description:"Revoke tokens and clear stored credentials",usage:"mmx auth logout [--yes] [--dry-run]",options:[{flag:"--yes",description:"Skip confirmation prompt"}],examples:["mmx auth logout","mmx auth logout --dry-run","mmx auth logout --yes"],async run(t,n){let i=await z(),r=J(),o=!!r.api_key;if(t.dryRun){if(i)console.log("Would remove ~/.mmx/credentials.json");if(o)console.log("Would clear api_key from ~/.mmx/config.json");if(!i&&!o)console.log("No credentials to clear.");console.log("No changes made.");return}if(i)await Wn(),process.stderr.write(`Removed ~/.mmx/credentials.json
134
+ `);if(o)try{let m=r;delete m.api_key,await a(m),process.stderr.write(`Cleared api_key from ~/.mmx/config.json
135
135
  `)}catch{}if(!i&&!o)process.stderr.write(`No credentials to clear.
136
- `)}});async function*Zt(t){let e=t.body?.getReader();if(!e)return;let i=new TextDecoder,r="";try{while(!0){let{done:o,value:$}=await e.read();if(o)break;r+=i.decode($,{stream:!0});let n=r.split(`
137
- `);r=n.pop()||"";let m={};for(let s of n){if(s===""){if(m.data!==void 0)yield{data:m.data,event:m.event,id:m.id};m={};continue}if(s.startsWith(":"))continue;let c=s.indexOf(":");if(c===-1)continue;let x=s.slice(0,c),w=s.slice(c+1).trimStart();switch(x){case"data":m.data=m.data!==void 0?`${m.data}
138
- ${w}`:w;break;case"event":m.event=w;break;case"id":m.id=w;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{e.releaseLock()}}import{readFileSync as he}from"fs";async function U(t){if(!J())return;let{defaultValue:e,message:i}=t,o=await(await Promise.resolve().then(() => (Vt(),Yt))).text({message:i,default:e,placeholder:e});if(typeof o==="symbol")return;return o}async function Vn(t){if(!J())return;let{message:e}=t,r=await(await Promise.resolve().then(() => (Vt(),Yt))).confirm({message:e});if(typeof r==="symbol")return;return r}function ct(t,e){throw new y(`Missing required argument: --${t}
136
+ `)}});async function*dt(t){let n=t.body?.getReader();if(!n)return;let i=new TextDecoder,r="";try{while(!0){let{done:o,value:m}=await n.read();if(o)break;r+=i.decode(m,{stream:!0});let e=r.split(`
137
+ `);r=e.pop()||"";let $={};for(let c of e){if(c===""){if($.data!==void 0)yield{data:$.data,event:$.event,id:$.id};$={};continue}if(c.startsWith(":"))continue;let x=c.indexOf(":");if(x===-1)continue;let y=c.slice(0,x),_=c.slice(x+1).trimStart();switch(y){case"data":$.data=$.data!==void 0?`${$.data}
138
+ ${_}`:_;break;case"event":$.event=_;break;case"id":$.id=_;break}}}if(r.trim()&&r.includes("data:")){let o=r.indexOf(":");if(o!==-1)yield{data:r.slice(o+1).trimStart()}}}finally{n.releaseLock()}}import{readFileSync as Gn}from"fs";async function it(t){if(!Q())return;let{defaultValue:n,message:i}=t,o=await(await Promise.resolve().then(() => (Wt(),zt))).text({message:i,default:n,placeholder:n});if(typeof o==="symbol")return;return o}async function He(t){if(!Q())return;let{message:n}=t,r=await(await Promise.resolve().then(() => (Wt(),zt))).confirm({message:n});if(typeof r==="symbol")return;return r}function Tn(t,n){throw new s(`Missing required argument: --${t}
139
139
  Hint: In non-interactive (CI / agent) environments all required flags must be provided.
140
- In an interactive terminal, run without --${t} and the CLI will prompt for it.`,u.USAGE,e)}function wo(t){let e=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,o=r==="-"?he("/dev/stdin","utf-8"):he(r,"utf-8"),$=JSON.parse(o);for(let n of $)if(n.role==="system")i=typeof n.content==="string"?n.content:"";else e.push(n)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let r=new Set(["system","user","assistant"]),o=t.message;for(let $ of o){let n=$.indexOf(":"),m=n!==-1?$.slice(0,n):"";if(r.has(m)){let s=$.slice(n+1);if(m==="system")i=s;else e.push({role:m,content:s})}else e.push({role:"user",content:$})}}return{system:i,messages:e}}function _o(t){return t.filter((e)=>e.type==="text").map((e)=>e.text).join("")}var Zn=l({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",apiDocs:"/docs/api-reference/text-post",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"','mmx text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "Write fizzbuzz in Python"','mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(t,e){let{system:i,messages:r}=wo(e),o=r;if(o.length===0)if(J({nonInteractive:t.nonInteractive})){let x=await U({message:"Enter your message:"});if(!x)process.stderr.write(`Chat cancelled.
141
- `),process.exit(1);o=[{role:"user",content:x}]}else ct("message","mmx text chat --message <text>");let $=e.model||t.defaultTextModel||"MiniMax-M2.7",n=e.stream===!0||e.stream===void 0&&process.stdout.isTTY,m=S(t.output),s={model:$,messages:o,max_tokens:e.maxTokens??4096,stream:n};if(i)s.system=i;if(e.temperature!==void 0)s.temperature=e.temperature;if(e.topP!==void 0)s.top_p=e.topP;if(e.tool){let x=e.tool.map((w)=>{try{return JSON.parse(w)}catch{try{let h=he(w,"utf-8");return JSON.parse(h)}catch{throw new y(`Invalid tool definition: "${w}" is neither valid JSON nor a readable file.`,u.USAGE)}}});s.tools=x}if(t.dryRun){console.log(v({request:s},m));return}let c=Ke(t.baseUrl);if(n){let x=await P(t,{url:c,method:"POST",body:s,stream:!0,authStyle:"x-api-key"}),w=x.headers.get("content-type")||"";if(!w.includes("text/event-stream")&&!w.includes("stream"))throw new y(`Expected SSE stream but got content-type "${w}". Server may be experiencing issues.`,u.GENERAL);let h="",_=!1,R=t.noColor?"":"\x1B[2m",k=t.noColor?"":"\x1B[0m",G=process.stdout.isTTY?process.stdout:process.stderr,N=process.stdout;for await(let Y of Zt(x)){if(Y.data==="[DONE]")break;try{let B=JSON.parse(Y.data);if(B.type==="content_block_start"){if(B.content_block.type==="thinking")_=!0,G.write(`${R}Thinking:
142
- `);else if(B.content_block.type==="text"&&_)G.write(`${k}
140
+ In an interactive terminal, run without --${t} and the CLI will prompt for it.`,u.USAGE,n)}async function Kt(t){if(t.value)return t.value;if(Q({nonInteractive:t.nonInteractive})){let n=await it({message:t.message});if(!n)process.stderr.write(t.cancelMessage+`
141
+ `),process.exit(1);return n}Tn(t.flagName,t.usageHint)}function Bo(t){let n=[],i;if(t.system)i=t.system;if(t.messagesFile){let r=t.messagesFile,o=r==="-"?Gn("/dev/stdin","utf-8"):Gn(r,"utf-8"),m=JSON.parse(o);for(let e of m)if(e.role==="system")i=typeof e.content==="string"?e.content:"";else n.push(e)}if(!t.message&&t.prompt)t.message=Array.isArray(t.prompt)?t.prompt:[t.prompt];if(t.message){let r=new Set(["system","user","assistant"]),o=t.message;for(let m of o){let e=m.indexOf(":"),$=e!==-1?m.slice(0,e):"";if(r.has($)){let c=m.slice(e+1);if($==="system")i=c;else n.push({role:$,content:c})}else n.push({role:"user",content:m})}}return{system:i,messages:n}}function qo(t){return t.filter((n)=>n.type==="text").map((n)=>n.text).join("")}var Ie=v({name:"text chat",description:"Send a chat completion (MiniMax Messages API)",apiDocs:"/docs/api-reference/text-post",usage:"mmx text chat --message <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-M2.7)"},{flag:"--message <text>",description:"Message text (repeatable, prefix role: to set role)",required:!0,type:"array"},{flag:"--messages-file <path>",description:"JSON file with messages array (use - for stdin)"},{flag:"--system <text>",description:"System prompt"},{flag:"--max-tokens <n>",description:"Maximum tokens to generate (default: 4096)",type:"number"},{flag:"--temperature <n>",description:"Sampling temperature (0.0, 1.0]",type:"number"},{flag:"--top-p <n>",description:"Nucleus sampling threshold",type:"number"},{flag:"--stream",description:"Stream response tokens (default: on in TTY)"},{flag:"--tool <json-or-path>",description:"Tool definition as JSON or file path (repeatable)",type:"array"}],examples:['mmx text chat --message "What is MiniMax?"','mmx text chat --model MiniMax-M2.7-highspeed --system "You are a coding assistant." --message "Write fizzbuzz in Python"','mmx text chat --message "Hello" --message "assistant:Hi!" --message "How are you?"',"cat conversation.json | mmx text chat --messages-file - --stream",'mmx text chat --message "Hello" --output json'],async run(t,n){let{system:i,messages:r}=Bo(n),o=r;if(o.length===0)if(Q({nonInteractive:t.nonInteractive})){let y=await it({message:"Enter your message:"});if(!y)process.stderr.write(`Chat cancelled.
142
+ `),process.exit(1);o=[{role:"user",content:y}]}else Tn("message","mmx text chat --message <text>");let m=n.model||t.defaultTextModel||"MiniMax-M2.7",e=A(t.output),$=n.stream===!0||n.stream===void 0&&e!=="json"&&process.stdout.isTTY,c={model:m,messages:o,max_tokens:n.maxTokens??4096,stream:$};if(i)c.system=i;if(n.temperature!==void 0)c.temperature=n.temperature;if(n.topP!==void 0)c.top_p=n.topP;if(n.tool){let y=n.tool.map((_)=>{try{return JSON.parse(_)}catch{try{let w=Gn(_,"utf-8");return JSON.parse(w)}catch{throw new s(`Invalid tool definition: "${_}" is neither valid JSON nor a readable file.`,u.USAGE)}}});c.tools=y}if(t.dryRun){console.log(k({request:c},e));return}let x=fn(t.baseUrl);if($){let y=await U(t,{url:x,method:"POST",body:c,stream:!0,authStyle:"x-api-key"}),_=y.headers.get("content-type")||"";if(!_.includes("text/event-stream")&&!_.includes("stream"))throw new s(`Expected SSE stream but got content-type "${_}". Server may be experiencing issues.`,u.GENERAL);let w="",h=!1,S=t.noColor?"":"\x1B[2m",M=t.noColor?"":"\x1B[0m",R=e==="json",B=process.stdout.isTTY&&!R?process.stdout:process.stderr,N=R?void 0:process.stdout;for await(let Y of dt(y)){if(Y.data==="[DONE]")break;try{let G=JSON.parse(Y.data);if(G.type==="content_block_start"){if(G.content_block.type==="thinking")h=!0,B.write(`${S}Thinking:
143
+ `);else if(G.content_block.type==="text"&&h)B.write(`${M}
143
144
 
144
145
  Response:
145
- `),_=!1}else if(B.type==="content_block_delta"){if(B.delta.type==="text_delta")h+=B.delta.text,N.write(B.delta.text);else if(B.delta.type==="thinking_delta")G.write(B.delta.thinking)}}catch(B){process.stderr.write(`
146
- ${R}[warning] Failed to parse stream chunk: ${B instanceof Error?B.message:String(B)}${k}
147
- `)}}if(_)G.write(k);if(N.write(`
148
- `),m==="json")console.log(v({content:h},m))}else{let x=await A(t,{url:c,method:"POST",body:s,authStyle:"x-api-key"}),w=_o(x.content);if(t.quiet||m==="text")console.log(w);else console.log(v(x,m))}}});import{writeFileSync as ho}from"fs";function ut(t,e,i,r){if(e){let o=t.data.audio;if(!o)throw new y("API response missing audio data (audio field is empty).",u.GENERAL);if(!/^[0-9a-fA-F]*$/.test(o))throw new y("API returned invalid audio data (not valid hex).",u.GENERAL);if(o.length%2!==0)throw new y("API returned truncated audio data (odd-length hex string).",u.GENERAL);try{ho(e,Buffer.from(o,"hex"))}catch($){if($.code==="ENOSPC")throw new y("Disk full — cannot write audio file.",u.GENERAL,"Free up disk space and try again.");throw $}if(r)console.log(e);else console.log(v({saved:e,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},i))}else{let o=t.data.audio_url??t.data.audio;if(r)console.log(o);else console.log(v({url:o,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},i))}}zt();import{writeFileSync as vo}from"fs";var be=l({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",apiDocs:"/docs/api-reference/speech-t2a-http",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','mmx speech synthesize --text "Hello" --subtitles --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(t,e){let i=e.text??e._positional?.[0];if(e.textFile)i=bt(e.textFile);if(!i)throw new y("--text or --text-file is required.",u.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=e.model||t.defaultSpeechModel||"speech-2.8-hd",o=e.voice||"English_expressive_narrator",$=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),n=e.format||"mp3",m=e.out??`speech_${$}.${n}`,s="hex",c=S(t.output),x={model:r,text:i,voice_setting:{voice_id:o,speed:e.speed??void 0,vol:e.volume??void 0,pitch:e.pitch??void 0},audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??32000,bitrate:e.bitrate??128000,channel:e.channels??1},output_format:s,stream:e.stream===!0};if(e.language)x.language_boost=e.language;if(e.subtitles)x.subtitle_enable=!0;if(e.pronunciation)x.pronunciation_dict=e.pronunciation.map((_)=>{let[R,k]=_.split("/");return{tone:k||R,text:R}});if(t.dryRun){console.log(v({request:x},c));return}let w=He(t.baseUrl);if(e.stream){let _=await P(t,{url:w,method:"POST",body:x,stream:!0});for await(let R of Zt(_)){if(!R.data||R.data==="[DONE]")break;let j=JSON.parse(R.data)?.data?.audio;if(j)process.stdout.write(Buffer.from(j,"hex"))}return}let h=await A(t,{url:w,method:"POST",body:x});if(!t.quiet)process.stderr.write(`[Model: ${r}]
149
- `);if(ut(h,m,c,t.quiet),e.subtitles&&h.data.subtitle_file)try{let _=await fetch(h.data.subtitle_file);if(!_.ok)throw new y(`Failed to download subtitle file: ${_.status}`,u.GENERAL);let R=await _.json();if(R?.length){let k=m.replace(/\.[^.]+$/,"")+".srt",j=R.map((G,N)=>{let Y=(B)=>{let M=String(Math.floor(B/3600000)).padStart(2,"0"),V=String(Math.floor(B%3600000/60000)).padStart(2,"0"),a=String(Math.floor(B%60000/1000)).padStart(2,"0"),I=String(Math.round(B%1000)).padStart(3,"0");return`${M}:${V}:${a},${I}`};return`${N+1}
150
- ${Y(G.time_begin)} --> ${Y(G.time_end)}
151
- ${G.text}`}).join(`
146
+ `),h=!1}else if(G.type==="content_block_delta"){if(G.delta.type==="text_delta")w+=G.delta.text,N?.write(G.delta.text);else if(G.delta.type==="thinking_delta")B.write(G.delta.thinking)}}catch(G){process.stderr.write(`
147
+ ${S}[warning] Failed to parse stream chunk: ${G instanceof Error?G.message:String(G)}${M}
148
+ `)}}if(h)B.write(M);if(e==="json")console.log(k({content:w},e));else N?.write(`
149
+ `)}else{let y=await T(t,{url:x,method:"POST",body:c,authStyle:"x-api-key"}),_=qo(y.content);if(t.quiet||e==="text")console.log(_);else console.log(k(y,e))}}});import{writeFileSync as No}from"fs";function ct(t,n,i,r){if(n){let o=t.data.audio;if(!o)throw new s("API response missing audio data (audio field is empty).",u.GENERAL);if(!/^[0-9a-fA-F]*$/.test(o))throw new s("API returned invalid audio data (not valid hex).",u.GENERAL);if(o.length%2!==0)throw new s("API returned truncated audio data (odd-length hex string).",u.GENERAL);try{No(n,Buffer.from(o,"hex"))}catch(m){if(m.code==="ENOSPC")throw new s("Disk full — cannot write audio file.",u.GENERAL,"Free up disk space and try again.");throw m}if(r)console.log(n);else console.log(k({saved:n,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size,sample_rate:t.extra_info?.audio_sample_rate},i))}else{let o=t.data.audio_url??t.data.audio;if(r)console.log(o);else console.log(k({url:o,duration_ms:t.extra_info?.audio_length,size_bytes:t.extra_info?.audio_size},i))}}at();import{writeFileSync as Jo}from"fs";var ln=["mp3","pcm","flac","wav","pcmu_raw","pcmu_wav","opus"],st=["mp3","wav","pcm"];function rt(t){return t.join(", ")}function xt(t,n){if(!n.includes(t))throw new s(`Invalid audio format "${t}". Supported: ${rt(n)}`,u.USAGE)}var Xo={opus:24000,pcmu_raw:8000,pcmu_wav:8000};function Ce(t,n){return Xo[t]??n}function Le(t,n){if(n&&t==="wav")throw new s("wav format is not supported in streaming mode.",u.USAGE,"Use mp3, pcm, flac, pcmu_raw, pcmu_wav, or opus for streaming.")}var Bn=v({name:"speech synthesize",description:"Synchronous TTS, up to 10k chars (speech-2.8-hd / 2.6 / 02)",apiDocs:"/docs/api-reference/speech-t2a-http",usage:"mmx speech synthesize --text <text> [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model ID (default: speech-2.8-hd)"},{flag:"--text <text>",description:"Text to synthesize"},{flag:"--text-file <path>",description:"Read text from file (use - for stdin)"},{flag:"--voice <id>",description:"Voice ID (default: English_expressive_narrator)"},{flag:"--speed <n>",description:"Speech speed multiplier",type:"number"},{flag:"--volume <n>",description:"Volume level",type:"number"},{flag:"--pitch <n>",description:"Pitch adjustment",type:"number"},{flag:"--format <fmt>",description:`Audio format: ${rt(ln)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 32000)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 128000)",type:"number"},{flag:"--channels <n>",description:"Audio channels (default: 1)",type:"number"},{flag:"--language <code>",description:"Language boost"},{flag:"--subtitles",description:"Include subtitle timing data"},{flag:"--pronunciation <from/to>",description:"Custom pronunciation (repeatable)",type:"array"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"},{flag:"--stream",description:"Stream raw audio to stdout"}],examples:['mmx speech synthesize --text "Hello, world!"','mmx speech synthesize --text "Hello, world!" --out hello.mp3','mmx speech synthesize --text "Hello" --subtitles --out hello.mp3','echo "Breaking news." | mmx speech synthesize --text-file - --out news.mp3','mmx speech synthesize --text "Stream" --stream | mpv --no-terminal -'],async run(t,n){let i=n.text??n._positional?.[0];if(n.textFile)i=St(n.textFile);if(!i)throw new s("--text or --text-file is required.",u.USAGE,'mmx speech synthesize --text "Hello" --out hello.mp3');let r=n.model||t.defaultSpeechModel||"speech-2.8-hd",o=n.voice||"English_expressive_narrator",m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),e=n.format||"mp3";xt(e,ln),Le(e,n.stream===!0);let $=n.out??`speech_${m}.${e}`,c="hex",x={model:r,text:i,voice_setting:{voice_id:o,speed:n.speed??void 0,vol:n.volume??void 0,pitch:n.pitch??void 0},audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??Ce(e,32000),bitrate:n.bitrate??128000,channel:n.channels??1},output_format:c,stream:n.stream===!0};if(n.language)x.language_boost=n.language;if(n.subtitles)x.subtitle_enable=!0;if(n.pronunciation)x.pronunciation_dict=n.pronunciation.map((h)=>{let[S,M]=h.split("/");return{tone:M||S,text:S}});if(K(t,x))return;let y=A(t.output),_=Fn(t.baseUrl);if(n.stream){let h=await U(t,{url:_,method:"POST",body:x,stream:!0});for await(let S of dt(h)){if(!S.data||S.data==="[DONE]")break;let R=JSON.parse(S.data)?.data?.audio;if(R)process.stdout.write(Buffer.from(R,"hex"))}return}let w=await T(t,{url:_,method:"POST",body:x});if(!t.quiet)process.stderr.write(`[Model: ${r}]
150
+ `);if(ct(w,$,y,t.quiet),n.subtitles&&w.data.subtitle_file)try{let h=await fetch(w.data.subtitle_file);if(!h.ok)throw new s(`Failed to download subtitle file: ${h.status}`,u.GENERAL);let S=await h.json();if(S?.length){let M=$.replace(/\.[^.]+$/,"")+".srt",R=S.map((j,B)=>{let N=(Y)=>{let G=String(Math.floor(Y/3600000)).padStart(2,"0"),yt=String(Math.floor(Y%3600000/60000)).padStart(2,"0"),Pt=String(Math.floor(Y%60000/1000)).padStart(2,"0"),Ct=String(Math.round(Y%1000)).padStart(3,"0");return`${G}:${yt}:${Pt},${Ct}`};return`${B+1}
151
+ ${N(j.time_begin)} --> ${N(j.time_end)}
152
+ ${j.text}`}).join(`
152
153
 
153
- `);if(vo(k,j,"utf-8"),!t.quiet)console.log(v({subtitles:k},c));else console.log(k)}}catch(_){if(!t.quiet)process.stderr.write(`Warning: failed to download subtitles: ${_.message}
154
- `)}else if(e.subtitles&&!h.data.subtitle_file){if(!t.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
155
- `)}}});function lo(t){let e=t.match(/^(.+?)_[A-Z]/);return e?e[1]:t}function Ro(t,e){let i=e.toLowerCase();return t.filter((r)=>{let o=lo(r.voice_id).toLowerCase();return o===i||o.startsWith(i+"_")||o.startsWith(i+" (")})}var dn=l({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(t,e){let i=S(t.output);if(t.dryRun){console.log(v({request:{voice_type:"system"}},i));return}let o=(await A(t,{url:Ue(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],$=e.language;if($){let n=Ro(o,$);if(i!=="text"){console.log(v(n,i));return}for(let m of n){let s=m.description?.join("; ")||"",c=m.voice_name?` (${m.voice_name})`:"";if(console.log(` ${m.voice_id}${c}`),s)console.log(` ${s}`)}}else{if(i!=="text"){console.log(v(o.map((n)=>n.voice_id),i));return}for(let n of o)console.log(n.voice_id)}}});import{createWriteStream as ko,unlinkSync as So}from"fs";var Wn=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Kn(t){let e=process.stderr.isTTY,i=0,r=null,o=t;return{start(){if(!e)return;r=setInterval(()=>{process.stderr.write(`\r${Wn[i%Wn.length]} ${o}`),i++},80)},update($){o=$},stop($){if(r)clearInterval(r),r=null;if(e){if(process.stderr.write("\r\x1B[K"),$)process.stderr.write(`${$}
156
- `)}}}}function Hn(t,e=""){let i=process.stderr.isTTY,r=30;return{update(o){if(!i)return;let $=Math.min(1,o/t),n=Math.round(30*$),m=30-n,s="█".repeat(n)+"░".repeat(m),c=`${Math.round($*100)}%`;process.stderr.write(`\r${e} ${s} ${c}`)},finish(){if(i)process.stderr.write(`
157
- `)}}}async function rt(t,e,i){let r=await fetch(t);if(!r.ok)throw new y(`Download failed: HTTP ${r.status}`,u.GENERAL);let o=Number(r.headers.get("content-length")||0),$=r.body?.getReader();if(!$)throw new y("No response body",u.GENERAL);let n=ko(e),m=o>0&&!i?.quiet?Hn(o,"Downloading"):null,s=0,c=!1;try{let x=new Promise((w,h)=>{n.on("error",h)});while(!0){let{done:w,value:h}=await Promise.race([$.read(),x]);if(w)break;if(!n.write(h))await new Promise((R)=>n.once("drain",R));s+=h.byteLength,m?.update(s)}c=!0}finally{if($.releaseLock(),m?.finish(),await new Promise((x,w)=>{n.on("finish",x),n.on("error",w),n.end()}),!c)try{So(e)}catch{}}return{size:s}}function dt(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}import{mkdirSync as Mo,existsSync as Un,readFileSync as Ao}from"fs";import{join as jo,resolve as Go,extname as Bo}from"path";var To={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},an=l({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-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'],async run(t,e){let i=e.prompt??e._positional?.[0];if(!i)if(J({nonInteractive:t.nonInteractive})){let _=await U({message:"Enter your image prompt:"});if(!_)process.stderr.write(`Image generation cancelled.
158
- `),process.exit(1);i=_}else ct("prompt","mmx image generate --prompt <text>");let{width:r,height:o}=e;if(r!==void 0&&o===void 0)throw new y("--width requires --height. Both must be specified together.",u.USAGE);if(o!==void 0&&r===void 0)throw new y("--height requires --width. Both must be specified together.",u.USAGE);if(r!==void 0&&o!==void 0){let _=(R,k)=>{if(k<512||k>2048)throw new y(`--${R} must be between 512 and 2048, got ${k}.`,u.USAGE);if(k%8!==0)throw new y(`--${R} must be a multiple of 8, got ${k}.`,u.USAGE)};_("width",r),_("height",o)}let $={model:"image-01",prompt:i,aspect_ratio:r!==void 0&&o!==void 0?void 0:e.aspectRatio||void 0,n:e.n??1,seed:e.seed,width:r,height:o,prompt_optimizer:e.promptOptimizer===!0||void 0,aigc_watermark:e.aigcWatermark===!0||void 0};if(e.subjectRef){let _=e.subjectRef,R=Object.fromEntries(_.split(",").map((j)=>{let G=j.indexOf("=");if(G===-1)return[j,""];return[j.slice(0,G),j.slice(G+1)]})),k={type:R.type||"character"};if(R.image)if(R.image.startsWith("http"))k.image_url=R.image;else{let j=Go(R.image),G=Ao(j),N=Bo(j).toLowerCase(),Y=To[N]||"image/jpeg";k.image_file=`data:${Y};base64,${G.toString("base64")}`}$.subject_reference=[k]}let n=S(t.output);if(t.dryRun){console.log(v({request:$},n));return}let m=ae(t.baseUrl),s=await A(t,{url:m,method:"POST",body:$}),c=s.data.image_urls||[];if(!t.quiet)process.stderr.write(`[Model: image-01]
159
- `);let x=e.outDir??".";if(!Un(x))Mo(x,{recursive:!0});let w=e.outPrefix||"image",h=[];for(let _=0;_<c.length;_++){let R=`${w}_${String(_+1).padStart(3,"0")}.jpg`,k=jo(x,R);if(Un(k))process.stderr.write(`Warning: overwriting existing file: ${k}
160
- `);await rt(c[_],k,{quiet:t.quiet}),h.push(k)}if(n==="json")console.log(v({id:s.data.task_id,saved:h,success_count:s.data.success_count,failed_count:s.data.failed_count},n));else if(t.quiet)console.log(h.join(`
161
- `));else console.log(v({id:s.data.task_id,saved:h,success_count:s.data.success_count,failed_count:s.data.failed_count},n))}});async function In(t,e){let i=Date.now()+e.timeoutSec*1000,r=Kn("Polling...");if(!t.quiet)r.start();try{while(Date.now()<i){let o=await A(t,{url:e.url});if(e.getStatus&&!t.quiet)r.update(`Status: ${e.getStatus(o)}`);if(e.isComplete(o))return r.stop("Done."),o;if(e.isFailed(o)){r.stop("Failed.");let $=e.getStatus?e.getStatus(o):"failed",n=o?.base_resp?` (${o.base_resp.status_msg})`:"";throw new y(`Task ${$}.${n}`,u.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise(($)=>setTimeout($,e.intervalSec*1000))}}finally{r.stop()}throw new y("Polling timed out.",u.TIMEOUT,"Try increasing --timeout or check task status manually.")}import{readFileSync as ve}from"fs";import{extname as le}from"path";var Re={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Pn=l({name:"video generate",description:"Generate a video (T2V: Hailuo-2.3 / 2.3-Fast / Hailuo-02 | I2V: I2V-01 / I2V-01-Director / I2V-01-live | S2V: S2V-01)",apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID (default: MiniMax-Hailuo-2.3). Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image (local path or URL). Auto base64-encoded for local files."},{flag:"--last-frame <path-or-url>",description:"Last frame image (local path or URL). Enables SEF (start-end frame) interpolation mode with Hailuo-02 model. Requires --first-frame."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --first-frame start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(t,e){let i=e.prompt;if(!i)if(J({nonInteractive:t.nonInteractive})){let M=await U({message:"Enter your video prompt:"});if(!M)process.stderr.write(`Video generation cancelled.
162
- `),process.exit(1);i=M}else ct("prompt","mmx video generate --prompt <text>");if(e.lastFrame&&e.subjectImage)throw new y("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",u.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let r=e.model,o;if(r)o=r;else if(e.lastFrame)o="MiniMax-Hailuo-02";else if(e.subjectImage)o="S2V-01";else o=t.defaultVideoModel||"MiniMax-Hailuo-2.3";let $=S(t.output),n={model:o,prompt:i};if(e.firstFrame){let M=e.firstFrame;if(M.startsWith("http"))n.first_frame_image=M;else{let V=ve(M),a=le(M).toLowerCase(),I=Re[a]||"image/jpeg";n.first_frame_image=`data:${I};base64,${V.toString("base64")}`}}if(e.lastFrame){if(!e.firstFrame)throw new y("--last-frame requires --first-frame (SEF mode).",u.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let M=e.lastFrame;if(M.startsWith("http"))n.last_frame_image=M;else{let V=ve(M),a=le(M).toLowerCase(),I=Re[a]||"image/jpeg";n.last_frame_image=`data:${I};base64,${V.toString("base64")}`}}if(e.subjectImage){let M=e.subjectImage,V;if(M.startsWith("http"))V=M;else{let a=ve(M),I=le(M).toLowerCase();V=`data:${Re[I]||"image/jpeg"};base64,${a.toString("base64")}`}n.subject_reference=[{type:"character",image:[V]}]}if(e.callbackUrl)n.callback_url=e.callbackUrl;if(t.dryRun){console.log(v({request:n},$));return}let m=Ie(t.baseUrl),c=(await A(t,{url:m,method:"POST",body:n})).task_id;if(!t.quiet)process.stderr.write(`[Model: ${o}]
163
- `);if(e.noWait||t.async){process.stdout.write(JSON.stringify({taskId:c})),process.stdout.write(`
164
- `);return}let x=e.pollInterval??5,w=At(t.baseUrl,c),h=await In(t,{url:w,intervalSec:x,timeoutSec:t.timeout,isComplete:(M)=>M.status==="Success",isFailed:(M)=>M.status==="Failed",getStatus:(M)=>M.status});if(!h.file_id)throw new y("Task completed but no file_id returned.",u.GENERAL);let R=(await A(t,{url:jt(t.baseUrl,h.file_id)})).file?.download_url;if(!R)throw new y("No download URL available for this file.",u.GENERAL);if(e.download){let M=e.download,{size:V}=await rt(R,M,{quiet:t.quiet});if(t.quiet)console.log(M);else console.log(v({task_id:c,status:"Success",file_id:h.file_id,saved:M,size:dt(V)},$));return}let k=await import("os"),{join:j}=await import("path"),G=j(k.tmpdir(),"mmx-video"),{existsSync:N,mkdirSync:Y}=await import("fs");if(!N(G))Y(G,{recursive:!0});let B=j(G,`${c}.mp4`);await rt(R,B,{quiet:t.quiet}),process.stdout.write(B),process.stdout.write(`
165
- `)}});var Cn=l({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,e){let i=e.taskId;if(!i)throw new y("--task-id is required.",u.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${i}`);return}let r=At(t.baseUrl,i),o=await A(t,{url:r}),$=S(t.output);if(t.quiet){console.log(o.status);return}console.log(v({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},$))}});var Ln=l({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(t,e){let i=e.fileId;if(!i)throw new y("--file-id is required.",u.USAGE,"mmx video download --file-id <id> --out <path>");let r=e.out;if(!r)throw new y("--out is required.",u.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${i} to ${r}`);return}let o=jt(t.baseUrl,i),n=(await A(t,{url:o})).file?.download_url;if(!n)throw new y("No download URL available for this file.",u.GENERAL,"The file may still be processing. Check task status first.");let{size:m}=await rt(n,r,{quiet:t.quiet}),s=S(t.output);if(t.quiet){console.log(r);return}console.log(v({saved:r,size:dt(m)},s))}});zt();function En(t){return(t.apiKey??t.fileApiKey??"").startsWith("sk-cp-")}function fn(t){if(t.defaultMusicModel)return t.defaultMusicModel;return En(t)?"music-2.6":"music-2.6-free"}var qo=new Set(["music-cover","music-cover-free"]);function Fn(t){if(t.defaultMusicModel&&qo.has(t.defaultMusicModel))return t.defaultMusicModel;return En(t)?"music-cover":"music-cover-free"}var gn=l({name:"music generate",description:"Generate a song (music-2.6 / music-2.6-free / music-2.5+ / music-2.5)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.'},{flag:"--lyrics <text>",description:"Song lyrics with structure tags (newline separated). Supported: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo]. Tags must be clean — no descriptions inside brackets (they will be sung). Max 3500 chars."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Same tag rules as --lyrics."},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). music-2.6/music-2.5+: native is_instrumental flag; music-2.5: lyrics workaround. Cannot be used with --lyrics."},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz, electronic"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano, strings"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--model <model>",description:"Model: music-2.6 (recommended), music-2.6-free (default, unlimited), music-2.5+, or music-2.5."},{flag:"--output-format <fmt>",description:"Return format: hex (default, saved to file) or url (24h expiry, download promptly). When --stream, only hex."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:"Audio format (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Auto-generate lyrics from prompt:",'mmx music generate --prompt "Upbeat pop about summer" --lyrics-optimizer --out summer.mp3',"# Instrumental:",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3',"# URL output (24h expiry — download promptly):",'mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --output-format url',"# Instrumental with music-2.5+:",'mmx music generate --prompt "Cinematic orchestral" --model "music-2.5+" --instrumental --out bgm.mp3',"# Detailed prompt with vocal characteristics:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3'],async run(t,e){let{prompt:i,lyrics:r}=e,o=e.instrumental===!0,$=e.lyricsOptimizer===!0;if(e.lyricsFile)r=bt(e.lyricsFile);if(o&&(r||e.lyricsFile))throw new y("Cannot use --instrumental with --lyrics or --lyrics-file.",u.USAGE,"mmx music generate --prompt <style> --instrumental");if($&&(r||o))throw new y("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",u.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!i&&!r&&!o&&!$)throw new y("At least one of --prompt or --lyrics is required.",u.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!o&&!$&&!r?.trim())throw new y("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",u.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let n=[];if(e.vocals)n.push(`Vocals: ${e.vocals}`);if(e.genre)n.push(`Genre: ${e.genre}`);if(e.mood)n.push(`Mood: ${e.mood}`);if(e.instruments)n.push(`Instruments: ${e.instruments}`);if(e.tempo)n.push(`Tempo: ${e.tempo}`);if(e.bpm)n.push(`BPM: ${e.bpm}`);if(e.key)n.push(`Key: ${e.key}`);if(e.avoid)n.push(`Avoid: ${e.avoid}`);if(e.useCase)n.push(`Use case: ${e.useCase}`);if(e.structure)n.push(`Structure: ${e.structure}`);if(e.references)n.push(`References: ${e.references}`);if(e.extra)n.push(`Extra: ${e.extra}`);if(n.length>0){let G=n.join(". ");i=i?`${i}. ${G}`:G}let m=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),s=e.format||"mp3",c=e.out??`music_${m}.${s}`,x=S(t.output),w=e.model||fn(t),h=["music-2.6","music-2.6-free","music-2.5+","music-2.5"];if(e.model&&!h.includes(w))throw new y(`Invalid model "${w}". Valid models: ${h.join(", ")}`,u.USAGE,"mmx music generate --model music-2.6");let _=e.outputFormat||"hex";if(_!=="hex"&&_!=="url")throw new y('--output-format must be "hex" or "url".',u.USAGE,"mmx music generate --output-format url");if(e.stream&&_==="url")throw new y("--stream and --output-format url cannot be used together. Streaming requires hex format.",u.USAGE,"mmx music generate --output-format url");let R={model:w,prompt:i,lyrics:r,is_instrumental:o||void 0,lyrics_optimizer:$||void 0,audio_setting:{format:e.format||"mp3",sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000},output_format:e.stream===!0?"hex":_,stream:e.stream===!0};if(e.aigcWatermark)R.aigc_watermark=!0;if(t.dryRun){console.log(v({request:R},x));return}let k=Gt(t.baseUrl);if(e.stream){let N=(await P(t,{url:k,method:"POST",body:R,stream:!0})).body?.getReader();if(!N)throw new y("No response body",u.GENERAL);while(!0){let{done:Y,value:B}=await N.read();if(Y)break;process.stdout.write(B)}N.releaseLock();return}let j=await A(t,{url:k,method:"POST",body:R});if(!t.quiet)process.stderr.write(`[Model: ${w}]
166
- `);if(_==="url"){if(j.data?.audio_url)console.log(j.data.audio_url);else throw new y("Requested URL output but API did not return audio_url.",u.GENERAL);return}ut(j,c,x,t.quiet)}});import{readFileSync as No}from"fs";var Dn=l({name:"music cover",description:"Generate a cover version of a song based on reference audio (music-cover / music-cover-free)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model: music-cover (Token Plan), music-cover-free (Pay-as-you-go, default). Override only if needed."},{flag:"--prompt <text>",description:'Target cover style, e.g. "Indie folk, acoustic guitar, warm male vocal"'},{flag:"--audio <url>",description:"URL of the reference audio (mp3, wav, flac, etc. — 6s to 6min, max 50MB)"},{flag:"--audio-file <path>",description:"Local reference audio file (auto base64-encoded)"},{flag:"--lyrics <text>",description:"Cover lyrics. If omitted, extracted from reference audio via ASR."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin)"},{flag:"--seed <number>",description:"Random seed 0–1000000 for reproducible results",type:"number"},{flag:"--format <fmt>",description:"Audio format: mp3, wav, pcm (default: mp3)"},{flag:"--sample-rate <hz>",description:"Sample rate: 16000, 24000, 32000, 44100 (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate: 32000, 64000, 128000, 256000 (default: 256000)",type:"number"},{flag:"--channel <n>",description:"Channels: 1 (mono) or 2 (stereo, default)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file"}],examples:['mmx music cover --prompt "Indie folk, acoustic guitar, warm male vocal" --audio https://example.com/song.mp3 --out cover.mp3','mmx music cover --prompt "Jazz, piano, slow" --audio-file original.mp3 --lyrics-file lyrics.txt --out jazz_cover.mp3','mmx music cover --prompt "Pop, upbeat" --audio https://example.com/ref.mp3 --seed 42 --out reproducible.mp3'],async run(t,e){let{prompt:i,audio:r,audioFile:o}=e;if(!i)throw new y("--prompt is required.",u.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!r&&!o)throw new y("One of --audio <url> or --audio-file <path> is required.",u.USAGE,"mmx music cover --prompt <text> --audio <url>");if(r&&o)throw new y("Use either --audio or --audio-file, not both.",u.USAGE);let $=e.lyrics;if(e.lyricsFile){let{readTextFromPathOrStdin:k}=await Promise.resolve().then(() => (zt(),zn));$=k(e.lyricsFile)}let n=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),m=e.format||"mp3",s=e.out??`cover_${n}.${m}`,c=S(t.output),x=e.model||Fn(t),w=["music-cover","music-cover-free"];if(e.model&&!w.includes(x))throw new y(`Invalid model "${x}". Valid models: ${w.join(", ")}`,u.USAGE,"mmx music cover --model music-cover");let h={model:x,prompt:i,lyrics:$,seed:e.seed,audio_setting:{format:m,sample_rate:e.sampleRate??44100,bitrate:e.bitrate??256000,channel:e.channel??void 0},output_format:"hex",stream:e.stream===!0};if(r)h.audio_url=r;else h.audio_base64=No(o).toString("base64");if(t.dryRun){console.log(v({request:h},c));return}let _=Gt(t.baseUrl);if(e.stream){let j=(await P(t,{url:_,method:"POST",body:h,stream:!0})).body?.getReader();if(!j)throw new y("No response body",u.GENERAL);while(!0){let{done:G,value:N}=await j.read();if(G)break;process.stdout.write(N)}j.releaseLock();return}let R=await A(t,{url:_,method:"POST",body:h});if(!t.quiet)process.stderr.write(`[Model: ${x}]
167
- `);ut(R,s,c,t.quiet)}});var ke=l({name:"search query",description:"Search the web via MiniMax",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(t,e){let i=e.q??e.query??e._positional?.[0];if(!i)throw new y("--q is required.",u.USAGE,'mmx search query --q "your search query"');let r=S(t.output);if(t.dryRun){console.log(v({request:{q:i}},r));return}let o=Pe(t.baseUrl),$=await A(t,{url:o,method:"POST",body:{q:i}}),n=$.organic||[];if(r!=="text"){console.log(v($,r));return}if(t.quiet){for(let m of n)console.log(`${m.title} ${m.link}`);return}if(n.length===0){console.log("No results found.");return}for(let m of n){if(console.log(`${m.title}`),console.log(` ${m.link}`),m.snippet)console.log(` ${m.snippet}`);if(m.date)console.log(` ${m.date}`);console.log("")}}});import{readFileSync as Jo,existsSync as Xo}from"fs";import{extname as Qo}from"path";var Oo={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"},Yo=52428800;async function Vo(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let o=await fetch(t);if(!o.ok)throw new y(`Failed to download image: HTTP ${o.status}`,u.GENERAL);let n=(o.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await o.arrayBuffer();if(m.byteLength>Yo)throw new y(`Image too large (${(m.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,u.USAGE);let s=Buffer.from(m).toString("base64");return`data:${n};base64,${s}`}if(!Xo(t))throw new y(`File not found: ${t}`,u.USAGE);let e=Qo(t).toLowerCase(),i=Oo[e];if(!i)throw new y(`Unsupported image format "${e}". Supported: jpg, jpeg, png, webp`,u.USAGE);let r=Jo(t);return`data:${i};base64,${r.toString("base64")}`}var ti=l({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(t,e){let i=e.image??e.file??e.path??e._positional?.[0],r=e.fileId,o=e.prompt||"Describe the image.";if(!i&&!r)if(J({nonInteractive:t.nonInteractive})){let c=await U({message:"Enter image path, URL, or File ID:"});if(!c)process.stderr.write(`Vision describe cancelled.
168
- `),process.exit(1);if(!c.includes(".")&&!c.startsWith("http"))r=c;else i=c}else throw new y("Missing required argument. Must provide either --image or --file-id.",u.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(i&&r)throw new y("Conflicting arguments: cannot provide both --image and --file-id.",u.USAGE);let $=S(t.output);if(t.dryRun){process.stdout.write(v({request:{prompt:o,image:i,fileId:r}},$)+`
169
- `);return}let n=Ce(t.baseUrl),m={prompt:o};if(r)m.file_id=r;else if(i){let c=await Vo(i);m.image_url=c}let s=await A(t,{url:n,method:"POST",body:m});if($!=="text"){process.stdout.write(v(s,$)+`
170
- `);return}process.stdout.write(s.content+`
171
- `)}});var ei=l({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(t,e){if(t.dryRun){console.log("Would fetch quota information.");return}let i=tt(t.baseUrl),r=await A(t,{url:i}),o=r.model_remains||[],$=S(e.output);if($!=="text"){console.log(v(r,$));return}if(t.quiet){for(let n of o){let m=n.current_interval_total_count-n.current_interval_usage_count;console.log(`${n.model_name} ${n.current_interval_usage_count} ${n.current_interval_total_count} ${m}`)}return}pt(o,t)}});var ni=l({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,e){let i=Q(),r=S(t.output),o={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:L()};if(i.api_key)o.api_key=W(i.api_key);if(i.default_text_model)o.default_text_model=i.default_text_model;if(i.default_speech_model)o.default_speech_model=i.default_speech_model;if(i.default_video_model)o.default_video_model=i.default_video_model;if(i.default_music_model)o.default_music_model=i.default_music_model;console.log(v(o,r))}});var ii=["region","base_url","output","timeout","api_key","default_text_model","default_speech_model","default_video_model","default_music_model"],Zo={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"},ri=l({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, default_text_model, default_speech_model, default_video_model, default_music_model)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,e){let i=e._positional,r=e.key??i?.[0],o=e.value??i?.[1];if(!r||o===void 0)throw new y("--key and --value are required.",u.USAGE,"mmx config set --key <key> --value <value>");let $=Zo[r]||r;if(!ii.includes($))throw new y(`Invalid config key "${r}". Valid keys: ${ii.join(", ")}`,u.USAGE);if($==="region"&&!["global","cn"].includes(o))throw new y(`Invalid region "${o}". Valid values: global, cn`,u.USAGE);if($==="output"&&!["text","json"].includes(o))throw new y(`Invalid output format "${o}". Valid values: text, json`,u.USAGE);if($==="timeout"){let s=Number(o);if(isNaN(s)||s<=0)throw new y(`Invalid timeout "${o}". Must be a positive number.`,u.USAGE)}let n=S(t.output);if(t.dryRun){console.log(v({would_set:{[$]:o}},n));return}let m=Q();if(m[$]=$==="timeout"?Number(o):o,$==="api_key")delete m.region;if(await H(m),!t.quiet)console.log(v({[$]:m[$]},n))}});function zo(t){let e=t.match(/^--([a-zA-Z0-9-]+)/),i=e?e[1]:"",r=i.replace(/-([a-zA-Z0-9])/g,(n,m)=>m.toUpperCase()),o="string",$=!1;if(!t.includes("<")&&!t.includes("["))o="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))o="number";if(t.toLowerCase().includes("repeatable"))$=!0;return{name:r,kebabName:i,inferredType:o,isArray:$}}function Se(t){let i={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let r of t.options){let{name:o,inferredType:$,isArray:n}=zo(r.flag);if(!o)continue;let m=r.type,s=n?"array":m??$,c={description:r.description};if(s==="array")c.type="array",c.items={type:"string"};else c.type=s;let x=i.input_schema;if(x.properties[o]=c,r.required)x.required.push(o)}return i}var Wo=["auth ","config ","update"],oi=l({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(t,e){let i=e.command;if(i){try{let{command:$}=D.resolve(i.split(" ")),n=Se($);process.stdout.write(JSON.stringify(n,null,2)+`
172
- `)}catch{throw new y(`Command "${i}" not found.`,u.USAGE)}return}let o=D.getAllCommands().filter(($)=>!Wo.some((n)=>$.name.startsWith(n))).map(($)=>Se($));process.stdout.write(JSON.stringify(o,null,2)+`
173
- `)}});var Ko="1.0.11",$i=l({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${Ko}
154
+ `);if(Jo(M,R,"utf-8"),!t.quiet)console.log(k({subtitles:M},y));else console.log(M)}}catch(h){if(!t.quiet)process.stderr.write(`Warning: failed to download subtitles: ${h.message}
155
+ `)}else if(n.subtitles&&!w.data.subtitle_file){if(!t.quiet)process.stderr.write(`Warning: subtitles requested but not returned by API
156
+ `)}}});function Oo(t){let n=t.match(/^(.+?)_[A-Z]/);return n?n[1]:t}function Qo(t,n){let i=n.toLowerCase();return t.filter((r)=>{let o=Oo(r.voice_id).toLowerCase();return o===i||o.startsWith(i+"_")||o.startsWith(i+" (")})}var Ee=v({name:"speech voices",description:"List available system voices",usage:"mmx speech voices [--language <lang>]",options:[{flag:"--language <lang>",description:"Filter voices by language (e.g. english, korean, japanese)"}],examples:["mmx speech voices","mmx speech voices --language english","mmx speech voices --language korean","mmx speech voices --output json"],async run(t,n){let i=A(t.output);if(t.dryRun){console.log(k({request:{voice_type:"system"}},i));return}let o=(await T(t,{url:gn(t.baseUrl),method:"POST",body:{voice_type:"system"}})).system_voice??[],m=n.language;if(m){let e=Qo(o,m);if(i!=="text"){console.log(k(e,i));return}for(let $ of e){let c=$.description?.join("; ")||"",x=$.voice_name?` (${$.voice_name})`:"";if(console.log(` ${$.voice_id}${x}`),c)console.log(` ${c}`)}}else{if(i!=="text"){console.log(k(o.map((e)=>e.voice_id),i));return}for(let e of o)console.log(e.voice_id)}}});import{createWriteStream as Zo,renameSync as Vo,unlinkSync as zo}from"fs";var fe=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];function Fe(t){let n=process.stderr.isTTY,i=0,r=null,o=t;return{start(){if(!n)return;r=setInterval(()=>{process.stderr.write(`\r${fe[i%fe.length]} ${o}`),i++},80)},update(m){o=m},stop(m){if(r)clearInterval(r),r=null;if(n){if(process.stderr.write("\r\x1B[K"),m)process.stderr.write(`${m}
157
+ `)}}}}function ge(t,n=""){let i=process.stderr.isTTY,r=30;return{update(o){if(!i)return;let m=Math.min(1,o/t),e=Math.round(30*m),$=30-e,c="█".repeat(e)+"░".repeat($),x=`${Math.round(m*100)}%`;process.stderr.write(`\r${n} ${c} ${x}`)},finish(){if(i)process.stderr.write(`
158
+ `)}}}async function f(t,n,i){let r=t.startsWith("http://")?t.replace("http://","https://"):t,o=i?.retries??3,m=i?.retryDelayMs??1000,e;for(let $=0;$<=o;$++)try{if($>0){let j=m*Math.pow(2,$-1);if(!i?.quiet)process.stderr.write(`
159
+ Retry ${$}/${o} in ${j}ms...
160
+ `);await new Promise((B)=>setTimeout(B,j))}let c=await fetch(r);if(!c.ok)throw new s(`Download failed: HTTP ${c.status}`,u.GENERAL);let x=Number(c.headers.get("content-length")||0),y=c.body?.getReader();if(!y)throw new s("No response body",u.GENERAL);let _=`${n}.tmp-${process.pid}-${Date.now()}-${$}-${Math.random().toString(36).slice(2)}`,w=Zo(_),h=x>0&&!i?.quiet?ge(x,"Downloading"):null,S=0,M=!1,R=!1;try{let j=new Promise((B,N)=>{w.on("error",N)});while(!0){let{done:B,value:N}=await Promise.race([y.read(),j]);if(B)break;if(!w.write(N))await new Promise((G)=>w.once("drain",G));S+=N.byteLength,h?.update(S)}M=!0}finally{y.releaseLock(),h?.finish();try{if(!w.destroyed)await new Promise((j,B)=>{w.on("finish",j),w.on("error",B),w.end()}),R=M}finally{if(!R)try{zo(_)}catch{}}}return Vo(_,n),{size:S}}catch(c){if(e=c instanceof Error?c:Error(String(c)),!i?.quiet)process.stderr.write(`
161
+ Download attempt ${$+1} failed: ${e.message}
162
+ `)}throw new s(`Download failed after ${o+1} attempts: ${e?.message}`,u.NETWORK,"Check your network connection and proxy settings.")}function Ut(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(1)} MB`;return`${(t/1073741824).toFixed(1)} GB`}import{mkdirSync as ei,existsSync as Mt,writeFileSync as ii}from"fs";import{dirname as Uo,join as ri,resolve as qn}from"path";import{readFileSync as Wo,existsSync as Ko}from"fs";import{extname as De}from"path";var ti={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"};function Ht(t){let n=De(t).toLowerCase(),i=ti[n]||"image/jpeg",r=Wo(t);return`data:${i};base64,${r.toString("base64")}`}function It(t){return t.startsWith("http")?t:Ht(t)}var ao=52428800;async function ni(t){if(t.startsWith("data:"))return t;if(t.startsWith("http://")||t.startsWith("https://")){let i=await fetch(t);if(!i.ok)throw new s(`Failed to download image: HTTP ${i.status}`,u.GENERAL);let o=(i.headers.get("content-type")||"image/jpeg").split(";")[0].trim(),m=await i.arrayBuffer();if(m.byteLength>ao)throw new s(`Image too large (${(m.byteLength/1024/1024).toFixed(1)} MB). Maximum is 50 MB.`,u.USAGE);return`data:${o};base64,${Buffer.from(m).toString("base64")}`}if(!Ko(t))throw new s(`File not found: ${t}`,u.USAGE);let n=De(t).toLowerCase();if(!ti[n])throw new s(`Unsupported image format "${n}". Supported: jpg, jpeg, png, webp`,u.USAGE);return Ht(t)}var oi=v({name:"image generate",description:"Generate images (image-01 / image-01-live)",apiDocs:"/docs/api-reference/image-generation-t2i",usage:"mmx image generate --prompt <text> [flags]",options:[{flag:"--prompt <text>",description:"Image description",required:!0},{flag:"--aspect-ratio <ratio>",description:"Aspect ratio (e.g. 16:9, 1:1). Ignored if --width and --height are both specified."},{flag:"--n <count>",description:"Number of images to generate (default: 1)",type:"number"},{flag:"--seed <n>",description:"Random seed for reproducible generation (same seed + prompt = identical output)",type:"number"},{flag:"--width <px>",description:"Custom width in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--height <px>",description:"Custom height in pixels. Range [512, 2048], must be multiple of 8. Only effective for image-01 model. Overrides --aspect-ratio if set.",type:"number"},{flag:"--prompt-optimizer",description:"Automatically optimize the prompt before generation for better results."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in the output image."},{flag:"--subject-ref <params>",description:"Subject reference for character consistency. Format: type=character,image=path-or-url"},{flag:"--out <path>",description:"Save image to exact file path (single image only)"},{flag:"--response-format <format>",description:"Response format: url (download), base64 (embed). Default: url"},{flag:"--out-dir <dir>",description:"Download images to directory"},{flag:"--out-prefix <prefix>",description:"Filename prefix (default: image)"}],examples:['mmx image generate --prompt "A cat in a spacesuit on Mars" --aspect-ratio 16:9','mmx image generate --prompt "Logo design" --n 3 --out-dir ./generated/','mmx image generate --prompt "Mountain landscape" --quiet',"# Reproducible output with seed",'mmx image generate --prompt "A castle" --seed 42',"# Custom dimensions (must be 512–2048, multiple of 8)",'mmx image generate --prompt "Wide landscape" --width 1920 --height 1080',"# Optimized prompt with watermark",'mmx image generate --prompt "sunset" --prompt-optimizer --aigc-watermark',"# Save to exact path",'mmx image generate --prompt "A cat" --out /tmp/cat.jpg',"# Base64 response (bypasses CDN, useful when image URLs are unreachable)",'mmx image generate --prompt "A cat" --response-format base64'],async run(t,n){let i=n.prompt??n._positional?.[0];i=await Kt({value:i,message:"Enter your image prompt:",cancelMessage:"Image generation cancelled.",flagName:"prompt",usageHint:"mmx image generate --prompt <text>",nonInteractive:t.nonInteractive});let{width:r,height:o}=n;if(r!==void 0&&o===void 0)throw new s("--width requires --height. Both must be specified together.",u.USAGE);if(o!==void 0&&r===void 0)throw new s("--height requires --width. Both must be specified together.",u.USAGE);if(r!==void 0&&o!==void 0){let w=(h,S)=>{if(S<512||S>2048)throw new s(`--${h} must be between 512 and 2048, got ${S}.`,u.USAGE);if(S%8!==0)throw new s(`--${h} must be a multiple of 8, got ${S}.`,u.USAGE)};w("width",r),w("height",o)}let m=n.out;if(m&&n.n>1)throw new s("--out cannot be used with --n > 1. Use --out-dir instead.",u.USAGE);let e=n.responseFormat||"url",$={model:"image-01",prompt:i,aspect_ratio:r!==void 0&&o!==void 0?void 0:n.aspectRatio||void 0,n:n.n??1,seed:n.seed,width:r,height:o,prompt_optimizer:n.promptOptimizer===!0||void 0,aigc_watermark:n.aigcWatermark===!0||void 0,response_format:e};if(n.subjectRef){let w=n.subjectRef,h=Object.fromEntries(w.split(",").map((M)=>{let R=M.indexOf("=");if(R===-1)return[M,""];return[M.slice(0,R),M.slice(R+1)]})),S={type:h.type||"character"};if(h.image)if(h.image.startsWith("http"))S.image_url=h.image;else S.image_file=Ht(qn(h.image));$.subject_reference=[S]}if(K(t,$))return;let c=A(t.output),x=Dn(t.baseUrl),y=await T(t,{url:x,method:"POST",body:$});if(!t.quiet)process.stderr.write(`[Model: image-01]
163
+ `);let _=[];if(m){let w=Uo(qn(m));if(!Mt(w))ei(w,{recursive:!0});let h=qn(m);if(Mt(h))process.stderr.write(`Warning: overwriting existing file: ${h}
164
+ `);if(e==="base64"){let S=(y.data.image_base64||[])[0];if(S)ii(h,S,"base64")}else{let S=(y.data.image_urls||[])[0];if(S)await f(S,h,{quiet:t.quiet})}_.push(h)}else{let w=n.outDir??".";if(!Mt(w))ei(w,{recursive:!0});let h=n.outPrefix||"image";if(e==="base64"){let S=y.data.image_base64||[];for(let M=0;M<S.length;M++){let R=`${h}_${String(M+1).padStart(3,"0")}.jpg`,j=ri(w,R);if(Mt(j))process.stderr.write(`Warning: overwriting existing file: ${j}
165
+ `);ii(j,S[M],"base64"),_.push(j)}}else{let S=y.data.image_urls||[];for(let M=0;M<S.length;M++){let R=`${h}_${String(M+1).padStart(3,"0")}.jpg`,j=ri(w,R);if(Mt(j))process.stderr.write(`Warning: overwriting existing file: ${j}
166
+ `);await f(S[M],j,{quiet:t.quiet}),_.push(j)}}}if(c==="json")console.log(k({id:y.data.task_id,saved:_,success_count:y.data.success_count,failed_count:y.data.failed_count},c));else if(t.quiet)console.log(_.join(`
167
+ `));else console.log(k({id:y.data.task_id,saved:_,success_count:y.data.success_count,failed_count:y.data.failed_count},c))}});async function mi(t,n){let i=Date.now()+n.timeoutSec*1000,r=Fe("Polling...");if(!t.quiet)r.start();try{while(Date.now()<i){let o=await T(t,{url:n.url});if(n.getStatus&&!t.quiet)r.update(`Status: ${n.getStatus(o)}`);if(n.isComplete(o))return r.stop("Done."),o;if(n.isFailed(o)){r.stop("Failed.");let m=n.getStatus?n.getStatus(o):"failed",e=o?.base_resp?` (${o.base_resp.status_msg})`:"";throw new s(`Task ${m}.${e}`,u.GENERAL,"Check the MiniMax dashboard or --verbose output for details.")}await new Promise((m)=>setTimeout(m,n.intervalSec*1000))}}finally{r.stop()}throw new s("Polling timed out.",u.TIMEOUT,"Try increasing --timeout or check task status manually.")}var $i=v({name:"video generate",description:`Generate a video
168
+ T2V: Hailuo-2.3
169
+ I2V: Hailuo-2.3 (default) / Hailuo-2.3-Fast (fast mode, requires --first-frame)
170
+ SEF: Hailuo-02 (requires --first-frame and --last-frame)
171
+ S2V: S2V-01 (requires --subject-image)`,apiDocs:"/docs/api-reference/video-generation",usage:"mmx video generate --prompt <text> [flags]",options:[{flag:"--model <model>",description:"Model ID. T2V: MiniMax-Hailuo-2.3; I2V: MiniMax-Hailuo-2.3 (default) or MiniMax-Hailuo-2.3-Fast (fast, requires --first-frame). Auto-switched to Hailuo-02 with --last-frame, or S2V-01 with --subject-image."},{flag:"--prompt <text>",description:"Video description",required:!0},{flag:"--first-frame <path-or-url>",description:"First frame image (local path or URL). Auto base64-encoded for local files."},{flag:"--last-frame <path-or-url>",description:"Last frame image (local path or URL). Enables SEF (start-end frame) interpolation mode with Hailuo-02 model. Requires --first-frame."},{flag:"--subject-image <path-or-url>",description:"Subject reference image for character consistency (local path or URL). Switches to S2V-01 model."},{flag:"--callback-url <url>",description:"Webhook URL for completion notification"},{flag:"--download <path>",description:"Save video to file on completion"},{flag:"--no-wait",description:"Return task ID immediately without waiting"},{flag:"--async",description:"Return task ID immediately (agent/CI mode, same as --no-wait but explicit)"},{flag:"--poll-interval <seconds>",description:"Polling interval when waiting (default: 5)",type:"number"}],examples:['mmx video generate --prompt "A man reads a book. Static shot."','mmx video generate --prompt "Ocean waves at sunset." --download sunset.mp4','mmx video generate --prompt "A robot painting." --async --quiet','mmx video generate --prompt "A robot painting." --no-wait --quiet',"# SEF: first + last frame interpolation (uses Hailuo-02 model)",'mmx video generate --prompt "Walk forward" --first-frame start.jpg --last-frame end.jpg',"# Subject reference: character consistency (uses S2V-01 model)",'mmx video generate --prompt "A detective walking" --subject-image character.jpg'],async run(t,n){let i=n.prompt;if(i=await Kt({value:i,message:"Enter your video prompt:",cancelMessage:"Video generation cancelled.",flagName:"prompt",usageHint:"mmx video generate --prompt <text>",nonInteractive:t.nonInteractive}),n.lastFrame&&n.subjectImage)throw new s("--last-frame and --subject-image cannot be used together (SEF and S2V are different modes).",u.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");let r=n.model;if(r==="MiniMax-Hailuo-2.3-Fast"&&!n.firstFrame)throw new s("MiniMax-Hailuo-2.3-Fast only supports I2V (image-to-video). Use --first-frame to provide an input image.",u.USAGE,"mmx video generate --prompt <text> --model MiniMax-Hailuo-2.3-Fast --first-frame <image>");let o;if(r)o=r;else if(n.lastFrame)o="MiniMax-Hailuo-02";else if(n.subjectImage)o="S2V-01";else o=t.defaultVideoModel||"MiniMax-Hailuo-2.3";let m={model:o,prompt:i};if(n.firstFrame)m.first_frame_image=It(n.firstFrame);if(n.lastFrame){if(!n.firstFrame)throw new s("--last-frame requires --first-frame (SEF mode).",u.USAGE,"mmx video generate --prompt <text> --first-frame <path> --last-frame <path>");m.last_frame_image=It(n.lastFrame)}if(n.subjectImage)m.subject_reference=[{type:"character",image:[It(n.subjectImage)]}];if(n.callbackUrl)m.callback_url=n.callbackUrl;if(K(t,m))return;let e=A(t.output),$=te(t.baseUrl),x=(await T(t,{url:$,method:"POST",body:m})).task_id;if(!t.quiet)process.stderr.write(`[Model: ${o}]
172
+ `);if(n.noWait||t.async){process.stdout.write(JSON.stringify({taskId:x})),process.stdout.write(`
173
+ `);return}let y=n.pollInterval??5,_=lt(t.baseUrl,x),w=await mi(t,{url:_,intervalSec:y,timeoutSec:t.timeout,isComplete:(G)=>G.status==="Success",isFailed:(G)=>G.status==="Failed",getStatus:(G)=>G.status});if(!w.file_id)throw new s("Task completed but no file_id returned.",u.GENERAL);let S=(await T(t,{url:Bt(t.baseUrl,w.file_id)})).file?.download_url;if(!S)throw new s("No download URL available for this file.",u.GENERAL);if(n.download){let G=n.download,{size:yt}=await f(S,G,{quiet:t.quiet});if(t.quiet)console.log(G);else console.log(k({task_id:x,status:"Success",file_id:w.file_id,saved:G,size:Ut(yt)},e));return}let M=await import("os"),{join:R}=await import("path"),j=R(M.tmpdir(),"mmx-video"),{existsSync:B,mkdirSync:N}=await import("fs");if(!B(j))N(j,{recursive:!0});let Y=R(j,`${x}.mp4`);await f(S,Y,{quiet:t.quiet}),process.stdout.write(Y),process.stdout.write(`
174
+ `)}});var pi=v({name:"video task get",description:"Query video task status",usage:"mmx video task get --task-id <id>",options:[{flag:"--task-id <id>",description:"Video generation task ID"}],examples:["mmx video task get --task-id 106916112212032","mmx video task get --task-id 106916112212032 --output json"],async run(t,n){let i=n.taskId;if(!i)throw new s("--task-id is required.",u.USAGE,"mmx video task get --task-id <id>");if(t.dryRun){console.log(`Would query task: ${i}`);return}let r=lt(t.baseUrl,i),o=await T(t,{url:r}),m=A(t.output);if(t.quiet){console.log(o.status);return}console.log(k({task_id:o.task_id,status:o.status,file_id:o.file_id,video_width:o.video_width,video_height:o.video_height},m))}});var ui=v({name:"video download",description:"Download a completed video by file ID",usage:"mmx video download --file-id <id> --out <path>",options:[{flag:"--file-id <id>",description:"File ID to download"},{flag:"--out <path>",description:"Output file path"}],examples:["mmx video download --file-id 176844028768320 --out video.mp4","mmx video download --file-id 176844028768320 --out video.mp4 --quiet"],async run(t,n){let i=n.fileId;if(!i)throw new s("--file-id is required.",u.USAGE,"mmx video download --file-id <id> --out <path>");let r=n.out;if(!r)throw new s("--out is required.",u.USAGE,"mmx video download --file-id <id> --out video.mp4");if(t.dryRun){console.log(`Would download file ${i} to ${r}`);return}let o=Bt(t.baseUrl,i),e=(await T(t,{url:o})).file?.download_url;if(!e)throw new s("No download URL available for this file.",u.GENERAL,"The file may still be processing. Check task status first.");let{size:$}=await f(e,r,{quiet:t.quiet}),c=A(t.output);if(t.quiet){console.log(r);return}console.log(k({saved:r,size:Ut($)},c))}});at();function ci(t){return(t.apiKey??t.fileApiKey??"").startsWith("sk-cp-")}function si(t){if(t.defaultMusicModel)return t.defaultMusicModel;return ci(t)?"music-2.6":"music-2.6-free"}var Ho=new Set(["music-cover","music-cover-free"]);function xi(t){if(t.defaultMusicModel&&Ho.has(t.defaultMusicModel))return t.defaultMusicModel;return ci(t)?"music-cover":"music-cover-free"}var yi=v({name:"music generate",description:"Generate a song (music-2.6 / music-2.6-free / music-2.5+ / music-2.5)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music generate --prompt <text> (--lyrics <text> | --instrumental | --lyrics-optimizer) [--out <path>] [flags]",options:[{flag:"--prompt <text>",description:'Music style description (e.g. "cinematic orchestral, building tension"). Max 2000 chars when combined with structured flags.'},{flag:"--lyrics <text>",description:"Song lyrics with structure tags (newline separated). Supported: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo]. Tags must be clean — no descriptions inside brackets (they will be sung). Max 3500 chars."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin). Same tag rules as --lyrics."},{flag:"--lyrics-optimizer",description:"Auto-generate lyrics from prompt (cannot be used with --lyrics or --instrumental)"},{flag:"--instrumental",description:"Generate instrumental music (no vocals). music-2.6/music-2.5+: native is_instrumental flag; music-2.5: lyrics workaround. Cannot be used with --lyrics."},{flag:"--vocals <text>",description:'Vocal style, e.g. "warm male baritone", "bright female soprano", "duet with harmonies"'},{flag:"--genre <text>",description:"Music genre, e.g. folk, pop, jazz, electronic"},{flag:"--mood <text>",description:"Mood or emotion, e.g. warm, melancholic, uplifting"},{flag:"--instruments <text>",description:'Instruments to feature, e.g. "acoustic guitar, piano, strings"'},{flag:"--tempo <text>",description:"Tempo description, e.g. fast, slow, moderate"},{flag:"--bpm <number>",description:"Exact tempo in beats per minute",type:"number"},{flag:"--key <text>",description:"Musical key, e.g. C major, A minor, G sharp"},{flag:"--avoid <text>",description:"Elements to avoid in the generated music"},{flag:"--use-case <text>",description:'Use case context, e.g. "background music for video", "theme song"'},{flag:"--structure <text>",description:'Song structure, e.g. "verse-chorus-verse-bridge-chorus"'},{flag:"--references <text>",description:'Reference tracks or artists, e.g. "similar to Ed Sheeran"'},{flag:"--extra <text>",description:"Additional fine-grained requirements not covered above"},{flag:"--model <model>",description:"Model: music-2.6 (recommended), music-2.6-free (default, unlimited), music-2.5+, or music-2.5."},{flag:"--output-format <fmt>",description:"Return format: hex (default, saved to file) or url (24h expiry, download promptly). When --stream, only hex."},{flag:"--aigc-watermark",description:"Embed AI-generated content watermark in audio for content provenance"},{flag:"--format <fmt>",description:`Audio format: ${rt(st)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate (default: 256000)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file (uses hex decoding)"}],examples:['mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --out summer.mp3','mmx music generate --prompt "Indie folk, melancholic" --lyrics-file song.txt --out my_song.mp3',"# Auto-generate lyrics from prompt:",'mmx music generate --prompt "Upbeat pop about summer" --lyrics-optimizer --out summer.mp3',"# Instrumental:",'mmx music generate --prompt "Cinematic orchestral, building tension" --instrumental --out bgm.mp3',"# URL output (24h expiry — download promptly):",'mmx music generate --prompt "Upbeat pop" --lyrics "La la la..." --output-format url',"# Instrumental with music-2.5+:",'mmx music generate --prompt "Cinematic orchestral" --model "music-2.5+" --instrumental --out bgm.mp3',"# Detailed prompt with vocal characteristics:",'mmx music generate --prompt "Warm morning folk" --vocals "male and female duet, harmonies in chorus" --instruments "acoustic guitar, piano" --bpm 95 --lyrics-file song.txt --out duet.mp3'],async run(t,n){let{prompt:i,lyrics:r}=n,o=n.instrumental===!0,m=n.lyricsOptimizer===!0;if(n.lyricsFile)r=St(n.lyricsFile);if(o&&(r||n.lyricsFile))throw new s("Cannot use --instrumental with --lyrics or --lyrics-file.",u.USAGE,"mmx music generate --prompt <style> --instrumental");if(m&&(r||o))throw new s("Cannot use --lyrics-optimizer with --lyrics, --lyrics-file, or --instrumental.",u.USAGE,"mmx music generate --prompt <text> --lyrics-optimizer");if(!i&&!r&&!o&&!m)throw new s("At least one of --prompt or --lyrics is required.",u.USAGE,"mmx music generate --prompt <text> --lyrics <text>");if(!o&&!m&&!r?.trim())throw new s("Lyrics are required. Add --lyrics or --lyrics-file, or use --instrumental for pure music, or --lyrics-optimizer to auto-generate.",u.USAGE,"mmx music generate --prompt <text> --lyrics <text>");let e=[];if(n.vocals)e.push(`Vocals: ${n.vocals}`);if(n.genre)e.push(`Genre: ${n.genre}`);if(n.mood)e.push(`Mood: ${n.mood}`);if(n.instruments)e.push(`Instruments: ${n.instruments}`);if(n.tempo)e.push(`Tempo: ${n.tempo}`);if(n.bpm)e.push(`BPM: ${n.bpm}`);if(n.key)e.push(`Key: ${n.key}`);if(n.avoid)e.push(`Avoid: ${n.avoid}`);if(n.useCase)e.push(`Use case: ${n.useCase}`);if(n.structure)e.push(`Structure: ${n.structure}`);if(n.references)e.push(`References: ${n.references}`);if(n.extra)e.push(`Extra: ${n.extra}`);if(e.length>0){let j=e.join(". ");i=i?`${i}. ${j}`:j}let $=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),c=n.format||"mp3";xt(c,st);let x=n.out??`music_${$}.${c}`,y=n.model||si(t),_=["music-2.6","music-2.6-free","music-2.5+","music-2.5"];if(n.model&&!_.includes(y))throw new s(`Invalid model "${y}". Valid models: ${_.join(", ")}`,u.USAGE,"mmx music generate --model music-2.6");let w=n.outputFormat||"hex";if(w!=="hex"&&w!=="url")throw new s('--output-format must be "hex" or "url".',u.USAGE,"mmx music generate --output-format url");if(n.stream&&w==="url")throw new s("--stream and --output-format url cannot be used together. Streaming requires hex format.",u.USAGE,"mmx music generate --output-format url");let h={model:y,prompt:i,lyrics:r,is_instrumental:o||void 0,lyrics_optimizer:m||void 0,audio_setting:{format:n.format||"mp3",sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000},output_format:n.stream===!0?"hex":w,stream:n.stream===!0};if(n.aigcWatermark)h.aigc_watermark=!0;if(K(t,h))return;let S=A(t.output),M=qt(t.baseUrl);if(n.stream){let B=(await U(t,{url:M,method:"POST",body:h,stream:!0})).body?.getReader();if(!B)throw new s("No response body",u.GENERAL);while(!0){let{done:N,value:Y}=await B.read();if(N)break;process.stdout.write(Y)}B.releaseLock();return}let R=await T(t,{url:M,method:"POST",body:h});if(!t.quiet)process.stderr.write(`[Model: ${y}]
175
+ `);if(w==="url"){if(R.data?.audio_url)console.log(R.data.audio_url);else throw new s("Requested URL output but API did not return audio_url.",u.GENERAL);return}ct(R,x,S,t.quiet)}});import{readFileSync as Io}from"fs";var _i=v({name:"music cover",description:"Generate a cover version of a song based on reference audio (music-cover / music-cover-free)",apiDocs:"/docs/api-reference/music-generation",usage:"mmx music cover --prompt <text> (--audio <url> | --audio-file <path>) [--lyrics <text>] [--out <path>] [flags]",options:[{flag:"--model <model>",description:"Model: music-cover (Token Plan), music-cover-free (Pay-as-you-go, default). Override only if needed."},{flag:"--prompt <text>",description:'Target cover style, e.g. "Indie folk, acoustic guitar, warm male vocal"'},{flag:"--audio <url>",description:"URL of the reference audio (mp3, wav, flac, etc. — 6s to 6min, max 50MB)"},{flag:"--audio-file <path>",description:"Local reference audio file (auto base64-encoded)"},{flag:"--lyrics <text>",description:"Cover lyrics. If omitted, extracted from reference audio via ASR."},{flag:"--lyrics-file <path>",description:"Read lyrics from file (use - for stdin)"},{flag:"--seed <number>",description:"Random seed 0–1000000 for reproducible results",type:"number"},{flag:"--format <fmt>",description:`Audio format: ${rt(st)} (default: mp3)`},{flag:"--sample-rate <hz>",description:"Sample rate: 16000, 24000, 32000, 44100 (default: 44100)",type:"number"},{flag:"--bitrate <bps>",description:"Bitrate: 32000, 64000, 128000, 256000 (default: 256000)",type:"number"},{flag:"--channel <n>",description:"Channels: 1 (mono) or 2 (stereo, default)",type:"number"},{flag:"--stream",description:"Stream raw audio to stdout"},{flag:"--out <path>",description:"Save audio to file"}],examples:['mmx music cover --prompt "Indie folk, acoustic guitar, warm male vocal" --audio https://example.com/song.mp3 --out cover.mp3','mmx music cover --prompt "Jazz, piano, slow" --audio-file original.mp3 --lyrics-file lyrics.txt --out jazz_cover.mp3','mmx music cover --prompt "Pop, upbeat" --audio https://example.com/ref.mp3 --seed 42 --out reproducible.mp3'],async run(t,n){let{prompt:i,audio:r,audioFile:o}=n;if(!i)throw new s("--prompt is required.",u.USAGE,"mmx music cover --prompt <text> --audio <url>");if(!r&&!o)throw new s("One of --audio <url> or --audio-file <path> is required.",u.USAGE,"mmx music cover --prompt <text> --audio <url>");if(r&&o)throw new s("Use either --audio or --audio-file, not both.",u.USAGE);let m=n.lyrics;if(n.lyricsFile){let{readTextFromPathOrStdin:M}=await Promise.resolve().then(() => (at(),Pe));m=M(n.lyricsFile)}let e=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),$=n.format||"mp3";xt($,st);let c=n.out??`cover_${e}.${$}`,x=A(t.output),y=n.model||xi(t),_=["music-cover","music-cover-free"];if(n.model&&!_.includes(y))throw new s(`Invalid model "${y}". Valid models: ${_.join(", ")}`,u.USAGE,"mmx music cover --model music-cover");let w={model:y,prompt:i,lyrics:m,seed:n.seed,audio_setting:{format:$,sample_rate:n.sampleRate??44100,bitrate:n.bitrate??256000,channel:n.channel??void 0},output_format:"hex",stream:n.stream===!0};if(r)w.audio_url=r;else w.audio_base64=Io(o).toString("base64");if(t.dryRun){console.log(k({request:w},x));return}let h=qt(t.baseUrl);if(n.stream){let R=(await U(t,{url:h,method:"POST",body:w,stream:!0})).body?.getReader();if(!R)throw new s("No response body",u.GENERAL);while(!0){let{done:j,value:B}=await R.read();if(j)break;process.stdout.write(B)}R.releaseLock();return}let S=await T(t,{url:h,method:"POST",body:w});if(!t.quiet)process.stderr.write(`[Model: ${y}]
176
+ `);ct(S,c,x,t.quiet)}});var Nn=v({name:"search query",description:"Search the web via MiniMax",usage:"mmx search query --q <query>",options:[{flag:"--q <query>",description:"Search query string"}],examples:['mmx search query --q "MiniMax AI"','mmx search query --q "latest news" --output json'],async run(t,n){let i=n.q??n.query??n._positional?.[0];if(!i)throw new s("--q is required.",u.USAGE,'mmx search query --q "your search query"');let r=A(t.output);if(t.dryRun){console.log(k({request:{q:i}},r));return}let o=ne(t.baseUrl),m=await T(t,{url:o,method:"POST",body:{q:i}}),e=m.organic||[];if(r!=="text"){console.log(k(m,r));return}if(t.quiet){for(let $ of e)console.log(`${$.title} ${$.link}`);return}if(e.length===0){console.log("No results found.");return}for(let $ of e){if(console.log(`${$.title}`),console.log(` ${$.link}`),$.snippet)console.log(` ${$.snippet}`);if($.date)console.log(` ${$.date}`);console.log("")}}});var wi=v({name:"vision describe",description:"Describe an image using MiniMax VLM",usage:"mmx vision describe (--image <path-or-url> | --file-id <id>) [--prompt <text>]",options:[{flag:"--image <path-or-url>",description:"Local image path or URL (base64 encoded automatically)"},{flag:"--file-id <id>",description:"Pre-uploaded file ID (skips base64 conversion)"},{flag:"--prompt <text>",description:'Question about the image (default: "Describe the image.")'}],examples:["mmx vision describe --image photo.jpg",'mmx vision describe --image https://example.com/photo.jpg --prompt "What breed is this dog?"','mmx vision describe --file-id file-123456789 --prompt "Extract the text"'],async run(t,n){let i=n.image??n.file??n.path??n._positional?.[0],r=n.fileId,o=n.prompt||"Describe the image.";if(!i&&!r)if(Q({nonInteractive:t.nonInteractive})){let x=await it({message:"Enter image path, URL, or File ID:"});if(!x)process.stderr.write(`Vision describe cancelled.
177
+ `),process.exit(1);if(!x.includes(".")&&!x.startsWith("http"))r=x;else i=x}else throw new s("Missing required argument. Must provide either --image or --file-id.",u.USAGE,"mmx vision describe --image <path> OR --file-id <id>");else if(i&&r)throw new s("Conflicting arguments: cannot provide both --image and --file-id.",u.USAGE);if(K(t,{prompt:o,image:i,fileId:r}))return;let m=A(t.output),e=ee(t.baseUrl),$={prompt:o};if(r)$.file_id=r;else if(i){let x=await ni(i);$.image_url=x}let c=await T(t,{url:e,method:"POST",body:$});if(m!=="text"){process.stdout.write(k(c,m)+`
178
+ `);return}process.stdout.write(c.content+`
179
+ `)}});var hi=v({name:"quota show",description:"Display Token Plan usage and remaining quotas",usage:"mmx quota show",examples:["mmx quota show","mmx quota show --output json"],async run(t,n){if(t.dryRun){console.log("Would fetch quota information.");return}let i=D(t.baseUrl),r=await T(t,{url:i}),o=r.model_remains||[],m=A(n.output);if(m!=="text"){console.log(k(r,m));return}if(t.quiet){for(let e of o){let $=e.current_interval_total_count-e.current_interval_usage_count;console.log(`${e.model_name} ${e.current_interval_usage_count} ${e.current_interval_total_count} ${$}`)}return}pt(o,t)}});var bi=v({name:"config show",description:"Display current configuration",usage:"mmx config show",examples:["mmx config show","mmx config show --output json"],async run(t,n){let i=J(),r=A(t.output),o={region:t.region,base_url:t.baseUrl,output:t.output,timeout:t.timeout,config_file:I()};if(i.api_key)o.api_key=W(i.api_key);if(i.default_text_model)o.default_text_model=i.default_text_model;if(i.default_speech_model)o.default_speech_model=i.default_speech_model;if(i.default_video_model)o.default_video_model=i.default_video_model;if(i.default_music_model)o.default_music_model=i.default_music_model;if(i.proxy)o.proxy=i.proxy;console.log(k(o,r))}});var Si=["region","base_url","output","timeout","api_key","proxy","default_text_model","default_speech_model","default_video_model","default_music_model"],Po={"default-text-model":"default_text_model","default-speech-model":"default_speech_model","default-video-model":"default_video_model","default-music-model":"default_music_model"},Mi=v({name:"config set",description:"Set a config value",usage:"mmx config set --key <key> --value <value>",options:[{flag:"--key <key>",description:"Config key (region, base_url, output, timeout, api_key, proxy, default_text_model, default_speech_model, default_video_model, default_music_model)"},{flag:"--value <value>",description:"Value to set"}],examples:["mmx config set --key output --value json","mmx config set --key timeout --value 600","mmx config set --key proxy --value http://127.0.0.1:7890","mmx config set --key base_url --value https://api-uw.minimax.io"],async run(t,n){let i=n._positional,r=n.key??i?.[0],o=n.value??i?.[1];if(!r||o===void 0)throw new s("--key and --value are required.",u.USAGE,"mmx config set --key <key> --value <value>");let m=Po[r]||r;if(!Si.includes(m))throw new s(`Invalid config key "${r}". Valid keys: ${Si.join(", ")}`,u.USAGE);if(m==="region"&&!["global","cn"].includes(o))throw new s(`Invalid region "${o}". Valid values: global, cn`,u.USAGE);if(m==="output"&&!["text","json"].includes(o))throw new s(`Invalid output format "${o}". Valid values: text, json`,u.USAGE);if(m==="base_url"&&!o.startsWith("http"))throw new s(`Invalid base_url "${o}". Must start with http.`,u.USAGE);if(m==="proxy"&&!o.startsWith("http"))throw new s(`Invalid proxy "${o}". Must be a URL starting with http (e.g. http://127.0.0.1:7890).`,u.USAGE);if(m==="timeout"){let c=Number(o);if(isNaN(c)||c<=0)throw new s(`Invalid timeout "${o}". Must be a positive number.`,u.USAGE)}let e=A(t.output);if(t.dryRun){console.log(k({would_set:{[m]:o}},e));return}let $=J();if($[m]=m==="timeout"?Number(o):o,m==="api_key")delete $.region;if(await a($),!t.quiet)console.log(k({[m]:$[m]},e))}});function Co(t){let n=t.match(/^--([a-zA-Z0-9-]+)/),i=n?n[1]:"",r=i.replace(/-([a-zA-Z0-9])/g,(e,$)=>$.toUpperCase()),o="string",m=!1;if(!t.includes("<")&&!t.includes("["))o="boolean";else if(t.includes("<n>")||t.includes("<hz>")||t.includes("<bps>")||t.includes("<count>"))o="number";if(t.toLowerCase().includes("repeatable"))m=!0;return{name:r,kebabName:i,inferredType:o,isArray:m}}function Yn(t){let i={name:`mmx_${t.name.replace(/ /g,"_")}`,description:t.description,input_schema:{type:"object",properties:{},required:[]}};if(t.options)for(let r of t.options){let{name:o,inferredType:m,isArray:e}=Co(r.flag);if(!o)continue;let $=r.type,c=e?"array":$??m,x={description:r.description};if(c==="array")x.type="array",x.items={type:"string"};else x.type=c;let y=i.input_schema;if(y.properties[o]=x,r.required)y.required.push(o)}return i}var Lo=["auth ","config ","update"],vi=v({name:"config export-schema",description:"Export all (or one) CLI command(s) as Anthropic/OpenAI-compatible JSON tool schemas",usage:'mmx config export-schema [--command "<name>"]',options:[{flag:"--command <name>",description:'Export schema for a specific command only (e.g. "image generate")'}],examples:["mmx config export-schema",'mmx config export-schema --command "video generate"'],async run(t,n){let i=n.command;if(i){try{let{command:m}=F.resolve(i.split(" ")),e=Yn(m);process.stdout.write(JSON.stringify(e,null,2)+`
180
+ `)}catch{throw new s(`Command "${i}" not found.`,u.USAGE)}return}let o=F.getAllCommands().filter((m)=>!Lo.some((e)=>m.name.startsWith(e))).map((m)=>Yn(m));process.stdout.write(JSON.stringify(o,null,2)+`
181
+ `)}});var ki=v({name:"update",description:"Update mmx to the latest version",usage:"mmx update",examples:["mmx update"],async run(){process.stderr.write(`Current version: ${g}
174
182
 
175
183
  `),process.stderr.write(`Run:
176
184
  `),process.stderr.write(` npm update -g mmx-cli
177
185
 
178
- `)}});var Ho=[{command:"mmx text chat",title:"Text Generation (Chat Completion)",path:"/docs/api-reference/text-post"},{command:"mmx speech synthesize",title:"Speech T2A (Text-to-Audio)",path:"/docs/api-reference/speech-t2a-http"},{command:"mmx image generate",title:"Image Generation (T2I / I2I)",path:"/docs/api-reference/image-generation-t2i"},{command:"mmx video generate",title:"Video Generation (T2V / I2V / S2V)",path:"/docs/api-reference/video-generation"},{command:"mmx music generate",title:"Music Generation",path:"/docs/api-reference/music-generation"},{command:"mmx music cover",title:"Music Cover (via Music Generation)",path:"/docs/api-reference/music-generation"},{command:"mmx search query",title:"Web Search",path:"/docs/api-reference/web-search"},{command:"mmx vision describe",title:"Vision (Image Understanding)",path:"/docs/api-reference/vision"}],mi=l({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(t,e){let i=xt[t.region]||xt.global;process.stdout.write(`
186
+ `)}});var Eo=[{command:"mmx text chat",title:"Text Generation (Chat Completion)",path:"/docs/api-reference/text-post"},{command:"mmx speech synthesize",title:"Speech T2A (Text-to-Audio)",path:"/docs/api-reference/speech-t2a-http"},{command:"mmx image generate",title:"Image Generation (T2I / I2I)",path:"/docs/api-reference/image-generation-t2i"},{command:"mmx video generate",title:"Video Generation (T2V / I2V / S2V)",path:"/docs/api-reference/video-generation"},{command:"mmx music generate",title:"Music Generation",path:"/docs/api-reference/music-generation"},{command:"mmx music cover",title:"Music Cover (via Music Generation)",path:"/docs/api-reference/music-generation"},{command:"mmx search query",title:"Web Search",path:"/docs/api-reference/web-search"},{command:"mmx vision describe",title:"Vision (Image Understanding)",path:"/docs/api-reference/vision"}],Ai=v({name:"help",description:"Show MiniMax API documentation links",usage:"mmx help",async run(t,n){let i=_t[t.region]||_t.global;process.stdout.write(`
179
187
  MiniMax API Documentation Links
180
188
 
181
189
  Official docs: ${i}/docs/api-reference
182
190
 
183
- `);for(let r of Ho)process.stdout.write(` ${r.command.padEnd(30)} ${r.title}
191
+ `);for(let r of Eo)process.stdout.write(` ${r.command.padEnd(30)} ${r.title}
184
192
  `),process.stdout.write(` ${" ".repeat(30)} ${i}${r.path}
185
193
 
186
- `)}});class pi{root={children:new Map};constructor(t){for(let[e,i]of Object.entries(t))this.register(e,i)}register(t,e){let i=t.split(" "),r=this.root;for(let o of i){if(!r.children.has(o))r.children.set(o,{children:new Map});r=r.children.get(o)}r.command=e}getAllCommands(){let t=[],e=(i)=>{if(i.command)t.push(i.command);for(let r of i.children.values())e(r)};return e(this.root),t}resolve(t){let e=this.root,i=[];for(let r of t){let o=e.children.get(r);if(!o)break;e=o,i.push(r)}if(e.command)return{command:e.command,extra:t.slice(i.length)};if(i.length>0&&e.children.size===1){let[,r]=e.children.entries().next().value;if(r.command)return{command:r.command,extra:t.slice(i.length)}}if(i.length>0&&e.children.size>0){let r=Array.from(e.children.entries()).map(([o,$])=>{if($.command)return` ${i.join(" ")} ${o} ${$.command.description}`;let n=Array.from($.children.keys()).join(", ");return` ${i.join(" ")} ${o} [${n}]`}).join(`
187
- `);throw new y(`Unknown command: mmx ${t.join(" ")}
194
+ `)}});class Ri{root={children:new Map};constructor(t){for(let[n,i]of Object.entries(t))this.register(n,i)}register(t,n){let i=t.split(" "),r=this.root;for(let o of i){if(!r.children.has(o))r.children.set(o,{children:new Map});r=r.children.get(o)}r.command=n}getAllCommands(){let t=[],n=(i)=>{if(i.command)t.push(i.command);for(let r of i.children.values())n(r)};return n(this.root),t}resolve(t){let n=this.root,i=[];for(let r of t){let o=n.children.get(r);if(!o)break;n=o,i.push(r)}if(n.command)return{command:n.command,extra:t.slice(i.length)};if(i.length>0&&n.children.size===1){let[,r]=n.children.entries().next().value;if(r.command)return{command:r.command,extra:t.slice(i.length)}}if(i.length>0&&n.children.size>0){let r=Array.from(n.children.entries()).map(([o,m])=>{if(m.command)return` ${i.join(" ")} ${o} ${m.command.description}`;let e=Array.from(m.children.keys()).join(", ");return` ${i.join(" ")} ${o} [${e}]`}).join(`
195
+ `);throw new s(`Unknown command: mmx ${t.join(" ")}
188
196
 
189
197
  Available commands:
190
- ${r}`,u.USAGE,`mmx ${i.join(" ")} --help`)}throw new y(`Unknown command: mmx ${t.join(" ")}`,u.USAGE,"mmx --help")}bold=(t,e)=>e.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,e)=>e.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,e)=>e.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,e=process.stdout,i="global"){if(t.length===0){this.printRootHelp(e);return}let r=this.root;for(let $ of t){let n=r.children.get($);if(!n){this.printRootHelp(e);return}r=n}if(r.command){this.printCommandHelp(r.command,e,i);return}let o=t.join(" ");e.write(`
191
- ${this.bold("Usage:",e)} mmx ${o} <command> [flags]
198
+ ${r}`,u.USAGE,`mmx ${i.join(" ")} --help`)}throw new s(`Unknown command: mmx ${t.join(" ")}`,u.USAGE,"mmx --help")}bold=(t,n)=>n.isTTY?`\x1B[1m${t}\x1B[0m`:t;accent=(t,n)=>n.isTTY?`\x1B[38;2;248;103;58m${t}\x1B[0m`:t;dim=(t,n)=>n.isTTY?`\x1B[2m${t}\x1B[0m`:t;printHelp(t,n=process.stdout,i="global"){if(t.length===0){this.printRootHelp(n);return}let r=this.root;for(let m of t){let e=r.children.get(m);if(!e){this.printRootHelp(n);return}r=e}if(r.command){this.printCommandHelp(r.command,n,i);return}let o=t.join(" ");n.write(`
199
+ ${this.bold("Usage:",n)} mmx ${o} <command> [flags]
192
200
 
193
- `),e.write(`${this.bold("Commands:",e)}
194
- `),this.printChildren(r,o,e),e.write(`
195
- `)}printRootHelp(t){let e=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],i=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
196
- `);for(let n=0;n<e.length;n++)if(t.isTTY){let[m,s,c]=i[n];t.write(`\x1B[1;38;2;${m};${s};${c}m${e[n]}\x1B[0m
197
- `)}else t.write(e[n]+`
198
- `);let r=(n)=>this.bold(n,t),o=(n)=>this.accent(n,t),$=(n)=>this.dim(n,t);t.write(`
201
+ `),n.write(`${this.bold("Commands:",n)}
202
+ `),this.printChildren(r,o,n),n.write(`
203
+ `)}printRootHelp(t){let n=["███╗ ███╗███╗ ███╗██╗ ██╗","████╗ ████║████╗ ████║╚██╗██╔╝","██╔████╔██║██╔████╔██║ ╚███╔╝ ","██║╚██╔╝██║██║╚██╔╝██║ ██╔██╗ ","██║ ╚═╝ ██║██║ ╚═╝ ██║██╔╝ ██╗","╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝"],i=[[240,23,122],[242,43,106],[244,63,90],[246,83,74],[248,103,58],[250,123,42]];t.write(`
204
+ `);for(let e=0;e<n.length;e++)if(t.isTTY){let[$,c,x]=i[e];t.write(`\x1B[1;38;2;${$};${c};${x}m${n[e]}\x1B[0m
205
+ `)}else t.write(n[e]+`
206
+ `);let r=(e)=>this.bold(e,t),o=(e)=>this.accent(e,t),m=(e)=>this.dim(e,t);t.write(`
199
207
  ${r("Usage:")} mmx <resource> <command> [flags]
200
208
 
201
209
  ${r("Resources:")}
202
- ${o("auth")} ${$("Authentication (login, status, refresh, logout)")}
203
- ${o("text")} ${$("Text generation (chat)")}
204
- ${o("speech")} ${$("Speech synthesis (synthesize, voices)")}
205
- ${o("image")} ${$("Image generation (generate)")}
206
- ${o("video")} ${$("Video generation (generate, task get, download)")}
207
- ${o("music")} ${$("Music generation (generate, cover)")}
208
- ${o("search")} ${$("Web search (query)")}
209
- ${o("vision")} ${$("Image understanding (describe)")}
210
- ${o("quota")} ${$("Usage quotas (show)")}
211
- ${o("config")} ${$("CLI configuration (show, set, export-schema)")}
212
- ${o("update")} ${$("Update mmx to a newer version")}
210
+ ${o("auth")} ${m("Authentication (login, status, refresh, logout)")}
211
+ ${o("text")} ${m("Text generation (chat)")}
212
+ ${o("speech")} ${m("Speech synthesis (synthesize, voices)")}
213
+ ${o("image")} ${m("Image generation (generate)")}
214
+ ${o("video")} ${m("Video generation (generate, task get, download)")}
215
+ ${o("music")} ${m("Music generation (generate, cover)")}
216
+ ${o("search")} ${m("Web search (query)")}
217
+ ${o("vision")} ${m("Image understanding (describe)")}
218
+ ${o("quota")} ${m("Usage quotas (show)")}
219
+ ${o("config")} ${m("CLI configuration (show, set, export-schema)")}
220
+ ${o("update")} ${m("Update mmx to a newer version")}
213
221
 
214
222
  ${r("Global Flags:")}
215
- ${o("--api-key <key>")} ${$("API key (overrides all other auth)")}
216
- ${o("--region <region>")} ${$("API region: global (default), cn")}
217
- ${o("--base-url <url>")} ${$("API base URL (overrides region)")}
218
- ${o("--output <format>")} ${$("Output format: text, json")}
219
- ${o("--quiet")} ${$("Suppress non-essential output")}
220
- ${o("--verbose")} ${$("Print HTTP request/response details")}
221
- ${o("--timeout <seconds>")} ${$("Request timeout (default: 300)")}
222
- ${o("--no-color")} ${$("Disable ANSI colors and spinners")}
223
- ${o("--dry-run")} ${$("Show what would happen without executing")}
224
- ${o("--non-interactive")} ${$("Disable interactive prompts (CI/agent mode)")}
225
- ${o("--version")} ${$("Print version and exit")}
226
- ${o("--help")} ${$("Show help")}
223
+ ${o("--api-key <key>")} ${m("API key (overrides all other auth)")}
224
+ ${o("--region <region>")} ${m("API region: global (default), cn")}
225
+ ${o("--base-url <url>")} ${m("API base URL (overrides region)")}
226
+ ${o("--output <format>")} ${m("Output format: text, json")}
227
+ ${o("--quiet")} ${m("Suppress non-essential output")}
228
+ ${o("--verbose")} ${m("Print HTTP request/response details")}
229
+ ${o("--timeout <seconds>")} ${m("Request timeout (default: 300)")}
230
+ ${o("--no-color")} ${m("Disable ANSI colors and spinners")}
231
+ ${o("--dry-run")} ${m("Show what would happen without executing")}
232
+ ${o("--non-interactive")} ${m("Disable interactive prompts (CI/agent mode)")}
233
+ ${o("--version")} ${m("Print version and exit")}
234
+ ${o("--help")} ${m("Show help")}
227
235
 
228
236
  ${r("Getting Help:")}
229
- ${$("Add --help after any command to see its full list of options, defaults,")}
230
- ${$("and usage examples. For example:")} mmx text chat --help
231
- `)}printCommandHelp(t,e,i="global"){let r=(n)=>this.bold(n,e),o=(n)=>this.accent(n,e),$=(n)=>this.dim(n,e);if(e.write(`
237
+ ${m("Add --help after any command to see its full list of options, defaults,")}
238
+ ${m("and usage examples. For example:")} mmx text chat --help
239
+ `)}printCommandHelp(t,n,i="global"){let r=(e)=>this.bold(e,n),o=(e)=>this.accent(e,n),m=(e)=>this.dim(e,n);if(n.write(`
232
240
  ${t.description}
233
- `),t.usage)e.write(`${r("Usage:")} ${t.usage}
234
- `);if(t.options&&t.options.length>0){let n=Math.max(...t.options.map((m)=>m.flag.length));e.write(`
241
+ `),t.usage)n.write(`${r("Usage:")} ${t.usage}
242
+ `);if(t.options&&t.options.length>0){let e=Math.max(...t.options.map(($)=>$.flag.length));n.write(`
235
243
  ${r("Options:")}
236
- `);for(let m of t.options)e.write(` ${o(m.flag.padEnd(n+2))} ${$(m.description)}
237
- `)}if(t.examples&&t.examples.length>0){e.write(`
244
+ `);for(let $ of t.options)n.write(` ${o($.flag.padEnd(e+2))} ${m($.description)}
245
+ `)}if(t.examples&&t.examples.length>0){n.write(`
238
246
  ${r("Examples:")}
239
- `);for(let n of t.examples)e.write(` ${$(n)}
240
- `)}if(t.apiDocs)e.write(`
241
- ${r("API Reference:")} ${$(xt[i]+t.apiDocs)}
242
- `);e.write(`
243
- ${$("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
244
- `),e.write(`${$("Run")} mmx --help ${$("for the full list.")}
245
- `)}printChildren(t,e,i){let r=[],o=(n,m)=>{for(let[s,c]of n.children){if(c.command)r.push({fullName:`${m} ${s}`,description:c.command.description});if(c.children.size>0)o(c,`${m} ${s}`)}};o(t,e);let $=Math.max(...r.map((n)=>n.fullName.length));for(let{fullName:n,description:m}of r)i.write(` ${this.accent(n.padEnd($),i)} ${this.dim(m,i)}
246
- `)}}var D=new pi({"auth login":Xn,"auth status":Qn,"auth refresh":On,"auth logout":Yn,"text chat":Zn,"speech synthesize":be,"speech generate":be,"speech voices":dn,"image generate":an,"video generate":Pn,"video task get":Cn,"video download":Ln,"music generate":gn,"music cover":Dn,"search query":ke,"search web":ke,"vision describe":ti,"quota show":ei,"config show":ni,"config set":ri,"config export-schema":oi,update:$i,help:mi});function ot(t){if(t instanceof y){if(S(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
247
+ `);for(let e of t.examples)n.write(` ${m(e)}
248
+ `)}if(t.apiDocs)n.write(`
249
+ ${r("API Reference:")} ${m(_t[i]+t.apiDocs)}
250
+ `);n.write(`
251
+ ${m("Global flags (--api-key, --output, --quiet, etc.) are always available.")}
252
+ `),n.write(`${m("Run")} mmx --help ${m("for the full list.")}
253
+ `)}printChildren(t,n,i){let r=[],o=(e,$)=>{for(let[c,x]of e.children){if(x.command)r.push({fullName:`${$} ${c}`,description:x.command.description});if(x.children.size>0)o(x,`${$} ${c}`)}};o(t,n);let m=Math.max(...r.map((e)=>e.fullName.length));for(let{fullName:e,description:$}of r)i.write(` ${this.accent(e.padEnd(m),i)} ${this.dim($,i)}
254
+ `)}}var F=new Ri({"auth login":de,"auth status":Ke,"auth refresh":ae,"auth logout":Ue,"text chat":Ie,"speech synthesize":Bn,"speech generate":Bn,"speech voices":Ee,"image generate":oi,"video generate":$i,"video task get":pi,"video download":ui,"music generate":yi,"music cover":_i,"search query":Nn,"search web":Nn,"vision describe":wi,"quota show":hi,"config show":bi,"config set":Mi,"config export-schema":vi,update:ki,help:Ai});function ot(t){if(t instanceof s){if(A(process.env.MINIMAX_OUTPUT)==="json")process.stderr.write(JSON.stringify(t.toJSON(),null,2)+`
247
255
  `);else{if(process.stderr.write(`
248
256
  Error: ${t.message}
249
257
  `),t.hint)process.stderr.write(`
@@ -251,29 +259,32 @@ Error: ${t.message}
251
259
  `).join(`
252
260
  `)}
253
261
  `);process.stderr.write(` (exit code ${t.exitCode})
254
- `)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.name==="TimeoutError"||t.message.includes("timed out")){let o=new y("Request timed out.",u.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
262
+ `)}process.exit(t.exitCode)}if(t instanceof Error){if(t.name==="AbortError"||t.name==="TimeoutError"||t.message.includes("timed out")){let o=new s("Request timed out.",u.TIMEOUT,`Try increasing --timeout (e.g. --timeout 60).
255
263
  If this happens on every request with a valid API key, you may be hitting the wrong region.
256
264
  `+`Run: mmx auth status — to check your credentials and region.
257
- `+"Run: mmx config set region global (or cn) — to override the region.");return ot(o)}if(t instanceof TypeError&&t.message==="fetch failed"){let o=new y("Network request failed.",u.NETWORK,"Check your network connection and proxy settings. Also verify MINIMAX_BASE_URL is a valid URL.");return ot(o)}let e=t.message.toLowerCase();if(e.includes("failed to fetch")||e.includes("connection refused")||e.includes("econnrefused")||e.includes("connection reset")||e.includes("econnreset")||e.includes("network error")||e.includes("enotfound")||e.includes("getaddrinfo")||e.includes("proxy")||e.includes("socket")||e.includes("etimedout")||e.includes("timeout")||e.includes("eai_AGAIN")){let o="Check your network connection and proxy settings.";if(e.includes("proxy"))o="Proxy error — check HTTP_PROXY / HTTPS_PROXY environment variables and proxy authentication.";let $=new y("Network request failed.",u.NETWORK,o);return ot($)}let r=t.code;if(r==="ENOENT"||r==="EACCES"||r==="ENOSPC"||r==="ENOTDIR"||r==="EISDIR"||r==="EPERM"||r==="EBUSY"){let o="Check the file path and permissions.";if(r==="ENOENT")o="File or directory not found.";if(r==="EACCES"||r==="EPERM")o="Permission denied — check file or directory permissions.";if(r==="ENOSPC")o="Disk full — free up space and try again.";let $=new y(`File system error: ${t.message}`,u.GENERAL,o);return ot($)}else if(typeof r==="string"&&r.startsWith("E")){let o=new y(`File system error: ${t.message}`,u.GENERAL,"Check the file path and permissions.");return ot(o)}if(process.stderr.write(`
265
+ `+"Run: mmx config set region global (or cn) — to override the region.");return ot(o)}if(t instanceof TypeError&&t.message==="fetch failed"){let o=new s("Network request failed.",u.NETWORK,`Check your network connection.
266
+ To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`);return ot(o)}let n=t.message.toLowerCase();if(n.includes("failed to fetch")||n.includes("connection refused")||n.includes("econnrefused")||n.includes("connection reset")||n.includes("econnreset")||n.includes("network error")||n.includes("enotfound")||n.includes("getaddrinfo")||n.includes("proxy")||n.includes("socket")||n.includes("etimedout")||n.includes("timeout")||n.includes("eai_AGAIN")){let o=`Check your network connection.
267
+ To use a proxy: set HTTPS_PROXY env var, or run: mmx config set --key proxy --value http://HOST:PORT`;if(n.includes("proxy"))o=`Proxy connection failed — verify your proxy URL and authentication.
268
+ `+"Check: HTTPS_PROXY / HTTP_PROXY env vars, or mmx config show for configured proxy.";let m=new s("Network request failed.",u.NETWORK,o);return ot(m)}let r=t.code;if(r==="ENOENT"||r==="EACCES"||r==="ENOSPC"||r==="ENOTDIR"||r==="EISDIR"||r==="EPERM"||r==="EBUSY"){let o="Check the file path and permissions.";if(r==="ENOENT")o="File or directory not found.";if(r==="EACCES"||r==="EPERM")o="Permission denied — check file or directory permissions.";if(r==="ENOSPC")o="Disk full — free up space and try again.";let m=new s(`File system error: ${t.message}`,u.GENERAL,o);return ot(m)}else if(typeof r==="string"&&r.startsWith("E")){let o=new s(`File system error: ${t.message}`,u.GENERAL,"Check the file path and permissions.");return ot(o)}if(process.stderr.write(`
258
269
  Error: ${t.message}
259
270
  `),process.env.MINIMAX_VERBOSE==="1")process.stderr.write(`${t.stack}
260
271
  `)}else process.stderr.write(`
261
272
  Error: ${String(t)}
262
- `);process.exit(u.GENERAL)}var Uo="/v1/token_plan/remains";function ao(t){return C[t]+Uo}async function Io(t,e,i){let r=[{Authorization:`Bearer ${e}`},{"x-api-key":e}];for(let o of r)try{let $=await fetch(ao(t),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(i)});if(!$.ok)continue;if((await $.json()).base_resp?.status_code===0)return!0}catch{}return!1}async function si(t){process.stderr.write("Detecting region...");let e=Object.keys(C),r=(await Promise.all(e.map(async($)=>({region:$,ok:await Io($,t,5000)})))).find(($)=>$.ok);if(!r)return process.stderr.write(` failed
273
+ `);process.exit(u.GENERAL)}var fo="/v1/token_plan/remains";function Fo(t){return H[t]+fo}async function go(t,n,i){let r=[{Authorization:`Bearer ${n}`},{"x-api-key":n}];for(let o of r)try{let m=await fetch(Fo(t),{headers:{...o,"Content-Type":"application/json"},signal:AbortSignal.timeout(i)});if(!m.ok)continue;if((await m.json()).base_resp?.status_code===0)return!0}catch{}return!1}async function ji(t){process.stderr.write("Detecting region...");let n=Object.keys(H),r=(await Promise.all(n.map(async(m)=>({region:m,ok:await go(m,t,5000)})))).find((m)=>m.ok);if(!r)return process.stderr.write(` failed
263
274
  `),process.stderr.write(`Warning: API key failed validation against all regions (global, cn).
264
275
  This usually means the API key is invalid or the network is blocking requests.
265
276
  Falling back to 'global'. Subsequent requests may fail.
266
277
  Run 'mmx auth status' to verify your credentials.
267
278
  `),"global";let o=r.region;return process.stderr.write(` ${o}
268
- `),o}async function ci(t){let e=Q();e.region=t,await H(e)}import{join as Po}from"path";import{readFileSync as Co,writeFileSync as Lo}from"fs";var ui=()=>Po(wt(),"update-state.json"),Eo=86400000,fo=3000,Fo="MiniMax-AI-Dev/minimax-cli";function go(){try{let t=Co(ui(),"utf-8");return JSON.parse(t)}catch{return null}}function Do(t){try{Lo(ui(),JSON.stringify(t))}catch{}}async function t$(){try{let t=await fetch(`https://api.github.com/repos/${Fo}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(fo)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var Me=null;function yi(){return Me}async function xi(t){if(process.env.CI||!process.stderr.isTTY)return;let e=go(),i=Date.now();if(e&&i-e.lastChecked<Eo){if(e.latestVersion&&e.latestVersion!==`v${t}`)Me=e.latestVersion;return}let r=await t$();if(!r)return;if(Do({lastChecked:i,latestVersion:r}),r!==`v${t}`)Me=r}async function wi(t){if(t.apiKey||t.fileApiKey)return;let e=process.env.MINIMAX_API_KEY,i;if(e){if(!J({nonInteractive:t.nonInteractive}))i=e;else if(await Vn({message:`Found MINIMAX_API_KEY in environment (${W(e)}). Save it to config file?`}))i=e}if(!i){if(!J({nonInteractive:t.nonInteractive}))throw new y("No API key found.",u.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
269
- Pass directly: --api-key sk-xxxxx`);let $=await U({message:"Enter your MiniMax API key:"});if(!$)throw new y("API key is required.",u.AUTH);i=$}let r={...Q(),api_key:i};await H(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
270
- `)}var _i="1.0.11";process.on("SIGINT",()=>{process.stderr.write(`
279
+ `),o}async function Ti(t){let n=J();n.region=t,await a(n)}import{join as Do}from"path";import{readFileSync as tm,writeFileSync as nm}from"fs";var Gi=()=>Do(wt(),"update-state.json"),em=86400000,im=3000,rm="MiniMax-AI-Dev/minimax-cli";function om(){try{let t=tm(Gi(),"utf-8");return JSON.parse(t)}catch{return null}}function mm(t){try{nm(Gi(),JSON.stringify(t))}catch{}}async function $m(){try{let t=await fetch(`https://api.github.com/repos/${rm}/releases/latest`,{headers:{Accept:"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28"},signal:AbortSignal.timeout(im)});if(!t.ok)return null;return(await t.json()).tag_name??null}catch{return null}}var Xn=null;function li(){return Xn}async function Bi(t){if(process.env.CI||!process.stderr.isTTY)return;let n=om(),i=Date.now();if(n&&i-n.lastChecked<em){if(n.latestVersion&&n.latestVersion!==`v${t}`)Xn=n.latestVersion;return}let r=await $m();if(!r)return;if(mm({lastChecked:i,latestVersion:r}),r!==`v${t}`)Xn=r}async function qi(t){if(t.apiKey||t.fileApiKey)return;let n=process.env.MINIMAX_API_KEY,i;if(n){if(!Q({nonInteractive:t.nonInteractive}))i=n;else if(await He({message:`Found MINIMAX_API_KEY in environment (${W(n)}). Save it to config file?`}))i=n}if(!i){if(!Q({nonInteractive:t.nonInteractive}))throw new s("No API key found.",u.AUTH,`Set env var: export MINIMAX_API_KEY=sk-xxxxx
280
+ Pass directly: --api-key sk-xxxxx`);let m=await it({message:"Enter your MiniMax API key:"});if(!m)throw new s("API key is required.",u.AUTH);i=m}let r={...J(),api_key:i};await a(r),t.fileApiKey=i;let o=t.configPath??"~/.mmx/config.json";process.stderr.write(`API key saved to ${o}
281
+ `)}import{ProxyAgent as pm,setGlobalDispatcher as um}from"undici";process.on("SIGINT",()=>{process.stderr.write(`
271
282
  Interrupted. Exiting.
272
- `),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var e$=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function n$(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${_i}`),process.exit(0);let e=Be(t,Rt);if(t.includes("--help")||t.includes("-h")){let c=t.indexOf("--region"),x=c>=0&&t[c+1]||process.env.MINIMAX_REGION||Q().region||"global";D.printHelp(e,process.stderr,x),process.exit(0)}if(e.length===0){D.printHelp([],process.stderr);let{command:c}=D.resolve(["quota","show"]),x=at(t,[...Rt,...c.options??[]]),w=ft(x),h=!!(w.apiKey||w.fileApiKey),_=!!await d();if(h||_)await c.execute(w,x);else process.stderr.write(` Not logged in.
283
+ `),process.exit(130)});process.stdout.on("error",(t)=>{if(t.code==="EPIPE")process.exit(0);else throw t});var cm=[["auth","login"],["auth","logout"],["config","show"],["config","set"],["config","export-schema"],["update"]];async function sm(){let t=process.argv.slice(2);if(t.includes("--version")||t.includes("-v"))console.log(`mmx ${g}`),process.exit(0);let n=Zn(t,Rt),i=J(),r=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||i.proxy;if(r)um(new pm(r));if(t.includes("--help")||t.includes("-h")){let _=t.indexOf("--region"),w=_>=0&&t[_+1]||process.env.MINIMAX_REGION||i.region||"global";F.printHelp(n,process.stderr,w),process.exit(0)}if(n.length===0){F.printHelp([],process.stderr);let{command:_}=F.resolve(["quota","show"]),w=gt(t,[...Rt,..._.options??[]]),h=on(w),S=!!(h.apiKey||h.fileApiKey),M=!!await z();if(S||M)await _.execute(h,w);else process.stderr.write(` Not logged in.
273
284
  `),process.stderr.write(` mmx auth login --api-key sk-xxxxx
274
285
 
275
- `);process.exit(0)}let{command:i,extra:r}=D.resolve(e),o=at(t,[...Rt,...i.options??[]]);if(r.length>0)o._positional=r;let $=ft(o);if(!e$.some((c)=>c.every((x,w)=>e[w]===x)))await wi($);if($.needsRegionDetection){let c=$.apiKey||$.fileApiKey;if(c){let x=await si(c);$.region=x,$.baseUrl=C[x],$.needsRegionDetection=!1,await ci(x)}}let m=xi(_i).catch(()=>{});await i.execute($,o),await m;let s=yi();if(s&&!$.quiet)process.stderr.write(`
276
- Update available: ${s}
286
+ `);process.exit(0)}let{command:o,extra:m}=F.resolve(n),e=gt(t,[...Rt,...o.options??[]]);if(m.length>0)e._positional=m;let $=on(e);if(!cm.some((_)=>_.every((w,h)=>n[h]===w)))await qi($);if($.needsRegionDetection){let _=$.apiKey||$.fileApiKey;if(_){let w=await ji(_);$.region=w,$.baseUrl=H[w],$.needsRegionDetection=!1,await Ti(w)}}let x=Bi(g).catch(()=>{});await o.execute($,e),await x;let y=li();if(y&&!$.quiet)process.stderr.write(`
287
+ Update available: ${y}
277
288
  `),process.stderr.write(` npm update -g mmx-cli
278
289
 
279
- `)}n$().catch(ot);
290
+ `)}sm().catch(ot);