aicommit2 1.2.0 → 1.3.0

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 +47 -21
  2. package/dist/cli.mjs +56 -55
  3. package/package.json +7 -5
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="https://github.com/tak-bro/aicommit2/assets/7614353/9046d4ab-5652-4f2a-99b8-e58920ddbe17" alt="AICommit2"/>
4
4
  <h1 align="center">AICommit2</h1>
5
5
  </div>
6
- <p>Reactive CLI that generates git commit messages with various AI</p>
6
+ <p>A Reactive CLI that generates git commit messages with various AI</p>
7
7
  <a aria-label="npm" href="https://www.npmjs.com/package/aicommit2">
8
8
  <img src="https://img.shields.io/npm/v/aicommit2" alt="Current version">
9
9
  </a>
@@ -22,12 +22,13 @@ The core functionalities and architecture of this project are inspired by [AI Co
22
22
 
23
23
  - [OpenAI](https://openai.com/)
24
24
  - [Anthropic Claude](https://console.anthropic.com/)
25
+ - [Gemini](https://gemini.google.com/)
25
26
  - [Huggingface **(Unofficial)**](https://huggingface.co/chat/)
26
27
  - [Clova X **(Unofficial)**](https://clova-x.naver.com/)
27
28
 
28
29
  ## Setup
29
30
 
30
- > The minimum supported version of Node.js is the latest v16.20.0. Check your Node.js version with `node --version`.
31
+ > The minimum supported version of Node.js is the v18. Check your Node.js version with `node --version`.
31
32
 
32
33
  1. Install _aicommit2_:
33
34
 
@@ -39,6 +40,7 @@ npm install -g aicommit2
39
40
 
40
41
  - [OpenAI](https://platform.openai.com/account/api-keys)
41
42
  - [Anthropic Claude](https://console.anthropic.com/)
43
+ - [Gemini](https://aistudio.google.com/app/apikey)
42
44
  - [Huggingface **(Unofficial)**](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
43
45
  - [Clova X **(Unofficial)**](https://github.com/tak-bro/aicommit2/blob/main/README.md#how-to-get-cookie)
44
46
 
@@ -49,6 +51,7 @@ npm install -g aicommit2
49
51
  ```sh
50
52
  aicommit2 config set OPENAI_KEY=<your key> # OpenAI
51
53
  aicommit2 config set ANTHROPIC_KEY=<your key> # Anthropic Claude
54
+ aicommit2 config set GEMINI_KEY=<your key> # Gemini
52
55
 
53
56
  # Please be cautious of Escape characters(\", \') in browser cookie string
54
57
  aicommit2 config set HUGGING_COOKIE="<your browser cookie>" # Hugging Face
@@ -199,7 +202,7 @@ aicommit2 config get OPENAI_KEY
199
202
  You can also retrieve multiple configuration options at once by separating them with spaces:
200
203
 
201
204
  ```sh
202
- aicommit2 config get OPENAI_KEY OPENAI_MODEL CLOVAX_COOKIE
205
+ aicommit2 config get OPENAI_KEY OPENAI_MODEL GEMINI_KEY
203
206
  ```
204
207
 
205
208
  ### Setting a configuration value
@@ -224,23 +227,25 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
224
227
 
225
228
  ### Options
226
229
 
227
- | Option | Default | Description |
228
- |--------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------|
229
- | `OPENAI_KEY` | N/A | The OpenAI API key. |
230
- | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use. |
231
- | `ANTHROPIC_KEY` | N/A | The Anthropic API key. |
232
- | `ANTHROPIC_MODEL` | `claude-2.1` | The Anthropic Model to use. |
233
- | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
234
- | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use. |
235
- | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
236
- | `locale` | `en` | Locale for the generated commit messages. |
237
- | `generate` | `1` | Number of commit messages to generate. |
238
- | `type` | `conventional` | Type of commit message to generate. |
239
- | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**). |
240
- | `timeout` | `10000` ms | Network request timeout |
241
- | `max-length` | `50` | Maximum character length of the generated commit message. |
242
- | `max-tokens` | `200` | The maximum number of tokens that the AI models can generate. (only **Open AI, Anthropic**) |
243
- | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (only **Open AI, Anthropic**) |
230
+ | Option | Default | Description |
231
+ |-------------------|----------------------------------------|----------------------------------------------------------------------------------------------------------------|
232
+ | `OPENAI_KEY` | N/A | The OpenAI API key. |
233
+ | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use. |
234
+ | `ANTHROPIC_KEY` | N/A | The Anthropic API key. |
235
+ | `ANTHROPIC_MODEL` | `claude-2.1` | The Anthropic Model to use. |
236
+ | `GEMINI_KEY` | N/A | The Gemini API key. |
237
+ | `GEMINI_MODEL` | `gemini-pro` | The Gemini Model |
238
+ | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
239
+ | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use. |
240
+ | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
241
+ | `locale` | `en` | Locale for the generated commit messages. |
242
+ | `generate` | `1` | Number of commit messages to generate. |
243
+ | `type` | `conventional` | Type of commit message to generate. |
244
+ | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**). |
245
+ | `timeout` | `10000` ms | Network request timeout |
246
+ | `max-length` | `50` | Maximum character length of the generated commit message. |
247
+ | `max-tokens` | `200` | The maximum number of tokens that the AI models can generate. (for **Open AI, Anthropic, Gemini**) |
248
+ | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini**) |
244
249
 
245
250
 
246
251
  #### OPENAI_KEY
@@ -275,6 +280,18 @@ Supported:
275
280
  aicommit2 config set ANTHROPIC_MODEL=claude-2.1
276
281
  ```
277
282
 
283
+ #### GEMINI_KEY
284
+
285
+ The Gemini API key. If you don't already have one, create a key in [Google AI Studio](https://aistudio.google.com/app/apikey).
286
+
287
+ #### GEMINI_MODEL
288
+
289
+ Default: `gemini-pro`
290
+
291
+ Supported:
292
+ - `gemini-pro`
293
+
294
+ > Currently supporting only one model, but as Gemini starts supporting other models, it will be updated.
278
295
 
279
296
  #### HUGGING_COOKIE
280
297
 
@@ -361,7 +378,7 @@ aicommit2 config set type=
361
378
  ```
362
379
 
363
380
  #### max-tokens
364
- The maximum number of tokens that the AI models can generate.
381
+ The maximum number of tokens that the AI models can generate. (for **Open AI, Anthropic, Gemini**)
365
382
 
366
383
  Default: `200`
367
384
 
@@ -369,6 +386,15 @@ Default: `200`
369
386
  aicommit2 config set max-tokens=1000
370
387
  ```
371
388
 
389
+ #### temperature
390
+ The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini**)
391
+
392
+ Default: `0.7`
393
+
394
+ ```sh
395
+ aicommit2 config set temperature=0
396
+ ```
397
+
372
398
  ## How it works
373
399
 
374
400
  This CLI tool runs `git diff` to grab all your latest code changes, sends them to configured AI, then returns the AI generated commit message.
package/dist/cli.mjs CHANGED
@@ -1,77 +1,78 @@
1
1
  #!/usr/bin/env node
2
- import Pe from"tty";import{createRequire as Dr}from"module";import{Buffer as cr}from"node:buffer";import L from"node:path";import St from"node:child_process";import _ from"node:process";import lr from"child_process";import j from"path";import Te from"fs";import fr from"node:url";import dr,{constants as It}from"node:os";import Pt from"assert";import Tt from"events";import pr from"buffer";import _e from"stream";import _t from"util";import Me from"inquirer";import Ne from"ora";import C from"chalk";import{of as ae,concatMap as De,from as Y,map as X,catchError as ce,mergeMap as mr,BehaviorSubject as Mt,ReplaySubject as hr,lastValueFrom as Cr,filter as gr,toArray as Fr}from"rxjs";import Re from"@anthropic-ai/sdk";import{fromPromise as le}from"rxjs/internal/observable/innerFrom";import Er from"https";import"@dqbd/tiktoken";import yr from"net";import wr from"tls";import br,{fileURLToPath as vr,pathToFileURL as Ar}from"url";import Nt from"os";import"web-streams-polyfill";import{FormData as Br,Blob as $r}from"formdata-node";import x from"fs/promises";import xr from"axios";import fe from"readline";import Or from"figlet";import Sr from"inquirer-reactive-list-prompt";const Ir="known-flag",Pr="unknown-flag",Tr="argument",{stringify:J}=JSON,_r=/\B([A-Z])/g,Mr=e=>e.replace(_r,"-$1").toLowerCase(),{hasOwnProperty:Nr}=Object.prototype,Z=(e,t)=>Nr.call(e,t),Rr=e=>Array.isArray(e),Rt=e=>typeof e=="function"?[e,!1]:Rr(e)?[e[0],!0]:Rt(e.type),kr=(e,t)=>e===Boolean?t!=="false":t,Lr=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),jr=/[\s.:=]/,Gr=e=>{const t=`Flag name ${J(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(jr);if(n)throw new Error(`${t} cannot contain ${J(n?.[0])}`)},Hr=e=>{const t={},n=(r,u)=>{if(Z(t,r))throw new Error(`Duplicate flags named ${J(r)}`);t[r]=u};for(const r in e){if(!Z(e,r))continue;Gr(r);const u=e[r],o=[[],...Rt(u),u];n(r,o);const s=Mr(r);if(r!==s&&n(s,o),"alias"in u&&typeof u.alias=="string"){const{alias:a}=u,i=`Flag alias ${J(a)} for flag ${J(r)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);n(a,o)}}return t},Ur=(e,t)=>{const n={};for(const r in e){if(!Z(e,r))continue;const[u,,o,s]=t[r];if(u.length===0&&"default"in s){let{default:a}=s;typeof a=="function"&&(a=a()),n[r]=a}else n[r]=o?u:u.pop()}return n},de="--",qr=/[.:=]/,Kr=/^-{1,2}\w/,zr=e=>{if(!Kr.test(e))return;const t=!e.startsWith(de);let n=e.slice(t?1:2),r;const u=n.match(qr);if(u){const{index:o}=u;r=n.slice(o+1),n=n.slice(0,o)}return[n,r,t]},Wr=(e,{onFlag:t,onArgument:n})=>{let r;const u=(o,s)=>{if(typeof r!="function")return!0;r(o,s),r=void 0};for(let o=0;o<e.length;o+=1){const s=e[o];if(s===de){u();const i=e.slice(o+1);n?.(i,[o],!0);break}const a=zr(s);if(a){if(u(),!t)continue;const[i,f,l]=a;if(l)for(let c=0;c<i.length;c+=1){u();const D=c===i.length-1;r=t(i[c],D?f:void 0,[o,c+1,D])}else r=t(i,f,[o])}else u(s,[o])&&n?.([s],[o])}u()},Vr=(e,t)=>{for(const[n,r,u]of t.reverse()){if(r){const o=e[n];let s=o.slice(0,r);if(u||(s+=o.slice(r+1)),s!=="-"){e[n]=s;continue}}e.splice(n,1)}},Yr=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],u=Hr(e),o={},s=[];return s[de]=[],Wr(t,{onFlag(a,i,f){const l=Z(u,a);if(!n?.(l?Ir:Pr,a,i)){if(l){const[c,D]=u[a],d=kr(D,i),p=(m,h)=>{r.push(f),h&&r.push(h),c.push(Lr(D,m||""))};return d===void 0?p:p(d)}Z(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),r.push(f)}},onArgument(a,i,f){n?.(Tr,t[i[0]])||(s.push(...a),f?(s[de]=a,t.splice(i[0])):r.push(i))}}),Vr(t,r),{flags:Ur(e,u),unknownFlags:o,_:s}};var Xr=Object.create,pe=Object.defineProperty,Jr=Object.defineProperties,Zr=Object.getOwnPropertyDescriptor,Qr=Object.getOwnPropertyDescriptors,eu=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,tu=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty,nu=Object.prototype.propertyIsEnumerable,jt=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,me=(e,t)=>{for(var n in t||(t={}))Lt.call(t,n)&&jt(e,n,t[n]);if(kt)for(var n of kt(t))nu.call(t,n)&&jt(e,n,t[n]);return e},ke=(e,t)=>Jr(e,Qr(t)),ru=e=>pe(e,"__esModule",{value:!0}),uu=(e,t)=>()=>(e&&(t=e(e=0)),t),ou=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),su=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of eu(t))!Lt.call(e,u)&&(n||u!=="default")&&pe(e,u,{get:()=>t[u],enumerable:!(r=Zr(t,u))||r.enumerable});return e},iu=(e,t)=>su(ru(pe(e!=null?Xr(tu(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=uu(()=>{}),au=ou((e,t)=>{B(),t.exports=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}});B(),B(),B();var Du=e=>{var t,n,r;let u=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(u)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:u}:{columns:(n=e.columns)!=null?n:[],stdoutColumns:(r=e.stdoutColumns)!=null?r:u}};B(),B(),B(),B(),B();function cu({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Gt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(cu(),"")}B();function lu(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var fu=iu(au(),1);function M(e){if(typeof e!="string"||e.length===0||(e=Gt(e),e.length===0))return 0;e=e.replace((0,fu.default)()," ");let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r<=31||r>=127&&r<=159||r>=768&&r<=879||(r>65535&&n++,t+=lu(r)?2:1)}return t}var Ht=e=>Math.max(...e.split(`
3
- `).map(M)),du=e=>{let t=[];for(let n of e){let{length:r}=n,u=r-t.length;for(let o=0;o<u;o+=1)t.push(0);for(let o=0;o<r;o+=1){let s=Ht(n[o]);s>t[o]&&(t[o]=s)}}return t};B();var Ut=/^\d+%$/,qt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},pu=(e,t)=>{var n;let r=[];for(let u=0;u<e.length;u+=1){let o=(n=t[u])!=null?n:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Ut.test(o)){r.push(ke(me({},qt),{width:o,contentWidth:e[u]}));continue}if(o&&typeof o=="object"){let s=ke(me(me({},qt),o),{contentWidth:e[u]});s.horizontalPadding=s.paddingLeft+s.paddingRight,r.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return r};function mu(e,t){for(let n of e){let{width:r}=n;if(r==="content-width"&&(n.width=n.contentWidth),r==="auto"){let i=Math.min(20,n.contentWidth);n.width=i,n.autoOverflow=n.contentWidth-i}if(typeof r=="string"&&Ut.test(r)){let i=Number.parseFloat(r.slice(0,-1))/100;n.width=Math.floor(t*i)-(n.paddingLeft+n.paddingRight)}let{horizontalPadding:u}=n,o=1,s=o+u;if(s>=t){let i=s-t,f=Math.ceil(n.paddingLeft/u*i),l=i-f;n.paddingLeft-=f,n.paddingRight-=l,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";let a=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,a),o)}}var Kt=()=>Object.assign([],{columns:0});function hu(e,t){let n=[Kt()],[r]=n;for(let u of e){let o=u.width+u.horizontalPadding;r.columns+o>t&&(r=Kt(),n.push(r)),r.push(u),r.columns+=o}for(let u of n){let o=u.reduce((D,d)=>D+d.width+d.horizontalPadding,0),s=t-o;if(s===0)continue;let a=u.filter(D=>"autoOverflow"in D),i=a.filter(D=>D.autoOverflow>0),f=i.reduce((D,d)=>D+d.autoOverflow,0),l=Math.min(f,s);for(let D of i){let d=Math.floor(D.autoOverflow/f*l);D.width+=d,s-=d}let c=Math.floor(s/a.length);for(let D=0;D<a.length;D+=1){let d=a[D];D===a.length-1?d.width+=s:d.width+=c,s-=c}}return n}function Cu(e,t,n){let r=pu(n,t);return mu(r,e),hu(r,e)}B(),B(),B();var Le=10,zt=(e=0)=>t=>`\x1B[${t+e}m`,Wt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Vt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`;function gu(){let e=new Map,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],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],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[n,r]of Object.entries(t)){for(let[u,o]of Object.entries(r))t[u]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},r[u]=t[u],e.set(o[0],o[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=zt(),t.color.ansi256=Wt(),t.color.ansi16m=Vt(),t.bgColor.ansi=zt(Le),t.bgColor.ansi256=Wt(Le),t.bgColor.ansi16m=Vt(Le),Object.defineProperties(t,{rgbToAnsi256:{value:(n,r,u)=>n===r&&r===u?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(u/255*5),enumerable:!1},hexToRgb:{value:n=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(n.toString(16));if(!r)return[0,0,0];let{colorString:u}=r.groups;u.length===3&&(u=u.split("").map(s=>s+s).join(""));let o=Number.parseInt(u,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:n=>t.rgbToAnsi256(...t.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:n=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,u,o;if(n>=232)r=((n-232)*10+8)/255,u=r,o=r;else{n-=16;let i=n%36;r=Math.floor(n/36)/5,u=Math.floor(i/6)/5,o=i%6/5}let s=Math.max(r,u,o)*2;if(s===0)return 30;let a=30+(Math.round(o)<<2|Math.round(u)<<1|Math.round(r));return s===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(n,r,u)=>t.ansi256ToAnsi(t.rgbToAnsi256(n,r,u)),enumerable:!1},hexToAnsi:{value:n=>t.ansi256ToAnsi(t.hexToAnsi256(n)),enumerable:!1}}),t}var Fu=gu(),Eu=Fu,he=new Set(["\x1B","\x9B"]),yu=39,je="\x07",Yt="[",wu="]",Xt="m",Ge=`${wu}8;;`,Jt=e=>`${he.values().next().value}${Yt}${e}${Xt}`,Zt=e=>`${he.values().next().value}${Ge}${e}${je}`,bu=e=>e.split(" ").map(t=>M(t)),He=(e,t,n)=>{let r=[...t],u=!1,o=!1,s=M(Gt(e[e.length-1]));for(let[a,i]of r.entries()){let f=M(i);if(s+f<=n?e[e.length-1]+=i:(e.push(i),s=0),he.has(i)&&(u=!0,o=r.slice(a+1).join("").startsWith(Ge)),u){o?i===je&&(u=!1,o=!1):i===Xt&&(u=!1);continue}s+=f,s===n&&a<r.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},vu=e=>{let t=e.split(" "),n=t.length;for(;n>0&&!(M(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(" ")+t.slice(n).join("")},Au=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",u,o,s=bu(e),a=[""];for(let[f,l]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let c=M(a[a.length-1]);if(f!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(a.push(""),c=0),(c>0||n.trim===!1)&&(a[a.length-1]+=" ",c++)),n.hard&&s[f]>t){let D=t-c,d=1+Math.floor((s[f]-D-1)/t);Math.floor((s[f]-1)/t)<d&&a.push(""),He(a,l,t);continue}if(c+s[f]>t&&c>0&&s[f]>0){if(n.wordWrap===!1&&c<t){He(a,l,t);continue}a.push("")}if(c+s[f]>t&&n.wordWrap===!1){He(a,l,t);continue}a[a.length-1]+=l}n.trim!==!1&&(a=a.map(f=>vu(f)));let i=[...a.join(`
4
- `)];for(let[f,l]of i.entries()){if(r+=l,he.has(l)){let{groups:D}=new RegExp(`(?:\\${Yt}(?<code>\\d+)m|\\${Ge}(?<uri>.*)${je})`).exec(i.slice(f).join(""))||{groups:{}};if(D.code!==void 0){let d=Number.parseFloat(D.code);u=d===yu?void 0:d}else D.uri!==void 0&&(o=D.uri.length===0?void 0:D.uri)}let c=Eu.codes.get(Number(u));i[f+1]===`
5
- `?(o&&(r+=Zt("")),u&&c&&(r+=Jt(c))):l===`
6
- `&&(u&&c&&(r+=Jt(u)),o&&(r+=Zt(o)))}return r};function Bu(e,t,n){return String(e).normalize().replace(/\r\n/g,`
2
+ import Pe from"tty";import{createRequire as Dr}from"module";import{Buffer as cr}from"node:buffer";import L from"node:path";import It from"node:child_process";import _ from"node:process";import lr from"child_process";import j from"path";import Me from"fs";import fr from"node:url";import dr,{constants as St}from"node:os";import Pt from"assert";import Mt from"events";import pr from"buffer";import _e from"stream";import _t from"util";import Te from"inquirer";import Ne from"ora";import g from"chalk";import{of as Z,concatMap as Q,from as G,map as H,catchError as ee,mergeMap as mr,BehaviorSubject as Tt,ReplaySubject as hr,lastValueFrom as gr,filter as Cr,toArray as Fr}from"rxjs";import Re from"@anthropic-ai/sdk";import{fromPromise as te}from"rxjs/internal/observable/innerFrom";import Er from"https";import"@dqbd/tiktoken";import yr from"net";import wr from"tls";import br,{fileURLToPath as Ar,pathToFileURL as vr}from"url";import Nt from"os";import{FormData as Br,Blob as $r}from"formdata-node";import x from"fs/promises";import xr from"axios";import{GoogleGenerativeAI as Or}from"@google/generative-ai";import me from"readline";import Ir from"figlet";import Sr from"inquirer-reactive-list-prompt";const Pr="known-flag",Mr="unknown-flag",_r="argument",{stringify:ne}=JSON,Tr=/\B([A-Z])/g,Nr=e=>e.replace(Tr,"-$1").toLowerCase(),{hasOwnProperty:Rr}=Object.prototype,re=(e,t)=>Rr.call(e,t),kr=e=>Array.isArray(e),Rt=e=>typeof e=="function"?[e,!1]:kr(e)?[e[0],!0]:Rt(e.type),Lr=(e,t)=>e===Boolean?t!=="false":t,jr=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Gr=/[\s.:=]/,Hr=e=>{const t=`Flag name ${ne(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(Gr);if(n)throw new Error(`${t} cannot contain ${ne(n?.[0])}`)},Ur=e=>{const t={},n=(r,u)=>{if(re(t,r))throw new Error(`Duplicate flags named ${ne(r)}`);t[r]=u};for(const r in e){if(!re(e,r))continue;Hr(r);const u=e[r],o=[[],...Rt(u),u];n(r,o);const s=Nr(r);if(r!==s&&n(s,o),"alias"in u&&typeof u.alias=="string"){const{alias:a}=u,i=`Flag alias ${ne(a)} for flag ${ne(r)}`;if(a.length===0)throw new Error(`${i} cannot be empty`);if(a.length>1)throw new Error(`${i} must be a single character`);n(a,o)}}return t},qr=(e,t)=>{const n={};for(const r in e){if(!re(e,r))continue;const[u,,o,s]=t[r];if(u.length===0&&"default"in s){let{default:a}=s;typeof a=="function"&&(a=a()),n[r]=a}else n[r]=o?u:u.pop()}return n},he="--",Kr=/[.:=]/,zr=/^-{1,2}\w/,Wr=e=>{if(!zr.test(e))return;const t=!e.startsWith(he);let n=e.slice(t?1:2),r;const u=n.match(Kr);if(u){const{index:o}=u;r=n.slice(o+1),n=n.slice(0,o)}return[n,r,t]},Yr=(e,{onFlag:t,onArgument:n})=>{let r;const u=(o,s)=>{if(typeof r!="function")return!0;r(o,s),r=void 0};for(let o=0;o<e.length;o+=1){const s=e[o];if(s===he){u();const i=e.slice(o+1);n?.(i,[o],!0);break}const a=Wr(s);if(a){if(u(),!t)continue;const[i,f,l]=a;if(l)for(let D=0;D<i.length;D+=1){u();const c=D===i.length-1;r=t(i[D],c?f:void 0,[o,D+1,c])}else r=t(i,f,[o])}else u(s,[o])&&n?.([s],[o])}u()},Vr=(e,t)=>{for(const[n,r,u]of t.reverse()){if(r){const o=e[n];let s=o.slice(0,r);if(u||(s+=o.slice(r+1)),s!=="-"){e[n]=s;continue}}e.splice(n,1)}},Xr=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],u=Ur(e),o={},s=[];return s[he]=[],Yr(t,{onFlag(a,i,f){const l=re(u,a);if(!n?.(l?Pr:Mr,a,i)){if(l){const[D,c]=u[a],d=Lr(c,i),p=(m,h)=>{r.push(f),h&&r.push(h),D.push(jr(c,m||""))};return d===void 0?p:p(d)}re(o,a)||(o[a]=[]),o[a].push(i===void 0?!0:i),r.push(f)}},onArgument(a,i,f){n?.(_r,t[i[0]])||(s.push(...a),f?(s[he]=a,t.splice(i[0])):r.push(i))}}),Vr(t,r),{flags:qr(e,u),unknownFlags:o,_:s}};var Jr=Object.create,ge=Object.defineProperty,Zr=Object.defineProperties,Qr=Object.getOwnPropertyDescriptor,eu=Object.getOwnPropertyDescriptors,tu=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,nu=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty,ru=Object.prototype.propertyIsEnumerable,jt=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ce=(e,t)=>{for(var n in t||(t={}))Lt.call(t,n)&&jt(e,n,t[n]);if(kt)for(var n of kt(t))ru.call(t,n)&&jt(e,n,t[n]);return e},ke=(e,t)=>Zr(e,eu(t)),uu=e=>ge(e,"__esModule",{value:!0}),ou=(e,t)=>()=>(e&&(t=e(e=0)),t),su=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),iu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of tu(t))!Lt.call(e,u)&&(n||u!=="default")&&ge(e,u,{get:()=>t[u],enumerable:!(r=Qr(t,u))||r.enumerable});return e},au=(e,t)=>iu(uu(ge(e!=null?Jr(nu(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=ou(()=>{}),Du=su((e,t)=>{B(),t.exports=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}});B(),B(),B();var cu=e=>{var t,n,r;let u=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(u)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:u}:{columns:(n=e.columns)!=null?n:[],stdoutColumns:(r=e.stdoutColumns)!=null?r:u}};B(),B(),B(),B(),B();function lu({onlyFirst:e=!1}={}){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}function Gt(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(lu(),"")}B();function fu(e){return Number.isInteger(e)?e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141):!1}var du=au(Du(),1);function T(e){if(typeof e!="string"||e.length===0||(e=Gt(e),e.length===0))return 0;e=e.replace((0,du.default)()," ");let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);r<=31||r>=127&&r<=159||r>=768&&r<=879||(r>65535&&n++,t+=fu(r)?2:1)}return t}var Ht=e=>Math.max(...e.split(`
3
+ `).map(T)),pu=e=>{let t=[];for(let n of e){let{length:r}=n,u=r-t.length;for(let o=0;o<u;o+=1)t.push(0);for(let o=0;o<r;o+=1){let s=Ht(n[o]);s>t[o]&&(t[o]=s)}}return t};B();var Ut=/^\d+%$/,qt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},mu=(e,t)=>{var n;let r=[];for(let u=0;u<e.length;u+=1){let o=(n=t[u])!=null?n:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Ut.test(o)){r.push(ke(Ce({},qt),{width:o,contentWidth:e[u]}));continue}if(o&&typeof o=="object"){let s=ke(Ce(Ce({},qt),o),{contentWidth:e[u]});s.horizontalPadding=s.paddingLeft+s.paddingRight,r.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return r};function hu(e,t){for(let n of e){let{width:r}=n;if(r==="content-width"&&(n.width=n.contentWidth),r==="auto"){let i=Math.min(20,n.contentWidth);n.width=i,n.autoOverflow=n.contentWidth-i}if(typeof r=="string"&&Ut.test(r)){let i=Number.parseFloat(r.slice(0,-1))/100;n.width=Math.floor(t*i)-(n.paddingLeft+n.paddingRight)}let{horizontalPadding:u}=n,o=1,s=o+u;if(s>=t){let i=s-t,f=Math.ceil(n.paddingLeft/u*i),l=i-f;n.paddingLeft-=f,n.paddingRight-=l,n.horizontalPadding=n.paddingLeft+n.paddingRight}n.paddingLeftString=n.paddingLeft?" ".repeat(n.paddingLeft):"",n.paddingRightString=n.paddingRight?" ".repeat(n.paddingRight):"";let a=t-n.horizontalPadding;n.width=Math.max(Math.min(n.width,a),o)}}var Kt=()=>Object.assign([],{columns:0});function gu(e,t){let n=[Kt()],[r]=n;for(let u of e){let o=u.width+u.horizontalPadding;r.columns+o>t&&(r=Kt(),n.push(r)),r.push(u),r.columns+=o}for(let u of n){let o=u.reduce((c,d)=>c+d.width+d.horizontalPadding,0),s=t-o;if(s===0)continue;let a=u.filter(c=>"autoOverflow"in c),i=a.filter(c=>c.autoOverflow>0),f=i.reduce((c,d)=>c+d.autoOverflow,0),l=Math.min(f,s);for(let c of i){let d=Math.floor(c.autoOverflow/f*l);c.width+=d,s-=d}let D=Math.floor(s/a.length);for(let c=0;c<a.length;c+=1){let d=a[c];c===a.length-1?d.width+=s:d.width+=D,s-=D}}return n}function Cu(e,t,n){let r=mu(n,t);return hu(r,e),gu(r,e)}B(),B(),B();var Le=10,zt=(e=0)=>t=>`\x1B[${t+e}m`,Wt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Yt=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`;function Fu(){let e=new Map,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],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],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};t.color.gray=t.color.blackBright,t.bgColor.bgGray=t.bgColor.bgBlackBright,t.color.grey=t.color.blackBright,t.bgColor.bgGrey=t.bgColor.bgBlackBright;for(let[n,r]of Object.entries(t)){for(let[u,o]of Object.entries(r))t[u]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},r[u]=t[u],e.set(o[0],o[1]);Object.defineProperty(t,n,{value:r,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=zt(),t.color.ansi256=Wt(),t.color.ansi16m=Yt(),t.bgColor.ansi=zt(Le),t.bgColor.ansi256=Wt(Le),t.bgColor.ansi16m=Yt(Le),Object.defineProperties(t,{rgbToAnsi256:{value:(n,r,u)=>n===r&&r===u?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(r/255*5)+Math.round(u/255*5),enumerable:!1},hexToRgb:{value:n=>{let r=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(n.toString(16));if(!r)return[0,0,0];let{colorString:u}=r.groups;u.length===3&&(u=u.split("").map(s=>s+s).join(""));let o=Number.parseInt(u,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:n=>t.rgbToAnsi256(...t.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value:n=>{if(n<8)return 30+n;if(n<16)return 90+(n-8);let r,u,o;if(n>=232)r=((n-232)*10+8)/255,u=r,o=r;else{n-=16;let i=n%36;r=Math.floor(n/36)/5,u=Math.floor(i/6)/5,o=i%6/5}let s=Math.max(r,u,o)*2;if(s===0)return 30;let a=30+(Math.round(o)<<2|Math.round(u)<<1|Math.round(r));return s===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(n,r,u)=>t.ansi256ToAnsi(t.rgbToAnsi256(n,r,u)),enumerable:!1},hexToAnsi:{value:n=>t.ansi256ToAnsi(t.hexToAnsi256(n)),enumerable:!1}}),t}var Eu=Fu(),yu=Eu,Fe=new Set(["\x1B","\x9B"]),wu=39,je="\x07",Vt="[",bu="]",Xt="m",Ge=`${bu}8;;`,Jt=e=>`${Fe.values().next().value}${Vt}${e}${Xt}`,Zt=e=>`${Fe.values().next().value}${Ge}${e}${je}`,Au=e=>e.split(" ").map(t=>T(t)),He=(e,t,n)=>{let r=[...t],u=!1,o=!1,s=T(Gt(e[e.length-1]));for(let[a,i]of r.entries()){let f=T(i);if(s+f<=n?e[e.length-1]+=i:(e.push(i),s=0),Fe.has(i)&&(u=!0,o=r.slice(a+1).join("").startsWith(Ge)),u){o?i===je&&(u=!1,o=!1):i===Xt&&(u=!1);continue}s+=f,s===n&&a<r.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},vu=e=>{let t=e.split(" "),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("")},Bu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",u,o,s=Au(e),a=[""];for(let[f,l]of e.split(" ").entries()){n.trim!==!1&&(a[a.length-1]=a[a.length-1].trimStart());let D=T(a[a.length-1]);if(f!==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&&s[f]>t){let c=t-D,d=1+Math.floor((s[f]-c-1)/t);Math.floor((s[f]-1)/t)<d&&a.push(""),He(a,l,t);continue}if(D+s[f]>t&&D>0&&s[f]>0){if(n.wordWrap===!1&&D<t){He(a,l,t);continue}a.push("")}if(D+s[f]>t&&n.wordWrap===!1){He(a,l,t);continue}a[a.length-1]+=l}n.trim!==!1&&(a=a.map(f=>vu(f)));let i=[...a.join(`
4
+ `)];for(let[f,l]of i.entries()){if(r+=l,Fe.has(l)){let{groups:c}=new RegExp(`(?:\\${Vt}(?<code>\\d+)m|\\${Ge}(?<uri>.*)${je})`).exec(i.slice(f).join(""))||{groups:{}};if(c.code!==void 0){let d=Number.parseFloat(c.code);u=d===wu?void 0:d}else c.uri!==void 0&&(o=c.uri.length===0?void 0:c.uri)}let D=yu.codes.get(Number(u));i[f+1]===`
5
+ `?(o&&(r+=Zt("")),u&&D&&(r+=Jt(D))):l===`
6
+ `&&(u&&D&&(r+=Jt(u)),o&&(r+=Zt(o)))}return r};function $u(e,t,n){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(r=>Au(r,t,n)).join(`
9
- `)}var Qt=e=>Array.from({length:e}).fill("");function $u(e,t){let n=[],r=0;for(let u of e){let o=0,s=u.map(i=>{var f;let l=(f=t[r])!=null?f:"";r+=1,i.preprocess&&(l=i.preprocess(l)),Ht(l)>i.width&&(l=Bu(l,i.width,{hard:!0}));let c=l.split(`
10
- `);if(i.postprocess){let{postprocess:D}=i;c=c.map((d,p)=>D.call(i,d,p))}return i.paddingTop&&c.unshift(...Qt(i.paddingTop)),i.paddingBottom&&c.push(...Qt(i.paddingBottom)),c.length>o&&(o=c.length),ke(me({},i),{lines:c})}),a=[];for(let i=0;i<o;i+=1){let f=s.map(l=>{var c;let D=(c=l.lines[i])!=null?c:"",d=Number.isFinite(l.width)?" ".repeat(l.width-M(D)):"",p=l.paddingLeftString;return l.align==="right"&&(p+=d),p+=D,l.align==="left"&&(p+=d),p+l.paddingRightString}).join("");a.push(f)}n.push(a.join(`
8
+ `).map(r=>Bu(r,t,n)).join(`
9
+ `)}var Qt=e=>Array.from({length:e}).fill("");function xu(e,t){let n=[],r=0;for(let u of e){let o=0,s=u.map(i=>{var f;let l=(f=t[r])!=null?f:"";r+=1,i.preprocess&&(l=i.preprocess(l)),Ht(l)>i.width&&(l=$u(l,i.width,{hard:!0}));let D=l.split(`
10
+ `);if(i.postprocess){let{postprocess:c}=i;D=D.map((d,p)=>c.call(i,d,p))}return i.paddingTop&&D.unshift(...Qt(i.paddingTop)),i.paddingBottom&&D.push(...Qt(i.paddingBottom)),D.length>o&&(o=D.length),ke(Ce({},i),{lines:D})}),a=[];for(let i=0;i<o;i+=1){let f=s.map(l=>{var D;let c=(D=l.lines[i])!=null?D:"",d=Number.isFinite(l.width)?" ".repeat(l.width-T(c)):"",p=l.paddingLeftString;return l.align==="right"&&(p+=d),p+=c,l.align==="left"&&(p+=d),p+l.paddingRightString}).join("");a.push(f)}n.push(a.join(`
11
11
  `))}return n.join(`
12
- `)}function xu(e,t){if(!e||e.length===0)return"";let n=du(e),r=n.length;if(r===0)return"";let{stdoutColumns:u,columns:o}=Du(t);if(o.length>r)throw new Error(`${o.length} columns defined, but only ${r} columns found`);let s=Cu(u,o,n);return e.map(a=>$u(s,a)).join(`
13
- `)}B();var Ou=["<",">","=",">=","<="];function Su(e){if(!Ou.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function Iu(e){let t=Object.keys(e).map(n=>{let[r,u]=n.split(" ");Su(r);let o=Number.parseInt(u,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${u}`);let s=e[n];return{operator:r,breakpoint:o,value:s}}).sort((n,r)=>r.breakpoint-n.breakpoint);return n=>{var r;return(r=t.find(({operator:u,breakpoint:o})=>u==="="&&n===o||u===">"&&n>o||u==="<"&&n<o||u===">="&&n>=o||u==="<="&&n<=o))==null?void 0:r.value}}const Pu=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),Tu=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),_u={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Mu(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,r)=>n.localeCompare(r)).map(n=>{const r=e[n],u="alias"in r;return u&&(t=!0),{name:n,flag:r,flagFormatted:`--${Tu(n)}`,aliasesEnabled:t,aliasFormatted:u?`-${r.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:_u}}}const en=e=>!e||(e.version??(e.help?e.help.version:void 0)),tn=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Nu(e){const t=[];e.name&&t.push(tn(e));const n=en(e)??("parent"in e&&en(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
- `}}function Ru(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
- `}}function ku(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(`
12
+ `)}function Ou(e,t){if(!e||e.length===0)return"";let n=pu(e),r=n.length;if(r===0)return"";let{stdoutColumns:u,columns:o}=cu(t);if(o.length>r)throw new Error(`${o.length} columns defined, but only ${r} columns found`);let s=Cu(u,o,n);return e.map(a=>xu(s,a)).join(`
13
+ `)}B();var Iu=["<",">","=",">=","<="];function Su(e){if(!Iu.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function Pu(e){let t=Object.keys(e).map(n=>{let[r,u]=n.split(" ");Su(r);let o=Number.parseInt(u,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${u}`);let s=e[n];return{operator:r,breakpoint:o,value:s}}).sort((n,r)=>r.breakpoint-n.breakpoint);return n=>{var r;return(r=t.find(({operator:u,breakpoint:o})=>u==="="&&n===o||u===">"&&n>o||u==="<"&&n<o||u===">="&&n>=o||u==="<="&&n<=o))==null?void 0:r.value}}const Mu=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),_u=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Tu={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:e=>e.trim()},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function Nu(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((n,r)=>n.localeCompare(r)).map(n=>{const r=e[n],u="alias"in r;return u&&(t=!0),{name:n,flag:r,flagFormatted:`--${_u(n)}`,aliasesEnabled:t,aliasFormatted:u?`-${r.alias}`:void 0}}).map(n=>(n.aliasesEnabled=t,[{type:"flagName",data:n},{type:"flagDescription",data:n}])),tableBreakpoints:Tu}}}const en=e=>!e||(e.version??(e.help?e.help.version:void 0)),tn=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Ru(e){const t=[];e.name&&t.push(tn(e));const n=en(e)??("parent"in e&&en(e.parent));if(n&&t.push(`v${n}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
+ `}}function ku(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
+ `}}function Lu(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(`
16
16
  `):t.usage}}:void 0;if(e.name){const n=[],r=[tn(e)];if(e.flags&&Object.keys(e.flags).length>0&&r.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:u}=e,o=u.indexOf("--"),s=o>-1&&u.slice(o+1).some(a=>a.startsWith("<"));r.push(u.map(a=>a!=="--"?a:s?"--":"[--]").join(" "))}if(r.length>1&&n.push(r.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(`
17
- `)}}}}function Lu(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}}}function ju(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Mu(e.flags),indentBody:0}}}function Gu(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(`
18
- `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}function Hu(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}}}const Uu=e=>[Nu,Ru,ku,Lu,ju,Gu,Hu].map(t=>t(e)).filter(Boolean),qu=Pe.WriteStream.prototype.hasColors();class Ku{text(t){return t}bold(t){return qu?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replace(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:r=2}){return`${(t?`${this.heading(t)}
17
+ `)}}}}function ju(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}}}function Gu(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Nu(e.flags),indentBody:0}}}function Hu(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(`
18
+ `)),n)return{id:"examples",type:"section",data:{title:"Examples:",body:n}}}function Uu(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}}}const qu=e=>[Ru,ku,Lu,ju,Gu,Hu,Uu].map(t=>t(e)).filter(Boolean),Ku=Pe.WriteStream.prototype.hasColors();class zu{text(t){return t}bold(t){return Ku?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:n}){return t.replace(/^/gm," ".repeat(n))}heading(t){return this.bold(t)}section({title:t,body:n,indentBody:r=2}){return`${(t?`${this.heading(t)}
19
19
  `:"")+(n?this.indentText({text:this.render(n),spaces:r}):"")}
20
- `}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return xu(t.map(u=>u.map(o=>this.render(o))),r?Iu(r):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:r,aliasesEnabled:u,aliasFormatted:o}=t;let s="";if(o?s+=`${o}, `:u&&(s+=" "),s+=r,"placeholder"in n&&typeof n.placeholder=="string")s+=`${this.flagOperator(t)}${n.placeholder}`;else{const a=this.flagParameter("type"in n?n.type:n);a&&(s+=`${this.flagOperator(t)}${a}`)}return s}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:r}=t;typeof r=="function"&&(r=r()),r&&(n+=` (default: ${this.flagDefault(r)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
21
- `);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)}`)}}const Ue=/^[\w.-]+$/,{stringify:O}=JSON,zu=/[|\\{}()[\]^$+*?.]/;function qe(e){const t=[];let n,r;for(const u of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${O(r)} must be last`);const o=u[0],s=u[u.length-1];let a;if(o==="<"&&s===">"&&(a=!0,n))throw new Error(`Invalid parameter: Required parameter ${O(u)} cannot come after optional parameter ${O(n)}`);if(o==="["&&s==="]"&&(a=!1,n=u),a===void 0)throw new Error(`Invalid parameter: ${O(u)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=u.slice(1,-1);const f=i.slice(-3)==="...";f&&(r=u,i=i.slice(0,-3));const l=i.match(zu);if(l)throw new Error(`Invalid parameter: ${O(u)}. Invalid character found ${O(l[0])}`);t.push({name:i,required:a,spread:f})}return t}function Ke(e,t,n,r){for(let u=0;u<t.length;u+=1){const{name:o,required:s,spread:a}=t[u],i=Pu(o);if(i in e)throw new Error(`Invalid parameter: ${O(o)} is used more than once.`);const f=a?n.slice(u):n[u];if(a&&(u=t.length),s&&(!f||a&&f.length===0))return console.error(`Error: Missing required parameter ${O(o)}
22
- `),r(),process.exit(1);e[i]=f}}function Wu(e){return e===void 0||e!==!1}function nn(e,t,n,r){const u={...t.flags},o=t.version;o&&(u.version={type:Boolean,description:"Show version"});const{help:s}=t,a=Wu(s);a&&!("help"in u)&&(u.help={type:Boolean,alias:"h",description:"Show help"});const i=Yr(u,r,{ignore:t.ignoreArgv}),f=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return f(),process.exit(0);const l=new Ku,c=a&&s?.render?s.render:p=>l.render(p),D=p=>{const m=Uu({...t,...p?{help:p}:{},flags:u});console.log(c(m,l))};if(a&&i.flags.help===!0)return D(),process.exit(0);if(t.parameters){let{parameters:p}=t,m=i._;const h=p.indexOf("--"),g=p.slice(h+1),E=Object.create(null);if(h>-1&&g.length>0){p=p.slice(0,h);const $=i._["--"];m=m.slice(0,-$.length||void 0),Ke(E,qe(p),m,D),Ke(E,qe(g),$,D)}else Ke(E,qe(p),m,D);Object.assign(i._,E)}const d={...i,showVersion:f,showHelp:D};return typeof n=="function"&&n(d),{command:e,...d}}function Vu(e,t){const n=new Map;for(const r of t){const u=[r.options.name],{alias:o}=r.options;o&&(Array.isArray(o)?u.push(...o):u.push(o));for(const s of u){if(n.has(s))throw new Error(`Duplicate command name found: ${O(s)}`);n.set(s,r)}}return n.get(e)}function Yu(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ue.test(e.name)))throw new Error(`Invalid script name: ${O(e.name)}`);const r=n[0];if(e.commands&&Ue.test(r)){const u=Vu(r,e.commands);if(u)return nn(u.options.name,{...u.options,parent:e},u.callback,n.slice(1))}return nn(void 0,e,t,n)}function rn(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ue.test(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}var Xu=Dr(import.meta.url),w=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function G(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var H={exports:{}},ze,un;function Ju(){if(un)return ze;un=1,ze=r,r.sync=u;var e=Te;function t(o,s){var a=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var f=a[i].toLowerCase();if(f&&o.substr(-f.length).toLowerCase()===f)return!0}return!1}function n(o,s,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(s,a)}function r(o,s,a){e.stat(o,function(i,f){a(i,i?!1:n(f,o,s))})}function u(o,s){return n(e.statSync(o),o,s)}return ze}var We,on;function Zu(){if(on)return We;on=1,We=t,t.sync=n;var e=Te;function t(o,s,a){e.stat(o,function(i,f){a(i,i?!1:r(f,s))})}function n(o,s){return r(e.statSync(o),s)}function r(o,s){return o.isFile()&&u(o,s)}function u(o,s){var a=o.mode,i=o.uid,f=o.gid,l=s.uid!==void 0?s.uid:process.getuid&&process.getuid(),c=s.gid!==void 0?s.gid:process.getgid&&process.getgid(),D=parseInt("100",8),d=parseInt("010",8),p=parseInt("001",8),m=D|d,h=a&p||a&d&&f===c||a&D&&i===l||a&m&&l===0;return h}return We}var Ce;process.platform==="win32"||w.TESTING_WINDOWS?Ce=Ju():Ce=Zu();var Qu=Ve;Ve.sync=eo;function Ve(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,u){Ve(e,t||{},function(o,s){o?u(o):r(s)})})}Ce(e,t||{},function(r,u){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,u=!1),n(r,u)})}function eo(e,t){try{return Ce.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const U=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",sn=j,to=U?";":":",an=Qu,Dn=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),cn=(e,t)=>{const n=t.colon||to,r=e.match(/\//)||U&&e.match(/\\/)?[""]:[...U?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],u=U?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=U?u.split(n):[""];return U&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:u}},ln=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:u,pathExtExe:o}=cn(e,t),s=[],a=f=>new Promise((l,c)=>{if(f===r.length)return t.all&&s.length?l(s):c(Dn(e));const D=r[f],d=/^".*"$/.test(D)?D.slice(1,-1):D,p=sn.join(d,e),m=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+p:p;l(i(m,f,0))}),i=(f,l,c)=>new Promise((D,d)=>{if(c===u.length)return D(a(l+1));const p=u[c];an(f+p,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)s.push(f+p);else return D(f+p);return D(i(f,l,c+1))})});return n?a(0).then(f=>n(null,f),n):a(0)},no=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:u}=cn(e,t),o=[];for(let s=0;s<n.length;s++){const a=n[s],i=/^".*"$/.test(a)?a.slice(1,-1):a,f=sn.join(i,e),l=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;for(let c=0;c<r.length;c++){const D=l+r[c];try{if(an.sync(D,{pathExt:u}))if(t.all)o.push(D);else return D}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Dn(e)};var ro=ln;ln.sync=no;var Ye={exports:{}};const fn=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Ye.exports=fn,Ye.exports.default=fn;var uo=Ye.exports;const dn=j,oo=ro,so=uo;function pn(e,t){const n=e.options.env||process.env,r=process.cwd(),u=e.options.cwd!=null,o=u&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let s;try{s=oo.sync(e.command,{path:n[so({env:n})],pathExt:t?dn.delimiter:void 0})}catch{}finally{o&&process.chdir(r)}return s&&(s=dn.resolve(u?e.options.cwd:"",s)),s}function io(e){return pn(e)||pn(e,!0)}var ao=io,Xe={};const Je=/([()\][%!^"`<>&|;, *?])/g;function Do(e){return e=e.replace(Je,"^$1"),e}function co(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Je,"^$1"),t&&(e=e.replace(Je,"^$1")),e}Xe.command=Do,Xe.argument=co;var lo=/^#!(.*)/;const fo=lo;var po=(e="")=>{const t=e.match(fo);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),u=n.split("/").pop();return u==="env"?r:r?`${u} ${r}`:u};const Ze=Te,mo=po;function ho(e){const n=Buffer.alloc(150);let r;try{r=Ze.openSync(e,"r"),Ze.readSync(r,n,0,150,0),Ze.closeSync(r)}catch{}return mo(n.toString())}var Co=ho;const go=j,mn=ao,hn=Xe,Fo=Co,Eo=process.platform==="win32",yo=/\.(?:com|exe)$/i,wo=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function bo(e){e.file=mn(e);const t=e.file&&Fo(e.file);return t?(e.args.unshift(e.file),e.command=t,mn(e)):e.file}function vo(e){if(!Eo)return e;const t=bo(e),n=!yo.test(t);if(e.options.forceShell||n){const r=wo.test(t);e.command=go.normalize(e.command),e.command=hn.command(e.command),e.args=e.args.map(o=>hn.argument(o,r));const u=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${u}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Ao(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:vo(r)}var Bo=Ao;const Qe=process.platform==="win32";function et(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function $o(e,t){if(!Qe)return;const n=e.emit;e.emit=function(r,u){if(r==="exit"){const o=Cn(u,t);if(o)return n.call(e,"error",o)}return n.apply(e,arguments)}}function Cn(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawn"):null}function xo(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawnSync"):null}var Oo={hookChildProcess:$o,verifyENOENT:Cn,verifyENOENTSync:xo,notFoundError:et};const gn=lr,tt=Bo,nt=Oo;function Fn(e,t,n){const r=tt(e,t,n),u=gn.spawn(r.command,r.args,r.options);return nt.hookChildProcess(u,r),u}function So(e,t,n){const r=tt(e,t,n),u=gn.spawnSync(r.command,r.args,r.options);return u.error=u.error||nt.verifyENOENTSync(u.status,r),u}H.exports=Fn,H.exports.spawn=Fn,H.exports.sync=So,H.exports._parse=tt,H.exports._enoent=nt;var Io=H.exports,Po=G(Io);function To(e){const t=typeof e=="string"?`
20
+ `}table({tableData:t,tableOptions:n,tableBreakpoints:r}){return Ou(t.map(u=>u.map(o=>this.render(o))),r?Pu(r):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:r,aliasesEnabled:u,aliasFormatted:o}=t;let s="";if(o?s+=`${o}, `:u&&(s+=" "),s+=r,"placeholder"in n&&typeof n.placeholder=="string")s+=`${this.flagOperator(t)}${n.placeholder}`;else{const a=this.flagParameter("type"in n?n.type:n);a&&(s+=`${this.flagOperator(t)}${a}`)}return s}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let n="description"in t?t.description??"":"";if("default"in t){let{default:r}=t;typeof r=="function"&&(r=r()),r&&(n+=` (default: ${this.flagDefault(r)})`)}return n}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(n=>this.render(n)).join(`
21
+ `);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)}`)}}const Ue=/^[\w.-]+$/,{stringify:O}=JSON,Wu=/[|\\{}()[\]^$+*?.]/;function qe(e){const t=[];let n,r;for(const u of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${O(r)} must be last`);const o=u[0],s=u[u.length-1];let a;if(o==="<"&&s===">"&&(a=!0,n))throw new Error(`Invalid parameter: Required parameter ${O(u)} cannot come after optional parameter ${O(n)}`);if(o==="["&&s==="]"&&(a=!1,n=u),a===void 0)throw new Error(`Invalid parameter: ${O(u)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let i=u.slice(1,-1);const f=i.slice(-3)==="...";f&&(r=u,i=i.slice(0,-3));const l=i.match(Wu);if(l)throw new Error(`Invalid parameter: ${O(u)}. Invalid character found ${O(l[0])}`);t.push({name:i,required:a,spread:f})}return t}function Ke(e,t,n,r){for(let u=0;u<t.length;u+=1){const{name:o,required:s,spread:a}=t[u],i=Mu(o);if(i in e)throw new Error(`Invalid parameter: ${O(o)} is used more than once.`);const f=a?n.slice(u):n[u];if(a&&(u=t.length),s&&(!f||a&&f.length===0))return console.error(`Error: Missing required parameter ${O(o)}
22
+ `),r(),process.exit(1);e[i]=f}}function Yu(e){return e===void 0||e!==!1}function nn(e,t,n,r){const u={...t.flags},o=t.version;o&&(u.version={type:Boolean,description:"Show version"});const{help:s}=t,a=Yu(s);a&&!("help"in u)&&(u.help={type:Boolean,alias:"h",description:"Show help"});const i=Xr(u,r,{ignore:t.ignoreArgv}),f=()=>{console.log(t.version)};if(o&&i.flags.version===!0)return f(),process.exit(0);const l=new zu,D=a&&s?.render?s.render:p=>l.render(p),c=p=>{const m=qu({...t,...p?{help:p}:{},flags:u});console.log(D(m,l))};if(a&&i.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:p}=t,m=i._;const h=p.indexOf("--"),C=p.slice(h+1),y=Object.create(null);if(h>-1&&C.length>0){p=p.slice(0,h);const $=i._["--"];m=m.slice(0,-$.length||void 0),Ke(y,qe(p),m,c),Ke(y,qe(C),$,c)}else Ke(y,qe(p),m,c);Object.assign(i._,y)}const d={...i,showVersion:f,showHelp:c};return typeof n=="function"&&n(d),{command:e,...d}}function Vu(e,t){const n=new Map;for(const r of t){const u=[r.options.name],{alias:o}=r.options;o&&(Array.isArray(o)?u.push(...o):u.push(o));for(const s of u){if(n.has(s))throw new Error(`Duplicate command name found: ${O(s)}`);n.set(s,r)}}return n.get(e)}function Xu(e,t,n=process.argv.slice(2)){if(!e)throw new Error("Options is required");if("name"in e&&(!e.name||!Ue.test(e.name)))throw new Error(`Invalid script name: ${O(e.name)}`);const r=n[0];if(e.commands&&Ue.test(r)){const u=Vu(r,e.commands);if(u)return nn(u.options.name,{...u.options,parent:e},u.callback,n.slice(1))}return nn(void 0,e,t,n)}function rn(e,t){if(!e)throw new Error("Command options are required");const{name:n}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ue.test(n))throw new Error(`Invalid command name ${JSON.stringify(n)}. Command names must be one word.`);return{options:e,callback:t}}var Ju=Dr(import.meta.url),b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function U(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var q={exports:{}},ze,un;function Zu(){if(un)return ze;un=1,ze=r,r.sync=u;var e=Me;function t(o,s){var a=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!a||(a=a.split(";"),a.indexOf("")!==-1))return!0;for(var i=0;i<a.length;i++){var f=a[i].toLowerCase();if(f&&o.substr(-f.length).toLowerCase()===f)return!0}return!1}function n(o,s,a){return!o.isSymbolicLink()&&!o.isFile()?!1:t(s,a)}function r(o,s,a){e.stat(o,function(i,f){a(i,i?!1:n(f,o,s))})}function u(o,s){return n(e.statSync(o),o,s)}return ze}var We,on;function Qu(){if(on)return We;on=1,We=t,t.sync=n;var e=Me;function t(o,s,a){e.stat(o,function(i,f){a(i,i?!1:r(f,s))})}function n(o,s){return r(e.statSync(o),s)}function r(o,s){return o.isFile()&&u(o,s)}function u(o,s){var a=o.mode,i=o.uid,f=o.gid,l=s.uid!==void 0?s.uid:process.getuid&&process.getuid(),D=s.gid!==void 0?s.gid:process.getgid&&process.getgid(),c=parseInt("100",8),d=parseInt("010",8),p=parseInt("001",8),m=c|d,h=a&p||a&d&&f===D||a&c&&i===l||a&m&&l===0;return h}return We}var Ee;process.platform==="win32"||b.TESTING_WINDOWS?Ee=Zu():Ee=Qu();var eo=Ye;Ye.sync=to;function Ye(e,t,n){if(typeof t=="function"&&(n=t,t={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,u){Ye(e,t||{},function(o,s){o?u(o):r(s)})})}Ee(e,t||{},function(r,u){r&&(r.code==="EACCES"||t&&t.ignoreErrors)&&(r=null,u=!1),n(r,u)})}function to(e,t){try{return Ee.sync(e,t||{})}catch(n){if(t&&t.ignoreErrors||n.code==="EACCES")return!1;throw n}}const K=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",sn=j,no=K?";":":",an=eo,Dn=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),cn=(e,t)=>{const n=t.colon||no,r=e.match(/\//)||K&&e.match(/\\/)?[""]:[...K?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(n)],u=K?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=K?u.split(n):[""];return K&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:r,pathExt:o,pathExtExe:u}},ln=(e,t,n)=>{typeof t=="function"&&(n=t,t={}),t||(t={});const{pathEnv:r,pathExt:u,pathExtExe:o}=cn(e,t),s=[],a=f=>new Promise((l,D)=>{if(f===r.length)return t.all&&s.length?l(s):D(Dn(e));const c=r[f],d=/^".*"$/.test(c)?c.slice(1,-1):c,p=sn.join(d,e),m=!d&&/^\.[\\\/]/.test(e)?e.slice(0,2)+p:p;l(i(m,f,0))}),i=(f,l,D)=>new Promise((c,d)=>{if(D===u.length)return c(a(l+1));const p=u[D];an(f+p,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)s.push(f+p);else return c(f+p);return c(i(f,l,D+1))})});return n?a(0).then(f=>n(null,f),n):a(0)},ro=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:r,pathExtExe:u}=cn(e,t),o=[];for(let s=0;s<n.length;s++){const a=n[s],i=/^".*"$/.test(a)?a.slice(1,-1):a,f=sn.join(i,e),l=!i&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;for(let D=0;D<r.length;D++){const c=l+r[D];try{if(an.sync(c,{pathExt:u}))if(t.all)o.push(c);else return c}catch{}}}if(t.all&&o.length)return o;if(t.nothrow)return null;throw Dn(e)};var uo=ln;ln.sync=ro;var Ve={exports:{}};const fn=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};Ve.exports=fn,Ve.exports.default=fn;var oo=Ve.exports;const dn=j,so=uo,io=oo;function pn(e,t){const n=e.options.env||process.env,r=process.cwd(),u=e.options.cwd!=null,o=u&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(e.options.cwd)}catch{}let s;try{s=so.sync(e.command,{path:n[io({env:n})],pathExt:t?dn.delimiter:void 0})}catch{}finally{o&&process.chdir(r)}return s&&(s=dn.resolve(u?e.options.cwd:"",s)),s}function ao(e){return pn(e)||pn(e,!0)}var Do=ao,Xe={};const Je=/([()\][%!^"`<>&|;, *?])/g;function co(e){return e=e.replace(Je,"^$1"),e}function lo(e,t){return e=`${e}`,e=e.replace(/(\\*)"/g,'$1$1\\"'),e=e.replace(/(\\*)$/,"$1$1"),e=`"${e}"`,e=e.replace(Je,"^$1"),t&&(e=e.replace(Je,"^$1")),e}Xe.command=co,Xe.argument=lo;var fo=/^#!(.*)/;const po=fo;var mo=(e="")=>{const t=e.match(po);if(!t)return null;const[n,r]=t[0].replace(/#! ?/,"").split(" "),u=n.split("/").pop();return u==="env"?r:r?`${u} ${r}`:u};const Ze=Me,ho=mo;function go(e){const n=Buffer.alloc(150);let r;try{r=Ze.openSync(e,"r"),Ze.readSync(r,n,0,150,0),Ze.closeSync(r)}catch{}return ho(n.toString())}var Co=go;const Fo=j,mn=Do,hn=Xe,Eo=Co,yo=process.platform==="win32",wo=/\.(?:com|exe)$/i,bo=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ao(e){e.file=mn(e);const t=e.file&&Eo(e.file);return t?(e.args.unshift(e.file),e.command=t,mn(e)):e.file}function vo(e){if(!yo)return e;const t=Ao(e),n=!wo.test(t);if(e.options.forceShell||n){const r=bo.test(t);e.command=Fo.normalize(e.command),e.command=hn.command(e.command),e.args=e.args.map(o=>hn.argument(o,r));const u=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${u}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function Bo(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);const r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:vo(r)}var $o=Bo;const Qe=process.platform==="win32";function et(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function xo(e,t){if(!Qe)return;const n=e.emit;e.emit=function(r,u){if(r==="exit"){const o=gn(u,t);if(o)return n.call(e,"error",o)}return n.apply(e,arguments)}}function gn(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawn"):null}function Oo(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawnSync"):null}var Io={hookChildProcess:xo,verifyENOENT:gn,verifyENOENTSync:Oo,notFoundError:et};const Cn=lr,tt=$o,nt=Io;function Fn(e,t,n){const r=tt(e,t,n),u=Cn.spawn(r.command,r.args,r.options);return nt.hookChildProcess(u,r),u}function So(e,t,n){const r=tt(e,t,n),u=Cn.spawnSync(r.command,r.args,r.options);return u.error=u.error||nt.verifyENOENTSync(u.status,r),u}q.exports=Fn,q.exports.spawn=Fn,q.exports.sync=So,q.exports._parse=tt,q.exports._enoent=nt;var Po=q.exports,Mo=U(Po);function _o(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.charCodeAt(),n=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}function En(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}function _o(e={}){const{cwd:t=_.cwd(),path:n=_.env[En()],execPath:r=_.execPath}=e;let u;const o=t instanceof URL?fr.fileURLToPath(t):t;let s=L.resolve(o);const a=[];for(;u!==s;)a.push(L.join(s,"node_modules/.bin")),u=s,s=L.resolve(s,"..");return a.push(L.resolve(o,r,"..")),[...a,n].join(L.delimiter)}function Mo({env:e=_.env,...t}={}){e={...e};const n=En({env:e});return t.path=e[n],e[n]=_o(t),e}const No=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const u=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);!Ro(u,o)&&r||Object.defineProperty(e,n,o)},Ro=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)},ko=(e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},Lo=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,jo=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Go=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ho=(e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,u=Lo.bind(null,r,t.toString());Object.defineProperty(u,"name",Go),Object.defineProperty(e,"toString",{...jo,value:u})};function Uo(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const u of Reflect.ownKeys(t))No(e,t,u,n);return ko(e,t),Ho(e,t,r),e}const ge=new WeakMap,yn=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const u=e.displayName||e.name||"<anonymous>",o=function(...s){if(ge.set(o,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${u}\` can only be called once`);return n};return Uo(o,e),ge.set(o,r),o};yn.callCount=e=>{if(!ge.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return ge.get(e)};const qo=()=>{const e=bn-wn+1;return Array.from({length:e},Ko)},Ko=(e,t)=>({name:`SIGRT${t+1}`,number:wn+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),wn=34,bn=64,zo=[{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"}],vn=()=>{const e=qo();return[...zo,...e].map(Wo)},Wo=({name:e,number:t,description:n,action:r,forced:u=!1,standard:o})=>{const{signals:{[e]:s}}=It,a=s!==void 0;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:u,standard:o}},Vo=()=>{const e=vn();return Object.fromEntries(e.map(Yo))},Yo=({name:e,number:t,description:n,supported:r,action:u,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:u,forced:o,standard:s}],Xo=Vo(),Jo=()=>{const e=vn(),t=bn+1,n=Array.from({length:t},(r,u)=>Zo(u,e));return Object.assign({},...n)},Zo=(e,t)=>{const n=Qo(e,t);if(n===void 0)return{};const{name:r,description:u,supported:o,action:s,forced:a,standard:i}=n;return{[e]:{name:r,number:e,description:u,supported:o,action:s,forced:a,standard:i}}},Qo=(e,t)=>{const n=t.find(({name:r})=>It.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)};Jo();const es=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:u,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${u})`:o!==void 0?`failed with exit code ${o}`:"failed",An=({stdout:e,stderr:t,all:n,error:r,signal:u,exitCode:o,command:s,escapedCommand:a,timedOut:i,isCanceled:f,killed:l,parsed:{options:{timeout:c}}})=>{o=o===null?void 0:o,u=u===null?void 0:u;const D=u===void 0?void 0:Xo[u].description,d=r&&r.code,m=`Command ${es({timedOut:i,timeout:c,errorCode:d,signal:u,signalDescription:D,exitCode:o,isCanceled:f})}: ${s}`,h=Object.prototype.toString.call(r)==="[object Error]",g=h?`${m}
26
- ${r.message}`:m,E=[g,t,e].filter(Boolean).join(`
27
- `);return h?(r.originalMessage=r.message,r.message=E):r=new Error(E),r.shortMessage=g,r.command=s,r.escapedCommand=a,r.exitCode=o,r.signal=u,r.signalDescription=D,r.stdout=e,r.stderr=t,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!i,r.isCanceled=f,r.killed=l&&!i,r},Fe=["stdin","stdout","stderr"],ts=e=>Fe.some(t=>e[t]!==void 0),ns=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return Fe.map(r=>e[r]);if(ts(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Fe.map(r=>`\`${r}\``).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,Fe.length);return Array.from({length:n},(r,u)=>t[u])};var q={exports:{}},Ee={exports:{}};Ee.exports;var Bn;function rs(){return Bn||(Bn=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")}(Ee)),Ee.exports}var F=w.process;const N=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"};if(!N(F))q.exports=function(){return function(){}};else{var us=Pt,Q=rs(),os=/^win/i.test(F.platform),ye=Tt;typeof ye!="function"&&(ye=ye.EventEmitter);var A;F.__signal_exit_emitter__?A=F.__signal_exit_emitter__:(A=F.__signal_exit_emitter__=new ye,A.count=0,A.emitted={}),A.infinite||(A.setMaxListeners(1/0),A.infinite=!0),q.exports=function(e,t){if(!N(w.process))return function(){};us.equal(typeof e,"function","a callback must be provided for exit handler"),ee===!1&&$n();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){A.removeListener(n,e),A.listeners("exit").length===0&&A.listeners("afterexit").length===0&&rt()};return A.on(n,e),r};var rt=function(){!ee||!N(w.process)||(ee=!1,Q.forEach(function(t){try{F.removeListener(t,ut[t])}catch{}}),F.emit=ot,F.reallyExit=xn,A.count-=1)};q.exports.unload=rt;var K=function(t,n,r){A.emitted[t]||(A.emitted[t]=!0,A.emit(t,n,r))},ut={};Q.forEach(function(e){ut[e]=function(){if(N(w.process)){var n=F.listeners(e);n.length===A.count&&(rt(),K("exit",null,e),K("afterexit",null,e),os&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),q.exports.signals=function(){return Q};var ee=!1,$n=function(){ee||!N(w.process)||(ee=!0,A.count+=1,Q=Q.filter(function(t){try{return F.on(t,ut[t]),!0}catch{return!1}}),F.emit=is,F.reallyExit=ss)};q.exports.load=$n;var xn=F.reallyExit,ss=function(t){N(w.process)&&(F.exitCode=t||0,K("exit",F.exitCode,null),K("afterexit",F.exitCode,null),xn.call(F,F.exitCode))},ot=F.emit,is=function(t,n){if(t==="exit"&&N(w.process)){n!==void 0&&(F.exitCode=n);var r=ot.apply(this,arguments);return K("exit",F.exitCode,null),K("afterexit",F.exitCode,null),r}else return ot.apply(this,arguments)}}var as=q.exports,Ds=G(as);const cs=1e3*5,ls=(e,t="SIGTERM",n={})=>{const r=e(t);return fs(e,t,n,r),r},fs=(e,t,n,r)=>{if(!ds(t,n,r))return;const u=ms(n),o=setTimeout(()=>{e("SIGKILL")},u);o.unref&&o.unref()},ds=(e,{forceKillAfterTimeout:t},n)=>ps(e)&&t!==!1&&n,ps=e=>e===dr.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",ms=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return cs;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},hs=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Cs=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},gs=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let u;const o=new Promise((a,i)=>{u=setTimeout(()=>{Cs(e,n,i)},t)}),s=r.finally(()=>{clearTimeout(u)});return Promise.race([o,s])},Fs=({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})`)},Es=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const u=Ds(()=>{e.kill()});return r.finally(()=>{u()})};function ys(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var te={exports:{}};const{PassThrough:ws}=_e;var bs=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const r=n==="buffer";let u=!1;t?u=!(n||r):n=n||"utf8",r&&(n=null);const o=new ws({objectMode:u});n&&o.setEncoding(n);let s=0;const a=[];return o.on("data",i=>{a.push(i),u?s=a.length:s+=i.length}),o.getBufferedValue=()=>t?a:r?Buffer.concat(a,s):a.join(""),o.getBufferedLength=()=>s,o};const{constants:vs}=pr,As=_e,{promisify:Bs}=_t,$s=bs,xs=Bs(As.pipeline);class On extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function st(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,r=$s(t);return await new Promise((u,o)=>{const s=a=>{a&&r.getBufferedLength()<=vs.MAX_LENGTH&&(a.bufferedData=r.getBufferedValue()),o(a)};(async()=>{try{await xs(e,r),u()}catch(a){s(a)}})(),r.on("data",()=>{r.getBufferedLength()>n&&s(new On)})}),r.getBufferedValue()}te.exports=st,te.exports.buffer=(e,t)=>st(e,{...t,encoding:"buffer"}),te.exports.array=(e,t)=>st(e,{...t,array:!0}),te.exports.MaxBufferError=On;var Os=te.exports,Sn=G(Os);const{PassThrough:Ss}=_e;var Is=function(){var e=[],t=new Ss({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",u),Array.prototype.slice.call(arguments).forEach(n),t;function n(o){return Array.isArray(o)?(o.forEach(n),this):(e.push(o),o.once("end",u.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function r(){return e.length==0}function u(o){e=e.filter(function(s){return s!==o}),!e.length&&t.readable&&t.end()}},Ps=G(Is);const Ts=(e,t)=>{t!==void 0&&(ys(t)?t.pipe(e.stdin):e.stdin.end(t))},_s=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=Ps();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},it=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},at=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?Sn(e,{encoding:t,maxBuffer:r}):Sn.buffer(e,{maxBuffer:r})},Ms=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:u,maxBuffer:o},s)=>{const a=at(e,{encoding:r,buffer:u,maxBuffer:o}),i=at(t,{encoding:r,buffer:u,maxBuffer:o}),f=at(n,{encoding:r,buffer:u,maxBuffer:o*2});try{return await Promise.all([s,a,i,f])}catch(l){return Promise.all([{error:l,signal:l.signal,timedOut:l.timedOut},it(e,a),it(t,i),it(n,f)])}},Ns=(async()=>{})().constructor.prototype,Rs=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Ns,e)]),In=(e,t)=>{for(const[n,r]of Rs){const u=typeof t=="function"?(...o)=>Reflect.apply(r.value,t(),o):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:u})}return e},ks=e=>new Promise((t,n)=>{e.on("exit",(r,u)=>{t({exitCode:r,signal:u})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),Pn=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Ls=/^[\w.-]+$/,js=/"/g,Gs=e=>typeof e!="string"||Ls.test(e)?e:`"${e.replace(js,'\\"')}"`,Hs=(e,t)=>Pn(e,t).join(" "),Us=(e,t)=>Pn(e,t).map(n=>Gs(n)).join(" "),qs=1e3*1e3*100,Ks=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:u})=>{const o=t?{..._.env,...e}:e;return n?Mo({env:o,cwd:r,execPath:u}):o},zs=(e,t,n={})=>{const r=Po._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:qs,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||_.cwd(),execPath:_.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...n},n.env=Ks(n),n.stdio=ns(n),_.platform==="win32"&&L.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},Dt=(e,t,n)=>typeof t!="string"&&!cr.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?To(t):t;function z(e,t,n){const r=zs(e,t,n),u=Hs(e,t),o=Us(e,t);Fs(r.options);let s;try{s=St.spawn(r.file,r.args,r.options)}catch(d){const p=new St.ChildProcess,m=Promise.reject(An({error:d,stdout:"",stderr:"",all:"",command:u,escapedCommand:o,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return In(p,m)}const a=ks(s),i=gs(s,r.options,a),f=Es(s,r.options,i),l={isCanceled:!1};s.kill=ls.bind(null,s.kill.bind(s)),s.cancel=hs.bind(null,s,l);const D=yn(async()=>{const[{error:d,exitCode:p,signal:m,timedOut:h},g,E,$]=await Ms(s,r.options,f),k=Dt(r.options,g),I=Dt(r.options,E),v=Dt(r.options,$);if(d||p!==0||m!==null){const T=An({error:d,exitCode:p,signal:m,stdout:k,stderr:I,all:v,command:u,escapedCommand:o,parsed:r,timedOut:h,isCanceled:l.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:s.killed});if(!r.options.reject)return T;throw T}return{command:u,escapedCommand:o,exitCode:0,stdout:k,stderr:I,all:v,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Ts(s,r.options.input),s.all=_s(s,r.options),In(s,D)}class we{static create(t,n){return new t(n)}}const Ws={"":"<commit message>",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"},Vs=e=>`The output response must be in ${e} commit type:
28
- ${Ws[e]}`,Ys={"":"",gitmoji:"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
29
- ${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 neither fixes a bug nor adds a feature",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)}`},Tn=(e,t,n)=>["Generate a concise git commit message written in present tense for the following code diff with the given specifications below:",`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.",Ys[n],Vs(n)].filter(Boolean).join(`
30
- `),Xs=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),Js=e=>/^\:\w+\: (.*)$/.test(e),ne={OPEN_AI:"OPENAI_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",ANTHROPIC:"ANTHROPIC_KEY"},_n=Object.values(ne).map(e=>e);class be{constructor(t){this.handleError$=n=>{let r="An error occurred";return n.message&&(r=n.message),ae({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,n,r,u,o){return`${Tn(t,u,o)}
24
+ `.charCodeAt(),n=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===n&&(e=e.slice(0,-1)),e}function En(e={}){const{env:t=process.env,platform:n=process.platform}=e;return n!=="win32"?"PATH":Object.keys(t).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"}function To(e={}){const{cwd:t=_.cwd(),path:n=_.env[En()],execPath:r=_.execPath}=e;let u;const o=t instanceof URL?fr.fileURLToPath(t):t;let s=L.resolve(o);const a=[];for(;u!==s;)a.push(L.join(s,"node_modules/.bin")),u=s,s=L.resolve(s,"..");return a.push(L.resolve(o,r,"..")),[...a,n].join(L.delimiter)}function No({env:e=_.env,...t}={}){e={...e};const n=En({env:e});return t.path=e[n],e[n]=To(t),e}const Ro=(e,t,n,r)=>{if(n==="length"||n==="prototype"||n==="arguments"||n==="caller")return;const u=Object.getOwnPropertyDescriptor(e,n),o=Object.getOwnPropertyDescriptor(t,n);!ko(u,o)&&r||Object.defineProperty(e,n,o)},ko=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)},Lo=(e,t)=>{const n=Object.getPrototypeOf(t);n!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,n)},jo=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,Go=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ho=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Uo=(e,t,n)=>{const r=n===""?"":`with ${n.trim()}() `,u=jo.bind(null,r,t.toString());Object.defineProperty(u,"name",Ho),Object.defineProperty(e,"toString",{...Go,value:u})};function qo(e,t,{ignoreNonConfigurable:n=!1}={}){const{name:r}=e;for(const u of Reflect.ownKeys(t))Ro(e,t,u,n);return Lo(e,t),Uo(e,t,r),e}const ye=new WeakMap,yn=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let n,r=0;const u=e.displayName||e.name||"<anonymous>",o=function(...s){if(ye.set(o,++r),r===1)n=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${u}\` can only be called once`);return n};return qo(o,e),ye.set(o,r),o};yn.callCount=e=>{if(!ye.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return ye.get(e)};const Ko=()=>{const e=bn-wn+1;return Array.from({length:e},zo)},zo=(e,t)=>({name:`SIGRT${t+1}`,number:wn+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),wn=34,bn=64,Wo=[{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"}],An=()=>{const e=Ko();return[...Wo,...e].map(Yo)},Yo=({name:e,number:t,description:n,action:r,forced:u=!1,standard:o})=>{const{signals:{[e]:s}}=St,a=s!==void 0;return{name:e,number:a?s:t,description:n,supported:a,action:r,forced:u,standard:o}},Vo=()=>{const e=An();return Object.fromEntries(e.map(Xo))},Xo=({name:e,number:t,description:n,supported:r,action:u,forced:o,standard:s})=>[e,{name:e,number:t,description:n,supported:r,action:u,forced:o,standard:s}],Jo=Vo(),Zo=()=>{const e=An(),t=bn+1,n=Array.from({length:t},(r,u)=>Qo(u,e));return Object.assign({},...n)},Qo=(e,t)=>{const n=es(e,t);if(n===void 0)return{};const{name:r,description:u,supported:o,action:s,forced:a,standard:i}=n;return{[e]:{name:r,number:e,description:u,supported:o,action:s,forced:a,standard:i}}},es=(e,t)=>{const n=t.find(({name:r})=>St.signals[r]===e);return n!==void 0?n:t.find(r=>r.number===e)};Zo();const ts=({timedOut:e,timeout:t,errorCode:n,signal:r,signalDescription:u,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":n!==void 0?`failed with ${n}`:r!==void 0?`was killed with ${r} (${u})`:o!==void 0?`failed with exit code ${o}`:"failed",vn=({stdout:e,stderr:t,all:n,error:r,signal:u,exitCode:o,command:s,escapedCommand:a,timedOut:i,isCanceled:f,killed:l,parsed:{options:{timeout:D}}})=>{o=o===null?void 0:o,u=u===null?void 0:u;const c=u===void 0?void 0:Jo[u].description,d=r&&r.code,m=`Command ${ts({timedOut:i,timeout:D,errorCode:d,signal:u,signalDescription:c,exitCode:o,isCanceled:f})}: ${s}`,h=Object.prototype.toString.call(r)==="[object Error]",C=h?`${m}
26
+ ${r.message}`:m,y=[C,t,e].filter(Boolean).join(`
27
+ `);return h?(r.originalMessage=r.message,r.message=y):r=new Error(y),r.shortMessage=C,r.command=s,r.escapedCommand=a,r.exitCode=o,r.signal=u,r.signalDescription=c,r.stdout=e,r.stderr=t,n!==void 0&&(r.all=n),"bufferedData"in r&&delete r.bufferedData,r.failed=!0,r.timedOut=!!i,r.isCanceled=f,r.killed=l&&!i,r},we=["stdin","stdout","stderr"],ns=e=>we.some(t=>e[t]!==void 0),rs=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return we.map(r=>e[r]);if(ns(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${we.map(r=>`\`${r}\``).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,we.length);return Array.from({length:n},(r,u)=>t[u])};var z={exports:{}},be={exports:{}};be.exports;var Bn;function us(){return Bn||(Bn=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")}(be)),be.exports}var F=b.process;const N=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"};if(!N(F))z.exports=function(){return function(){}};else{var os=Pt,ue=us(),ss=/^win/i.test(F.platform),Ae=Mt;typeof Ae!="function"&&(Ae=Ae.EventEmitter);var v;F.__signal_exit_emitter__?v=F.__signal_exit_emitter__:(v=F.__signal_exit_emitter__=new Ae,v.count=0,v.emitted={}),v.infinite||(v.setMaxListeners(1/0),v.infinite=!0),z.exports=function(e,t){if(!N(b.process))return function(){};os.equal(typeof e,"function","a callback must be provided for exit handler"),oe===!1&&$n();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){v.removeListener(n,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&rt()};return v.on(n,e),r};var rt=function(){!oe||!N(b.process)||(oe=!1,ue.forEach(function(t){try{F.removeListener(t,ut[t])}catch{}}),F.emit=ot,F.reallyExit=xn,v.count-=1)};z.exports.unload=rt;var W=function(t,n,r){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,n,r))},ut={};ue.forEach(function(e){ut[e]=function(){if(N(b.process)){var n=F.listeners(e);n.length===v.count&&(rt(),W("exit",null,e),W("afterexit",null,e),ss&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),z.exports.signals=function(){return ue};var oe=!1,$n=function(){oe||!N(b.process)||(oe=!0,v.count+=1,ue=ue.filter(function(t){try{return F.on(t,ut[t]),!0}catch{return!1}}),F.emit=as,F.reallyExit=is)};z.exports.load=$n;var xn=F.reallyExit,is=function(t){N(b.process)&&(F.exitCode=t||0,W("exit",F.exitCode,null),W("afterexit",F.exitCode,null),xn.call(F,F.exitCode))},ot=F.emit,as=function(t,n){if(t==="exit"&&N(b.process)){n!==void 0&&(F.exitCode=n);var r=ot.apply(this,arguments);return W("exit",F.exitCode,null),W("afterexit",F.exitCode,null),r}else return ot.apply(this,arguments)}}var Ds=z.exports,cs=U(Ds);const ls=1e3*5,fs=(e,t="SIGTERM",n={})=>{const r=e(t);return ds(e,t,n,r),r},ds=(e,t,n,r)=>{if(!ps(t,n,r))return;const u=hs(n),o=setTimeout(()=>{e("SIGKILL")},u);o.unref&&o.unref()},ps=(e,{forceKillAfterTimeout:t},n)=>ms(e)&&t!==!1&&n,ms=e=>e===dr.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",hs=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return ls;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},gs=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Cs=(e,t,n)=>{e.kill(t),n(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Fs=(e,{timeout:t,killSignal:n="SIGTERM"},r)=>{if(t===0||t===void 0)return r;let u;const o=new Promise((a,i)=>{u=setTimeout(()=>{Cs(e,n,i)},t)}),s=r.finally(()=>{clearTimeout(u)});return Promise.race([o,s])},Es=({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})`)},ys=async(e,{cleanup:t,detached:n},r)=>{if(!t||n)return r;const u=cs(()=>{e.kill()});return r.finally(()=>{u()})};function ws(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var se={exports:{}};const{PassThrough:bs}=_e;var As=e=>{e={...e};const{array:t}=e;let{encoding:n}=e;const r=n==="buffer";let u=!1;t?u=!(n||r):n=n||"utf8",r&&(n=null);const o=new bs({objectMode:u});n&&o.setEncoding(n);let s=0;const a=[];return o.on("data",i=>{a.push(i),u?s=a.length:s+=i.length}),o.getBufferedValue=()=>t?a:r?Buffer.concat(a,s):a.join(""),o.getBufferedLength=()=>s,o};const{constants:vs}=pr,Bs=_e,{promisify:$s}=_t,xs=As,Os=$s(Bs.pipeline);class On extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}}async function st(e,t){if(!e)throw new Error("Expected a stream");t={maxBuffer:1/0,...t};const{maxBuffer:n}=t,r=xs(t);return await new Promise((u,o)=>{const s=a=>{a&&r.getBufferedLength()<=vs.MAX_LENGTH&&(a.bufferedData=r.getBufferedValue()),o(a)};(async()=>{try{await Os(e,r),u()}catch(a){s(a)}})(),r.on("data",()=>{r.getBufferedLength()>n&&s(new On)})}),r.getBufferedValue()}se.exports=st,se.exports.buffer=(e,t)=>st(e,{...t,encoding:"buffer"}),se.exports.array=(e,t)=>st(e,{...t,array:!0}),se.exports.MaxBufferError=On;var Is=se.exports,In=U(Is);const{PassThrough:Ss}=_e;var Ps=function(){var e=[],t=new Ss({objectMode:!0});return t.setMaxListeners(0),t.add=n,t.isEmpty=r,t.on("unpipe",u),Array.prototype.slice.call(arguments).forEach(n),t;function n(o){return Array.isArray(o)?(o.forEach(n),this):(e.push(o),o.once("end",u.bind(null,o)),o.once("error",t.emit.bind(t,"error")),o.pipe(t,{end:!1}),this)}function r(){return e.length==0}function u(o){e=e.filter(function(s){return s!==o}),!e.length&&t.readable&&t.end()}},Ms=U(Ps);const _s=(e,t)=>{t!==void 0&&(ws(t)?t.pipe(e.stdin):e.stdin.end(t))},Ts=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const n=Ms();return e.stdout&&n.add(e.stdout),e.stderr&&n.add(e.stderr),n},it=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(n){return n.bufferedData}}},at=(e,{encoding:t,buffer:n,maxBuffer:r})=>{if(!(!e||!n))return t?In(e,{encoding:t,maxBuffer:r}):In.buffer(e,{maxBuffer:r})},Ns=async({stdout:e,stderr:t,all:n},{encoding:r,buffer:u,maxBuffer:o},s)=>{const a=at(e,{encoding:r,buffer:u,maxBuffer:o}),i=at(t,{encoding:r,buffer:u,maxBuffer:o}),f=at(n,{encoding:r,buffer:u,maxBuffer:o*2});try{return await Promise.all([s,a,i,f])}catch(l){return Promise.all([{error:l,signal:l.signal,timedOut:l.timedOut},it(e,a),it(t,i),it(n,f)])}},Rs=(async()=>{})().constructor.prototype,ks=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Rs,e)]),Sn=(e,t)=>{for(const[n,r]of ks){const u=typeof t=="function"?(...o)=>Reflect.apply(r.value,t(),o):r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:u})}return e},Ls=e=>new Promise((t,n)=>{e.on("exit",(r,u)=>{t({exitCode:r,signal:u})}),e.on("error",r=>{n(r)}),e.stdin&&e.stdin.on("error",r=>{n(r)})}),Pn=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],js=/^[\w.-]+$/,Gs=/"/g,Hs=e=>typeof e!="string"||js.test(e)?e:`"${e.replace(Gs,'\\"')}"`,Us=(e,t)=>Pn(e,t).join(" "),qs=(e,t)=>Pn(e,t).map(n=>Hs(n)).join(" "),Ks=1e3*1e3*100,zs=({env:e,extendEnv:t,preferLocal:n,localDir:r,execPath:u})=>{const o=t?{..._.env,...e}:e;return n?No({env:o,cwd:r,execPath:u}):o},Ws=(e,t,n={})=>{const r=Mo._parse(e,t,n);return e=r.command,t=r.args,n=r.options,n={maxBuffer:Ks,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:n.cwd||_.cwd(),execPath:_.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...n},n.env=zs(n),n.stdio=rs(n),_.platform==="win32"&&L.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:n,parsed:r}},Dt=(e,t,n)=>typeof t!="string"&&!cr.isBuffer(t)?n===void 0?void 0:"":e.stripFinalNewline?_o(t):t;function Y(e,t,n){const r=Ws(e,t,n),u=Us(e,t),o=qs(e,t);Es(r.options);let s;try{s=It.spawn(r.file,r.args,r.options)}catch(d){const p=new It.ChildProcess,m=Promise.reject(vn({error:d,stdout:"",stderr:"",all:"",command:u,escapedCommand:o,parsed:r,timedOut:!1,isCanceled:!1,killed:!1}));return Sn(p,m)}const a=Ls(s),i=Fs(s,r.options,a),f=ys(s,r.options,i),l={isCanceled:!1};s.kill=fs.bind(null,s.kill.bind(s)),s.cancel=gs.bind(null,s,l);const c=yn(async()=>{const[{error:d,exitCode:p,signal:m,timedOut:h},C,y,$]=await Ns(s,r.options,f),k=Dt(r.options,C),S=Dt(r.options,y),A=Dt(r.options,$);if(d||p!==0||m!==null){const M=vn({error:d,exitCode:p,signal:m,stdout:k,stderr:S,all:A,command:u,escapedCommand:o,parsed:r,timedOut:h,isCanceled:l.isCanceled||(r.options.signal?r.options.signal.aborted:!1),killed:s.killed});if(!r.options.reject)return M;throw M}return{command:u,escapedCommand:o,exitCode:0,stdout:k,stderr:S,all:A,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return _s(s,r.options.input),s.all=Ts(s,r.options),Sn(s,c)}class ie{static create(t,n){return new t(n)}}const Ys={"":"<commit message>",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"},Vs=e=>`The output response must be in ${e} commit type:
28
+ ${Ys[e]}`,Xs={"":"",gitmoji:"",conventional:`Choose a type from the type-to-description JSON below that best describes the git diff:
29
+ ${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 neither fixes a bug nor adds a feature",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)}`},Mn=(e,t,n)=>["Generate a concise git commit message written in present tense for the following code diff with the given specifications below:",`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.",Xs[n],Vs(n)].filter(Boolean).join(`
30
+ `),Js=e=>/^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\s\w\.\-\p{Extended_Pictographic}]+\))?(!)?: ([\s\w \p{Extended_Pictographic}])+([\s\S]*)/.test(e),Zs=e=>/^\:\w+\: (.*)$/.test(e),V={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE"},_n=Object.values(V).map(e=>e);class ae{constructor(t){this.handleError$=n=>{let r="An error occurred";return n.message&&(r=n.message),Z({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,n,r,u,o){return`${Mn(t,u,o)}
31
31
  Please just generate ${r} messages in numbered list format.
32
32
  Here are git diff:
33
- ${n}`}extractCommitMessageFromRawText(t,n){switch(t){case"conventional":const r=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),u=n.match(r);return u?u[0].replace(/: (\w)/,(a,i)=>`: ${i.toLowerCase()}`):"";case"gitmoji":const o=new RegExp(/\:\w+\: (.*)$/),s=n.match(o);return s?s[0]:"";default:return n}}}var Mn="1.2.0",Zs="Reactive CLI that generates git commit messages with various AI";class b extends Error{}const ct=" ",ve=e=>{e instanceof Error&&(e instanceof b||(e.stack&&console.error(C.dim(e.stack.split(`
33
+ ${n}`}extractCommitMessageFromRawText(t,n){switch(t){case"conventional":const r=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),u=n.match(r);return u?u[0].replace(/: (\w)/,(a,i)=>`: ${i.toLowerCase()}`):"";case"gitmoji":const o=new RegExp(/\:\w+\: (.*)$/),s=n.match(o);return s?s[0]:"";default:return n}}}var Tn="1.3.0",Qs="A Reactive CLI that generates git commit messages with various AI";class w extends Error{}const ct=" ",ve=e=>{e instanceof Error&&(e instanceof w||(e.stack&&console.error(g.dim(e.stack.split(`
34
34
  `).slice(1).join(`
35
35
  `))),console.error(`
36
- ${ct}${C.dim(`aicommit2 v${Mn}`)}`),console.error(`
37
- ${ct}Please open a Bug report with the information above:`),console.error(`${ct}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var lt={},ft={exports:{}},re={exports:{}},dt,Nn;function Qs(){if(Nn)return dt;Nn=1;var e=1e3,t=e*60,n=t*60,r=n*24,u=r*7,o=r*365.25;dt=function(l,c){c=c||{};var D=typeof l;if(D==="string"&&l.length>0)return s(l);if(D==="number"&&isFinite(l))return c.long?i(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(c){var D=parseFloat(c[1]),d=(c[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return D*o;case"weeks":case"week":case"w":return D*u;case"days":case"day":case"d":return D*r;case"hours":case"hour":case"hrs":case"hr":case"h":return D*n;case"minutes":case"minute":case"mins":case"min":case"m":return D*t;case"seconds":case"second":case"secs":case"sec":case"s":return D*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return D;default:return}}}}function a(l){var c=Math.abs(l);return c>=r?Math.round(l/r)+"d":c>=n?Math.round(l/n)+"h":c>=t?Math.round(l/t)+"m":c>=e?Math.round(l/e)+"s":l+"ms"}function i(l){var c=Math.abs(l);return c>=r?f(l,c,r,"day"):c>=n?f(l,c,n,"hour"):c>=t?f(l,c,t,"minute"):c>=e?f(l,c,e,"second"):l+" ms"}function f(l,c,D,d){var p=c>=D*1.5;return Math.round(l/D)+" "+d+(p?"s":"")}return dt}var pt,Rn;function kn(){if(Rn)return pt;Rn=1;function e(t){r.debug=r,r.default=r,r.coerce=f,r.disable=s,r.enable=o,r.enabled=a,r.humanize=Qs(),r.destroy=l,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function n(c){let D=0;for(let d=0;d<c.length;d++)D=(D<<5)-D+c.charCodeAt(d),D|=0;return r.colors[Math.abs(D)%r.colors.length]}r.selectColor=n;function r(c){let D,d=null,p,m;function h(...g){if(!h.enabled)return;const E=h,$=Number(new Date),k=$-(D||$);E.diff=k,E.prev=D,E.curr=$,D=$,g[0]=r.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let I=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(T,ir)=>{if(T==="%%")return"%";I++;const Ot=r.formatters[ir];if(typeof Ot=="function"){const ar=g[I];T=Ot.call(E,ar),g.splice(I,1),I--}return T}),r.formatArgs.call(E,g),(E.log||r.log).apply(E,g)}return h.namespace=c,h.useColors=r.useColors(),h.color=r.selectColor(c),h.extend=u,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==r.namespaces&&(p=r.namespaces,m=r.enabled(c)),m),set:g=>{d=g}}),typeof r.init=="function"&&r.init(h),h}function u(c,D){const d=r(this.namespace+(typeof D>"u"?":":D)+c);return d.log=this.log,d}function o(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let D;const d=(typeof c=="string"?c:"").split(/[\s,]+/),p=d.length;for(D=0;D<p;D++)d[D]&&(c=d[D].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function s(){const c=[...r.names.map(i),...r.skips.map(i).map(D=>"-"+D)].join(",");return r.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let D,d;for(D=0,d=r.skips.length;D<d;D++)if(r.skips[D].test(c))return!1;for(D=0,d=r.names.length;D<d;D++)if(r.names[D].test(c))return!0;return!1}function i(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function f(c){return c instanceof Error?c.stack||c.message:c}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return pt=e,pt}re.exports;var Ln;function ei(){return Ln||(Ln=1,function(e,t){t.formatArgs=r,t.save=u,t.load=o,t.useColors=n,t.storage=s(),t.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;i.splice(1,0,f,"color: inherit");let l=0,c=0;i[0].replace(/%[a-zA-Z%]/g,D=>{D!=="%%"&&(l++,D==="%c"&&(c=l))}),i.splice(c,0,f)}t.log=console.debug||console.log||(()=>{});function u(i){try{i?t.storage.setItem("debug",i):t.storage.removeItem("debug")}catch{}}function o(){let i;try{i=t.storage.getItem("debug")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function s(){try{return localStorage}catch{}}e.exports=kn()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}(re,re.exports)),re.exports}var ue={exports:{}},mt,jn;function ti(){return jn||(jn=1,mt=(e,t=process.argv)=>{const n=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return r!==-1&&(u===-1||r<u)}),mt}var ht,Gn;function ni(){if(Gn)return ht;Gn=1;const e=Nt,t=Pe,n=ti(),{env:r}=process;let u;n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?u=1:r.FORCE_COLOR==="false"?u=0:u=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function o(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function s(i,f){if(u===0)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(i&&!f&&u===void 0)return 0;const l=u||0;if(r.TERM==="dumb")return l;if(process.platform==="win32"){const c=e.release().split(".");return Number(c[0])>=10&&Number(c[2])>=10586?Number(c[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(c=>c in r)||r.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){const c=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return c>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:l}function a(i){const f=s(i,i&&i.isTTY);return o(f)}return ht={supportsColor:a,stdout:o(s(!0,t.isatty(1))),stderr:o(s(!0,t.isatty(2)))},ht}ue.exports;var Hn;function ri(){return Hn||(Hn=1,function(e,t){const n=Pe,r=_t;t.init=l,t.log=a,t.formatArgs=o,t.save=i,t.load=f,t.useColors=u,t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const D=ni();D&&(D.stderr||D).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(D=>/^debug_/i.test(D)).reduce((D,d)=>{const p=d.substring(6).toLowerCase().replace(/_([a-z])/g,(h,g)=>g.toUpperCase());let m=process.env[d];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),D[p]=m,D},{});function u(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:n.isatty(process.stderr.fd)}function o(D){const{namespace:d,useColors:p}=this;if(p){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),g=` ${h};1m${d} \x1B[0m`;D[0]=g+D[0].split(`
36
+ ${ct}${g.dim(`aicommit2 v${Tn}`)}`),console.error(`
37
+ ${ct}Please open a Bug report with the information above:`),console.error(`${ct}https://github.com/tak-bro/aicommit2/issues/new/choose`)))};var lt={},ft={exports:{}},De={exports:{}},dt,Nn;function ei(){if(Nn)return dt;Nn=1;var e=1e3,t=e*60,n=t*60,r=n*24,u=r*7,o=r*365.25;dt=function(l,D){D=D||{};var c=typeof l;if(c==="string"&&l.length>0)return s(l);if(c==="number"&&isFinite(l))return D.long?i(l):a(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function s(l){if(l=String(l),!(l.length>100)){var D=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(D){var c=parseFloat(D[1]),d=(D[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*u;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}}}function a(l){var D=Math.abs(l);return D>=r?Math.round(l/r)+"d":D>=n?Math.round(l/n)+"h":D>=t?Math.round(l/t)+"m":D>=e?Math.round(l/e)+"s":l+"ms"}function i(l){var D=Math.abs(l);return D>=r?f(l,D,r,"day"):D>=n?f(l,D,n,"hour"):D>=t?f(l,D,t,"minute"):D>=e?f(l,D,e,"second"):l+" ms"}function f(l,D,c,d){var p=D>=c*1.5;return Math.round(l/c)+" "+d+(p?"s":"")}return dt}var pt,Rn;function kn(){if(Rn)return pt;Rn=1;function e(t){r.debug=r,r.default=r,r.coerce=f,r.disable=s,r.enable=o,r.enabled=a,r.humanize=ei(),r.destroy=l,Object.keys(t).forEach(D=>{r[D]=t[D]}),r.names=[],r.skips=[],r.formatters={};function n(D){let c=0;for(let d=0;d<D.length;d++)c=(c<<5)-c+D.charCodeAt(d),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=n;function r(D){let c,d=null,p,m;function h(...C){if(!h.enabled)return;const y=h,$=Number(new Date),k=$-(c||$);y.diff=k,y.prev=c,y.curr=$,c=$,C[0]=r.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let S=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(M,ir)=>{if(M==="%%")return"%";S++;const Ot=r.formatters[ir];if(typeof Ot=="function"){const ar=C[S];M=Ot.call(y,ar),C.splice(S,1),S--}return M}),r.formatArgs.call(y,C),(y.log||r.log).apply(y,C)}return h.namespace=D,h.useColors=r.useColors(),h.color=r.selectColor(D),h.extend=u,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==r.namespaces&&(p=r.namespaces,m=r.enabled(D)),m),set:C=>{d=C}}),typeof r.init=="function"&&r.init(h),h}function u(D,c){const d=r(this.namespace+(typeof c>"u"?":":c)+D);return d.log=this.log,d}function o(D){r.save(D),r.namespaces=D,r.names=[],r.skips=[];let c;const d=(typeof D=="string"?D:"").split(/[\s,]+/),p=d.length;for(c=0;c<p;c++)d[c]&&(D=d[c].replace(/\*/g,".*?"),D[0]==="-"?r.skips.push(new RegExp("^"+D.slice(1)+"$")):r.names.push(new RegExp("^"+D+"$")))}function s(){const D=[...r.names.map(i),...r.skips.map(i).map(c=>"-"+c)].join(",");return r.enable(""),D}function a(D){if(D[D.length-1]==="*")return!0;let c,d;for(c=0,d=r.skips.length;c<d;c++)if(r.skips[c].test(D))return!1;for(c=0,d=r.names.length;c<d;c++)if(r.names[c].test(D))return!0;return!1}function i(D){return D.toString().substring(2,D.toString().length-2).replace(/\.\*\?$/,"*")}function f(D){return D instanceof Error?D.stack||D.message:D}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}return pt=e,pt}De.exports;var Ln;function ti(){return Ln||(Ln=1,function(e,t){t.formatArgs=r,t.save=u,t.load=o,t.useColors=n,t.storage=s(),t.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function n(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;i.splice(1,0,f,"color: inherit");let l=0,D=0;i[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(l++,c==="%c"&&(D=l))}),i.splice(D,0,f)}t.log=console.debug||console.log||(()=>{});function u(i){try{i?t.storage.setItem("debug",i):t.storage.removeItem("debug")}catch{}}function o(){let i;try{i=t.storage.getItem("debug")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function s(){try{return localStorage}catch{}}e.exports=kn()(t);const{formatters:a}=e.exports;a.j=function(i){try{return JSON.stringify(i)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}(De,De.exports)),De.exports}var ce={exports:{}},mt,jn;function ni(){return jn||(jn=1,mt=(e,t=process.argv)=>{const n=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(n+e),u=t.indexOf("--");return r!==-1&&(u===-1||r<u)}),mt}var ht,Gn;function ri(){if(Gn)return ht;Gn=1;const e=Nt,t=Pe,n=ni(),{env:r}=process;let u;n("no-color")||n("no-colors")||n("color=false")||n("color=never")?u=0:(n("color")||n("colors")||n("color=true")||n("color=always"))&&(u=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?u=1:r.FORCE_COLOR==="false"?u=0:u=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function o(i){return i===0?!1:{level:i,hasBasic:!0,has256:i>=2,has16m:i>=3}}function s(i,f){if(u===0)return 0;if(n("color=16m")||n("color=full")||n("color=truecolor"))return 3;if(n("color=256"))return 2;if(i&&!f&&u===void 0)return 0;const l=u||0;if(r.TERM==="dumb")return l;if(process.platform==="win32"){const D=e.release().split(".");return Number(D[0])>=10&&Number(D[2])>=10586?Number(D[2])>=14931?3:2:1}if("CI"in r)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in r)||r.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in r)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){const D=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:l}function a(i){const f=s(i,i&&i.isTTY);return o(f)}return ht={supportsColor:a,stdout:o(s(!0,t.isatty(1))),stderr:o(s(!0,t.isatty(2)))},ht}ce.exports;var Hn;function ui(){return Hn||(Hn=1,function(e,t){const n=Pe,r=_t;t.init=l,t.log=a,t.formatArgs=o,t.save=i,t.load=f,t.useColors=u,t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const c=ri();c&&(c.stderr||c).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}t.inspectOpts=Object.keys(process.env).filter(c=>/^debug_/i.test(c)).reduce((c,d)=>{const p=d.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[d];return/^(yes|on|true|enabled)$/i.test(m)?m=!0:/^(no|off|false|disabled)$/i.test(m)?m=!1:m==="null"?m=null:m=Number(m),c[p]=m,c},{});function u(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:n.isatty(process.stderr.fd)}function o(c){const{namespace:d,useColors:p}=this;if(p){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${d} \x1B[0m`;c[0]=C+c[0].split(`
38
38
  `).join(`
39
- `+g),D.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=s()+d+" "+D[0]}function s(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...D){return process.stderr.write(r.format(...D)+`
40
- `)}function i(D){D?process.env.DEBUG=D:delete process.env.DEBUG}function f(){return process.env.DEBUG}function l(D){D.inspectOpts={};const d=Object.keys(t.inspectOpts);for(let p=0;p<d.length;p++)D.inspectOpts[d[p]]=t.inspectOpts[d[p]]}e.exports=kn()(t);const{formatters:c}=e.exports;c.o=function(D){return this.inspectOpts.colors=this.useColors,r.inspect(D,this.inspectOpts).split(`
41
- `).map(d=>d.trim()).join(" ")},c.O=function(D){return this.inspectOpts.colors=this.useColors,r.inspect(D,this.inspectOpts)}}(ue,ue.exports)),ue.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ft.exports=ei():ft.exports=ri();var Ct=ft.exports,gt={};Object.defineProperty(gt,"__esModule",{value:!0});function ui(e){return function(t,n){return new Promise((r,u)=>{e.call(this,t,n,(o,s)=>{o?u(o):r(s)})})}}gt.default=ui;var Un=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const oi=Tt,si=Un(Ct),ii=Un(gt),oe=si.default("agent-base");function ai(e){return!!e&&typeof e.addRequest=="function"}function Ft(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
42
- `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Ae(e,t){return new Ae.Agent(e,t)}(function(e){class t extends oi.EventEmitter{constructor(r,u){super();let o=u;typeof r=="function"?this.callback=r:r&&(o=r),this.timeout=null,o&&typeof o.timeout=="number"&&(this.timeout=o.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:Ft()?443:80}set defaultPort(r){this.explicitDefaultPort=r}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Ft()?"https:":"http:"}set protocol(r){this.explicitProtocol=r}callback(r,u,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(r,u){const o=Object.assign({},u);typeof o.secureEndpoint!="boolean"&&(o.secureEndpoint=Ft()),o.host==null&&(o.host="localhost"),o.port==null&&(o.port=o.secureEndpoint?443:80),o.protocol==null&&(o.protocol=o.secureEndpoint?"https:":"http:"),o.host&&o.path&&delete o.path,delete o.agent,delete o.hostname,delete o._defaultAgent,delete o.defaultPort,delete o.createConnection,r._last=!0,r.shouldKeepAlive=!1;let s=!1,a=null;const i=o.timeout||this.timeout,f=d=>{r._hadError||(r.emit("error",d),r._hadError=!0)},l=()=>{a=null,s=!0;const d=new Error(`A "socket" was not created for HTTP request before ${i}ms`);d.code="ETIMEOUT",f(d)},c=d=>{s||(a!==null&&(clearTimeout(a),a=null),f(d))},D=d=>{if(s)return;if(a!=null&&(clearTimeout(a),a=null),ai(d)){oe("Callback returned another Agent instance %o",d.constructor.name),d.addRequest(r,o);return}if(d){d.once("free",()=>{this.freeSocket(d,o)}),r.onSocket(d);return}const p=new Error(`no Duplex stream was returned to agent-base for \`${r.method} ${r.path}\``);f(p)};if(typeof this.callback!="function"){f(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(oe("Converting legacy callback function to promise"),this.promisifiedCallback=ii.default(this.callback)):this.promisifiedCallback=this.callback),typeof i=="number"&&i>0&&(a=setTimeout(l,i)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{oe("Resolving socket for %o request: %o",o.protocol,`${r.method} ${r.path}`),Promise.resolve(this.promisifiedCallback(r,o)).then(D,c)}catch(d){Promise.reject(d).catch(c)}}freeSocket(r,u){oe("Freeing socket %o %o",r.constructor.name,u),r.destroy()}destroy(){oe("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Ae||(Ae={}));var Di=Ae,Et={},ci=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});const li=ci(Ct),se=li.default("https-proxy-agent:parse-proxy-response");function fi(e){return new Promise((t,n)=>{let r=0;const u=[];function o(){const c=e.read();c?l(c):e.once("readable",o)}function s(){e.removeListener("end",i),e.removeListener("error",f),e.removeListener("close",a),e.removeListener("readable",o)}function a(c){se("onclose had error %o",c)}function i(){se("onend")}function f(c){s(),se("onerror %o",c),n(c)}function l(c){u.push(c),r+=c.length;const D=Buffer.concat(u,r);if(D.indexOf(`\r
39
+ `+C),c.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else c[0]=s()+d+" "+c[0]}function s(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function a(...c){return process.stderr.write(r.format(...c)+`
40
+ `)}function i(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function f(){return process.env.DEBUG}function l(c){c.inspectOpts={};const d=Object.keys(t.inspectOpts);for(let p=0;p<d.length;p++)c.inspectOpts[d[p]]=t.inspectOpts[d[p]]}e.exports=kn()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,r.inspect(c,this.inspectOpts).split(`
41
+ `).map(d=>d.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,r.inspect(c,this.inspectOpts)}}(ce,ce.exports)),ce.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ft.exports=ti():ft.exports=ui();var gt=ft.exports,Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});function oi(e){return function(t,n){return new Promise((r,u)=>{e.call(this,t,n,(o,s)=>{o?u(o):r(s)})})}}Ct.default=oi;var Un=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const si=Mt,ii=Un(gt),ai=Un(Ct),le=ii.default("agent-base");function Di(e){return!!e&&typeof e.addRequest=="function"}function Ft(){const{stack:e}=new Error;return typeof e!="string"?!1:e.split(`
42
+ `).some(t=>t.indexOf("(https.js:")!==-1||t.indexOf("node:https:")!==-1)}function Be(e,t){return new Be.Agent(e,t)}(function(e){class t extends si.EventEmitter{constructor(r,u){super();let o=u;typeof r=="function"?this.callback=r:r&&(o=r),this.timeout=null,o&&typeof o.timeout=="number"&&(this.timeout=o.timeout),this.maxFreeSockets=1,this.maxSockets=1,this.maxTotalSockets=1/0,this.sockets={},this.freeSockets={},this.requests={},this.options={}}get defaultPort(){return typeof this.explicitDefaultPort=="number"?this.explicitDefaultPort:Ft()?443:80}set defaultPort(r){this.explicitDefaultPort=r}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Ft()?"https:":"http:"}set protocol(r){this.explicitProtocol=r}callback(r,u,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(r,u){const o=Object.assign({},u);typeof o.secureEndpoint!="boolean"&&(o.secureEndpoint=Ft()),o.host==null&&(o.host="localhost"),o.port==null&&(o.port=o.secureEndpoint?443:80),o.protocol==null&&(o.protocol=o.secureEndpoint?"https:":"http:"),o.host&&o.path&&delete o.path,delete o.agent,delete o.hostname,delete o._defaultAgent,delete o.defaultPort,delete o.createConnection,r._last=!0,r.shouldKeepAlive=!1;let s=!1,a=null;const i=o.timeout||this.timeout,f=d=>{r._hadError||(r.emit("error",d),r._hadError=!0)},l=()=>{a=null,s=!0;const d=new Error(`A "socket" was not created for HTTP request before ${i}ms`);d.code="ETIMEOUT",f(d)},D=d=>{s||(a!==null&&(clearTimeout(a),a=null),f(d))},c=d=>{if(s)return;if(a!=null&&(clearTimeout(a),a=null),Di(d)){le("Callback returned another Agent instance %o",d.constructor.name),d.addRequest(r,o);return}if(d){d.once("free",()=>{this.freeSocket(d,o)}),r.onSocket(d);return}const p=new Error(`no Duplex stream was returned to agent-base for \`${r.method} ${r.path}\``);f(p)};if(typeof this.callback!="function"){f(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(le("Converting legacy callback function to promise"),this.promisifiedCallback=ai.default(this.callback)):this.promisifiedCallback=this.callback),typeof i=="number"&&i>0&&(a=setTimeout(l,i)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{le("Resolving socket for %o request: %o",o.protocol,`${r.method} ${r.path}`),Promise.resolve(this.promisifiedCallback(r,o)).then(c,D)}catch(d){Promise.reject(d).catch(D)}}freeSocket(r,u){le("Freeing socket %o %o",r.constructor.name,u),r.destroy()}destroy(){le("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Be||(Be={}));var ci=Be,Et={},li=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});const fi=li(gt),fe=fi.default("https-proxy-agent:parse-proxy-response");function di(e){return new Promise((t,n)=>{let r=0;const u=[];function o(){const D=e.read();D?l(D):e.once("readable",o)}function s(){e.removeListener("end",i),e.removeListener("error",f),e.removeListener("close",a),e.removeListener("readable",o)}function a(D){fe("onclose had error %o",D)}function i(){fe("onend")}function f(D){s(),fe("onerror %o",D),n(D)}function l(D){u.push(D),r+=D.length;const c=Buffer.concat(u,r);if(c.indexOf(`\r
43
43
  \r
44
- `)===-1){se("have not received end of HTTP headers yet..."),o();return}const p=D.toString("ascii",0,D.indexOf(`\r
45
- `)),m=+p.split(" ")[1];se("got proxy server response: %o",p),t({statusCode:m,buffered:D})}e.on("error",f),e.on("close",a),e.on("end",i),o()})}Et.default=fi;var di=w&&w.__awaiter||function(e,t,n,r){function u(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(l){try{f(r.next(l))}catch(c){s(c)}}function i(l){try{f(r.throw(l))}catch(c){s(c)}}function f(l){l.done?o(l.value):u(l.value).then(a,i)}f((r=r.apply(e,t||[])).next())})},W=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lt,"__esModule",{value:!0});const qn=W(yr),Kn=W(wr),pi=W(br),mi=W(Pt),hi=W(Ct),Ci=Di,gi=W(Et),ie=hi.default("https-proxy-agent:agent");class Fi extends Ci.Agent{constructor(t){let n;if(typeof t=="string"?n=pi.default.parse(t):n=t,!n)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");ie("creating new HttpsProxyAgent instance: %o",n),super(n);const r=Object.assign({},n);this.secureProxy=n.secureProxy||wi(r.protocol),r.host=r.hostname||r.host,typeof r.port=="string"&&(r.port=parseInt(r.port,10)),!r.port&&r.host&&(r.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in r)&&(r.ALPNProtocols=["http 1.1"]),r.host&&r.path&&(delete r.path,delete r.pathname),this.proxy=r}callback(t,n){return di(this,void 0,void 0,function*(){const{proxy:r,secureProxy:u}=this;let o;u?(ie("Creating `tls.Socket`: %o",r),o=Kn.default.connect(r)):(ie("Creating `net.Socket`: %o",r),o=qn.default.connect(r));const s=Object.assign({},r.headers);let i=`CONNECT ${`${n.host}:${n.port}`} HTTP/1.1\r
46
- `;r.auth&&(s["Proxy-Authorization"]=`Basic ${Buffer.from(r.auth).toString("base64")}`);let{host:f,port:l,secureEndpoint:c}=n;yi(l,c)||(f+=`:${l}`),s.Host=f,s.Connection="close";for(const h of Object.keys(s))i+=`${h}: ${s[h]}\r
47
- `;const D=gi.default(o);o.write(`${i}\r
48
- `);const{statusCode:d,buffered:p}=yield D;if(d===200){if(t.once("socket",Ei),n.secureEndpoint){ie("Upgrading socket connection to TLS");const h=n.servername||n.host;return Kn.default.connect(Object.assign(Object.assign({},bi(n,"host","hostname","path","port")),{socket:o,servername:h}))}return o}o.destroy();const m=new qn.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{ie("replaying proxy buffer for failed request"),mi.default(h.listenerCount("data")>0),h.push(p),h.push(null)}),m})}}lt.default=Fi;function Ei(e){e.resume()}function yi(e,t){return!!(!t&&e===80||t&&e===443)}function wi(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function bi(e,...t){const n={};let r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var vi=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const yt=vi(lt);function wt(e){return new yt.default(e)}(function(e){e.HttpsProxyAgent=yt.default,e.prototype=yt.default.prototype})(wt||(wt={}));var Ai=wt,Bi=G(Ai);const $i=async(e,t,n,r,u,o,s)=>new Promise((a,i)=>{const f=JSON.stringify(r),l=Er.request({port:s||void 0,hostname:e,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(f),...n},timeout:u,agent:o?Bi(o):void 0},c=>{const D=[];c.on("data",d=>D.push(d)),c.on("end",()=>{a({request:l,response:c,data:Buffer.concat(D).toString()})})});l.on("error",i),l.on("timeout",()=>{l.destroy(),i(new b(`Time out error: request took over ${u}ms. Try increasing the \`timeout\` config`))}),l.write(f),l.end()}),xi=async(e,t,n,r)=>{const{response:u,data:o}=await $i("api.openai.com","/v1/chat/completions",{Authorization:`Bearer ${e}`},t,n,r);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let s=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw o&&(s+=`
44
+ `)===-1){fe("have not received end of HTTP headers yet..."),o();return}const p=c.toString("ascii",0,c.indexOf(`\r
45
+ `)),m=+p.split(" ")[1];fe("got proxy server response: %o",p),t({statusCode:m,buffered:c})}e.on("error",f),e.on("close",a),e.on("end",i),o()})}Et.default=di;var pi=b&&b.__awaiter||function(e,t,n,r){function u(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(l){try{f(r.next(l))}catch(D){s(D)}}function i(l){try{f(r.throw(l))}catch(D){s(D)}}function f(l){l.done?o(l.value):u(l.value).then(a,i)}f((r=r.apply(e,t||[])).next())})},X=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lt,"__esModule",{value:!0});const qn=X(yr),Kn=X(wr),mi=X(br),hi=X(Pt),gi=X(gt),Ci=ci,Fi=X(Et),de=gi.default("https-proxy-agent:agent");class Ei extends Ci.Agent{constructor(t){let n;if(typeof t=="string"?n=mi.default.parse(t):n=t,!n)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");de("creating new HttpsProxyAgent instance: %o",n),super(n);const r=Object.assign({},n);this.secureProxy=n.secureProxy||bi(r.protocol),r.host=r.hostname||r.host,typeof r.port=="string"&&(r.port=parseInt(r.port,10)),!r.port&&r.host&&(r.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in r)&&(r.ALPNProtocols=["http 1.1"]),r.host&&r.path&&(delete r.path,delete r.pathname),this.proxy=r}callback(t,n){return pi(this,void 0,void 0,function*(){const{proxy:r,secureProxy:u}=this;let o;u?(de("Creating `tls.Socket`: %o",r),o=Kn.default.connect(r)):(de("Creating `net.Socket`: %o",r),o=qn.default.connect(r));const s=Object.assign({},r.headers);let i=`CONNECT ${`${n.host}:${n.port}`} HTTP/1.1\r
46
+ `;r.auth&&(s["Proxy-Authorization"]=`Basic ${Buffer.from(r.auth).toString("base64")}`);let{host:f,port:l,secureEndpoint:D}=n;wi(l,D)||(f+=`:${l}`),s.Host=f,s.Connection="close";for(const h of Object.keys(s))i+=`${h}: ${s[h]}\r
47
+ `;const c=Fi.default(o);o.write(`${i}\r
48
+ `);const{statusCode:d,buffered:p}=yield c;if(d===200){if(t.once("socket",yi),n.secureEndpoint){de("Upgrading socket connection to TLS");const h=n.servername||n.host;return Kn.default.connect(Object.assign(Object.assign({},Ai(n,"host","hostname","path","port")),{socket:o,servername:h}))}return o}o.destroy();const m=new qn.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{de("replaying proxy buffer for failed request"),hi.default(h.listenerCount("data")>0),h.push(p),h.push(null)}),m})}}lt.default=Ei;function yi(e){e.resume()}function wi(e,t){return!!(!t&&e===80||t&&e===443)}function bi(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function Ai(e,...t){const n={};let r;for(r in e)t.includes(r)||(n[r]=e[r]);return n}var vi=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const yt=vi(lt);function wt(e){return new yt.default(e)}(function(e){e.HttpsProxyAgent=yt.default,e.prototype=yt.default.prototype})(wt||(wt={}));var Bi=wt,$i=U(Bi);const xi=async(e,t,n,r,u,o,s)=>new Promise((a,i)=>{const f=JSON.stringify(r),l=Er.request({port:s||void 0,hostname:e,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(f),...n},timeout:u,agent:o?$i(o):void 0},D=>{const c=[];D.on("data",d=>c.push(d)),D.on("end",()=>{a({request:l,response:D,data:Buffer.concat(c).toString()})})});l.on("error",i),l.on("timeout",()=>{l.destroy(),i(new w(`Time out error: request took over ${u}ms. Try increasing the \`timeout\` config`))}),l.write(f),l.end()}),Oi=async(e,t,n,r)=>{const{response:u,data:o}=await xi("api.openai.com","/v1/chat/completions",{Authorization:`Bearer ${e}`},t,n,r);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let s=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw o&&(s+=`
49
49
 
50
50
  ${o}`),u.statusCode===500&&(s+=`
51
51
 
52
- Check the API status: https://status.openai.com`),new b(s)}return JSON.parse(o)},Oi=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),Be=e=>Array.from(new Set(e)),Si=async(e,t,n,r,u,o,s,a,i,f,l)=>{try{const c=await xi(e,{model:t,messages:[{role:"system",content:Tn(n,o,s)},{role:"user",content:r}],temperature:f,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:i,stream:!1,n:u},a,l);return Be(c.choices.filter(D=>D.message?.content).map(D=>Oi(D.message.content)).map(D=>{if(s==="conventional"){const d=/: (\w)/;return D.replace(d,(p,m)=>`: ${m.toLowerCase()}`)}return D}).filter(D=>{switch(s){case"gitmoji":return Js(D);case"conventional":return Xs(D);case"":default:return!0}}))}catch(c){const D=c;throw D.code==="ENOTFOUND"?new b(`Error connecting to ${D.hostname} (${D.syscall})`):D}};class Ii extends be{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=C.red.bold("[Anthropic]"),u=n.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return ae({name:`${r} ${u}`,value:u,isError:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=C.red.bold("[Anthropic]"),this.anthropic=new Re({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return le(this.generateMessage()).pipe(De(t=>Y(t)),X(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ce(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(n,t,r,o,u),i=(await this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${Re.HUMAN_PROMPT} ${s}${Re.AI_PROMPT}`})).completion;return Be(this.sanitizeMessage(i))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new b(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeMessage(t){return t.split(`
52
+ Check the API status: https://status.openai.com`),new w(s)}return JSON.parse(o)},Ii=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),pe=e=>Array.from(new Set(e)),Si=async(e,t,n,r,u,o,s,a,i,f,l)=>{try{const D=await Oi(e,{model:t,messages:[{role:"system",content:Mn(n,o,s)},{role:"user",content:r}],temperature:f,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:i,stream:!1,n:u},a,l);return pe(D.choices.filter(c=>c.message?.content).map(c=>Ii(c.message.content)).map(c=>{if(s==="conventional"){const d=/: (\w)/;return c.replace(d,(p,m)=>`: ${m.toLowerCase()}`)}return c}).filter(c=>{switch(s){case"gitmoji":return Zs(c);case"conventional":return Js(c);case"":default:return!0}}))}catch(D){const c=D;throw c.code==="ENOTFOUND"?new w(`Error connecting to ${c.hostname} (${c.syscall})`):c}};class Pi extends ae{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return Z({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#AE5630",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Anthropic]"),this.errorPrefix=g.red.bold("[Anthropic]"),this.anthropic=new Re({apiKey:this.params.config.ANTHROPIC_KEY})}generateCommitMessage$(){return te(this.generateMessage()).pipe(Q(t=>G(t)),H(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ee(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(n,t,r,o,u),i=(await this.anthropic.completions.create({model:this.params.config.ANTHROPIC_MODEL,max_tokens_to_sample:this.params.config["max-tokens"],temperature:this.params.config.temperature,prompt:`${Re.HUMAN_PROMPT} ${s}${Re.AI_PROMPT}`})).completion;return pe(this.sanitizeMessage(i))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new w(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeMessage(t){return t.split(`
53
53
  `).map(n=>n.trim().replace(/^\d+\.\s/,"")).map(n=>n.replace(/`/g,"")).map(n=>this.extractCommitMessageFromRawText(this.params.config.type,n)).filter(n=>!!n)}}const{hasOwnProperty:bt}=Object.prototype,$e=typeof process<"u"&&process.platform==="win32"?`\r
54
54
  `:`
55
- `,vt=(e,t)=>{const n=[];let r="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const u=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const s=e[o];if(s&&Array.isArray(s))for(const a of s)r+=V(o+"[]")+u+V(a)+$e;else s&&typeof s=="object"?n.push(o):r+=V(o)+u+V(s)+$e}t.section&&r.length&&(r="["+V(t.section)+"]"+$e+r);for(const o of n){const s=zn(o).join("\\."),a=(t.section?t.section+".":"")+s,{whitespace:i}=t,f=vt(e[o],{section:a,whitespace:i});r.length&&f.length&&(r+=$e),r+=f}return r},zn=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Wn=e=>{const t=Object.create(null);let n=t,r=null;const u=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const a of o){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(u);if(!i)continue;if(i[1]!==void 0){if(r=xe(i[1]),r==="__proto__"){n=Object.create(null);continue}n=t[r]=t[r]||Object.create(null);continue}const f=xe(i[2]),l=f.length>2&&f.slice(-2)==="[]",c=l?f.slice(0,-2):f;if(c==="__proto__")continue;const D=i[3]?xe(i[4]):!0,d=D==="true"||D==="false"||D==="null"?JSON.parse(D):D;l&&(bt.call(n,c)?Array.isArray(n[c])||(n[c]=[n[c]]):n[c]=[]),Array.isArray(n[c])?n[c].push(d):n[c]=d}const s=[];for(const a of Object.keys(t)){if(!bt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=zn(a);n=t;const f=i.pop(),l=f.replace(/\\\./g,".");for(const c of i)c!=="__proto__"&&((!bt.call(n,c)||typeof n[c]!="object")&&(n[c]=Object.create(null)),n=n[c]);n===t&&l===f||(n[l]=t[a],s.push(a))}for(const a of s)delete t[a];return t},Vn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),V=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Vn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),xe=(e,t)=>{if(e=(e||"").trim(),Vn(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let n=!1,r="";for(let u=0,o=e.length;u<o;u++){const s=e.charAt(u);if(n)"\\;#".indexOf(s)!==-1?r+=s:r+="\\"+s,n=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?n=!0:r+=s}}return n&&(r+="\\"),r.trim()}return e};var Pi={parse:Wn,decode:Wn,stringify:vt,encode:vt,safe:V,unsafe:xe},Yn=G(Pi);const Xn=e=>x.lstat(e).then(()=>!0,()=>!1),Ti=["","conventional","gitmoji"],{hasOwnProperty:_i}=Object.prototype,R=(e,t)=>_i.call(e,t),y=(e,t,n)=>{if(!t)throw new b(`Invalid config property ${e}: ${n}`)},Oe={OPENAI_KEY(e){return e?(y("OPENAI_KEY",e.startsWith("sk-"),'Must start with "sk-"'),e):""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(y("HUGGING_MODEL",["mistralai/Mixtral-8x7B-Instruct-v0.1","meta-llama/Llama-2-70b-chat-hf","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","codellama/CodeLlama-70b-Instruct-hf","mistralai/Mistral-7B-Instruct-v0.2","openchat/openchat-3.5-0106"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GOOGLE_KEY(e){return e||""},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(y("ANTHROPIC_MODEL",["claude-2.1","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},confirm(e){return e?typeof e=="boolean"?e:(y("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},locale(e){return e?(y("locale",e,"Cannot be empty"),y("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;y("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("generate",t>0,"Must be greater than 0"),y("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(y("type",Ti.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return y("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;y("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;y("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return y("temperature",t>0,"Must be greater than 0"),y("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;y("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return y("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(y("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},At=j.join(Nt.homedir(),".aicommit2"),Jn=async()=>{if(!await Xn(At))return Object.create(null);const t=await x.readFile(At,"utf8");return Yn.parse(t)},Bt=async(e,t)=>{const n=await Jn(),r={};for(const u of Object.keys(Oe)){const o=Oe[u],s=e?.[u]??n[u];if(t)try{r[u]=o(s)}catch{}else r[u]=o(s)}return r},Mi=async e=>{const t=await Jn();for(const[n,r]of e){if(!R(Oe,n))throw new b(`Invalid config property: ${n}`);const u=Oe[n](r);t[n]=u}await x.writeFile(At,Yn.stringify(t),"utf8")};class S{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=xr.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Ni extends be{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=C.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return le(this.generateMessage()).pipe(De(t=>Y(t)),X(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ce(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,n,u,r);await this.getAllConversationIds();const a=await this.sendMessage(s),{conversationId:i,allText:f}=this.parseSendMessageResult(a);return await this.deleteConversation(i),Be(this.sanitizeMessage(f))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new b(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async getAllConversationIds(){const n=(await new S({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!n||!n.content)throw new Error("No content on conversations ClovaX");return n.content.length===0?[]:n.content.map(u=>u.conversationId||"").filter(u=>!!u)}async sendMessage(t){const n={text:t,action:"new"},r=new Br;return r.set("form",new $r([JSON.stringify(n)],{type:"application/json"})),(await new S({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(r),Cookie:this.cookie}).setBody(r).execute()).data}parseSendMessageResult(t){const n=/data:{(.*)}/g,r=t.match(n);if(!r)throw new Error("Failed to extract object from generated text");const u=r.map(i=>i.trim().replace(/data:/g,""));if(!u||u.length===0)throw new Error("Cannot extract message");let o="",s="",a="";if(u.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(R(i,"conversationId")){o=i.conversationId;return}if(R(i,"text")){s+=i.text;return}if(R(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!o)throw new Error("No conversationId!");if(!s)throw new Error("No allText!");return{conversationId:o,allText:s}}sanitizeMessage(t){return t.split(`
56
- `).map(n=>n.trim().replace(/^\d+\.\s/,"")).map(n=>n.replace(/`/g,"")).map(n=>this.extractCommitMessageFromRawText(this.params.config.type,n)).filter(n=>!!n)}async deleteConversation(t){return(await new S({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([n,r])=>({[n]:{ContentLength:typeof r=="string"?r.length:r.size}}))}}class Ri extends be{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=C.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return le(this.generateMessage()).pipe(De(t=>Y(t)),X(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ce(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,n,u,r);await this.prepareNewConversation();const{conversationId:a}=await this.getNewConversationId();await this.prepareConversationEvent(a);const{lastMessageId:i}=await this.getConversationInfo(a),f=await this.sendMessage(a,s,i);return await this.deleteConversation(a),Be(this.sanitizeMessage(f))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new b(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeMessage(t){const n=/{[^{}]*}/g,r=t.match(n);if(!r)throw new Error("Failed to extract object from generated text");let u=null;if(r.forEach((o,s)=>{try{const a=JSON.parse(o);R(a,"type")&&a.type==="finalAnswer"&&(u=a)}catch{}}),!u||!R(u,"text"))throw new Error("Cannot parse finalAnswer");return u.text.split(`
57
- `).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/`/g,"")).map(o=>this.extractCommitMessageFromRawText(this.params.config.type,o)).filter(o=>!!o)}async prepareNewConversation(){return(await new S({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new S({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new S({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const r=(await new S({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!r||!r.nodes||r.nodes.length===0)throw new Error("No Nodes on conversation info");if(!r.nodes[1]||!r.nodes[1].data||r.nodes[1].data.length===0||!r.nodes[1].data[3])throw new Error("No data on node");const s=r.nodes[1]?.data[3];return{conversationInfo:r,lastMessageId:s}}async deleteConversation(t){return await new S({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new S({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,n,r){return(await new S({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:r,inputs:n,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}class ki extends be{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=C.red.bold("[ChatGPT]");let u="An error occurred";if(n.message){u=n.message.split(`
58
- `)[0];const o=this.extractJSONFromError(n.message);u+=`: ${o.error.message}`}return ae({name:`${r} ${u}`,value:u,isError:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=C.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]")}generateCommitMessage$(){return le(Si(this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,this.params.config.locale,this.params.stagedDiff.diff,this.params.config.generate,this.params.config["max-length"],this.params.config.type,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.proxy)).pipe(De(t=>Y(t)),X(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ce(this.handleError$))}extractJSONFromError(t){const n=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,r=t.match(n);return r?Object.assign({},...r.map(u=>JSON.parse(u))):{error:{message:"Unknown error"}}}}class Zn{constructor(t,n){this.config=t,this.stagedDiff=n}createAIRequests$(t){return Y(t).pipe(mr(n=>{const r={config:this.config,stagedDiff:this.stagedDiff};switch(n){case ne.OPEN_AI:return we.create(ki,r).generateCommitMessage$();case ne.HUGGING:return we.create(Ri,r).generateCommitMessage$();case ne.CLOVA_X:return we.create(Ni,r).generateCommitMessage$();case ne.ANTHROPIC:return we.create(Ii,r).generateCommitMessage$();default:const u=C.red.bold(`[${n}]`);return ae({name:u+" Invalid AI type",value:"Invalid AI type",isError:!0})}}))}}const Qn=async()=>{const{stdout:e,failed:t}=await z("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new b("The current directory must be a Git repository!");return e},$t=e=>`:(exclude)${e}`,er=["package-lock.json","pnpm-lock.yaml","*.lock"].map($t),tr=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await z("git",[...t,"--name-only",...er,...e?e.map($t):[]]);if(!n)return null;const{stdout:r}=await z("git",[...t,...er,...e?e.map($t):[]]);return{files:n.split(`
59
- `),diff:r}},Li=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Se{constructor(){this.title="aicommit2"}printTitle(){console.log(Or.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Ne(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(C.bold.green("\u2714 ")+C.bold(`${Li(t.files)}:`)),console.log(`${t.files.map(n=>` ${n}`).join(`
55
+ `,At=(e,t)=>{const n=[];let r="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const u=t.whitespace?" = ":"=";for(const o of Object.keys(e)){const s=e[o];if(s&&Array.isArray(s))for(const a of s)r+=J(o+"[]")+u+J(a)+$e;else s&&typeof s=="object"?n.push(o):r+=J(o)+u+J(s)+$e}t.section&&r.length&&(r="["+J(t.section)+"]"+$e+r);for(const o of n){const s=zn(o).join("\\."),a=(t.section?t.section+".":"")+s,{whitespace:i}=t,f=At(e[o],{section:a,whitespace:i});r.length&&f.length&&(r+=$e),r+=f}return r},zn=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Wn=e=>{const t=Object.create(null);let n=t,r=null;const u=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const a of o){if(!a||a.match(/^\s*[;#]/))continue;const i=a.match(u);if(!i)continue;if(i[1]!==void 0){if(r=xe(i[1]),r==="__proto__"){n=Object.create(null);continue}n=t[r]=t[r]||Object.create(null);continue}const f=xe(i[2]),l=f.length>2&&f.slice(-2)==="[]",D=l?f.slice(0,-2):f;if(D==="__proto__")continue;const c=i[3]?xe(i[4]):!0,d=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;l&&(bt.call(n,D)?Array.isArray(n[D])||(n[D]=[n[D]]):n[D]=[]),Array.isArray(n[D])?n[D].push(d):n[D]=d}const s=[];for(const a of Object.keys(t)){if(!bt.call(t,a)||typeof t[a]!="object"||Array.isArray(t[a]))continue;const i=zn(a);n=t;const f=i.pop(),l=f.replace(/\\\./g,".");for(const D of i)D!=="__proto__"&&((!bt.call(n,D)||typeof n[D]!="object")&&(n[D]=Object.create(null)),n=n[D]);n===t&&l===f||(n[l]=t[a],s.push(a))}for(const a of s)delete t[a];return t},Yn=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),J=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Yn(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),xe=(e,t)=>{if(e=(e||"").trim(),Yn(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let n=!1,r="";for(let u=0,o=e.length;u<o;u++){const s=e.charAt(u);if(n)"\\;#".indexOf(s)!==-1?r+=s:r+="\\"+s,n=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?n=!0:r+=s}}return n&&(r+="\\"),r.trim()}return e};var Mi={parse:Wn,decode:Wn,stringify:At,encode:At,safe:J,unsafe:xe},Vn=U(Mi);const Xn=e=>x.lstat(e).then(()=>!0,()=>!1),_i=["","conventional","gitmoji"],{hasOwnProperty:Ti}=Object.prototype,R=(e,t)=>Ti.call(e,t),E=(e,t,n)=>{if(!t)throw new w(`Invalid config property ${e}: ${n}`)},Oe={OPENAI_KEY(e){return e?(E("OPENAI_KEY",e.startsWith("sk-"),'Must start with "sk-"'),e):""},OPENAI_MODEL(e){return!e||e.length===0?"gpt-3.5-turbo":e},HUGGING_COOKIE(e){return e||""},HUGGING_MODEL(e){return!e||e.length===0?"mistralai/Mixtral-8x7B-Instruct-v0.1":(E("HUGGING_MODEL",["mistralai/Mixtral-8x7B-Instruct-v0.1","meta-llama/Llama-2-70b-chat-hf","NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO","codellama/CodeLlama-70b-Instruct-hf","mistralai/Mistral-7B-Instruct-v0.2","openchat/openchat-3.5-0106"].includes(e),"Invalid model type of hugging"),e)},CLOVAX_COOKIE(e){return e||""},GEMINI_KEY(e){return e||""},GEMINI_MODEL(e){return!e||e.length===0?"gemini-pro":(E("GEMINI_MODEL",["gemini-pro"].includes(e),"Invalid model type of Gemini"),e)},ANTHROPIC_MODEL(e){return!e||e.length===0?"claude-2.1":(E("ANTHROPIC_MODEL",["claude-2.1","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},confirm(e){return e?typeof e=="boolean"?e:(E("confirm",/^(?:true|false)$/.test(e),"Must be a boolean"),e==="true"):!1},locale(e){return e?(E("locale",e,"Cannot be empty"),E("locale",/^[a-z-]+$/i.test(e),"Must be a valid locale (letters and dashes/underscores). You can consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes"),e):"en"},generate(e){if(!e)return 1;E("generate",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("generate",t>0,"Must be greater than 0"),E("generate",t<=5,"Must be less or equal to 5"),t},type(e){return e?(E("type",_i.includes(e),"Invalid commit type"),e):"conventional"},proxy(e){if(!(!e||e.length===0))return E("proxy",/^https?:\/\//.test(e),"Must be a valid URL"),e},timeout(e){if(!e)return 1e4;E("timeout",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("timeout",t>=500,"Must be greater than 500ms"),t},temperature(e){if(!e)return .7;E("temperature",/^(2|\d)(\.\d{1,2})?$/.test(e),"Must be decimal between 0 and 2");const t=Number(e);return E("temperature",t>0,"Must be greater than 0"),E("temperature",t<=2,"Must be less than or equal to 2"),t},"max-length"(e){if(!e)return 50;E("max-length",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("max-length",t>=20,"Must be greater than 20 characters"),t},"max-tokens"(e){return e?(E("max-tokens",/^\d+$/.test(e),"Must be an integer"),Number(e)):200}},vt=j.join(Nt.homedir(),".aicommit2"),Jn=async()=>{if(!await Xn(vt))return Object.create(null);const t=await x.readFile(vt,"utf8");return Vn.parse(t)},Bt=async(e,t)=>{const n=await Jn(),r={};for(const u of Object.keys(Oe)){const o=Oe[u],s=e?.[u]??n[u];if(t)try{r[u]=o(s)}catch{}else r[u]=o(s)}return r},Ni=async e=>{const t=await Jn();for(const[n,r]of e){if(!R(Oe,n))throw new w(`Invalid config property: ${n}`);const u=Oe[n](r);t[n]=u}await x.writeFile(vt,Vn.stringify(t),"utf8")};class I{constructor(t={}){if(!t.method)throw new Error("method should be defined!");if(!t.baseURL)throw new Error("baseURL should be defined!");this.config={...t},this.axiosInstance=xr.create(this.config)}setHeaders(t){return this.config.headers=t,this}setParams(t){return this.config.params=t,this}setBody(t){return this.config.data=t,this}setMethod(t){return this.config.method=t,this}async execute(){try{return await this.axiosInstance.request(this.config)}catch(t){throw t}}}class Ri extends ae{constructor(t){super(t),this.params=t,this.host="https://clova-x.naver.com",this.cookie="",this.colors={primary:"#00db9b",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[CLOVA X]"),this.errorPrefix=g.red.bold("[CLOVA X]"),this.cookie=this.params.config.CLOVAX_COOKIE}generateCommitMessage$(){return te(this.generateMessage()).pipe(Q(t=>G(t)),H(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ee(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,n,u,r);await this.getAllConversationIds();const a=await this.sendMessage(s),{conversationId:i,allText:f}=this.parseSendMessageResult(a);return await this.deleteConversation(i),pe(this.sanitizeMessage(f))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new w(`Error connecting to ${n.hostname} (${n.syscall})`):n}}async getAllConversationIds(){const n=(await new I({method:"GET",baseURL:`${this.host}/api/v1/conversations`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).setParams({page:0,size:50,sort:"turnUpdatedTime,DESC"}).execute()).data;if(!n||!n.content)throw new Error("No content on conversations ClovaX");return n.content.length===0?[]:n.content.map(u=>u.conversationId||"").filter(u=>!!u)}async sendMessage(t){const n={text:t,action:"new"},r=new Br;return r.set("form",new $r([JSON.stringify(n)],{type:"application/json"})),(await new I({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(r),Cookie:this.cookie}).setBody(r).execute()).data}parseSendMessageResult(t){const n=/data:{(.*)}/g,r=t.match(n);if(!r)throw new Error("Failed to extract object from generated text");const u=r.map(i=>i.trim().replace(/data:/g,""));if(!u||u.length===0)throw new Error("Cannot extract message");let o="",s="",a="";if(u.map(i=>{try{return JSON.parse(i)}catch{return null}}).filter(i=>!!i).forEach(i=>{if(R(i,"conversationId")){o=i.conversationId;return}if(R(i,"text")){s+=i.text;return}if(R(i,"error")){a=`${i.error}: ${i.type||i.message||""}`;return}}),a)throw new Error(a);if(!o)throw new Error("No conversationId!");if(!s)throw new Error("No allText!");return{conversationId:o,allText:s}}sanitizeMessage(t){return t.split(`
56
+ `).map(n=>n.trim().replace(/^\d+\.\s/,"")).map(n=>n.replace(/`/g,"")).map(n=>this.extractCommitMessageFromRawText(this.params.config.type,n)).filter(n=>!!n)}async deleteConversation(t){return(await new I({method:"DELETE",baseURL:`${this.host}/api/v1/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute()).data}getContentLength(t){return Array.from(t.entries(),([n,r])=>({[n]:{ContentLength:typeof r=="string"?r.length:r.size}}))}}class ki extends ae{constructor(t){super(t),this.params=t,this.handleError$=n=>{const r=n.message||n.toString(),u=/(\[.*?\]\s*[^[]*)/g,o=[...r.matchAll(u)],s=[];o.forEach(i=>s.push(i[1]));const a=s[1]||"An error occurred";return Z({name:`${this.errorPrefix} ${a}`,value:a,isError:!0})},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Gemini]"),this.errorPrefix=g.red.bold("[Gemini]"),this.genAI=new Or(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return te(this.generateMessage()).pipe(Q(t=>G(t)),H(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ee(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:n,generate:r,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(n,t,r,o,u),a=this.params.config["max-tokens"],D=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:a,temperature:this.params.config.temperature}}).generateContent(s)).response).text();return pe(this.sanitizeMessage(D))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new w(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeMessage(t){return t.split(`
57
+ `).map(n=>n.trim().replace(/^\d+\.\s/,"")).map(n=>n.replace(/`/g,"")).map(n=>this.extractCommitMessageFromRawText(this.params.config.type,n)).filter(n=>!!n)}}class Li extends ae{constructor(t){super(t),this.params=t,this.host="https://huggingface.co",this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[HuggingFace]"),this.errorPrefix=g.red.bold("[HuggingFace]"),this.cookie=this.params.config.HUGGING_COOKIE}generateCommitMessage$(){return te(this.generateMessage()).pipe(Q(t=>G(t)),H(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ee(this.handleError$))}async generateMessage(){try{const{locale:t,generate:n,type:r}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,n,u,r);await this.prepareNewConversation();const{conversationId:a}=await this.getNewConversationId();await this.prepareConversationEvent(a);const{lastMessageId:i}=await this.getConversationInfo(a),f=await this.sendMessage(a,s,i);return await this.deleteConversation(a),pe(this.sanitizeMessage(f))}catch(t){const n=t;throw n.code==="ENOTFOUND"?new w(`Error connecting to ${n.hostname} (${n.syscall})`):n}}sanitizeMessage(t){const n=/{[^{}]*}/g,r=t.match(n);if(!r)throw new Error("Failed to extract object from generated text");let u=null;if(r.forEach((o,s)=>{try{const a=JSON.parse(o);R(a,"type")&&a.type==="finalAnswer"&&(u=a)}catch{}}),!u||!R(u,"text"))throw new Error("Cannot parse finalAnswer");return u.text.split(`
58
+ `).map(o=>o.trim().replace(/^\d+\.\s/,"")).map(o=>o.replace(/`/g,"")).map(o=>this.extractCommitMessageFromRawText(this.params.config.type,o)).filter(o=>!!o)}async prepareNewConversation(){return(await new I({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:"https://huggingface.co/chat/"}).execute()).data}async prepareConversationEvent(t){return(await new I({method:"POST",baseURL:`${this.host}/api/event`}).setHeaders({"content-type":"application/json",Cookie:this.cookie}).setBody({d:"huggingface.co",n:"pageview",r:"https://huggingface.co/chat/",u:`https://huggingface.co/chat/conversation/${t}`}).execute()).data}async getNewConversationId(){const t=await new I({method:"POST",baseURL:`${this.host}/chat/conversation`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Host:"huggingface.co",Origin:"https://huggingface.co"}).setBody({model:this.params.config.HUGGING_MODEL,preprompt:""}).execute();if(!t.data||!t.data.conversationId)throw new Error("No conversationId on Hugging service");return t.data}async getConversationInfo(t){const r=(await new I({method:"GET",baseURL:`${this.host}/chat/conversation/${t}/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-invalidated":"11"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data;if(!r||!r.nodes||r.nodes.length===0)throw new Error("No Nodes on conversation info");if(!r.nodes[1]||!r.nodes[1].data||r.nodes[1].data.length===0||!r.nodes[1].data[3])throw new Error("No data on node");const s=r.nodes[1]?.data[3];return{conversationInfo:r,lastMessageId:s}}async deleteConversation(t){return await new I({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new I({method:"GET",baseURL:`${this.host}/chat/__data.json`,timeout:this.params.config.timeout}).setParams({"x-sveltekit-trailing-slash":"1","x-sveltekit-invalidated":"10"}).setHeaders({"Content-Type":"application/json",Cookie:this.cookie,Accept:"*/*",Connection:"keep-alive",Referer:"https://huggingface.co/chat/"}).execute()).data}async sendMessage(t,n,r){return(await new I({method:"POST",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({"content-type":"application/json",Cookie:this.cookie,authority:"huggingface.co",accept:"*/*",origin:"https://huggingface.co"}).setBody({files:[],id:r,inputs:n,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}class ji extends ae{constructor(t){super(t),this.params=t,this.handleError$=n=>{let r="An error occurred";if(n.message){r=n.message.split(`
59
+ `)[0];const u=this.extractJSONFromError(n.message);r+=`: ${u.error.message}`}return Z({name:`${this.errorPrefix} ${r}`,value:r,isError:!0})},this.colors={primary:"#74AA9C",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[ChatGPT]"),this.errorPrefix=g.red.bold("[ChatGPT]")}generateCommitMessage$(){return te(Si(this.params.config.OPENAI_KEY,this.params.config.OPENAI_MODEL,this.params.config.locale,this.params.stagedDiff.diff,this.params.config.generate,this.params.config["max-length"],this.params.config.type,this.params.config.timeout,this.params.config["max-tokens"],this.params.config.temperature,this.params.config.proxy)).pipe(Q(t=>G(t)),H(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),ee(this.handleError$))}extractJSONFromError(t){const n=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,r=t.match(n);return r?Object.assign({},...r.map(u=>JSON.parse(u))):{error:{message:"Unknown error"}}}}class Zn{constructor(t,n){this.config=t,this.stagedDiff=n}createAIRequests$(t){return G(t).pipe(mr(n=>{const r={config:this.config,stagedDiff:this.stagedDiff};switch(n){case V.OPEN_AI:return ie.create(ji,r).generateCommitMessage$();case V.GEMINI:return ie.create(ki,r).generateCommitMessage$();case V.ANTHROPIC:return ie.create(Pi,r).generateCommitMessage$();case V.HUGGING:return ie.create(Li,r).generateCommitMessage$();case V.CLOVA_X:return ie.create(Ri,r).generateCommitMessage$();default:const u=g.red.bold(`[${n}]`);return Z({name:u+" Invalid AI type",value:"Invalid AI type",isError:!0})}}))}}const Qn=async()=>{const{stdout:e,failed:t}=await Y("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new w("The current directory must be a Git repository!");return e},$t=e=>`:(exclude)${e}`,er=["package-lock.json","pnpm-lock.yaml","*.lock"].map($t),tr=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:n}=await Y("git",[...t,"--name-only",...er,...e?e.map($t):[]]);if(!n)return null;const{stdout:r}=await Y("git",[...t,...er,...e?e.map($t):[]]);return{files:n.split(`
60
+ `),diff:r}},Gi=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ie{constructor(){this.title="aicommit2"}printTitle(){console.log(Ir.textSync(this.title,{font:"Small"}))}displaySpinner(t){return Ne(t).start()}stopSpinner(t){t.stop(),t.clear()}printStagedFiles(t){console.log(g.bold.green("\u2714 ")+g.bold(`${Gi(t.files)}:`)),console.log(`${t.files.map(n=>` ${n}`).join(`
60
61
  `)}
61
62
  `)}printAnalyzed(){console.log(`
62
- ${C.bold.green("\u2714")} ${C.bold("Changes analyzed")}`)}printCommitted(){console.log(`
63
- ${C.bold.green("\u2714")} ${C.bold("Successfully committed!")}`)}printCopied(){console.log(`
64
- ${C.bold.green("\u2714")} ${C.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
65
- ${C.bold.green("\u2714")} ${C.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
66
- ${C.bold.yellow("\u26A0")} ${C.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
67
- ${C.bold.red("\u2716")} ${C.red(`${t}`)}`)}moveCursorUp(){const t=fe.createInterface({input:process.stdin,output:process.stdout});fe.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=fe.createInterface({input:process.stdin,output:process.stdout});fe.moveCursor(process.stdout,0,1),t.close()}}const ji={isLoading:!1,startOption:{text:"AI is analyzing your changes"}};class Gi{constructor(){this.choices$=new Mt([]),this.loader$=new Mt(ji),this.destroyed$=new hr(1)}initPrompt(){return Me.registerPrompt("reactiveListPrompt",Sr),Me.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:"\u26A0 No commit messages were generated",choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{name:n,value:r,isError:u}=t;if(!t||!r)return;const o=this.choices$.getValue();this.choices$.next([...o,{name:n,value:r,disabled:u,isError:u}])}checkErrorOnChoices(){if(this.choices$.getValue().map(n=>n).every(n=>n?.isError||n?.disabled)){this.alertNoGeneratedMessage();return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:"No commit messages were generated",stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}}const P=new Se;var Hi=async(e,t,n,r,u,o,s,a)=>(async()=>{P.printTitle(),await Qn(),r&&await z("git",["add","--update"]);const i=P.displaySpinner("Detecting staged files"),f=await tr(n);if(i.stop(),!f)throw new b("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");P.printStagedFiles(f);const{env:l}=process,c=await Bt({OPENAI_KEY:l.OPENAI_KEY||l.OPENAI_API_KEY,OPENAI_MODEL:l.OPENAI_MODEL||l["openai-model"]||l.openai_model,HUGGING_COOKIE:l.HUGGING_COOKIE||l.HUGGING_API_KEY||l.HF_TOKEN,HUGGING_MODEL:l.HUGGING_MODEL||l["hugging-model"],CLOVAX_COOKIE:l.CLOVAX_COOKIE||l.CLOVA_X_COOKIE,proxy:l.https_proxy||l.HTTPS_PROXY||l.http_proxy||l.HTTP_PROXY,temperature:l.temperature,generate:t?.toString()||l.generate,type:u?.toString()||l.type,locale:e?.toString()||l.locale}),D=Object.entries(c).filter(([v])=>_n.includes(v)).filter(([v,T])=>!!T).map(([v])=>v);if(D.length===0)throw new b("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const p=new Zn(c,f),m=new Gi,h=m.initPrompt();m.startLoader();const g=p.createAIRequests$(D).subscribe(v=>m.refreshChoices(v),()=>{},()=>m.checkErrorOnChoices()),E=await h;g.unsubscribe(),m.completeSubject(),P.moveCursorUp();const $=E.aicommit2Prompt?.value;if(!$)throw new b("An error occurred! No selected message");if(s&&(Xu("copy-paste").copy($),P.printCopied(),process.exit()),o){const v=Ne("Committing with the generated message").start();await z("git",["commit","-m",$,...a]),v.stop(),v.clear(),P.printCommitted(),process.exit()}const k=await Me.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:I}=k;if(I){const v=Ne("Committing with the generated message").start();await z("git",["commit","-m",$,...a]),v.stop(),v.clear(),P.printCommitted(),process.exit()}P.printCancelledCommit(),process.exit()})().catch(i=>{P.printErrorMessage(i.message),ve(i),process.exit(1)}),Ui=rn({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:n}=e._;if(t==="get"){const r=await Bt({},!0);for(const u of n)R(r,u)&&console.log(`${u}=${r[u]}`);return}if(t==="set"){await Mi(n.map(r=>r.split("=")));return}throw new b(`Invalid mode: ${t}`)})().catch(t=>{new Se().printErrorMessage(t.message),ve(t),process.exit(1)})});const nr="prepare-commit-msg",rr=`.git/hooks/${nr}`,Ie=vr(new URL("cli.mjs",import.meta.url)),qi=process.argv[1].replace(/\\/g,"/").endsWith(`/${rr}`),ur=process.platform==="win32",or=`
63
+ ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
64
+ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){console.log(`
65
+ ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
66
+ ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
67
+ ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
68
+ ${g.bold.red("\u2716")} ${g.red(`${t}`)}`)}moveCursorUp(){const t=me.createInterface({input:process.stdin,output:process.stdout});me.moveCursor(process.stdout,0,-1),t.close()}moveCursorDown(){const t=me.createInterface({input:process.stdin,output:process.stdout});me.moveCursor(process.stdout,0,1),t.close()}}const Hi={isLoading:!1,startOption:{text:"AI is analyzing your changes"}};class Ui{constructor(){this.choices$=new Tt([]),this.loader$=new Tt(Hi),this.destroyed$=new hr(1)}initPrompt(){return Te.registerPrompt("reactiveListPrompt",Sr),Te.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:"\u26A0 No commit messages were generated",choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{name:n,value:r,isError:u}=t;if(!t||!r)return;const o=this.choices$.getValue();this.choices$.next([...o,{name:n,value:r,disabled:u,isError:u}])}checkErrorOnChoices(){if(this.choices$.getValue().map(n=>n).every(n=>n?.isError||n?.disabled)){this.alertNoGeneratedMessage();return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:"No commit messages were generated",stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}}const P=new Ie;var qi=async(e,t,n,r,u,o,s,a)=>(async()=>{P.printTitle(),await Qn(),r&&await Y("git",["add","--update"]);const i=P.displaySpinner("Detecting staged files"),f=await tr(n);if(i.stop(),!f)throw new w("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");P.printStagedFiles(f);const{env:l}=process,D=await Bt({OPENAI_KEY:l.OPENAI_KEY||l.OPENAI_API_KEY,OPENAI_MODEL:l.OPENAI_MODEL||l["openai-model"]||l.openai_model,GEMINI_KEY:l.GEMINI_KEY||l.GEMINI_API_KEY,GEMINI_MODEL:l.GEMINI_MODEL||l["gemini-model"]||l.gemini_model,ANTHROPIC_KEY:l.ANTHROPIC_KEY||l.ANTHROPIC_API_KEY,ANTHROPIC_MODEL:l.ANTHROPIC_MODEL||l["anthropic-model"]||l.anthropic_model,HUGGING_COOKIE:l.HUGGING_COOKIE||l.HUGGING_API_KEY||l.HF_TOKEN,HUGGING_MODEL:l.HUGGING_MODEL||l["hugging-model"],CLOVAX_COOKIE:l.CLOVAX_COOKIE||l.CLOVA_X_COOKIE,proxy:l.https_proxy||l.HTTPS_PROXY||l.http_proxy||l.HTTP_PROXY,temperature:l.temperature,generate:t?.toString()||l.generate,type:u?.toString()||l.type,locale:e?.toString()||l.locale}),c=Object.entries(D).filter(([A])=>_n.includes(A)).filter(([A,M])=>!!M).map(([A])=>A);if(c.length===0)throw new w("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const p=new Zn(D,f),m=new Ui,h=m.initPrompt();m.startLoader();const C=p.createAIRequests$(c).subscribe(A=>m.refreshChoices(A),()=>{},()=>m.checkErrorOnChoices()),y=await h;C.unsubscribe(),m.completeSubject(),P.moveCursorUp();const $=y.aicommit2Prompt?.value;if(!$)throw new w("An error occurred! No selected message");if(s&&(Ju("copy-paste").copy($),P.printCopied(),process.exit()),o){const A=Ne("Committing with the generated message").start();await Y("git",["commit","-m",$,...a]),A.stop(),A.clear(),P.printCommitted(),process.exit()}const k=await Te.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:S}=k;if(S){const A=Ne("Committing with the generated message").start();await Y("git",["commit","-m",$,...a]),A.stop(),A.clear(),P.printCommitted(),process.exit()}P.printCancelledCommit(),process.exit()})().catch(i=>{P.printErrorMessage(i.message),ve(i),process.exit(1)}),Ki=rn({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:n}=e._;if(t==="get"){const r=await Bt({},!0);for(const u of n)R(r,u)&&console.log(`${u}=${r[u]}`);return}if(t==="set"){await Ni(n.map(r=>r.split("=")));return}throw new w(`Invalid mode: ${t}`)})().catch(t=>{new Ie().printErrorMessage(t.message),ve(t),process.exit(1)})});const nr="prepare-commit-msg",rr=`.git/hooks/${nr}`,Se=Ar(new URL("cli.mjs",import.meta.url)),zi=process.argv[1].replace(/\\/g,"/").endsWith(`/${rr}`),ur=process.platform==="win32",or=`
68
69
  #!/usr/bin/env node
69
- import(${JSON.stringify(Ar(Ie))})
70
- `.trim();var Ki=rn({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Qn(),{installUninstall:n}=e._,r=j.join(t,rr),u=await Xn(r);if(n==="install"){if(u){if(await x.realpath(r).catch(()=>{})===Ie){console.warn("The hook is already installed");return}throw new b(`A different ${nr} hook seems to be installed. Please remove it before installing aicommit2.`)}await x.mkdir(j.dirname(r),{recursive:!0}),ur?await x.writeFile(r,or):(await x.symlink(Ie,r,"file"),await x.chmod(r,493)),console.log(`${C.green("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!u){console.warn("Hook is not installed");return}if(ur){if(await x.readFile(r,"utf8")!==or){console.warn("Hook is not installed");return}}else if(await x.realpath(r)!==Ie){console.warn("Hook is not installed");return}await x.rm(r),console.log(`${C.green("\u2714")} Hook uninstalled`);return}throw new b(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${C.red("\u2716")} ${t.message}`),ve(t),process.exit(1)})});const[xt,zi]=process.argv.slice(2);var Wi=()=>(async()=>{if(!xt)throw new b('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(zi)return;const e=await tr();if(!e)return;const t=new Se;t.printTitle();const{env:n}=process,r=await Bt({proxy:n.https_proxy||n.HTTPS_PROXY||n.http_proxy||n.HTTP_PROXY}),u=Object.entries(r).filter(([d])=>_n.includes(d)).filter(([d,p])=>!!p).map(([d])=>d);if(u.length===0)throw new b("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const s=new Zn(r,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await Cr(s.createAIRequests$(u).pipe(gr(d=>!d.isError),X(d=>d.value),Fr()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const l=await x.readFile(xt,"utf8")!=="",c=i.length>1;let D="";l&&(D=`# \u{1F916} AI generated commit${c?"s":""}
71
- `),c?(l&&(D+=`# Select one of the following messages by uncommenting:
72
- `),D+=`
70
+ import(${JSON.stringify(vr(Se))})
71
+ `.trim();var Wi=rn({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Qn(),{installUninstall:n}=e._,r=j.join(t,rr),u=await Xn(r);if(n==="install"){if(u){if(await x.realpath(r).catch(()=>{})===Se){console.warn("The hook is already installed");return}throw new w(`A different ${nr} hook seems to be installed. Please remove it before installing aicommit2.`)}await x.mkdir(j.dirname(r),{recursive:!0}),ur?await x.writeFile(r,or):(await x.symlink(Se,r,"file"),await x.chmod(r,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(n==="uninstall"){if(!u){console.warn("Hook is not installed");return}if(ur){if(await x.readFile(r,"utf8")!==or){console.warn("Hook is not installed");return}}else if(await x.realpath(r)!==Se){console.warn("Hook is not installed");return}await x.rm(r),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new w(`Invalid mode: ${n}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),ve(t),process.exit(1)})});const[xt,Yi]=process.argv.slice(2);var Vi=()=>(async()=>{if(!xt)throw new w('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Yi)return;const e=await tr();if(!e)return;const t=new Ie;t.printTitle();const{env:n}=process,r=await Bt({proxy:n.https_proxy||n.HTTPS_PROXY||n.http_proxy||n.HTTP_PROXY}),u=Object.entries(r).filter(([d])=>_n.includes(d)).filter(([d,p])=>!!p).map(([d])=>d);if(u.length===0)throw new w("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const s=new Zn(r,e),a=t.displaySpinner("The AI is analyzing your changes");let i;try{i=await gr(s.createAIRequests$(u).pipe(Cr(d=>!d.isError),H(d=>d.value),Fr()))}finally{a.stop(),a.clear(),t.printAnalyzed()}const l=await x.readFile(xt,"utf8")!=="",D=i.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${D?"s":""}
72
+ `),D?(l&&(c+=`# Select one of the following messages by uncommenting:
73
+ `),c+=`
73
74
  ${i.map(d=>`# ${d}`).join(`
74
- `)}`):(l&&(D+=`# Edit the message below and commit:
75
- `),D+=`
75
+ `)}`):(l&&(c+=`# Edit the message below and commit:
76
+ `),c+=`
76
77
  ${i[0]}
77
- `),await x.appendFile(xt,D),t.printSavedCommitMessage()})().catch(e=>{new Se().printErrorMessage(e.message),ve(e),process.exit(1)});const sr=process.argv.slice(2);Yu({name:"aicommit2",version:Mn,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},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:"Type of commit message to generate",alias:"t",default:"conventional"},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",alias:"c",default:!1}},commands:[Ui,Ki],help:{description:Zs},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(qi){Wi();return}Hi(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,sr)},sr);
78
+ `),await x.appendFile(xt,c),t.printSavedCommitMessage()})().catch(e=>{new Ie().printErrorMessage(e.message),ve(e),process.exit(1)});const sr=process.argv.slice(2);Xu({name:"aicommit2",version:Tn,flags:{locale:{type:String,description:"Locale to use for the generated commit messages (default: en)",alias:"l"},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:"Type of commit message to generate",alias:"t",default:"conventional"},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",alias:"c",default:!1}},commands:[Ki,Wi],help:{description:Qs},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(zi){Vi();return}qi(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,sr)},sr);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.2.0",
4
- "description": "Reactive CLI that generates git commit messages with various AI",
3
+ "version": "1.3.0",
4
+ "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "ai",
7
7
  "git",
@@ -15,7 +15,9 @@
15
15
  "clovax",
16
16
  "clova x",
17
17
  "anthropic",
18
- "claude"
18
+ "claude",
19
+ "gemini",
20
+ "generative-ai"
19
21
  ],
20
22
  "license": "MIT",
21
23
  "repository": "tak-bro/aicommit2",
@@ -31,6 +33,7 @@
31
33
  "dependencies": {
32
34
  "@anthropic-ai/sdk": "^0.14.1",
33
35
  "@dqbd/tiktoken": "^1.0.2",
36
+ "@google/generative-ai": "^0.2.1",
34
37
  "@inquirer/prompts": "^3.0.0",
35
38
  "axios": "^1.4.0",
36
39
  "chalk": "^5.3.0",
@@ -42,7 +45,6 @@
42
45
  "ora": "^8.0.1",
43
46
  "readline": "^1.3.0",
44
47
  "rxjs": "^7.8.1",
45
- "uuid": "^9.0.1",
46
- "web-streams-polyfill": "^3.3.2"
48
+ "uuid": "^9.0.1"
47
49
  }
48
50
  }