aicommits 1.12.0-develop.4 → 1.12.0-develop.6

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.mjs +73 -73
  3. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1,101 +1,101 @@
1
1
  #!/usr/bin/env node
2
- var Pl=Object.defineProperty;var o=(e,t)=>Pl(e,"name",{value:t,configurable:!0});var ot,at,ct,lt,Dt,dt,ht,ft,pt,mt,Ft;import Tl from"tty";import Nl from"update-notifier";import{Buffer as Ml}from"node:buffer";import Me from"node:path";import io,{ChildProcess as Ll}from"node:child_process";import j,{stdin as oo,stdout as ao}from"node:process";import jl,{execSync as Ul}from"child_process";import ae from"path";import Us from"fs";import{fileURLToPath as co}from"node:url";import Wl,{constants as lo}from"node:os";import ql from"assert";import Gl from"events";import{createWriteStream as Kl,createReadStream as Hl}from"node:fs";import zl from"buffer";import Ws from"stream";import Vl from"util";import{debuglog as Jl}from"node:util";import*as nn from"node:readline";import Do from"node:readline";import{Writable as Xl}from"node:stream";import Q from"fs/promises";import ho from"os";import Yl from"crypto";import{fileURLToPath as Ql,pathToFileURL as Zl}from"url";var eD=Object.defineProperty,q=o((e,t)=>eD(e,"name",{value:t,configurable:!0}),"a");const tD="known-flag",nD="unknown-flag",sD="argument",rD=/\B([A-Z])/g,uD=q(e=>e.replaceAll(rD,"-$1").toLowerCase(),"camelToKebab"),{hasOwnProperty:iD}=Object.prototype,gt=q((e,t)=>iD.call(e,t),"hasOwn"),qs=q(e=>typeof e=="function"?[e,!1]:Array.isArray(e)?[e[0],!0]:qs(e.type),"parseFlagType"),fo=q((e,t)=>e===Boolean?t!=="false":t,"normalizeBoolean"),po=q((e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),"applyParser"),oD=/[\s.:=]/,aD=q(e=>{const t=`Flag name "${e}"`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(oD);if(n)throw new Error(`${t} cannot contain "${n?.[0]}"`)},"validateFlagName"),Gs=q((e,t,n)=>{if(gt(e,t))throw new Error(`Duplicate flags named "${t}"`);e[t]=n},"setFlag"),cD=q(e=>{const t={};for(const n in e){if(!gt(e,n))continue;aD(n);const s=e[n],r=[[],...qs(s),s];Gs(t,n,r);const i=uD(n);if(n!==i&&Gs(t,i,r),"alias"in s&&typeof s.alias=="string"){const{alias:u}=s,a=`Flag alias "${u}" for flag "${n}"`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);Gs(t,u,r)}}return t},"createRegistry"),lD=q((e,t)=>{const n={};for(const s in e){if(!gt(e,s))continue;const[r,,i,u]=t[s];if(r.length===0&&"default"in u){let{default:a}=u;typeof a=="function"&&(a=a()),n[s]=a}else n[s]=i?r:r.pop()}return n},"finalizeFlags"),sn="--",DD=3,dD=/^-{1,2}\w/,mo=q(e=>{if(!dD.test(e))return;const t=!e.startsWith(sn);let n=e.slice(t?1:2),s,r=-1;for(const i of["=",":","."]){const u=n.indexOf(i);u!==-1&&(r===-1||u<r)&&(r=u)}return r!==-1&&(s=n.slice(r+1),n=n.slice(0,r)),[n,s,t]},"parseFlagArgv"),Fo=q((e,{onFlag:t,onArgument:n})=>{let s;const r=q((i,u)=>{if(typeof s!="function")return!0;s(i,u),s=void 0},"triggerValueCallback");for(let i=0;i<e.length;i+=1){const u=e[i];if(u===sn){r();const c=e.slice(i+1);n?.(c,[i],!0);break}const a=mo(u);if(a){if(r(),!t)continue;const[c,l,D]=a;if(D)for(let d=0;d<c.length;d+=1){r();const f=d===c.length-1;s=t(c[d],f?l:void 0,[i,d+1,f])}else s=t(c,l,[i])}else r(u,[i])&&n?.([u],[i])}r()},"argvIterator"),go=q((e,t)=>{for(let n=t.length-1;n>=0;n-=1){const[s,r,i]=t[n];if(r){const u=e[s];let a=u.slice(0,r);if(i||(a+=u.slice(r+1)),a!=="-"){e[s]=a;continue}}e.splice(s,1)}},"spliceFromArgv"),hD=q((e,t=process.argv.slice(2),{ignore:n}={})=>{const s=[],r=cD(e),i={},u=[];return u[sn]=[],Fo(t,{onFlag(a,c,l){const D=(l.length===DD||a.length>1)&&gt(r,a);if(!n?.(D?tD:nD,a,c)){if(D){const[d,f]=r[a],h=fo(f,c),F=q((m,E)=>{s.push(l),E&&s.push(E),d.push(po(f,m||""))},"getFollowingValue");return h===void 0?F:F(h)}gt(i,a)||(i[a]=[]),i[a].push(c===void 0?!0:c),s.push(l)}},onArgument:q((a,c,l)=>{n?.(sD,t[c[0]])||(u.push(...a),l?(u[sn]=a,t.splice(c[0])):s.push(c))},"onArgument")}),go(t,s),{flags:lD(e,r),unknownFlags:i,_:u}},"typeFlag");q((e,t,n=process.argv.slice(2))=>{const s=new Set(e.split(",").map(c=>mo(c)?.[0])),[r,i]=qs(t),u=[],a=[];return Fo(n,{onFlag:q((c,l,D)=>{if(!s.has(c)||!i&&u.length>0)return;const d=fo(r,l),f=q((h,F)=>{a.push(D),F&&a.push(F),u.push(po(r,h||""))},"getFollowingValue");return d===void 0?f:f(d)},"onFlag")}),go(n,a),i?u:u[0]},"getFlag");var fD=Object.defineProperty,S=o((e,t)=>fD(e,"name",{value:t,configurable:!0}),"n");const pD=S(e=>{const t=process.stdout.columns??Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(t)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:t}:{columns:e.columns??[],stdoutColumns:e.stdoutColumns??t}},"getOptions");function Co({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}o(Co,"j$1"),S(Co,"ansiRegex");const mD=Co();function Ks(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(mD,"")}o(Ks,"w$2"),S(Ks,"stripAnsi");function Eo(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}o(Eo,"P$2"),S(Eo,"isAmbiguous");function yo(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}o(yo,"z$2"),S(yo,"isFullWidth");function wo(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}o(wo,"G$3"),S(wo,"isWide");function bo(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}o(bo,"Z$1"),S(bo,"validate");function _o(e,{ambiguousAsWide:t=!1}={}){return bo(e),yo(e)||wo(e)||t&&Eo(e)?2:1}o(_o,"V$3"),S(_o,"eastAsianWidth");var FD=S(()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\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?|[\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](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\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-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,"emojiRegex");const gD=new Intl.Segmenter,CD=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function Fe(e,t={}){if(typeof e!="string"||e.length===0)return 0;const{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:s=!1}=t;if(s||(e=Ks(e)),e.length===0)return 0;let r=0;const i={ambiguousAsWide:!n};for(const{segment:u}of gD.segment(e)){const a=u.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!CD.test(u)){if(FD().test(u)){r+=2;continue}r+=_o(a,i)}}return r}o(Fe,"d$2"),S(Fe,"stringWidth");const Bo=S(e=>Math.max(...e.split(`
3
- `).map(t=>Fe(t))),"getLongestLineWidth"),ED=S(e=>{const t=[];for(const n of e){const{length:s}=n,r=s-t.length;for(let i=0;i<r;i+=1)t.push(0);for(let i=0;i<s;i+=1){const u=Bo(n[i]);u>t[i]&&(t[i]=u)}}return t},"getColumnContentWidths"),Ao=/^\d+%$/,vo={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},yD=S((e,t)=>{const n=[];for(let s=0;s<e.length;s+=1){const r=t[s]??"auto";if(typeof r=="number"||r==="auto"||r==="content-width"||typeof r=="string"&&Ao.test(r)){n.push({...vo,width:r,contentWidth:e[s]});continue}if(r&&typeof r=="object"){const i={...vo,...r,contentWidth:e[s]};i.horizontalPadding=i.paddingLeft+i.paddingRight,n.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(r)}`)}return n},"initColumns"),wD=S((e,t)=>{for(const n of e){const{width:s}=n;if(s==="content-width"&&(n.width=n.contentWidth),s==="auto"){const c=Math.min(20,n.contentWidth);n.width=c,n.autoOverflow=n.contentWidth-c}if(typeof s=="string"&&Ao.test(s)){const c=Number.parseFloat(s.slice(0,-1))/100;n.width=Math.floor(t*c)-(n.paddingLeft+n.paddingRight)}const{horizontalPadding:r}=n,i=1,u=i+r;if(u>=t){const c=u-t,l=Math.ceil(n.paddingLeft/r*c),D=c-l;n.paddingLeft-=l,n.paddingRight-=D,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";const a=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,a),i)}},"resolveColumnWidths"),$o=S(()=>Object.assign([],{columns:0}),"makeRow"),bD=S((e,t)=>{const n=[$o()];let[s]=n;for(const r of e){const i=r.width+r.horizontalPadding;s.columns+i>t&&(s=$o(),n.push(s)),s.push(r),s.columns+=i}for(const r of n){const i=r.reduce((f,h)=>f+h.width+h.horizontalPadding,0);let u=t-i;if(u===0)continue;const a=r.filter(f=>"autoOverflow"in f),c=a.filter(f=>f.autoOverflow>0),l=c.reduce((f,h)=>f+h.autoOverflow,0),D=Math.min(l,u);for(const f of c){const h=Math.floor(f.autoOverflow/l*D);f.width+=h,u-=h}const d=Math.floor(u/a.length);for(let f=0;f<a.length;f+=1){const h=a[f];f===a.length-1?h.width+=u:h.width+=d,u-=d}}return n},"balanceAuto"),_D=S((e,t,n)=>{const s=yD(n,t);return wD(s,e),bD(s,e)},"computeColumnWidths"),Hs=10,xo=S((e=0)=>t=>`\x1B[${t+e}m`,"wrapAnsi16"),So=S((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"wrapAnsi256"),Io=S((e=0)=>(t,n,s)=>`\x1B[${38+e};2;${t};${n};${s}m`,"wrapAnsi16m"),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);const BD=Object.keys(T.color),AD=Object.keys(T.bgColor);[...BD,...AD];function Oo(){const e=new Map;for(const[t,n]of Object.entries(T)){for(const[s,r]of Object.entries(n))T[s]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[s]=T[s],e.set(r[0],r[1]);Object.defineProperty(T,t,{value:n,enumerable:!1})}return Object.defineProperty(T,"codes",{value:e,enumerable:!1}),T.color.close="\x1B[39m",T.bgColor.close="\x1B[49m",T.color.ansi=xo(),T.color.ansi256=So(),T.color.ansi16m=Io(),T.bgColor.ansi=xo(Hs),T.bgColor.ansi256=So(Hs),T.bgColor.ansi16m=Io(Hs),Object.defineProperties(T,{rgbToAnsi256:{value:S((t,n,s)=>t===n&&n===s?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(s/255*5),"value"),enumerable:!1},hexToRgb:{value:S(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[s]=n;s.length===3&&(s=[...s].map(i=>i+i).join(""));const r=Number.parseInt(s,16);return[r>>16&255,r>>8&255,r&255]},"value"),enumerable:!1},hexToAnsi256:{value:S(t=>T.rgbToAnsi256(...T.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:S(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,s,r;if(t>=232)n=((t-232)*10+8)/255,s=n,r=n;else{t-=16;const a=t%36;n=Math.floor(t/36)/5,s=Math.floor(a/6)/5,r=a%6/5}const i=Math.max(n,s,r)*2;if(i===0)return 30;let u=30+(Math.round(r)<<2|Math.round(s)<<1|Math.round(n));return i===2&&(u+=60),u},"value"),enumerable:!1},rgbToAnsi:{value:S((t,n,s)=>T.ansi256ToAnsi(T.rgbToAnsi256(t,n,s)),"value"),enumerable:!1},hexToAnsi:{value:S(t=>T.ansi256ToAnsi(T.hexToAnsi256(t)),"value"),enumerable:!1}}),T}o(Oo,"FD$1"),S(Oo,"assembleStyles");const vD=Oo(),rn=new Set(["\x1B","\x9B"]),$D=39,zs="\x07",Ro="[",xD="]",ko="m",un=`${xD}8;;`,Po=S(e=>`${rn.values().next().value}${Ro}${e}${ko}`,"wrapAnsiCode"),To=S(e=>`${rn.values().next().value}${un}${e}${zs}`,"wrapAnsiHyperlink"),SD=S(e=>e.split(" ").map(t=>Fe(t)),"wordLengths"),Vs=S((e,t,n)=>{const s=[...t];let r=!1,i=!1,u=Fe(Ks(e.at(-1)));for(const[a,c]of s.entries()){const l=Fe(c);if(u+l<=n?e[e.length-1]+=c:(e.push(c),u=0),rn.has(c)&&(r=!0,i=s.slice(a+1,a+1+un.length).join("")===un),r){i?c===zs&&(r=!1,i=!1):c===ko&&(r=!1);continue}u+=l,u===n&&a<s.length-1&&(e.push(""),u=0)}!u&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"wrapWord"),ID=S(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(Fe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"stringVisibleTrimSpacesRight"),OD=S((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i;const u=SD(e);let a=[""];for(const[d,f]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let h=Fe(a.at(-1));if(d!==0&&(h>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),h=0),(h>0||n.trim===!1)&&(a[a.length-1]+=" ",h++)),n.hard&&u[d]>t){const F=t-h,m=1+Math.floor((u[d]-F-1)/t);Math.floor((u[d]-1)/t)<m&&a.push(""),Vs(a,f,t);continue}if(h+u[d]>t&&h>0&&u[d]>0){if(n.wordWrap===!1&&h<t){Vs(a,f,t);continue}a.push("")}if(h+u[d]>t&&n.wordWrap===!1){Vs(a,f,t);continue}a[a.length-1]+=f}n.trim!==!1&&(a=a.map(d=>ID(d)));const c=a.join(`
4
- `),l=[...c];let D=0;for(const[d,f]of l.entries()){if(s+=f,rn.has(f)){const{groups:F}=new RegExp(`(?:\\${Ro}(?<code>\\d+)m|\\${un}(?<uri>.*)${zs})`).exec(c.slice(D))||{groups:{}};if(F.code!==void 0){const m=Number.parseFloat(F.code);r=m===$D?void 0:m}else F.uri!==void 0&&(i=F.uri.length===0?void 0:F.uri)}const h=vD.codes.get(Number(r));l[d+1]===`
5
- `?(i&&(s+=To("")),r&&h&&(s+=Po(h))):f===`
6
- `&&(r&&h&&(s+=Po(r)),i&&(s+=To(i))),D+=f.length}return s},"exec");function No(e,t,n){return String(e).normalize().replaceAll(`\r
2
+ var Rl=Object.defineProperty;var o=(e,t)=>Rl(e,"name",{value:t,configurable:!0});var it,ot,at,ct,lt,Dt,dt,ht,ft,pt,mt;import kl from"tty";import Pl from"update-notifier";import{Buffer as Tl}from"node:buffer";import Ne from"node:path";import uo,{ChildProcess as Nl}from"node:child_process";import j,{stdin as io,stdout as oo}from"node:process";import Ml from"child_process";import ae from"path";import js from"fs";import{fileURLToPath as ao}from"node:url";import Ll,{constants as co}from"node:os";import jl from"assert";import Ul from"events";import{createWriteStream as Wl,createReadStream as ql}from"node:fs";import Gl from"buffer";import Us from"stream";import Kl from"util";import{debuglog as Hl}from"node:util";import*as en from"node:readline";import lo from"node:readline";import{Writable as zl}from"node:stream";import Q from"fs/promises";import Do from"os";import Vl from"crypto";import{fileURLToPath as Jl,pathToFileURL as Xl}from"url";var Yl=Object.defineProperty,q=o((e,t)=>Yl(e,"name",{value:t,configurable:!0}),"a");const Ql="known-flag",Zl="unknown-flag",eD="argument",tD=/\B([A-Z])/g,nD=q(e=>e.replaceAll(tD,"-$1").toLowerCase(),"camelToKebab"),{hasOwnProperty:sD}=Object.prototype,Ft=q((e,t)=>sD.call(e,t),"hasOwn"),Ws=q(e=>typeof e=="function"?[e,!1]:Array.isArray(e)?[e[0],!0]:Ws(e.type),"parseFlagType"),ho=q((e,t)=>e===Boolean?t!=="false":t,"normalizeBoolean"),fo=q((e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),"applyParser"),rD=/[\s.:=]/,uD=q(e=>{const t=`Flag name "${e}"`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(rD);if(n)throw new Error(`${t} cannot contain "${n?.[0]}"`)},"validateFlagName"),qs=q((e,t,n)=>{if(Ft(e,t))throw new Error(`Duplicate flags named "${t}"`);e[t]=n},"setFlag"),iD=q(e=>{const t={};for(const n in e){if(!Ft(e,n))continue;uD(n);const s=e[n],r=[[],...Ws(s),s];qs(t,n,r);const i=nD(n);if(n!==i&&qs(t,i,r),"alias"in s&&typeof s.alias=="string"){const{alias:u}=s,a=`Flag alias "${u}" for flag "${n}"`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);qs(t,u,r)}}return t},"createRegistry"),oD=q((e,t)=>{const n={};for(const s in e){if(!Ft(e,s))continue;const[r,,i,u]=t[s];if(r.length===0&&"default"in u){let{default:a}=u;typeof a=="function"&&(a=a()),n[s]=a}else n[s]=i?r:r.pop()}return n},"finalizeFlags"),tn="--",aD=3,cD=/^-{1,2}\w/,po=q(e=>{if(!cD.test(e))return;const t=!e.startsWith(tn);let n=e.slice(t?1:2),s,r=-1;for(const i of["=",":","."]){const u=n.indexOf(i);u!==-1&&(r===-1||u<r)&&(r=u)}return r!==-1&&(s=n.slice(r+1),n=n.slice(0,r)),[n,s,t]},"parseFlagArgv"),mo=q((e,{onFlag:t,onArgument:n})=>{let s;const r=q((i,u)=>{if(typeof s!="function")return!0;s(i,u),s=void 0},"triggerValueCallback");for(let i=0;i<e.length;i+=1){const u=e[i];if(u===tn){r();const c=e.slice(i+1);n?.(c,[i],!0);break}const a=po(u);if(a){if(r(),!t)continue;const[c,l,d]=a;if(d)for(let D=0;D<c.length;D+=1){r();const f=D===c.length-1;s=t(c[D],f?l:void 0,[i,D+1,f])}else s=t(c,l,[i])}else r(u,[i])&&n?.([u],[i])}r()},"argvIterator"),Fo=q((e,t)=>{for(let n=t.length-1;n>=0;n-=1){const[s,r,i]=t[n];if(r){const u=e[s];let a=u.slice(0,r);if(i||(a+=u.slice(r+1)),a!=="-"){e[s]=a;continue}}e.splice(s,1)}},"spliceFromArgv"),lD=q((e,t=process.argv.slice(2),{ignore:n}={})=>{const s=[],r=iD(e),i={},u=[];return u[tn]=[],mo(t,{onFlag(a,c,l){const d=(l.length===aD||a.length>1)&&Ft(r,a);if(!n?.(d?Ql:Zl,a,c)){if(d){const[D,f]=r[a],h=ho(f,c),F=q((m,E)=>{s.push(l),E&&s.push(E),D.push(fo(f,m||""))},"getFollowingValue");return h===void 0?F:F(h)}Ft(i,a)||(i[a]=[]),i[a].push(c===void 0?!0:c),s.push(l)}},onArgument:q((a,c,l)=>{n?.(eD,t[c[0]])||(u.push(...a),l?(u[tn]=a,t.splice(c[0])):s.push(c))},"onArgument")}),Fo(t,s),{flags:oD(e,r),unknownFlags:i,_:u}},"typeFlag");q((e,t,n=process.argv.slice(2))=>{const s=new Set(e.split(",").map(c=>po(c)?.[0])),[r,i]=Ws(t),u=[],a=[];return mo(n,{onFlag:q((c,l,d)=>{if(!s.has(c)||!i&&u.length>0)return;const D=ho(r,l),f=q((h,F)=>{a.push(d),F&&a.push(F),u.push(fo(r,h||""))},"getFollowingValue");return D===void 0?f:f(D)},"onFlag")}),Fo(n,a),i?u:u[0]},"getFlag");var DD=Object.defineProperty,S=o((e,t)=>DD(e,"name",{value:t,configurable:!0}),"n");const dD=S(e=>{const t=process.stdout.columns??Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(t)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:t}:{columns:e.columns??[],stdoutColumns:e.stdoutColumns??t}},"getOptions");function go({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}o(go,"j$1"),S(go,"ansiRegex");const hD=go();function Gs(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(hD,"")}o(Gs,"w$2"),S(Gs,"stripAnsi");function Co(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}o(Co,"P$2"),S(Co,"isAmbiguous");function Eo(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}o(Eo,"z$2"),S(Eo,"isFullWidth");function yo(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}o(yo,"G$3"),S(yo,"isWide");function wo(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}o(wo,"Z$1"),S(wo,"validate");function bo(e,{ambiguousAsWide:t=!1}={}){return wo(e),Eo(e)||yo(e)||t&&Co(e)?2:1}o(bo,"V$3"),S(bo,"eastAsianWidth");var fD=S(()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\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?|[\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](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\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-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,"emojiRegex");const pD=new Intl.Segmenter,mD=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u");function Fe(e,t={}){if(typeof e!="string"||e.length===0)return 0;const{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:s=!1}=t;if(s||(e=Gs(e)),e.length===0)return 0;let r=0;const i={ambiguousAsWide:!n};for(const{segment:u}of pD.segment(e)){const a=u.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!mD.test(u)){if(fD().test(u)){r+=2;continue}r+=bo(a,i)}}return r}o(Fe,"d$2"),S(Fe,"stringWidth");const _o=S(e=>Math.max(...e.split(`
3
+ `).map(t=>Fe(t))),"getLongestLineWidth"),FD=S(e=>{const t=[];for(const n of e){const{length:s}=n,r=s-t.length;for(let i=0;i<r;i+=1)t.push(0);for(let i=0;i<s;i+=1){const u=_o(n[i]);u>t[i]&&(t[i]=u)}}return t},"getColumnContentWidths"),Bo=/^\d+%$/,Ao={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},gD=S((e,t)=>{const n=[];for(let s=0;s<e.length;s+=1){const r=t[s]??"auto";if(typeof r=="number"||r==="auto"||r==="content-width"||typeof r=="string"&&Bo.test(r)){n.push({...Ao,width:r,contentWidth:e[s]});continue}if(r&&typeof r=="object"){const i={...Ao,...r,contentWidth:e[s]};i.horizontalPadding=i.paddingLeft+i.paddingRight,n.push(i);continue}throw new Error(`Invalid column width: ${JSON.stringify(r)}`)}return n},"initColumns"),CD=S((e,t)=>{for(const n of e){const{width:s}=n;if(s==="content-width"&&(n.width=n.contentWidth),s==="auto"){const c=Math.min(20,n.contentWidth);n.width=c,n.autoOverflow=n.contentWidth-c}if(typeof s=="string"&&Bo.test(s)){const c=Number.parseFloat(s.slice(0,-1))/100;n.width=Math.floor(t*c)-(n.paddingLeft+n.paddingRight)}const{horizontalPadding:r}=n,i=1,u=i+r;if(u>=t){const c=u-t,l=Math.ceil(n.paddingLeft/r*c),d=c-l;n.paddingLeft-=l,n.paddingRight-=d,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";const a=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,a),i)}},"resolveColumnWidths"),vo=S(()=>Object.assign([],{columns:0}),"makeRow"),ED=S((e,t)=>{const n=[vo()];let[s]=n;for(const r of e){const i=r.width+r.horizontalPadding;s.columns+i>t&&(s=vo(),n.push(s)),s.push(r),s.columns+=i}for(const r of n){const i=r.reduce((f,h)=>f+h.width+h.horizontalPadding,0);let u=t-i;if(u===0)continue;const a=r.filter(f=>"autoOverflow"in f),c=a.filter(f=>f.autoOverflow>0),l=c.reduce((f,h)=>f+h.autoOverflow,0),d=Math.min(l,u);for(const f of c){const h=Math.floor(f.autoOverflow/l*d);f.width+=h,u-=h}const D=Math.floor(u/a.length);for(let f=0;f<a.length;f+=1){const h=a[f];f===a.length-1?h.width+=u:h.width+=D,u-=D}}return n},"balanceAuto"),yD=S((e,t,n)=>{const s=gD(n,t);return CD(s,e),ED(s,e)},"computeColumnWidths"),Ks=10,$o=S((e=0)=>t=>`\x1B[${t+e}m`,"wrapAnsi16"),xo=S((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"wrapAnsi256"),So=S((e=0)=>(t,n,s)=>`\x1B[${38+e};2;${t};${n};${s}m`,"wrapAnsi16m"),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);const wD=Object.keys(T.color),bD=Object.keys(T.bgColor);[...wD,...bD];function Io(){const e=new Map;for(const[t,n]of Object.entries(T)){for(const[s,r]of Object.entries(n))T[s]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[s]=T[s],e.set(r[0],r[1]);Object.defineProperty(T,t,{value:n,enumerable:!1})}return Object.defineProperty(T,"codes",{value:e,enumerable:!1}),T.color.close="\x1B[39m",T.bgColor.close="\x1B[49m",T.color.ansi=$o(),T.color.ansi256=xo(),T.color.ansi16m=So(),T.bgColor.ansi=$o(Ks),T.bgColor.ansi256=xo(Ks),T.bgColor.ansi16m=So(Ks),Object.defineProperties(T,{rgbToAnsi256:{value:S((t,n,s)=>t===n&&n===s?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(s/255*5),"value"),enumerable:!1},hexToRgb:{value:S(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[s]=n;s.length===3&&(s=[...s].map(i=>i+i).join(""));const r=Number.parseInt(s,16);return[r>>16&255,r>>8&255,r&255]},"value"),enumerable:!1},hexToAnsi256:{value:S(t=>T.rgbToAnsi256(...T.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:S(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,s,r;if(t>=232)n=((t-232)*10+8)/255,s=n,r=n;else{t-=16;const a=t%36;n=Math.floor(t/36)/5,s=Math.floor(a/6)/5,r=a%6/5}const i=Math.max(n,s,r)*2;if(i===0)return 30;let u=30+(Math.round(r)<<2|Math.round(s)<<1|Math.round(n));return i===2&&(u+=60),u},"value"),enumerable:!1},rgbToAnsi:{value:S((t,n,s)=>T.ansi256ToAnsi(T.rgbToAnsi256(t,n,s)),"value"),enumerable:!1},hexToAnsi:{value:S(t=>T.ansi256ToAnsi(T.hexToAnsi256(t)),"value"),enumerable:!1}}),T}o(Io,"FD$1"),S(Io,"assembleStyles");const _D=Io(),nn=new Set(["\x1B","\x9B"]),BD=39,Hs="\x07",Oo="[",AD="]",Ro="m",sn=`${AD}8;;`,ko=S(e=>`${nn.values().next().value}${Oo}${e}${Ro}`,"wrapAnsiCode"),Po=S(e=>`${nn.values().next().value}${sn}${e}${Hs}`,"wrapAnsiHyperlink"),vD=S(e=>e.split(" ").map(t=>Fe(t)),"wordLengths"),zs=S((e,t,n)=>{const s=[...t];let r=!1,i=!1,u=Fe(Gs(e.at(-1)));for(const[a,c]of s.entries()){const l=Fe(c);if(u+l<=n?e[e.length-1]+=c:(e.push(c),u=0),nn.has(c)&&(r=!0,i=s.slice(a+1,a+1+sn.length).join("")===sn),r){i?c===Hs&&(r=!1,i=!1):c===Ro&&(r=!1);continue}u+=l,u===n&&a<s.length-1&&(e.push(""),u=0)}!u&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"wrapWord"),$D=S(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(Fe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"stringVisibleTrimSpacesRight"),xD=S((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i;const u=vD(e);let a=[""];for(const[D,f]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a.at(-1).trimStart());let h=Fe(a.at(-1));if(D!==0&&(h>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),h=0),(h>0||n.trim===!1)&&(a[a.length-1]+=" ",h++)),n.hard&&u[D]>t){const F=t-h,m=1+Math.floor((u[D]-F-1)/t);Math.floor((u[D]-1)/t)<m&&a.push(""),zs(a,f,t);continue}if(h+u[D]>t&&h>0&&u[D]>0){if(n.wordWrap===!1&&h<t){zs(a,f,t);continue}a.push("")}if(h+u[D]>t&&n.wordWrap===!1){zs(a,f,t);continue}a[a.length-1]+=f}n.trim!==!1&&(a=a.map(D=>$D(D)));const c=a.join(`
4
+ `),l=[...c];let d=0;for(const[D,f]of l.entries()){if(s+=f,nn.has(f)){const{groups:F}=new RegExp(`(?:\\${Oo}(?<code>\\d+)m|\\${sn}(?<uri>.*)${Hs})`).exec(c.slice(d))||{groups:{}};if(F.code!==void 0){const m=Number.parseFloat(F.code);r=m===BD?void 0:m}else F.uri!==void 0&&(i=F.uri.length===0?void 0:F.uri)}const h=_D.codes.get(Number(r));l[D+1]===`
5
+ `?(i&&(s+=Po("")),r&&h&&(s+=ko(h))):f===`
6
+ `&&(r&&h&&(s+=ko(r)),i&&(s+=Po(i))),d+=f.length}return s},"exec");function To(e,t,n){return String(e).normalize().replaceAll(`\r
7
7
  `,`
8
8
  `).split(`
9
- `).map(s=>OD(s,t,n)).join(`
10
- `)}o(No,"BD$1"),S(No,"wrapAnsi");const Mo=S(e=>Array.from({length:e}).fill(""),"emptyLines"),RD=S((e,t)=>{const n=[];let s=0;for(const r of e){let i=0;const u=r.map(c=>{let l=t[s]??"";s+=1,c.preprocess&&(l=c.preprocess(l)),Bo(l)>c.width&&(l=No(l,c.width,{hard:!0}));let D=l.split(`
11
- `);if(c.postprocess){const{postprocess:d}=c;D=D.map((f,h)=>d.call(c,f,h))}return c.paddingTop&&D.unshift(...Mo(c.paddingTop)),c.paddingBottom&&D.push(...Mo(c.paddingBottom)),D.length>i&&(i=D.length),{...c,lines:D}}),a=[];for(let c=0;c<i;c+=1){const l=u.map(D=>{const d=D.lines[c]??"",f=Number.isFinite(D.width)?" ".repeat(D.width-Fe(d)):"";let h=D.paddingLeftString;return D.align==="right"&&(h+=f),h+=d,D.align==="left"&&(h+=f),h+D.paddingRightString}).join("");a.push(l)}n.push(a.join(`
9
+ `).map(s=>xD(s,t,n)).join(`
10
+ `)}o(To,"BD$1"),S(To,"wrapAnsi");const No=S(e=>Array.from({length:e}).fill(""),"emptyLines"),SD=S((e,t)=>{const n=[];let s=0;for(const r of e){let i=0;const u=r.map(c=>{let l=t[s]??"";s+=1,c.preprocess&&(l=c.preprocess(l)),_o(l)>c.width&&(l=To(l,c.width,{hard:!0}));let d=l.split(`
11
+ `);if(c.postprocess){const{postprocess:D}=c;d=d.map((f,h)=>D.call(c,f,h))}return c.paddingTop&&d.unshift(...No(c.paddingTop)),c.paddingBottom&&d.push(...No(c.paddingBottom)),d.length>i&&(i=d.length),{...c,lines:d}}),a=[];for(let c=0;c<i;c+=1){const l=u.map(d=>{const D=d.lines[c]??"",f=Number.isFinite(d.width)?" ".repeat(d.width-Fe(D)):"";let h=d.paddingLeftString;return d.align==="right"&&(h+=f),h+=D,d.align==="left"&&(h+=f),h+d.paddingRightString}).join("");a.push(l)}n.push(a.join(`
12
12
  `))}return n.join(`
13
- `)},"renderRow"),kD=S((e,t)=>{if(!e||e.length===0)return"";const n=ED(e),s=n.length;if(s===0)return"";const{stdoutColumns:r,columns:i}=pD(t);if(i.length>s)throw new Error(`${i.length} columns defined, but only ${s} columns found`);const u=_D(r,i,n);return e.map(a=>RD(u,a)).join(`
14
- `)},"terminalColumns"),PD=["<",">","=",">=","<="],TD=S(e=>{if(!PD.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)},"assertOperator"),ND=S(e=>{const t=Object.keys(e).map(n=>{const[s,r]=n.split(" ");TD(s);const i=Number.parseInt(r,10);if(Number.isNaN(i))throw new TypeError(`Invalid breakpoint value: ${r}`);const u=e[n];return{operator:s,breakpoint:i,value:u}}).sort((n,s)=>s.breakpoint-n.breakpoint);return n=>t.find(({operator:s,breakpoint:r})=>s==="="&&n===r||s===">"&&n>r||s==="<"&&n<r||s===">="&&n>=r||s==="<="&&n<=r)?.value},"breakpoints");var MD=Object.defineProperty,P=o((e,t)=>MD(e,"name",{value:t,configurable:!0}),"s");const LD=P(e=>e.replaceAll(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),"camelCase"),jD=P(e=>e.replaceAll(/\B([A-Z])/g,"-$1").toLowerCase(),"kebabCase"),UD={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:P(e=>e.trim(),"preprocess")},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Lo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,s)=>n.localeCompare(s)).map(n=>{const s=e[n],r="alias"in s;return r&&(t=!0),{name:n,flag:s,flagFormatted:`--${jD(n)}`,aliasesEnabled:t,aliasFormatted:r?`-${s.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:UD}}}o(Lo,"T"),P(Lo,"renderFlags");const jo=P(e=>!e||(e.version??(e.help?e.help.version:void 0)),"getVersion"),Uo=P(e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name},"getName");function Wo(e){const t=[];e.name&&t.push(Uo(e));const n=jo(e)??("parent"in e&&jo(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
15
- `}}o(Wo,"k$2"),P(Wo,"getNameAndVersion");function qo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
16
- `}}o(qo,"_$1"),P(qo,"getDescription");function Go(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
17
- `):t.usage}}:void 0;if(e.name){const n=[],s=[Uo(e)];if(e.flags&&Object.keys(e.flags).length>0&&s.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:r}=e,i=r.indexOf("--"),u=i!==-1&&r.slice(i+1).some(a=>a.startsWith("<"));s.push(r.map(a=>a!=="--"?a:u?"--":"[--]").join(" "))}if(s.length>1&&n.push(s.join(" ")),"commands"in e&&e.commands?.length&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
18
- `)}}}}o(Go,"F"),P(Go,"getUsage");function Ko(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}o(Ko,"H"),P(Ko,"getCommands");function Ho(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Lo(e.flags),indentBody:0}}}o(Ho,"U$1"),P(Ho,"getFlags");function zo(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:n}=t;if(Array.isArray(n)&&(n=n.join(`
19
- `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}o(zo,"V$2"),P(zo,"getExamples");function Vo(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}o(Vo,"J$1"),P(Vo,"getAliases");const WD=P(e=>[Wo,qo,Go,Ko,Ho,zo,Vo].map(t=>t(e)).filter(Boolean),"generateHelp"),qD=Tl.WriteStream.prototype.hasColors(),Jo=(ot=class{text(t){return t}bold(t){return qD?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replaceAll(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:s=2}){return`${(t?`${this.heading(t)}
13
+ `)},"renderRow"),ID=S((e,t)=>{if(!e||e.length===0)return"";const n=FD(e),s=n.length;if(s===0)return"";const{stdoutColumns:r,columns:i}=dD(t);if(i.length>s)throw new Error(`${i.length} columns defined, but only ${s} columns found`);const u=yD(r,i,n);return e.map(a=>SD(u,a)).join(`
14
+ `)},"terminalColumns"),OD=["<",">","=",">=","<="],RD=S(e=>{if(!OD.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)},"assertOperator"),kD=S(e=>{const t=Object.keys(e).map(n=>{const[s,r]=n.split(" ");RD(s);const i=Number.parseInt(r,10);if(Number.isNaN(i))throw new TypeError(`Invalid breakpoint value: ${r}`);const u=e[n];return{operator:s,breakpoint:i,value:u}}).sort((n,s)=>s.breakpoint-n.breakpoint);return n=>t.find(({operator:s,breakpoint:r})=>s==="="&&n===r||s===">"&&n>r||s==="<"&&n<r||s===">="&&n>=r||s==="<="&&n<=r)?.value},"breakpoints");var PD=Object.defineProperty,P=o((e,t)=>PD(e,"name",{value:t,configurable:!0}),"s");const TD=P(e=>e.replaceAll(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),"camelCase"),ND=P(e=>e.replaceAll(/\B([A-Z])/g,"-$1").toLowerCase(),"kebabCase"),MD={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:P(e=>e.trim(),"preprocess")},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Mo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,s)=>n.localeCompare(s)).map(n=>{const s=e[n],r="alias"in s;return r&&(t=!0),{name:n,flag:s,flagFormatted:`--${ND(n)}`,aliasesEnabled:t,aliasFormatted:r?`-${s.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:MD}}}o(Mo,"T"),P(Mo,"renderFlags");const Lo=P(e=>!e||(e.version??(e.help?e.help.version:void 0)),"getVersion"),jo=P(e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name},"getName");function Uo(e){const t=[];e.name&&t.push(jo(e));const n=Lo(e)??("parent"in e&&Lo(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
15
+ `}}o(Uo,"k$2"),P(Uo,"getNameAndVersion");function Wo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
16
+ `}}o(Wo,"_$1"),P(Wo,"getDescription");function qo(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
17
+ `):t.usage}}:void 0;if(e.name){const n=[],s=[jo(e)];if(e.flags&&Object.keys(e.flags).length>0&&s.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:r}=e,i=r.indexOf("--"),u=i!==-1&&r.slice(i+1).some(a=>a.startsWith("<"));s.push(r.map(a=>a!=="--"?a:u?"--":"[--]").join(" "))}if(s.length>1&&n.push(s.join(" ")),"commands"in e&&e.commands?.length&&n.push(`${e.name} <command>`),n.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:n.join(`
18
+ `)}}}}o(qo,"F"),P(qo,"getUsage");function Go(e){return!("commands"in e)||!e.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:e.commands.map(t=>[t.options.name,t.options.help?t.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}o(Go,"H"),P(Go,"getCommands");function Ko(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Mo(e.flags),indentBody:0}}}o(Ko,"U$1"),P(Ko,"getFlags");function Ho(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:n}=t;if(Array.isArray(n)&&(n=n.join(`
19
+ `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}o(Ho,"V$2"),P(Ho,"getExamples");function zo(e){if(!("alias"in e)||!e.alias)return;const{alias:t}=e;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(t)?t.join(", "):t}}}o(zo,"J$1"),P(zo,"getAliases");const LD=P(e=>[Uo,Wo,qo,Go,Ko,Ho,zo].map(t=>t(e)).filter(Boolean),"generateHelp"),jD=kl.WriteStream.prototype.hasColors(),Vo=(it=class{text(t){return t}bold(t){return jD?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replaceAll(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:s=2}){return`${(t?`${this.heading(t)}
20
20
  `:"")+(n?this.indentText({text:this.render(n),spaces:s}):"")}
21
- `}table({tableData:t,tableOptions:n,tableBreakpoints:s}){return kD(t.map(r=>r.map(i=>this.render(i))),s?ND(s):n)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:n,flagFormatted:s,aliasesEnabled:r,aliasFormatted:i}=t;let u="";if(i?u+=`${i}, `:r&&(u+=" "),u+=s,"placeholder"in n&&typeof n.placeholder=="string")u+=`${this.flagOperator(t)}${n.placeholder}`;else{const a=this.flagParameter("type"in n?n.type:n);a&&(u+=`${this.flagOperator(t)}${a}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:s}=t;typeof s=="function"&&(s=s()),s&&(n+=` (default: ${this.flagDefault(s)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
22
- `);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}},o(ot,"_z"),ot);P(Jo,"Renderers");let GD=Jo;const Js=P(e=>e.length>0&&!e.includes(" "),"isValidScriptName"),{stringify:le}=JSON,KD=/[|\\{}()[\]^$+*?.]/;function on(e){const t=[];let n,s;for(const r of e){if(s)throw new Error(`Invalid parameter: Spread parameter ${le(s)} must be last`);const i=r[0],u=r.at(-1);let a;if(i==="<"&&u===">"&&(a=!0,n))throw new Error(`Invalid parameter: Required parameter ${le(r)} cannot come after optional parameter ${le(n)}`);if(i==="["&&u==="]"&&(a=!1,n=r),a===void 0)throw new Error(`Invalid parameter: ${le(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=r.slice(1,-1);const l=c.slice(-3)==="...";l&&(s=r,c=c.slice(0,-3));const D=c.match(KD);if(D)throw new Error(`Invalid parameter: ${le(r)}. Invalid character found ${le(D[0])}`);t.push({name:c,required:a,spread:l})}return t}o(on,"b$1"),P(on,"parseParameters");function an(e,t,n,s){for(let r=0;r<t.length;r+=1){const{name:i,required:u,spread:a}=t[r],c=LD(i);if(c in e)throw new Error(`Invalid parameter: ${le(i)} is used more than once.`);const l=a?n.slice(r):n[r];if(a&&(r=t.length),u&&(!l||a&&l.length===0))return console.error(`Error: Missing required parameter ${le(i)}
23
- `),s(),process.exit(1);e[c]=l}}o(an,"v"),P(an,"mapParametersToArguments");function Xo(e){return e===void 0||e!==!1}o(Xo,"G$2"),P(Xo,"helpEnabled");function Xs(e,t,n,s){const r={...t.flags},i=t.version&&!("version"in r);i&&(r.version={type:Boolean,description:"Show version"});const{help:u}=t,a=Xo(u);a&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const c=hD(r,s,{ignore:t.ignoreArgv}),l=P(()=>{console.log(t.version)},"showVersion");if(i&&c.flags.version===!0)return l(),process.exit(0);const D=new GD,d=a&&u?.render?u.render:m=>D.render(m),f=P(m=>{const E=WD({...t,...m?{help:m}:{},flags:r});console.log(d(E,D))},"showHelp");if(a&&c.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:m}=t,E=c._;const y=m.indexOf("--"),g=m.slice(y+1),b=Object.create(null);if(y>-1&&g.length>0){m=m.slice(0,y);const B=c._["--"];E=E.slice(0,-B.length||void 0),an(b,on(m),E,f),an(b,on(g),B,f)}else an(b,on(m),E,f);Object.assign(c._,b)}const h={...c,showVersion:l,showHelp:f},F={command:e,...h};if(typeof n=="function"){const m=n(h);if(m&&"then"in m)return Object.assign(Promise.resolve(m),F)}return F}o(Xs,"j"),P(Xs,"cliBase");function Yo(e,t){const n=new Map;for(const s of t){const r=[s.options.name],{alias:i}=s.options;i&&(Array.isArray(i)?r.push(...i):r.push(i));for(const u of r){if(n.has(u))throw new Error(`Duplicate command name found: ${le(u)}`);n.set(u,s)}}return n.get(e)}o(Yo,"K$1"),P(Yo,"getCommand");function Qo(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Js(e.name)))throw new Error(`Invalid script name: ${le(e.name)}`);const s=n[0];if(e.commands&&s&&Js(s)){const r=Yo(s,e.commands);if(r)return Xs(r.options.name,{...r.options,parent:e},r.callback,n.slice(1))}return Xs(void 0,e,t,n)}o(Qo,"Q"),P(Qo,"cli");function Ct(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(n===void 0)throw new Error("Command name is required");if(!Js(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}o(Ct,"X"),P(Ct,"command");var HD="aicommits",zD="1.12.0-develop.4",VD="Writes your git commit messages for you with AI",JD=["ai","git","commit","code changes"],XD="MIT",YD="Nutlope/aicommits",QD="Hassan El Mghari (@nutlope)",ZD="module",ed=["dist"],td={aicommits:"./dist/cli.mjs",aic:"./dist/cli.mjs"},nd={build:"pkgroll --minify",lint:"","type-check":"tsc",test:"tsx tests",prepack:"pnpm build && clean-pkg-json"},sd={"@clack/prompts":"^0.11.0","@types/ini":"^1.3.31","@types/node":"^24.10.1","@types/update-notifier":"^6.0.8","clean-pkg-json":"^1.3.0",cleye:"^2.0.0",clipboardy:"^5.0.0",execa:"^7.0.0","fs-fixture":"^1.2.0",ini:"^3.0.1",kolorist:"^1.8.0",manten:"^0.7.0",openai:"^6.9.0",pkgroll:"^2.20.1",tsx:"^4.20.6",typescript:"^5.9.3"},rd={branches:["main",{name:"develop",prerelease:!0}]},ud={"update-notifier":"^7.3.1"},Ys={name:HD,version:zD,description:VD,keywords:JD,license:XD,repository:YD,author:QD,type:ZD,files:ed,bin:td,scripts:nd,devDependencies:sd,release:rd,dependencies:ud},ge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Le(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(Le,"getDefaultExportFromCjs");var be={exports:{}},Qs,Zo;function id(){if(Zo)return Qs;Zo=1,Qs=s,s.sync=r;var e=Us;function t(i,u){var a=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var c=0;c<a.length;c++){var l=a[c].toLowerCase();if(l&&i.substr(-l.length).toLowerCase()===l)return!0}return!1}o(t,"checkPathExt");function n(i,u,a){return!i.isSymbolicLink()&&!i.isFile()?!1:t(u,a)}o(n,"checkStat");function s(i,u,a){e.stat(i,function(c,l){a(c,c?!1:n(l,i,u))})}o(s,"isexe");function r(i,u){return n(e.statSync(i),i,u)}return o(r,"sync"),Qs}o(id,"requireWindows");var Zs,ea;function od(){if(ea)return Zs;ea=1,Zs=t,t.sync=n;var e=Us;function t(i,u,a){e.stat(i,function(c,l){a(c,c?!1:s(l,u))})}o(t,"isexe");function n(i,u){return s(e.statSync(i),u)}o(n,"sync");function s(i,u){return i.isFile()&&r(i,u)}o(s,"checkStat");function r(i,u){var a=i.mode,c=i.uid,l=i.gid,D=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),d=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),f=parseInt("100",8),h=parseInt("010",8),F=parseInt("001",8),m=f|h,E=a&F||a&h&&l===d||a&f&&c===D||a&m&&D===0;return E}return o(r,"checkMode"),Zs}o(od,"requireMode");var er,ta;function ad(){if(ta)return er;ta=1;var e;process.platform==="win32"||ge.TESTING_WINDOWS?e=id():e=od(),er=t,t.sync=n;function t(s,r,i){if(typeof r=="function"&&(i=r,r={}),!i){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(u,a){t(s,r||{},function(c,l){c?a(c):u(l)})})}e(s,r||{},function(u,a){u&&(u.code==="EACCES"||r&&r.ignoreErrors)&&(u=null,a=!1),i(u,a)})}o(t,"isexe");function n(s,r){try{return e.sync(s,r||{})}catch(i){if(r&&r.ignoreErrors||i.code==="EACCES")return!1;throw i}}return o(n,"sync"),er}o(ad,"requireIsexe");var tr,na;function cd(){if(na)return tr;na=1;const e=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",t=ae,n=e?";":":",s=ad(),r=o(c=>Object.assign(new Error(`not found: ${c}`),{code:"ENOENT"}),"getNotFoundError"),i=o((c,l)=>{const D=l.colon||n,d=c.match(/\//)||e&&c.match(/\\/)?[""]:[...e?[process.cwd()]:[],...(l.path||process.env.PATH||"").split(D)],f=e?l.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",h=e?f.split(D):[""];return e&&c.indexOf(".")!==-1&&h[0]!==""&&h.unshift(""),{pathEnv:d,pathExt:h,pathExtExe:f}},"getPathInfo"),u=o((c,l,D)=>{typeof l=="function"&&(D=l,l={}),l||(l={});const{pathEnv:d,pathExt:f,pathExtExe:h}=i(c,l),F=[],m=o(y=>new Promise((g,b)=>{if(y===d.length)return l.all&&F.length?g(F):b(r(c));const B=d[y],I=/^".*"$/.test(B)?B.slice(1,-1):B,O=t.join(I,c),R=!I&&/^\.[\\\/]/.test(c)?c.slice(0,2)+O:O;g(E(R,y,0))}),"step"),E=o((y,g,b)=>new Promise((B,I)=>{if(b===f.length)return B(m(g+1));const O=f[b];s(y+O,{pathExt:h},(R,L)=>{if(!R&&L)if(l.all)F.push(y+O);else return B(y+O);return B(E(y,g,b+1))})}),"subStep");return D?m(0).then(y=>D(null,y),D):m(0)},"which"),a=o((c,l)=>{l=l||{};const{pathEnv:D,pathExt:d,pathExtExe:f}=i(c,l),h=[];for(let F=0;F<D.length;F++){const m=D[F],E=/^".*"$/.test(m)?m.slice(1,-1):m,y=t.join(E,c),g=!E&&/^\.[\\\/]/.test(c)?c.slice(0,2)+y:y;for(let b=0;b<d.length;b++){const B=g+d[b];try{if(s.sync(B,{pathExt:f}))if(l.all)h.push(B);else return B}catch{}}}if(l.all&&h.length)return h;if(l.nothrow)return null;throw r(c)},"whichSync");return tr=u,u.sync=a,tr}o(cd,"requireWhich");var cn={exports:{}},sa;function ld(){if(sa)return cn.exports;sa=1;const e=o((t={})=>{const n=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(n).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"},"pathKey");return cn.exports=e,cn.exports.default=e,cn.exports}o(ld,"requirePathKey");var nr,ra;function Dd(){if(ra)return nr;ra=1;const e=ae,t=cd(),n=ld();function s(i,u){const a=i.options.env||process.env,c=process.cwd(),l=i.options.cwd!=null,D=l&&process.chdir!==void 0&&!process.chdir.disabled;if(D)try{process.chdir(i.options.cwd)}catch{}let d;try{d=t.sync(i.command,{path:a[n({env:a})],pathExt:u?e.delimiter:void 0})}catch{}finally{D&&process.chdir(c)}return d&&(d=e.resolve(l?i.options.cwd:"",d)),d}o(s,"resolveCommandAttempt");function r(i){return s(i)||s(i,!0)}return o(r,"resolveCommand"),nr=r,nr}o(Dd,"requireResolveCommand");var ln={},ua;function dd(){if(ua)return ln;ua=1;const e=/([()\][%!^"`<>&|;, *?])/g;function t(s){return s=s.replace(e,"^$1"),s}o(t,"escapeCommand");function n(s,r){return s=`${s}`,s=s.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),s=s.replace(/(?=(\\+?)?)\1$/,"$1$1"),s=`"${s}"`,s=s.replace(e,"^$1"),r&&(s=s.replace(e,"^$1")),s}return o(n,"escapeArgument"),ln.command=t,ln.argument=n,ln}o(dd,"require_escape");var sr,ia;function hd(){return ia||(ia=1,sr=/^#!(.*)/),sr}o(hd,"requireShebangRegex");var rr,oa;function fd(){if(oa)return rr;oa=1;const e=hd();return rr=o((t="")=>{const n=t.match(e);if(!n)return null;const[s,r]=n[0].replace(/#! ?/,"").split(" "),i=s.split("/").pop();return i==="env"?r:r?`${i} ${r}`:i},"shebangCommand"),rr}o(fd,"requireShebangCommand");var ur,aa;function pd(){if(aa)return ur;aa=1;const e=Us,t=fd();function n(s){const i=Buffer.alloc(150);let u;try{u=e.openSync(s,"r"),e.readSync(u,i,0,150,0),e.closeSync(u)}catch{}return t(i.toString())}return o(n,"readShebang"),ur=n,ur}o(pd,"requireReadShebang");var ir,ca;function md(){if(ca)return ir;ca=1;const e=ae,t=Dd(),n=dd(),s=pd(),r=process.platform==="win32",i=/\.(?:com|exe)$/i,u=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function a(D){D.file=t(D);const d=D.file&&s(D.file);return d?(D.args.unshift(D.file),D.command=d,t(D)):D.file}o(a,"detectShebang");function c(D){if(!r)return D;const d=a(D),f=!i.test(d);if(D.options.forceShell||f){const h=u.test(d);D.command=e.normalize(D.command),D.command=n.command(D.command),D.args=D.args.map(m=>n.argument(m,h));const F=[D.command].concat(D.args).join(" ");D.args=["/d","/s","/c",`"${F}"`],D.command=process.env.comspec||"cmd.exe",D.options.windowsVerbatimArguments=!0}return D}o(c,"parseNonShell");function l(D,d,f){d&&!Array.isArray(d)&&(f=d,d=null),d=d?d.slice(0):[],f=Object.assign({},f);const h={command:D,args:d,options:f,file:void 0,original:{command:D,args:d}};return f.shell?h:c(h)}return o(l,"parse"),ir=l,ir}o(md,"requireParse");var or,la;function Fd(){if(la)return or;la=1;const e=process.platform==="win32";function t(i,u){return Object.assign(new Error(`${u} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${u} ${i.command}`,path:i.command,spawnargs:i.args})}o(t,"notFoundError");function n(i,u){if(!e)return;const a=i.emit;i.emit=function(c,l){if(c==="exit"){const D=s(l,u);if(D)return a.call(i,"error",D)}return a.apply(i,arguments)}}o(n,"hookChildProcess");function s(i,u){return e&&i===1&&!u.file?t(u.original,"spawn"):null}o(s,"verifyENOENT");function r(i,u){return e&&i===1&&!u.file?t(u.original,"spawnSync"):null}return o(r,"verifyENOENTSync"),or={hookChildProcess:n,verifyENOENT:s,verifyENOENTSync:r,notFoundError:t},or}o(Fd,"requireEnoent");var Da;function gd(){if(Da)return be.exports;Da=1;const e=jl,t=md(),n=Fd();function s(i,u,a){const c=t(i,u,a),l=e.spawn(c.command,c.args,c.options);return n.hookChildProcess(l,c),l}o(s,"spawn");function r(i,u,a){const c=t(i,u,a),l=e.spawnSync(c.command,c.args,c.options);return l.error=l.error||n.verifyENOENTSync(l.status,c),l}return o(r,"spawnSync"),be.exports=s,be.exports.spawn=s,be.exports.sync=r,be.exports._parse=t,be.exports._enoent=n,be.exports}o(gd,"requireCrossSpawn");var Cd=gd(),Ed=Le(Cd);function yd(e){const t=typeof e=="string"?`
24
- `:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}o(yd,"stripFinalNewline");function da(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"}o(da,"pathKey");const wd=o(({cwd:e=j.cwd(),path:t=j.env[da()],preferLocal:n=!0,execPath:s=j.execPath,addExecPath:r=!0}={})=>{const i=e instanceof URL?co(e):e,u=Me.resolve(i),a=[];return n&&bd(a,u),r&&_d(a,s,u),[...a,t].join(Me.delimiter)},"npmRunPath"),bd=o((e,t)=>{let n;for(;n!==t;)e.push(Me.join(t,"node_modules/.bin")),n=t,t=Me.resolve(t,"..")},"applyPreferLocal"),_d=o((e,t,n)=>{const s=t instanceof URL?co(t):t;e.push(Me.resolve(n,s,".."))},"applyExecPath"),Bd=o(({env:e=j.env,...t}={})=>{e={...e};const n=da({env:e});return t.path=e[n],e[n]=wd(t),e},"npmRunPathEnv"),Ad=o((e,t,n,s)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const r=Object.getOwnPropertyDescriptor(e,n),i=Object.getOwnPropertyDescriptor(t,n);!vd(r,i)&&s||Object.defineProperty(e,n,i)},"copyProperty"),vd=o(function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},"canCopyProperty"),$d=o((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},"changePrototype"),xd=o((e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,"wrappedToString"),Sd=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Id=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Od=o((e,t,n)=>{const s=n===""?"":`with ${n.trim()}() `,r=xd.bind(null,s,t.toString());Object.defineProperty(r,"name",Id),Object.defineProperty(e,"toString",{...Sd,value:r})},"changeToString");function Rd(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:s}=e;for(const r of Reflect.ownKeys(t))Ad(e,t,r,n);return $d(e,t),Od(e,t,s),e}o(Rd,"mimicFunction");const Dn=new WeakMap,ha=o((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,s=0;const r=e.displayName||e.name||"<anonymous>",i=o(function(...u){if(Dn.set(i,++s),s===1)n=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return n},"onetime2");return Rd(i,e),Dn.set(i,s),i},"onetime");ha.callCount=e=>{if(!Dn.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return Dn.get(e)};const kd=o(()=>{const e=pa-fa+1;return Array.from({length:e},Pd)},"getRealtimeSignals"),Pd=o((e,t)=>({name:`SIGRT${t+1}`,number:fa+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),"getRealtimeSignal"),fa=34,pa=64,Td=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],ma=o(()=>{const e=kd();return[...Td,...e].map(Nd)},"getSignals"),Nd=o(({name:e,number:t,description:n,action:s,forced:r=!1,standard:i})=>{const{signals:{[e]:u}}=lo,a=u!==void 0;return{name:e,number:a?u:t,description:n,supported:a,action:s,forced:r,standard:i}},"normalizeSignal"),Md=o(()=>{const e=ma();return Object.fromEntries(e.map(Ld))},"getSignalsByName"),Ld=o(({name:e,number:t,description:n,supported:s,action:r,forced:i,standard:u})=>[e,{name:e,number:t,description:n,supported:s,action:r,forced:i,standard:u}],"getSignalByName"),jd=Md(),Ud=o(()=>{const e=ma(),t=pa+1,n=Array.from({length:t},(s,r)=>Wd(r,e));return Object.assign({},...n)},"getSignalsByNumber"),Wd=o((e,t)=>{const n=qd(e,t);if(n===void 0)return{};const{name:s,description:r,supported:i,action:u,forced:a,standard:c}=n;return{[e]:{name:s,number:e,description:r,supported:i,action:u,forced:a,standard:c}}},"getSignalByNumber"),qd=o((e,t)=>{const n=t.find(({name:s})=>lo.signals[s]===e);return n!==void 0?n:t.find(s=>s.number===e)},"findSignalByNumber");Ud();const Gd=o(({timedOut:e,timeout:t,errorCode:n,signal:s,signalDescription:r,exitCode:i,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":n!==void 0?`failed with ${n}`:s!==void 0?`was killed with ${s} (${r})`:i!==void 0?`failed with exit code ${i}`:"failed","getErrorPrefix"),Fa=o(({stdout:e,stderr:t,all:n,error:s,signal:r,exitCode:i,command:u,escapedCommand:a,timedOut:c,isCanceled:l,killed:D,parsed:{options:{timeout:d,cwd:f=j.cwd()}}})=>{i=i===null?void 0:i,r=r===null?void 0:r;const h=r===void 0?void 0:jd[r].description,F=s&&s.code,E=`Command ${Gd({timedOut:c,timeout:d,errorCode:F,signal:r,signalDescription:h,exitCode:i,isCanceled:l})}: ${u}`,y=Object.prototype.toString.call(s)==="[object Error]",g=y?`${E}
21
+ `}table({tableData:t,tableOptions:n,tableBreakpoints:s}){return ID(t.map(r=>r.map(i=>this.render(i))),s?kD(s):n)}flagParameter(t){return t===Boolean?"":t===String?"<string>":t===Number?"<number>":Array.isArray(t)?this.flagParameter(t[0]):"<value>"}flagOperator(t){return" "}flagName(t){const{flag:n,flagFormatted:s,aliasesEnabled:r,aliasFormatted:i}=t;let u="";if(i?u+=`${i}, `:r&&(u+=" "),u+=s,"placeholder"in n&&typeof n.placeholder=="string")u+=`${this.flagOperator(t)}${n.placeholder}`;else{const a=this.flagParameter("type"in n?n.type:n);a&&(u+=`${this.flagOperator(t)}${a}`)}return u}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:s}=t;typeof s=="function"&&(s=s()),s&&(n+=` (default: ${this.flagDefault(s)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
22
+ `);if("type"in t&&this[t.type]){const n=this[t.type];if(typeof n=="function")return n.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}},o(it,"_z"),it);P(Vo,"Renderers");let UD=Vo;const Vs=P(e=>e.length>0&&!e.includes(" "),"isValidScriptName"),{stringify:le}=JSON,WD=/[|\\{}()[\]^$+*?.]/;function rn(e){const t=[];let n,s;for(const r of e){if(s)throw new Error(`Invalid parameter: Spread parameter ${le(s)} must be last`);const i=r[0],u=r.at(-1);let a;if(i==="<"&&u===">"&&(a=!0,n))throw new Error(`Invalid parameter: Required parameter ${le(r)} cannot come after optional parameter ${le(n)}`);if(i==="["&&u==="]"&&(a=!1,n=r),a===void 0)throw new Error(`Invalid parameter: ${le(r)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let c=r.slice(1,-1);const l=c.slice(-3)==="...";l&&(s=r,c=c.slice(0,-3));const d=c.match(WD);if(d)throw new Error(`Invalid parameter: ${le(r)}. Invalid character found ${le(d[0])}`);t.push({name:c,required:a,spread:l})}return t}o(rn,"b$1"),P(rn,"parseParameters");function un(e,t,n,s){for(let r=0;r<t.length;r+=1){const{name:i,required:u,spread:a}=t[r],c=TD(i);if(c in e)throw new Error(`Invalid parameter: ${le(i)} is used more than once.`);const l=a?n.slice(r):n[r];if(a&&(r=t.length),u&&(!l||a&&l.length===0))return console.error(`Error: Missing required parameter ${le(i)}
23
+ `),s(),process.exit(1);e[c]=l}}o(un,"v"),P(un,"mapParametersToArguments");function Jo(e){return e===void 0||e!==!1}o(Jo,"G$2"),P(Jo,"helpEnabled");function Js(e,t,n,s){const r={...t.flags},i=t.version&&!("version"in r);i&&(r.version={type:Boolean,description:"Show version"});const{help:u}=t,a=Jo(u);a&&!("help"in r)&&(r.help={type:Boolean,alias:"h",description:"Show help"});const c=lD(r,s,{ignore:t.ignoreArgv}),l=P(()=>{console.log(t.version)},"showVersion");if(i&&c.flags.version===!0)return l(),process.exit(0);const d=new UD,D=a&&u?.render?u.render:m=>d.render(m),f=P(m=>{const E=LD({...t,...m?{help:m}:{},flags:r});console.log(D(E,d))},"showHelp");if(a&&c.flags.help===!0)return f(),process.exit(0);if(t.parameters){let{parameters:m}=t,E=c._;const y=m.indexOf("--"),g=m.slice(y+1),b=Object.create(null);if(y>-1&&g.length>0){m=m.slice(0,y);const B=c._["--"];E=E.slice(0,-B.length||void 0),un(b,rn(m),E,f),un(b,rn(g),B,f)}else un(b,rn(m),E,f);Object.assign(c._,b)}const h={...c,showVersion:l,showHelp:f},F={command:e,...h};if(typeof n=="function"){const m=n(h);if(m&&"then"in m)return Object.assign(Promise.resolve(m),F)}return F}o(Js,"j"),P(Js,"cliBase");function Xo(e,t){const n=new Map;for(const s of t){const r=[s.options.name],{alias:i}=s.options;i&&(Array.isArray(i)?r.push(...i):r.push(i));for(const u of r){if(n.has(u))throw new Error(`Duplicate command name found: ${le(u)}`);n.set(u,s)}}return n.get(e)}o(Xo,"K$1"),P(Xo,"getCommand");function Yo(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Vs(e.name)))throw new Error(`Invalid script name: ${le(e.name)}`);const s=n[0];if(e.commands&&s&&Vs(s)){const r=Xo(s,e.commands);if(r)return Js(r.options.name,{...r.options,parent:e},r.callback,n.slice(1))}return Js(void 0,e,t,n)}o(Yo,"Q"),P(Yo,"cli");function gt(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(n===void 0)throw new Error("Command name is required");if(!Vs(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}o(gt,"X"),P(gt,"command");var qD="aicommits",GD="1.12.0-develop.6",KD="Writes your git commit messages for you with AI",HD=["ai","git","commit","code changes"],zD="MIT",VD="Nutlope/aicommits",JD="Hassan El Mghari (@nutlope)",XD="module",YD=["dist"],QD={aicommits:"./dist/cli.mjs",aic:"./dist/cli.mjs"},ZD={build:"pkgroll --minify",lint:"","type-check":"tsc",test:"tsx tests",prepack:"pnpm build && clean-pkg-json"},ed={"@clack/prompts":"^0.11.0","@types/ini":"^1.3.31","@types/node":"^24.10.1","@types/update-notifier":"^6.0.8","clean-pkg-json":"^1.3.0",cleye:"^2.0.0",clipboardy:"^5.0.0",execa:"^7.0.0","fs-fixture":"^1.2.0",ini:"^3.0.1",kolorist:"^1.8.0",manten:"^0.7.0",openai:"^6.9.0",pkgroll:"^2.20.1",tsx:"^4.20.6",typescript:"^5.9.3"},td={branches:["main",{name:"develop",prerelease:!0}]},nd={"update-notifier":"^7.3.1"},Xs={name:qD,version:GD,description:KD,keywords:HD,license:zD,repository:VD,author:JD,type:XD,files:YD,bin:QD,scripts:ZD,devDependencies:ed,release:td,dependencies:nd},ge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(Me,"getDefaultExportFromCjs");var be={exports:{}},Ys,Qo;function sd(){if(Qo)return Ys;Qo=1,Ys=s,s.sync=r;var e=js;function t(i,u){var a=u.pathExt!==void 0?u.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var c=0;c<a.length;c++){var l=a[c].toLowerCase();if(l&&i.substr(-l.length).toLowerCase()===l)return!0}return!1}o(t,"checkPathExt");function n(i,u,a){return!i.isSymbolicLink()&&!i.isFile()?!1:t(u,a)}o(n,"checkStat");function s(i,u,a){e.stat(i,function(c,l){a(c,c?!1:n(l,i,u))})}o(s,"isexe");function r(i,u){return n(e.statSync(i),i,u)}return o(r,"sync"),Ys}o(sd,"requireWindows");var Qs,Zo;function rd(){if(Zo)return Qs;Zo=1,Qs=t,t.sync=n;var e=js;function t(i,u,a){e.stat(i,function(c,l){a(c,c?!1:s(l,u))})}o(t,"isexe");function n(i,u){return s(e.statSync(i),u)}o(n,"sync");function s(i,u){return i.isFile()&&r(i,u)}o(s,"checkStat");function r(i,u){var a=i.mode,c=i.uid,l=i.gid,d=u.uid!==void 0?u.uid:process.getuid&&process.getuid(),D=u.gid!==void 0?u.gid:process.getgid&&process.getgid(),f=parseInt("100",8),h=parseInt("010",8),F=parseInt("001",8),m=f|h,E=a&F||a&h&&l===D||a&f&&c===d||a&m&&d===0;return E}return o(r,"checkMode"),Qs}o(rd,"requireMode");var Zs,ea;function ud(){if(ea)return Zs;ea=1;var e;process.platform==="win32"||ge.TESTING_WINDOWS?e=sd():e=rd(),Zs=t,t.sync=n;function t(s,r,i){if(typeof r=="function"&&(i=r,r={}),!i){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(u,a){t(s,r||{},function(c,l){c?a(c):u(l)})})}e(s,r||{},function(u,a){u&&(u.code==="EACCES"||r&&r.ignoreErrors)&&(u=null,a=!1),i(u,a)})}o(t,"isexe");function n(s,r){try{return e.sync(s,r||{})}catch(i){if(r&&r.ignoreErrors||i.code==="EACCES")return!1;throw i}}return o(n,"sync"),Zs}o(ud,"requireIsexe");var er,ta;function id(){if(ta)return er;ta=1;const e=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",t=ae,n=e?";":":",s=ud(),r=o(c=>Object.assign(new Error(`not found: ${c}`),{code:"ENOENT"}),"getNotFoundError"),i=o((c,l)=>{const d=l.colon||n,D=c.match(/\//)||e&&c.match(/\\/)?[""]:[...e?[process.cwd()]:[],...(l.path||process.env.PATH||"").split(d)],f=e?l.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",h=e?f.split(d):[""];return e&&c.indexOf(".")!==-1&&h[0]!==""&&h.unshift(""),{pathEnv:D,pathExt:h,pathExtExe:f}},"getPathInfo"),u=o((c,l,d)=>{typeof l=="function"&&(d=l,l={}),l||(l={});const{pathEnv:D,pathExt:f,pathExtExe:h}=i(c,l),F=[],m=o(y=>new Promise((g,b)=>{if(y===D.length)return l.all&&F.length?g(F):b(r(c));const B=D[y],I=/^".*"$/.test(B)?B.slice(1,-1):B,O=t.join(I,c),R=!I&&/^\.[\\\/]/.test(c)?c.slice(0,2)+O:O;g(E(R,y,0))}),"step"),E=o((y,g,b)=>new Promise((B,I)=>{if(b===f.length)return B(m(g+1));const O=f[b];s(y+O,{pathExt:h},(R,L)=>{if(!R&&L)if(l.all)F.push(y+O);else return B(y+O);return B(E(y,g,b+1))})}),"subStep");return d?m(0).then(y=>d(null,y),d):m(0)},"which"),a=o((c,l)=>{l=l||{};const{pathEnv:d,pathExt:D,pathExtExe:f}=i(c,l),h=[];for(let F=0;F<d.length;F++){const m=d[F],E=/^".*"$/.test(m)?m.slice(1,-1):m,y=t.join(E,c),g=!E&&/^\.[\\\/]/.test(c)?c.slice(0,2)+y:y;for(let b=0;b<D.length;b++){const B=g+D[b];try{if(s.sync(B,{pathExt:f}))if(l.all)h.push(B);else return B}catch{}}}if(l.all&&h.length)return h;if(l.nothrow)return null;throw r(c)},"whichSync");return er=u,u.sync=a,er}o(id,"requireWhich");var on={exports:{}},na;function od(){if(na)return on.exports;na=1;const e=o((t={})=>{const n=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(n).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"},"pathKey");return on.exports=e,on.exports.default=e,on.exports}o(od,"requirePathKey");var tr,sa;function ad(){if(sa)return tr;sa=1;const e=ae,t=id(),n=od();function s(i,u){const a=i.options.env||process.env,c=process.cwd(),l=i.options.cwd!=null,d=l&&process.chdir!==void 0&&!process.chdir.disabled;if(d)try{process.chdir(i.options.cwd)}catch{}let D;try{D=t.sync(i.command,{path:a[n({env:a})],pathExt:u?e.delimiter:void 0})}catch{}finally{d&&process.chdir(c)}return D&&(D=e.resolve(l?i.options.cwd:"",D)),D}o(s,"resolveCommandAttempt");function r(i){return s(i)||s(i,!0)}return o(r,"resolveCommand"),tr=r,tr}o(ad,"requireResolveCommand");var an={},ra;function cd(){if(ra)return an;ra=1;const e=/([()\][%!^"`<>&|;, *?])/g;function t(s){return s=s.replace(e,"^$1"),s}o(t,"escapeCommand");function n(s,r){return s=`${s}`,s=s.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),s=s.replace(/(?=(\\+?)?)\1$/,"$1$1"),s=`"${s}"`,s=s.replace(e,"^$1"),r&&(s=s.replace(e,"^$1")),s}return o(n,"escapeArgument"),an.command=t,an.argument=n,an}o(cd,"require_escape");var nr,ua;function ld(){return ua||(ua=1,nr=/^#!(.*)/),nr}o(ld,"requireShebangRegex");var sr,ia;function Dd(){if(ia)return sr;ia=1;const e=ld();return sr=o((t="")=>{const n=t.match(e);if(!n)return null;const[s,r]=n[0].replace(/#! ?/,"").split(" "),i=s.split("/").pop();return i==="env"?r:r?`${i} ${r}`:i},"shebangCommand"),sr}o(Dd,"requireShebangCommand");var rr,oa;function dd(){if(oa)return rr;oa=1;const e=js,t=Dd();function n(s){const i=Buffer.alloc(150);let u;try{u=e.openSync(s,"r"),e.readSync(u,i,0,150,0),e.closeSync(u)}catch{}return t(i.toString())}return o(n,"readShebang"),rr=n,rr}o(dd,"requireReadShebang");var ur,aa;function hd(){if(aa)return ur;aa=1;const e=ae,t=ad(),n=cd(),s=dd(),r=process.platform==="win32",i=/\.(?:com|exe)$/i,u=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function a(d){d.file=t(d);const D=d.file&&s(d.file);return D?(d.args.unshift(d.file),d.command=D,t(d)):d.file}o(a,"detectShebang");function c(d){if(!r)return d;const D=a(d),f=!i.test(D);if(d.options.forceShell||f){const h=u.test(D);d.command=e.normalize(d.command),d.command=n.command(d.command),d.args=d.args.map(m=>n.argument(m,h));const F=[d.command].concat(d.args).join(" ");d.args=["/d","/s","/c",`"${F}"`],d.command=process.env.comspec||"cmd.exe",d.options.windowsVerbatimArguments=!0}return d}o(c,"parseNonShell");function l(d,D,f){D&&!Array.isArray(D)&&(f=D,D=null),D=D?D.slice(0):[],f=Object.assign({},f);const h={command:d,args:D,options:f,file:void 0,original:{command:d,args:D}};return f.shell?h:c(h)}return o(l,"parse"),ur=l,ur}o(hd,"requireParse");var ir,ca;function fd(){if(ca)return ir;ca=1;const e=process.platform==="win32";function t(i,u){return Object.assign(new Error(`${u} ${i.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${u} ${i.command}`,path:i.command,spawnargs:i.args})}o(t,"notFoundError");function n(i,u){if(!e)return;const a=i.emit;i.emit=function(c,l){if(c==="exit"){const d=s(l,u);if(d)return a.call(i,"error",d)}return a.apply(i,arguments)}}o(n,"hookChildProcess");function s(i,u){return e&&i===1&&!u.file?t(u.original,"spawn"):null}o(s,"verifyENOENT");function r(i,u){return e&&i===1&&!u.file?t(u.original,"spawnSync"):null}return o(r,"verifyENOENTSync"),ir={hookChildProcess:n,verifyENOENT:s,verifyENOENTSync:r,notFoundError:t},ir}o(fd,"requireEnoent");var la;function pd(){if(la)return be.exports;la=1;const e=Ml,t=hd(),n=fd();function s(i,u,a){const c=t(i,u,a),l=e.spawn(c.command,c.args,c.options);return n.hookChildProcess(l,c),l}o(s,"spawn");function r(i,u,a){const c=t(i,u,a),l=e.spawnSync(c.command,c.args,c.options);return l.error=l.error||n.verifyENOENTSync(l.status,c),l}return o(r,"spawnSync"),be.exports=s,be.exports.spawn=s,be.exports.sync=r,be.exports._parse=t,be.exports._enoent=n,be.exports}o(pd,"requireCrossSpawn");var md=pd(),Fd=Me(md);function gd(e){const t=typeof e=="string"?`
24
+ `:10,n=typeof e=="string"?"\r":13;return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}o(gd,"stripFinalNewline");function Da(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"}o(Da,"pathKey");const Cd=o(({cwd:e=j.cwd(),path:t=j.env[Da()],preferLocal:n=!0,execPath:s=j.execPath,addExecPath:r=!0}={})=>{const i=e instanceof URL?ao(e):e,u=Ne.resolve(i),a=[];return n&&Ed(a,u),r&&yd(a,s,u),[...a,t].join(Ne.delimiter)},"npmRunPath"),Ed=o((e,t)=>{let n;for(;n!==t;)e.push(Ne.join(t,"node_modules/.bin")),n=t,t=Ne.resolve(t,"..")},"applyPreferLocal"),yd=o((e,t,n)=>{const s=t instanceof URL?ao(t):t;e.push(Ne.resolve(n,s,".."))},"applyExecPath"),wd=o(({env:e=j.env,...t}={})=>{e={...e};const n=Da({env:e});return t.path=e[n],e[n]=Cd(t),e},"npmRunPathEnv"),bd=o((e,t,n,s)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const r=Object.getOwnPropertyDescriptor(e,n),i=Object.getOwnPropertyDescriptor(t,n);!_d(r,i)&&s||Object.defineProperty(e,n,i)},"copyProperty"),_d=o(function(e,t){return e===void 0||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},"canCopyProperty"),Bd=o((e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},"changePrototype"),Ad=o((e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,"wrappedToString"),vd=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),$d=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),xd=o((e,t,n)=>{const s=n===""?"":`with ${n.trim()}() `,r=Ad.bind(null,s,t.toString());Object.defineProperty(r,"name",$d),Object.defineProperty(e,"toString",{...vd,value:r})},"changeToString");function Sd(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:s}=e;for(const r of Reflect.ownKeys(t))bd(e,t,r,n);return Bd(e,t),xd(e,t,s),e}o(Sd,"mimicFunction");const cn=new WeakMap,da=o((e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,s=0;const r=e.displayName||e.name||"<anonymous>",i=o(function(...u){if(cn.set(i,++s),s===1)n=e.apply(this,u),e=null;else if(t.throw===!0)throw new Error(`Function \`${r}\` can only be called once`);return n},"onetime2");return Sd(i,e),cn.set(i,s),i},"onetime");da.callCount=e=>{if(!cn.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return cn.get(e)};const Id=o(()=>{const e=fa-ha+1;return Array.from({length:e},Od)},"getRealtimeSignals"),Od=o((e,t)=>({name:`SIGRT${t+1}`,number:ha+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),"getRealtimeSignal"),ha=34,fa=64,Rd=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}],pa=o(()=>{const e=Id();return[...Rd,...e].map(kd)},"getSignals"),kd=o(({name:e,number:t,description:n,action:s,forced:r=!1,standard:i})=>{const{signals:{[e]:u}}=co,a=u!==void 0;return{name:e,number:a?u:t,description:n,supported:a,action:s,forced:r,standard:i}},"normalizeSignal"),Pd=o(()=>{const e=pa();return Object.fromEntries(e.map(Td))},"getSignalsByName"),Td=o(({name:e,number:t,description:n,supported:s,action:r,forced:i,standard:u})=>[e,{name:e,number:t,description:n,supported:s,action:r,forced:i,standard:u}],"getSignalByName"),Nd=Pd(),Md=o(()=>{const e=pa(),t=fa+1,n=Array.from({length:t},(s,r)=>Ld(r,e));return Object.assign({},...n)},"getSignalsByNumber"),Ld=o((e,t)=>{const n=jd(e,t);if(n===void 0)return{};const{name:s,description:r,supported:i,action:u,forced:a,standard:c}=n;return{[e]:{name:s,number:e,description:r,supported:i,action:u,forced:a,standard:c}}},"getSignalByNumber"),jd=o((e,t)=>{const n=t.find(({name:s})=>co.signals[s]===e);return n!==void 0?n:t.find(s=>s.number===e)},"findSignalByNumber");Md();const Ud=o(({timedOut:e,timeout:t,errorCode:n,signal:s,signalDescription:r,exitCode:i,isCanceled:u})=>e?`timed out after ${t} milliseconds`:u?"was canceled":n!==void 0?`failed with ${n}`:s!==void 0?`was killed with ${s} (${r})`:i!==void 0?`failed with exit code ${i}`:"failed","getErrorPrefix"),ma=o(({stdout:e,stderr:t,all:n,error:s,signal:r,exitCode:i,command:u,escapedCommand:a,timedOut:c,isCanceled:l,killed:d,parsed:{options:{timeout:D,cwd:f=j.cwd()}}})=>{i=i===null?void 0:i,r=r===null?void 0:r;const h=r===void 0?void 0:Nd[r].description,F=s&&s.code,E=`Command ${Ud({timedOut:c,timeout:D,errorCode:F,signal:r,signalDescription:h,exitCode:i,isCanceled:l})}: ${u}`,y=Object.prototype.toString.call(s)==="[object Error]",g=y?`${E}
26
26
  ${s.message}`:E,b=[g,t,e].filter(Boolean).join(`
27
- `);return y?(s.originalMessage=s.message,s.message=b):s=new Error(b),s.shortMessage=g,s.command=u,s.escapedCommand=a,s.exitCode=i,s.signal=r,s.signalDescription=h,s.stdout=e,s.stderr=t,s.cwd=f,n!==void 0&&(s.all=n),"bufferedData"in s&&delete s.bufferedData,s.failed=!0,s.timedOut=!!c,s.isCanceled=l,s.killed=D&&!c,s},"makeError"),dn=["stdin","stdout","stderr"],Kd=o(e=>dn.some(t=>e[t]!==void 0),"hasAlias"),Hd=o(e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return dn.map(s=>e[s]);if(Kd(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dn.map(s=>`\`${s}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,dn.length);return Array.from({length:n},(s,r)=>t[r])},"normalizeStdio");var _e={exports:{}},ar={exports:{}},ga;function zd(){return ga||(ga=1,(function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")})(ar)),ar.exports}o(zd,"requireSignals");var Ca;function Vd(){if(Ca)return _e.exports;Ca=1;var e=ge.process;const t=o(function(E){return E&&typeof E=="object"&&typeof E.removeListener=="function"&&typeof E.emit=="function"&&typeof E.reallyExit=="function"&&typeof E.listeners=="function"&&typeof E.kill=="function"&&typeof E.pid=="number"&&typeof E.on=="function"},"processOk");if(!t(e))_e.exports=function(){return function(){}};else{var n=ql,s=zd(),r=/^win/i.test(e.platform),i=Gl;typeof i!="function"&&(i=i.EventEmitter);var u;e.__signal_exit_emitter__?u=e.__signal_exit_emitter__:(u=e.__signal_exit_emitter__=new i,u.count=0,u.emitted={}),u.infinite||(u.setMaxListeners(1/0),u.infinite=!0),_e.exports=function(E,y){if(!t(ge.process))return function(){};n.equal(typeof E,"function","a callback must be provided for exit handler"),D===!1&&d();var g="exit";y&&y.alwaysLast&&(g="afterexit");var b=o(function(){u.removeListener(g,E),u.listeners("exit").length===0&&u.listeners("afterexit").length===0&&a()},"remove");return u.on(g,E),b};var a=o(function(){!D||!t(ge.process)||(D=!1,s.forEach(function(y){try{e.removeListener(y,l[y])}catch{}}),e.emit=F,e.reallyExit=f,u.count-=1)},"unload2");_e.exports.unload=a;var c=o(function(y,g,b){u.emitted[y]||(u.emitted[y]=!0,u.emit(y,g,b))},"emit2"),l={};s.forEach(function(E){l[E]=o(function(){if(t(ge.process)){var g=e.listeners(E);g.length===u.count&&(a(),c("exit",null,E),c("afterexit",null,E),r&&E==="SIGHUP"&&(E="SIGINT"),e.kill(e.pid,E))}},"listener")}),_e.exports.signals=function(){return s};var D=!1,d=o(function(){D||!t(ge.process)||(D=!0,u.count+=1,s=s.filter(function(y){try{return e.on(y,l[y]),!0}catch{return!1}}),e.emit=m,e.reallyExit=h)},"load2");_e.exports.load=d;var f=e.reallyExit,h=o(function(y){t(ge.process)&&(e.exitCode=y||0,c("exit",e.exitCode,null),c("afterexit",e.exitCode,null),f.call(e,e.exitCode))},"processReallyExit2"),F=e.emit,m=o(function(y,g){if(y==="exit"&&t(ge.process)){g!==void 0&&(e.exitCode=g);var b=F.apply(this,arguments);return c("exit",e.exitCode,null),c("afterexit",e.exitCode,null),b}else return F.apply(this,arguments)},"processEmit2")}return _e.exports}o(Vd,"requireSignalExit");var Jd=Vd(),Xd=Le(Jd);const Yd=1e3*5,Qd=o((e,t="SIGTERM",n={})=>{const s=e(t);return Zd(e,t,n,s),s},"spawnedKill"),Zd=o((e,t,n,s)=>{if(!eh(t,n,s))return;const r=nh(n),i=setTimeout(()=>{e("SIGKILL")},r);i.unref&&i.unref()},"setKillTimeout"),eh=o((e,{forceKillAfterTimeout:t},n)=>th(e)&&t!==!1&&n,"shouldForceKill"),th=o(e=>e===Wl.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM","isSigterm"),nh=o(({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Yd;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},"getForceKillAfterTimeout"),sh=o((e,t)=>{e.kill()&&(t.isCanceled=!0)},"spawnedCancel"),rh=o((e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},"timeoutKill"),uh=o((e,{timeout:t,killSignal:n="SIGTERM"},s)=>{if(t===0||t===void 0)return s;let r;const i=new Promise((a,c)=>{r=setTimeout(()=>{rh(e,n,c)},t)}),u=s.finally(()=>{clearTimeout(r)});return Promise.race([i,u])},"setupTimeout"),ih=o(({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},"validateTimeout"),oh=o(async(e,{cleanup:t,detached:n},s)=>{if(!t||n)return s;const r=Xd(()=>{e.kill()});return s.finally(()=>{r()})},"setExitHandler");function Ea(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}o(Ea,"isStream");function ya(e){return Ea(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}o(ya,"isWritableStream");const ah=o(e=>e instanceof Ll&&typeof e.then=="function","isExecaChildProcess"),cr=o((e,t,n)=>{if(typeof n=="string")return e[t].pipe(Kl(n)),e;if(ya(n))return e[t].pipe(n),e;if(!ah(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!ya(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},"pipeToTarget"),ch=o(e=>{e.stdout!==null&&(e.pipeStdout=cr.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=cr.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=cr.bind(void 0,e,"all"))},"addPipeMethods");var je={exports:{}},lr,wa;function lh(){if(wa)return lr;wa=1;const{PassThrough:e}=Ws;return lr=o(t=>{t={...t};const{array:n}=t;let{encoding:s}=t;const r=s==="buffer";let i=!1;n?i=!(s||r):s=s||"utf8",r&&(s=null);const u=new e({objectMode:i});s&&u.setEncoding(s);let a=0;const c=[];return u.on("data",l=>{c.push(l),i?a=c.length:a+=l.length}),u.getBufferedValue=()=>n?c:r?Buffer.concat(c,a):c.join(""),u.getBufferedLength=()=>a,u},"bufferStream"),lr}o(lh,"requireBufferStream");var ba;function Dh(){if(ba)return je.exports;ba=1;const{constants:e}=zl,t=Ws,{promisify:n}=Vl,s=lh(),r=n(t.pipeline),a=class a extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};o(a,"MaxBufferError");let i=a;async function u(c,l){if(!c)throw new Error("Expected a stream");l={maxBuffer:1/0,...l};const{maxBuffer:D}=l,d=s(l);return await new Promise((f,h)=>{const F=o(m=>{m&&d.getBufferedLength()<=e.MAX_LENGTH&&(m.bufferedData=d.getBufferedValue()),h(m)},"rejectPromise");(async()=>{try{await r(c,d),f()}catch(m){F(m)}})(),d.on("data",()=>{d.getBufferedLength()>D&&F(new i)})}),d.getBufferedValue()}return o(u,"getStream"),je.exports=u,je.exports.buffer=(c,l)=>u(c,{...l,encoding:"buffer"}),je.exports.array=(c,l)=>u(c,{...l,array:!0}),je.exports.MaxBufferError=i,je.exports}o(Dh,"requireGetStream");var dh=Dh(),_a=Le(dh),Dr,Ba;function hh(){if(Ba)return Dr;Ba=1;const{PassThrough:e}=Ws;return Dr=o(function(){var t=[],n=new e({objectMode:!0});return n.setMaxListeners(0),n.add=s,n.isEmpty=r,n.on("unpipe",i),Array.prototype.slice.call(arguments).forEach(s),n;function s(u){return Array.isArray(u)?(u.forEach(s),this):(t.push(u),u.once("end",i.bind(null,u)),u.once("error",n.emit.bind(n,"error")),u.pipe(n,{end:!1}),this)}o(s,"add");function r(){return t.length==0}o(r,"isEmpty");function i(u){t=t.filter(function(a){return a!==u}),!t.length&&n.readable&&n.end()}o(i,"remove")},"mergeStream$1"),Dr}o(hh,"requireMergeStream");var fh=hh(),ph=Le(fh);const mh=o(e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},"validateInputOptions"),Fh=o(({input:e,inputFile:t})=>typeof t!="string"?e:(mh(e),Hl(t)),"getInput"),gh=o((e,t)=>{const n=Fh(t);n!==void 0&&(Ea(n)?n.pipe(e.stdin):e.stdin.end(n))},"handleInput"),Ch=o((e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=ph();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},"makeAllStream"),dr=o(async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},"getBufferedData"),hr=o((e,{encoding:t,buffer:n,maxBuffer:s})=>{if(!(!e||!n))return t?_a(e,{encoding:t,maxBuffer:s}):_a.buffer(e,{maxBuffer:s})},"getStreamPromise"),Eh=o(async({stdout:e,stderr:t,all:n},{encoding:s,buffer:r,maxBuffer:i},u)=>{const a=hr(e,{encoding:s,buffer:r,maxBuffer:i}),c=hr(t,{encoding:s,buffer:r,maxBuffer:i}),l=hr(n,{encoding:s,buffer:r,maxBuffer:i*2});try{return await Promise.all([u,a,c,l])}catch(D){return Promise.all([{error:D,signal:D.signal,timedOut:D.timedOut},dr(e,a),dr(t,c),dr(n,l)])}},"getSpawnedResult"),yh=(async()=>{})().constructor.prototype,wh=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(yh,e)]),Aa=o((e,t)=>{for(const[n,s]of wh){const r=typeof t=="function"?(...i)=>Reflect.apply(s.value,t(),i):s.value.bind(t);Reflect.defineProperty(e,n,{...s,value:r})}},"mergePromise"),bh=o(e=>new Promise((t,n)=>{e.on("exit",(s,r)=>{t({exitCode:s,signal:r})}),e.on("error",s=>{n(s)}),e.stdin&&e.stdin.on("error",s=>{n(s)})}),"getSpawnedPromise"),va=o((e,t=[])=>Array.isArray(t)?[e,...t]:[e],"normalizeArgs"),_h=/^[\w.-]+$/,Bh=/"/g,Ah=o(e=>typeof e!="string"||_h.test(e)?e:`"${e.replace(Bh,'\\"')}"`,"escapeArg"),vh=o((e,t)=>va(e,t).join(" "),"joinCommand"),$h=o((e,t)=>va(e,t).map(n=>Ah(n)).join(" "),"getEscapedCommand"),xh=Jl("execa").enabled,hn=o((e,t)=>String(e).padStart(t,"0"),"padField"),Sh=o(()=>{const e=new Date;return`${hn(e.getHours(),2)}:${hn(e.getMinutes(),2)}:${hn(e.getSeconds(),2)}.${hn(e.getMilliseconds(),3)}`},"getTimestamp"),Ih=o((e,{verbose:t})=>{t&&j.stderr.write(`[${Sh()}] ${e}
28
- `)},"logCommand"),Oh=1e3*1e3*100,Rh=o(({env:e,extendEnv:t,preferLocal:n,localDir:s,execPath:r})=>{const i=t?{...j.env,...e}:e;return n?Bd({env:i,cwd:s,execPath:r}):i},"getEnv"),kh=o((e,t,n={})=>{const s=Ed._parse(e,t,n);return e=s.command,t=s.args,n=s.options,n={maxBuffer:Oh,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||j.cwd(),execPath:j.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:xh,...n},n.env=Rh(n),n.stdio=Hd(n),j.platform==="win32"&&Me.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:s}},"handleArguments"),fr=o((e,t,n)=>typeof t!="string"&&!Ml.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?yd(t):t,"handleOutput");function Et(e,t,n){const s=kh(e,t,n),r=vh(e,t),i=$h(e,t);Ih(i,s.options),ih(s.options);let u;try{u=io.spawn(s.file,s.args,s.options)}catch(h){const F=new io.ChildProcess,m=Promise.reject(Fa({error:h,stdout:"",stderr:"",all:"",command:r,escapedCommand:i,parsed:s,timedOut:!1,isCanceled:!1,killed:!1}));return Aa(F,m),F}const a=bh(u),c=uh(u,s.options,a),l=oh(u,s.options,c),D={isCanceled:!1};u.kill=Qd.bind(null,u.kill.bind(u)),u.cancel=sh.bind(null,u,D);const f=ha(o(async()=>{const[{error:h,exitCode:F,signal:m,timedOut:E},y,g,b]=await Eh(u,s.options,l),B=fr(s.options,y),I=fr(s.options,g),O=fr(s.options,b);if(h||F!==0||m!==null){const R=Fa({error:h,exitCode:F,signal:m,stdout:B,stderr:I,all:O,command:r,escapedCommand:i,parsed:s,timedOut:E,isCanceled:D.isCanceled||(s.options.signal?s.options.signal.aborted:!1),killed:u.killed});if(!s.options.reject)return R;throw R}return{command:r,escapedCommand:i,exitCode:0,stdout:B,stderr:I,all:O,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return gh(u,s.options),u.all=Ch(u,s.options),ch(u),Aa(u,f),u}o(Et,"execa");let Be=!0;const Ue=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let yt=0;if(Ue.process&&Ue.process.env&&Ue.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:n,TERM:s,COLORTERM:r}=Ue.process.env;t||n||e==="0"?Be=!1:e==="1"||e==="2"||e==="3"?Be=!0:s==="dumb"?Be=!1:"CI"in Ue.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(i=>i in Ue.process.env)?Be=!0:Be=process.stdout.isTTY,Be&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?yt=3:s&&(s.endsWith("-256color")||s.endsWith("256"))?yt=2:yt=1)}let pr={enabled:Be,supportLevel:yt};function wt(e,t,n=1){const s=`\x1B[${e}m`,r=`\x1B[${t}m`,i=new RegExp(`\\x1b\\[${t}m`,"g");return u=>pr.enabled&&pr.supportLevel>=n?s+(""+u).replace(i,s)+r:""+u}o(wt,"kolorist");const mr=wt(2,22),Fr=wt(30,39),gr=wt(31,39),We=wt(32,39),Cr=wt(46,49);var Ph=Object.freeze({__proto__:null,bgCyan:Cr,black:Fr,dim:mr,green:We,options:pr,red:gr});const bt={};bt.write=async e=>{await navigator.clipboard.writeText(e)},bt.read=async()=>navigator.clipboard.readText(),bt.readSync=()=>{throw new Error("`.readSync()` is not supported in browsers!")},bt.writeSync=()=>{throw new Error("`.writeSync()` is not supported in browsers!")};var Er,$a;function Th(){if($a)return Er;$a=1;const e="\x1B",t=`${e}[`,n="\x07",s={to(u,a){return a?`${t}${a+1};${u+1}H`:`${t}${u+1}G`},move(u,a){let c="";return u<0?c+=`${t}${-u}D`:u>0&&(c+=`${t}${u}C`),a<0?c+=`${t}${-a}A`:a>0&&(c+=`${t}${a}B`),c},up:o((u=1)=>`${t}${u}A`,"up"),down:o((u=1)=>`${t}${u}B`,"down"),forward:o((u=1)=>`${t}${u}C`,"forward"),backward:o((u=1)=>`${t}${u}D`,"backward"),nextLine:o((u=1)=>`${t}E`.repeat(u),"nextLine"),prevLine:o((u=1)=>`${t}F`.repeat(u),"prevLine"),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},r={up:o((u=1)=>`${t}S`.repeat(u),"up"),down:o((u=1)=>`${t}T`.repeat(u),"down")},i={screen:`${t}2J`,up:o((u=1)=>`${t}1J`.repeat(u),"up"),down:o((u=1)=>`${t}J`.repeat(u),"down"),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(u){let a="";for(let c=0;c<u;c++)a+=this.line+(c<u-1?s.up():"");return u&&(a+=s.left),a}};return Er={cursor:s,scroll:r,erase:i,beep:n},Er}o(Th,"requireSrc");var Z=Th(),fn={exports:{}},xa;function Nh(){if(xa)return fn.exports;xa=1;let e=process||{},t=e.argv||[],n=e.env||{},s=!(n.NO_COLOR||t.includes("--no-color"))&&(!!n.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&n.TERM!=="dumb"||!!n.CI),r=o((a,c,l=a)=>D=>{let d=""+D,f=d.indexOf(c,a.length);return~f?a+i(d,c,l,f)+c:a+d+c},"formatter"),i=o((a,c,l,D)=>{let d="",f=0;do d+=a.substring(f,D)+l,f=D+c.length,D=a.indexOf(c,f);while(~D);return d+a.substring(f)},"replaceClose"),u=o((a=s)=>{let c=a?r:()=>String;return{isColorSupported:a,reset:c("\x1B[0m","\x1B[0m"),bold:c("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:c("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:c("\x1B[3m","\x1B[23m"),underline:c("\x1B[4m","\x1B[24m"),inverse:c("\x1B[7m","\x1B[27m"),hidden:c("\x1B[8m","\x1B[28m"),strikethrough:c("\x1B[9m","\x1B[29m"),black:c("\x1B[30m","\x1B[39m"),red:c("\x1B[31m","\x1B[39m"),green:c("\x1B[32m","\x1B[39m"),yellow:c("\x1B[33m","\x1B[39m"),blue:c("\x1B[34m","\x1B[39m"),magenta:c("\x1B[35m","\x1B[39m"),cyan:c("\x1B[36m","\x1B[39m"),white:c("\x1B[37m","\x1B[39m"),gray:c("\x1B[90m","\x1B[39m"),bgBlack:c("\x1B[40m","\x1B[49m"),bgRed:c("\x1B[41m","\x1B[49m"),bgGreen:c("\x1B[42m","\x1B[49m"),bgYellow:c("\x1B[43m","\x1B[49m"),bgBlue:c("\x1B[44m","\x1B[49m"),bgMagenta:c("\x1B[45m","\x1B[49m"),bgCyan:c("\x1B[46m","\x1B[49m"),bgWhite:c("\x1B[47m","\x1B[49m"),blackBright:c("\x1B[90m","\x1B[39m"),redBright:c("\x1B[91m","\x1B[39m"),greenBright:c("\x1B[92m","\x1B[39m"),yellowBright:c("\x1B[93m","\x1B[39m"),blueBright:c("\x1B[94m","\x1B[39m"),magentaBright:c("\x1B[95m","\x1B[39m"),cyanBright:c("\x1B[96m","\x1B[39m"),whiteBright:c("\x1B[97m","\x1B[39m"),bgBlackBright:c("\x1B[100m","\x1B[49m"),bgRedBright:c("\x1B[101m","\x1B[49m"),bgGreenBright:c("\x1B[102m","\x1B[49m"),bgYellowBright:c("\x1B[103m","\x1B[49m"),bgBlueBright:c("\x1B[104m","\x1B[49m"),bgMagentaBright:c("\x1B[105m","\x1B[49m"),bgCyanBright:c("\x1B[106m","\x1B[49m"),bgWhiteBright:c("\x1B[107m","\x1B[49m")}},"createColors");return fn.exports=u(),fn.exports.createColors=u,fn.exports}o(Nh,"requirePicocolors");var Mh=Nh(),w=Le(Mh);function Lh({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}o(Lh,"DD");const jh=Lh();function Sa(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(jh,"")}o(Sa,"P$1");function Ia(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(Ia,"L$1");var Oa={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(s){var r=s.charCodeAt(0),i=s.length==2?s.charCodeAt(1):0,u=r;return 55296<=r&&r<=56319&&56320<=i&&i<=57343&&(r&=1023,i&=1023,u=r<<10|i,u+=65536),u==12288||65281<=u&&u<=65376||65504<=u&&u<=65510?"F":u==8361||65377<=u&&u<=65470||65474<=u&&u<=65479||65482<=u&&u<=65487||65490<=u&&u<=65495||65498<=u&&u<=65500||65512<=u&&u<=65518?"H":4352<=u&&u<=4447||4515<=u&&u<=4519||4602<=u&&u<=4607||9001<=u&&u<=9002||11904<=u&&u<=11929||11931<=u&&u<=12019||12032<=u&&u<=12245||12272<=u&&u<=12283||12289<=u&&u<=12350||12353<=u&&u<=12438||12441<=u&&u<=12543||12549<=u&&u<=12589||12593<=u&&u<=12686||12688<=u&&u<=12730||12736<=u&&u<=12771||12784<=u&&u<=12830||12832<=u&&u<=12871||12880<=u&&u<=13054||13056<=u&&u<=19903||19968<=u&&u<=42124||42128<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||55216<=u&&u<=55238||55243<=u&&u<=55291||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65106||65108<=u&&u<=65126||65128<=u&&u<=65131||110592<=u&&u<=110593||127488<=u&&u<=127490||127504<=u&&u<=127546||127552<=u&&u<=127560||127568<=u&&u<=127569||131072<=u&&u<=194367||177984<=u&&u<=196605||196608<=u&&u<=262141?"W":32<=u&&u<=126||162<=u&&u<=163||165<=u&&u<=166||u==172||u==175||10214<=u&&u<=10221||10629<=u&&u<=10630?"Na":u==161||u==164||167<=u&&u<=168||u==170||173<=u&&u<=174||176<=u&&u<=180||182<=u&&u<=186||188<=u&&u<=191||u==198||u==208||215<=u&&u<=216||222<=u&&u<=225||u==230||232<=u&&u<=234||236<=u&&u<=237||u==240||242<=u&&u<=243||247<=u&&u<=250||u==252||u==254||u==257||u==273||u==275||u==283||294<=u&&u<=295||u==299||305<=u&&u<=307||u==312||319<=u&&u<=322||u==324||328<=u&&u<=331||u==333||338<=u&&u<=339||358<=u&&u<=359||u==363||u==462||u==464||u==466||u==468||u==470||u==472||u==474||u==476||u==593||u==609||u==708||u==711||713<=u&&u<=715||u==717||u==720||728<=u&&u<=731||u==733||u==735||768<=u&&u<=879||913<=u&&u<=929||931<=u&&u<=937||945<=u&&u<=961||963<=u&&u<=969||u==1025||1040<=u&&u<=1103||u==1105||u==8208||8211<=u&&u<=8214||8216<=u&&u<=8217||8220<=u&&u<=8221||8224<=u&&u<=8226||8228<=u&&u<=8231||u==8240||8242<=u&&u<=8243||u==8245||u==8251||u==8254||u==8308||u==8319||8321<=u&&u<=8324||u==8364||u==8451||u==8453||u==8457||u==8467||u==8470||8481<=u&&u<=8482||u==8486||u==8491||8531<=u&&u<=8532||8539<=u&&u<=8542||8544<=u&&u<=8555||8560<=u&&u<=8569||u==8585||8592<=u&&u<=8601||8632<=u&&u<=8633||u==8658||u==8660||u==8679||u==8704||8706<=u&&u<=8707||8711<=u&&u<=8712||u==8715||u==8719||u==8721||u==8725||u==8730||8733<=u&&u<=8736||u==8739||u==8741||8743<=u&&u<=8748||u==8750||8756<=u&&u<=8759||8764<=u&&u<=8765||u==8776||u==8780||u==8786||8800<=u&&u<=8801||8804<=u&&u<=8807||8810<=u&&u<=8811||8814<=u&&u<=8815||8834<=u&&u<=8835||8838<=u&&u<=8839||u==8853||u==8857||u==8869||u==8895||u==8978||9312<=u&&u<=9449||9451<=u&&u<=9547||9552<=u&&u<=9587||9600<=u&&u<=9615||9618<=u&&u<=9621||9632<=u&&u<=9633||9635<=u&&u<=9641||9650<=u&&u<=9651||9654<=u&&u<=9655||9660<=u&&u<=9661||9664<=u&&u<=9665||9670<=u&&u<=9672||u==9675||9678<=u&&u<=9681||9698<=u&&u<=9701||u==9711||9733<=u&&u<=9734||u==9737||9742<=u&&u<=9743||9748<=u&&u<=9749||u==9756||u==9758||u==9792||u==9794||9824<=u&&u<=9825||9827<=u&&u<=9829||9831<=u&&u<=9834||9836<=u&&u<=9837||u==9839||9886<=u&&u<=9887||9918<=u&&u<=9919||9924<=u&&u<=9933||9935<=u&&u<=9953||u==9955||9960<=u&&u<=9983||u==10045||u==10071||10102<=u&&u<=10111||11093<=u&&u<=11097||12872<=u&&u<=12879||57344<=u&&u<=63743||65024<=u&&u<=65039||u==65533||127232<=u&&u<=127242||127248<=u&&u<=127277||127280<=u&&u<=127337||127344<=u&&u<=127386||917760<=u&&u<=917999||983040<=u&&u<=1048573||1048576<=u&&u<=1114109?"A":"N"},t.characterLength=function(s){var r=this.eastAsianWidth(s);return r=="F"||r=="W"||r=="A"?2:1};function n(s){return s.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}o(n,"t"),t.length=function(s){for(var r=n(s),i=0,u=0;u<r.length;u++)i=i+this.characterLength(r[u]);return i},t.slice=function(s,r,i){textLen=t.length(s),r=r||0,i=i||1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var u="",a=0,c=n(s),l=0;l<c.length;l++){var D=c[l],d=t.length(D);if(a>=r-(d==2?1:0))if(a+d<=i)u+=D;else break;a+=d}return u}})(Oa);var Uh=Oa.exports;const Wh=Ia(Uh);var qh=o(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},"FD");const Gh=Ia(qh);function _t(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Sa(e),e.length===0))return 0;e=e.replace(Gh()," ");const n=t.ambiguousIsNarrow?1:2;let s=0;for(const r of e){const i=r.codePointAt(0);if(!(i<=31||i>=127&&i<=159||i>=768&&i<=879))switch(Wh.eastAsianWidth(r)){case"F":case"W":s+=2;break;case"A":s+=n;break;default:s+=1}}return s}o(_t,"p");const yr=10,Ra=o((e=0)=>t=>`\x1B[${t+e}m`,"N"),ka=o((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"I"),Pa=o((e=0)=>(t,n,s)=>`\x1B[${38+e};2;${t};${n};${s}m`,"R"),N={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(N.modifier);const Kh=Object.keys(N.color),Hh=Object.keys(N.bgColor);[...Kh,...Hh];function zh(){const e=new Map;for(const[t,n]of Object.entries(N)){for(const[s,r]of Object.entries(n))N[s]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[s]=N[s],e.set(r[0],r[1]);Object.defineProperty(N,t,{value:n,enumerable:!1})}return Object.defineProperty(N,"codes",{value:e,enumerable:!1}),N.color.close="\x1B[39m",N.bgColor.close="\x1B[49m",N.color.ansi=Ra(),N.color.ansi256=ka(),N.color.ansi16m=Pa(),N.bgColor.ansi=Ra(yr),N.bgColor.ansi256=ka(yr),N.bgColor.ansi16m=Pa(yr),Object.defineProperties(N,{rgbToAnsi256:{value:o((t,n,s)=>t===n&&n===s?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(s/255*5),"value"),enumerable:!1},hexToRgb:{value:o(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[s]=n;s.length===3&&(s=[...s].map(i=>i+i).join(""));const r=Number.parseInt(s,16);return[r>>16&255,r>>8&255,r&255]},"value"),enumerable:!1},hexToAnsi256:{value:o(t=>N.rgbToAnsi256(...N.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:o(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,s,r;if(t>=232)n=((t-232)*10+8)/255,s=n,r=n;else{t-=16;const a=t%36;n=Math.floor(t/36)/5,s=Math.floor(a/6)/5,r=a%6/5}const i=Math.max(n,s,r)*2;if(i===0)return 30;let u=30+(Math.round(r)<<2|Math.round(s)<<1|Math.round(n));return i===2&&(u+=60),u},"value"),enumerable:!1},rgbToAnsi:{value:o((t,n,s)=>N.ansi256ToAnsi(N.rgbToAnsi256(t,n,s)),"value"),enumerable:!1},hexToAnsi:{value:o(t=>N.ansi256ToAnsi(N.hexToAnsi256(t)),"value"),enumerable:!1}}),N}o(zh,"rD");const Vh=zh(),pn=new Set(["\x1B","\x9B"]),Jh=39,wr="\x07",Ta="[",Xh="]",Na="m",br=`${Xh}8;;`,Ma=o(e=>`${pn.values().next().value}${Ta}${e}${Na}`,"z"),La=o(e=>`${pn.values().next().value}${br}${e}${wr}`,"K"),Yh=o(e=>e.split(" ").map(t=>_t(t)),"aD"),_r=o((e,t,n)=>{const s=[...t];let r=!1,i=!1,u=_t(Sa(e[e.length-1]));for(const[a,c]of s.entries()){const l=_t(c);if(u+l<=n?e[e.length-1]+=c:(e.push(c),u=0),pn.has(c)&&(r=!0,i=s.slice(a+1).join("").startsWith(br)),r){i?c===wr&&(r=!1,i=!1):c===Na&&(r=!1);continue}u+=l,u===n&&a<s.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"k$1"),Qh=o(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(_t(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"hD"),Zh=o((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i;const u=Yh(e);let a=[""];for(const[l,D]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let d=_t(a[a.length-1]);if(l!==0&&(d>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),d=0),(d>0||n.trim===!1)&&(a[a.length-1]+=" ",d++)),n.hard&&u[l]>t){const f=t-d,h=1+Math.floor((u[l]-f-1)/t);Math.floor((u[l]-1)/t)<h&&a.push(""),_r(a,D,t);continue}if(d+u[l]>t&&d>0&&u[l]>0){if(n.wordWrap===!1&&d<t){_r(a,D,t);continue}a.push("")}if(d+u[l]>t&&n.wordWrap===!1){_r(a,D,t);continue}a[a.length-1]+=D}n.trim!==!1&&(a=a.map(l=>Qh(l)));const c=[...a.join(`
29
- `)];for(const[l,D]of c.entries()){if(s+=D,pn.has(D)){const{groups:f}=new RegExp(`(?:\\${Ta}(?<code>\\d+)m|\\${br}(?<uri>.*)${wr})`).exec(c.slice(l).join(""))||{groups:{}};if(f.code!==void 0){const h=Number.parseFloat(f.code);r=h===Jh?void 0:h}else f.uri!==void 0&&(i=f.uri.length===0?void 0:f.uri)}const d=Vh.codes.get(Number(r));c[l+1]===`
30
- `?(i&&(s+=La("")),r&&d&&(s+=Ma(d))):D===`
31
- `&&(r&&d&&(s+=Ma(r)),i&&(s+=La(i)))}return s},"lD");function ja(e,t,n){return String(e).normalize().replace(/\r\n/g,`
27
+ `);return y?(s.originalMessage=s.message,s.message=b):s=new Error(b),s.shortMessage=g,s.command=u,s.escapedCommand=a,s.exitCode=i,s.signal=r,s.signalDescription=h,s.stdout=e,s.stderr=t,s.cwd=f,n!==void 0&&(s.all=n),"bufferedData"in s&&delete s.bufferedData,s.failed=!0,s.timedOut=!!c,s.isCanceled=l,s.killed=d&&!c,s},"makeError"),ln=["stdin","stdout","stderr"],Wd=o(e=>ln.some(t=>e[t]!==void 0),"hasAlias"),qd=o(e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return ln.map(s=>e[s]);if(Wd(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ln.map(s=>`\`${s}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);const n=Math.max(t.length,ln.length);return Array.from({length:n},(s,r)=>t[r])},"normalizeStdio");var _e={exports:{}},or={exports:{}},Fa;function Gd(){return Fa||(Fa=1,(function(e){e.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"],process.platform!=="win32"&&e.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),process.platform==="linux"&&e.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")})(or)),or.exports}o(Gd,"requireSignals");var ga;function Kd(){if(ga)return _e.exports;ga=1;var e=ge.process;const t=o(function(E){return E&&typeof E=="object"&&typeof E.removeListener=="function"&&typeof E.emit=="function"&&typeof E.reallyExit=="function"&&typeof E.listeners=="function"&&typeof E.kill=="function"&&typeof E.pid=="number"&&typeof E.on=="function"},"processOk");if(!t(e))_e.exports=function(){return function(){}};else{var n=jl,s=Gd(),r=/^win/i.test(e.platform),i=Ul;typeof i!="function"&&(i=i.EventEmitter);var u;e.__signal_exit_emitter__?u=e.__signal_exit_emitter__:(u=e.__signal_exit_emitter__=new i,u.count=0,u.emitted={}),u.infinite||(u.setMaxListeners(1/0),u.infinite=!0),_e.exports=function(E,y){if(!t(ge.process))return function(){};n.equal(typeof E,"function","a callback must be provided for exit handler"),d===!1&&D();var g="exit";y&&y.alwaysLast&&(g="afterexit");var b=o(function(){u.removeListener(g,E),u.listeners("exit").length===0&&u.listeners("afterexit").length===0&&a()},"remove");return u.on(g,E),b};var a=o(function(){!d||!t(ge.process)||(d=!1,s.forEach(function(y){try{e.removeListener(y,l[y])}catch{}}),e.emit=F,e.reallyExit=f,u.count-=1)},"unload2");_e.exports.unload=a;var c=o(function(y,g,b){u.emitted[y]||(u.emitted[y]=!0,u.emit(y,g,b))},"emit2"),l={};s.forEach(function(E){l[E]=o(function(){if(t(ge.process)){var g=e.listeners(E);g.length===u.count&&(a(),c("exit",null,E),c("afterexit",null,E),r&&E==="SIGHUP"&&(E="SIGINT"),e.kill(e.pid,E))}},"listener")}),_e.exports.signals=function(){return s};var d=!1,D=o(function(){d||!t(ge.process)||(d=!0,u.count+=1,s=s.filter(function(y){try{return e.on(y,l[y]),!0}catch{return!1}}),e.emit=m,e.reallyExit=h)},"load2");_e.exports.load=D;var f=e.reallyExit,h=o(function(y){t(ge.process)&&(e.exitCode=y||0,c("exit",e.exitCode,null),c("afterexit",e.exitCode,null),f.call(e,e.exitCode))},"processReallyExit2"),F=e.emit,m=o(function(y,g){if(y==="exit"&&t(ge.process)){g!==void 0&&(e.exitCode=g);var b=F.apply(this,arguments);return c("exit",e.exitCode,null),c("afterexit",e.exitCode,null),b}else return F.apply(this,arguments)},"processEmit2")}return _e.exports}o(Kd,"requireSignalExit");var Hd=Kd(),zd=Me(Hd);const Vd=1e3*5,Jd=o((e,t="SIGTERM",n={})=>{const s=e(t);return Xd(e,t,n,s),s},"spawnedKill"),Xd=o((e,t,n,s)=>{if(!Yd(t,n,s))return;const r=Zd(n),i=setTimeout(()=>{e("SIGKILL")},r);i.unref&&i.unref()},"setKillTimeout"),Yd=o((e,{forceKillAfterTimeout:t},n)=>Qd(e)&&t!==!1&&n,"shouldForceKill"),Qd=o(e=>e===Ll.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM","isSigterm"),Zd=o(({forceKillAfterTimeout:e=!0})=>{if(e===!0)return Vd;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},"getForceKillAfterTimeout"),eh=o((e,t)=>{e.kill()&&(t.isCanceled=!0)},"spawnedCancel"),th=o((e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},"timeoutKill"),nh=o((e,{timeout:t,killSignal:n="SIGTERM"},s)=>{if(t===0||t===void 0)return s;let r;const i=new Promise((a,c)=>{r=setTimeout(()=>{th(e,n,c)},t)}),u=s.finally(()=>{clearTimeout(r)});return Promise.race([i,u])},"setupTimeout"),sh=o(({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},"validateTimeout"),rh=o(async(e,{cleanup:t,detached:n},s)=>{if(!t||n)return s;const r=zd(()=>{e.kill()});return s.finally(()=>{r()})},"setExitHandler");function Ca(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}o(Ca,"isStream");function Ea(e){return Ca(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}o(Ea,"isWritableStream");const uh=o(e=>e instanceof Nl&&typeof e.then=="function","isExecaChildProcess"),ar=o((e,t,n)=>{if(typeof n=="string")return e[t].pipe(Wl(n)),e;if(Ea(n))return e[t].pipe(n),e;if(!uh(n))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Ea(n.stdin))throw new TypeError("The target child process's stdin must be available.");return e[t].pipe(n.stdin),n},"pipeToTarget"),ih=o(e=>{e.stdout!==null&&(e.pipeStdout=ar.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=ar.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=ar.bind(void 0,e,"all"))},"addPipeMethods");var Le={exports:{}},cr,ya;function oh(){if(ya)return cr;ya=1;const{PassThrough:e}=Us;return cr=o(t=>{t={...t};const{array:n}=t;let{encoding:s}=t;const r=s==="buffer";let i=!1;n?i=!(s||r):s=s||"utf8",r&&(s=null);const u=new e({objectMode:i});s&&u.setEncoding(s);let a=0;const c=[];return u.on("data",l=>{c.push(l),i?a=c.length:a+=l.length}),u.getBufferedValue=()=>n?c:r?Buffer.concat(c,a):c.join(""),u.getBufferedLength=()=>a,u},"bufferStream"),cr}o(oh,"requireBufferStream");var wa;function ah(){if(wa)return Le.exports;wa=1;const{constants:e}=Gl,t=Us,{promisify:n}=Kl,s=oh(),r=n(t.pipeline),a=class a extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};o(a,"MaxBufferError");let i=a;async function u(c,l){if(!c)throw new Error("Expected a stream");l={maxBuffer:1/0,...l};const{maxBuffer:d}=l,D=s(l);return await new Promise((f,h)=>{const F=o(m=>{m&&D.getBufferedLength()<=e.MAX_LENGTH&&(m.bufferedData=D.getBufferedValue()),h(m)},"rejectPromise");(async()=>{try{await r(c,D),f()}catch(m){F(m)}})(),D.on("data",()=>{D.getBufferedLength()>d&&F(new i)})}),D.getBufferedValue()}return o(u,"getStream"),Le.exports=u,Le.exports.buffer=(c,l)=>u(c,{...l,encoding:"buffer"}),Le.exports.array=(c,l)=>u(c,{...l,array:!0}),Le.exports.MaxBufferError=i,Le.exports}o(ah,"requireGetStream");var ch=ah(),ba=Me(ch),lr,_a;function lh(){if(_a)return lr;_a=1;const{PassThrough:e}=Us;return lr=o(function(){var t=[],n=new e({objectMode:!0});return n.setMaxListeners(0),n.add=s,n.isEmpty=r,n.on("unpipe",i),Array.prototype.slice.call(arguments).forEach(s),n;function s(u){return Array.isArray(u)?(u.forEach(s),this):(t.push(u),u.once("end",i.bind(null,u)),u.once("error",n.emit.bind(n,"error")),u.pipe(n,{end:!1}),this)}o(s,"add");function r(){return t.length==0}o(r,"isEmpty");function i(u){t=t.filter(function(a){return a!==u}),!t.length&&n.readable&&n.end()}o(i,"remove")},"mergeStream$1"),lr}o(lh,"requireMergeStream");var Dh=lh(),dh=Me(Dh);const hh=o(e=>{if(e!==void 0)throw new TypeError("The `input` and `inputFile` options cannot be both set.")},"validateInputOptions"),fh=o(({input:e,inputFile:t})=>typeof t!="string"?e:(hh(e),ql(t)),"getInput"),ph=o((e,t)=>{const n=fh(t);n!==void 0&&(Ca(n)?n.pipe(e.stdin):e.stdin.end(n))},"handleInput"),mh=o((e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=dh();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},"makeAllStream"),Dr=o(async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},"getBufferedData"),dr=o((e,{encoding:t,buffer:n,maxBuffer:s})=>{if(!(!e||!n))return t?ba(e,{encoding:t,maxBuffer:s}):ba.buffer(e,{maxBuffer:s})},"getStreamPromise"),Fh=o(async({stdout:e,stderr:t,all:n},{encoding:s,buffer:r,maxBuffer:i},u)=>{const a=dr(e,{encoding:s,buffer:r,maxBuffer:i}),c=dr(t,{encoding:s,buffer:r,maxBuffer:i}),l=dr(n,{encoding:s,buffer:r,maxBuffer:i*2});try{return await Promise.all([u,a,c,l])}catch(d){return Promise.all([{error:d,signal:d.signal,timedOut:d.timedOut},Dr(e,a),Dr(t,c),Dr(n,l)])}},"getSpawnedResult"),gh=(async()=>{})().constructor.prototype,Ch=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(gh,e)]),Ba=o((e,t)=>{for(const[n,s]of Ch){const r=typeof t=="function"?(...i)=>Reflect.apply(s.value,t(),i):s.value.bind(t);Reflect.defineProperty(e,n,{...s,value:r})}},"mergePromise"),Eh=o(e=>new Promise((t,n)=>{e.on("exit",(s,r)=>{t({exitCode:s,signal:r})}),e.on("error",s=>{n(s)}),e.stdin&&e.stdin.on("error",s=>{n(s)})}),"getSpawnedPromise"),Aa=o((e,t=[])=>Array.isArray(t)?[e,...t]:[e],"normalizeArgs"),yh=/^[\w.-]+$/,wh=/"/g,bh=o(e=>typeof e!="string"||yh.test(e)?e:`"${e.replace(wh,'\\"')}"`,"escapeArg"),_h=o((e,t)=>Aa(e,t).join(" "),"joinCommand"),Bh=o((e,t)=>Aa(e,t).map(n=>bh(n)).join(" "),"getEscapedCommand"),Ah=Hl("execa").enabled,Dn=o((e,t)=>String(e).padStart(t,"0"),"padField"),vh=o(()=>{const e=new Date;return`${Dn(e.getHours(),2)}:${Dn(e.getMinutes(),2)}:${Dn(e.getSeconds(),2)}.${Dn(e.getMilliseconds(),3)}`},"getTimestamp"),$h=o((e,{verbose:t})=>{t&&j.stderr.write(`[${vh()}] ${e}
28
+ `)},"logCommand"),xh=1e3*1e3*100,Sh=o(({env:e,extendEnv:t,preferLocal:n,localDir:s,execPath:r})=>{const i=t?{...j.env,...e}:e;return n?wd({env:i,cwd:s,execPath:r}):i},"getEnv"),Ih=o((e,t,n={})=>{const s=Fd._parse(e,t,n);return e=s.command,t=s.args,n=s.options,n={maxBuffer:xh,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||j.cwd(),execPath:j.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,verbose:Ah,...n},n.env=Sh(n),n.stdio=qd(n),j.platform==="win32"&&Ne.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:s}},"handleArguments"),hr=o((e,t,n)=>typeof t!="string"&&!Tl.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?gd(t):t,"handleOutput");function Ct(e,t,n){const s=Ih(e,t,n),r=_h(e,t),i=Bh(e,t);$h(i,s.options),sh(s.options);let u;try{u=uo.spawn(s.file,s.args,s.options)}catch(h){const F=new uo.ChildProcess,m=Promise.reject(ma({error:h,stdout:"",stderr:"",all:"",command:r,escapedCommand:i,parsed:s,timedOut:!1,isCanceled:!1,killed:!1}));return Ba(F,m),F}const a=Eh(u),c=nh(u,s.options,a),l=rh(u,s.options,c),d={isCanceled:!1};u.kill=Jd.bind(null,u.kill.bind(u)),u.cancel=eh.bind(null,u,d);const f=da(o(async()=>{const[{error:h,exitCode:F,signal:m,timedOut:E},y,g,b]=await Fh(u,s.options,l),B=hr(s.options,y),I=hr(s.options,g),O=hr(s.options,b);if(h||F!==0||m!==null){const R=ma({error:h,exitCode:F,signal:m,stdout:B,stderr:I,all:O,command:r,escapedCommand:i,parsed:s,timedOut:E,isCanceled:d.isCanceled||(s.options.signal?s.options.signal.aborted:!1),killed:u.killed});if(!s.options.reject)return R;throw R}return{command:r,escapedCommand:i,exitCode:0,stdout:B,stderr:I,all:O,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return ph(u,s.options),u.all=mh(u,s.options),ih(u),Ba(u,f),u}o(Ct,"execa");let Be=!0;const je=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let Et=0;if(je.process&&je.process.env&&je.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:n,TERM:s,COLORTERM:r}=je.process.env;t||n||e==="0"?Be=!1:e==="1"||e==="2"||e==="3"?Be=!0:s==="dumb"?Be=!1:"CI"in je.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(i=>i in je.process.env)?Be=!0:Be=process.stdout.isTTY,Be&&(process.platform==="win32"||r&&(r==="truecolor"||r==="24bit")?Et=3:s&&(s.endsWith("-256color")||s.endsWith("256"))?Et=2:Et=1)}let fr={enabled:Be,supportLevel:Et};function yt(e,t,n=1){const s=`\x1B[${e}m`,r=`\x1B[${t}m`,i=new RegExp(`\\x1b\\[${t}m`,"g");return u=>fr.enabled&&fr.supportLevel>=n?s+(""+u).replace(i,s)+r:""+u}o(yt,"kolorist");const pr=yt(2,22),mr=yt(30,39),Fr=yt(31,39),Ue=yt(32,39),gr=yt(46,49);var Oh=Object.freeze({__proto__:null,bgCyan:gr,black:mr,dim:pr,green:Ue,options:fr,red:Fr});const wt={};wt.write=async e=>{await navigator.clipboard.writeText(e)},wt.read=async()=>navigator.clipboard.readText(),wt.readSync=()=>{throw new Error("`.readSync()` is not supported in browsers!")},wt.writeSync=()=>{throw new Error("`.writeSync()` is not supported in browsers!")};var Cr,va;function Rh(){if(va)return Cr;va=1;const e="\x1B",t=`${e}[`,n="\x07",s={to(u,a){return a?`${t}${a+1};${u+1}H`:`${t}${u+1}G`},move(u,a){let c="";return u<0?c+=`${t}${-u}D`:u>0&&(c+=`${t}${u}C`),a<0?c+=`${t}${-a}A`:a>0&&(c+=`${t}${a}B`),c},up:o((u=1)=>`${t}${u}A`,"up"),down:o((u=1)=>`${t}${u}B`,"down"),forward:o((u=1)=>`${t}${u}C`,"forward"),backward:o((u=1)=>`${t}${u}D`,"backward"),nextLine:o((u=1)=>`${t}E`.repeat(u),"nextLine"),prevLine:o((u=1)=>`${t}F`.repeat(u),"prevLine"),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},r={up:o((u=1)=>`${t}S`.repeat(u),"up"),down:o((u=1)=>`${t}T`.repeat(u),"down")},i={screen:`${t}2J`,up:o((u=1)=>`${t}1J`.repeat(u),"up"),down:o((u=1)=>`${t}J`.repeat(u),"down"),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(u){let a="";for(let c=0;c<u;c++)a+=this.line+(c<u-1?s.up():"");return u&&(a+=s.left),a}};return Cr={cursor:s,scroll:r,erase:i,beep:n},Cr}o(Rh,"requireSrc");var Z=Rh(),dn={exports:{}},$a;function kh(){if($a)return dn.exports;$a=1;let e=process||{},t=e.argv||[],n=e.env||{},s=!(n.NO_COLOR||t.includes("--no-color"))&&(!!n.FORCE_COLOR||t.includes("--color")||e.platform==="win32"||(e.stdout||{}).isTTY&&n.TERM!=="dumb"||!!n.CI),r=o((a,c,l=a)=>d=>{let D=""+d,f=D.indexOf(c,a.length);return~f?a+i(D,c,l,f)+c:a+D+c},"formatter"),i=o((a,c,l,d)=>{let D="",f=0;do D+=a.substring(f,d)+l,f=d+c.length,d=a.indexOf(c,f);while(~d);return D+a.substring(f)},"replaceClose"),u=o((a=s)=>{let c=a?r:()=>String;return{isColorSupported:a,reset:c("\x1B[0m","\x1B[0m"),bold:c("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:c("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:c("\x1B[3m","\x1B[23m"),underline:c("\x1B[4m","\x1B[24m"),inverse:c("\x1B[7m","\x1B[27m"),hidden:c("\x1B[8m","\x1B[28m"),strikethrough:c("\x1B[9m","\x1B[29m"),black:c("\x1B[30m","\x1B[39m"),red:c("\x1B[31m","\x1B[39m"),green:c("\x1B[32m","\x1B[39m"),yellow:c("\x1B[33m","\x1B[39m"),blue:c("\x1B[34m","\x1B[39m"),magenta:c("\x1B[35m","\x1B[39m"),cyan:c("\x1B[36m","\x1B[39m"),white:c("\x1B[37m","\x1B[39m"),gray:c("\x1B[90m","\x1B[39m"),bgBlack:c("\x1B[40m","\x1B[49m"),bgRed:c("\x1B[41m","\x1B[49m"),bgGreen:c("\x1B[42m","\x1B[49m"),bgYellow:c("\x1B[43m","\x1B[49m"),bgBlue:c("\x1B[44m","\x1B[49m"),bgMagenta:c("\x1B[45m","\x1B[49m"),bgCyan:c("\x1B[46m","\x1B[49m"),bgWhite:c("\x1B[47m","\x1B[49m"),blackBright:c("\x1B[90m","\x1B[39m"),redBright:c("\x1B[91m","\x1B[39m"),greenBright:c("\x1B[92m","\x1B[39m"),yellowBright:c("\x1B[93m","\x1B[39m"),blueBright:c("\x1B[94m","\x1B[39m"),magentaBright:c("\x1B[95m","\x1B[39m"),cyanBright:c("\x1B[96m","\x1B[39m"),whiteBright:c("\x1B[97m","\x1B[39m"),bgBlackBright:c("\x1B[100m","\x1B[49m"),bgRedBright:c("\x1B[101m","\x1B[49m"),bgGreenBright:c("\x1B[102m","\x1B[49m"),bgYellowBright:c("\x1B[103m","\x1B[49m"),bgBlueBright:c("\x1B[104m","\x1B[49m"),bgMagentaBright:c("\x1B[105m","\x1B[49m"),bgCyanBright:c("\x1B[106m","\x1B[49m"),bgWhiteBright:c("\x1B[107m","\x1B[49m")}},"createColors");return dn.exports=u(),dn.exports.createColors=u,dn.exports}o(kh,"requirePicocolors");var Ph=kh(),w=Me(Ph);function Th({onlyFirst:e=!1}={}){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}o(Th,"DD");const Nh=Th();function xa(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Nh,"")}o(xa,"P$1");function Sa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o(Sa,"L$1");var Ia={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(s){var r=s.charCodeAt(0),i=s.length==2?s.charCodeAt(1):0,u=r;return 55296<=r&&r<=56319&&56320<=i&&i<=57343&&(r&=1023,i&=1023,u=r<<10|i,u+=65536),u==12288||65281<=u&&u<=65376||65504<=u&&u<=65510?"F":u==8361||65377<=u&&u<=65470||65474<=u&&u<=65479||65482<=u&&u<=65487||65490<=u&&u<=65495||65498<=u&&u<=65500||65512<=u&&u<=65518?"H":4352<=u&&u<=4447||4515<=u&&u<=4519||4602<=u&&u<=4607||9001<=u&&u<=9002||11904<=u&&u<=11929||11931<=u&&u<=12019||12032<=u&&u<=12245||12272<=u&&u<=12283||12289<=u&&u<=12350||12353<=u&&u<=12438||12441<=u&&u<=12543||12549<=u&&u<=12589||12593<=u&&u<=12686||12688<=u&&u<=12730||12736<=u&&u<=12771||12784<=u&&u<=12830||12832<=u&&u<=12871||12880<=u&&u<=13054||13056<=u&&u<=19903||19968<=u&&u<=42124||42128<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||55216<=u&&u<=55238||55243<=u&&u<=55291||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65106||65108<=u&&u<=65126||65128<=u&&u<=65131||110592<=u&&u<=110593||127488<=u&&u<=127490||127504<=u&&u<=127546||127552<=u&&u<=127560||127568<=u&&u<=127569||131072<=u&&u<=194367||177984<=u&&u<=196605||196608<=u&&u<=262141?"W":32<=u&&u<=126||162<=u&&u<=163||165<=u&&u<=166||u==172||u==175||10214<=u&&u<=10221||10629<=u&&u<=10630?"Na":u==161||u==164||167<=u&&u<=168||u==170||173<=u&&u<=174||176<=u&&u<=180||182<=u&&u<=186||188<=u&&u<=191||u==198||u==208||215<=u&&u<=216||222<=u&&u<=225||u==230||232<=u&&u<=234||236<=u&&u<=237||u==240||242<=u&&u<=243||247<=u&&u<=250||u==252||u==254||u==257||u==273||u==275||u==283||294<=u&&u<=295||u==299||305<=u&&u<=307||u==312||319<=u&&u<=322||u==324||328<=u&&u<=331||u==333||338<=u&&u<=339||358<=u&&u<=359||u==363||u==462||u==464||u==466||u==468||u==470||u==472||u==474||u==476||u==593||u==609||u==708||u==711||713<=u&&u<=715||u==717||u==720||728<=u&&u<=731||u==733||u==735||768<=u&&u<=879||913<=u&&u<=929||931<=u&&u<=937||945<=u&&u<=961||963<=u&&u<=969||u==1025||1040<=u&&u<=1103||u==1105||u==8208||8211<=u&&u<=8214||8216<=u&&u<=8217||8220<=u&&u<=8221||8224<=u&&u<=8226||8228<=u&&u<=8231||u==8240||8242<=u&&u<=8243||u==8245||u==8251||u==8254||u==8308||u==8319||8321<=u&&u<=8324||u==8364||u==8451||u==8453||u==8457||u==8467||u==8470||8481<=u&&u<=8482||u==8486||u==8491||8531<=u&&u<=8532||8539<=u&&u<=8542||8544<=u&&u<=8555||8560<=u&&u<=8569||u==8585||8592<=u&&u<=8601||8632<=u&&u<=8633||u==8658||u==8660||u==8679||u==8704||8706<=u&&u<=8707||8711<=u&&u<=8712||u==8715||u==8719||u==8721||u==8725||u==8730||8733<=u&&u<=8736||u==8739||u==8741||8743<=u&&u<=8748||u==8750||8756<=u&&u<=8759||8764<=u&&u<=8765||u==8776||u==8780||u==8786||8800<=u&&u<=8801||8804<=u&&u<=8807||8810<=u&&u<=8811||8814<=u&&u<=8815||8834<=u&&u<=8835||8838<=u&&u<=8839||u==8853||u==8857||u==8869||u==8895||u==8978||9312<=u&&u<=9449||9451<=u&&u<=9547||9552<=u&&u<=9587||9600<=u&&u<=9615||9618<=u&&u<=9621||9632<=u&&u<=9633||9635<=u&&u<=9641||9650<=u&&u<=9651||9654<=u&&u<=9655||9660<=u&&u<=9661||9664<=u&&u<=9665||9670<=u&&u<=9672||u==9675||9678<=u&&u<=9681||9698<=u&&u<=9701||u==9711||9733<=u&&u<=9734||u==9737||9742<=u&&u<=9743||9748<=u&&u<=9749||u==9756||u==9758||u==9792||u==9794||9824<=u&&u<=9825||9827<=u&&u<=9829||9831<=u&&u<=9834||9836<=u&&u<=9837||u==9839||9886<=u&&u<=9887||9918<=u&&u<=9919||9924<=u&&u<=9933||9935<=u&&u<=9953||u==9955||9960<=u&&u<=9983||u==10045||u==10071||10102<=u&&u<=10111||11093<=u&&u<=11097||12872<=u&&u<=12879||57344<=u&&u<=63743||65024<=u&&u<=65039||u==65533||127232<=u&&u<=127242||127248<=u&&u<=127277||127280<=u&&u<=127337||127344<=u&&u<=127386||917760<=u&&u<=917999||983040<=u&&u<=1048573||1048576<=u&&u<=1114109?"A":"N"},t.characterLength=function(s){var r=this.eastAsianWidth(s);return r=="F"||r=="W"||r=="A"?2:1};function n(s){return s.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}o(n,"t"),t.length=function(s){for(var r=n(s),i=0,u=0;u<r.length;u++)i=i+this.characterLength(r[u]);return i},t.slice=function(s,r,i){textLen=t.length(s),r=r||0,i=i||1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var u="",a=0,c=n(s),l=0;l<c.length;l++){var d=c[l],D=t.length(d);if(a>=r-(D==2?1:0))if(a+D<=i)u+=d;else break;a+=D}return u}})(Ia);var Mh=Ia.exports;const Lh=Sa(Mh);var jh=o(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},"FD");const Uh=Sa(jh);function bt(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=xa(e),e.length===0))return 0;e=e.replace(Uh()," ");const n=t.ambiguousIsNarrow?1:2;let s=0;for(const r of e){const i=r.codePointAt(0);if(!(i<=31||i>=127&&i<=159||i>=768&&i<=879))switch(Lh.eastAsianWidth(r)){case"F":case"W":s+=2;break;case"A":s+=n;break;default:s+=1}}return s}o(bt,"p");const Er=10,Oa=o((e=0)=>t=>`\x1B[${t+e}m`,"N"),Ra=o((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"I"),ka=o((e=0)=>(t,n,s)=>`\x1B[${38+e};2;${t};${n};${s}m`,"R"),N={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(N.modifier);const Wh=Object.keys(N.color),qh=Object.keys(N.bgColor);[...Wh,...qh];function Gh(){const e=new Map;for(const[t,n]of Object.entries(N)){for(const[s,r]of Object.entries(n))N[s]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[s]=N[s],e.set(r[0],r[1]);Object.defineProperty(N,t,{value:n,enumerable:!1})}return Object.defineProperty(N,"codes",{value:e,enumerable:!1}),N.color.close="\x1B[39m",N.bgColor.close="\x1B[49m",N.color.ansi=Oa(),N.color.ansi256=Ra(),N.color.ansi16m=ka(),N.bgColor.ansi=Oa(Er),N.bgColor.ansi256=Ra(Er),N.bgColor.ansi16m=ka(Er),Object.defineProperties(N,{rgbToAnsi256:{value:o((t,n,s)=>t===n&&n===s?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(s/255*5),"value"),enumerable:!1},hexToRgb:{value:o(t=>{const n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[s]=n;s.length===3&&(s=[...s].map(i=>i+i).join(""));const r=Number.parseInt(s,16);return[r>>16&255,r>>8&255,r&255]},"value"),enumerable:!1},hexToAnsi256:{value:o(t=>N.rgbToAnsi256(...N.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value:o(t=>{if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,s,r;if(t>=232)n=((t-232)*10+8)/255,s=n,r=n;else{t-=16;const a=t%36;n=Math.floor(t/36)/5,s=Math.floor(a/6)/5,r=a%6/5}const i=Math.max(n,s,r)*2;if(i===0)return 30;let u=30+(Math.round(r)<<2|Math.round(s)<<1|Math.round(n));return i===2&&(u+=60),u},"value"),enumerable:!1},rgbToAnsi:{value:o((t,n,s)=>N.ansi256ToAnsi(N.rgbToAnsi256(t,n,s)),"value"),enumerable:!1},hexToAnsi:{value:o(t=>N.ansi256ToAnsi(N.hexToAnsi256(t)),"value"),enumerable:!1}}),N}o(Gh,"rD");const Kh=Gh(),hn=new Set(["\x1B","\x9B"]),Hh=39,yr="\x07",Pa="[",zh="]",Ta="m",wr=`${zh}8;;`,Na=o(e=>`${hn.values().next().value}${Pa}${e}${Ta}`,"z"),Ma=o(e=>`${hn.values().next().value}${wr}${e}${yr}`,"K"),Vh=o(e=>e.split(" ").map(t=>bt(t)),"aD"),br=o((e,t,n)=>{const s=[...t];let r=!1,i=!1,u=bt(xa(e[e.length-1]));for(const[a,c]of s.entries()){const l=bt(c);if(u+l<=n?e[e.length-1]+=c:(e.push(c),u=0),hn.has(c)&&(r=!0,i=s.slice(a+1).join("").startsWith(wr)),r){i?c===yr&&(r=!1,i=!1):c===Ta&&(r=!1);continue}u+=l,u===n&&a<s.length-1&&(e.push(""),u=0)}!u&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},"k$1"),Jh=o(e=>{const t=e.split(" ");let n=t.length;for(;n>0&&!(bt(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},"hD"),Xh=o((e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let s="",r,i;const u=Vh(e);let a=[""];for(const[l,d]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let D=bt(a[a.length-1]);if(l!==0&&(D>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),D=0),(D>0||n.trim===!1)&&(a[a.length-1]+=" ",D++)),n.hard&&u[l]>t){const f=t-D,h=1+Math.floor((u[l]-f-1)/t);Math.floor((u[l]-1)/t)<h&&a.push(""),br(a,d,t);continue}if(D+u[l]>t&&D>0&&u[l]>0){if(n.wordWrap===!1&&D<t){br(a,d,t);continue}a.push("")}if(D+u[l]>t&&n.wordWrap===!1){br(a,d,t);continue}a[a.length-1]+=d}n.trim!==!1&&(a=a.map(l=>Jh(l)));const c=[...a.join(`
29
+ `)];for(const[l,d]of c.entries()){if(s+=d,hn.has(d)){const{groups:f}=new RegExp(`(?:\\${Pa}(?<code>\\d+)m|\\${wr}(?<uri>.*)${yr})`).exec(c.slice(l).join(""))||{groups:{}};if(f.code!==void 0){const h=Number.parseFloat(f.code);r=h===Hh?void 0:h}else f.uri!==void 0&&(i=f.uri.length===0?void 0:f.uri)}const D=Kh.codes.get(Number(r));c[l+1]===`
30
+ `?(i&&(s+=Ma("")),r&&D&&(s+=Na(D))):d===`
31
+ `&&(r&&D&&(s+=Na(r)),i&&(s+=Ma(i)))}return s},"lD");function La(e,t,n){return String(e).normalize().replace(/\r\n/g,`
32
32
  `).split(`
33
- `).map(s=>Zh(s,t,n)).join(`
34
- `)}o(ja,"Y$1");const ef=["up","down","left","right","space","enter","cancel"],mn={actions:new Set(ef),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function Br(e,t){if(typeof e=="string")return mn.aliases.get(e)===t;for(const n of e)if(n!==void 0&&Br(n,t))return!0;return!1}o(Br,"$");function tf(e,t){if(e===t)return;const n=e.split(`
33
+ `).map(s=>Xh(s,t,n)).join(`
34
+ `)}o(La,"Y$1");const Yh=["up","down","left","right","space","enter","cancel"],fn={actions:new Set(Yh),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function _r(e,t){if(typeof e=="string")return fn.aliases.get(e)===t;for(const n of e)if(n!==void 0&&_r(n,t))return!0;return!1}o(_r,"$");function Qh(e,t){if(e===t)return;const n=e.split(`
35
35
  `),s=t.split(`
36
- `),r=[];for(let i=0;i<Math.max(n.length,s.length);i++)n[i]!==s[i]&&r.push(i);return r}o(tf,"BD");const nf=globalThis.process.platform.startsWith("win"),Ar=Symbol("clack:cancel");function Fn(e){return e===Ar}o(Fn,"pD");function gn(e,t){const n=e;n.isTTY&&n.setRawMode(t)}o(gn,"m");function sf({input:e=oo,output:t=ao,overwrite:n=!0,hideCursor:s=!0}={}){const r=nn.createInterface({input:e,output:t,prompt:"",tabSize:1});nn.emitKeypressEvents(e,r),e.isTTY&&e.setRawMode(!0);const i=o((u,{name:a,sequence:c})=>{const l=String(u);if(Br([l,a,c],"cancel")){s&&t.write(Z.cursor.show),process.exit(0);return}if(!n)return;const D=a==="return"?0:-1,d=a==="return"?-1:0;nn.moveCursor(t,D,d,()=>{nn.clearLine(t,1,()=>{e.once("keypress",i)})})},"i");return s&&t.write(Z.cursor.hide),e.once("keypress",i),()=>{e.off("keypress",i),s&&t.write(Z.cursor.show),e.isTTY&&!nf&&e.setRawMode(!1),r.terminal=!1,r.close()}}o(sf,"fD");var rf=Object.defineProperty,uf=o((e,t,n)=>t in e?rf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"vD"),re=o((e,t,n)=>(uf(e,typeof t!="symbol"?t+"":t,n),n),"h");const xu=class xu{constructor(t,n=!0){re(this,"input"),re(this,"output"),re(this,"_abortSignal"),re(this,"rl"),re(this,"opts"),re(this,"_render"),re(this,"_track",!1),re(this,"_prevFrame",""),re(this,"_subscribers",new Map),re(this,"_cursor",0),re(this,"state","initial"),re(this,"error",""),re(this,"value");const{input:s=oo,output:r=ao,render:i,signal:u,...a}=t;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=n,this._abortSignal=u,this.input=s,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,n){const s=this._subscribers.get(t)??[];s.push(n),this._subscribers.set(t,s)}on(t,n){this.setSubscriber(t,{cb:n})}once(t,n){this.setSubscriber(t,{cb:n,once:!0})}emit(t,...n){const s=this._subscribers.get(t)??[],r=[];for(const i of s)i.cb(...n),i.once&&r.push(()=>s.splice(s.indexOf(i),1));for(const i of r)i()}prompt(){return new Promise((t,n)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Ar);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}const s=new Xl;s._write=(r,i,u)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),u()},this.input.pipe(s),this.rl=Do.createInterface({input:this.input,output:s,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),Do.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),gn(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Z.cursor.show),this.output.off("resize",this.render),gn(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Z.cursor.show),this.output.off("resize",this.render),gn(this.input,!1),t(Ar)})})}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&(!this._track&&mn.aliases.has(n.name)&&this.emit("cursor",mn.aliases.get(n.name)),mn.actions.has(n.name)&&this.emit("cursor",n.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),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){const s=this.opts.validate(this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}Br([t,n?.name,n?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
37
- `),gn(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=ja(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
38
- `).length-1;this.output.write(Z.cursor.move(-999,t*-1))}render(){const t=ja(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Z.cursor.hide);else{const n=tf(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){const s=n[0];this.output.write(Z.cursor.move(0,s)),this.output.write(Z.erase.lines(1));const r=t.split(`
36
+ `),r=[];for(let i=0;i<Math.max(n.length,s.length);i++)n[i]!==s[i]&&r.push(i);return r}o(Qh,"BD");const Zh=globalThis.process.platform.startsWith("win"),Br=Symbol("clack:cancel");function pn(e){return e===Br}o(pn,"pD");function mn(e,t){const n=e;n.isTTY&&n.setRawMode(t)}o(mn,"m");function ef({input:e=io,output:t=oo,overwrite:n=!0,hideCursor:s=!0}={}){const r=en.createInterface({input:e,output:t,prompt:"",tabSize:1});en.emitKeypressEvents(e,r),e.isTTY&&e.setRawMode(!0);const i=o((u,{name:a,sequence:c})=>{const l=String(u);if(_r([l,a,c],"cancel")){s&&t.write(Z.cursor.show),process.exit(0);return}if(!n)return;const d=a==="return"?0:-1,D=a==="return"?-1:0;en.moveCursor(t,d,D,()=>{en.clearLine(t,1,()=>{e.once("keypress",i)})})},"i");return s&&t.write(Z.cursor.hide),e.once("keypress",i),()=>{e.off("keypress",i),s&&t.write(Z.cursor.show),e.isTTY&&!Zh&&e.setRawMode(!1),r.terminal=!1,r.close()}}o(ef,"fD");var tf=Object.defineProperty,nf=o((e,t,n)=>t in e?tf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"vD"),re=o((e,t,n)=>(nf(e,typeof t!="symbol"?t+"":t,n),n),"h");const $u=class $u{constructor(t,n=!0){re(this,"input"),re(this,"output"),re(this,"_abortSignal"),re(this,"rl"),re(this,"opts"),re(this,"_render"),re(this,"_track",!1),re(this,"_prevFrame",""),re(this,"_subscribers",new Map),re(this,"_cursor",0),re(this,"state","initial"),re(this,"error",""),re(this,"value");const{input:s=io,output:r=oo,render:i,signal:u,...a}=t;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=n,this._abortSignal=u,this.input=s,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(t,n){const s=this._subscribers.get(t)??[];s.push(n),this._subscribers.set(t,s)}on(t,n){this.setSubscriber(t,{cb:n})}once(t,n){this.setSubscriber(t,{cb:n,once:!0})}emit(t,...n){const s=this._subscribers.get(t)??[],r=[];for(const i of s)i.cb(...n),i.once&&r.push(()=>s.splice(s.indexOf(i),1));for(const i of r)i()}prompt(){return new Promise((t,n)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(Br);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}const s=new zl;s._write=(r,i,u)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),u()},this.input.pipe(s),this.rl=lo.createInterface({input:this.input,output:s,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),lo.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),mn(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(Z.cursor.show),this.output.off("resize",this.render),mn(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(Z.cursor.show),this.output.off("resize",this.render),mn(this.input,!1),t(Br)})})}onKeypress(t,n){if(this.state==="error"&&(this.state="active"),n?.name&&(!this._track&&fn.aliases.has(n.name)&&this.emit("cursor",fn.aliases.get(n.name)),fn.actions.has(n.name)&&this.emit("cursor",n.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),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){const s=this.opts.validate(this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}_r([t,n?.name,n?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
37
+ `),mn(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=La(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
38
+ `).length-1;this.output.write(Z.cursor.move(-999,t*-1))}render(){const t=La(this._render(this)??"",process.stdout.columns,{hard:!0});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(Z.cursor.hide);else{const n=Qh(this._prevFrame,t);if(this.restoreCursor(),n&&n?.length===1){const s=n[0];this.output.write(Z.cursor.move(0,s)),this.output.write(Z.erase.lines(1));const r=t.split(`
39
39
  `);this.output.write(r[s]),this._prevFrame=t,this.output.write(Z.cursor.move(0,r.length-s-1));return}if(n&&n?.length>1){const s=n[0];this.output.write(Z.cursor.move(0,s)),this.output.write(Z.erase.down());const r=t.split(`
40
40
  `).slice(s);this.output.write(r.join(`
41
- `)),this._prevFrame=t;return}this.output.write(Z.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};o(xu,"x");let qe=xu;const Su=class Su extends qe{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(Z.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};o(Su,"dD");let vr=Su;var of=Object.defineProperty,af=o((e,t,n)=>t in e?of(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"jD"),Ua=o((e,t,n)=>(af(e,typeof t!="symbol"?t+"":t,n),n),"U");const Iu=class Iu extends qe{constructor({mask:t,...n}){super(n),Ua(this,"valueWithCursor",""),Ua(this,"_mask","\u2022"),this._mask=t??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${w.inverse(w.hidden("_"))}`;else{const s=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${s}${w.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};o(Iu,"MD");let $r=Iu;var cf=Object.defineProperty,lf=o((e,t,n)=>t in e?cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"PD"),Wa=o((e,t,n)=>(lf(e,typeof t!="symbol"?t+"":t,n),n),"J");const Ou=class Ou extends qe{constructor(t){super(t,!1),Wa(this,"options"),Wa(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}};o(Ou,"LD");let xr=Ou;const Ru=class Ru extends qe{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;const t=this.value.slice(0,this.cursor),[n,...s]=this.value.slice(this.cursor);return`${t}${w.inverse(n)}${s.join("")}`}get cursor(){return this._cursor}constructor(t){super(t),this.on("finalize",()=>{this.value||(this.value=t.defaultValue)})}};o(Ru,"RD");let Sr=Ru;function Df(){return j.platform!=="win32"?j.env.TERM!=="linux":!!j.env.CI||!!j.env.WT_SESSION||!!j.env.TERMINUS_SUBLIME||j.env.ConEmuTask==="{cmd::Cmder}"||j.env.TERM_PROGRAM==="Terminus-Sublime"||j.env.TERM_PROGRAM==="vscode"||j.env.TERM==="xterm-256color"||j.env.TERM==="alacritty"||j.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}o(Df,"ce");const Ir=Df(),De=o((e,t)=>Ir?e:t,"u"),df=De("\u25C6","*"),qa=De("\u25A0","x"),Ga=De("\u25B2","x"),Ka=De("\u25C7","o"),hf=De("\u250C","T"),k=De("\u2502","|"),Ae=De("\u2514","\u2014"),Or=De("\u25CF",">"),Rr=De("\u25CB"," "),ff=De("\u25AA","\u2022"),Cn=o(e=>{switch(e){case"initial":case"active":return w.cyan(df);case"cancel":return w.red(qa);case"error":return w.yellow(Ga);case"submit":return w.green(Ka)}},"b"),pf=o(e=>{const{cursor:t,options:n,style:s}=e,r=e.maxItems??Number.POSITIVE_INFINITY,i=Math.max(process.stdout.rows-4,0),u=Math.min(i,Math.max(r,5));let a=0;t>=a+u-3?a=Math.max(Math.min(t-u+3,n.length-u),0):t<a+2&&(a=Math.max(t-2,0));const c=u<n.length&&a>0,l=u<n.length&&a+u<n.length;return n.slice(a,a+u).map((D,d,f)=>{const h=d===0&&c,F=d===f.length-1&&l;return h||F?w.dim("..."):s(D,d+a===t)})},"G"),Ha=o(e=>new Sr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){const t=`${w.gray(k)}
42
- ${Cn(this.state)} ${e.message}
41
+ `)),this._prevFrame=t;return}this.output.write(Z.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};o($u,"x");let We=$u;const xu=class xu extends We{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(Z.cursor.move(0,-1)),this.value=n,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};o(xu,"dD");let Ar=xu;var sf=Object.defineProperty,rf=o((e,t,n)=>t in e?sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"jD"),ja=o((e,t,n)=>(rf(e,typeof t!="symbol"?t+"":t,n),n),"U");const Su=class Su extends We{constructor({mask:t,...n}){super(n),ja(this,"valueWithCursor",""),ja(this,"_mask","\u2022"),this._mask=t??"\u2022",this.on("finalize",()=>{this.valueWithCursor=this.masked}),this.on("value",()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${w.inverse(w.hidden("_"))}`;else{const s=this.masked.slice(0,this.cursor),r=this.masked.slice(this.cursor);this.valueWithCursor=`${s}${w.inverse(r[0])}${r.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};o(Su,"MD");let vr=Su;var uf=Object.defineProperty,of=o((e,t,n)=>t in e?uf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"PD"),Ua=o((e,t,n)=>(of(e,typeof t!="symbol"?t+"":t,n),n),"J");const Iu=class Iu extends We{constructor(t){super(t,!1),Ua(this,"options"),Ua(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}};o(Iu,"LD");let $r=Iu;const Ou=class Ou extends We{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;const t=this.value.slice(0,this.cursor),[n,...s]=this.value.slice(this.cursor);return`${t}${w.inverse(n)}${s.join("")}`}get cursor(){return this._cursor}constructor(t){super(t),this.on("finalize",()=>{this.value||(this.value=t.defaultValue)})}};o(Ou,"RD");let xr=Ou;function af(){return j.platform!=="win32"?j.env.TERM!=="linux":!!j.env.CI||!!j.env.WT_SESSION||!!j.env.TERMINUS_SUBLIME||j.env.ConEmuTask==="{cmd::Cmder}"||j.env.TERM_PROGRAM==="Terminus-Sublime"||j.env.TERM_PROGRAM==="vscode"||j.env.TERM==="xterm-256color"||j.env.TERM==="alacritty"||j.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}o(af,"ce");const Sr=af(),De=o((e,t)=>Sr?e:t,"u"),cf=De("\u25C6","*"),Wa=De("\u25A0","x"),qa=De("\u25B2","x"),Ga=De("\u25C7","o"),lf=De("\u250C","T"),k=De("\u2502","|"),Ae=De("\u2514","\u2014"),Ir=De("\u25CF",">"),Or=De("\u25CB"," "),Df=De("\u25AA","\u2022"),Fn=o(e=>{switch(e){case"initial":case"active":return w.cyan(cf);case"cancel":return w.red(Wa);case"error":return w.yellow(qa);case"submit":return w.green(Ga)}},"b"),df=o(e=>{const{cursor:t,options:n,style:s}=e,r=e.maxItems??Number.POSITIVE_INFINITY,i=Math.max(process.stdout.rows-4,0),u=Math.min(i,Math.max(r,5));let a=0;t>=a+u-3?a=Math.max(Math.min(t-u+3,n.length-u),0):t<a+2&&(a=Math.max(t-2,0));const c=u<n.length&&a>0,l=u<n.length&&a+u<n.length;return n.slice(a,a+u).map((d,D,f)=>{const h=D===0&&c,F=D===f.length-1&&l;return h||F?w.dim("..."):s(d,D+a===t)})},"G"),Ka=o(e=>new xr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){const t=`${w.gray(k)}
42
+ ${Fn(this.state)} ${e.message}
43
43
  `,n=e.placeholder?w.inverse(e.placeholder[0])+w.dim(e.placeholder.slice(1)):w.inverse(w.hidden("_")),s=this.value?this.valueWithCursor:n;switch(this.state){case"error":return`${t.trim()}
44
44
  ${w.yellow(k)} ${s}
45
45
  ${w.yellow(Ae)} ${w.yellow(this.error)}
46
46
  `;case"submit":return`${t}${w.gray(k)} ${w.dim(this.value||e.placeholder)}`;case"cancel":return`${t}${w.gray(k)} ${w.strikethrough(w.dim(this.value??""))}${this.value?.trim()?`
47
47
  ${w.gray(k)}`:""}`;default:return`${t}${w.cyan(k)} ${s}
48
48
  ${w.cyan(Ae)}
49
- `}}}).prompt(),"he"),mf=o(e=>new $r({validate:e.validate,mask:e.mask??ff,render(){const t=`${w.gray(k)}
50
- ${Cn(this.state)} ${e.message}
49
+ `}}}).prompt(),"he"),hf=o(e=>new vr({validate:e.validate,mask:e.mask??Df,render(){const t=`${w.gray(k)}
50
+ ${Fn(this.state)} ${e.message}
51
51
  `,n=this.valueWithCursor,s=this.masked;switch(this.state){case"error":return`${t.trim()}
52
52
  ${w.yellow(k)} ${s}
53
53
  ${w.yellow(Ae)} ${w.yellow(this.error)}
54
54
  `;case"submit":return`${t}${w.gray(k)} ${w.dim(s)}`;case"cancel":return`${t}${w.gray(k)} ${w.strikethrough(w.dim(s??""))}${s?`
55
55
  ${w.gray(k)}`:""}`;default:return`${t}${w.cyan(k)} ${n}
56
56
  ${w.cyan(Ae)}
57
- `}}}).prompt(),"ge"),za=o(e=>{const t=e.active??"Yes",n=e.inactive??"No";return new vr({active:t,inactive:n,initialValue:e.initialValue??!0,render(){const s=`${w.gray(k)}
58
- ${Cn(this.state)} ${e.message}
57
+ `}}}).prompt(),"ge"),ff=o(e=>{const t=e.active??"Yes",n=e.inactive??"No";return new Ar({active:t,inactive:n,initialValue:e.initialValue??!0,render(){const s=`${w.gray(k)}
58
+ ${Fn(this.state)} ${e.message}
59
59
  `,r=this.value?t:n;switch(this.state){case"submit":return`${s}${w.gray(k)} ${w.dim(r)}`;case"cancel":return`${s}${w.gray(k)} ${w.strikethrough(w.dim(r))}
60
- ${w.gray(k)}`;default:return`${s}${w.cyan(k)} ${this.value?`${w.green(Or)} ${t}`:`${w.dim(Rr)} ${w.dim(t)}`} ${w.dim("/")} ${this.value?`${w.dim(Rr)} ${w.dim(n)}`:`${w.green(Or)} ${n}`}
60
+ ${w.gray(k)}`;default:return`${s}${w.cyan(k)} ${this.value?`${w.green(Ir)} ${t}`:`${w.dim(Or)} ${w.dim(t)}`} ${w.dim("/")} ${this.value?`${w.dim(Or)} ${w.dim(n)}`:`${w.green(Ir)} ${n}`}
61
61
  ${w.cyan(Ae)}
62
- `}}}).prompt()},"ye"),Va=o(e=>{const t=o((n,s)=>{const r=n.label??String(n.value);switch(s){case"selected":return`${w.dim(r)}`;case"active":return`${w.green(Or)} ${r} ${n.hint?w.dim(`(${n.hint})`):""}`;case"cancelled":return`${w.strikethrough(w.dim(r))}`;default:return`${w.dim(Rr)} ${w.dim(r)}`}},"n");return new xr({options:e.options,initialValue:e.initialValue,render(){const n=`${w.gray(k)}
63
- ${Cn(this.state)} ${e.message}
62
+ `}}}).prompt()},"ye"),Ha=o(e=>{const t=o((n,s)=>{const r=n.label??String(n.value);switch(s){case"selected":return`${w.dim(r)}`;case"active":return`${w.green(Ir)} ${r} ${n.hint?w.dim(`(${n.hint})`):""}`;case"cancelled":return`${w.strikethrough(w.dim(r))}`;default:return`${w.dim(Or)} ${w.dim(r)}`}},"n");return new $r({options:e.options,initialValue:e.initialValue,render(){const n=`${w.gray(k)}
63
+ ${Fn(this.state)} ${e.message}
64
64
  `;switch(this.state){case"submit":return`${n}${w.gray(k)} ${t(this.options[this.cursor],"selected")}`;case"cancel":return`${n}${w.gray(k)} ${t(this.options[this.cursor],"cancelled")}
65
- ${w.gray(k)}`;default:return`${n}${w.cyan(k)} ${pf({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:o((s,r)=>t(s,r?"active":"inactive"),"style")}).join(`
65
+ ${w.gray(k)}`;default:return`${n}${w.cyan(k)} ${df({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:o((s,r)=>t(s,r?"active":"inactive"),"style")}).join(`
66
66
  ${w.cyan(k)} `)}
67
67
  ${w.cyan(Ae)}
68
- `}}}).prompt()},"ve"),kr=o((e="")=>{process.stdout.write(`${w.gray(hf)} ${e}
69
- `)},"Ie"),V=o((e="")=>{process.stdout.write(`${w.gray(k)}
68
+ `}}}).prompt()},"ve"),Rr=o((e="")=>{process.stdout.write(`${w.gray(lf)} ${e}
69
+ `)},"Ie"),J=o((e="")=>{process.stdout.write(`${w.gray(k)}
70
70
  ${w.gray(Ae)} ${e}
71
71
 
72
- `)},"Se");`${w.gray(k)}`;const En=o(({indicator:e="dots"}={})=>{const t=Ir?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=Ir?80:120,s=process.env.CI==="true";let r,i,u=!1,a="",c,l=performance.now();const D=o(B=>{const I=B>1?"Something went wrong":"Canceled";u&&b(I,B)},"p"),d=o(()=>D(2),"v"),f=o(()=>D(1),"f"),h=o(()=>{process.on("uncaughtExceptionMonitor",d),process.on("unhandledRejection",d),process.on("SIGINT",f),process.on("SIGTERM",f),process.on("exit",D)},"j"),F=o(()=>{process.removeListener("uncaughtExceptionMonitor",d),process.removeListener("unhandledRejection",d),process.removeListener("SIGINT",f),process.removeListener("SIGTERM",f),process.removeListener("exit",D)},"E"),m=o(()=>{if(c===void 0)return;s&&process.stdout.write(`
72
+ `)},"Se");`${w.gray(k)}`;const gn=o(({indicator:e="dots"}={})=>{const t=Sr?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=Sr?80:120,s=process.env.CI==="true";let r,i,u=!1,a="",c,l=performance.now();const d=o(B=>{const I=B>1?"Something went wrong":"Canceled";u&&b(I,B)},"p"),D=o(()=>d(2),"v"),f=o(()=>d(1),"f"),h=o(()=>{process.on("uncaughtExceptionMonitor",D),process.on("unhandledRejection",D),process.on("SIGINT",f),process.on("SIGTERM",f),process.on("exit",d)},"j"),F=o(()=>{process.removeListener("uncaughtExceptionMonitor",D),process.removeListener("unhandledRejection",D),process.removeListener("SIGINT",f),process.removeListener("SIGTERM",f),process.removeListener("exit",d)},"E"),m=o(()=>{if(c===void 0)return;s&&process.stdout.write(`
73
73
  `);const B=c.split(`
74
- `);process.stdout.write(Z.cursor.move(-999,B.length-1)),process.stdout.write(Z.erase.down(B.length))},"B"),E=o(B=>B.replace(/\.+$/,""),"R"),y=o(B=>{const I=(performance.now()-B)/1e3,O=Math.floor(I/60),R=Math.floor(I%60);return O>0?`[${O}m ${R}s]`:`[${R}s]`},"O"),g=o((B="")=>{u=!0,r=sf(),a=E(B),l=performance.now(),process.stdout.write(`${w.gray(k)}
75
- `);let I=0,O=0;h(),i=setInterval(()=>{if(s&&a===c)return;m(),c=a;const R=w.magenta(t[I]);if(s)process.stdout.write(`${R} ${a}...`);else if(e==="timer")process.stdout.write(`${R} ${a} ${y(l)}`);else{const L=".".repeat(Math.floor(O)).slice(0,3);process.stdout.write(`${R} ${a}${L}`)}I=I+1<t.length?I+1:0,O=O<t.length?O+.125:0},n)},"H"),b=o((B="",I=0)=>{u=!1,clearInterval(i),m();const O=I===0?w.green(Ka):I===1?w.red(qa):w.red(Ga);a=E(B??a),e==="timer"?process.stdout.write(`${O} ${a} ${y(l)}
74
+ `);process.stdout.write(Z.cursor.move(-999,B.length-1)),process.stdout.write(Z.erase.down(B.length))},"B"),E=o(B=>B.replace(/\.+$/,""),"R"),y=o(B=>{const I=(performance.now()-B)/1e3,O=Math.floor(I/60),R=Math.floor(I%60);return O>0?`[${O}m ${R}s]`:`[${R}s]`},"O"),g=o((B="")=>{u=!0,r=ef(),a=E(B),l=performance.now(),process.stdout.write(`${w.gray(k)}
75
+ `);let I=0,O=0;h(),i=setInterval(()=>{if(s&&a===c)return;m(),c=a;const R=w.magenta(t[I]);if(s)process.stdout.write(`${R} ${a}...`);else if(e==="timer")process.stdout.write(`${R} ${a} ${y(l)}`);else{const L=".".repeat(Math.floor(O)).slice(0,3);process.stdout.write(`${R} ${a}${L}`)}I=I+1<t.length?I+1:0,O=O<t.length?O+.125:0},n)},"H"),b=o((B="",I=0)=>{u=!1,clearInterval(i),m();const O=I===0?w.green(Ga):I===1?w.red(Wa):w.red(qa);a=E(B??a),e==="timer"?process.stdout.write(`${O} ${a} ${y(l)}
76
76
  `):process.stdout.write(`${O} ${a}
77
- `),F(),r()},"N");return{start:g,stop:b,message:o((B="")=>{a=E(B??a)},"message")}},"Y");var yn=Object.freeze({__proto__:null,confirm:za,intro:kr,isCancel:Fn,outro:V,password:mf,select:Va,spinner:En,text:Ha});const{version:Ff}=Ys,ku=class ku extends Error{};o(ku,"KnownError");let G=ku;const Pr=" ",Ja=o(e=>{e instanceof Error&&!(e instanceof G)&&(e.stack&&console.error(mr(e.stack.split(`
77
+ `),F(),r()},"N");return{start:g,stop:b,message:o((B="")=>{a=E(B??a)},"message")}},"Y");var Cn=Object.freeze({__proto__:null,confirm:ff,intro:Rr,isCancel:pn,outro:J,password:hf,select:Ha,spinner:gn,text:Ka});const{version:pf}=Xs,Ru=class Ru extends Error{};o(Ru,"KnownError");let G=Ru;const kr=" ",za=o(e=>{e instanceof Error&&!(e instanceof G)&&(e.stack&&console.error(pr(e.stack.split(`
78
78
  `).slice(1).join(`
79
79
  `))),console.error(`
80
- ${Pr}${mr(`aicommits v${Ff}`)}`),console.error(`
81
- ${Pr}Please open a Bug report with the information above:`),console.error(`${Pr}https://github.com/Nutlope/aicommits/issues/new/choose`))},"handleCliError"),Tr=o(e=>{process.stderr.write(`${gr("\u2716")} ${e.message}
82
- `),Ja(e),process.exit(1)},"handleCommandError"),Xa=o(async()=>{const{stdout:e,failed:t}=await Et("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new G("The current directory must be a Git repository!");return e},"assertGitRepo"),Nr=o(e=>`:(exclude)${e}`,"excludeFromDiff"),Ya=["package-lock.json","pnpm-lock.yaml","*.lock"].map(Nr),Qa=o(async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await Et("git",[...t,"--name-only",...Ya,...e?e.map(Nr):[]]);if(!n)return;const{stdout:s}=await Et("git",[...t,...Ya,...e?e.map(Nr):[]]);return{files:n.split(`
83
- `),diff:s}},"getStagedDiff"),gf=o(e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`,"getDetectedMessage");var Mr,Za;function Cf(){if(Za)return Mr;Za=1;const{hasOwnProperty:e}=Object.prototype,t=typeof process<"u"&&process.platform==="win32"?`\r
80
+ ${kr}${pr(`aicommits v${pf}`)}`),console.error(`
81
+ ${kr}Please open a Bug report with the information above:`),console.error(`${kr}https://github.com/Nutlope/aicommits/issues/new/choose`))},"handleCliError"),Pr=o(e=>{process.stderr.write(`${Fr("\u2716")} ${e.message}
82
+ `),za(e),process.exit(1)},"handleCommandError"),Va=o(async()=>{const{stdout:e,failed:t}=await Ct("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new G("The current directory must be a Git repository!");return e},"assertGitRepo"),Tr=o(e=>`:(exclude)${e}`,"excludeFromDiff"),Ja=["package-lock.json","pnpm-lock.yaml","*.lock"].map(Tr),Xa=o(async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await Ct("git",[...t,"--name-only",...Ja,...e?e.map(Tr):[]]);if(!n)return;const{stdout:s}=await Ct("git",[...t,...Ja,...e?e.map(Tr):[]]);return{files:n.split(`
83
+ `),diff:s}},"getStagedDiff"),mf=o(e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`,"getDetectedMessage");var Nr,Ya;function Ff(){if(Ya)return Nr;Ya=1;const{hasOwnProperty:e}=Object.prototype,t=typeof process<"u"&&process.platform==="win32"?`\r
84
84
  `:`
85
- `,n=o((c,l)=>{const D=[];let d="";typeof l=="string"?l={section:l,whitespace:!1}:(l=l||Object.create(null),l.whitespace=l.whitespace===!0);const f=l.whitespace?" = ":"=";for(const h of Object.keys(c)){const F=c[h];if(F&&Array.isArray(F))for(const m of F)d+=u(h+"[]")+f+u(m)+t;else F&&typeof F=="object"?D.push(h):d+=u(h)+f+u(F)+t}l.section&&d.length&&(d="["+u(l.section)+"]"+t+d);for(const h of D){const F=s(h).join("\\."),m=(l.section?l.section+".":"")+F,{whitespace:E}=l,y=n(c[h],{section:m,whitespace:E});d.length&&y.length&&(d+=t),d+=y}return d},"encode"),s=o(c=>c.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(l=>l.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),"dotSplit"),r=o(c=>{const l=Object.create(null);let D=l,d=null;const f=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,h=c.split(/[\r\n]+/g);for(const m of h){if(!m||m.match(/^\s*[;#]/))continue;const E=m.match(f);if(!E)continue;if(E[1]!==void 0){if(d=a(E[1]),d==="__proto__"){D=Object.create(null);continue}D=l[d]=l[d]||Object.create(null);continue}const y=a(E[2]),g=y.length>2&&y.slice(-2)==="[]",b=g?y.slice(0,-2):y;if(b==="__proto__")continue;const B=E[3]?a(E[4]):!0,I=B==="true"||B==="false"||B==="null"?JSON.parse(B):B;g&&(e.call(D,b)?Array.isArray(D[b])||(D[b]=[D[b]]):D[b]=[]),Array.isArray(D[b])?D[b].push(I):D[b]=I}const F=[];for(const m of Object.keys(l)){if(!e.call(l,m)||typeof l[m]!="object"||Array.isArray(l[m]))continue;const E=s(m);D=l;const y=E.pop(),g=y.replace(/\\\./g,".");for(const b of E)b!=="__proto__"&&((!e.call(D,b)||typeof D[b]!="object")&&(D[b]=Object.create(null)),D=D[b]);D===l&&g===y||(D[g]=l[m],F.push(m))}for(const m of F)delete l[m];return l},"decode"),i=o(c=>c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"),"isQuoted"),u=o(c=>typeof c!="string"||c.match(/[=\r\n]/)||c.match(/^\[/)||c.length>1&&i(c)||c!==c.trim()?JSON.stringify(c):c.split(";").join("\\;").split("#").join("\\#"),"safe"),a=o((c,l)=>{if(c=(c||"").trim(),i(c)){c.charAt(0)==="'"&&(c=c.slice(1,-1));try{c=JSON.parse(c)}catch{}}else{let D=!1,d="";for(let f=0,h=c.length;f<h;f++){const F=c.charAt(f);if(D)"\\;#".indexOf(F)!==-1?d+=F:d+="\\"+F,D=!1;else{if(";#".indexOf(F)!==-1)break;F==="\\"?D=!0:d+=F}}return D&&(d+="\\"),d.trim()}return c},"unsafe");return Mr={parse:r,decode:r,stringify:n,encode:n,safe:u,unsafe:a},Mr}o(Cf,"requireIni");var Ef=Cf(),ec=Le(Ef);const Lr=o(e=>Q.lstat(e).then(()=>!0,()=>!1),"fileExists"),yf=["","conventional","gitmoji"],{hasOwnProperty:wf}=Object.prototype,tc=o((e,t)=>wf.call(e,t),"hasOwn$1"),de=o((e,t,n)=>{if(!t)throw new G(`Invalid config property ${e}: ${n}`)},"parseAssert"),wn={OPENAI_API_KEY(e){return e},OPENAI_BASE_URL(e){return e},OPENAI_MODEL(e){return e||""},locale(e){return e?(de("locale",!!e,"Cannot be empty"),de("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores)."),e):"en"},generate(e){if(!e)return 1;de("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("generate",t>0,"Must be greater than 0"),de("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(de("type",yf.includes(e),"Invalid commit type"),e):""},proxy(e){if(!(!e||e.length===0))throw new G('The "proxy" config property is deprecated and no longer supported.')},timeout(e){if(!e)return;de("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("timeout",t>=500,"Must be greater than 500ms"),t},"max-length"(e){if(!e)return 72;de("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("max-length",t>=20,"Must be greater than 20 characters"),t}},bf={name:"togetherai",displayName:"Together AI (recommended)",baseUrl:"https://api.together.xyz/v1",apiKeyFormat:"tgp_",modelsFilter:o(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",requiresApiKey:!0},_f={name:"openai",displayName:"OpenAI",baseUrl:"https://api.openai.com/v1",apiKeyFormat:"sk-",modelsFilter:o(e=>e.filter(t=>t.id&&(t.id.includes("gpt")||t.id.includes("o1")||t.id.includes("o3")||t.id.includes("o4")||t.id.includes("o5")||!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModel:"gpt-4o",requiresApiKey:!0},Bf={name:"ollama",displayName:"Ollama (local)",baseUrl:"http://localhost:11434/v1",modelsFilter:o(e=>e.filter(t=>t.name).map(t=>t.name),"modelsFilter"),defaultModel:"llama2",requiresApiKey:!1},Af={name:"custom",displayName:"Custom (OpenAI-compatible)",baseUrl:"",modelsFilter:o(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"",requiresApiKey:!0},Bt=[bf,_f,Bf,Af],vf=o(()=>Bt.find(t=>t.name==="openai")?.baseUrl||"","getDefaultBaseUrl"),$f=o((e,t)=>{if(e){const n=Bt.find(s=>s.baseUrl===e||s.name==="ollama"&&e.startsWith(s.baseUrl.slice(0,-3)));return n?n.name:"custom"}else if(t)return"openai"},"detectProvider"),jr=o(()=>ae.join(ho.homedir(),".aicommits"),"getConfigPath"),nc=o(async()=>{if(!await Lr(jr()))return Object.create(null);const t=await Q.readFile(jr(),"utf8");return ec.parse(t)},"readConfigFile"),Ge=o(async(e,t,n)=>{const s=await nc(),r={},{env:i}=process,u=t??{OPENAI_API_KEY:i.OPENAI_API_KEY||i.OPENAI_KEY,OPENAI_BASE_URL:i.OPENAI_BASE_URL,OPENAI_MODEL:i.OPENAI_MODEL};for(const D of Object.keys(wn)){const d=wn[D],f=e?.[D]??u?.[D]??s[D];if(n)try{r[D]=d(f)}catch{}else r[D]=d(f)}let a,c=r.OPENAI_BASE_URL;const l=r.OPENAI_API_KEY;return!c&&l&&(c=vf(),r.OPENAI_BASE_URL=c),a=$f(c,l),{...r,model:r.OPENAI_MODEL,provider:a}},"getConfig"),At=o(async e=>{const t=await nc();for(const[n,s]of e){if(!tc(wn,n))throw new G(`Invalid config property: ${n}`);if(s==="")delete t[n];else{const r=wn[n](s);t[n]=r}}await Q.writeFile(jr(),ec.stringify(t),"utf8")},"setConfigs");function $(e,t,n,s,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}o($,"__classPrivateFieldSet");function p(e,t,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(e):s?s.value:t.get(e)}o(p,"__classPrivateFieldGet");let sc=o(function(){const{crypto:e}=globalThis;if(e?.randomUUID)return sc=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))},"uuid4");function Ur(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}o(Ur,"isAbortError");const Wr=o(e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)},"castToError"),Pu=class Pu extends Error{};o(Pu,"OpenAIError");let v=Pu;const Zt=class Zt extends v{constructor(t,n,s,r){super(`${Zt.makeMessage(t,n,s)}`),this.status=t,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const i=n;this.code=i?.code,this.param=i?.param,this.type=i?.type}static makeMessage(t,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return t&&r?`${t} ${r}`:t?`${t} status code (no body)`:r||"(no status code or body)"}static generate(t,n,s,r){if(!t||!r)return new Ke({message:s,cause:Wr(n)});const i=n?.error;return t===400?new bn(t,i,s,r):t===401?new _n(t,i,s,r):t===403?new Bn(t,i,s,r):t===404?new An(t,i,s,r):t===409?new vn(t,i,s,r):t===422?new $n(t,i,s,r):t===429?new xn(t,i,s,r):t>=500?new Sn(t,i,s,r):new Zt(t,i,s,r)}};o(Zt,"APIError");let ee=Zt;const Tu=class Tu extends ee{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}};o(Tu,"APIUserAbortError");let ne=Tu;const Nu=class Nu extends ee{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}};o(Nu,"APIConnectionError");let Ke=Nu;const Mu=class Mu extends Ke{constructor({message:t}={}){super({message:t??"Request timed out."})}};o(Mu,"APIConnectionTimeoutError");let vt=Mu;const Lu=class Lu extends ee{};o(Lu,"BadRequestError");let bn=Lu;const ju=class ju extends ee{};o(ju,"AuthenticationError");let _n=ju;const Uu=class Uu extends ee{};o(Uu,"PermissionDeniedError");let Bn=Uu;const Wu=class Wu extends ee{};o(Wu,"NotFoundError");let An=Wu;const qu=class qu extends ee{};o(qu,"ConflictError");let vn=qu;const Gu=class Gu extends ee{};o(Gu,"UnprocessableEntityError");let $n=Gu;const Ku=class Ku extends ee{};o(Ku,"RateLimitError");let xn=Ku;const Hu=class Hu extends ee{};o(Hu,"InternalServerError");let Sn=Hu;const zu=class zu extends v{constructor(){super("Could not parse response content as the length limit was reached")}};o(zu,"LengthFinishReasonError");let In=zu;const Vu=class Vu extends v{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};o(Vu,"ContentFilterFinishReasonError");let On=Vu;const Ju=class Ju extends Error{constructor(t){super(t)}};o(Ju,"InvalidWebhookSignatureError");let ve=Ju;const xf=/^[a-z][a-z0-9+.-]*:/i,Sf=o(e=>xf.test(e),"isAbsoluteURL");let se=o(e=>(se=Array.isArray,se(e)),"isArray"),rc=se;function uc(e){return typeof e!="object"?{}:e??{}}o(uc,"maybeObj");function If(e){if(!e)return!0;for(const t in e)return!1;return!0}o(If,"isEmptyObj");function Of(e,t){return Object.prototype.hasOwnProperty.call(e,t)}o(Of,"hasOwn");function qr(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}o(qr,"isObj");const Rf=o((e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},"validatePositiveInteger"),kf=o(e=>{try{return JSON.parse(e)}catch{return}},"safeJSON"),$t=o(e=>new Promise(t=>setTimeout(t,e)),"sleep$1"),He="6.9.0",Pf=o(()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u","isRunningInBrowser");function Tf(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}o(Tf,"getDetectedPlatform");const Nf=o(()=>{const e=Tf();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":He,"X-Stainless-OS":oc(Deno.build.os),"X-Stainless-Arch":ic(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":He,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":He,"X-Stainless-OS":oc(globalThis.process.platform??"unknown"),"X-Stainless-Arch":ic(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=Mf();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":He,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":He,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},"getPlatformProperties");function Mf(){if(typeof navigator>"u"||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const s=n.exec(navigator.userAgent);if(s){const r=s[1]||0,i=s[2]||0,u=s[3]||0;return{browser:t,version:`${r}.${i}.${u}`}}}return null}o(Mf,"getBrowserInfo");const ic=o(e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown","normalizeArch"),oc=o(e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),"normalizePlatform");let ac;const Lf=o(()=>ac??(ac=Nf()),"getPlatformHeaders");function jf(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}o(jf,"getDefaultFetch");function cc(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}o(cc,"makeReadableStream");function lc(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return cc({start(){},async pull(n){const{done:s,value:r}=await t.next();s?n.close():n.enqueue(r)},async cancel(){await t.return?.()}})}o(lc,"ReadableStreamFrom");function Dc(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n?.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}o(Dc,"ReadableStreamToAsyncIterable");async function Uf(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}o(Uf,"CancelReadableStream");const Wf=o(({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),"FallbackEncoder"),dc="RFC3986",hc=o(e=>String(e),"default_formatter"),fc={RFC1738:o(e=>String(e).replace(/%20/g,"+"),"RFC1738"),RFC3986:hc},qf="RFC1738";let Gr=o((e,t)=>(Gr=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Gr(e,t)),"has");const he=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),Kr=1024,Gf=o((e,t,n,s,r)=>{if(e.length===0)return e;let i=e;if(typeof e=="symbol"?i=Symbol.prototype.toString.call(e):typeof e!="string"&&(i=String(e)),n==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let u="";for(let a=0;a<i.length;a+=Kr){const c=i.length>=Kr?i.slice(a,a+Kr):i,l=[];for(let D=0;D<c.length;++D){let d=c.charCodeAt(D);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||r===qf&&(d===40||d===41)){l[l.length]=c.charAt(D);continue}if(d<128){l[l.length]=he[d];continue}if(d<2048){l[l.length]=he[192|d>>6]+he[128|d&63];continue}if(d<55296||d>=57344){l[l.length]=he[224|d>>12]+he[128|d>>6&63]+he[128|d&63];continue}D+=1,d=65536+((d&1023)<<10|c.charCodeAt(D)&1023),l[l.length]=he[240|d>>18]+he[128|d>>12&63]+he[128|d>>6&63]+he[128|d&63]}u+=l.join("")}return u},"encode");function Kf(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}o(Kf,"is_buffer");function pc(e,t){if(se(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)}o(pc,"maybe_map");const mc={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},Fc=o(function(e,t){Array.prototype.push.apply(e,se(t)?t:[t])},"push_to_array");let gc;const K={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Gf,encodeValuesOnly:!1,format:dc,formatter:hc,indices:!1,serializeDate(e){return(gc??(gc=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function Hf(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}o(Hf,"is_non_nullish_primitive");const Hr={};function Cc(e,t,n,s,r,i,u,a,c,l,D,d,f,h,F,m,E,y){let g=e,b=y,B=0,I=!1;for(;(b=b.get(Hr))!==void 0&&!I;){const U=b.get(e);if(B+=1,typeof U<"u"){if(U===B)throw new RangeError("Cyclic object value");I=!0}typeof b.get(Hr)>"u"&&(B=0)}if(typeof l=="function"?g=l(t,g):g instanceof Date?g=f?.(g):n==="comma"&&se(g)&&(g=pc(g,function(U){return U instanceof Date?f?.(U):U})),g===null){if(i)return c&&!m?c(t,K.encoder,E,"key",h):t;g=""}if(Hf(g)||Kf(g)){if(c){const U=m?t:c(t,K.encoder,E,"key",h);return[F?.(U)+"="+F?.(c(g,K.encoder,E,"value",h))]}return[F?.(t)+"="+F?.(String(g))]}const O=[];if(typeof g>"u")return O;let R;if(n==="comma"&&se(g))m&&c&&(g=pc(g,c)),R=[{value:g.length>0?g.join(",")||null:void 0}];else if(se(l))R=l;else{const U=Object.keys(g);R=D?U.sort(D):U}const L=a?String(t).replace(/\./g,"%2E"):String(t),z=s&&se(g)&&g.length===1?L+"[]":L;if(r&&se(g)&&g.length===0)return z+"[]";for(let U=0;U<R.length;++U){const W=R[U],ro=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(u&&ro===null)continue;const js=d&&a?W.replace(/\./g,"%2E"):W,kl=se(g)?typeof n=="function"?n(z,js):z:z+(d?"."+js:"["+js+"]");y.set(e,B);const uo=new WeakMap;uo.set(Hr,y),Fc(O,Cc(ro,kl,n,s,r,i,u,a,n==="comma"&&m&&se(g)?null:c,l,D,d,f,h,F,m,E,uo))}return O}o(Cc,"inner_stringify");function zf(e=K){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");const t=e.charset||K.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=dc;if(typeof e.format<"u"){if(!Gr(fc,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const s=fc[n];let r=K.filter;(typeof e.filter=="function"||se(e.filter))&&(r=e.filter);let i;if(e.arrayFormat&&e.arrayFormat in mc?i=e.arrayFormat:"indices"in e?i=e.indices?"indices":"repeat":i=K.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const u=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:K.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:K.addQueryPrefix,allowDots:u,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:K.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:K.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?K.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:K.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:K.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:K.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:K.encodeValuesOnly,filter:r,format:n,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:K.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:K.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:K.strictNullHandling}}o(zf,"normalize_stringify_options");function Vf(e,t={}){let n=e;const s=zf(t);let r,i;typeof s.filter=="function"?(i=s.filter,n=i("",n)):se(s.filter)&&(i=s.filter,r=i);const u=[];if(typeof n!="object"||n===null)return"";const a=mc[s.arrayFormat],c=a==="comma"&&s.commaRoundTrip;r||(r=Object.keys(n)),s.sort&&r.sort(s.sort);const l=new WeakMap;for(let f=0;f<r.length;++f){const h=r[f];s.skipNulls&&n[h]===null||Fc(u,Cc(n[h],h,a,c,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}const D=u.join(s.delimiter);let d=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),D.length>0?d+D:""}o(Vf,"stringify");function Jf(e){let t=0;for(const r of e)t+=r.length;const n=new Uint8Array(t);let s=0;for(const r of e)n.set(r,s),s+=r.length;return n}o(Jf,"concatBytes");let Ec;function zr(e){let t;return(Ec??(t=new globalThis.TextEncoder,Ec=t.encode.bind(t)))(e)}o(zr,"encodeUTF8");let yc;function wc(e){let t;return(yc??(t=new globalThis.TextDecoder,yc=t.decode.bind(t)))(e)}o(wc,"decodeUTF8");var ue,ie;const Xu=class Xu{constructor(){ue.set(this,void 0),ie.set(this,void 0),$(this,ue,new Uint8Array),$(this,ie,null)}decode(t){if(t==null)return[];const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?zr(t):t;$(this,ue,Jf([p(this,ue,"f"),n]));const s=[];let r;for(;(r=Xf(p(this,ue,"f"),p(this,ie,"f")))!=null;){if(r.carriage&&p(this,ie,"f")==null){$(this,ie,r.index);continue}if(p(this,ie,"f")!=null&&(r.index!==p(this,ie,"f")+1||r.carriage)){s.push(wc(p(this,ue,"f").subarray(0,p(this,ie,"f")-1))),$(this,ue,p(this,ue,"f").subarray(p(this,ie,"f"))),$(this,ie,null);continue}const i=p(this,ie,"f")!==null?r.preceding-1:r.preceding,u=wc(p(this,ue,"f").subarray(0,i));s.push(u),$(this,ue,p(this,ue,"f").subarray(r.index)),$(this,ie,null)}return s}flush(){return p(this,ue,"f").length?this.decode(`
86
- `):[]}};o(Xu,"LineDecoder");let ze=Xu;ue=new WeakMap,ie=new WeakMap,ze.NEWLINE_CHARS=new Set([`
87
- `,"\r"]),ze.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Xf(e,t){for(let r=t??0;r<e.length;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}o(Xf,"findNewlineIndex");function Yf(e){for(let s=0;s<e.length-1;s++){if(e[s]===10&&e[s+1]===10||e[s]===13&&e[s+1]===13)return s+2;if(e[s]===13&&e[s+1]===10&&s+3<e.length&&e[s+2]===13&&e[s+3]===10)return s+4}return-1}o(Yf,"findDoubleNewlineIndex");const Rn={off:0,error:200,warn:300,info:400,debug:500},bc=o((e,t,n)=>{if(e){if(Of(Rn,e))return e;X(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Rn))}`)}},"parseLogLevel");function xt(){}o(xt,"noop");function kn(e,t,n){return!t||Rn[e]>Rn[n]?xt:t[e].bind(t)}o(kn,"makeLogFn");const Qf={error:xt,warn:xt,info:xt,debug:xt};let _c=new WeakMap;function X(e){const t=e.logger,n=e.logLevel??"off";if(!t)return Qf;const s=_c.get(t);if(s&&s[0]===n)return s[1];const r={error:kn("error",t,n),warn:kn("warn",t,n),info:kn("info",t,n),debug:kn("debug",t,n)};return _c.set(t,[n,r]),r}o(X,"loggerFor");const $e=o(e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,n])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),"formatRequestDetails");var St;const Ne=class Ne{constructor(t,n,s){this.iterator=t,St.set(this,void 0),this.controller=n,$(this,St,s)}static fromSSEResponse(t,n,s){let r=!1;const i=s?X(s):console;async function*u(){if(r)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let a=!1;try{for await(const c of Zf(t,n))if(!a){if(c.data.startsWith("[DONE]")){a=!0;continue}if(c.event===null||!c.event.startsWith("thread.")){let l;try{l=JSON.parse(c.data)}catch(D){throw i.error("Could not parse message into JSON:",c.data),i.error("From chunk:",c.raw),D}if(l&&l.error)throw new ee(void 0,l.error,void 0,t.headers);yield l}else{let l;try{l=JSON.parse(c.data)}catch(D){throw console.error("Could not parse message into JSON:",c.data),console.error("From chunk:",c.raw),D}if(c.event=="error")throw new ee(void 0,l.error,l.message,void 0);yield{event:c.event,data:l}}}a=!0}catch(c){if(Ur(c))return;throw c}finally{a||n.abort()}}return o(u,"iterator"),new Ne(u,n,s)}static fromReadableStream(t,n,s){let r=!1;async function*i(){const a=new ze,c=Dc(t);for await(const l of c)for(const D of a.decode(l))yield D;for(const l of a.flush())yield l}o(i,"iterLines");async function*u(){if(r)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let a=!1;try{for await(const c of i())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(Ur(c))return;throw c}finally{a||n.abort()}}return o(u,"iterator"),new Ne(u,n,s)}[(St=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const t=[],n=[],s=this.iterator(),r=o(i=>({next:o(()=>{if(i.length===0){const u=s.next();t.push(u),n.push(u)}return i.shift()},"next")}),"teeIterator");return[new Ne(()=>r(t),this.controller,p(this,St,"f")),new Ne(()=>r(n),this.controller,p(this,St,"f"))]}toReadableStream(){const t=this;let n;return cc({async start(){n=t[Symbol.asyncIterator]()},async pull(s){try{const{value:r,done:i}=await n.next();if(i)return s.close();const u=zr(JSON.stringify(r)+`
88
- `);s.enqueue(u)}catch(r){s.error(r)}},async cancel(){await n.return?.()}})}};o(Ne,"Stream");let xe=Ne;async function*Zf(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new v("Attempted to iterate over a response with no body");const n=new Vr,s=new ze,r=Dc(e.body);for await(const i of ep(r))for(const u of s.decode(i)){const a=n.decode(u);a&&(yield a)}for(const i of s.flush()){const u=n.decode(i);u&&(yield u)}}o(Zf,"_iterSSEMessages");async function*ep(e){let t=new Uint8Array;for await(const n of e){if(n==null)continue;const s=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?zr(n):n;let r=new Uint8Array(t.length+s.length);r.set(t),r.set(s,t.length),t=r;let i;for(;(i=Yf(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}o(ep,"iterSSEChunks");const Yu=class Yu{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const i={event:this.event,data:this.data.join(`
89
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,s,r]=tp(t,":");return r.startsWith(" ")&&(r=r.substring(1)),n==="event"?this.event=r:n==="data"&&this.data.push(r),null}};o(Yu,"SSEDecoder");let Vr=Yu;function tp(e,t){const n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}o(tp,"partition");async function Bc(e,t){const{response:n,requestLogID:s,retryOfRequestLogID:r,startTime:i}=t,u=await(async()=>{if(t.options.stream)return X(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):xe.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;const c=n.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){const d=await n.json();return Ac(d,n)}return await n.text()})();return X(e).debug(`[${s}] response parsed`,$e({retryOfRequestLogID:r,url:n.url,status:n.status,body:u,durationMs:Date.now()-i})),u}o(Bc,"defaultParseResponse");function Ac(e,t){return!e||typeof e!="object"||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}o(Ac,"addRequestID");var It;const Ns=class Ns extends Promise{constructor(t,n,s=Bc){super(r=>{r(null)}),this.responsePromise=n,this.parseResponse=s,It.set(this,void 0),$(this,It,t)}_thenUnwrap(t){return new Ns(p(this,It,"f"),this.responsePromise,async(n,s)=>Ac(t(await this.parseResponse(n,s),s),s.response))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n,request_id:n.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(p(this,It,"f"),t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};o(Ns,"APIPromise");let Pn=Ns;It=new WeakMap;var Tn;const Qu=class Qu{constructor(t,n,s,r){Tn.set(this,void 0),$(this,Tn,t),this.options=r,this.response=n,this.body=s}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const t=this.nextPageRequestOptions();if(!t)throw new v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await p(this,Tn,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(Tn=new WeakMap,Symbol.asyncIterator)](){for await(const t of this.iterPages())for(const n of t.getPaginatedItems())yield n}};o(Qu,"AbstractPage");let Ot=Qu;const Zu=class Zu extends Pn{constructor(t,n,s){super(t,n,async(r,i)=>new s(r,i.response,await Bc(r,i),i.options))}async*[Symbol.asyncIterator](){const t=await this;for await(const n of t)yield n}};o(Zu,"PagePromise");let Jr=Zu;const ei=class ei extends Ot{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.object=s.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}};o(ei,"Page");let Ve=ei;const ti=class ti extends Ot{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.has_more=s.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const t=this.getPaginatedItems(),n=t[t.length-1]?.id;return n?{...this.options,query:{...uc(this.options.query),after:n}}:null}};o(ti,"CursorPage");let M=ti;const ni=class ni extends Ot{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.has_more=s.has_more||!1,this.last_id=s.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const t=this.last_id;return t?{...this.options,query:{...uc(this.options.query),after:t}}:null}};o(ni,"ConversationCursorPage");let Je=ni;const vc=o(()=>{if(typeof File>"u"){const{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},"checkFileSupport");function Rt(e,t,n){return vc(),new File(e,t??"unknown_file",n)}o(Rt,"makeFile");function Nn(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}o(Nn,"getName");const Xr=o(e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function","isAsyncIterable"),$c=o(async(e,t)=>Yr(e.body)?{...e,body:await Sc(e.body,t)}:e,"maybeMultipartFormRequestOptions"),Se=o(async(e,t)=>({...e,body:await Sc(e.body,t)}),"multipartFormRequestOptions"),xc=new WeakMap;function np(e){const t=typeof e=="function"?e:e.fetch,n=xc.get(t);if(n)return n;const s=(async()=>{try{const r="Response"in t?t.Response:(await t("data:,")).constructor,i=new FormData;return i.toString()!==await new r(i).text()}catch{return!0}})();return xc.set(t,s),s}o(np,"supportsFormData");const Sc=o(async(e,t)=>{if(!await np(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(e||{}).map(([s,r])=>Qr(n,s,r))),n},"createForm"),Ic=o(e=>e instanceof Blob&&"name"in e,"isNamedBlob"),sp=o(e=>typeof e=="object"&&e!==null&&(e instanceof Response||Xr(e)||Ic(e)),"isUploadable"),Yr=o(e=>{if(sp(e))return!0;if(Array.isArray(e))return e.some(Yr);if(e&&typeof e=="object"){for(const t in e)if(Yr(e[t]))return!0}return!1},"hasUploadableValue"),Qr=o(async(e,t,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")e.append(t,String(n));else if(n instanceof Response)e.append(t,Rt([await n.blob()],Nn(n)));else if(Xr(n))e.append(t,Rt([await new Response(lc(n)).blob()],Nn(n)));else if(Ic(n))e.append(t,n,Nn(n));else if(Array.isArray(n))await Promise.all(n.map(s=>Qr(e,t+"[]",s)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([s,r])=>Qr(e,`${t}[${s}]`,r)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},"addFormValue"),Oc=o(e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function","isBlobLike"),rp=o(e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&Oc(e),"isFileLike"),up=o(e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function","isResponseLike");async function ip(e,t,n){if(vc(),e=await e,rp(e))return e instanceof File?e:Rt([await e.arrayBuffer()],e.name);if(up(e)){const r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Rt(await Zr(r),t,n)}const s=await Zr(e);if(t||(t=Nn(e)),!n?.type){const r=s.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof r=="string"&&(n={...n,type:r})}return Rt(s,t,n)}o(ip,"toFile");async function Zr(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(Oc(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Xr(e))for await(const n of e)t.push(...await Zr(n));else{const n=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${n?`; constructor: ${n}`:""}${op(e)}`)}return t}o(Zr,"getBytes");function op(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}o(op,"propsForError");const si=class si{constructor(t){this._client=t}};o(si,"APIResource");let A=si;function Rc(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}o(Rc,"encodeURIPath");const kc=Object.freeze(Object.create(null)),ap=o((e=Rc)=>o(function(n,...s){if(n.length===1)return n[0];let r=!1;const i=[],u=n.reduce((D,d,f)=>{/[?#]/.test(d)&&(r=!0);const h=s[f];let F=(r?encodeURIComponent:e)(""+h);return f!==s.length&&(h==null||typeof h=="object"&&h.toString===Object.getPrototypeOf(Object.getPrototypeOf(h.hasOwnProperty??kc)??kc)?.toString)&&(F=h+"",i.push({start:D.length+d.length,length:F.length,error:`Value of type ${Object.prototype.toString.call(h).slice(8,-1)} is not a valid path parameter`})),D+d+(f===s.length?"":F)},""),a=u.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let l;for(;(l=c.exec(a))!==null;)i.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can't be safely passed as a path parameter`});if(i.sort((D,d)=>D.start-d.start),i.length>0){let D=0;const d=i.reduce((f,h)=>{const F=" ".repeat(h.start-D),m="^".repeat(h.length);return D=h.start+h.length,f+F+m},"");throw new v(`Path parameters result in path with invalid segments:
85
+ `,n=o((c,l)=>{const d=[];let D="";typeof l=="string"?l={section:l,whitespace:!1}:(l=l||Object.create(null),l.whitespace=l.whitespace===!0);const f=l.whitespace?" = ":"=";for(const h of Object.keys(c)){const F=c[h];if(F&&Array.isArray(F))for(const m of F)D+=u(h+"[]")+f+u(m)+t;else F&&typeof F=="object"?d.push(h):D+=u(h)+f+u(F)+t}l.section&&D.length&&(D="["+u(l.section)+"]"+t+D);for(const h of d){const F=s(h).join("\\."),m=(l.section?l.section+".":"")+F,{whitespace:E}=l,y=n(c[h],{section:m,whitespace:E});D.length&&y.length&&(D+=t),D+=y}return D},"encode"),s=o(c=>c.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(l=>l.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),"dotSplit"),r=o(c=>{const l=Object.create(null);let d=l,D=null;const f=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,h=c.split(/[\r\n]+/g);for(const m of h){if(!m||m.match(/^\s*[;#]/))continue;const E=m.match(f);if(!E)continue;if(E[1]!==void 0){if(D=a(E[1]),D==="__proto__"){d=Object.create(null);continue}d=l[D]=l[D]||Object.create(null);continue}const y=a(E[2]),g=y.length>2&&y.slice(-2)==="[]",b=g?y.slice(0,-2):y;if(b==="__proto__")continue;const B=E[3]?a(E[4]):!0,I=B==="true"||B==="false"||B==="null"?JSON.parse(B):B;g&&(e.call(d,b)?Array.isArray(d[b])||(d[b]=[d[b]]):d[b]=[]),Array.isArray(d[b])?d[b].push(I):d[b]=I}const F=[];for(const m of Object.keys(l)){if(!e.call(l,m)||typeof l[m]!="object"||Array.isArray(l[m]))continue;const E=s(m);d=l;const y=E.pop(),g=y.replace(/\\\./g,".");for(const b of E)b!=="__proto__"&&((!e.call(d,b)||typeof d[b]!="object")&&(d[b]=Object.create(null)),d=d[b]);d===l&&g===y||(d[g]=l[m],F.push(m))}for(const m of F)delete l[m];return l},"decode"),i=o(c=>c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"),"isQuoted"),u=o(c=>typeof c!="string"||c.match(/[=\r\n]/)||c.match(/^\[/)||c.length>1&&i(c)||c!==c.trim()?JSON.stringify(c):c.split(";").join("\\;").split("#").join("\\#"),"safe"),a=o((c,l)=>{if(c=(c||"").trim(),i(c)){c.charAt(0)==="'"&&(c=c.slice(1,-1));try{c=JSON.parse(c)}catch{}}else{let d=!1,D="";for(let f=0,h=c.length;f<h;f++){const F=c.charAt(f);if(d)"\\;#".indexOf(F)!==-1?D+=F:D+="\\"+F,d=!1;else{if(";#".indexOf(F)!==-1)break;F==="\\"?d=!0:D+=F}}return d&&(D+="\\"),D.trim()}return c},"unsafe");return Nr={parse:r,decode:r,stringify:n,encode:n,safe:u,unsafe:a},Nr}o(Ff,"requireIni");var gf=Ff(),Qa=Me(gf);const Mr=o(e=>Q.lstat(e).then(()=>!0,()=>!1),"fileExists"),Cf=["","conventional","gitmoji"],{hasOwnProperty:Ef}=Object.prototype,Za=o((e,t)=>Ef.call(e,t),"hasOwn$1"),de=o((e,t,n)=>{if(!t)throw new G(`Invalid config property ${e}: ${n}`)},"parseAssert"),En={OPENAI_API_KEY(e){return e},OPENAI_BASE_URL(e){return e},OPENAI_MODEL(e){return e||""},locale(e){return e?(de("locale",!!e,"Cannot be empty"),de("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores)."),e):"en"},generate(e){if(!e)return 1;de("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("generate",t>0,"Must be greater than 0"),de("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(de("type",Cf.includes(e),"Invalid commit type"),e):""},proxy(e){if(!(!e||e.length===0))throw new G('The "proxy" config property is deprecated and no longer supported.')},timeout(e){if(!e)return;de("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("timeout",t>=500,"Must be greater than 500ms"),t},"max-length"(e){if(!e)return 72;de("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return de("max-length",t>=20,"Must be greater than 20 characters"),t}},yf={name:"togetherai",displayName:"Together AI (recommended)",baseUrl:"https://api.together.xyz/v1",apiKeyFormat:"tgp_",modelsFilter:o(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",requiresApiKey:!0},wf={name:"openai",displayName:"OpenAI",baseUrl:"https://api.openai.com/v1",apiKeyFormat:"sk-",modelsFilter:o(e=>e.filter(t=>t.id&&(t.id.includes("gpt")||t.id.includes("o1")||t.id.includes("o3")||t.id.includes("o4")||t.id.includes("o5")||!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModel:"gpt-4o",requiresApiKey:!0},bf={name:"ollama",displayName:"Ollama (local)",baseUrl:"http://localhost:11434/v1",modelsFilter:o(e=>e.filter(t=>t.name).map(t=>t.name),"modelsFilter"),defaultModel:"llama2",requiresApiKey:!1},_f={name:"custom",displayName:"Custom (OpenAI-compatible)",baseUrl:"",modelsFilter:o(e=>e.filter(t=>!t.type||t.type==="chat"||t.type==="language").map(t=>t.id),"modelsFilter"),defaultModel:"",requiresApiKey:!0},Bf={name:"openrouter",displayName:"OpenRouter",baseUrl:"https://openrouter.ai/api/v1",apiKeyFormat:"sk-or-v1-",modelsFilter:o(e=>e.filter(t=>t.id&&(!t.type||t.type==="chat")).map(t=>t.id),"modelsFilter"),defaultModel:"x-ai/grok-4.1-fast:free",requiresApiKey:!0},_t=[yf,wf,bf,Bf,_f],Af=o(()=>_t.find(t=>t.name==="openai")?.baseUrl||"","getDefaultBaseUrl"),vf=o((e,t)=>{if(e){const n=_t.find(s=>s.baseUrl===e||s.name==="ollama"&&e.startsWith(s.baseUrl.slice(0,-3)));return n?n.name:"custom"}else if(t)return"openai"},"detectProvider"),Lr=o(()=>ae.join(Do.homedir(),".aicommits"),"getConfigPath"),ec=o(async()=>{if(!await Mr(Lr()))return Object.create(null);const t=await Q.readFile(Lr(),"utf8");return Qa.parse(t)},"readConfigFile"),qe=o(async(e,t,n)=>{const s=await ec(),r={},{env:i}=process,u=t??{OPENAI_API_KEY:i.OPENAI_API_KEY||i.OPENAI_KEY,OPENAI_BASE_URL:i.OPENAI_BASE_URL,OPENAI_MODEL:i.OPENAI_MODEL};for(const d of Object.keys(En)){const D=En[d],f=e?.[d]??u?.[d]??s[d];if(n)try{r[d]=D(f)}catch{}else r[d]=D(f)}let a,c=r.OPENAI_BASE_URL;const l=r.OPENAI_API_KEY;return!c&&l&&(c=Af(),r.OPENAI_BASE_URL=c),a=vf(c,l),{...r,model:r.OPENAI_MODEL,provider:a}},"getConfig"),jr=o(async e=>{const t=await ec();for(const[n,s]of e){if(!Za(En,n))throw new G(`Invalid config property: ${n}`);if(s==="")delete t[n];else{const r=En[n](s);t[n]=r}}await Q.writeFile(Lr(),Qa.stringify(t),"utf8")},"setConfigs");function $(e,t,n,s,r){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,n),n}o($,"__classPrivateFieldSet");function p(e,t,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(e):s?s.value:t.get(e)}o(p,"__classPrivateFieldGet");let tc=o(function(){const{crypto:e}=globalThis;if(e?.randomUUID)return tc=e.randomUUID.bind(e),e.randomUUID();const t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))},"uuid4");function Ur(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}o(Ur,"isAbortError");const Wr=o(e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{if(Object.prototype.toString.call(e)==="[object Error]"){const t=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)},"castToError"),ku=class ku extends Error{};o(ku,"OpenAIError");let v=ku;const Yt=class Yt extends v{constructor(t,n,s,r){super(`${Yt.makeMessage(t,n,s)}`),this.status=t,this.headers=r,this.requestID=r?.get("x-request-id"),this.error=n;const i=n;this.code=i?.code,this.param=i?.param,this.type=i?.type}static makeMessage(t,n,s){const r=n?.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):s;return t&&r?`${t} ${r}`:t?`${t} status code (no body)`:r||"(no status code or body)"}static generate(t,n,s,r){if(!t||!r)return new Ge({message:s,cause:Wr(n)});const i=n?.error;return t===400?new yn(t,i,s,r):t===401?new wn(t,i,s,r):t===403?new bn(t,i,s,r):t===404?new _n(t,i,s,r):t===409?new Bn(t,i,s,r):t===422?new An(t,i,s,r):t===429?new vn(t,i,s,r):t>=500?new $n(t,i,s,r):new Yt(t,i,s,r)}};o(Yt,"APIError");let ee=Yt;const Pu=class Pu extends ee{constructor({message:t}={}){super(void 0,void 0,t||"Request was aborted.",void 0)}};o(Pu,"APIUserAbortError");let ne=Pu;const Tu=class Tu extends ee{constructor({message:t,cause:n}){super(void 0,void 0,t||"Connection error.",void 0),n&&(this.cause=n)}};o(Tu,"APIConnectionError");let Ge=Tu;const Nu=class Nu extends Ge{constructor({message:t}={}){super({message:t??"Request timed out."})}};o(Nu,"APIConnectionTimeoutError");let Bt=Nu;const Mu=class Mu extends ee{};o(Mu,"BadRequestError");let yn=Mu;const Lu=class Lu extends ee{};o(Lu,"AuthenticationError");let wn=Lu;const ju=class ju extends ee{};o(ju,"PermissionDeniedError");let bn=ju;const Uu=class Uu extends ee{};o(Uu,"NotFoundError");let _n=Uu;const Wu=class Wu extends ee{};o(Wu,"ConflictError");let Bn=Wu;const qu=class qu extends ee{};o(qu,"UnprocessableEntityError");let An=qu;const Gu=class Gu extends ee{};o(Gu,"RateLimitError");let vn=Gu;const Ku=class Ku extends ee{};o(Ku,"InternalServerError");let $n=Ku;const Hu=class Hu extends v{constructor(){super("Could not parse response content as the length limit was reached")}};o(Hu,"LengthFinishReasonError");let xn=Hu;const zu=class zu extends v{constructor(){super("Could not parse response content as the request was rejected by the content filter")}};o(zu,"ContentFilterFinishReasonError");let Sn=zu;const Vu=class Vu extends Error{constructor(t){super(t)}};o(Vu,"InvalidWebhookSignatureError");let ve=Vu;const $f=/^[a-z][a-z0-9+.-]*:/i,xf=o(e=>$f.test(e),"isAbsoluteURL");let se=o(e=>(se=Array.isArray,se(e)),"isArray"),nc=se;function sc(e){return typeof e!="object"?{}:e??{}}o(sc,"maybeObj");function Sf(e){if(!e)return!0;for(const t in e)return!1;return!0}o(Sf,"isEmptyObj");function If(e,t){return Object.prototype.hasOwnProperty.call(e,t)}o(If,"hasOwn");function qr(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}o(qr,"isObj");const Of=o((e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new v(`${e} must be an integer`);if(t<0)throw new v(`${e} must be a positive integer`);return t},"validatePositiveInteger"),Rf=o(e=>{try{return JSON.parse(e)}catch{return}},"safeJSON"),At=o(e=>new Promise(t=>setTimeout(t,e)),"sleep$1"),Ke="6.9.0",kf=o(()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u","isRunningInBrowser");function Pf(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}o(Pf,"getDetectedPlatform");const Tf=o(()=>{const e=Pf();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ke,"X-Stainless-OS":uc(Deno.build.os),"X-Stainless-Arch":rc(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ke,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ke,"X-Stainless-OS":uc(globalThis.process.platform??"unknown"),"X-Stainless-Arch":rc(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const t=Nf();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ke,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Ke,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},"getPlatformProperties");function Nf(){if(typeof navigator>"u"||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:n}of e){const s=n.exec(navigator.userAgent);if(s){const r=s[1]||0,i=s[2]||0,u=s[3]||0;return{browser:t,version:`${r}.${i}.${u}`}}}return null}o(Nf,"getBrowserInfo");const rc=o(e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown","normalizeArch"),uc=o(e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown"),"normalizePlatform");let ic;const Mf=o(()=>ic??(ic=Tf()),"getPlatformHeaders");function Lf(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}o(Lf,"getDefaultFetch");function oc(...e){const t=globalThis.ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}o(oc,"makeReadableStream");function ac(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return oc({start(){},async pull(n){const{done:s,value:r}=await t.next();s?n.close():n.enqueue(r)},async cancel(){await t.return?.()}})}o(ac,"ReadableStreamFrom");function cc(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const n=await t.read();return n?.done&&t.releaseLock(),n}catch(n){throw t.releaseLock(),n}},async return(){const n=t.cancel();return t.releaseLock(),await n,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}o(cc,"ReadableStreamToAsyncIterable");async function jf(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}const t=e.getReader(),n=t.cancel();t.releaseLock(),await n}o(jf,"CancelReadableStream");const Uf=o(({headers:e,body:t})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(t)}),"FallbackEncoder"),lc="RFC3986",Dc=o(e=>String(e),"default_formatter"),dc={RFC1738:o(e=>String(e).replace(/%20/g,"+"),"RFC1738"),RFC3986:Dc},Wf="RFC1738";let Gr=o((e,t)=>(Gr=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Gr(e,t)),"has");const he=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),Kr=1024,qf=o((e,t,n,s,r)=>{if(e.length===0)return e;let i=e;if(typeof e=="symbol"?i=Symbol.prototype.toString.call(e):typeof e!="string"&&(i=String(e)),n==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});let u="";for(let a=0;a<i.length;a+=Kr){const c=i.length>=Kr?i.slice(a,a+Kr):i,l=[];for(let d=0;d<c.length;++d){let D=c.charCodeAt(d);if(D===45||D===46||D===95||D===126||D>=48&&D<=57||D>=65&&D<=90||D>=97&&D<=122||r===Wf&&(D===40||D===41)){l[l.length]=c.charAt(d);continue}if(D<128){l[l.length]=he[D];continue}if(D<2048){l[l.length]=he[192|D>>6]+he[128|D&63];continue}if(D<55296||D>=57344){l[l.length]=he[224|D>>12]+he[128|D>>6&63]+he[128|D&63];continue}d+=1,D=65536+((D&1023)<<10|c.charCodeAt(d)&1023),l[l.length]=he[240|D>>18]+he[128|D>>12&63]+he[128|D>>6&63]+he[128|D&63]}u+=l.join("")}return u},"encode");function Gf(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}o(Gf,"is_buffer");function hc(e,t){if(se(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(t(e[s]));return n}return t(e)}o(hc,"maybe_map");const fc={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},pc=o(function(e,t){Array.prototype.push.apply(e,se(t)?t:[t])},"push_to_array");let mc;const K={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:qf,encodeValuesOnly:!1,format:lc,formatter:Dc,indices:!1,serializeDate(e){return(mc??(mc=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function Kf(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}o(Kf,"is_non_nullish_primitive");const Hr={};function Fc(e,t,n,s,r,i,u,a,c,l,d,D,f,h,F,m,E,y){let g=e,b=y,B=0,I=!1;for(;(b=b.get(Hr))!==void 0&&!I;){const U=b.get(e);if(B+=1,typeof U<"u"){if(U===B)throw new RangeError("Cyclic object value");I=!0}typeof b.get(Hr)>"u"&&(B=0)}if(typeof l=="function"?g=l(t,g):g instanceof Date?g=f?.(g):n==="comma"&&se(g)&&(g=hc(g,function(U){return U instanceof Date?f?.(U):U})),g===null){if(i)return c&&!m?c(t,K.encoder,E,"key",h):t;g=""}if(Kf(g)||Gf(g)){if(c){const U=m?t:c(t,K.encoder,E,"key",h);return[F?.(U)+"="+F?.(c(g,K.encoder,E,"value",h))]}return[F?.(t)+"="+F?.(String(g))]}const O=[];if(typeof g>"u")return O;let R;if(n==="comma"&&se(g))m&&c&&(g=hc(g,c)),R=[{value:g.length>0?g.join(",")||null:void 0}];else if(se(l))R=l;else{const U=Object.keys(g);R=d?U.sort(d):U}const L=a?String(t).replace(/\./g,"%2E"):String(t),z=s&&se(g)&&g.length===1?L+"[]":L;if(r&&se(g)&&g.length===0)return z+"[]";for(let U=0;U<R.length;++U){const W=R[U],so=typeof W=="object"&&typeof W.value<"u"?W.value:g[W];if(u&&so===null)continue;const Ls=D&&a?W.replace(/\./g,"%2E"):W,Ol=se(g)?typeof n=="function"?n(z,Ls):z:z+(D?"."+Ls:"["+Ls+"]");y.set(e,B);const ro=new WeakMap;ro.set(Hr,y),pc(O,Fc(so,Ol,n,s,r,i,u,a,n==="comma"&&m&&se(g)?null:c,l,d,D,f,h,F,m,E,ro))}return O}o(Fc,"inner_stringify");function Hf(e=K){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");const t=e.charset||K.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=lc;if(typeof e.format<"u"){if(!Gr(dc,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const s=dc[n];let r=K.filter;(typeof e.filter=="function"||se(e.filter))&&(r=e.filter);let i;if(e.arrayFormat&&e.arrayFormat in fc?i=e.arrayFormat:"indices"in e?i=e.indices?"indices":"repeat":i=K.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const u=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:K.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:K.addQueryPrefix,allowDots:u,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:K.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:K.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?K.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:K.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:K.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:K.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:K.encodeValuesOnly,filter:r,format:n,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:K.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:K.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:K.strictNullHandling}}o(Hf,"normalize_stringify_options");function zf(e,t={}){let n=e;const s=Hf(t);let r,i;typeof s.filter=="function"?(i=s.filter,n=i("",n)):se(s.filter)&&(i=s.filter,r=i);const u=[];if(typeof n!="object"||n===null)return"";const a=fc[s.arrayFormat],c=a==="comma"&&s.commaRoundTrip;r||(r=Object.keys(n)),s.sort&&r.sort(s.sort);const l=new WeakMap;for(let f=0;f<r.length;++f){const h=r[f];s.skipNulls&&n[h]===null||pc(u,Fc(n[h],h,a,c,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,l))}const d=u.join(s.delimiter);let D=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?D+="utf8=%26%2310003%3B&":D+="utf8=%E2%9C%93&"),d.length>0?D+d:""}o(zf,"stringify");function Vf(e){let t=0;for(const r of e)t+=r.length;const n=new Uint8Array(t);let s=0;for(const r of e)n.set(r,s),s+=r.length;return n}o(Vf,"concatBytes");let gc;function zr(e){let t;return(gc??(t=new globalThis.TextEncoder,gc=t.encode.bind(t)))(e)}o(zr,"encodeUTF8");let Cc;function Ec(e){let t;return(Cc??(t=new globalThis.TextDecoder,Cc=t.decode.bind(t)))(e)}o(Ec,"decodeUTF8");var ue,ie;const Ju=class Ju{constructor(){ue.set(this,void 0),ie.set(this,void 0),$(this,ue,new Uint8Array),$(this,ie,null)}decode(t){if(t==null)return[];const n=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?zr(t):t;$(this,ue,Vf([p(this,ue,"f"),n]));const s=[];let r;for(;(r=Jf(p(this,ue,"f"),p(this,ie,"f")))!=null;){if(r.carriage&&p(this,ie,"f")==null){$(this,ie,r.index);continue}if(p(this,ie,"f")!=null&&(r.index!==p(this,ie,"f")+1||r.carriage)){s.push(Ec(p(this,ue,"f").subarray(0,p(this,ie,"f")-1))),$(this,ue,p(this,ue,"f").subarray(p(this,ie,"f"))),$(this,ie,null);continue}const i=p(this,ie,"f")!==null?r.preceding-1:r.preceding,u=Ec(p(this,ue,"f").subarray(0,i));s.push(u),$(this,ue,p(this,ue,"f").subarray(r.index)),$(this,ie,null)}return s}flush(){return p(this,ue,"f").length?this.decode(`
86
+ `):[]}};o(Ju,"LineDecoder");let He=Ju;ue=new WeakMap,ie=new WeakMap,He.NEWLINE_CHARS=new Set([`
87
+ `,"\r"]),He.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Jf(e,t){for(let r=t??0;r<e.length;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}o(Jf,"findNewlineIndex");function Xf(e){for(let s=0;s<e.length-1;s++){if(e[s]===10&&e[s+1]===10||e[s]===13&&e[s+1]===13)return s+2;if(e[s]===13&&e[s+1]===10&&s+3<e.length&&e[s+2]===13&&e[s+3]===10)return s+4}return-1}o(Xf,"findDoubleNewlineIndex");const In={off:0,error:200,warn:300,info:400,debug:500},yc=o((e,t,n)=>{if(e){if(If(In,e))return e;X(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(In))}`)}},"parseLogLevel");function vt(){}o(vt,"noop");function On(e,t,n){return!t||In[e]>In[n]?vt:t[e].bind(t)}o(On,"makeLogFn");const Yf={error:vt,warn:vt,info:vt,debug:vt};let wc=new WeakMap;function X(e){const t=e.logger,n=e.logLevel??"off";if(!t)return Yf;const s=wc.get(t);if(s&&s[0]===n)return s[1];const r={error:On("error",t,n),warn:On("warn",t,n),info:On("info",t,n),debug:On("debug",t,n)};return wc.set(t,[n,r]),r}o(X,"loggerFor");const $e=o(e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([t,n])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),"formatRequestDetails");var $t;const Te=class Te{constructor(t,n,s){this.iterator=t,$t.set(this,void 0),this.controller=n,$(this,$t,s)}static fromSSEResponse(t,n,s){let r=!1;const i=s?X(s):console;async function*u(){if(r)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let a=!1;try{for await(const c of Qf(t,n))if(!a){if(c.data.startsWith("[DONE]")){a=!0;continue}if(c.event===null||!c.event.startsWith("thread.")){let l;try{l=JSON.parse(c.data)}catch(d){throw i.error("Could not parse message into JSON:",c.data),i.error("From chunk:",c.raw),d}if(l&&l.error)throw new ee(void 0,l.error,void 0,t.headers);yield l}else{let l;try{l=JSON.parse(c.data)}catch(d){throw console.error("Could not parse message into JSON:",c.data),console.error("From chunk:",c.raw),d}if(c.event=="error")throw new ee(void 0,l.error,l.message,void 0);yield{event:c.event,data:l}}}a=!0}catch(c){if(Ur(c))return;throw c}finally{a||n.abort()}}return o(u,"iterator"),new Te(u,n,s)}static fromReadableStream(t,n,s){let r=!1;async function*i(){const a=new He,c=cc(t);for await(const l of c)for(const d of a.decode(l))yield d;for(const l of a.flush())yield l}o(i,"iterLines");async function*u(){if(r)throw new v("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");r=!0;let a=!1;try{for await(const c of i())a||c&&(yield JSON.parse(c));a=!0}catch(c){if(Ur(c))return;throw c}finally{a||n.abort()}}return o(u,"iterator"),new Te(u,n,s)}[($t=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const t=[],n=[],s=this.iterator(),r=o(i=>({next:o(()=>{if(i.length===0){const u=s.next();t.push(u),n.push(u)}return i.shift()},"next")}),"teeIterator");return[new Te(()=>r(t),this.controller,p(this,$t,"f")),new Te(()=>r(n),this.controller,p(this,$t,"f"))]}toReadableStream(){const t=this;let n;return oc({async start(){n=t[Symbol.asyncIterator]()},async pull(s){try{const{value:r,done:i}=await n.next();if(i)return s.close();const u=zr(JSON.stringify(r)+`
88
+ `);s.enqueue(u)}catch(r){s.error(r)}},async cancel(){await n.return?.()}})}};o(Te,"Stream");let xe=Te;async function*Qf(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new v("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new v("Attempted to iterate over a response with no body");const n=new Vr,s=new He,r=cc(e.body);for await(const i of Zf(r))for(const u of s.decode(i)){const a=n.decode(u);a&&(yield a)}for(const i of s.flush()){const u=n.decode(i);u&&(yield u)}}o(Qf,"_iterSSEMessages");async function*Zf(e){let t=new Uint8Array;for await(const n of e){if(n==null)continue;const s=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?zr(n):n;let r=new Uint8Array(t.length+s.length);r.set(t),r.set(s,t.length),t=r;let i;for(;(i=Xf(t))!==-1;)yield t.slice(0,i),t=t.slice(i)}t.length>0&&(yield t)}o(Zf,"iterSSEChunks");const Xu=class Xu{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;const i={event:this.event,data:this.data.join(`
89
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(t),t.startsWith(":"))return null;let[n,s,r]=ep(t,":");return r.startsWith(" ")&&(r=r.substring(1)),n==="event"?this.event=r:n==="data"&&this.data.push(r),null}};o(Xu,"SSEDecoder");let Vr=Xu;function ep(e,t){const n=e.indexOf(t);return n!==-1?[e.substring(0,n),t,e.substring(n+t.length)]:[e,"",""]}o(ep,"partition");async function bc(e,t){const{response:n,requestLogID:s,retryOfRequestLogID:r,startTime:i}=t,u=await(async()=>{if(t.options.stream)return X(e).debug("response",n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):xe.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;const c=n.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){const D=await n.json();return _c(D,n)}return await n.text()})();return X(e).debug(`[${s}] response parsed`,$e({retryOfRequestLogID:r,url:n.url,status:n.status,body:u,durationMs:Date.now()-i})),u}o(bc,"defaultParseResponse");function _c(e,t){return!e||typeof e!="object"||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}o(_c,"addRequestID");var xt;const Ts=class Ts extends Promise{constructor(t,n,s=bc){super(r=>{r(null)}),this.responsePromise=n,this.parseResponse=s,xt.set(this,void 0),$(this,xt,t)}_thenUnwrap(t){return new Ts(p(this,xt,"f"),this.responsePromise,async(n,s)=>_c(t(await this.parseResponse(n,s),s),s.response))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){const[t,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:n,request_id:n.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(p(this,xt,"f"),t))),this.parsedPromise}then(t,n){return this.parse().then(t,n)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};o(Ts,"APIPromise");let Rn=Ts;xt=new WeakMap;var kn;const Yu=class Yu{constructor(t,n,s,r){kn.set(this,void 0),$(this,kn,t),this.options=r,this.response=n,this.body=s}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const t=this.nextPageRequestOptions();if(!t)throw new v("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await p(this,kn,"f").requestAPIList(this.constructor,t)}async*iterPages(){let t=this;for(yield t;t.hasNextPage();)t=await t.getNextPage(),yield t}async*[(kn=new WeakMap,Symbol.asyncIterator)](){for await(const t of this.iterPages())for(const n of t.getPaginatedItems())yield n}};o(Yu,"AbstractPage");let St=Yu;const Qu=class Qu extends Rn{constructor(t,n,s){super(t,n,async(r,i)=>new s(r,i.response,await bc(r,i),i.options))}async*[Symbol.asyncIterator](){const t=await this;for await(const n of t)yield n}};o(Qu,"PagePromise");let Jr=Qu;const Zu=class Zu extends St{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.object=s.object}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){return null}};o(Zu,"Page");let ze=Zu;const ei=class ei extends St{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.has_more=s.has_more||!1}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const t=this.getPaginatedItems(),n=t[t.length-1]?.id;return n?{...this.options,query:{...sc(this.options.query),after:n}}:null}};o(ei,"CursorPage");let M=ei;const ti=class ti extends St{constructor(t,n,s,r){super(t,n,s,r),this.data=s.data||[],this.has_more=s.has_more||!1,this.last_id=s.last_id||""}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){const t=this.last_id;return t?{...this.options,query:{...sc(this.options.query),after:t}}:null}};o(ti,"ConversationCursorPage");let Ve=ti;const Bc=o(()=>{if(typeof File>"u"){const{process:e}=globalThis,t=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},"checkFileSupport");function It(e,t,n){return Bc(),new File(e,t??"unknown_file",n)}o(It,"makeFile");function Pn(e){return(typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}o(Pn,"getName");const Xr=o(e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function","isAsyncIterable"),Ac=o(async(e,t)=>Yr(e.body)?{...e,body:await $c(e.body,t)}:e,"maybeMultipartFormRequestOptions"),Se=o(async(e,t)=>({...e,body:await $c(e.body,t)}),"multipartFormRequestOptions"),vc=new WeakMap;function tp(e){const t=typeof e=="function"?e:e.fetch,n=vc.get(t);if(n)return n;const s=(async()=>{try{const r="Response"in t?t.Response:(await t("data:,")).constructor,i=new FormData;return i.toString()!==await new r(i).text()}catch{return!0}})();return vc.set(t,s),s}o(tp,"supportsFormData");const $c=o(async(e,t)=>{if(!await tp(t))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(e||{}).map(([s,r])=>Qr(n,s,r))),n},"createForm"),xc=o(e=>e instanceof Blob&&"name"in e,"isNamedBlob"),np=o(e=>typeof e=="object"&&e!==null&&(e instanceof Response||Xr(e)||xc(e)),"isUploadable"),Yr=o(e=>{if(np(e))return!0;if(Array.isArray(e))return e.some(Yr);if(e&&typeof e=="object"){for(const t in e)if(Yr(e[t]))return!0}return!1},"hasUploadableValue"),Qr=o(async(e,t,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")e.append(t,String(n));else if(n instanceof Response)e.append(t,It([await n.blob()],Pn(n)));else if(Xr(n))e.append(t,It([await new Response(ac(n)).blob()],Pn(n)));else if(xc(n))e.append(t,n,Pn(n));else if(Array.isArray(n))await Promise.all(n.map(s=>Qr(e,t+"[]",s)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([s,r])=>Qr(e,`${t}[${s}]`,r)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},"addFormValue"),Sc=o(e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function","isBlobLike"),sp=o(e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&Sc(e),"isFileLike"),rp=o(e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function","isResponseLike");async function up(e,t,n){if(Bc(),e=await e,sp(e))return e instanceof File?e:It([await e.arrayBuffer()],e.name);if(rp(e)){const r=await e.blob();return t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()),It(await Zr(r),t,n)}const s=await Zr(e);if(t||(t=Pn(e)),!n?.type){const r=s.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof r=="string"&&(n={...n,type:r})}return It(s,t,n)}o(up,"toFile");async function Zr(e){let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(Sc(e))t.push(e instanceof Blob?e:await e.arrayBuffer());else if(Xr(e))for await(const n of e)t.push(...await Zr(n));else{const n=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${n?`; constructor: ${n}`:""}${ip(e)}`)}return t}o(Zr,"getBytes");function ip(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}o(ip,"propsForError");const ni=class ni{constructor(t){this._client=t}};o(ni,"APIResource");let A=ni;function Ic(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}o(Ic,"encodeURIPath");const Oc=Object.freeze(Object.create(null)),op=o((e=Ic)=>o(function(n,...s){if(n.length===1)return n[0];let r=!1;const i=[],u=n.reduce((d,D,f)=>{/[?#]/.test(D)&&(r=!0);const h=s[f];let F=(r?encodeURIComponent:e)(""+h);return f!==s.length&&(h==null||typeof h=="object"&&h.toString===Object.getPrototypeOf(Object.getPrototypeOf(h.hasOwnProperty??Oc)??Oc)?.toString)&&(F=h+"",i.push({start:d.length+D.length,length:F.length,error:`Value of type ${Object.prototype.toString.call(h).slice(8,-1)} is not a valid path parameter`})),d+D+(f===s.length?"":F)},""),a=u.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;let l;for(;(l=c.exec(a))!==null;)i.push({start:l.index,length:l[0].length,error:`Value "${l[0]}" can't be safely passed as a path parameter`});if(i.sort((d,D)=>d.start-D.start),i.length>0){let d=0;const D=i.reduce((f,h)=>{const F=" ".repeat(h.start-d),m="^".repeat(h.length);return d=h.start+h.length,f+F+m},"");throw new v(`Path parameters result in path with invalid segments:
90
90
  ${i.map(f=>f.error).join(`
91
91
  `)}
92
92
  ${u}
93
- ${d}`)}return u},"path2"),"createPathTagFunction"),C=ap(Rc);let Pc=(at=class extends A{list(t,n={},s){return this._client.getAPIList(C`/chat/completions/${t}/messages`,M,{query:n,...s})}},o(at,"Messages"),at);function Mn(e){return e!==void 0&&"function"in e&&e.function!==void 0}o(Mn,"isChatCompletionFunctionTool");function eu(e){return e?.$brand==="auto-parseable-response-format"}o(eu,"isAutoParsableResponseFormat");function kt(e){return e?.$brand==="auto-parseable-tool"}o(kt,"isAutoParsableTool$1");function cp(e,t){return!t||!Tc(t)?{...e,choices:e.choices.map(n=>(Nc(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:tu(e,t)}o(cp,"maybeParseChatCompletion");function tu(e,t){const n=e.choices.map(s=>{if(s.finish_reason==="length")throw new In;if(s.finish_reason==="content_filter")throw new On;return Nc(s.message.tool_calls),{...s,message:{...s.message,...s.message.tool_calls?{tool_calls:s.message.tool_calls?.map(r=>Dp(t,r))??void 0}:void 0,parsed:s.message.content&&!s.message.refusal?lp(t,s.message.content):null}}});return{...e,choices:n}}o(tu,"parseChatCompletion");function lp(e,t){return e.response_format?.type!=="json_schema"?null:e.response_format?.type==="json_schema"?"$parseRaw"in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}o(lp,"parseResponseFormat");function Dp(e,t){const n=e.tools?.find(s=>Mn(s)&&s.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:kt(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}o(Dp,"parseToolCall$1");function dp(e,t){if(!e||!("tools"in e)||!e.tools)return!1;const n=e.tools?.find(s=>Mn(s)&&s.function?.name===t.function.name);return Mn(n)&&(kt(n)||n?.function.strict||!1)}o(dp,"shouldParseToolCall");function Tc(e){return eu(e.response_format)?!0:e.tools?.some(t=>kt(t)||t.type==="function"&&t.function.strict===!0)??!1}o(Tc,"hasAutoParseableInput$1");function Nc(e){for(const t of e||[])if(t.type!=="function")throw new v(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}o(Nc,"assertToolCallsAreChatCompletionFunctionToolCalls");function hp(e){for(const t of e??[]){if(t.type!=="function")throw new v(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new v(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}o(hp,"validateInputTools");const Ln=o(e=>e?.role==="assistant","isAssistantMessage"),Mc=o(e=>e?.role==="tool","isToolMessage");var nu,jn,Un,Pt,Tt,Wn,Nt,pe,Mt,qn,Gn,Xe,Lc;const ri=class ri{constructor(){nu.add(this),this.controller=new AbortController,jn.set(this,void 0),Un.set(this,()=>{}),Pt.set(this,()=>{}),Tt.set(this,void 0),Wn.set(this,()=>{}),Nt.set(this,()=>{}),pe.set(this,{}),Mt.set(this,!1),qn.set(this,!1),Gn.set(this,!1),Xe.set(this,!1),$(this,jn,new Promise((t,n)=>{$(this,Un,t,"f"),$(this,Pt,n,"f")})),$(this,Tt,new Promise((t,n)=>{$(this,Wn,t,"f"),$(this,Nt,n,"f")})),p(this,jn,"f").catch(()=>{}),p(this,Tt,"f").catch(()=>{})}_run(t){setTimeout(()=>{t().then(()=>{this._emitFinal(),this._emit("end")},p(this,nu,"m",Lc).bind(this))},0)}_connected(){this.ended||(p(this,Un,"f").call(this),this._emit("connect"))}get ended(){return p(this,Mt,"f")}get errored(){return p(this,qn,"f")}get aborted(){return p(this,Gn,"f")}abort(){this.controller.abort()}on(t,n){return(p(this,pe,"f")[t]||(p(this,pe,"f")[t]=[])).push({listener:n}),this}off(t,n){const s=p(this,pe,"f")[t];if(!s)return this;const r=s.findIndex(i=>i.listener===n);return r>=0&&s.splice(r,1),this}once(t,n){return(p(this,pe,"f")[t]||(p(this,pe,"f")[t]=[])).push({listener:n,once:!0}),this}emitted(t){return new Promise((n,s)=>{$(this,Xe,!0),t!=="error"&&this.once("error",s),this.once(t,n)})}async done(){$(this,Xe,!0),await p(this,Tt,"f")}_emit(t,...n){if(p(this,Mt,"f"))return;t==="end"&&($(this,Mt,!0),p(this,Wn,"f").call(this));const s=p(this,pe,"f")[t];if(s&&(p(this,pe,"f")[t]=s.filter(r=>!r.once),s.forEach(({listener:r})=>r(...n))),t==="abort"){const r=n[0];!p(this,Xe,"f")&&!s?.length&&Promise.reject(r),p(this,Pt,"f").call(this,r),p(this,Nt,"f").call(this,r),this._emit("end");return}if(t==="error"){const r=n[0];!p(this,Xe,"f")&&!s?.length&&Promise.reject(r),p(this,Pt,"f").call(this,r),p(this,Nt,"f").call(this,r),this._emit("end")}}_emitFinal(){}};o(ri,"EventStream");let Lt=ri;jn=new WeakMap,Un=new WeakMap,Pt=new WeakMap,Tt=new WeakMap,Wn=new WeakMap,Nt=new WeakMap,pe=new WeakMap,Mt=new WeakMap,qn=new WeakMap,Gn=new WeakMap,Xe=new WeakMap,nu=new WeakSet,Lc=o(function(t){if($(this,qn,!0),t instanceof Error&&t.name==="AbortError"&&(t=new ne),t instanceof ne)return $(this,Gn,!0),this._emit("abort",t);if(t instanceof v)return this._emit("error",t);if(t instanceof Error){const n=new v(t.message);return n.cause=t,this._emit("error",n)}return this._emit("error",new v(String(t)))},"_EventStream_handleError2");function fp(e){return typeof e.parse=="function"}o(fp,"isRunnableFunctionWithParse");var te,su,Kn,ru,uu,iu,jc,Uc;const pp=10,ui=class ui extends Lt{constructor(){super(...arguments),te.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(t){this._chatCompletions.push(t),this._emit("chatCompletion",t);const n=t.choices[0]?.message;return n&&this._addMessage(n),t}_addMessage(t,n=!0){if("content"in t||(t.content=null),this.messages.push(t),n){if(this._emit("message",t),Mc(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(Ln(t)&&t.tool_calls)for(const s of t.tool_calls)s.type==="function"&&this._emit("functionToolCall",s.function)}}async finalChatCompletion(){await this.done();const t=this._chatCompletions[this._chatCompletions.length-1];if(!t)throw new v("stream ended without producing a ChatCompletion");return t}async finalContent(){return await this.done(),p(this,te,"m",su).call(this)}async finalMessage(){return await this.done(),p(this,te,"m",Kn).call(this)}async finalFunctionToolCall(){return await this.done(),p(this,te,"m",ru).call(this)}async finalFunctionToolCallResult(){return await this.done(),p(this,te,"m",uu).call(this)}async totalUsage(){return await this.done(),p(this,te,"m",iu).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const t=this._chatCompletions[this._chatCompletions.length-1];t&&this._emit("finalChatCompletion",t);const n=p(this,te,"m",Kn).call(this);n&&this._emit("finalMessage",n);const s=p(this,te,"m",su).call(this);s&&this._emit("finalContent",s);const r=p(this,te,"m",ru).call(this);r&&this._emit("finalFunctionToolCall",r);const i=p(this,te,"m",uu).call(this);i!=null&&this._emit("finalFunctionToolCallResult",i),this._chatCompletions.some(u=>u.usage)&&this._emit("totalUsage",p(this,te,"m",iu).call(this))}async _createChatCompletion(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,te,"m",jc).call(this,n);const i=await t.chat.completions.create({...n,stream:!1},{...s,signal:this.controller.signal});return this._connected(),this._addChatCompletion(tu(i,n))}async _runChatCompletion(t,n,s){for(const r of n.messages)this._addMessage(r,!1);return await this._createChatCompletion(t,n,s)}async _runTools(t,n,s){const r="tool",{tool_choice:i="auto",stream:u,...a}=n,c=typeof i!="string"&&i.type==="function"&&i?.function?.name,{maxChatCompletions:l=pp}=s||{},D=n.tools.map(h=>{if(kt(h)){if(!h.$callback)throw new v("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:h.$callback,name:h.function.name,description:h.function.description||"",parameters:h.function.parameters,parse:h.$parseRaw,strict:!0}}}return h}),d={};for(const h of D)h.type==="function"&&(d[h.function.name||h.function.function.name]=h.function);const f="tools"in n?D.map(h=>h.type==="function"?{type:"function",function:{name:h.function.name||h.function.function.name,parameters:h.function.parameters,description:h.function.description,strict:h.function.strict}}:h):void 0;for(const h of n.messages)this._addMessage(h,!1);for(let h=0;h<l;++h){const m=(await this._createChatCompletion(t,{...a,tool_choice:i,tools:f,messages:[...this.messages]},s)).choices[0]?.message;if(!m)throw new v("missing message in ChatCompletion response");if(!m.tool_calls?.length)return;for(const E of m.tool_calls){if(E.type!=="function")continue;const y=E.id,{name:g,arguments:b}=E.function,B=d[g];if(B){if(c&&c!==g){const L=`Invalid tool_call: ${JSON.stringify(g)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:r,tool_call_id:y,content:L});continue}}else{const L=`Invalid tool_call: ${JSON.stringify(g)}. Available options are: ${Object.keys(d).map(z=>JSON.stringify(z)).join(", ")}. Please try again`;this._addMessage({role:r,tool_call_id:y,content:L});continue}let I;try{I=fp(B)?await B.parse(b):b}catch(L){const z=L instanceof Error?L.message:String(L);this._addMessage({role:r,tool_call_id:y,content:z});continue}const O=await B.function(I,this),R=p(this,te,"m",Uc).call(this,O);if(this._addMessage({role:r,tool_call_id:y,content:R}),c)return}}}};o(ui,"AbstractChatCompletionRunner");let Hn=ui;te=new WeakSet,su=o(function(){return p(this,te,"m",Kn).call(this).content??null},"_AbstractChatCompletionRunner_getFinalContent2"),Kn=o(function(){let t=this.messages.length;for(;t-- >0;){const n=this.messages[t];if(Ln(n))return{...n,content:n.content??null,refusal:n.refusal??null}}throw new v("stream ended without producing a ChatCompletionMessage with role=assistant")},"_AbstractChatCompletionRunner_getFinalMessage2"),ru=o(function(){for(let t=this.messages.length-1;t>=0;t--){const n=this.messages[t];if(Ln(n)&&n?.tool_calls?.length)return n.tool_calls.filter(s=>s.type==="function").at(-1)?.function}},"_AbstractChatCompletionRunner_getFinalFunctionToolCall2"),uu=o(function(){for(let t=this.messages.length-1;t>=0;t--){const n=this.messages[t];if(Mc(n)&&n.content!=null&&typeof n.content=="string"&&this.messages.some(s=>s.role==="assistant"&&s.tool_calls?.some(r=>r.type==="function"&&r.id===n.tool_call_id)))return n.content}},"_AbstractChatCompletionRunner_getFinalFunctionToolCallResult2"),iu=o(function(){const t={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:n}of this._chatCompletions)n&&(t.completion_tokens+=n.completion_tokens,t.prompt_tokens+=n.prompt_tokens,t.total_tokens+=n.total_tokens);return t},"_AbstractChatCompletionRunner_calculateTotalUsage2"),jc=o(function(t){if(t.n!=null&&t.n>1)throw new v("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},"_AbstractChatCompletionRunner_validateParams2"),Uc=o(function(t){return typeof t=="string"?t:t===void 0?"undefined":JSON.stringify(t)},"_AbstractChatCompletionRunner_stringifyFunctionCallResult2");const Ms=class Ms extends Hn{static runTools(t,n,s){const r=new Ms,i={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(t,n,i)),r}_addMessage(t,n=!0){super._addMessage(t,n),Ln(t)&&t.content&&this._emit("content",t.content)}};o(Ms,"ChatCompletionRunner");let ou=Ms;const Wc=1,qc=2,Gc=4,Kc=8,Hc=16,zc=32,Vc=64,Jc=128,Xc=256,Yc=Jc|Xc,Qc=Hc|zc|Yc|Vc,Zc=Wc|qc|Qc,el=Gc|Kc,mp=Zc|el,J={STR:Wc,NUM:qc,ARR:Gc,OBJ:Kc,NULL:Hc,BOOL:zc,NAN:Vc,INFINITY:Jc,MINUS_INFINITY:Xc,INF:Yc,SPECIAL:Qc,ATOM:Zc,COLLECTION:el,ALL:mp},ii=class ii extends Error{};o(ii,"PartialJSON");let au=ii;const oi=class oi extends Error{};o(oi,"MalformedJSON");let cu=oi;function Fp(e,t=J.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return gp(e.trim(),t)}o(Fp,"parseJSON");const gp=o((e,t)=>{const n=e.length;let s=0;const r=o(f=>{throw new au(`${f} at position ${s}`)},"markPartialJSON"),i=o(f=>{throw new cu(`${f} at position ${s}`)},"throwMalformedError"),u=o(()=>(d(),s>=n&&r("Unexpected end of input"),e[s]==='"'?a():e[s]==="{"?c():e[s]==="["?l():e.substring(s,s+4)==="null"||J.NULL&t&&n-s<4&&"null".startsWith(e.substring(s))?(s+=4,null):e.substring(s,s+4)==="true"||J.BOOL&t&&n-s<4&&"true".startsWith(e.substring(s))?(s+=4,!0):e.substring(s,s+5)==="false"||J.BOOL&t&&n-s<5&&"false".startsWith(e.substring(s))?(s+=5,!1):e.substring(s,s+8)==="Infinity"||J.INFINITY&t&&n-s<8&&"Infinity".startsWith(e.substring(s))?(s+=8,1/0):e.substring(s,s+9)==="-Infinity"||J.MINUS_INFINITY&t&&1<n-s&&n-s<9&&"-Infinity".startsWith(e.substring(s))?(s+=9,-1/0):e.substring(s,s+3)==="NaN"||J.NAN&t&&n-s<3&&"NaN".startsWith(e.substring(s))?(s+=3,NaN):D()),"parseAny"),a=o(()=>{const f=s;let h=!1;for(s++;s<n&&(e[s]!=='"'||h&&e[s-1]==="\\");)h=e[s]==="\\"?!h:!1,s++;if(e.charAt(s)=='"')try{return JSON.parse(e.substring(f,++s-Number(h)))}catch(F){i(String(F))}else if(J.STR&t)try{return JSON.parse(e.substring(f,s-Number(h))+'"')}catch{return JSON.parse(e.substring(f,e.lastIndexOf("\\"))+'"')}r("Unterminated string literal")},"parseStr"),c=o(()=>{s++,d();const f={};try{for(;e[s]!=="}";){if(d(),s>=n&&J.OBJ&t)return f;const h=a();d(),s++;try{const F=u();Object.defineProperty(f,h,{value:F,writable:!0,enumerable:!0,configurable:!0})}catch(F){if(J.OBJ&t)return f;throw F}d(),e[s]===","&&s++}}catch{if(J.OBJ&t)return f;r("Expected '}' at end of object")}return s++,f},"parseObj"),l=o(()=>{s++;const f=[];try{for(;e[s]!=="]";)f.push(u()),d(),e[s]===","&&s++}catch{if(J.ARR&t)return f;r("Expected ']' at end of array")}return s++,f},"parseArr"),D=o(()=>{if(s===0){e==="-"&&J.NUM&t&&r("Not sure what '-' is");try{return JSON.parse(e)}catch(h){if(J.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}i(String(h))}}const f=s;for(e[s]==="-"&&s++;e[s]&&!",]}".includes(e[s]);)s++;s==n&&!(J.NUM&t)&&r("Unterminated number literal");try{return JSON.parse(e.substring(f,s))}catch{e.substring(f,s)==="-"&&J.NUM&t&&r("Not sure what '-' is");try{return JSON.parse(e.substring(f,e.lastIndexOf("e")))}catch(F){i(String(F))}}},"parseNum"),d=o(()=>{for(;s<n&&`
94
- \r `.includes(e[s]);)s++},"skipBlank");return u()},"_parseJSON"),tl=o(e=>Fp(e,J.ALL^J.NUM),"partialParse");var H,me,Ye,Ce,lu,zn,Du,du,hu,Vn,fu,nl;const en=class en extends Hn{constructor(t){super(),H.add(this),me.set(this,void 0),Ye.set(this,void 0),Ce.set(this,void 0),$(this,me,t),$(this,Ye,[])}get currentChatCompletionSnapshot(){return p(this,Ce,"f")}static fromReadableStream(t){const n=new en(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,s){const r=new en(n);return r._run(()=>r._runChatCompletion(t,{...n,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createChatCompletion(t,n,s){super._createChatCompletion;const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,H,"m",lu).call(this);const i=await t.chat.completions.create({...n,stream:!0},{...s,signal:this.controller.signal});this._connected();for await(const u of i)p(this,H,"m",Du).call(this,u);if(i.controller.signal?.aborted)throw new ne;return this._addChatCompletion(p(this,H,"m",Vn).call(this))}async _fromReadableStream(t,n){const s=n?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),p(this,H,"m",lu).call(this),this._connected();const r=xe.fromReadableStream(t,this.controller);let i;for await(const u of r)i&&i!==u.id&&this._addChatCompletion(p(this,H,"m",Vn).call(this)),p(this,H,"m",Du).call(this,u),i=u.id;if(r.controller.signal?.aborted)throw new ne;return this._addChatCompletion(p(this,H,"m",Vn).call(this))}[(me=new WeakMap,Ye=new WeakMap,Ce=new WeakMap,H=new WeakSet,lu=o(function(){this.ended||$(this,Ce,void 0)},"_ChatCompletionStream_beginRequest2"),zn=o(function(n){let s=p(this,Ye,"f")[n.index];return s||(s={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},p(this,Ye,"f")[n.index]=s,s)},"_ChatCompletionStream_getChoiceEventState2"),Du=o(function(n){if(this.ended)return;const s=p(this,H,"m",nl).call(this,n);this._emit("chunk",n,s);for(const r of n.choices){const i=s.choices[r.index];r.delta.content!=null&&i.message?.role==="assistant"&&i.message?.content&&(this._emit("content",r.delta.content,i.message.content),this._emit("content.delta",{delta:r.delta.content,snapshot:i.message.content,parsed:i.message.parsed})),r.delta.refusal!=null&&i.message?.role==="assistant"&&i.message?.refusal&&this._emit("refusal.delta",{delta:r.delta.refusal,snapshot:i.message.refusal}),r.logprobs?.content!=null&&i.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:r.logprobs?.content,snapshot:i.logprobs?.content??[]}),r.logprobs?.refusal!=null&&i.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:r.logprobs?.refusal,snapshot:i.logprobs?.refusal??[]});const u=p(this,H,"m",zn).call(this,i);i.finish_reason&&(p(this,H,"m",hu).call(this,i),u.current_tool_call_index!=null&&p(this,H,"m",du).call(this,i,u.current_tool_call_index));for(const a of r.delta.tool_calls??[])u.current_tool_call_index!==a.index&&(p(this,H,"m",hu).call(this,i),u.current_tool_call_index!=null&&p(this,H,"m",du).call(this,i,u.current_tool_call_index)),u.current_tool_call_index=a.index;for(const a of r.delta.tool_calls??[]){const c=i.message.tool_calls?.[a.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:a.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):(c?.type,void 0))}}},"_ChatCompletionStream_addChunk2"),du=o(function(n,s){if(p(this,H,"m",zn).call(this,n).done_tool_calls.has(s))return;const i=n.message.tool_calls?.[s];if(!i)throw new Error("no tool call snapshot");if(!i.type)throw new Error("tool call snapshot missing `type`");if(i.type==="function"){const u=p(this,me,"f")?.tools?.find(a=>Mn(a)&&a.function.name===i.function.name);this._emit("tool_calls.function.arguments.done",{name:i.function.name,index:s,arguments:i.function.arguments,parsed_arguments:kt(u)?u.$parseRaw(i.function.arguments):u?.function.strict?JSON.parse(i.function.arguments):null})}else i.type},"_ChatCompletionStream_emitToolCallDoneEvent2"),hu=o(function(n){const s=p(this,H,"m",zn).call(this,n);if(n.message.content&&!s.content_done){s.content_done=!0;const r=p(this,H,"m",fu).call(this);this._emit("content.done",{content:n.message.content,parsed:r?r.$parseRaw(n.message.content):null})}n.message.refusal&&!s.refusal_done&&(s.refusal_done=!0,this._emit("refusal.done",{refusal:n.message.refusal})),n.logprobs?.content&&!s.logprobs_content_done&&(s.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:n.logprobs.content})),n.logprobs?.refusal&&!s.logprobs_refusal_done&&(s.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:n.logprobs.refusal}))},"_ChatCompletionStream_emitContentDoneEvents2"),Vn=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");const n=p(this,Ce,"f");if(!n)throw new v("request ended without sending any chunks");return $(this,Ce,void 0),$(this,Ye,[]),Cp(n,p(this,me,"f"))},"_ChatCompletionStream_endRequest2"),fu=o(function(){const n=p(this,me,"f")?.response_format;return eu(n)?n:null},"_ChatCompletionStream_getAutoParseableResponseFormat2"),nl=o(function(n){var s,r,i,u;let a=p(this,Ce,"f");const{choices:c,...l}=n;a?Object.assign(a,l):a=$(this,Ce,{...l,choices:[]});for(const{delta:D,finish_reason:d,index:f,logprobs:h=null,...F}of n.choices){let m=a.choices[f];if(m||(m=a.choices[f]={finish_reason:d,index:f,message:{},logprobs:h,...F}),h)if(!m.logprobs)m.logprobs=Object.assign({},h);else{const{content:O,refusal:R,...L}=h;Object.assign(m.logprobs,L),O&&((s=m.logprobs).content??(s.content=[]),m.logprobs.content.push(...O)),R&&((r=m.logprobs).refusal??(r.refusal=[]),m.logprobs.refusal.push(...R))}if(d&&(m.finish_reason=d,p(this,me,"f")&&Tc(p(this,me,"f")))){if(d==="length")throw new In;if(d==="content_filter")throw new On}if(Object.assign(m,F),!D)continue;const{content:E,refusal:y,function_call:g,role:b,tool_calls:B,...I}=D;if(Object.assign(m.message,I),y&&(m.message.refusal=(m.message.refusal||"")+y),b&&(m.message.role=b),g&&(m.message.function_call?(g.name&&(m.message.function_call.name=g.name),g.arguments&&((i=m.message.function_call).arguments??(i.arguments=""),m.message.function_call.arguments+=g.arguments)):m.message.function_call=g),E&&(m.message.content=(m.message.content||"")+E,!m.message.refusal&&p(this,H,"m",fu).call(this)&&(m.message.parsed=tl(m.message.content))),B){m.message.tool_calls||(m.message.tool_calls=[]);for(const{index:O,id:R,type:L,function:z,...U}of B){const W=(u=m.message.tool_calls)[O]??(u[O]={});Object.assign(W,U),R&&(W.id=R),L&&(W.type=L),z&&(W.function??(W.function={name:z.name??"",arguments:""})),z?.name&&(W.function.name=z.name),z?.arguments&&(W.function.arguments+=z.arguments,dp(p(this,me,"f"),W)&&(W.function.parsed_arguments=tl(W.function.arguments)))}}}return a},"_ChatCompletionStream_accumulateChatCompletion2"),Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("chunk",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};o(en,"ChatCompletionStream");let Jn=en;function Cp(e,t){const{id:n,choices:s,created:r,model:i,system_fingerprint:u,...a}=e,c={...a,id:n,choices:s.map(({message:l,finish_reason:D,index:d,logprobs:f,...h})=>{if(!D)throw new v(`missing finish_reason for choice ${d}`);const{content:F=null,function_call:m,tool_calls:E,...y}=l,g=l.role;if(!g)throw new v(`missing role for choice ${d}`);if(m){const{arguments:b,name:B}=m;if(b==null)throw new v(`missing function_call.arguments for choice ${d}`);if(!B)throw new v(`missing function_call.name for choice ${d}`);return{...h,message:{content:F,function_call:{arguments:b,name:B},role:g,refusal:l.refusal??null},finish_reason:D,index:d,logprobs:f}}return E?{...h,index:d,finish_reason:D,logprobs:f,message:{...y,role:g,content:F,refusal:l.refusal??null,tool_calls:E.map((b,B)=>{const{function:I,type:O,id:R,...L}=b,{arguments:z,name:U,...W}=I||{};if(R==null)throw new v(`missing choices[${d}].tool_calls[${B}].id
95
- ${Xn(e)}`);if(O==null)throw new v(`missing choices[${d}].tool_calls[${B}].type
96
- ${Xn(e)}`);if(U==null)throw new v(`missing choices[${d}].tool_calls[${B}].function.name
97
- ${Xn(e)}`);if(z==null)throw new v(`missing choices[${d}].tool_calls[${B}].function.arguments
98
- ${Xn(e)}`);return{...L,id:R,type:O,function:{...W,name:U,arguments:z}}})}}:{...h,message:{...y,content:F,role:g,refusal:l.refusal??null},finish_reason:D,index:d,logprobs:f}}),created:r,model:i,object:"chat.completion",...u?{system_fingerprint:u}:{}};return cp(c,t)}o(Cp,"finalizeChatCompletion");function Xn(e){return JSON.stringify(e)}o(Xn,"str");function km(e){}o(km,"assertNever");const tn=class tn extends Jn{static fromReadableStream(t){const n=new tn(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,s){const r=new tn(n),i={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(t,n,i)),r}};o(tn,"ChatCompletionStreamingRunner");let pu=tn,mu=(ct=class extends A{constructor(){super(...arguments),this.messages=new Pc(this._client)}create(t,n){return this._client.post("/chat/completions",{body:t,...n,stream:t.stream??!1})}retrieve(t,n){return this._client.get(C`/chat/completions/${t}`,n)}update(t,n,s){return this._client.post(C`/chat/completions/${t}`,{body:n,...s})}list(t={},n){return this._client.getAPIList("/chat/completions",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/chat/completions/${t}`,n)}parse(t,n){return hp(t.tools),this._client.chat.completions.create(t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(s=>tu(s,t))}runTools(t,n){return t.stream?pu.runTools(this._client,t,n):ou.runTools(this._client,t,n)}stream(t,n){return Jn.createChatCompletion(this._client,t,n)}},o(ct,"Completions"),ct);mu.Messages=Pc;const ai=class ai extends A{constructor(){super(...arguments),this.completions=new mu(this._client)}};o(ai,"Chat");let jt=ai;jt.Completions=mu;const sl=Symbol("brand.privateNullableHeaders");function*Ep(e){if(!e)return;if(sl in e){const{values:s,nulls:r}=e;yield*s.entries();for(const i of r)yield[i,null];return}let t=!1,n;e instanceof Headers?n=e.entries():rc(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let s of n){const r=s[0];if(typeof r!="string")throw new TypeError("expected header name to be a string");const i=rc(s[1])?s[1]:[s[1]];let u=!1;for(const a of i)a!==void 0&&(t&&!u&&(u=!0,yield[r,null]),yield[r,a])}}o(Ep,"iterateHeaders");const _=o(e=>{const t=new Headers,n=new Set;for(const s of e){const r=new Set;for(const[i,u]of Ep(s)){const a=i.toLowerCase();r.has(a)||(t.delete(i),r.add(a)),u===null?(t.delete(i),n.add(a)):(t.append(i,u),n.delete(a))}}return{[sl]:!0,values:t,nulls:n}},"buildHeaders"),ci=class ci extends A{create(t,n){return this._client.post("/audio/speech",{body:t,...n,headers:_([{Accept:"application/octet-stream"},n?.headers]),__binaryResponse:!0})}};o(ci,"Speech");let Yn=ci;const li=class li extends A{create(t,n){return this._client.post("/audio/transcriptions",Se({body:t,...n,stream:t.stream??!1,__metadata:{model:t.model}},this._client))}};o(li,"Transcriptions");let Qn=li;const Di=class Di extends A{create(t,n){return this._client.post("/audio/translations",Se({body:t,...n,__metadata:{model:t.model}},this._client))}};o(Di,"Translations");let Zn=Di;const di=class di extends A{constructor(){super(...arguments),this.transcriptions=new Qn(this._client),this.translations=new Zn(this._client),this.speech=new Yn(this._client)}};o(di,"Audio");let Ie=di;Ie.Transcriptions=Qn,Ie.Translations=Zn,Ie.Speech=Yn;const hi=class hi extends A{create(t,n){return this._client.post("/batches",{body:t,...n})}retrieve(t,n){return this._client.get(C`/batches/${t}`,n)}list(t={},n){return this._client.getAPIList("/batches",M,{query:t,...n})}cancel(t,n){return this._client.post(C`/batches/${t}/cancel`,n)}};o(hi,"Batches");let es=hi;const fi=class fi extends A{create(t,n){return this._client.post("/assistants",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/assistants/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/assistants/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t={},n){return this._client.getAPIList("/assistants",M,{query:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,n){return this._client.delete(C`/assistants/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};o(fi,"Assistants");let ts=fi,rl=(lt=class extends A{create(t,n){return this._client.post("/realtime/sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}},o(lt,"Sessions"),lt);const pi=class pi extends A{create(t,n){return this._client.post("/realtime/transcription_sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};o(pi,"TranscriptionSessions");let ns=pi,ss=(Dt=class extends A{constructor(){super(...arguments),this.sessions=new rl(this._client),this.transcriptionSessions=new ns(this._client)}},o(Dt,"Realtime"),Dt);ss.Sessions=rl,ss.TranscriptionSessions=ns;const mi=class mi extends A{create(t,n){return this._client.post("/chatkit/sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}cancel(t,n){return this._client.post(C`/chatkit/sessions/${t}/cancel`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}};o(mi,"Sessions");let rs=mi,ul=(dt=class extends A{retrieve(t,n){return this._client.get(C`/chatkit/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}list(t={},n){return this._client.getAPIList("/chatkit/threads",Je,{query:t,...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}delete(t,n){return this._client.delete(C`/chatkit/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}listItems(t,n={},s){return this._client.getAPIList(C`/chatkit/threads/${t}/items`,Je,{query:n,...s,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}},o(dt,"Threads"),dt);const Fi=class Fi extends A{constructor(){super(...arguments),this.sessions=new rs(this._client),this.threads=new ul(this._client)}};o(Fi,"ChatKit");let Qe=Fi;Qe.Sessions=rs,Qe.Threads=ul;const gi=class gi extends A{create(t,n,s){return this._client.post(C`/threads/${t}/messages`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{thread_id:r}=n;return this._client.get(C`/threads/${r}/messages/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/messages/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/threads/${t}/messages`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n,s){const{thread_id:r}=n;return this._client.delete(C`/threads/${r}/messages/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(gi,"Messages");let us=gi;const Ci=class Ci extends A{retrieve(t,n,s){const{thread_id:r,run_id:i,...u}=n;return this._client.get(C`/threads/${r}/runs/${i}/steps/${t}`,{query:u,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n,s){const{thread_id:r,...i}=n;return this._client.getAPIList(C`/threads/${r}/runs/${t}/steps`,M,{query:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Ci,"Steps");let is=Ci;const yp=o(e=>{if(typeof Buffer<"u"){const t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{const t=atob(e),n=t.length,s=new Uint8Array(n);for(let r=0;r<n;r++)s[r]=t.charCodeAt(r);return Array.from(new Float32Array(s.buffer))}},"toFloat32Array"),Ze=o(e=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()},"readEnv");var Y,Oe,Fu,fe,os,ce,Re,et,ke,as,oe,cs,ls,Ut,Wt,qt,il,ol,al,cl,ll,Dl,dl;const Ei=class Ei extends Lt{constructor(){super(...arguments),Y.add(this),Fu.set(this,[]),fe.set(this,{}),os.set(this,{}),ce.set(this,void 0),Re.set(this,void 0),et.set(this,void 0),ke.set(this,void 0),as.set(this,void 0),oe.set(this,void 0),cs.set(this,void 0),ls.set(this,void 0),Ut.set(this,void 0)}[(Fu=new WeakMap,fe=new WeakMap,os=new WeakMap,ce=new WeakMap,Re=new WeakMap,et=new WeakMap,ke=new WeakMap,as=new WeakMap,oe=new WeakMap,cs=new WeakMap,ls=new WeakMap,Ut=new WeakMap,Y=new WeakSet,Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("event",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}static fromReadableStream(t){const n=new Oe;return n._run(()=>n._fromReadableStream(t)),n}async _fromReadableStream(t,n){const s=n?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),this._connected();const r=xe.fromReadableStream(t,this.controller);for await(const i of r)p(this,Y,"m",Wt).call(this,i);if(r.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",qt).call(this))}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(t,n,s,r){const i=new Oe;return i._run(()=>i._runToolAssistantStream(t,n,s,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createToolAssistantStream(t,n,s,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const u={...s,stream:!0},a=await t.submitToolOutputs(n,u,{...r,signal:this.controller.signal});this._connected();for await(const c of a)p(this,Y,"m",Wt).call(this,c);if(a.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",qt).call(this))}static createThreadAssistantStream(t,n,s){const r=new Oe;return r._run(()=>r._threadAssistantStream(t,n,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}static createAssistantStream(t,n,s,r){const i=new Oe;return i._run(()=>i._runAssistantStream(t,n,s,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}currentEvent(){return p(this,cs,"f")}currentRun(){return p(this,ls,"f")}currentMessageSnapshot(){return p(this,ce,"f")}currentRunStepSnapshot(){return p(this,Ut,"f")}async finalRunSteps(){return await this.done(),Object.values(p(this,fe,"f"))}async finalMessages(){return await this.done(),Object.values(p(this,os,"f"))}async finalRun(){if(await this.done(),!p(this,Re,"f"))throw Error("Final run was not received.");return p(this,Re,"f")}async _createThreadAssistantStream(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},u=await t.createAndRun(i,{...s,signal:this.controller.signal});this._connected();for await(const a of u)p(this,Y,"m",Wt).call(this,a);if(u.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",qt).call(this))}async _createAssistantStream(t,n,s,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const u={...s,stream:!0},a=await t.create(n,u,{...r,signal:this.controller.signal});this._connected();for await(const c of a)p(this,Y,"m",Wt).call(this,c);if(a.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",qt).call(this))}static accumulateDelta(t,n){for(const[s,r]of Object.entries(n)){if(!t.hasOwnProperty(s)){t[s]=r;continue}let i=t[s];if(i==null){t[s]=r;continue}if(s==="index"||s==="type"){t[s]=r;continue}if(typeof i=="string"&&typeof r=="string")i+=r;else if(typeof i=="number"&&typeof r=="number")i+=r;else if(qr(i)&&qr(r))i=this.accumulateDelta(i,r);else if(Array.isArray(i)&&Array.isArray(r)){if(i.every(u=>typeof u=="string"||typeof u=="number")){i.push(...r);continue}for(const u of r){if(!qr(u))throw new Error(`Expected array delta entry to be an object but got: ${u}`);const a=u.index;if(a==null)throw console.error(u),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);const c=i[a];c==null?i.push(u):i[a]=this.accumulateDelta(c,u)}continue}else throw Error(`Unhandled record type: ${s}, deltaValue: ${r}, accValue: ${i}`);t[s]=i}return t}_addRun(t){return t}async _threadAssistantStream(t,n,s){return await this._createThreadAssistantStream(n,t,s)}async _runAssistantStream(t,n,s,r){return await this._createAssistantStream(n,t,s,r)}async _runToolAssistantStream(t,n,s,r){return await this._createToolAssistantStream(n,t,s,r)}};o(Ei,"AssistantStream");let Pe=Ei;Oe=Pe,Wt=o(function(t){if(!this.ended)switch($(this,cs,t),p(this,Y,"m",al).call(this,t),t.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":p(this,Y,"m",dl).call(this,t);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":p(this,Y,"m",ol).call(this,t);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":p(this,Y,"m",il).call(this,t);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},"_AssistantStream_addEvent2"),qt=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");if(!p(this,Re,"f"))throw Error("Final run has not been received");return p(this,Re,"f")},"_AssistantStream_endRequest2"),il=o(function(t){const[n,s]=p(this,Y,"m",ll).call(this,t,p(this,ce,"f"));$(this,ce,n),p(this,os,"f")[n.id]=n;for(const r of s){const i=n.content[r.index];i?.type=="text"&&this._emit("textCreated",i.text)}switch(t.event){case"thread.message.created":this._emit("messageCreated",t.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",t.data.delta,n),t.data.delta.content)for(const r of t.data.delta.content){if(r.type=="text"&&r.text){let i=r.text,u=n.content[r.index];if(u&&u.type=="text")this._emit("textDelta",i,u.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(r.index!=p(this,et,"f")){if(p(this,ke,"f"))switch(p(this,ke,"f").type){case"text":this._emit("textDone",p(this,ke,"f").text,p(this,ce,"f"));break;case"image_file":this._emit("imageFileDone",p(this,ke,"f").image_file,p(this,ce,"f"));break}$(this,et,r.index)}$(this,ke,n.content[r.index])}break;case"thread.message.completed":case"thread.message.incomplete":if(p(this,et,"f")!==void 0){const r=t.data.content[p(this,et,"f")];if(r)switch(r.type){case"image_file":this._emit("imageFileDone",r.image_file,p(this,ce,"f"));break;case"text":this._emit("textDone",r.text,p(this,ce,"f"));break}}p(this,ce,"f")&&this._emit("messageDone",t.data),$(this,ce,void 0)}},"_AssistantStream_handleMessage2"),ol=o(function(t){const n=p(this,Y,"m",cl).call(this,t);switch($(this,Ut,n),t.event){case"thread.run.step.created":this._emit("runStepCreated",t.data);break;case"thread.run.step.delta":const s=t.data.delta;if(s.step_details&&s.step_details.type=="tool_calls"&&s.step_details.tool_calls&&n.step_details.type=="tool_calls")for(const i of s.step_details.tool_calls)i.index==p(this,as,"f")?this._emit("toolCallDelta",i,n.step_details.tool_calls[i.index]):(p(this,oe,"f")&&this._emit("toolCallDone",p(this,oe,"f")),$(this,as,i.index),$(this,oe,n.step_details.tool_calls[i.index]),p(this,oe,"f")&&this._emit("toolCallCreated",p(this,oe,"f")));this._emit("runStepDelta",t.data.delta,n);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":$(this,Ut,void 0),t.data.step_details.type=="tool_calls"&&p(this,oe,"f")&&(this._emit("toolCallDone",p(this,oe,"f")),$(this,oe,void 0)),this._emit("runStepDone",t.data,n);break}},"_AssistantStream_handleRunStep2"),al=o(function(t){p(this,Fu,"f").push(t),this._emit("event",t)},"_AssistantStream_handleEvent2"),cl=o(function(t){switch(t.event){case"thread.run.step.created":return p(this,fe,"f")[t.data.id]=t.data,t.data;case"thread.run.step.delta":let n=p(this,fe,"f")[t.data.id];if(!n)throw Error("Received a RunStepDelta before creation of a snapshot");let s=t.data;if(s.delta){const r=Oe.accumulateDelta(n,s.delta);p(this,fe,"f")[t.data.id]=r}return p(this,fe,"f")[t.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":p(this,fe,"f")[t.data.id]=t.data;break}if(p(this,fe,"f")[t.data.id])return p(this,fe,"f")[t.data.id];throw new Error("No snapshot available")},"_AssistantStream_accumulateRunStep2"),ll=o(function(t,n){let s=[];switch(t.event){case"thread.message.created":return[t.data,s];case"thread.message.delta":if(!n)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let r=t.data;if(r.delta.content)for(const i of r.delta.content)if(i.index in n.content){let u=n.content[i.index];n.content[i.index]=p(this,Y,"m",Dl).call(this,i,u)}else n.content[i.index]=i,s.push(i);return[n,s];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(n)return[n,s];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},"_AssistantStream_accumulateMessage2"),Dl=o(function(t,n){return Oe.accumulateDelta(n,t)},"_AssistantStream_accumulateContent2"),dl=o(function(t){switch($(this,ls,t.data),t.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":$(this,Re,t.data),p(this,oe,"f")&&(this._emit("toolCallDone",p(this,oe,"f")),$(this,oe,void 0));break}},"_AssistantStream_handleRun2");let gu=(ht=class extends A{constructor(){super(...arguments),this.steps=new is(this._client)}create(t,n,s){const{include:r,...i}=n;return this._client.post(C`/threads/${t}/runs`,{query:{include:r},body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:n.stream??!1})}retrieve(t,n,s){const{thread_id:r}=n;return this._client.get(C`/threads/${r}/runs/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/runs/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/threads/${t}/runs`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(t,n,s){const{thread_id:r}=n;return this._client.post(C`/threads/${r}/runs/${t}/cancel`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n,s);return await this.poll(r.id,{thread_id:t},s)}createAndStream(t,n,s){return Pe.createAssistantStream(t,this._client.beta.threads.runs,n,s)}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:i,response:u}=await this.retrieve(t,n,{...s,headers:{...s?.headers,...r}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=u.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await $t(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(t,n,s){return Pe.createAssistantStream(t,this._client.beta.threads.runs,n,s)}submitToolOutputs(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/runs/${t}/submit_tool_outputs`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:n.stream??!1})}async submitToolOutputsAndPoll(t,n,s){const r=await this.submitToolOutputs(t,n,s);return await this.poll(r.id,n,s)}submitToolOutputsStream(t,n,s){return Pe.createToolAssistantStream(t,this._client.beta.threads.runs,n,s)}},o(ht,"Runs"),ht);gu.Steps=is;const yi=class yi extends A{constructor(){super(...arguments),this.runs=new gu(this._client),this.messages=new us(this._client)}create(t={},n){return this._client.post("/threads",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/threads/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n){return this._client.delete(C`/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}createAndRun(t,n){return this._client.post("/threads/runs",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1})}async createAndRunPoll(t,n){const s=await this.createAndRun(t,n);return await this.runs.poll(s.id,{thread_id:s.thread_id},n)}createAndRunStream(t,n){return Pe.createThreadAssistantStream(t,this._client.beta.threads,n)}};o(yi,"Threads");let tt=yi;tt.Runs=gu,tt.Messages=us;const wi=class wi extends A{constructor(){super(...arguments),this.realtime=new ss(this._client),this.chatkit=new Qe(this._client),this.assistants=new ts(this._client),this.threads=new tt(this._client)}};o(wi,"Beta");let Ee=wi;Ee.Realtime=ss,Ee.ChatKit=Qe,Ee.Assistants=ts,Ee.Threads=tt;const bi=class bi extends A{create(t,n){return this._client.post("/completions",{body:t,...n,stream:t.stream??!1})}};o(bi,"Completions");let Ds=bi;const _i=class _i extends A{retrieve(t,n,s){const{container_id:r}=n;return this._client.get(C`/containers/${r}/files/${t}/content`,{...s,headers:_([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}};o(_i,"Content");let ds=_i,Cu=(ft=class extends A{constructor(){super(...arguments),this.content=new ds(this._client)}create(t,n,s){return this._client.post(C`/containers/${t}/files`,Se({body:n,...s},this._client))}retrieve(t,n,s){const{container_id:r}=n;return this._client.get(C`/containers/${r}/files/${t}`,s)}list(t,n={},s){return this._client.getAPIList(C`/containers/${t}/files`,M,{query:n,...s})}delete(t,n,s){const{container_id:r}=n;return this._client.delete(C`/containers/${r}/files/${t}`,{...s,headers:_([{Accept:"*/*"},s?.headers])})}},o(ft,"Files"),ft);Cu.Content=ds;const Bi=class Bi extends A{constructor(){super(...arguments),this.files=new Cu(this._client)}create(t,n){return this._client.post("/containers",{body:t,...n})}retrieve(t,n){return this._client.get(C`/containers/${t}`,n)}list(t={},n){return this._client.getAPIList("/containers",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/containers/${t}`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}};o(Bi,"Containers");let Gt=Bi;Gt.Files=Cu;const Ai=class Ai extends A{create(t,n,s){const{include:r,...i}=n;return this._client.post(C`/conversations/${t}/items`,{query:{include:r},body:i,...s})}retrieve(t,n,s){const{conversation_id:r,...i}=n;return this._client.get(C`/conversations/${r}/items/${t}`,{query:i,...s})}list(t,n={},s){return this._client.getAPIList(C`/conversations/${t}/items`,Je,{query:n,...s})}delete(t,n,s){const{conversation_id:r}=n;return this._client.delete(C`/conversations/${r}/items/${t}`,s)}};o(Ai,"Items");let hs=Ai;const vi=class vi extends A{constructor(){super(...arguments),this.items=new hs(this._client)}create(t={},n){return this._client.post("/conversations",{body:t,...n})}retrieve(t,n){return this._client.get(C`/conversations/${t}`,n)}update(t,n,s){return this._client.post(C`/conversations/${t}`,{body:n,...s})}delete(t,n){return this._client.delete(C`/conversations/${t}`,n)}};o(vi,"Conversations");let Kt=vi;Kt.Items=hs;const $i=class $i extends A{create(t,n){const s=!!t.encoding_format;let r=s?t.encoding_format:"base64";s&&X(this._client).debug("embeddings/user defined encoding_format:",t.encoding_format);const i=this._client.post("/embeddings",{body:{...t,encoding_format:r},...n});return s?i:(X(this._client).debug("embeddings/decoding base64 embeddings from base64"),i._thenUnwrap(u=>(u&&u.data&&u.data.forEach(a=>{const c=a.embedding;a.embedding=yp(c)}),u)))}};o($i,"Embeddings");let fs=$i;const xi=class xi extends A{retrieve(t,n,s){const{eval_id:r,run_id:i}=n;return this._client.get(C`/evals/${r}/runs/${i}/output_items/${t}`,s)}list(t,n,s){const{eval_id:r,...i}=n;return this._client.getAPIList(C`/evals/${r}/runs/${t}/output_items`,M,{query:i,...s})}};o(xi,"OutputItems");let ps=xi;const Si=class Si extends A{constructor(){super(...arguments),this.outputItems=new ps(this._client)}create(t,n,s){return this._client.post(C`/evals/${t}/runs`,{body:n,...s})}retrieve(t,n,s){const{eval_id:r}=n;return this._client.get(C`/evals/${r}/runs/${t}`,s)}list(t,n={},s){return this._client.getAPIList(C`/evals/${t}/runs`,M,{query:n,...s})}delete(t,n,s){const{eval_id:r}=n;return this._client.delete(C`/evals/${r}/runs/${t}`,s)}cancel(t,n,s){const{eval_id:r}=n;return this._client.post(C`/evals/${r}/runs/${t}`,s)}};o(Si,"Runs");let Ht=Si;Ht.OutputItems=ps;const Ii=class Ii extends A{constructor(){super(...arguments),this.runs=new Ht(this._client)}create(t,n){return this._client.post("/evals",{body:t,...n})}retrieve(t,n){return this._client.get(C`/evals/${t}`,n)}update(t,n,s){return this._client.post(C`/evals/${t}`,{body:n,...s})}list(t={},n){return this._client.getAPIList("/evals",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/evals/${t}`,n)}};o(Ii,"Evals");let zt=Ii;zt.Runs=Ht;let hl=(pt=class extends A{create(t,n){return this._client.post("/files",Se({body:t,...n},this._client))}retrieve(t,n){return this._client.get(C`/files/${t}`,n)}list(t={},n){return this._client.getAPIList("/files",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/files/${t}`,n)}content(t,n){return this._client.get(C`/files/${t}/content`,{...n,headers:_([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}async waitForProcessing(t,{pollInterval:n=5e3,maxWait:s=1800*1e3}={}){const r=new Set(["processed","error","deleted"]),i=Date.now();let u=await this.retrieve(t);for(;!u.status||!r.has(u.status);)if(await $t(n),u=await this.retrieve(t),Date.now()-i>s)throw new vt({message:`Giving up on waiting for file ${t} to finish processing after ${s} milliseconds.`});return u}},o(pt,"Files"),pt);const Oi=class Oi extends A{};o(Oi,"Methods");let ms=Oi,fl=(mt=class extends A{run(t,n){return this._client.post("/fine_tuning/alpha/graders/run",{body:t,...n})}validate(t,n){return this._client.post("/fine_tuning/alpha/graders/validate",{body:t,...n})}},o(mt,"Graders"),mt);const Ri=class Ri extends A{constructor(){super(...arguments),this.graders=new fl(this._client)}};o(Ri,"Alpha");let Vt=Ri;Vt.Graders=fl;const ki=class ki extends A{create(t,n,s){return this._client.getAPIList(C`/fine_tuning/checkpoints/${t}/permissions`,Ve,{body:n,method:"post",...s})}retrieve(t,n={},s){return this._client.get(C`/fine_tuning/checkpoints/${t}/permissions`,{query:n,...s})}delete(t,n,s){const{fine_tuned_model_checkpoint:r}=n;return this._client.delete(C`/fine_tuning/checkpoints/${r}/permissions/${t}`,s)}};o(ki,"Permissions");let Fs=ki,Eu=(Ft=class extends A{constructor(){super(...arguments),this.permissions=new Fs(this._client)}},o(Ft,"Checkpoints"),Ft);Eu.Permissions=Fs;const Pi=class Pi extends A{list(t,n={},s){return this._client.getAPIList(C`/fine_tuning/jobs/${t}/checkpoints`,M,{query:n,...s})}};o(Pi,"Checkpoints");let gs=Pi;const Ti=class Ti extends A{constructor(){super(...arguments),this.checkpoints=new gs(this._client)}create(t,n){return this._client.post("/fine_tuning/jobs",{body:t,...n})}retrieve(t,n){return this._client.get(C`/fine_tuning/jobs/${t}`,n)}list(t={},n){return this._client.getAPIList("/fine_tuning/jobs",M,{query:t,...n})}cancel(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/cancel`,n)}listEvents(t,n={},s){return this._client.getAPIList(C`/fine_tuning/jobs/${t}/events`,M,{query:n,...s})}pause(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/pause`,n)}resume(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/resume`,n)}};o(Ti,"Jobs");let Jt=Ti;Jt.Checkpoints=gs;const Ni=class Ni extends A{constructor(){super(...arguments),this.methods=new ms(this._client),this.jobs=new Jt(this._client),this.checkpoints=new Eu(this._client),this.alpha=new Vt(this._client)}};o(Ni,"FineTuning");let ye=Ni;ye.Methods=ms,ye.Jobs=Jt,ye.Checkpoints=Eu,ye.Alpha=Vt;const Mi=class Mi extends A{};o(Mi,"GraderModels");let Cs=Mi;const Li=class Li extends A{constructor(){super(...arguments),this.graderModels=new Cs(this._client)}};o(Li,"Graders");let Xt=Li;Xt.GraderModels=Cs;const ji=class ji extends A{createVariation(t,n){return this._client.post("/images/variations",Se({body:t,...n},this._client))}edit(t,n){return this._client.post("/images/edits",Se({body:t,...n,stream:t.stream??!1},this._client))}generate(t,n){return this._client.post("/images/generations",{body:t,...n,stream:t.stream??!1})}};o(ji,"Images");let Es=ji;const Ui=class Ui extends A{retrieve(t,n){return this._client.get(C`/models/${t}`,n)}list(t){return this._client.getAPIList("/models",Ve,t)}delete(t,n){return this._client.delete(C`/models/${t}`,n)}};o(Ui,"Models");let ys=Ui;const Wi=class Wi extends A{create(t,n){return this._client.post("/moderations",{body:t,...n})}};o(Wi,"Moderations");let ws=Wi;const qi=class qi extends A{accept(t,n,s){return this._client.post(C`/realtime/calls/${t}/accept`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}hangup(t,n){return this._client.post(C`/realtime/calls/${t}/hangup`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}refer(t,n,s){return this._client.post(C`/realtime/calls/${t}/refer`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}reject(t,n={},s){return this._client.post(C`/realtime/calls/${t}/reject`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}};o(qi,"Calls");let bs=qi;const Gi=class Gi extends A{create(t,n){return this._client.post("/realtime/client_secrets",{body:t,...n})}};o(Gi,"ClientSecrets");let _s=Gi;const Ki=class Ki extends A{constructor(){super(...arguments),this.clientSecrets=new _s(this._client),this.calls=new bs(this._client)}};o(Ki,"Realtime");let nt=Ki;nt.ClientSecrets=_s,nt.Calls=bs;function wp(e,t){return!t||!_p(t)?{...e,output_parsed:null,output:e.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:n.type==="message"?{...n,content:n.content.map(s=>({...s,parsed:null}))}:n)}:pl(e,t)}o(wp,"maybeParseResponse");function pl(e,t){const n=e.output.map(r=>{if(r.type==="function_call")return{...r,parsed_arguments:vp(t,r)};if(r.type==="message"){const i=r.content.map(u=>u.type==="output_text"?{...u,parsed:bp(t,u.text)}:u);return{...r,content:i}}return r}),s=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||yu(s),Object.defineProperty(s,"output_parsed",{enumerable:!0,get(){for(const r of s.output)if(r.type==="message"){for(const i of r.content)if(i.type==="output_text"&&i.parsed!==null)return i.parsed}return null}}),s}o(pl,"parseResponse");function bp(e,t){return e.text?.format?.type!=="json_schema"?null:"$parseRaw"in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t)}o(bp,"parseTextFormat");function _p(e){return!!eu(e.text?.format)}o(_p,"hasAutoParseableInput");function Bp(e){return e?.$brand==="auto-parseable-tool"}o(Bp,"isAutoParsableTool");function Ap(e,t){return e.find(n=>n.type==="function"&&n.name===t)}o(Ap,"getInputToolByName");function vp(e,t){const n=Ap(e.tools??[],t.name);return{...t,...t,parsed_arguments:Bp(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}o(vp,"parseToolCall");function yu(e){const t=[];for(const n of e.output)if(n.type==="message")for(const s of n.content)s.type==="output_text"&&t.push(s.text);e.output_text=t.join("")}o(yu,"addOutputText");var st,Bs,we,As,ml,Fl,gl,Cl;const Ls=class Ls extends Lt{constructor(t){super(),st.add(this),Bs.set(this,void 0),we.set(this,void 0),As.set(this,void 0),$(this,Bs,t)}static createResponse(t,n,s){const r=new Ls(n);return r._run(()=>r._createOrRetrieveResponse(t,n,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createOrRetrieveResponse(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,st,"m",ml).call(this);let i,u=null;"response_id"in n?(i=await t.responses.retrieve(n.response_id,{stream:!0},{...s,signal:this.controller.signal,stream:!0}),u=n.starting_after??null):i=await t.responses.create({...n,stream:!0},{...s,signal:this.controller.signal}),this._connected();for await(const a of i)p(this,st,"m",Fl).call(this,a,u);if(i.controller.signal?.aborted)throw new ne;return p(this,st,"m",gl).call(this)}[(Bs=new WeakMap,we=new WeakMap,As=new WeakMap,st=new WeakSet,ml=o(function(){this.ended||$(this,we,void 0)},"_ResponseStream_beginRequest2"),Fl=o(function(n,s){if(this.ended)return;const r=o((u,a)=>{(s==null||a.sequence_number>s)&&this._emit(u,a)},"maybeEmit"),i=p(this,st,"m",Cl).call(this,n);switch(r("event",n),n.type){case"response.output_text.delta":{const u=i.output[n.output_index];if(!u)throw new v(`missing output at index ${n.output_index}`);if(u.type==="message"){const a=u.content[n.content_index];if(!a)throw new v(`missing content at index ${n.content_index}`);if(a.type!=="output_text")throw new v(`expected content to be 'output_text', got ${a.type}`);r("response.output_text.delta",{...n,snapshot:a.text})}break}case"response.function_call_arguments.delta":{const u=i.output[n.output_index];if(!u)throw new v(`missing output at index ${n.output_index}`);u.type==="function_call"&&r("response.function_call_arguments.delta",{...n,snapshot:u.arguments});break}default:r(n.type,n);break}},"_ResponseStream_addEvent2"),gl=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");const n=p(this,we,"f");if(!n)throw new v("request ended without sending any events");$(this,we,void 0);const s=$p(n,p(this,Bs,"f"));return $(this,As,s),s},"_ResponseStream_endRequest2"),Cl=o(function(n){let s=p(this,we,"f");if(!s){if(n.type!=="response.created")throw new v(`When snapshot hasn't been set yet, expected 'response.created' event, got ${n.type}`);return s=$(this,we,n.response),s}switch(n.type){case"response.output_item.added":{s.output.push(n.item);break}case"response.content_part.added":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);const i=r.type,u=n.part;i==="message"&&u.type!=="reasoning_text"?r.content.push(u):i==="reasoning"&&u.type==="reasoning_text"&&(r.content||(r.content=[]),r.content.push(u));break}case"response.output_text.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);if(r.type==="message"){const i=r.content[n.content_index];if(!i)throw new v(`missing content at index ${n.content_index}`);if(i.type!=="output_text")throw new v(`expected content to be 'output_text', got ${i.type}`);i.text+=n.delta}break}case"response.function_call_arguments.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);r.type==="function_call"&&(r.arguments+=n.delta);break}case"response.reasoning_text.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);if(r.type==="reasoning"){const i=r.content?.[n.content_index];if(!i)throw new v(`missing content at index ${n.content_index}`);if(i.type!=="reasoning_text")throw new v(`expected content to be 'reasoning_text', got ${i.type}`);i.text+=n.delta}break}case"response.completed":{$(this,we,n.response);break}}return s},"_ResponseStream_accumulateResponse2"),Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("event",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}async finalResponse(){await this.done();const t=p(this,As,"f");if(!t)throw new v("stream ended without producing a ChatCompletion");return t}};o(Ls,"ResponseStream");let wu=Ls;function $p(e,t){return wp(e,t)}o($p,"finalizeResponse");const Hi=class Hi extends A{list(t,n={},s){return this._client.getAPIList(C`/responses/${t}/input_items`,M,{query:n,...s})}};o(Hi,"InputItems");let vs=Hi;const zi=class zi extends A{count(t={},n){return this._client.post("/responses/input_tokens",{body:t,...n})}};o(zi,"InputTokens");let $s=zi;const Vi=class Vi extends A{constructor(){super(...arguments),this.inputItems=new vs(this._client),this.inputTokens=new $s(this._client)}create(t,n){return this._client.post("/responses",{body:t,...n,stream:t.stream??!1})._thenUnwrap(s=>("object"in s&&s.object==="response"&&yu(s),s))}retrieve(t,n={},s){return this._client.get(C`/responses/${t}`,{query:n,...s,stream:n?.stream??!1})._thenUnwrap(r=>("object"in r&&r.object==="response"&&yu(r),r))}delete(t,n){return this._client.delete(C`/responses/${t}`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}parse(t,n){return this._client.responses.create(t,n)._thenUnwrap(s=>pl(s,t))}stream(t,n){return wu.createResponse(this._client,t,n)}cancel(t,n){return this._client.post(C`/responses/${t}/cancel`,n)}};o(Vi,"Responses");let rt=Vi;rt.InputItems=vs,rt.InputTokens=$s;const Ji=class Ji extends A{create(t,n,s){return this._client.post(C`/uploads/${t}/parts`,Se({body:n,...s},this._client))}};o(Ji,"Parts");let xs=Ji;const Xi=class Xi extends A{constructor(){super(...arguments),this.parts=new xs(this._client)}create(t,n){return this._client.post("/uploads",{body:t,...n})}cancel(t,n){return this._client.post(C`/uploads/${t}/cancel`,n)}complete(t,n,s){return this._client.post(C`/uploads/${t}/complete`,{body:n,...s})}};o(Xi,"Uploads");let Yt=Xi;Yt.Parts=xs;const xp=o(async e=>{const t=await Promise.allSettled(e),n=t.filter(r=>r.status==="rejected");if(n.length){for(const r of n)console.error(r.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}const s=[];for(const r of t)r.status==="fulfilled"&&s.push(r.value);return s},"allSettledWithThrow"),Yi=class Yi extends A{create(t,n,s){return this._client.post(C`/vector_stores/${t}/file_batches`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{vector_store_id:r}=n;return this._client.get(C`/vector_stores/${r}/file_batches/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(t,n,s){const{vector_store_id:r}=n;return this._client.post(C`/vector_stores/${r}/file_batches/${t}/cancel`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n);return await this.poll(t,r.id,s)}listFiles(t,n,s){const{vector_store_id:r,...i}=n;return this._client.getAPIList(C`/vector_stores/${r}/file_batches/${t}/files`,M,{query:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:i,response:u}=await this.retrieve(n,{vector_store_id:t},{...s,headers:r}).withResponse();switch(i.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=u.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await $t(a);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(t,{files:n,fileIds:s=[]},r){if(n==null||n.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const i=r?.maxConcurrency??5,u=Math.min(i,n.length),a=this._client,c=n.values(),l=[...s];async function D(f){for(let h of f){const F=await a.files.create({file:h,purpose:"assistants"},r);l.push(F.id)}}o(D,"processFiles");const d=Array(u).fill(c).map(D);return await xp(d),await this.createAndPoll(t,{file_ids:l})}};o(Yi,"FileBatches");let Ss=Yi;const Qi=class Qi extends A{create(t,n,s){return this._client.post(C`/vector_stores/${t}/files`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{vector_store_id:r}=n;return this._client.get(C`/vector_stores/${r}/files/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{vector_store_id:r,...i}=n;return this._client.post(C`/vector_stores/${r}/files/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/vector_stores/${t}/files`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n,s){const{vector_store_id:r}=n;return this._client.delete(C`/vector_stores/${r}/files/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n,s);return await this.poll(t,r.id,s)}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const i=await this.retrieve(n,{vector_store_id:t},{...s,headers:r}).withResponse(),u=i.data;switch(u.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=i.response.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await $t(a);break;case"failed":case"completed":return u}}}async upload(t,n,s){const r=await this._client.files.create({file:n,purpose:"assistants"},s);return this.create(t,{file_id:r.id},s)}async uploadAndPoll(t,n,s){const r=await this.upload(t,n,s);return await this.poll(t,r.id,s)}content(t,n,s){const{vector_store_id:r}=n;return this._client.getAPIList(C`/vector_stores/${r}/files/${t}/content`,Ve,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Qi,"Files");let Is=Qi;const Zi=class Zi extends A{constructor(){super(...arguments),this.files=new Is(this._client),this.fileBatches=new Ss(this._client)}create(t,n){return this._client.post("/vector_stores",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/vector_stores/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/vector_stores/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t={},n){return this._client.getAPIList("/vector_stores",M,{query:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,n){return this._client.delete(C`/vector_stores/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}search(t,n,s){return this._client.getAPIList(C`/vector_stores/${t}/search`,Ve,{body:n,method:"post",...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Zi,"VectorStores");let ut=Zi;ut.Files=Is,ut.FileBatches=Ss;const eo=class eo extends A{create(t,n){return this._client.post("/videos",$c({body:t,...n},this._client))}retrieve(t,n){return this._client.get(C`/videos/${t}`,n)}list(t={},n){return this._client.getAPIList("/videos",Je,{query:t,...n})}delete(t,n){return this._client.delete(C`/videos/${t}`,n)}downloadContent(t,n={},s){return this._client.get(C`/videos/${t}/content`,{query:n,...s,headers:_([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}remix(t,n,s){return this._client.post(C`/videos/${t}/remix`,$c({body:n,...s},this._client))}};o(eo,"Videos");let Os=eo;var it,El,Rs;const to=class to extends A{constructor(){super(...arguments),it.add(this)}async unwrap(t,n,s=this._client.webhookSecret,r=300){return await this.verifySignature(t,n,s,r),JSON.parse(t)}async verifySignature(t,n,s=this._client.webhookSecret,r=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");p(this,it,"m",El).call(this,s);const i=_([n]).values,u=p(this,it,"m",Rs).call(this,i,"webhook-signature"),a=p(this,it,"m",Rs).call(this,i,"webhook-timestamp"),c=p(this,it,"m",Rs).call(this,i,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new ve("Invalid webhook timestamp format");const D=Math.floor(Date.now()/1e3);if(D-l>r)throw new ve("Webhook timestamp is too old");if(l>D+r)throw new ve("Webhook timestamp is too new");const d=u.split(" ").map(m=>m.startsWith("v1,")?m.substring(3):m),f=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),h=c?`${c}.${a}.${t}`:`${a}.${t}`,F=await crypto.subtle.importKey("raw",f,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(const m of d)try{const E=Buffer.from(m,"base64");if(await crypto.subtle.verify("HMAC",F,E,new TextEncoder().encode(h)))return}catch{continue}throw new ve("The given webhook signature does not match the expected signature")}};o(to,"Webhooks");let ks=to;it=new WeakSet,El=o(function(t){if(typeof t!="string"||t.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},"_Webhooks_validateSecret2"),Rs=o(function(t,n){if(!t)throw new Error("Headers are required");const s=t.get(n);if(s==null)throw new Error(`Missing required header: ${n}`);return s},"_Webhooks_getRequiredHeader2");var bu,_u,Ps,yl;const no=class no{constructor({baseURL:t=Ze("OPENAI_BASE_URL"),apiKey:n=Ze("OPENAI_API_KEY"),organization:s=Ze("OPENAI_ORG_ID")??null,project:r=Ze("OPENAI_PROJECT_ID")??null,webhookSecret:i=Ze("OPENAI_WEBHOOK_SECRET")??null,...u}={}){if(bu.add(this),Ps.set(this,void 0),this.completions=new Ds(this),this.chat=new jt(this),this.embeddings=new fs(this),this.files=new hl(this),this.images=new Es(this),this.audio=new Ie(this),this.moderations=new ws(this),this.models=new ys(this),this.fineTuning=new ye(this),this.graders=new Xt(this),this.vectorStores=new ut(this),this.webhooks=new ks(this),this.beta=new Ee(this),this.batches=new es(this),this.uploads=new Yt(this),this.responses=new rt(this),this.realtime=new nt(this),this.conversations=new Kt(this),this.evals=new zt(this),this.containers=new Gt(this),this.videos=new Os(this),n===void 0)throw new v("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:n,organization:s,project:r,webhookSecret:i,...u,baseURL:t||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&Pf())throw new v(`It looks like you're running in a browser-like environment.
93
+ ${D}`)}return u},"path2"),"createPathTagFunction"),C=op(Ic);let Rc=(ot=class extends A{list(t,n={},s){return this._client.getAPIList(C`/chat/completions/${t}/messages`,M,{query:n,...s})}},o(ot,"Messages"),ot);function Tn(e){return e!==void 0&&"function"in e&&e.function!==void 0}o(Tn,"isChatCompletionFunctionTool");function eu(e){return e?.$brand==="auto-parseable-response-format"}o(eu,"isAutoParsableResponseFormat");function Ot(e){return e?.$brand==="auto-parseable-tool"}o(Ot,"isAutoParsableTool$1");function ap(e,t){return!t||!kc(t)?{...e,choices:e.choices.map(n=>(Pc(n.message.tool_calls),{...n,message:{...n.message,parsed:null,...n.message.tool_calls?{tool_calls:n.message.tool_calls}:void 0}}))}:tu(e,t)}o(ap,"maybeParseChatCompletion");function tu(e,t){const n=e.choices.map(s=>{if(s.finish_reason==="length")throw new xn;if(s.finish_reason==="content_filter")throw new Sn;return Pc(s.message.tool_calls),{...s,message:{...s.message,...s.message.tool_calls?{tool_calls:s.message.tool_calls?.map(r=>lp(t,r))??void 0}:void 0,parsed:s.message.content&&!s.message.refusal?cp(t,s.message.content):null}}});return{...e,choices:n}}o(tu,"parseChatCompletion");function cp(e,t){return e.response_format?.type!=="json_schema"?null:e.response_format?.type==="json_schema"?"$parseRaw"in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}o(cp,"parseResponseFormat");function lp(e,t){const n=e.tools?.find(s=>Tn(s)&&s.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:Ot(n)?n.$parseRaw(t.function.arguments):n?.function.strict?JSON.parse(t.function.arguments):null}}}o(lp,"parseToolCall$1");function Dp(e,t){if(!e||!("tools"in e)||!e.tools)return!1;const n=e.tools?.find(s=>Tn(s)&&s.function?.name===t.function.name);return Tn(n)&&(Ot(n)||n?.function.strict||!1)}o(Dp,"shouldParseToolCall");function kc(e){return eu(e.response_format)?!0:e.tools?.some(t=>Ot(t)||t.type==="function"&&t.function.strict===!0)??!1}o(kc,"hasAutoParseableInput$1");function Pc(e){for(const t of e||[])if(t.type!=="function")throw new v(`Currently only \`function\` tool calls are supported; Received \`${t.type}\``)}o(Pc,"assertToolCallsAreChatCompletionFunctionToolCalls");function dp(e){for(const t of e??[]){if(t.type!=="function")throw new v(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(t.function.strict!==!0)throw new v(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}o(dp,"validateInputTools");const Nn=o(e=>e?.role==="assistant","isAssistantMessage"),Tc=o(e=>e?.role==="tool","isToolMessage");var nu,Mn,Ln,Rt,kt,jn,Pt,pe,Tt,Un,Wn,Je,Nc;const si=class si{constructor(){nu.add(this),this.controller=new AbortController,Mn.set(this,void 0),Ln.set(this,()=>{}),Rt.set(this,()=>{}),kt.set(this,void 0),jn.set(this,()=>{}),Pt.set(this,()=>{}),pe.set(this,{}),Tt.set(this,!1),Un.set(this,!1),Wn.set(this,!1),Je.set(this,!1),$(this,Mn,new Promise((t,n)=>{$(this,Ln,t,"f"),$(this,Rt,n,"f")})),$(this,kt,new Promise((t,n)=>{$(this,jn,t,"f"),$(this,Pt,n,"f")})),p(this,Mn,"f").catch(()=>{}),p(this,kt,"f").catch(()=>{})}_run(t){setTimeout(()=>{t().then(()=>{this._emitFinal(),this._emit("end")},p(this,nu,"m",Nc).bind(this))},0)}_connected(){this.ended||(p(this,Ln,"f").call(this),this._emit("connect"))}get ended(){return p(this,Tt,"f")}get errored(){return p(this,Un,"f")}get aborted(){return p(this,Wn,"f")}abort(){this.controller.abort()}on(t,n){return(p(this,pe,"f")[t]||(p(this,pe,"f")[t]=[])).push({listener:n}),this}off(t,n){const s=p(this,pe,"f")[t];if(!s)return this;const r=s.findIndex(i=>i.listener===n);return r>=0&&s.splice(r,1),this}once(t,n){return(p(this,pe,"f")[t]||(p(this,pe,"f")[t]=[])).push({listener:n,once:!0}),this}emitted(t){return new Promise((n,s)=>{$(this,Je,!0),t!=="error"&&this.once("error",s),this.once(t,n)})}async done(){$(this,Je,!0),await p(this,kt,"f")}_emit(t,...n){if(p(this,Tt,"f"))return;t==="end"&&($(this,Tt,!0),p(this,jn,"f").call(this));const s=p(this,pe,"f")[t];if(s&&(p(this,pe,"f")[t]=s.filter(r=>!r.once),s.forEach(({listener:r})=>r(...n))),t==="abort"){const r=n[0];!p(this,Je,"f")&&!s?.length&&Promise.reject(r),p(this,Rt,"f").call(this,r),p(this,Pt,"f").call(this,r),this._emit("end");return}if(t==="error"){const r=n[0];!p(this,Je,"f")&&!s?.length&&Promise.reject(r),p(this,Rt,"f").call(this,r),p(this,Pt,"f").call(this,r),this._emit("end")}}_emitFinal(){}};o(si,"EventStream");let Nt=si;Mn=new WeakMap,Ln=new WeakMap,Rt=new WeakMap,kt=new WeakMap,jn=new WeakMap,Pt=new WeakMap,pe=new WeakMap,Tt=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Je=new WeakMap,nu=new WeakSet,Nc=o(function(t){if($(this,Un,!0),t instanceof Error&&t.name==="AbortError"&&(t=new ne),t instanceof ne)return $(this,Wn,!0),this._emit("abort",t);if(t instanceof v)return this._emit("error",t);if(t instanceof Error){const n=new v(t.message);return n.cause=t,this._emit("error",n)}return this._emit("error",new v(String(t)))},"_EventStream_handleError2");function hp(e){return typeof e.parse=="function"}o(hp,"isRunnableFunctionWithParse");var te,su,qn,ru,uu,iu,Mc,Lc;const fp=10,ri=class ri extends Nt{constructor(){super(...arguments),te.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(t){this._chatCompletions.push(t),this._emit("chatCompletion",t);const n=t.choices[0]?.message;return n&&this._addMessage(n),t}_addMessage(t,n=!0){if("content"in t||(t.content=null),this.messages.push(t),n){if(this._emit("message",t),Tc(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(Nn(t)&&t.tool_calls)for(const s of t.tool_calls)s.type==="function"&&this._emit("functionToolCall",s.function)}}async finalChatCompletion(){await this.done();const t=this._chatCompletions[this._chatCompletions.length-1];if(!t)throw new v("stream ended without producing a ChatCompletion");return t}async finalContent(){return await this.done(),p(this,te,"m",su).call(this)}async finalMessage(){return await this.done(),p(this,te,"m",qn).call(this)}async finalFunctionToolCall(){return await this.done(),p(this,te,"m",ru).call(this)}async finalFunctionToolCallResult(){return await this.done(),p(this,te,"m",uu).call(this)}async totalUsage(){return await this.done(),p(this,te,"m",iu).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const t=this._chatCompletions[this._chatCompletions.length-1];t&&this._emit("finalChatCompletion",t);const n=p(this,te,"m",qn).call(this);n&&this._emit("finalMessage",n);const s=p(this,te,"m",su).call(this);s&&this._emit("finalContent",s);const r=p(this,te,"m",ru).call(this);r&&this._emit("finalFunctionToolCall",r);const i=p(this,te,"m",uu).call(this);i!=null&&this._emit("finalFunctionToolCallResult",i),this._chatCompletions.some(u=>u.usage)&&this._emit("totalUsage",p(this,te,"m",iu).call(this))}async _createChatCompletion(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,te,"m",Mc).call(this,n);const i=await t.chat.completions.create({...n,stream:!1},{...s,signal:this.controller.signal});return this._connected(),this._addChatCompletion(tu(i,n))}async _runChatCompletion(t,n,s){for(const r of n.messages)this._addMessage(r,!1);return await this._createChatCompletion(t,n,s)}async _runTools(t,n,s){const r="tool",{tool_choice:i="auto",stream:u,...a}=n,c=typeof i!="string"&&i.type==="function"&&i?.function?.name,{maxChatCompletions:l=fp}=s||{},d=n.tools.map(h=>{if(Ot(h)){if(!h.$callback)throw new v("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:h.$callback,name:h.function.name,description:h.function.description||"",parameters:h.function.parameters,parse:h.$parseRaw,strict:!0}}}return h}),D={};for(const h of d)h.type==="function"&&(D[h.function.name||h.function.function.name]=h.function);const f="tools"in n?d.map(h=>h.type==="function"?{type:"function",function:{name:h.function.name||h.function.function.name,parameters:h.function.parameters,description:h.function.description,strict:h.function.strict}}:h):void 0;for(const h of n.messages)this._addMessage(h,!1);for(let h=0;h<l;++h){const m=(await this._createChatCompletion(t,{...a,tool_choice:i,tools:f,messages:[...this.messages]},s)).choices[0]?.message;if(!m)throw new v("missing message in ChatCompletion response");if(!m.tool_calls?.length)return;for(const E of m.tool_calls){if(E.type!=="function")continue;const y=E.id,{name:g,arguments:b}=E.function,B=D[g];if(B){if(c&&c!==g){const L=`Invalid tool_call: ${JSON.stringify(g)}. ${JSON.stringify(c)} requested. Please try again`;this._addMessage({role:r,tool_call_id:y,content:L});continue}}else{const L=`Invalid tool_call: ${JSON.stringify(g)}. Available options are: ${Object.keys(D).map(z=>JSON.stringify(z)).join(", ")}. Please try again`;this._addMessage({role:r,tool_call_id:y,content:L});continue}let I;try{I=hp(B)?await B.parse(b):b}catch(L){const z=L instanceof Error?L.message:String(L);this._addMessage({role:r,tool_call_id:y,content:z});continue}const O=await B.function(I,this),R=p(this,te,"m",Lc).call(this,O);if(this._addMessage({role:r,tool_call_id:y,content:R}),c)return}}}};o(ri,"AbstractChatCompletionRunner");let Gn=ri;te=new WeakSet,su=o(function(){return p(this,te,"m",qn).call(this).content??null},"_AbstractChatCompletionRunner_getFinalContent2"),qn=o(function(){let t=this.messages.length;for(;t-- >0;){const n=this.messages[t];if(Nn(n))return{...n,content:n.content??null,refusal:n.refusal??null}}throw new v("stream ended without producing a ChatCompletionMessage with role=assistant")},"_AbstractChatCompletionRunner_getFinalMessage2"),ru=o(function(){for(let t=this.messages.length-1;t>=0;t--){const n=this.messages[t];if(Nn(n)&&n?.tool_calls?.length)return n.tool_calls.filter(s=>s.type==="function").at(-1)?.function}},"_AbstractChatCompletionRunner_getFinalFunctionToolCall2"),uu=o(function(){for(let t=this.messages.length-1;t>=0;t--){const n=this.messages[t];if(Tc(n)&&n.content!=null&&typeof n.content=="string"&&this.messages.some(s=>s.role==="assistant"&&s.tool_calls?.some(r=>r.type==="function"&&r.id===n.tool_call_id)))return n.content}},"_AbstractChatCompletionRunner_getFinalFunctionToolCallResult2"),iu=o(function(){const t={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:n}of this._chatCompletions)n&&(t.completion_tokens+=n.completion_tokens,t.prompt_tokens+=n.prompt_tokens,t.total_tokens+=n.total_tokens);return t},"_AbstractChatCompletionRunner_calculateTotalUsage2"),Mc=o(function(t){if(t.n!=null&&t.n>1)throw new v("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},"_AbstractChatCompletionRunner_validateParams2"),Lc=o(function(t){return typeof t=="string"?t:t===void 0?"undefined":JSON.stringify(t)},"_AbstractChatCompletionRunner_stringifyFunctionCallResult2");const Ns=class Ns extends Gn{static runTools(t,n,s){const r=new Ns,i={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(t,n,i)),r}_addMessage(t,n=!0){super._addMessage(t,n),Nn(t)&&t.content&&this._emit("content",t.content)}};o(Ns,"ChatCompletionRunner");let ou=Ns;const jc=1,Uc=2,Wc=4,qc=8,Gc=16,Kc=32,Hc=64,zc=128,Vc=256,Jc=zc|Vc,Xc=Gc|Kc|Jc|Hc,Yc=jc|Uc|Xc,Qc=Wc|qc,pp=Yc|Qc,V={STR:jc,NUM:Uc,ARR:Wc,OBJ:qc,NULL:Gc,BOOL:Kc,NAN:Hc,INFINITY:zc,MINUS_INFINITY:Vc,INF:Jc,SPECIAL:Xc,ATOM:Yc,COLLECTION:Qc,ALL:pp},ui=class ui extends Error{};o(ui,"PartialJSON");let au=ui;const ii=class ii extends Error{};o(ii,"MalformedJSON");let cu=ii;function mp(e,t=V.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return Fp(e.trim(),t)}o(mp,"parseJSON");const Fp=o((e,t)=>{const n=e.length;let s=0;const r=o(f=>{throw new au(`${f} at position ${s}`)},"markPartialJSON"),i=o(f=>{throw new cu(`${f} at position ${s}`)},"throwMalformedError"),u=o(()=>(D(),s>=n&&r("Unexpected end of input"),e[s]==='"'?a():e[s]==="{"?c():e[s]==="["?l():e.substring(s,s+4)==="null"||V.NULL&t&&n-s<4&&"null".startsWith(e.substring(s))?(s+=4,null):e.substring(s,s+4)==="true"||V.BOOL&t&&n-s<4&&"true".startsWith(e.substring(s))?(s+=4,!0):e.substring(s,s+5)==="false"||V.BOOL&t&&n-s<5&&"false".startsWith(e.substring(s))?(s+=5,!1):e.substring(s,s+8)==="Infinity"||V.INFINITY&t&&n-s<8&&"Infinity".startsWith(e.substring(s))?(s+=8,1/0):e.substring(s,s+9)==="-Infinity"||V.MINUS_INFINITY&t&&1<n-s&&n-s<9&&"-Infinity".startsWith(e.substring(s))?(s+=9,-1/0):e.substring(s,s+3)==="NaN"||V.NAN&t&&n-s<3&&"NaN".startsWith(e.substring(s))?(s+=3,NaN):d()),"parseAny"),a=o(()=>{const f=s;let h=!1;for(s++;s<n&&(e[s]!=='"'||h&&e[s-1]==="\\");)h=e[s]==="\\"?!h:!1,s++;if(e.charAt(s)=='"')try{return JSON.parse(e.substring(f,++s-Number(h)))}catch(F){i(String(F))}else if(V.STR&t)try{return JSON.parse(e.substring(f,s-Number(h))+'"')}catch{return JSON.parse(e.substring(f,e.lastIndexOf("\\"))+'"')}r("Unterminated string literal")},"parseStr"),c=o(()=>{s++,D();const f={};try{for(;e[s]!=="}";){if(D(),s>=n&&V.OBJ&t)return f;const h=a();D(),s++;try{const F=u();Object.defineProperty(f,h,{value:F,writable:!0,enumerable:!0,configurable:!0})}catch(F){if(V.OBJ&t)return f;throw F}D(),e[s]===","&&s++}}catch{if(V.OBJ&t)return f;r("Expected '}' at end of object")}return s++,f},"parseObj"),l=o(()=>{s++;const f=[];try{for(;e[s]!=="]";)f.push(u()),D(),e[s]===","&&s++}catch{if(V.ARR&t)return f;r("Expected ']' at end of array")}return s++,f},"parseArr"),d=o(()=>{if(s===0){e==="-"&&V.NUM&t&&r("Not sure what '-' is");try{return JSON.parse(e)}catch(h){if(V.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}i(String(h))}}const f=s;for(e[s]==="-"&&s++;e[s]&&!",]}".includes(e[s]);)s++;s==n&&!(V.NUM&t)&&r("Unterminated number literal");try{return JSON.parse(e.substring(f,s))}catch{e.substring(f,s)==="-"&&V.NUM&t&&r("Not sure what '-' is");try{return JSON.parse(e.substring(f,e.lastIndexOf("e")))}catch(F){i(String(F))}}},"parseNum"),D=o(()=>{for(;s<n&&`
94
+ \r `.includes(e[s]);)s++},"skipBlank");return u()},"_parseJSON"),Zc=o(e=>mp(e,V.ALL^V.NUM),"partialParse");var H,me,Xe,Ce,lu,Kn,Du,du,hu,Hn,fu,el;const Qt=class Qt extends Gn{constructor(t){super(),H.add(this),me.set(this,void 0),Xe.set(this,void 0),Ce.set(this,void 0),$(this,me,t),$(this,Xe,[])}get currentChatCompletionSnapshot(){return p(this,Ce,"f")}static fromReadableStream(t){const n=new Qt(null);return n._run(()=>n._fromReadableStream(t)),n}static createChatCompletion(t,n,s){const r=new Qt(n);return r._run(()=>r._runChatCompletion(t,{...n,stream:!0},{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createChatCompletion(t,n,s){super._createChatCompletion;const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,H,"m",lu).call(this);const i=await t.chat.completions.create({...n,stream:!0},{...s,signal:this.controller.signal});this._connected();for await(const u of i)p(this,H,"m",Du).call(this,u);if(i.controller.signal?.aborted)throw new ne;return this._addChatCompletion(p(this,H,"m",Hn).call(this))}async _fromReadableStream(t,n){const s=n?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),p(this,H,"m",lu).call(this),this._connected();const r=xe.fromReadableStream(t,this.controller);let i;for await(const u of r)i&&i!==u.id&&this._addChatCompletion(p(this,H,"m",Hn).call(this)),p(this,H,"m",Du).call(this,u),i=u.id;if(r.controller.signal?.aborted)throw new ne;return this._addChatCompletion(p(this,H,"m",Hn).call(this))}[(me=new WeakMap,Xe=new WeakMap,Ce=new WeakMap,H=new WeakSet,lu=o(function(){this.ended||$(this,Ce,void 0)},"_ChatCompletionStream_beginRequest2"),Kn=o(function(n){let s=p(this,Xe,"f")[n.index];return s||(s={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},p(this,Xe,"f")[n.index]=s,s)},"_ChatCompletionStream_getChoiceEventState2"),Du=o(function(n){if(this.ended)return;const s=p(this,H,"m",el).call(this,n);this._emit("chunk",n,s);for(const r of n.choices){const i=s.choices[r.index];r.delta.content!=null&&i.message?.role==="assistant"&&i.message?.content&&(this._emit("content",r.delta.content,i.message.content),this._emit("content.delta",{delta:r.delta.content,snapshot:i.message.content,parsed:i.message.parsed})),r.delta.refusal!=null&&i.message?.role==="assistant"&&i.message?.refusal&&this._emit("refusal.delta",{delta:r.delta.refusal,snapshot:i.message.refusal}),r.logprobs?.content!=null&&i.message?.role==="assistant"&&this._emit("logprobs.content.delta",{content:r.logprobs?.content,snapshot:i.logprobs?.content??[]}),r.logprobs?.refusal!=null&&i.message?.role==="assistant"&&this._emit("logprobs.refusal.delta",{refusal:r.logprobs?.refusal,snapshot:i.logprobs?.refusal??[]});const u=p(this,H,"m",Kn).call(this,i);i.finish_reason&&(p(this,H,"m",hu).call(this,i),u.current_tool_call_index!=null&&p(this,H,"m",du).call(this,i,u.current_tool_call_index));for(const a of r.delta.tool_calls??[])u.current_tool_call_index!==a.index&&(p(this,H,"m",hu).call(this,i),u.current_tool_call_index!=null&&p(this,H,"m",du).call(this,i,u.current_tool_call_index)),u.current_tool_call_index=a.index;for(const a of r.delta.tool_calls??[]){const c=i.message.tool_calls?.[a.index];c?.type&&(c?.type==="function"?this._emit("tool_calls.function.arguments.delta",{name:c.function?.name,index:a.index,arguments:c.function.arguments,parsed_arguments:c.function.parsed_arguments,arguments_delta:a.function?.arguments??""}):(c?.type,void 0))}}},"_ChatCompletionStream_addChunk2"),du=o(function(n,s){if(p(this,H,"m",Kn).call(this,n).done_tool_calls.has(s))return;const i=n.message.tool_calls?.[s];if(!i)throw new Error("no tool call snapshot");if(!i.type)throw new Error("tool call snapshot missing `type`");if(i.type==="function"){const u=p(this,me,"f")?.tools?.find(a=>Tn(a)&&a.function.name===i.function.name);this._emit("tool_calls.function.arguments.done",{name:i.function.name,index:s,arguments:i.function.arguments,parsed_arguments:Ot(u)?u.$parseRaw(i.function.arguments):u?.function.strict?JSON.parse(i.function.arguments):null})}else i.type},"_ChatCompletionStream_emitToolCallDoneEvent2"),hu=o(function(n){const s=p(this,H,"m",Kn).call(this,n);if(n.message.content&&!s.content_done){s.content_done=!0;const r=p(this,H,"m",fu).call(this);this._emit("content.done",{content:n.message.content,parsed:r?r.$parseRaw(n.message.content):null})}n.message.refusal&&!s.refusal_done&&(s.refusal_done=!0,this._emit("refusal.done",{refusal:n.message.refusal})),n.logprobs?.content&&!s.logprobs_content_done&&(s.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:n.logprobs.content})),n.logprobs?.refusal&&!s.logprobs_refusal_done&&(s.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:n.logprobs.refusal}))},"_ChatCompletionStream_emitContentDoneEvents2"),Hn=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");const n=p(this,Ce,"f");if(!n)throw new v("request ended without sending any chunks");return $(this,Ce,void 0),$(this,Xe,[]),gp(n,p(this,me,"f"))},"_ChatCompletionStream_endRequest2"),fu=o(function(){const n=p(this,me,"f")?.response_format;return eu(n)?n:null},"_ChatCompletionStream_getAutoParseableResponseFormat2"),el=o(function(n){var s,r,i,u;let a=p(this,Ce,"f");const{choices:c,...l}=n;a?Object.assign(a,l):a=$(this,Ce,{...l,choices:[]});for(const{delta:d,finish_reason:D,index:f,logprobs:h=null,...F}of n.choices){let m=a.choices[f];if(m||(m=a.choices[f]={finish_reason:D,index:f,message:{},logprobs:h,...F}),h)if(!m.logprobs)m.logprobs=Object.assign({},h);else{const{content:O,refusal:R,...L}=h;Object.assign(m.logprobs,L),O&&((s=m.logprobs).content??(s.content=[]),m.logprobs.content.push(...O)),R&&((r=m.logprobs).refusal??(r.refusal=[]),m.logprobs.refusal.push(...R))}if(D&&(m.finish_reason=D,p(this,me,"f")&&kc(p(this,me,"f")))){if(D==="length")throw new xn;if(D==="content_filter")throw new Sn}if(Object.assign(m,F),!d)continue;const{content:E,refusal:y,function_call:g,role:b,tool_calls:B,...I}=d;if(Object.assign(m.message,I),y&&(m.message.refusal=(m.message.refusal||"")+y),b&&(m.message.role=b),g&&(m.message.function_call?(g.name&&(m.message.function_call.name=g.name),g.arguments&&((i=m.message.function_call).arguments??(i.arguments=""),m.message.function_call.arguments+=g.arguments)):m.message.function_call=g),E&&(m.message.content=(m.message.content||"")+E,!m.message.refusal&&p(this,H,"m",fu).call(this)&&(m.message.parsed=Zc(m.message.content))),B){m.message.tool_calls||(m.message.tool_calls=[]);for(const{index:O,id:R,type:L,function:z,...U}of B){const W=(u=m.message.tool_calls)[O]??(u[O]={});Object.assign(W,U),R&&(W.id=R),L&&(W.type=L),z&&(W.function??(W.function={name:z.name??"",arguments:""})),z?.name&&(W.function.name=z.name),z?.arguments&&(W.function.arguments+=z.arguments,Dp(p(this,me,"f"),W)&&(W.function.parsed_arguments=Zc(W.function.arguments)))}}}return a},"_ChatCompletionStream_accumulateChatCompletion2"),Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("chunk",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};o(Qt,"ChatCompletionStream");let zn=Qt;function gp(e,t){const{id:n,choices:s,created:r,model:i,system_fingerprint:u,...a}=e,c={...a,id:n,choices:s.map(({message:l,finish_reason:d,index:D,logprobs:f,...h})=>{if(!d)throw new v(`missing finish_reason for choice ${D}`);const{content:F=null,function_call:m,tool_calls:E,...y}=l,g=l.role;if(!g)throw new v(`missing role for choice ${D}`);if(m){const{arguments:b,name:B}=m;if(b==null)throw new v(`missing function_call.arguments for choice ${D}`);if(!B)throw new v(`missing function_call.name for choice ${D}`);return{...h,message:{content:F,function_call:{arguments:b,name:B},role:g,refusal:l.refusal??null},finish_reason:d,index:D,logprobs:f}}return E?{...h,index:D,finish_reason:d,logprobs:f,message:{...y,role:g,content:F,refusal:l.refusal??null,tool_calls:E.map((b,B)=>{const{function:I,type:O,id:R,...L}=b,{arguments:z,name:U,...W}=I||{};if(R==null)throw new v(`missing choices[${D}].tool_calls[${B}].id
95
+ ${Vn(e)}`);if(O==null)throw new v(`missing choices[${D}].tool_calls[${B}].type
96
+ ${Vn(e)}`);if(U==null)throw new v(`missing choices[${D}].tool_calls[${B}].function.name
97
+ ${Vn(e)}`);if(z==null)throw new v(`missing choices[${D}].tool_calls[${B}].function.arguments
98
+ ${Vn(e)}`);return{...L,id:R,type:O,function:{...W,name:U,arguments:z}}})}}:{...h,message:{...y,content:F,role:g,refusal:l.refusal??null},finish_reason:d,index:D,logprobs:f}}),created:r,model:i,object:"chat.completion",...u?{system_fingerprint:u}:{}};return ap(c,t)}o(gp,"finalizeChatCompletion");function Vn(e){return JSON.stringify(e)}o(Vn,"str");function Om(e){}o(Om,"assertNever");const Zt=class Zt extends zn{static fromReadableStream(t){const n=new Zt(null);return n._run(()=>n._fromReadableStream(t)),n}static runTools(t,n,s){const r=new Zt(n),i={...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"runTools"}};return r._run(()=>r._runTools(t,n,i)),r}};o(Zt,"ChatCompletionStreamingRunner");let pu=Zt,mu=(at=class extends A{constructor(){super(...arguments),this.messages=new Rc(this._client)}create(t,n){return this._client.post("/chat/completions",{body:t,...n,stream:t.stream??!1})}retrieve(t,n){return this._client.get(C`/chat/completions/${t}`,n)}update(t,n,s){return this._client.post(C`/chat/completions/${t}`,{body:n,...s})}list(t={},n){return this._client.getAPIList("/chat/completions",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/chat/completions/${t}`,n)}parse(t,n){return dp(t.tools),this._client.chat.completions.create(t,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"chat.completions.parse"}})._thenUnwrap(s=>tu(s,t))}runTools(t,n){return t.stream?pu.runTools(this._client,t,n):ou.runTools(this._client,t,n)}stream(t,n){return zn.createChatCompletion(this._client,t,n)}},o(at,"Completions"),at);mu.Messages=Rc;const oi=class oi extends A{constructor(){super(...arguments),this.completions=new mu(this._client)}};o(oi,"Chat");let Mt=oi;Mt.Completions=mu;const tl=Symbol("brand.privateNullableHeaders");function*Cp(e){if(!e)return;if(tl in e){const{values:s,nulls:r}=e;yield*s.entries();for(const i of r)yield[i,null];return}let t=!1,n;e instanceof Headers?n=e.entries():nc(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let s of n){const r=s[0];if(typeof r!="string")throw new TypeError("expected header name to be a string");const i=nc(s[1])?s[1]:[s[1]];let u=!1;for(const a of i)a!==void 0&&(t&&!u&&(u=!0,yield[r,null]),yield[r,a])}}o(Cp,"iterateHeaders");const _=o(e=>{const t=new Headers,n=new Set;for(const s of e){const r=new Set;for(const[i,u]of Cp(s)){const a=i.toLowerCase();r.has(a)||(t.delete(i),r.add(a)),u===null?(t.delete(i),n.add(a)):(t.append(i,u),n.delete(a))}}return{[tl]:!0,values:t,nulls:n}},"buildHeaders"),ai=class ai extends A{create(t,n){return this._client.post("/audio/speech",{body:t,...n,headers:_([{Accept:"application/octet-stream"},n?.headers]),__binaryResponse:!0})}};o(ai,"Speech");let Jn=ai;const ci=class ci extends A{create(t,n){return this._client.post("/audio/transcriptions",Se({body:t,...n,stream:t.stream??!1,__metadata:{model:t.model}},this._client))}};o(ci,"Transcriptions");let Xn=ci;const li=class li extends A{create(t,n){return this._client.post("/audio/translations",Se({body:t,...n,__metadata:{model:t.model}},this._client))}};o(li,"Translations");let Yn=li;const Di=class Di extends A{constructor(){super(...arguments),this.transcriptions=new Xn(this._client),this.translations=new Yn(this._client),this.speech=new Jn(this._client)}};o(Di,"Audio");let Ie=Di;Ie.Transcriptions=Xn,Ie.Translations=Yn,Ie.Speech=Jn;const di=class di extends A{create(t,n){return this._client.post("/batches",{body:t,...n})}retrieve(t,n){return this._client.get(C`/batches/${t}`,n)}list(t={},n){return this._client.getAPIList("/batches",M,{query:t,...n})}cancel(t,n){return this._client.post(C`/batches/${t}/cancel`,n)}};o(di,"Batches");let Qn=di;const hi=class hi extends A{create(t,n){return this._client.post("/assistants",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/assistants/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/assistants/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t={},n){return this._client.getAPIList("/assistants",M,{query:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,n){return this._client.delete(C`/assistants/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};o(hi,"Assistants");let Zn=hi,nl=(ct=class extends A{create(t,n){return this._client.post("/realtime/sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}},o(ct,"Sessions"),ct);const fi=class fi extends A{create(t,n){return this._client.post("/realtime/transcription_sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}};o(fi,"TranscriptionSessions");let es=fi,ts=(lt=class extends A{constructor(){super(...arguments),this.sessions=new nl(this._client),this.transcriptionSessions=new es(this._client)}},o(lt,"Realtime"),lt);ts.Sessions=nl,ts.TranscriptionSessions=es;const pi=class pi extends A{create(t,n){return this._client.post("/chatkit/sessions",{body:t,...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}cancel(t,n){return this._client.post(C`/chatkit/sessions/${t}/cancel`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}};o(pi,"Sessions");let ns=pi,sl=(Dt=class extends A{retrieve(t,n){return this._client.get(C`/chatkit/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}list(t={},n){return this._client.getAPIList("/chatkit/threads",Ve,{query:t,...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}delete(t,n){return this._client.delete(C`/chatkit/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},n?.headers])})}listItems(t,n={},s){return this._client.getAPIList(C`/chatkit/threads/${t}/items`,Ve,{query:n,...s,headers:_([{"OpenAI-Beta":"chatkit_beta=v1"},s?.headers])})}},o(Dt,"Threads"),Dt);const mi=class mi extends A{constructor(){super(...arguments),this.sessions=new ns(this._client),this.threads=new sl(this._client)}};o(mi,"ChatKit");let Ye=mi;Ye.Sessions=ns,Ye.Threads=sl;const Fi=class Fi extends A{create(t,n,s){return this._client.post(C`/threads/${t}/messages`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{thread_id:r}=n;return this._client.get(C`/threads/${r}/messages/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/messages/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/threads/${t}/messages`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n,s){const{thread_id:r}=n;return this._client.delete(C`/threads/${r}/messages/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Fi,"Messages");let ss=Fi;const gi=class gi extends A{retrieve(t,n,s){const{thread_id:r,run_id:i,...u}=n;return this._client.get(C`/threads/${r}/runs/${i}/steps/${t}`,{query:u,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n,s){const{thread_id:r,...i}=n;return this._client.getAPIList(C`/threads/${r}/runs/${t}/steps`,M,{query:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(gi,"Steps");let rs=gi;const Ep=o(e=>{if(typeof Buffer<"u"){const t=Buffer.from(e,"base64");return Array.from(new Float32Array(t.buffer,t.byteOffset,t.length/Float32Array.BYTES_PER_ELEMENT))}else{const t=atob(e),n=t.length,s=new Uint8Array(n);for(let r=0;r<n;r++)s[r]=t.charCodeAt(r);return Array.from(new Float32Array(s.buffer))}},"toFloat32Array"),Qe=o(e=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()??void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()},"readEnv");var Y,Oe,Fu,fe,us,ce,Re,Ze,ke,is,oe,os,as,Lt,jt,Ut,rl,ul,il,ol,al,cl,ll;const Ci=class Ci extends Nt{constructor(){super(...arguments),Y.add(this),Fu.set(this,[]),fe.set(this,{}),us.set(this,{}),ce.set(this,void 0),Re.set(this,void 0),Ze.set(this,void 0),ke.set(this,void 0),is.set(this,void 0),oe.set(this,void 0),os.set(this,void 0),as.set(this,void 0),Lt.set(this,void 0)}[(Fu=new WeakMap,fe=new WeakMap,us=new WeakMap,ce=new WeakMap,Re=new WeakMap,Ze=new WeakMap,ke=new WeakMap,is=new WeakMap,oe=new WeakMap,os=new WeakMap,as=new WeakMap,Lt=new WeakMap,Y=new WeakSet,Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("event",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}static fromReadableStream(t){const n=new Oe;return n._run(()=>n._fromReadableStream(t)),n}async _fromReadableStream(t,n){const s=n?.signal;s&&(s.aborted&&this.controller.abort(),s.addEventListener("abort",()=>this.controller.abort())),this._connected();const r=xe.fromReadableStream(t,this.controller);for await(const i of r)p(this,Y,"m",jt).call(this,i);if(r.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",Ut).call(this))}toReadableStream(){return new xe(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(t,n,s,r){const i=new Oe;return i._run(()=>i._runToolAssistantStream(t,n,s,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}async _createToolAssistantStream(t,n,s,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const u={...s,stream:!0},a=await t.submitToolOutputs(n,u,{...r,signal:this.controller.signal});this._connected();for await(const c of a)p(this,Y,"m",jt).call(this,c);if(a.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",Ut).call(this))}static createThreadAssistantStream(t,n,s){const r=new Oe;return r._run(()=>r._threadAssistantStream(t,n,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}static createAssistantStream(t,n,s,r){const i=new Oe;return i._run(()=>i._runAssistantStream(t,n,s,{...r,headers:{...r?.headers,"X-Stainless-Helper-Method":"stream"}})),i}currentEvent(){return p(this,os,"f")}currentRun(){return p(this,as,"f")}currentMessageSnapshot(){return p(this,ce,"f")}currentRunStepSnapshot(){return p(this,Lt,"f")}async finalRunSteps(){return await this.done(),Object.values(p(this,fe,"f"))}async finalMessages(){return await this.done(),Object.values(p(this,us,"f"))}async finalRun(){if(await this.done(),!p(this,Re,"f"))throw Error("Final run was not received.");return p(this,Re,"f")}async _createThreadAssistantStream(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort()));const i={...n,stream:!0},u=await t.createAndRun(i,{...s,signal:this.controller.signal});this._connected();for await(const a of u)p(this,Y,"m",jt).call(this,a);if(u.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",Ut).call(this))}async _createAssistantStream(t,n,s,r){const i=r?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",()=>this.controller.abort()));const u={...s,stream:!0},a=await t.create(n,u,{...r,signal:this.controller.signal});this._connected();for await(const c of a)p(this,Y,"m",jt).call(this,c);if(a.controller.signal?.aborted)throw new ne;return this._addRun(p(this,Y,"m",Ut).call(this))}static accumulateDelta(t,n){for(const[s,r]of Object.entries(n)){if(!t.hasOwnProperty(s)){t[s]=r;continue}let i=t[s];if(i==null){t[s]=r;continue}if(s==="index"||s==="type"){t[s]=r;continue}if(typeof i=="string"&&typeof r=="string")i+=r;else if(typeof i=="number"&&typeof r=="number")i+=r;else if(qr(i)&&qr(r))i=this.accumulateDelta(i,r);else if(Array.isArray(i)&&Array.isArray(r)){if(i.every(u=>typeof u=="string"||typeof u=="number")){i.push(...r);continue}for(const u of r){if(!qr(u))throw new Error(`Expected array delta entry to be an object but got: ${u}`);const a=u.index;if(a==null)throw console.error(u),new Error("Expected array delta entry to have an `index` property");if(typeof a!="number")throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);const c=i[a];c==null?i.push(u):i[a]=this.accumulateDelta(c,u)}continue}else throw Error(`Unhandled record type: ${s}, deltaValue: ${r}, accValue: ${i}`);t[s]=i}return t}_addRun(t){return t}async _threadAssistantStream(t,n,s){return await this._createThreadAssistantStream(n,t,s)}async _runAssistantStream(t,n,s,r){return await this._createAssistantStream(n,t,s,r)}async _runToolAssistantStream(t,n,s,r){return await this._createToolAssistantStream(n,t,s,r)}};o(Ci,"AssistantStream");let Pe=Ci;Oe=Pe,jt=o(function(t){if(!this.ended)switch($(this,os,t),p(this,Y,"m",il).call(this,t),t.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.incomplete":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":p(this,Y,"m",ll).call(this,t);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":p(this,Y,"m",ul).call(this,t);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":p(this,Y,"m",rl).call(this,t);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},"_AssistantStream_addEvent2"),Ut=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");if(!p(this,Re,"f"))throw Error("Final run has not been received");return p(this,Re,"f")},"_AssistantStream_endRequest2"),rl=o(function(t){const[n,s]=p(this,Y,"m",al).call(this,t,p(this,ce,"f"));$(this,ce,n),p(this,us,"f")[n.id]=n;for(const r of s){const i=n.content[r.index];i?.type=="text"&&this._emit("textCreated",i.text)}switch(t.event){case"thread.message.created":this._emit("messageCreated",t.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",t.data.delta,n),t.data.delta.content)for(const r of t.data.delta.content){if(r.type=="text"&&r.text){let i=r.text,u=n.content[r.index];if(u&&u.type=="text")this._emit("textDelta",i,u.text);else throw Error("The snapshot associated with this text delta is not text or missing")}if(r.index!=p(this,Ze,"f")){if(p(this,ke,"f"))switch(p(this,ke,"f").type){case"text":this._emit("textDone",p(this,ke,"f").text,p(this,ce,"f"));break;case"image_file":this._emit("imageFileDone",p(this,ke,"f").image_file,p(this,ce,"f"));break}$(this,Ze,r.index)}$(this,ke,n.content[r.index])}break;case"thread.message.completed":case"thread.message.incomplete":if(p(this,Ze,"f")!==void 0){const r=t.data.content[p(this,Ze,"f")];if(r)switch(r.type){case"image_file":this._emit("imageFileDone",r.image_file,p(this,ce,"f"));break;case"text":this._emit("textDone",r.text,p(this,ce,"f"));break}}p(this,ce,"f")&&this._emit("messageDone",t.data),$(this,ce,void 0)}},"_AssistantStream_handleMessage2"),ul=o(function(t){const n=p(this,Y,"m",ol).call(this,t);switch($(this,Lt,n),t.event){case"thread.run.step.created":this._emit("runStepCreated",t.data);break;case"thread.run.step.delta":const s=t.data.delta;if(s.step_details&&s.step_details.type=="tool_calls"&&s.step_details.tool_calls&&n.step_details.type=="tool_calls")for(const i of s.step_details.tool_calls)i.index==p(this,is,"f")?this._emit("toolCallDelta",i,n.step_details.tool_calls[i.index]):(p(this,oe,"f")&&this._emit("toolCallDone",p(this,oe,"f")),$(this,is,i.index),$(this,oe,n.step_details.tool_calls[i.index]),p(this,oe,"f")&&this._emit("toolCallCreated",p(this,oe,"f")));this._emit("runStepDelta",t.data.delta,n);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":$(this,Lt,void 0),t.data.step_details.type=="tool_calls"&&p(this,oe,"f")&&(this._emit("toolCallDone",p(this,oe,"f")),$(this,oe,void 0)),this._emit("runStepDone",t.data,n);break}},"_AssistantStream_handleRunStep2"),il=o(function(t){p(this,Fu,"f").push(t),this._emit("event",t)},"_AssistantStream_handleEvent2"),ol=o(function(t){switch(t.event){case"thread.run.step.created":return p(this,fe,"f")[t.data.id]=t.data,t.data;case"thread.run.step.delta":let n=p(this,fe,"f")[t.data.id];if(!n)throw Error("Received a RunStepDelta before creation of a snapshot");let s=t.data;if(s.delta){const r=Oe.accumulateDelta(n,s.delta);p(this,fe,"f")[t.data.id]=r}return p(this,fe,"f")[t.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":p(this,fe,"f")[t.data.id]=t.data;break}if(p(this,fe,"f")[t.data.id])return p(this,fe,"f")[t.data.id];throw new Error("No snapshot available")},"_AssistantStream_accumulateRunStep2"),al=o(function(t,n){let s=[];switch(t.event){case"thread.message.created":return[t.data,s];case"thread.message.delta":if(!n)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let r=t.data;if(r.delta.content)for(const i of r.delta.content)if(i.index in n.content){let u=n.content[i.index];n.content[i.index]=p(this,Y,"m",cl).call(this,i,u)}else n.content[i.index]=i,s.push(i);return[n,s];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(n)return[n,s];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},"_AssistantStream_accumulateMessage2"),cl=o(function(t,n){return Oe.accumulateDelta(n,t)},"_AssistantStream_accumulateContent2"),ll=o(function(t){switch($(this,as,t.data),t.event){case"thread.run.created":break;case"thread.run.queued":break;case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":case"thread.run.incomplete":$(this,Re,t.data),p(this,oe,"f")&&(this._emit("toolCallDone",p(this,oe,"f")),$(this,oe,void 0));break}},"_AssistantStream_handleRun2");let gu=(dt=class extends A{constructor(){super(...arguments),this.steps=new rs(this._client)}create(t,n,s){const{include:r,...i}=n;return this._client.post(C`/threads/${t}/runs`,{query:{include:r},body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:n.stream??!1})}retrieve(t,n,s){const{thread_id:r}=n;return this._client.get(C`/threads/${r}/runs/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/runs/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/threads/${t}/runs`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(t,n,s){const{thread_id:r}=n;return this._client.post(C`/threads/${r}/runs/${t}/cancel`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n,s);return await this.poll(r.id,{thread_id:t},s)}createAndStream(t,n,s){return Pe.createAssistantStream(t,this._client.beta.threads.runs,n,s)}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:i,response:u}=await this.retrieve(t,n,{...s,headers:{...s?.headers,...r}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=u.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await At(a);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(t,n,s){return Pe.createAssistantStream(t,this._client.beta.threads.runs,n,s)}submitToolOutputs(t,n,s){const{thread_id:r,...i}=n;return this._client.post(C`/threads/${r}/runs/${t}/submit_tool_outputs`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers]),stream:n.stream??!1})}async submitToolOutputsAndPoll(t,n,s){const r=await this.submitToolOutputs(t,n,s);return await this.poll(r.id,n,s)}submitToolOutputsStream(t,n,s){return Pe.createToolAssistantStream(t,this._client.beta.threads.runs,n,s)}},o(dt,"Runs"),dt);gu.Steps=rs;const Ei=class Ei extends A{constructor(){super(...arguments),this.runs=new gu(this._client),this.messages=new ss(this._client)}create(t={},n){return this._client.post("/threads",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/threads/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n){return this._client.delete(C`/threads/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}createAndRun(t,n){return this._client.post("/threads/runs",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers]),stream:t.stream??!1})}async createAndRunPoll(t,n){const s=await this.createAndRun(t,n);return await this.runs.poll(s.id,{thread_id:s.thread_id},n)}createAndRunStream(t,n){return Pe.createThreadAssistantStream(t,this._client.beta.threads,n)}};o(Ei,"Threads");let et=Ei;et.Runs=gu,et.Messages=ss;const yi=class yi extends A{constructor(){super(...arguments),this.realtime=new ts(this._client),this.chatkit=new Ye(this._client),this.assistants=new Zn(this._client),this.threads=new et(this._client)}};o(yi,"Beta");let Ee=yi;Ee.Realtime=ts,Ee.ChatKit=Ye,Ee.Assistants=Zn,Ee.Threads=et;const wi=class wi extends A{create(t,n){return this._client.post("/completions",{body:t,...n,stream:t.stream??!1})}};o(wi,"Completions");let cs=wi;const bi=class bi extends A{retrieve(t,n,s){const{container_id:r}=n;return this._client.get(C`/containers/${r}/files/${t}/content`,{...s,headers:_([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}};o(bi,"Content");let ls=bi,Cu=(ht=class extends A{constructor(){super(...arguments),this.content=new ls(this._client)}create(t,n,s){return this._client.post(C`/containers/${t}/files`,Se({body:n,...s},this._client))}retrieve(t,n,s){const{container_id:r}=n;return this._client.get(C`/containers/${r}/files/${t}`,s)}list(t,n={},s){return this._client.getAPIList(C`/containers/${t}/files`,M,{query:n,...s})}delete(t,n,s){const{container_id:r}=n;return this._client.delete(C`/containers/${r}/files/${t}`,{...s,headers:_([{Accept:"*/*"},s?.headers])})}},o(ht,"Files"),ht);Cu.Content=ls;const _i=class _i extends A{constructor(){super(...arguments),this.files=new Cu(this._client)}create(t,n){return this._client.post("/containers",{body:t,...n})}retrieve(t,n){return this._client.get(C`/containers/${t}`,n)}list(t={},n){return this._client.getAPIList("/containers",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/containers/${t}`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}};o(_i,"Containers");let Wt=_i;Wt.Files=Cu;const Bi=class Bi extends A{create(t,n,s){const{include:r,...i}=n;return this._client.post(C`/conversations/${t}/items`,{query:{include:r},body:i,...s})}retrieve(t,n,s){const{conversation_id:r,...i}=n;return this._client.get(C`/conversations/${r}/items/${t}`,{query:i,...s})}list(t,n={},s){return this._client.getAPIList(C`/conversations/${t}/items`,Ve,{query:n,...s})}delete(t,n,s){const{conversation_id:r}=n;return this._client.delete(C`/conversations/${r}/items/${t}`,s)}};o(Bi,"Items");let Ds=Bi;const Ai=class Ai extends A{constructor(){super(...arguments),this.items=new Ds(this._client)}create(t={},n){return this._client.post("/conversations",{body:t,...n})}retrieve(t,n){return this._client.get(C`/conversations/${t}`,n)}update(t,n,s){return this._client.post(C`/conversations/${t}`,{body:n,...s})}delete(t,n){return this._client.delete(C`/conversations/${t}`,n)}};o(Ai,"Conversations");let qt=Ai;qt.Items=Ds;const vi=class vi extends A{create(t,n){const s=!!t.encoding_format;let r=s?t.encoding_format:"base64";s&&X(this._client).debug("embeddings/user defined encoding_format:",t.encoding_format);const i=this._client.post("/embeddings",{body:{...t,encoding_format:r},...n});return s?i:(X(this._client).debug("embeddings/decoding base64 embeddings from base64"),i._thenUnwrap(u=>(u&&u.data&&u.data.forEach(a=>{const c=a.embedding;a.embedding=Ep(c)}),u)))}};o(vi,"Embeddings");let ds=vi;const $i=class $i extends A{retrieve(t,n,s){const{eval_id:r,run_id:i}=n;return this._client.get(C`/evals/${r}/runs/${i}/output_items/${t}`,s)}list(t,n,s){const{eval_id:r,...i}=n;return this._client.getAPIList(C`/evals/${r}/runs/${t}/output_items`,M,{query:i,...s})}};o($i,"OutputItems");let hs=$i;const xi=class xi extends A{constructor(){super(...arguments),this.outputItems=new hs(this._client)}create(t,n,s){return this._client.post(C`/evals/${t}/runs`,{body:n,...s})}retrieve(t,n,s){const{eval_id:r}=n;return this._client.get(C`/evals/${r}/runs/${t}`,s)}list(t,n={},s){return this._client.getAPIList(C`/evals/${t}/runs`,M,{query:n,...s})}delete(t,n,s){const{eval_id:r}=n;return this._client.delete(C`/evals/${r}/runs/${t}`,s)}cancel(t,n,s){const{eval_id:r}=n;return this._client.post(C`/evals/${r}/runs/${t}`,s)}};o(xi,"Runs");let Gt=xi;Gt.OutputItems=hs;const Si=class Si extends A{constructor(){super(...arguments),this.runs=new Gt(this._client)}create(t,n){return this._client.post("/evals",{body:t,...n})}retrieve(t,n){return this._client.get(C`/evals/${t}`,n)}update(t,n,s){return this._client.post(C`/evals/${t}`,{body:n,...s})}list(t={},n){return this._client.getAPIList("/evals",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/evals/${t}`,n)}};o(Si,"Evals");let Kt=Si;Kt.Runs=Gt;let Dl=(ft=class extends A{create(t,n){return this._client.post("/files",Se({body:t,...n},this._client))}retrieve(t,n){return this._client.get(C`/files/${t}`,n)}list(t={},n){return this._client.getAPIList("/files",M,{query:t,...n})}delete(t,n){return this._client.delete(C`/files/${t}`,n)}content(t,n){return this._client.get(C`/files/${t}/content`,{...n,headers:_([{Accept:"application/binary"},n?.headers]),__binaryResponse:!0})}async waitForProcessing(t,{pollInterval:n=5e3,maxWait:s=1800*1e3}={}){const r=new Set(["processed","error","deleted"]),i=Date.now();let u=await this.retrieve(t);for(;!u.status||!r.has(u.status);)if(await At(n),u=await this.retrieve(t),Date.now()-i>s)throw new Bt({message:`Giving up on waiting for file ${t} to finish processing after ${s} milliseconds.`});return u}},o(ft,"Files"),ft);const Ii=class Ii extends A{};o(Ii,"Methods");let fs=Ii,dl=(pt=class extends A{run(t,n){return this._client.post("/fine_tuning/alpha/graders/run",{body:t,...n})}validate(t,n){return this._client.post("/fine_tuning/alpha/graders/validate",{body:t,...n})}},o(pt,"Graders"),pt);const Oi=class Oi extends A{constructor(){super(...arguments),this.graders=new dl(this._client)}};o(Oi,"Alpha");let Ht=Oi;Ht.Graders=dl;const Ri=class Ri extends A{create(t,n,s){return this._client.getAPIList(C`/fine_tuning/checkpoints/${t}/permissions`,ze,{body:n,method:"post",...s})}retrieve(t,n={},s){return this._client.get(C`/fine_tuning/checkpoints/${t}/permissions`,{query:n,...s})}delete(t,n,s){const{fine_tuned_model_checkpoint:r}=n;return this._client.delete(C`/fine_tuning/checkpoints/${r}/permissions/${t}`,s)}};o(Ri,"Permissions");let ps=Ri,Eu=(mt=class extends A{constructor(){super(...arguments),this.permissions=new ps(this._client)}},o(mt,"Checkpoints"),mt);Eu.Permissions=ps;const ki=class ki extends A{list(t,n={},s){return this._client.getAPIList(C`/fine_tuning/jobs/${t}/checkpoints`,M,{query:n,...s})}};o(ki,"Checkpoints");let ms=ki;const Pi=class Pi extends A{constructor(){super(...arguments),this.checkpoints=new ms(this._client)}create(t,n){return this._client.post("/fine_tuning/jobs",{body:t,...n})}retrieve(t,n){return this._client.get(C`/fine_tuning/jobs/${t}`,n)}list(t={},n){return this._client.getAPIList("/fine_tuning/jobs",M,{query:t,...n})}cancel(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/cancel`,n)}listEvents(t,n={},s){return this._client.getAPIList(C`/fine_tuning/jobs/${t}/events`,M,{query:n,...s})}pause(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/pause`,n)}resume(t,n){return this._client.post(C`/fine_tuning/jobs/${t}/resume`,n)}};o(Pi,"Jobs");let zt=Pi;zt.Checkpoints=ms;const Ti=class Ti extends A{constructor(){super(...arguments),this.methods=new fs(this._client),this.jobs=new zt(this._client),this.checkpoints=new Eu(this._client),this.alpha=new Ht(this._client)}};o(Ti,"FineTuning");let ye=Ti;ye.Methods=fs,ye.Jobs=zt,ye.Checkpoints=Eu,ye.Alpha=Ht;const Ni=class Ni extends A{};o(Ni,"GraderModels");let Fs=Ni;const Mi=class Mi extends A{constructor(){super(...arguments),this.graderModels=new Fs(this._client)}};o(Mi,"Graders");let Vt=Mi;Vt.GraderModels=Fs;const Li=class Li extends A{createVariation(t,n){return this._client.post("/images/variations",Se({body:t,...n},this._client))}edit(t,n){return this._client.post("/images/edits",Se({body:t,...n,stream:t.stream??!1},this._client))}generate(t,n){return this._client.post("/images/generations",{body:t,...n,stream:t.stream??!1})}};o(Li,"Images");let gs=Li;const ji=class ji extends A{retrieve(t,n){return this._client.get(C`/models/${t}`,n)}list(t){return this._client.getAPIList("/models",ze,t)}delete(t,n){return this._client.delete(C`/models/${t}`,n)}};o(ji,"Models");let Cs=ji;const Ui=class Ui extends A{create(t,n){return this._client.post("/moderations",{body:t,...n})}};o(Ui,"Moderations");let Es=Ui;const Wi=class Wi extends A{accept(t,n,s){return this._client.post(C`/realtime/calls/${t}/accept`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}hangup(t,n){return this._client.post(C`/realtime/calls/${t}/hangup`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}refer(t,n,s){return this._client.post(C`/realtime/calls/${t}/refer`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}reject(t,n={},s){return this._client.post(C`/realtime/calls/${t}/reject`,{body:n,...s,headers:_([{Accept:"*/*"},s?.headers])})}};o(Wi,"Calls");let ys=Wi;const qi=class qi extends A{create(t,n){return this._client.post("/realtime/client_secrets",{body:t,...n})}};o(qi,"ClientSecrets");let ws=qi;const Gi=class Gi extends A{constructor(){super(...arguments),this.clientSecrets=new ws(this._client),this.calls=new ys(this._client)}};o(Gi,"Realtime");let tt=Gi;tt.ClientSecrets=ws,tt.Calls=ys;function yp(e,t){return!t||!bp(t)?{...e,output_parsed:null,output:e.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:n.type==="message"?{...n,content:n.content.map(s=>({...s,parsed:null}))}:n)}:hl(e,t)}o(yp,"maybeParseResponse");function hl(e,t){const n=e.output.map(r=>{if(r.type==="function_call")return{...r,parsed_arguments:Ap(t,r)};if(r.type==="message"){const i=r.content.map(u=>u.type==="output_text"?{...u,parsed:wp(t,u.text)}:u);return{...r,content:i}}return r}),s=Object.assign({},e,{output:n});return Object.getOwnPropertyDescriptor(e,"output_text")||yu(s),Object.defineProperty(s,"output_parsed",{enumerable:!0,get(){for(const r of s.output)if(r.type==="message"){for(const i of r.content)if(i.type==="output_text"&&i.parsed!==null)return i.parsed}return null}}),s}o(hl,"parseResponse");function wp(e,t){return e.text?.format?.type!=="json_schema"?null:"$parseRaw"in e.text?.format?(e.text?.format).$parseRaw(t):JSON.parse(t)}o(wp,"parseTextFormat");function bp(e){return!!eu(e.text?.format)}o(bp,"hasAutoParseableInput");function _p(e){return e?.$brand==="auto-parseable-tool"}o(_p,"isAutoParsableTool");function Bp(e,t){return e.find(n=>n.type==="function"&&n.name===t)}o(Bp,"getInputToolByName");function Ap(e,t){const n=Bp(e.tools??[],t.name);return{...t,...t,parsed_arguments:_p(n)?n.$parseRaw(t.arguments):n?.strict?JSON.parse(t.arguments):null}}o(Ap,"parseToolCall");function yu(e){const t=[];for(const n of e.output)if(n.type==="message")for(const s of n.content)s.type==="output_text"&&t.push(s.text);e.output_text=t.join("")}o(yu,"addOutputText");var nt,bs,we,_s,fl,pl,ml,Fl;const Ms=class Ms extends Nt{constructor(t){super(),nt.add(this),bs.set(this,void 0),we.set(this,void 0),_s.set(this,void 0),$(this,bs,t)}static createResponse(t,n,s){const r=new Ms(n);return r._run(()=>r._createOrRetrieveResponse(t,n,{...s,headers:{...s?.headers,"X-Stainless-Helper-Method":"stream"}})),r}async _createOrRetrieveResponse(t,n,s){const r=s?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",()=>this.controller.abort())),p(this,nt,"m",fl).call(this);let i,u=null;"response_id"in n?(i=await t.responses.retrieve(n.response_id,{stream:!0},{...s,signal:this.controller.signal,stream:!0}),u=n.starting_after??null):i=await t.responses.create({...n,stream:!0},{...s,signal:this.controller.signal}),this._connected();for await(const a of i)p(this,nt,"m",pl).call(this,a,u);if(i.controller.signal?.aborted)throw new ne;return p(this,nt,"m",ml).call(this)}[(bs=new WeakMap,we=new WeakMap,_s=new WeakMap,nt=new WeakSet,fl=o(function(){this.ended||$(this,we,void 0)},"_ResponseStream_beginRequest2"),pl=o(function(n,s){if(this.ended)return;const r=o((u,a)=>{(s==null||a.sequence_number>s)&&this._emit(u,a)},"maybeEmit"),i=p(this,nt,"m",Fl).call(this,n);switch(r("event",n),n.type){case"response.output_text.delta":{const u=i.output[n.output_index];if(!u)throw new v(`missing output at index ${n.output_index}`);if(u.type==="message"){const a=u.content[n.content_index];if(!a)throw new v(`missing content at index ${n.content_index}`);if(a.type!=="output_text")throw new v(`expected content to be 'output_text', got ${a.type}`);r("response.output_text.delta",{...n,snapshot:a.text})}break}case"response.function_call_arguments.delta":{const u=i.output[n.output_index];if(!u)throw new v(`missing output at index ${n.output_index}`);u.type==="function_call"&&r("response.function_call_arguments.delta",{...n,snapshot:u.arguments});break}default:r(n.type,n);break}},"_ResponseStream_addEvent2"),ml=o(function(){if(this.ended)throw new v("stream has ended, this shouldn't happen");const n=p(this,we,"f");if(!n)throw new v("request ended without sending any events");$(this,we,void 0);const s=vp(n,p(this,bs,"f"));return $(this,_s,s),s},"_ResponseStream_endRequest2"),Fl=o(function(n){let s=p(this,we,"f");if(!s){if(n.type!=="response.created")throw new v(`When snapshot hasn't been set yet, expected 'response.created' event, got ${n.type}`);return s=$(this,we,n.response),s}switch(n.type){case"response.output_item.added":{s.output.push(n.item);break}case"response.content_part.added":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);const i=r.type,u=n.part;i==="message"&&u.type!=="reasoning_text"?r.content.push(u):i==="reasoning"&&u.type==="reasoning_text"&&(r.content||(r.content=[]),r.content.push(u));break}case"response.output_text.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);if(r.type==="message"){const i=r.content[n.content_index];if(!i)throw new v(`missing content at index ${n.content_index}`);if(i.type!=="output_text")throw new v(`expected content to be 'output_text', got ${i.type}`);i.text+=n.delta}break}case"response.function_call_arguments.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);r.type==="function_call"&&(r.arguments+=n.delta);break}case"response.reasoning_text.delta":{const r=s.output[n.output_index];if(!r)throw new v(`missing output at index ${n.output_index}`);if(r.type==="reasoning"){const i=r.content?.[n.content_index];if(!i)throw new v(`missing content at index ${n.content_index}`);if(i.type!=="reasoning_text")throw new v(`expected content to be 'reasoning_text', got ${i.type}`);i.text+=n.delta}break}case"response.completed":{$(this,we,n.response);break}}return s},"_ResponseStream_accumulateResponse2"),Symbol.asyncIterator)](){const t=[],n=[];let s=!1;return this.on("event",r=>{const i=n.shift();i?i.resolve(r):t.push(r)}),this.on("end",()=>{s=!0;for(const r of n)r.resolve(void 0);n.length=0}),this.on("abort",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),this.on("error",r=>{s=!0;for(const i of n)i.reject(r);n.length=0}),{next:o(async()=>t.length?{value:t.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((i,u)=>n.push({resolve:i,reject:u})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),"next"),return:o(async()=>(this.abort(),{value:void 0,done:!0}),"return")}}async finalResponse(){await this.done();const t=p(this,_s,"f");if(!t)throw new v("stream ended without producing a ChatCompletion");return t}};o(Ms,"ResponseStream");let wu=Ms;function vp(e,t){return yp(e,t)}o(vp,"finalizeResponse");const Ki=class Ki extends A{list(t,n={},s){return this._client.getAPIList(C`/responses/${t}/input_items`,M,{query:n,...s})}};o(Ki,"InputItems");let Bs=Ki;const Hi=class Hi extends A{count(t={},n){return this._client.post("/responses/input_tokens",{body:t,...n})}};o(Hi,"InputTokens");let As=Hi;const zi=class zi extends A{constructor(){super(...arguments),this.inputItems=new Bs(this._client),this.inputTokens=new As(this._client)}create(t,n){return this._client.post("/responses",{body:t,...n,stream:t.stream??!1})._thenUnwrap(s=>("object"in s&&s.object==="response"&&yu(s),s))}retrieve(t,n={},s){return this._client.get(C`/responses/${t}`,{query:n,...s,stream:n?.stream??!1})._thenUnwrap(r=>("object"in r&&r.object==="response"&&yu(r),r))}delete(t,n){return this._client.delete(C`/responses/${t}`,{...n,headers:_([{Accept:"*/*"},n?.headers])})}parse(t,n){return this._client.responses.create(t,n)._thenUnwrap(s=>hl(s,t))}stream(t,n){return wu.createResponse(this._client,t,n)}cancel(t,n){return this._client.post(C`/responses/${t}/cancel`,n)}};o(zi,"Responses");let st=zi;st.InputItems=Bs,st.InputTokens=As;const Vi=class Vi extends A{create(t,n,s){return this._client.post(C`/uploads/${t}/parts`,Se({body:n,...s},this._client))}};o(Vi,"Parts");let vs=Vi;const Ji=class Ji extends A{constructor(){super(...arguments),this.parts=new vs(this._client)}create(t,n){return this._client.post("/uploads",{body:t,...n})}cancel(t,n){return this._client.post(C`/uploads/${t}/cancel`,n)}complete(t,n,s){return this._client.post(C`/uploads/${t}/complete`,{body:n,...s})}};o(Ji,"Uploads");let Jt=Ji;Jt.Parts=vs;const $p=o(async e=>{const t=await Promise.allSettled(e),n=t.filter(r=>r.status==="rejected");if(n.length){for(const r of n)console.error(r.reason);throw new Error(`${n.length} promise(s) failed - see the above errors`)}const s=[];for(const r of t)r.status==="fulfilled"&&s.push(r.value);return s},"allSettledWithThrow"),Xi=class Xi extends A{create(t,n,s){return this._client.post(C`/vector_stores/${t}/file_batches`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{vector_store_id:r}=n;return this._client.get(C`/vector_stores/${r}/file_batches/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}cancel(t,n,s){const{vector_store_id:r}=n;return this._client.post(C`/vector_stores/${r}/file_batches/${t}/cancel`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n);return await this.poll(t,r.id,s)}listFiles(t,n,s){const{vector_store_id:r,...i}=n;return this._client.getAPIList(C`/vector_stores/${r}/file_batches/${t}/files`,M,{query:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const{data:i,response:u}=await this.retrieve(n,{vector_store_id:t},{...s,headers:r}).withResponse();switch(i.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=u.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await At(a);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(t,{files:n,fileIds:s=[]},r){if(n==null||n.length==0)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const i=r?.maxConcurrency??5,u=Math.min(i,n.length),a=this._client,c=n.values(),l=[...s];async function d(f){for(let h of f){const F=await a.files.create({file:h,purpose:"assistants"},r);l.push(F.id)}}o(d,"processFiles");const D=Array(u).fill(c).map(d);return await $p(D),await this.createAndPoll(t,{file_ids:l})}};o(Xi,"FileBatches");let $s=Xi;const Yi=class Yi extends A{create(t,n,s){return this._client.post(C`/vector_stores/${t}/files`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}retrieve(t,n,s){const{vector_store_id:r}=n;return this._client.get(C`/vector_stores/${r}/files/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}update(t,n,s){const{vector_store_id:r,...i}=n;return this._client.post(C`/vector_stores/${r}/files/${t}`,{body:i,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t,n={},s){return this._client.getAPIList(C`/vector_stores/${t}/files`,M,{query:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}delete(t,n,s){const{vector_store_id:r}=n;return this._client.delete(C`/vector_stores/${r}/files/${t}`,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}async createAndPoll(t,n,s){const r=await this.create(t,n,s);return await this.poll(t,r.id,s)}async poll(t,n,s){const r=_([s?.headers,{"X-Stainless-Poll-Helper":"true","X-Stainless-Custom-Poll-Interval":s?.pollIntervalMs?.toString()??void 0}]);for(;;){const i=await this.retrieve(n,{vector_store_id:t},{...s,headers:r}).withResponse(),u=i.data;switch(u.status){case"in_progress":let a=5e3;if(s?.pollIntervalMs)a=s.pollIntervalMs;else{const c=i.response.headers.get("openai-poll-after-ms");if(c){const l=parseInt(c);isNaN(l)||(a=l)}}await At(a);break;case"failed":case"completed":return u}}}async upload(t,n,s){const r=await this._client.files.create({file:n,purpose:"assistants"},s);return this.create(t,{file_id:r.id},s)}async uploadAndPoll(t,n,s){const r=await this.upload(t,n,s);return await this.poll(t,r.id,s)}content(t,n,s){const{vector_store_id:r}=n;return this._client.getAPIList(C`/vector_stores/${r}/files/${t}/content`,ze,{...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Yi,"Files");let xs=Yi;const Qi=class Qi extends A{constructor(){super(...arguments),this.files=new xs(this._client),this.fileBatches=new $s(this._client)}create(t,n){return this._client.post("/vector_stores",{body:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}retrieve(t,n){return this._client.get(C`/vector_stores/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}update(t,n,s){return this._client.post(C`/vector_stores/${t}`,{body:n,...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}list(t={},n){return this._client.getAPIList("/vector_stores",M,{query:t,...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}delete(t,n){return this._client.delete(C`/vector_stores/${t}`,{...n,headers:_([{"OpenAI-Beta":"assistants=v2"},n?.headers])})}search(t,n,s){return this._client.getAPIList(C`/vector_stores/${t}/search`,ze,{body:n,method:"post",...s,headers:_([{"OpenAI-Beta":"assistants=v2"},s?.headers])})}};o(Qi,"VectorStores");let rt=Qi;rt.Files=xs,rt.FileBatches=$s;const Zi=class Zi extends A{create(t,n){return this._client.post("/videos",Ac({body:t,...n},this._client))}retrieve(t,n){return this._client.get(C`/videos/${t}`,n)}list(t={},n){return this._client.getAPIList("/videos",Ve,{query:t,...n})}delete(t,n){return this._client.delete(C`/videos/${t}`,n)}downloadContent(t,n={},s){return this._client.get(C`/videos/${t}/content`,{query:n,...s,headers:_([{Accept:"application/binary"},s?.headers]),__binaryResponse:!0})}remix(t,n,s){return this._client.post(C`/videos/${t}/remix`,Ac({body:n,...s},this._client))}};o(Zi,"Videos");let Ss=Zi;var ut,gl,Is;const eo=class eo extends A{constructor(){super(...arguments),ut.add(this)}async unwrap(t,n,s=this._client.webhookSecret,r=300){return await this.verifySignature(t,n,s,r),JSON.parse(t)}async verifySignature(t,n,s=this._client.webhookSecret,r=300){if(typeof crypto>"u"||typeof crypto.subtle.importKey!="function"||typeof crypto.subtle.verify!="function")throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");p(this,ut,"m",gl).call(this,s);const i=_([n]).values,u=p(this,ut,"m",Is).call(this,i,"webhook-signature"),a=p(this,ut,"m",Is).call(this,i,"webhook-timestamp"),c=p(this,ut,"m",Is).call(this,i,"webhook-id"),l=parseInt(a,10);if(isNaN(l))throw new ve("Invalid webhook timestamp format");const d=Math.floor(Date.now()/1e3);if(d-l>r)throw new ve("Webhook timestamp is too old");if(l>d+r)throw new ve("Webhook timestamp is too new");const D=u.split(" ").map(m=>m.startsWith("v1,")?m.substring(3):m),f=s.startsWith("whsec_")?Buffer.from(s.replace("whsec_",""),"base64"):Buffer.from(s,"utf-8"),h=c?`${c}.${a}.${t}`:`${a}.${t}`,F=await crypto.subtle.importKey("raw",f,{name:"HMAC",hash:"SHA-256"},!1,["verify"]);for(const m of D)try{const E=Buffer.from(m,"base64");if(await crypto.subtle.verify("HMAC",F,E,new TextEncoder().encode(h)))return}catch{continue}throw new ve("The given webhook signature does not match the expected signature")}};o(eo,"Webhooks");let Os=eo;ut=new WeakSet,gl=o(function(t){if(typeof t!="string"||t.length===0)throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function")},"_Webhooks_validateSecret2"),Is=o(function(t,n){if(!t)throw new Error("Headers are required");const s=t.get(n);if(s==null)throw new Error(`Missing required header: ${n}`);return s},"_Webhooks_getRequiredHeader2");var bu,_u,Rs,Cl;const to=class to{constructor({baseURL:t=Qe("OPENAI_BASE_URL"),apiKey:n=Qe("OPENAI_API_KEY"),organization:s=Qe("OPENAI_ORG_ID")??null,project:r=Qe("OPENAI_PROJECT_ID")??null,webhookSecret:i=Qe("OPENAI_WEBHOOK_SECRET")??null,...u}={}){if(bu.add(this),Rs.set(this,void 0),this.completions=new cs(this),this.chat=new Mt(this),this.embeddings=new ds(this),this.files=new Dl(this),this.images=new gs(this),this.audio=new Ie(this),this.moderations=new Es(this),this.models=new Cs(this),this.fineTuning=new ye(this),this.graders=new Vt(this),this.vectorStores=new rt(this),this.webhooks=new Os(this),this.beta=new Ee(this),this.batches=new Qn(this),this.uploads=new Jt(this),this.responses=new st(this),this.realtime=new tt(this),this.conversations=new qt(this),this.evals=new Kt(this),this.containers=new Wt(this),this.videos=new Ss(this),n===void 0)throw new v("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");const a={apiKey:n,organization:s,project:r,webhookSecret:i,...u,baseURL:t||"https://api.openai.com/v1"};if(!a.dangerouslyAllowBrowser&&kf())throw new v(`It looks like you're running in a browser-like environment.
99
99
 
100
100
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
101
101
  If you understand the risks and have appropriate mitigations in place,
@@ -104,23 +104,23 @@ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
104
104
  new OpenAI({ apiKey, dangerouslyAllowBrowser: true });
105
105
 
106
106
  https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
107
- `);this.baseURL=a.baseURL,this.timeout=a.timeout??_u.DEFAULT_TIMEOUT,this.logger=a.logger??console;const c="warn";this.logLevel=c,this.logLevel=bc(a.logLevel,"ClientOptions.logLevel",this)??bc(Ze("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??jf(),$(this,Ps,Wf),this._options=a,this.apiKey=typeof n=="string"?n:"Missing Key",this.organization=s,this.project=r,this.webhookSecret=i}withOptions(t){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:n}){}async authHeaders(t){return _([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(t){return Vf(t,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${He}`}defaultIdempotencyKey(){return`stainless-node-retry-${sc()}`}makeStatusError(t,n,s,r){return ee.generate(t,n,s,r)}async _callApiKey(){const t=this._options.apiKey;if(typeof t!="function")return!1;let n;try{n=await t()}catch(s){throw s instanceof v?s:new v(`Failed to get token from 'apiKey' function: ${s.message}`,{cause:s})}if(typeof n!="string"||!n)throw new v(`Expected 'apiKey' function argument to return a string but it returned ${n}`);return this.apiKey=n,!0}buildURL(t,n,s){const r=!p(this,bu,"m",yl).call(this)&&s||this.baseURL,i=Sf(t)?new URL(t):new URL(r+(r.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),u=this.defaultQuery();return If(u)||(n={...u,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(i.search=this.stringifyQuery(n)),i.toString()}async prepareOptions(t){await this._callApiKey()}async prepareRequest(t,{url:n,options:s}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,s){return this.request(Promise.resolve(s).then(r=>({method:t,path:n,...r})))}request(t,n=null){return new Pn(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,s){const r=await t,i=r.maxRetries??this.maxRetries;n==null&&(n=i),await this.prepareOptions(r);const{req:u,url:a,timeout:c}=await this.buildRequest(r,{retryCount:i-n});await this.prepareRequest(u,{url:a,options:r});const l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),D=s===void 0?"":`, retryOf: ${s}`,d=Date.now();if(X(this).debug(`[${l}] sending request`,$e({retryOfRequestLogID:s,method:r.method,url:a,options:r,headers:u.headers})),r.signal?.aborted)throw new ne;const f=new AbortController,h=await this.fetchWithTimeout(a,u,c,f).catch(Wr),F=Date.now();if(h instanceof globalThis.Error){const y=`retrying, ${n} attempts remaining`;if(r.signal?.aborted)throw new ne;const g=Ur(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(n)return X(this).info(`[${l}] connection ${g?"timed out":"failed"} - ${y}`),X(this).debug(`[${l}] connection ${g?"timed out":"failed"} (${y})`,$e({retryOfRequestLogID:s,url:a,durationMs:F-d,message:h.message})),this.retryRequest(r,n,s??l);throw X(this).info(`[${l}] connection ${g?"timed out":"failed"} - error; no more retries left`),X(this).debug(`[${l}] connection ${g?"timed out":"failed"} (error; no more retries left)`,$e({retryOfRequestLogID:s,url:a,durationMs:F-d,message:h.message})),g?new vt:new Ke({cause:h})}const m=[...h.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,g])=>", "+y+": "+JSON.stringify(g)).join(""),E=`[${l}${D}${m}] ${u.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${F-d}ms`;if(!h.ok){const y=await this.shouldRetry(h);if(n&&y){const R=`retrying, ${n} attempts remaining`;return await Uf(h.body),X(this).info(`${E} - ${R}`),X(this).debug(`[${l}] response error (${R})`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,durationMs:F-d})),this.retryRequest(r,n,s??l,h.headers)}const g=y?"error; no more retries left":"error; not retryable";X(this).info(`${E} - ${g}`);const b=await h.text().catch(R=>Wr(R).message),B=kf(b),I=B?void 0:b;throw X(this).debug(`[${l}] response error (${g})`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,message:I,durationMs:Date.now()-d})),this.makeStatusError(h.status,B,I,h.headers)}return X(this).info(E),X(this).debug(`[${l}] response start`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,durationMs:F-d})),{response:h,options:r,controller:f,requestLogID:l,retryOfRequestLogID:s,startTime:d}}getAPIList(t,n,s){return this.requestAPIList(n,{method:"get",path:t,...s})}requestAPIList(t,n){const s=this.makeRequest(n,null,void 0);return new Jr(this,s,t)}async fetchWithTimeout(t,n,s,r){const{signal:i,method:u,...a}=n||{};i&&i.addEventListener("abort",()=>r.abort());const c=setTimeout(()=>r.abort(),s),l=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,D={signal:r.signal,...l?{duplex:"half"}:{},method:"GET",...a};u&&(D.method=u.toUpperCase());try{return await this.fetch.call(void 0,t,D)}finally{clearTimeout(c)}}async shouldRetry(t){const n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,s,r){let i;const u=r?.get("retry-after-ms");if(u){const c=parseFloat(u);Number.isNaN(c)||(i=c)}const a=r?.get("retry-after");if(a&&!i){const c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(!(i&&0<=i&&i<60*1e3)){const c=t.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(n,c)}return await $t(i),this.makeRequest(t,n-1,s)}calculateDefaultRetryTimeoutMillis(t,n){const i=n-t,u=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return u*a*1e3}async buildRequest(t,{retryCount:n=0}={}){const s={...t},{method:r,path:i,query:u,defaultBaseURL:a}=s,c=this.buildURL(i,u,a);"timeout"in s&&Rf("timeout",s.timeout),s.timeout=s.timeout??this.timeout;const{bodyHeaders:l,body:D}=this.buildBody({options:s}),d=await this.buildHeaders({options:t,method:r,bodyHeaders:l,retryCount:n});return{req:{method:r,headers:d,...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&D instanceof globalThis.ReadableStream&&{duplex:"half"},...D&&{body:D},...this.fetchOptions??{},...s.fetchOptions??{}},url:c,timeout:s.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:s,retryCount:r}){let i={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=t.idempotencyKey);const u=_([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...Lf(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(t),this._options.defaultHeaders,s,t.headers]);return this.validateHeaders(u),u.values}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0};const s=_([n]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&s.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:lc(t)}:p(this,Ps,"f").call(this,{body:t,headers:s})}};o(no,"OpenAI");let x=no;_u=x,Ps=new WeakMap,bu=new WeakSet,yl=o(function(){return this.baseURL!=="https://api.openai.com/v1"},"_OpenAI_baseURLOverridden2"),x.OpenAI=_u,x.DEFAULT_TIMEOUT=6e5,x.OpenAIError=v,x.APIError=ee,x.APIConnectionError=Ke,x.APIConnectionTimeoutError=vt,x.APIUserAbortError=ne,x.NotFoundError=An,x.ConflictError=vn,x.RateLimitError=xn,x.BadRequestError=bn,x.AuthenticationError=_n,x.InternalServerError=Sn,x.PermissionDeniedError=Bn,x.UnprocessableEntityError=$n,x.InvalidWebhookSignatureError=ve,x.toFile=ip,x.Completions=Ds,x.Chat=jt,x.Embeddings=fs,x.Files=hl,x.Images=Es,x.Audio=Ie,x.Moderations=ws,x.Models=ys,x.FineTuning=ye,x.Graders=Xt,x.VectorStores=ut,x.Webhooks=ks,x.Beta=Ee,x.Batches=es,x.Uploads=Yt,x.Responses=rt,x.Realtime=nt,x.Conversations=Kt,x.Evals=zt,x.Containers=Gt,x.Videos=Os;const Te="meta-llama/Llama-3.3-70B-Instruct-Turbo",wl=o(e=>`[${e} - \u2705]`,"CURRENT_LABEL_FORMAT"),Sp=o(e=>`[${e} - suggested]`,"PREFERRED_LABEL_FORMAT"),Ip=3600*1e3,bl=o(()=>{const e=process.platform,t=ho.homedir();if(e==="darwin")return ae.join(t,"Library","Caches","aicommits","models");if(e==="win32")return ae.join(t,"AppData","Local","aicommits","models");{const n=process.env.XDG_CACHE_HOME,s=n||ae.join(t,".cache");return ae.join(s,"aicommits","models")}},"getCacheDir"),Op=o(e=>{const t=Yl.createHash("sha256");return t.update(e),t.digest("hex")},"getCacheKey"),_l=o(e=>ae.join(bl(),`${e}.json`),"getCachePath"),Rp=o(async e=>{const t=_l(e);try{if(!await Lr(t))return null;const n=await Q.readFile(t,"utf8");return JSON.parse(n)}catch{return null}},"readCache"),Bl=o(async(e,t)=>{try{const n=bl();await Q.mkdir(n,{recursive:!0});const s=_l(e);await Q.writeFile(s,JSON.stringify(t),"utf8")}catch{}},"writeCache"),Bu=o(async(e,t)=>{const n=Op(e),s=Date.now(),r=await Rp(n);if(r&&s-r.timestamp<Ip)return r.data;try{const u=await new x({baseURL:e,apiKey:t}).models.list(),c={models:u.data.length>0?u.data:u.body};return await Bl(n,{data:c,timestamp:s}),c}catch(i){const u=i instanceof Error?i.message:"Request failed",a={models:[],error:u};return await Bl(n,{data:a,timestamp:s}),a}},"fetchModels"),kp=o(async(e,t,n)=>{console.log("Fetching available models...");const s=await Bu(e,t);s.error&&console.error(`Failed to fetch models: ${s.error}`);let r=[];return n?.modelsFilter?r=n.modelsFilter(s.models):r=s.models.map(i=>i.id||i.name).filter(Boolean),r},"fetchAndFilterModels"),Pp=o((e,t,n)=>{let s=e.map(r=>({label:r,value:r}));if(t&&t!=="undefined"){const r=s.findIndex(i=>i.value===t);if(r>=0){if(s[r].label=wl(s[r].value),r>0){const[i]=s.splice(r,1);s.unshift(i)}}else s.unshift({label:wl(t),value:t})}if(n?.name==="togetherai"&&t!==Te){const r=s.findIndex(i=>i.value===Te);if(r>=0){s[r].label=Sp(s[r].value);const i=t&&t!=="undefined"?1:0,[u]=s.splice(r,1);s.splice(i,0,u)}}return s},"prepareModelOptions"),Tp=o(async(e,t,n,s)=>{const r=await n({message:"Enter search term for models:",placeholder:"e.g., gpt, llama"});if(s(r))return null;let i=e;r&&(i=e.filter(c=>c.toLowerCase().includes(r.toLowerCase())));let u=i.slice(0,20).map(c=>({label:c,value:c}));const a=await t({message:`Choose your model (filtered by "${r}"):`,options:[...u,{label:"Custom model name...",value:"custom"}]});return s(a)?null:a},"handleSearch"),Np=o(async e=>{const t=await e({message:"Enter your custom model name:",validate:o(n=>{if(!n)return"Model name is required"},"validate")});return Fn(t)?null:t},"handleCustom"),Al=o(async(e,t,n,s)=>{(!n||n==="undefined")&&s?.name==="togetherai"&&(n=Te);const r=await kp(e,t,s);let i=null;if(r.length>0){const{select:u,text:a,isCancel:c}=await Promise.resolve().then(function(){return yn});let l=Pp(r,n,s),D=await u({message:"Choose your model:",options:[{label:"\u{1F50D} Search models...",value:"search"},...l,{label:"Custom model name...",value:"custom"}]});if(c(D))return null;if(D==="search"){const d=await Tp(r,u,a,c);if(d===null)return null;D=d}if(D==="custom"){if(i=await Np(a),i===null)return null}else i=D}else{console.log("Could not fetch available models. Please specify a model name manually.");const{text:u}=await Promise.resolve().then(function(){return yn});try{i=await u({message:"Enter your model name:",validate:o(c=>{if(!c)return"Model name is required"},"validate")})}catch{return null}}return i},"selectModel");var Mp=Object.freeze({__proto__:null,fetchModels:Bu,selectModel:Al}),Lp=Object.defineProperty,jp=o((e,t,n)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"__defNormalProp"),vl=o((e,t,n)=>jp(e,typeof t!="symbol"?t+"":t,n),"__publicField");const so=class so{constructor(t,n){vl(this,"config"),vl(this,"def"),this.def=t,this.config=n}get name(){return this.def.name}get displayName(){return this.def.displayName}getDefinition(){return this.def}async setup(){const{text:t,password:n}=await Promise.resolve().then(function(){return yn}),s=[];if(this.def.requiresApiKey){const r=this.getApiKey(),i=await n({message:r?`Enter your API key (leave empty to keep current: ${r.substring(0,4)}****):`:"Enter your API key:",validate:o(u=>{if(!u&&!r)return"API key is required";if(u&&this.def.apiKeyFormat&&!u.startsWith(this.def.apiKeyFormat))return`Invalid API key format, must start with "${this.def.apiKeyFormat}"`},"validate")});i&&s.push(["OPENAI_API_KEY",i])}if(this.name==="ollama"){const r=this.getBaseUrl(),i=await t({message:"Enter Ollama endpoint (leave empty for default):",placeholder:r});i&&i!=="http://localhost:11434/v1"&&s.push(["OPENAI_BASE_URL",i])}return s}async getModels(){const t=this.getBaseUrl(),n=this.getApiKey()||"",s=await Bu(t,n);if(s.error)return{models:[],error:s.error};let r;return this.def.modelsFilter?r=this.def.modelsFilter(s.models):r=s.models.map(i=>i.id||i.name).filter(Boolean),{models:r}}getApiKey(){return this.def.requiresApiKey?this.config.OPENAI_API_KEY:void 0}getBaseUrl(){return this.name==="custom"?this.config.OPENAI_BASE_URL||"":this.def.baseUrl}getDefaultModel(){return this.def.defaultModel}validateConfig(){const t=[];return this.def.requiresApiKey&&!this.getApiKey()&&t.push(`${this.displayName} API key is required`),this.name==="custom"&&!this.getBaseUrl()&&t.push("Custom endpoint is required"),{valid:t.length===0,errors:t}}};o(so,"Provider");let Au=so;function Qt(e){const t=e.provider,n=Bt.find(s=>s.name===t);return n?new Au(n,e):null}o(Qt,"getProvider");function Up(){return Bt.map(e=>({value:e.name,label:e.displayName}))}o(Up,"getAvailableProviders");function Wp(e){return Bt.find(n=>n.name===e)?.baseUrl||""}o(Wp,"getProviderBaseUrl");const qp={"":"<commit message>",conventional:"<type>[optional (<scope>)]: <commit message>",gitmoji:":emoji: <commit message>"},Gp=o(e=>`The output response must be in format:
108
- ${qp[e]}`,"specifyCommitFormat"),Kp={"":"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
107
+ `);this.baseURL=a.baseURL,this.timeout=a.timeout??_u.DEFAULT_TIMEOUT,this.logger=a.logger??console;const c="warn";this.logLevel=c,this.logLevel=yc(a.logLevel,"ClientOptions.logLevel",this)??yc(Qe("OPENAI_LOG"),"process.env['OPENAI_LOG']",this)??c,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??Lf(),$(this,Rs,Uf),this._options=a,this.apiKey=typeof n=="string"?n:"Missing Key",this.organization=s,this.project=r,this.webhookSecret=i}withOptions(t){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,organization:this.organization,project:this.project,webhookSecret:this.webhookSecret,...t})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:n}){}async authHeaders(t){return _([{Authorization:`Bearer ${this.apiKey}`}])}stringifyQuery(t){return zf(t,{arrayFormat:"brackets"})}getUserAgent(){return`${this.constructor.name}/JS ${Ke}`}defaultIdempotencyKey(){return`stainless-node-retry-${tc()}`}makeStatusError(t,n,s,r){return ee.generate(t,n,s,r)}async _callApiKey(){const t=this._options.apiKey;if(typeof t!="function")return!1;let n;try{n=await t()}catch(s){throw s instanceof v?s:new v(`Failed to get token from 'apiKey' function: ${s.message}`,{cause:s})}if(typeof n!="string"||!n)throw new v(`Expected 'apiKey' function argument to return a string but it returned ${n}`);return this.apiKey=n,!0}buildURL(t,n,s){const r=!p(this,bu,"m",Cl).call(this)&&s||this.baseURL,i=xf(t)?new URL(t):new URL(r+(r.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),u=this.defaultQuery();return Sf(u)||(n={...u,...n}),typeof n=="object"&&n&&!Array.isArray(n)&&(i.search=this.stringifyQuery(n)),i.toString()}async prepareOptions(t){await this._callApiKey()}async prepareRequest(t,{url:n,options:s}){}get(t,n){return this.methodRequest("get",t,n)}post(t,n){return this.methodRequest("post",t,n)}patch(t,n){return this.methodRequest("patch",t,n)}put(t,n){return this.methodRequest("put",t,n)}delete(t,n){return this.methodRequest("delete",t,n)}methodRequest(t,n,s){return this.request(Promise.resolve(s).then(r=>({method:t,path:n,...r})))}request(t,n=null){return new Rn(this,this.makeRequest(t,n,void 0))}async makeRequest(t,n,s){const r=await t,i=r.maxRetries??this.maxRetries;n==null&&(n=i),await this.prepareOptions(r);const{req:u,url:a,timeout:c}=await this.buildRequest(r,{retryCount:i-n});await this.prepareRequest(u,{url:a,options:r});const l="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),d=s===void 0?"":`, retryOf: ${s}`,D=Date.now();if(X(this).debug(`[${l}] sending request`,$e({retryOfRequestLogID:s,method:r.method,url:a,options:r,headers:u.headers})),r.signal?.aborted)throw new ne;const f=new AbortController,h=await this.fetchWithTimeout(a,u,c,f).catch(Wr),F=Date.now();if(h instanceof globalThis.Error){const y=`retrying, ${n} attempts remaining`;if(r.signal?.aborted)throw new ne;const g=Ur(h)||/timed? ?out/i.test(String(h)+("cause"in h?String(h.cause):""));if(n)return X(this).info(`[${l}] connection ${g?"timed out":"failed"} - ${y}`),X(this).debug(`[${l}] connection ${g?"timed out":"failed"} (${y})`,$e({retryOfRequestLogID:s,url:a,durationMs:F-D,message:h.message})),this.retryRequest(r,n,s??l);throw X(this).info(`[${l}] connection ${g?"timed out":"failed"} - error; no more retries left`),X(this).debug(`[${l}] connection ${g?"timed out":"failed"} (error; no more retries left)`,$e({retryOfRequestLogID:s,url:a,durationMs:F-D,message:h.message})),g?new Bt:new Ge({cause:h})}const m=[...h.headers.entries()].filter(([y])=>y==="x-request-id").map(([y,g])=>", "+y+": "+JSON.stringify(g)).join(""),E=`[${l}${d}${m}] ${u.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status} in ${F-D}ms`;if(!h.ok){const y=await this.shouldRetry(h);if(n&&y){const R=`retrying, ${n} attempts remaining`;return await jf(h.body),X(this).info(`${E} - ${R}`),X(this).debug(`[${l}] response error (${R})`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,durationMs:F-D})),this.retryRequest(r,n,s??l,h.headers)}const g=y?"error; no more retries left":"error; not retryable";X(this).info(`${E} - ${g}`);const b=await h.text().catch(R=>Wr(R).message),B=Rf(b),I=B?void 0:b;throw X(this).debug(`[${l}] response error (${g})`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,message:I,durationMs:Date.now()-D})),this.makeStatusError(h.status,B,I,h.headers)}return X(this).info(E),X(this).debug(`[${l}] response start`,$e({retryOfRequestLogID:s,url:h.url,status:h.status,headers:h.headers,durationMs:F-D})),{response:h,options:r,controller:f,requestLogID:l,retryOfRequestLogID:s,startTime:D}}getAPIList(t,n,s){return this.requestAPIList(n,{method:"get",path:t,...s})}requestAPIList(t,n){const s=this.makeRequest(n,null,void 0);return new Jr(this,s,t)}async fetchWithTimeout(t,n,s,r){const{signal:i,method:u,...a}=n||{};i&&i.addEventListener("abort",()=>r.abort());const c=setTimeout(()=>r.abort(),s),l=globalThis.ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in a.body,d={signal:r.signal,...l?{duplex:"half"}:{},method:"GET",...a};u&&(d.method=u.toUpperCase());try{return await this.fetch.call(void 0,t,d)}finally{clearTimeout(c)}}async shouldRetry(t){const n=t.headers.get("x-should-retry");return n==="true"?!0:n==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,n,s,r){let i;const u=r?.get("retry-after-ms");if(u){const c=parseFloat(u);Number.isNaN(c)||(i=c)}const a=r?.get("retry-after");if(a&&!i){const c=parseFloat(a);Number.isNaN(c)?i=Date.parse(a)-Date.now():i=c*1e3}if(!(i&&0<=i&&i<60*1e3)){const c=t.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(n,c)}return await At(i),this.makeRequest(t,n-1,s)}calculateDefaultRetryTimeoutMillis(t,n){const i=n-t,u=Math.min(.5*Math.pow(2,i),8),a=1-Math.random()*.25;return u*a*1e3}async buildRequest(t,{retryCount:n=0}={}){const s={...t},{method:r,path:i,query:u,defaultBaseURL:a}=s,c=this.buildURL(i,u,a);"timeout"in s&&Of("timeout",s.timeout),s.timeout=s.timeout??this.timeout;const{bodyHeaders:l,body:d}=this.buildBody({options:s}),D=await this.buildHeaders({options:t,method:r,bodyHeaders:l,retryCount:n});return{req:{method:r,headers:D,...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&d instanceof globalThis.ReadableStream&&{duplex:"half"},...d&&{body:d},...this.fetchOptions??{},...s.fetchOptions??{}},url:c,timeout:s.timeout}}async buildHeaders({options:t,method:n,bodyHeaders:s,retryCount:r}){let i={};this.idempotencyHeader&&n!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),i[this.idempotencyHeader]=t.idempotencyKey);const u=_([i,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r),...t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{},...Mf(),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project},await this.authHeaders(t),this._options.defaultHeaders,s,t.headers]);return this.validateHeaders(u),u.values}buildBody({options:{body:t,headers:n}}){if(!t)return{bodyHeaders:void 0,body:void 0};const s=_([n]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&s.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:ac(t)}:p(this,Rs,"f").call(this,{body:t,headers:s})}};o(to,"OpenAI");let x=to;_u=x,Rs=new WeakMap,bu=new WeakSet,Cl=o(function(){return this.baseURL!=="https://api.openai.com/v1"},"_OpenAI_baseURLOverridden2"),x.OpenAI=_u,x.DEFAULT_TIMEOUT=6e5,x.OpenAIError=v,x.APIError=ee,x.APIConnectionError=Ge,x.APIConnectionTimeoutError=Bt,x.APIUserAbortError=ne,x.NotFoundError=_n,x.ConflictError=Bn,x.RateLimitError=vn,x.BadRequestError=yn,x.AuthenticationError=wn,x.InternalServerError=$n,x.PermissionDeniedError=bn,x.UnprocessableEntityError=An,x.InvalidWebhookSignatureError=ve,x.toFile=up,x.Completions=cs,x.Chat=Mt,x.Embeddings=ds,x.Files=Dl,x.Images=gs,x.Audio=Ie,x.Moderations=Es,x.Models=Cs,x.FineTuning=ye,x.Graders=Vt,x.VectorStores=rt,x.Webhooks=Os,x.Beta=Ee,x.Batches=Qn,x.Uploads=Jt,x.Responses=st,x.Realtime=tt,x.Conversations=qt,x.Evals=Kt,x.Containers=Wt,x.Videos=Ss;const El=o(e=>`[${e} - \u2705]`,"CURRENT_LABEL_FORMAT"),xp=3600*1e3,yl=o(()=>{const e=process.platform,t=Do.homedir();if(e==="darwin")return ae.join(t,"Library","Caches","aicommits","models");if(e==="win32")return ae.join(t,"AppData","Local","aicommits","models");{const n=process.env.XDG_CACHE_HOME,s=n||ae.join(t,".cache");return ae.join(s,"aicommits","models")}},"getCacheDir"),Sp=o(e=>{const t=Vl.createHash("sha256");return t.update(e),t.digest("hex")},"getCacheKey"),wl=o(e=>ae.join(yl(),`${e}.json`),"getCachePath"),Ip=o(async e=>{const t=wl(e);try{if(!await Mr(t))return null;const n=await Q.readFile(t,"utf8");return JSON.parse(n)}catch{return null}},"readCache"),bl=o(async(e,t)=>{try{const n=yl();await Q.mkdir(n,{recursive:!0});const s=wl(e);await Q.writeFile(s,JSON.stringify(t),"utf8")}catch{}},"writeCache"),Bu=o(async(e,t)=>{const n=Sp(e),s=Date.now(),r=await Ip(n);if(r&&s-r.timestamp<xp)return r.data;try{const u=await new x({baseURL:e,apiKey:t}).models.list(),c={models:u.data.length>0?u.data:u.body};return await bl(n,{data:c,timestamp:s}),c}catch(i){const u=i instanceof Error?i.message:"Request failed",a={models:[],error:u};return await bl(n,{data:a,timestamp:s}),a}},"fetchModels"),Op=o(async(e,t,n)=>{console.log("Fetching available models...");const s=await Bu(e,t);s.error&&console.error(`Failed to fetch models: ${s.error}`);let r=[];return n?.modelsFilter?r=n.modelsFilter(s.models):r=s.models.map(i=>i.id||i.name).filter(Boolean),r},"fetchAndFilterModels"),Rp=o((e,t,n)=>{let s=e.map(r=>({label:r,value:r}));if(t&&t!=="undefined"){const r=s.findIndex(i=>i.value===t);if(r>=0){if(s[r].label=El(s[r].value),r>0){const[i]=s.splice(r,1);s.unshift(i)}}else s.unshift({label:El(t),value:t})}return s},"prepareModelOptions"),kp=o(async(e,t,n,s)=>{const r=await n({message:"Enter search term for models:",placeholder:"e.g., gpt, llama"});if(s(r))return null;let i=e;r&&(i=e.filter(c=>c.toLowerCase().includes(r.toLowerCase())));let u=i.slice(0,20).map(c=>({label:c,value:c}));const a=await t({message:`Choose your model (filtered by "${r}"):`,options:[...u,{label:"Custom model name...",value:"custom"}]});return s(a)?null:a},"handleSearch"),Pp=o(async e=>{const t=await e({message:"Enter your custom model name:",validate:o(n=>{if(!n)return"Model name is required"},"validate")});return pn(t)?null:t},"handleCustom"),_l=o(async(e,t,n,s)=>{(!n||n==="undefined")&&(n=s?.defaultModel);const r=await Op(e,t,s);let i=null;if(r.length>0){const{select:u,text:a,isCancel:c}=await Promise.resolve().then(function(){return Cn});let l=Rp(r,n),d=await u({message:"Choose your model:",options:[{label:"\u{1F50D} Search models...",value:"search"},...l,{label:"Custom model name...",value:"custom"}]});if(c(d))return null;if(d==="search"){const D=await kp(r,u,a,c);if(D===null)return null;d=D}if(d==="custom"){if(i=await Pp(a),i===null)return null}else i=d}else{console.log("Could not fetch available models. Please specify a model name manually.");const{text:u}=await Promise.resolve().then(function(){return Cn});try{i=await u({message:"Enter your model name:",validate:o(c=>{if(!c)return"Model name is required"},"validate")})}catch{return null}}return i},"selectModel");var Tp=Object.freeze({__proto__:null,fetchModels:Bu,selectModel:_l}),Np=Object.defineProperty,Mp=o((e,t,n)=>t in e?Np(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,"__defNormalProp"),Bl=o((e,t,n)=>Mp(e,typeof t!="symbol"?t+"":t,n),"__publicField");const no=class no{constructor(t,n){Bl(this,"config"),Bl(this,"def"),this.def=t,this.config=n}get name(){return this.def.name}get displayName(){return this.def.displayName}getDefinition(){return this.def}async setup(){const{text:t,password:n}=await Promise.resolve().then(function(){return Cn}),s=[];if(this.def.requiresApiKey){const r=this.getApiKey(),i=await n({message:r?`Enter your API key (leave empty to keep current: ${r.substring(0,4)}****):`:"Enter your API key:",validate:o(u=>{if(!u&&!r)return"API key is required";if(u&&this.def.apiKeyFormat&&!u.startsWith(this.def.apiKeyFormat))return`Invalid API key format, must start with "${this.def.apiKeyFormat}"`},"validate")});i&&s.push(["OPENAI_API_KEY",i])}if(this.name==="ollama"){const r=this.getBaseUrl(),i=await t({message:"Enter Ollama endpoint (leave empty for default):",placeholder:r});i&&i!=="http://localhost:11434/v1"&&s.push(["OPENAI_BASE_URL",i])}return s}async getModels(){const t=this.getBaseUrl(),n=this.getApiKey()||"",s=await Bu(t,n);if(s.error)return{models:[],error:s.error};let r;return this.def.modelsFilter?r=this.def.modelsFilter(s.models):r=s.models.map(i=>i.id||i.name).filter(Boolean),{models:r}}getApiKey(){return this.def.requiresApiKey?this.config.OPENAI_API_KEY:void 0}getBaseUrl(){return this.name==="custom"?this.config.OPENAI_BASE_URL||"":this.def.baseUrl}getDefaultModel(){return this.def.defaultModel}validateConfig(){const t=[];return this.def.requiresApiKey&&!this.getApiKey()&&t.push(`${this.displayName} API key is required`),this.name==="custom"&&!this.getBaseUrl()&&t.push("Custom endpoint is required"),{valid:t.length===0,errors:t}}};o(no,"Provider");let Au=no;function Xt(e){const t=e.provider,n=_t.find(s=>s.name===t);return n?new Au(n,e):null}o(Xt,"getProvider");function Lp(){return _t.map(e=>({value:e.name,label:e.displayName}))}o(Lp,"getAvailableProviders");function jp(e){return _t.find(n=>n.name===e)?.baseUrl||""}o(jp,"getProviderBaseUrl");const Up={"":"<commit message>",conventional:"<type>[optional (<scope>)]: <commit message>",gitmoji:":emoji: <commit message>"},Wp=o(e=>`The output response must be in format:
108
+ ${Up[e]}`,"specifyCommitFormat"),qp={"":"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
109
109
  ${JSON.stringify({docs:"Documentation only changes",style:"Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",refactor:"A code change that improves code structure without changing functionality (renaming, restructuring classes/methods, extracting functions, etc)",perf:"A code change that improves performance",test:"Adding missing tests or correcting existing tests",build:"Changes that affect the build system or external dependencies",ci:"Changes to our CI configuration files and scripts",chore:"Other changes that don't modify src or test files",revert:"Reverts a previous commit",feat:"A new feature",fix:"A bug fix"},null,2)}`,gitmoji:`Choose an emoji from the emoji-to-description JSON below that best describes the git diff:
110
- ${JSON.stringify({"\u{1F3A8}":"Improve structure / format of the code","\u26A1":"Improve performance","\u{1F525}":"Remove code or files","\u{1F41B}":"Fix a bug","\u{1F691}":"Critical hotfix","\u2728":"Introduce new features","\u{1F4DD}":"Add or update documentation","\u{1F680}":"Deploy stuff","\u{1F484}":"Add or update the UI and style files","\u{1F389}":"Begin a project","\u2705":"Add, update, or pass tests","\u{1F512}":"Fix security or privacy issues","\u{1F510}":"Add or update secrets","\u{1F516}":"Release / Version tags","\u{1F6A8}":"Fix compiler / linter warnings","\u{1F6A7}":"Work in progress","\u{1F49A}":"Fix CI Build","\u2B07\uFE0F":"Downgrade dependencies","\u2B06\uFE0F":"Upgrade dependencies","\u{1F4CC}":"Pin dependencies to specific versions","\u{1F477}":"Add or update CI build system","\u{1F4C8}":"Add or update analytics or track code","\u267B\uFE0F":"Refactor code","\u2795":"Add a dependency","\u2796":"Remove a dependency","\u{1F527}":"Add or update configuration files","\u{1F528}":"Add or update development scripts","\u{1F310}":"Internationalization and localization","\u270F\uFE0F":"Fix typos","\u{1F4A9}":"Write bad code that needs to be improved","\u23EA":"Revert changes","\u{1F500}":"Merge branches","\u{1F4E6}":"Add or update compiled files or packages","\u{1F47D}":"Update code due to external API changes","\u{1F69A}":"Move or rename resources (e.g.: files, paths, routes)","\u{1F4C4}":"Add or update license","\u{1F4A5}":"Introduce breaking changes","\u{1F371}":"Add or update assets","\u267F":"Improve accessibility","\u{1F4A1}":"Add or update comments in source code","\u{1F37B}":"Write code drunkenly","\u{1F4AC}":"Add or update text and literals","\u{1F5C3}":"Perform database related changes","\u{1F50A}":"Add or update logs","\u{1F507}":"Remove logs","\u{1F465}":"Add or update contributor(s)","\u{1F6B8}":"Improve user experience / usability","\u{1F3D7}":"Make architectural changes","\u{1F4F1}":"Work on responsive design","\u{1F921}":"Mock things","\u{1F95A}":"Add or update an easter egg","\u{1F648}":"Add or update a .gitignore file","\u{1F4F8}":"Add or update snapshots","\u2697":"Perform experiments","\u{1F50D}":"Improve SEO","\u{1F3F7}":"Add or update types","\u{1F331}":"Add or update seed files","\u{1F6A9}":"Add, update, or remove feature flags","\u{1F945}":"Catch errors","\u{1F4AB}":"Add or update animations and transitions","\u{1F5D1}":"Deprecate code that needs to be cleaned up","\u{1F6C2}":"Work on code related to authorization, roles and permissions","\u{1FA79}":"Simple fix for a non-critical issue","\u{1F9D0}":"Data exploration/inspection","\u26B0":"Remove dead code","\u{1F9EA}":"Add a failing test","\u{1F454}":"Add or update business logic","\u{1FA7A}":"Add or update healthcheck","\u{1F9F1}":"Infrastructure related changes","\u{1F9D1}\u200D\u{1F4BB}":"Improve developer experience","\u{1F4B8}":"Add sponsorships or money related infrastructure","\u{1F9F5}":"Add or update code related to multithreading or concurrency","\u{1F9BA}":"Add or update code related to validation"},null,2)}`},Hp=o((e,t,n)=>["Generate a concise git commit message title in present tense that precisely describes the key changes in the following code diff. Focus on what was changed, not just file names. Provide only the title, no description or body.",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.","IMPORTANT: Do not include any explanations, introductions, or additional text. Do not wrap the commit message in quotes or any other formatting. Respond with ONLY the commit message text.",Kp[n],Gp(n)].filter(Boolean).join(`
111
- `),"generatePrompt"),zp=o(async(e,t,n,s)=>await new x({baseURL:e,apiKey:t,timeout:s}).chat.completions.create(n),"createChatCompletion"),Vp=o((e,t)=>e.trim().split(`
112
- `)[0].replace(/(\w)\.$/,"$1").replace(/^["'`]|["'`]$/g,"").substring(0,t),"sanitizeMessage"),Jp=o(e=>Array.from(new Set(e)),"deduplicateMessages"),$l=o(async(e,t,n,s,r,i,u,a,c)=>{process.env.DEBUG&&(console.log("Diff being sent to AI:"),console.log(r));try{const D=(await zp(e,t,{model:n,messages:[{role:"system",content:Hp(s,u,a)},{role:"user",content:r}],temperature:.4,max_tokens:100,stream:!1,n:i},c)).choices.filter(d=>d.message?.content);return Jp(D.map(d=>Vp(d.message.content??"",u)))}catch(l){const D=l;throw D.code==="ENOTFOUND"?new G(`Error connecting to ${D.hostname} (${D.syscall}). Are you connected to the internet?`):D.status===429?new G("You have exceeded your OpenAI API quota. Please check your plan and billing details at https://platform.openai.com/account/billing"):D}},"generateCommitMessage"),Xp=o(e=>new Promise(t=>setTimeout(t,e)),"sleep"),Yp=o(async(e,t=3,n=1e3)=>{for(let s=0;s<t;s++)try{return await e()}catch(r){if(s===t-1)throw r;await Xp(n)}throw new Error("Retry failed")},"retry"),Qp=o(async(e,t)=>{const{select:n,confirm:s,isCancel:r}=await Promise.resolve().then(function(){return yn}),{dim:i}=await Promise.resolve().then(function(){return Ph});if(e.length===1){const[a]=e;if(t)return a;console.log(`
110
+ ${JSON.stringify({"\u{1F3A8}":"Improve structure / format of the code","\u26A1":"Improve performance","\u{1F525}":"Remove code or files","\u{1F41B}":"Fix a bug","\u{1F691}":"Critical hotfix","\u2728":"Introduce new features","\u{1F4DD}":"Add or update documentation","\u{1F680}":"Deploy stuff","\u{1F484}":"Add or update the UI and style files","\u{1F389}":"Begin a project","\u2705":"Add, update, or pass tests","\u{1F512}":"Fix security or privacy issues","\u{1F510}":"Add or update secrets","\u{1F516}":"Release / Version tags","\u{1F6A8}":"Fix compiler / linter warnings","\u{1F6A7}":"Work in progress","\u{1F49A}":"Fix CI Build","\u2B07\uFE0F":"Downgrade dependencies","\u2B06\uFE0F":"Upgrade dependencies","\u{1F4CC}":"Pin dependencies to specific versions","\u{1F477}":"Add or update CI build system","\u{1F4C8}":"Add or update analytics or track code","\u267B\uFE0F":"Refactor code","\u2795":"Add a dependency","\u2796":"Remove a dependency","\u{1F527}":"Add or update configuration files","\u{1F528}":"Add or update development scripts","\u{1F310}":"Internationalization and localization","\u270F\uFE0F":"Fix typos","\u{1F4A9}":"Write bad code that needs to be improved","\u23EA":"Revert changes","\u{1F500}":"Merge branches","\u{1F4E6}":"Add or update compiled files or packages","\u{1F47D}":"Update code due to external API changes","\u{1F69A}":"Move or rename resources (e.g.: files, paths, routes)","\u{1F4C4}":"Add or update license","\u{1F4A5}":"Introduce breaking changes","\u{1F371}":"Add or update assets","\u267F":"Improve accessibility","\u{1F4A1}":"Add or update comments in source code","\u{1F37B}":"Write code drunkenly","\u{1F4AC}":"Add or update text and literals","\u{1F5C3}":"Perform database related changes","\u{1F50A}":"Add or update logs","\u{1F507}":"Remove logs","\u{1F465}":"Add or update contributor(s)","\u{1F6B8}":"Improve user experience / usability","\u{1F3D7}":"Make architectural changes","\u{1F4F1}":"Work on responsive design","\u{1F921}":"Mock things","\u{1F95A}":"Add or update an easter egg","\u{1F648}":"Add or update a .gitignore file","\u{1F4F8}":"Add or update snapshots","\u2697":"Perform experiments","\u{1F50D}":"Improve SEO","\u{1F3F7}":"Add or update types","\u{1F331}":"Add or update seed files","\u{1F6A9}":"Add, update, or remove feature flags","\u{1F945}":"Catch errors","\u{1F4AB}":"Add or update animations and transitions","\u{1F5D1}":"Deprecate code that needs to be cleaned up","\u{1F6C2}":"Work on code related to authorization, roles and permissions","\u{1FA79}":"Simple fix for a non-critical issue","\u{1F9D0}":"Data exploration/inspection","\u26B0":"Remove dead code","\u{1F9EA}":"Add a failing test","\u{1F454}":"Add or update business logic","\u{1FA7A}":"Add or update healthcheck","\u{1F9F1}":"Infrastructure related changes","\u{1F9D1}\u200D\u{1F4BB}":"Improve developer experience","\u{1F4B8}":"Add sponsorships or money related infrastructure","\u{1F9F5}":"Add or update code related to multithreading or concurrency","\u{1F9BA}":"Add or update code related to validation"},null,2)}`},Gp=o((e,t,n)=>["Generate a concise git commit message title in present tense that precisely describes the key changes in the following code diff. Focus on what was changed, not just file names. Provide only the title, no description or body.",`Message language: ${e}`,`Commit message must be a maximum of ${t} characters.`,"Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.","IMPORTANT: Do not include any explanations, introductions, or additional text. Do not wrap the commit message in quotes or any other formatting. Respond with ONLY the commit message text.",qp[n],Wp(n)].filter(Boolean).join(`
111
+ `),"generatePrompt"),Kp=o(async(e,t,n,s)=>await new x({baseURL:e,apiKey:t,timeout:s}).chat.completions.create(n),"createChatCompletion"),Hp=o((e,t)=>e.trim().split(`
112
+ `)[0].replace(/(\w)\.$/,"$1").replace(/^["'`]|["'`]$/g,"").substring(0,t),"sanitizeMessage"),zp=o(e=>Array.from(new Set(e)),"deduplicateMessages"),Al=o(async(e,t,n,s,r,i,u,a,c)=>{process.env.DEBUG&&(console.log("Diff being sent to AI:"),console.log(r));try{const d=(await Kp(e,t,{model:n,messages:[{role:"system",content:Gp(s,u,a)},{role:"user",content:r}],temperature:.4,max_tokens:100,stream:!1,n:i},c)).choices.filter(D=>D.message?.content);return zp(d.map(D=>Hp(D.message.content??"",u)))}catch(l){const d=l;throw d.code==="ENOTFOUND"?new G(`Error connecting to ${d.hostname} (${d.syscall}). Are you connected to the internet?`):d.status===429?new G("You have exceeded your OpenAI API quota. Please check your plan and billing details at https://platform.openai.com/account/billing"):d}},"generateCommitMessage"),Vp=o(e=>new Promise(t=>setTimeout(t,e)),"sleep"),Jp=o(async(e,t=3,n=1e3)=>{for(let s=0;s<t;s++)try{return await e()}catch(r){if(s===t-1)throw r;await Vp(n)}throw new Error("Retry failed")},"retry"),Xp=o(async(e,t)=>{const{select:n,confirm:s,isCancel:r}=await Promise.resolve().then(function(){return Cn}),{dim:i}=await Promise.resolve().then(function(){return Oh});if(e.length===1){const[a]=e;if(t)return a;console.log(`
113
113
  \x1B[1m${a}\x1B[0m
114
- `);const c=await s({message:"Use this commit message?"});return c&&!r(c)?a:null}if(t)return e[0];const u=await n({message:`Pick a commit message to use: ${i("(Ctrl+c to exit)")}`,options:e.map(a=>({label:a,value:a}))});return r(u)?null:u},"getCommitMessage");var Zp=o(async(e,t,n,s,r,i,u)=>(async()=>{kr(Cr(Fr(" aicommits "))),await Xa();const a=En();n&&await Et("git",["add","--update"]),a.start("Detecting staged files");const c=await Qa(t);if(!c)throw a.stop("Detecting staged files"),new G("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");a.stop(`\u{1F4C1} ${gf(c.files)}:
114
+ `);const c=await s({message:"Use this commit message?"});return c&&!r(c)?a:null}if(t)return e[0];const u=await n({message:`Pick a commit message to use: ${i("(Ctrl+c to exit)")}`,options:e.map(a=>({label:a,value:a}))});return r(u)?null:u},"getCommitMessage");var Yp=o(async(e,t,n,s,r,i,u)=>(async()=>{Rr(gr(mr(" aicommits "))),await Va();const a=gn();n&&await Ct("git",["add","--update"]),a.start("Detecting staged files");const c=await Xa(t);if(!c)throw a.stop("Detecting staged files"),new G("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");a.stop(`\u{1F4C1} ${mf(c.files)}:
115
115
  ${c.files.map(g=>` ${g}`).join(`
116
- `)}`);const{env:l}=process,D=await Ge({generate:e?.toString(),type:s?.toString()}),d=Qt(D);if(!d)if(process.stdout.isTTY&&!process.env.CI){console.log("Welcome to aicommits! Let's set up your AI provider."),console.log("Run `aicommits setup` to configure your provider."),V("Setup required. Please run: aicommits setup");return}else throw new G("No configuration found. Run `aicommits setup` in an interactive terminal, or set environment variables (OPENAI_API_KEY, etc.)");const f=D.timeout||(d.name==="ollama"?3e4:1e4),h=d.validateConfig();if(!h.valid)throw new G(`Provider configuration issues: ${h.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);D.model=D.OPENAI_MODEL||d.getDefaultModel(),D.provider==="togetherai"&&D.model==="undefined"&&(D.model=Te,await At([["OPENAI_MODEL",Te]]));const F=En();F.start(`\u{1F50D} Analyzing changes in ${c.files.length} file${c.files.length===1?"":"s"}`);const m=Date.now();let E;try{const g=d.getBaseUrl(),b=d.getApiKey()||"";E=await Yp(()=>$l(g,b,D.model,D.locale,c.diff,D.generate,D["max-length"],D.type,f),3,2e3)}finally{const g=Date.now()-m;F.stop(`\u2705 Changes analyzed in ${g}ms`)}if(E.length===0)throw new G("No commit messages were generated. Try again.");const y=await Qp(E,r);if(!y){V("Commit cancelled");return}if(i){try{await bt.write(y),V(`${We("\u2714")} Message copied to clipboard`)}catch{}return}await Et("git",["commit","-m",y,...u]),V(`${We("\u2714")} Successfully committed!`)})().catch(Tr),"aicommits");const[vu,em]=process.argv.slice(2);var tm=o(()=>(async()=>{if(!vu)throw new G('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(em)return;const e=await Qa();if(!e)return;kr(Cr(Fr(" aicommits ")));const t=await Ge({}),n=Qt(t);if(!n)throw new G("Invalid provider configuration. Run `aicommits setup` to reconfigure.");const s=n.validateConfig();if(!s.valid)throw new G(`Provider configuration issues: ${s.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);const r=n.getBaseUrl(),i=n.getApiKey()||"",u=t.timeout||(n.name==="ollama"?3e4:1e4);let a=t.OPENAI_MODEL||n.getDefaultModel();const c=En();c.start("The AI is analyzing your changes");let l;try{l=await $l(r,i,a,t.locale,e.diff,t.generate,t["max-length"],t.type,u)}finally{c.stop("Changes analyzed")}const d=await Q.readFile(vu,"utf8")!=="",f=l.length>1;let h="";d&&(h=`# \u{1F916} AI generated commit${f?"s":""}
117
- `),f?(d&&(h+=`# Select one of the following messages by uncommeting:
116
+ `)}`);const{env:l}=process,d=await qe({generate:e?.toString(),type:s?.toString()}),D=Xt(d);if(!D)if(process.stdout.isTTY&&!process.env.CI){console.log("Welcome to aicommits! Let's set up your AI provider."),console.log("Run `aicommits setup` to configure your provider."),J("Setup required. Please run: aicommits setup");return}else throw new G("No configuration found. Run `aicommits setup` in an interactive terminal, or set environment variables (OPENAI_API_KEY, etc.)");const f=d.timeout||(D.name==="ollama"?3e4:1e4),h=D.validateConfig();if(!h.valid)throw new G(`Provider configuration issues: ${h.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);d.model=d.OPENAI_MODEL||D.getDefaultModel();const F=gn();F.start(`\u{1F50D} Analyzing changes in ${c.files.length} file${c.files.length===1?"":"s"}`);const m=Date.now();let E;try{const g=D.getBaseUrl(),b=D.getApiKey()||"";E=await Jp(()=>Al(g,b,d.model,d.locale,c.diff,d.generate,d["max-length"],d.type,f),3,2e3)}finally{const g=Date.now()-m;F.stop(`\u2705 Changes analyzed in ${g}ms`)}if(E.length===0)throw new G("No commit messages were generated. Try again.");const y=await Xp(E,r);if(!y){J("Commit cancelled");return}if(i){try{await wt.write(y),J(`${Ue("\u2714")} Message copied to clipboard`)}catch{}return}await Ct("git",["commit","-m",y,...u]),J(`${Ue("\u2714")} Successfully committed!`)})().catch(Pr),"aicommits");const[vu,Qp]=process.argv.slice(2);var Zp=o(()=>(async()=>{if(!vu)throw new G('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Qp)return;const e=await Xa();if(!e)return;Rr(gr(mr(" aicommits ")));const t=await qe({}),n=Xt(t);if(!n)throw new G("Invalid provider configuration. Run `aicommits setup` to reconfigure.");const s=n.validateConfig();if(!s.valid)throw new G(`Provider configuration issues: ${s.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);const r=n.getBaseUrl(),i=n.getApiKey()||"",u=t.timeout||(n.name==="ollama"?3e4:1e4);let a=t.OPENAI_MODEL||n.getDefaultModel();const c=gn();c.start("The AI is analyzing your changes");let l;try{l=await Al(r,i,a,t.locale,e.diff,t.generate,t["max-length"],t.type,u)}finally{c.stop("Changes analyzed")}const D=await Q.readFile(vu,"utf8")!=="",f=l.length>1;let h="";D&&(h=`# \u{1F916} AI generated commit${f?"s":""}
117
+ `),f?(D&&(h+=`# Select one of the following messages by uncommeting:
118
118
  `),h+=`
119
119
  ${l.map(F=>`# ${F}`).join(`
120
- `)}`):(d&&(h+=`# Edit the message below and commit:
120
+ `)}`):(D&&(h+=`# Edit the message below and commit:
121
121
  `),h+=`
122
122
  ${l[0]}
123
- `),await Q.appendFile(vu,h),V(`${We("\u2714")} Saved commit message!`)})().catch(Tr),"prepareCommitMessageHook"),nm=Ct({name:"config",description:"View or modify configuration settings",help:{description:"View or modify configuration settings"},parameters:["[mode]","[key=value...]"]},e=>{(async()=>{const[t,...n]=e._;if(!t){const s=await Ge({},{},!0);console.log("Provider:",s.provider),s.OPENAI_API_KEY&&console.log("API Key:",`${s.OPENAI_API_KEY.substring(0,4)}****`),s.OPENAI_BASE_URL&&console.log("Base URL:",s.OPENAI_BASE_URL),s.OPENAI_MODEL&&console.log("Model:",s.OPENAI_MODEL);return}if(t==="get"){const s=await Ge({},{},!0),r=["OPENAI_API_KEY","TOGETHER_API_KEY","api-key"];for(const i of n)if(tc(s,i)){const u=s[i],a=r.includes(i)?`${String(u).substring(0,4)}****`:String(u);console.log(`${i}=${a}`)}return}if(t==="set"){await At(n.map(s=>s.split("=")));return}throw new G(`Invalid mode: ${t}`)})().catch(Tr)}),sm=Ct({name:"setup",description:"Configure your AI provider and settings",help:{description:"Configure your AI provider and settings"}},e=>{(async()=>{let t=await Ge();const n=Up(),s=await Va({message:"Choose your AI provider:",options:n,initialValue:t.provider});if(Fn(s)){V("Setup cancelled");return}const r=s;let i="";if(r==="custom"){const F=await Ha({message:"Enter your custom API endpoint:",validate:o(m=>{if(!m)return"Endpoint is required";try{new URL(m)}catch{return"Invalid URL format"}},"validate")});if(Fn(F)){V("Setup cancelled");return}i=F}let u=i||Wp(r);t.OPENAI_BASE_URL=u,t.OPENAI_API_KEY="",t.OPENAI_MODEL="";let a=Qt({...t,provider:r});if(!a){V("Invalid provider selected");return}const c=await a.setup();for(const[F,m]of c)t[F]=m;if(a=Qt({...t,provider:r}),!a){V("Invalid provider selected");return}const l=a.validateConfig();if(!l.valid){V(`Setup cancelled: ${l.errors.join(", ")}`);return}const{selectModel:D}=await Promise.resolve().then(function(){return Mp}),d=await D(a.getBaseUrl(),a.getApiKey()||"",void 0,a.getDefinition());d?(t.OPENAI_MODEL=d,console.log(`Model selected: ${d}`)):console.log("Model selection cancelled.");const f=Object.entries(t).filter(([F,m])=>F!=="provider"&&m!==void 0&&m!==""&&typeof m=="string");if(await At(f),V(`\u2705 Setup complete! You're now using ${a.displayName}.`),await za({message:'Would you like to create a git alias "git ac" for "aicommits"?'}))try{Ul('git config --global alias.ac "!aicommits"',{stdio:"inherit"}),console.log('\u2705 Git alias "git ac" created successfully.')}catch(F){console.error(`\u274C Failed to create git alias: ${F.message}`)}})().catch(t=>{console.error(`\u274C Setup failed: ${t.message}`),process.exit(1)})}),rm=Ct({name:"model",description:"Select or change your AI model",help:{description:"Select or change your AI model"},alias:["-m","models"]},()=>{(async()=>{const e=await Ge();if(!e.provider){V("No provider configured. Run `aicommits setup` first.");return}const t=Qt(e);if(!t){V("Invalid provider configured. Run `aicommits setup` to reconfigure.");return}console.log(`Current provider: ${t.displayName}`);const n=e.OPENAI_MODEL;console.log(`Current model: ${n&&n!=="undefined"?n:"not set"}`);const s=n,r=t.validateConfig();if(!r.valid){V(`Configuration issues: ${r.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);return}const i=await Al(t.getBaseUrl(),t.getApiKey()||"",n,t.getDefinition());i?(await At([["OPENAI_MODEL",i]]),V(`\u2705 Model updated to: ${i}`)):t.name==="togetherai"&&(!s||s==="undefined")?(await At([["OPENAI_MODEL",Te]]),V(`\u2705 Model set to default: ${Te}`)):V("Model selection cancelled")})().catch(e=>{console.error(`\u274C Model selection failed: ${e.message}`),process.exit(1)})});const xl="prepare-commit-msg",Sl=`.git/hooks/${xl}`,Ts=Ql(new URL("cli.mjs",import.meta.url)),um=process.argv[1].replace(/\\/g,"/").endsWith(`/${Sl}`),Il=process.platform==="win32",Ol=`
123
+ `),await Q.appendFile(vu,h),J(`${Ue("\u2714")} Saved commit message!`)})().catch(Pr),"prepareCommitMessageHook"),em=gt({name:"config",description:"View or modify configuration settings",help:{description:"View or modify configuration settings"},parameters:["[mode]","[key=value...]"]},e=>{(async()=>{const[t,...n]=e._;if(!t){const s=await qe({},{},!0);console.log("Provider:",s.provider),s.OPENAI_API_KEY&&console.log("API Key:",`${s.OPENAI_API_KEY.substring(0,4)}****`),s.OPENAI_BASE_URL&&console.log("Base URL:",s.OPENAI_BASE_URL),s.OPENAI_MODEL&&console.log("Model:",s.OPENAI_MODEL);return}if(t==="get"){const s=await qe({},{},!0),r=["OPENAI_API_KEY","TOGETHER_API_KEY","api-key"];for(const i of n)if(Za(s,i)){const u=s[i],a=r.includes(i)?`${String(u).substring(0,4)}****`:String(u);console.log(`${i}=${a}`)}return}if(t==="set"){await jr(n.map(s=>s.split("=")));return}throw new G(`Invalid mode: ${t}`)})().catch(Pr)}),tm=gt({name:"setup",description:"Configure your AI provider and settings",help:{description:"Configure your AI provider and settings"}},e=>{(async()=>{let t=await qe();const n=Lp(),s=await Ha({message:"Choose your AI provider:",options:n,initialValue:t.provider});if(pn(s)){J("Setup cancelled");return}const r=s;let i="";if(r==="custom"){const h=await Ka({message:"Enter your custom API endpoint:",validate:o(F=>{if(!F)return"Endpoint is required";try{new URL(F)}catch{return"Invalid URL format"}},"validate")});if(pn(h)){J("Setup cancelled");return}i=h}let u=i||jp(r);t.OPENAI_BASE_URL=u,t.OPENAI_API_KEY="",t.OPENAI_MODEL="";let a=Xt({...t,provider:r});if(!a){J("Invalid provider selected");return}const c=await a.setup();for(const[h,F]of c)t[h]=F;if(a=Xt({...t,provider:r}),!a){J("Invalid provider selected");return}const l=a.validateConfig();if(!l.valid){J(`Setup cancelled: ${l.errors.join(", ")}`);return}const{selectModel:d}=await Promise.resolve().then(function(){return Tp}),D=await d(a.getBaseUrl(),a.getApiKey()||"",void 0,a.getDefinition());D?(t.OPENAI_MODEL=D,console.log(`Model selected: ${D}`)):console.log("Model selection cancelled.");const f=Object.entries(t).filter(([h,F])=>h!=="provider"&&h!=="model"&&F!==void 0&&F!==""&&typeof F=="string");await jr(f),J(`\u2705 Setup complete! You're now using ${a.displayName}.`)})().catch(t=>{console.error(`\u274C Setup failed: ${t.message}`),process.exit(1)})}),nm=gt({name:"model",description:"Select or change your AI model",help:{description:"Select or change your AI model"},alias:["-m","models"]},()=>{(async()=>{const e=await qe();if(!e.provider){J("No provider configured. Run `aicommits setup` first.");return}const t=Xt(e);if(!t){J("Invalid provider configured. Run `aicommits setup` to reconfigure.");return}console.log(`Current provider: ${t.displayName}`);const n=e.OPENAI_MODEL;console.log(`Current model: ${n&&n!=="undefined"?n:"not set"}`);const s=t.validateConfig();if(!s.valid){J(`Configuration issues: ${s.errors.join(", ")}. Run \`aicommits setup\` to reconfigure.`);return}const r=await _l(t.getBaseUrl(),t.getApiKey()||"",n,t.getDefinition());r?(await jr([["OPENAI_MODEL",r]]),J(`\u2705 Model updated to: ${r}`)):J("Model selection cancelled")})().catch(e=>{console.error(`\u274C Model selection failed: ${e.message}`),process.exit(1)})});const vl="prepare-commit-msg",$l=`.git/hooks/${vl}`,ks=Jl(new URL("cli.mjs",import.meta.url)),sm=process.argv[1].replace(/\\/g,"/").endsWith(`/${$l}`),xl=process.platform==="win32",Sl=`
124
124
  #!/usr/bin/env node
125
- import(${JSON.stringify(Zl(Ts))})
126
- `.trim();var im=Ct({name:"hook",description:"Install or uninstall the Git hook for automatic commit messages",help:{description:"Install or uninstall the Git hook for automatic commit messages"},parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Xa(),{installUninstall:n}=e._,s=ae.join(t,Sl),r=await Lr(s);if(n==="install"){if(r){if(await Q.realpath(s).catch(()=>{})===Ts){console.warn("The hook is already installed");return}throw new G(`A different ${xl} hook seems to be installed. Please remove it before installing aicommits.`)}await Q.mkdir(ae.dirname(s),{recursive:!0}),Il?await Q.writeFile(s,Ol):(await Q.symlink(Ts,s,"file"),await Q.chmod(s,493)),console.log(`${We("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!r){console.warn("Hook is not installed");return}if(Il){if(await Q.readFile(s,"utf8")!==Ol){console.warn("Hook is not installed");return}}else if(await Q.realpath(s)!==Ts){console.warn("Hook is not installed");return}await Q.rm(s),console.log(`${We("\u2714")} Hook uninstalled`);return}throw new G(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${gr("\u2716")} ${t.message}`),Ja(t),process.exit(1)})});const{description:om,version:$u}=Ys,am=Nl({pkg:Ys});$u!=="0.0.0-semantic-release"&&$u.includes("-")&&am.notify();const Rl=process.argv.slice(2);Qo({name:"aicommits",flags:{generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Git commit message format (default: conventional). Supports conventional and gitmoji",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard instead of committing (default: false)",alias:"c",default:!1},version:{type:Boolean,description:"Show version number",alias:"v"}},commands:[nm,sm,rm,im],help:{description:om},ignoreArgv:o(e=>e==="unknown-flag"||e==="argument","ignoreArgv")},e=>{e.flags.version&&(console.log($u),process.exit(0)),um?tm():Zp(e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,Rl)},Rl);
125
+ import(${JSON.stringify(Xl(ks))})
126
+ `.trim();var rm=gt({name:"hook",description:"Install or uninstall the Git hook for automatic commit messages",help:{description:"Install or uninstall the Git hook for automatic commit messages"},parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Va(),{installUninstall:n}=e._,s=ae.join(t,$l),r=await Mr(s);if(n==="install"){if(r){if(await Q.realpath(s).catch(()=>{})===ks){console.warn("The hook is already installed");return}throw new G(`A different ${vl} hook seems to be installed. Please remove it before installing aicommits.`)}await Q.mkdir(ae.dirname(s),{recursive:!0}),xl?await Q.writeFile(s,Sl):(await Q.symlink(ks,s,"file"),await Q.chmod(s,493)),console.log(`${Ue("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!r){console.warn("Hook is not installed");return}if(xl){if(await Q.readFile(s,"utf8")!==Sl){console.warn("Hook is not installed");return}}else if(await Q.realpath(s)!==ks){console.warn("Hook is not installed");return}await Q.rm(s),console.log(`${Ue("\u2714")} Hook uninstalled`);return}throw new G(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${Fr("\u2716")} ${t.message}`),za(t),process.exit(1)})});const{description:um,version:Ps}=Xs,im=Pl({pkg:Xs,distTag:Ps.includes("-")?"develop":"latest"});Ps!=="0.0.0-semantic-release"&&Ps.includes("-")&&im.notify();const Il=process.argv.slice(2);Yo({name:"aicommits",flags:{generate:{type:Number,description:"Number of messages to generate (Warning: generating multiple costs more) (default: 1)",alias:"g"},exclude:{type:[String],description:"Files to exclude from AI analysis",alias:"x"},all:{type:Boolean,description:"Automatically stage changes in tracked files for the commit",alias:"a",default:!1},type:{type:String,description:"Git commit message format (default: conventional). Supports conventional and gitmoji",alias:"t"},confirm:{type:Boolean,description:"Skip confirmation when committing after message generation (default: false)",alias:"y",default:!1},clipboard:{type:Boolean,description:"Copy the selected message to the clipboard instead of committing (default: false)",alias:"c",default:!1},version:{type:Boolean,description:"Show version number",alias:"v"}},commands:[em,tm,nm,rm],help:{description:um},ignoreArgv:o(e=>e==="unknown-flag"||e==="argument","ignoreArgv")},e=>{e.flags.version&&(console.log(Ps),process.exit(0)),sm?Zp():Yp(e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,Il)},Il);