aicommit2 1.5.0 → 1.6.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 +83 -32
  2. package/dist/cli.mjs +48 -47
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -14,6 +14,10 @@
14
14
 
15
15
  ---
16
16
 
17
+ ## Introduction
18
+
19
+ AICommit2 streamlines interactions with various AI, enabling users to send requests to multiple AI simultaneously and choose the most suitable message, without the necessity of waiting for all AI responses.
20
+
17
21
  ## Project Base & Inspiration
18
22
 
19
23
  The core functionalities and architecture of this project are inspired by [AI Commits](https://github.com/Nutlope/aicommits).
@@ -27,6 +31,10 @@ The core functionalities and architecture of this project are inspired by [AI Co
27
31
  - [Huggingface **(Unofficial)**](https://huggingface.co/chat/)
28
32
  - [Clova X **(Unofficial)**](https://clova-x.naver.com/)
29
33
 
34
+ ## Local Model
35
+
36
+ - [Ollama](https://ollama.com/)
37
+
30
38
  ## Setup
31
39
 
32
40
  > The minimum supported version of Node.js is the v18. Check your Node.js version with `node --version`.
@@ -55,6 +63,7 @@ aicommit2 config set OPENAI_KEY=<your key> # OpenAI
55
63
  aicommit2 config set ANTHROPIC_KEY=<your key> # Anthropic Claude
56
64
  aicommit2 config set GEMINI_KEY=<your key> # Gemini
57
65
  aicommit2 config set MISTRAL_KEY=<your key> # Mistral AI
66
+
58
67
  # Please be cautious of Escape characters(\", \') in browser cookie string
59
68
  aicommit2 config set HUGGING_COOKIE="<your browser cookie>" # Hugging Face
60
69
  aicommit2 config set CLOVAX_COOKIE="<your browser cookie>" # Clova X
@@ -64,7 +73,29 @@ This will create a `.aicommit2` file in your home directory.
64
73
 
65
74
  > It is not necessary to set all keys. **But at least one key must be set up.**
66
75
 
67
- ### Upgrading
76
+ ## Using Locally
77
+
78
+ You can also use your model for free with [Ollama](https://ollama.com/).
79
+
80
+ 1. Install Ollama from [https://ollama.com](https://ollama.com/)
81
+
82
+ 2. Start it with your model
83
+
84
+ ```shell
85
+ ollama run llama2 # model you want use
86
+ ```
87
+
88
+ 3. Set the model and host
89
+
90
+ ```sh
91
+ aicommit2 config set OLLAMA_MODEL=<your model>
92
+ aicommit2 config set OLLAMA_HOST=<host> # The default host for ollama is http://localhost:11434.
93
+ aicommit2 config set OLLAMA_TIMEOUT=<timout> # default is 100000ms (100s)
94
+ ```
95
+
96
+ > If you want to use ollama, you must set **OLLAMA_MODEL**.
97
+
98
+ ## Upgrading
68
99
 
69
100
  Check the installed version with:
70
101
 
@@ -229,39 +260,43 @@ aicommit2 config set OPENAI_KEY=<your-api-key> generate=3 locale=en
229
260
 
230
261
  ### Options
231
262
 
232
- | Option | Default | Description |
233
- |---------------------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
234
- | `OPENAI_KEY` | N/A | The OpenAI API key. |
235
- | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use. |
236
- | `ANTHROPIC_KEY` | N/A | The Anthropic API key. |
237
- | `ANTHROPIC_MODEL` | `claude-2.1` | The Anthropic Model to use. |
238
- | `GEMINI_KEY` | N/A | The Gemini API key. |
239
- | `GEMINI_MODEL` | `gemini-pro` | The Gemini Model |
240
- | `MISTRAL_KEY` | N/A | The Mistral API key. |
241
- | `MISTRAL_MODEL` | `mistral-tiny` | The Mistral Model to use |
242
- | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
243
- | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use. |
244
- | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
245
- | `locale` | `en` | Locale for the generated commit messages. |
246
- | `generate` | `1` | Number of commit messages to generate. |
247
- | `type` | `conventional` | Type of commit message to generate. |
248
- | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**). |
249
- | `timeout` | `10000` ms | Network request timeout |
250
- | `max-length` | `50` | Maximum character length of the generated commit message. |
251
- | `max-tokens` | `200` | The maximum number of tokens that the AI models can generate. (for **Open AI, Anthropic, Gemini, Mistral**) |
252
- | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini, Mistral**) |
263
+ | Option | Default | Description |
264
+ |-------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
265
+ | `OPENAI_KEY` | N/A | The OpenAI API key |
266
+ | `OPENAI_MODEL` | `gpt-3.5-turbo` | The OpenAI Model to use |
267
+ | `ANTHROPIC_KEY` | N/A | The Anthropic API key |
268
+ | `ANTHROPIC_MODEL` | `claude-2.1` | The Anthropic Model to use |
269
+ | `GEMINI_KEY` | N/A | The Gemini API key |
270
+ | `GEMINI_MODEL` | `gemini-pro` | The Gemini Model |
271
+ | `MISTRAL_KEY` | N/A | The Mistral API key |
272
+ | `MISTRAL_MODEL` | `mistral-tiny` | The Mistral Model to use |
273
+ | `HUGGING_COOKIE` | N/A | The HuggingFace Cookie string |
274
+ | `HUGGING_MODEL` | `mistralai/Mixtral-8x7B-Instruct-v0.1` | The HuggingFace Model to use |
275
+ | `CLOVAX_COOKIE` | N/A | The Clova X Cookie string |
276
+ | `OLLAMA_MODEL` | N/A | The Ollama Model. It should be downloaded your local |
277
+ | `OLLAMA_HOST` | `http://localhost:11434` | The Ollama Host |
278
+ | `OLLAMA_TIMEOUT` | `100000` ms | Request timeout for the Ollama |
279
+ | `locale` | `en` | Locale for the generated commit messages |
280
+ | `generate` | `1` | Number of commit messages to generate |
281
+ | `type` | `conventional` | Type of commit message to generate |
282
+ | `proxy` | N/A | Set a HTTP/HTTPS proxy to use for requests(only **OpenAI**) |
283
+ | `timeout` | `10000` ms | Network request timeout |
284
+ | `max-length` | `50` | Maximum character length of the generated commit message |
285
+ | `max-tokens` | `200` | The maximum number of tokens that the AI models can generate (for **Open AI, Anthropic, Gemini, Mistral**) |
286
+ | `temperature` | `0.7` | The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini, Mistral**) |
253
287
 
254
288
  > **Currently, options are set universally. However, there are plans to develop the ability to set individual options in the future.**
255
289
 
256
290
  #### Available Options by Model
257
- | | locale | generate | type | proxy | timeout | max-length | max-tokens | max-tokens |
258
- |:--------------------:|:------:|:--------:|:-----:|:-----:|:--------:|:-----------:|:----------:|:----------:|
259
- | **OpenAI** | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ |
260
- | **Anthropic Claude** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
261
- | **Gemini** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
262
- | **Mistral AI** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
263
- | **Huggingface** | ✓ | ✓ | ✓ | | | ✓ | | |
264
- | **Clova X** | ✓ | ✓ | ✓ | | | ✓ | | |
291
+ | | locale | generate | type | proxy | timeout | max-length | max-tokens | temperature |
292
+ |:--------------------:|:------:|:--------:|:-----:|:-----:|:----------------------:|:-----------:|:----------:|:-----------:|
293
+ | **OpenAI** | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ |
294
+ | **Anthropic Claude** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
295
+ | **Gemini** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
296
+ | **Mistral AI** | ✓ | ✓ | ✓ | | | ✓ | ✓ | ✓ |
297
+ | **Huggingface** | ✓ | ✓ | ✓ | | | ✓ | | |
298
+ | **Clova X** | ✓ | ✓ | ✓ | | | ✓ | | |
299
+ | **Ollama** | ✓ | ✓ | ✓ | | ✓<br/>(OLLAMA_TIMEOUT) | ✓ | | ✓ |
265
300
 
266
301
  #### OPENAI_KEY
267
302
 
@@ -357,6 +392,22 @@ Supported:
357
392
 
358
393
  The [Clova X](https://clova-x.naver.com/) Cookie. Please check [how to get cookie](https://github.com/tak-bro/aicommit2?tab=readme-ov-file#how-to-get-cookieunofficial-api)
359
394
 
395
+ #### OLLAMA_MODEL
396
+
397
+ The Ollama Model. Please see [a list of models available](https://ollama.com/library)
398
+
399
+ #### OLLAMA_HOST
400
+
401
+ Default: `http://localhost:11434`
402
+
403
+ The Ollama host
404
+
405
+ #### OLLAMA_TIMEOUT
406
+
407
+ Default: `100000` (100 seconds)
408
+
409
+ Request timeout for the Ollama. Default OLLAMA_TIMEOUT is **100 seconds** because it can take a long time to run locally.
410
+
360
411
  #### locale
361
412
 
362
413
  Default: `en`
@@ -422,7 +473,7 @@ aicommit2 config set type=
422
473
  ```
423
474
 
424
475
  #### max-tokens
425
- The maximum number of tokens that the AI models can generate. (for **Open AI, Anthropic, Gemini**)
476
+ The maximum number of tokens that the AI models can generate.
426
477
 
427
478
  Default: `200`
428
479
 
@@ -431,7 +482,7 @@ aicommit2 config set max-tokens=1000
431
482
  ```
432
483
 
433
484
  #### temperature
434
- The temperature (0.0-2.0) is used to control the randomness of the output (for **Open AI, Anthropic, Gemini**)
485
+ The temperature (0.0-2.0) is used to control the randomness of the output
435
486
 
436
487
  Default: `0.7`
437
488
 
package/dist/cli.mjs CHANGED
@@ -1,64 +1,65 @@
1
1
  #!/usr/bin/env node
2
- import Pe from"tty";import{createRequire as Dn}from"module";import{Buffer as cn}from"node:buffer";import H from"node:path";import It from"node:child_process";import _ from"node:process";import ln from"child_process";import U from"path";import Me from"fs";import fn from"node:url";import pn,{constants as St}from"node:os";import Pt from"assert";import Mt from"events";import dn 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 K,concatMap as q,from as T,map as N,catchError as z,mergeMap as mn,BehaviorSubject as Tt,ReplaySubject as hn,lastValueFrom as gn,filter as Cn,toArray as Fn}from"rxjs";import Re from"@anthropic-ai/sdk";import{fromPromise as Y}from"rxjs/internal/observable/innerFrom";import En from"https";import"@dqbd/tiktoken";import yn from"net";import wn from"tls";import bn,{fileURLToPath as An,pathToFileURL as vn}from"url";import Nt from"os";import{FormData as Bn,Blob as $n}from"formdata-node";import x from"fs/promises";import xn from"axios";import{GoogleGenerativeAI as On}from"@google/generative-ai";import me from"readline";import In from"figlet";import Sn from"inquirer-reactive-list-prompt";const Pn="known-flag",Mn="unknown-flag",_n="argument",{stringify:oe}=JSON,Tn=/\B([A-Z])/g,Nn=e=>e.replace(Tn,"-$1").toLowerCase(),{hasOwnProperty:Rn}=Object.prototype,se=(e,t)=>Rn.call(e,t),kn=e=>Array.isArray(e),Rt=e=>typeof e=="function"?[e,!1]:kn(e)?[e[0],!0]:Rt(e.type),Ln=(e,t)=>e===Boolean?t!=="false":t,jn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Gn=/[\s.:=]/,Hn=e=>{const t=`Flag name ${oe(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 r=e.match(Gn);if(r)throw new Error(`${t} cannot contain ${oe(r?.[0])}`)},Un=e=>{const t={},r=(n,u)=>{if(se(t,n))throw new Error(`Duplicate flags named ${oe(n)}`);t[n]=u};for(const n in e){if(!se(e,n))continue;Hn(n);const u=e[n],o=[[],...Rt(u),u];r(n,o);const s=Nn(n);if(n!==s&&r(s,o),"alias"in u&&typeof u.alias=="string"){const{alias:i}=u,a=`Flag alias ${oe(i)} for flag ${oe(n)}`;if(i.length===0)throw new Error(`${a} cannot be empty`);if(i.length>1)throw new Error(`${a} must be a single character`);r(i,o)}}return t},Kn=(e,t)=>{const r={};for(const n in e){if(!se(e,n))continue;const[u,,o,s]=t[n];if(u.length===0&&"default"in s){let{default:i}=s;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=o?u:u.pop()}return r},he="--",qn=/[.:=]/,zn=/^-{1,2}\w/,Yn=e=>{if(!zn.test(e))return;const t=!e.startsWith(he);let r=e.slice(t?1:2),n;const u=r.match(qn);if(u){const{index:o}=u;n=r.slice(o+1),r=r.slice(0,o)}return[r,n,t]},Wn=(e,{onFlag:t,onArgument:r})=>{let n;const u=(o,s)=>{if(typeof n!="function")return!0;n(o,s),n=void 0};for(let o=0;o<e.length;o+=1){const s=e[o];if(s===he){u();const a=e.slice(o+1);r?.(a,[o],!0);break}const i=Yn(s);if(i){if(u(),!t)continue;const[a,f,l]=i;if(l)for(let D=0;D<a.length;D+=1){u();const c=D===a.length-1;n=t(a[D],c?f:void 0,[o,D+1,c])}else n=t(a,f,[o])}else u(s,[o])&&r?.([s],[o])}u()},Vn=(e,t)=>{for(const[r,n,u]of t.reverse()){if(n){const o=e[r];let s=o.slice(0,n);if(u||(s+=o.slice(n+1)),s!=="-"){e[r]=s;continue}}e.splice(r,1)}},Xn=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],u=Un(e),o={},s=[];return s[he]=[],Wn(t,{onFlag(i,a,f){const l=se(u,i);if(!r?.(l?Pn:Mn,i,a)){if(l){const[D,c]=u[i],p=Ln(c,a),d=(m,h)=>{n.push(f),h&&n.push(h),D.push(jn(c,m||""))};return p===void 0?d:d(p)}se(o,i)||(o[i]=[]),o[i].push(a===void 0?!0:a),n.push(f)}},onArgument(i,a,f){r?.(_n,t[a[0]])||(s.push(...i),f?(s[he]=i,t.splice(a[0])):n.push(a))}}),Vn(t,n),{flags:Kn(e,u),unknownFlags:o,_:s}};var Jn=Object.create,ge=Object.defineProperty,Zn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptor,eu=Object.getOwnPropertyDescriptors,tu=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,ru=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty,nu=Object.prototype.propertyIsEnumerable,jt=(e,t,r)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ce=(e,t)=>{for(var r in t||(t={}))Lt.call(t,r)&&jt(e,r,t[r]);if(kt)for(var r of kt(t))nu.call(t,r)&&jt(e,r,t[r]);return e},ke=(e,t)=>Zn(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,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of tu(t))!Lt.call(e,u)&&(r||u!=="default")&&ge(e,u,{get:()=>t[u],enumerable:!(n=Qn(t,u))||n.enumerable});return e},au=(e,t)=>iu(uu(ge(e!=null?Jn(ru(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,r,n;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:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n: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 pu=au(Du(),1);function R(e){if(typeof e!="string"||e.length===0||(e=Gt(e),e.length===0))return 0;e=e.replace((0,pu.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=fu(n)?2:1)}return t}var Ht=e=>Math.max(...e.split(`
3
- `).map(R)),du=e=>{let t=[];for(let r of e){let{length:n}=r,u=n-t.length;for(let o=0;o<u;o+=1)t.push(0);for(let o=0;o<n;o+=1){let s=Ht(r[o]);s>t[o]&&(t[o]=s)}}return t};B();var Ut=/^\d+%$/,Kt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},mu=(e,t)=>{var r;let n=[];for(let u=0;u<e.length;u+=1){let o=(r=t[u])!=null?r:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Ut.test(o)){n.push(ke(Ce({},Kt),{width:o,contentWidth:e[u]}));continue}if(o&&typeof o=="object"){let s=ke(Ce(Ce({},Kt),o),{contentWidth:e[u]});s.horizontalPadding=s.paddingLeft+s.paddingRight,n.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return n};function hu(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof n=="string"&&Ut.test(n)){let a=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:u}=r,o=1,s=o+u;if(s>=t){let a=s-t,f=Math.ceil(r.paddingLeft/u*a),l=a-f;r.paddingLeft-=f,r.paddingRight-=l,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),o)}}var qt=()=>Object.assign([],{columns:0});function gu(e,t){let r=[qt()],[n]=r;for(let u of e){let o=u.width+u.horizontalPadding;n.columns+o>t&&(n=qt(),r.push(n)),n.push(u),n.columns+=o}for(let u of r){let o=u.reduce((c,p)=>c+p.width+p.horizontalPadding,0),s=t-o;if(s===0)continue;let i=u.filter(c=>"autoOverflow"in c),a=i.filter(c=>c.autoOverflow>0),f=a.reduce((c,p)=>c+p.autoOverflow,0),l=Math.min(f,s);for(let c of a){let p=Math.floor(c.autoOverflow/f*l);c.width+=p,s-=p}let D=Math.floor(s/i.length);for(let c=0;c<i.length;c+=1){let p=i[c];c===i.length-1?p.width+=s:p.width+=D,s-=D}}return r}function Cu(e,t,r){let n=mu(r,t);return hu(n,e),gu(n,e)}B(),B(),B();var Le=10,zt=(e=0)=>t=>`\x1B[${t+e}m`,Yt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Wt=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}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[r,n]of Object.entries(t)){for(let[u,o]of Object.entries(n))t[u]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},n[u]=t[u],e.set(o[0],o[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=zt(),t.color.ansi256=Yt(),t.color.ansi16m=Wt(),t.bgColor.ansi=zt(Le),t.bgColor.ansi256=Yt(Le),t.bgColor.ansi16m=Wt(Le),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,u)=>r===n&&n===u?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(u/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:u}=n.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:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,u,o;if(r>=232)n=((r-232)*10+8)/255,u=n,o=n;else{r-=16;let a=r%36;n=Math.floor(r/36)/5,u=Math.floor(a/6)/5,o=a%6/5}let s=Math.max(n,u,o)*2;if(s===0)return 30;let i=30+(Math.round(o)<<2|Math.round(u)<<1|Math.round(n));return s===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,u)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,u)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),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=>R(t)),He=(e,t,r)=>{let n=[...t],u=!1,o=!1,s=R(Gt(e[e.length-1]));for(let[i,a]of n.entries()){let f=R(a);if(s+f<=r?e[e.length-1]+=a:(e.push(a),s=0),Fe.has(a)&&(u=!0,o=n.slice(i+1).join("").startsWith(Ge)),u){o?a===je&&(u=!1,o=!1):a===Xt&&(u=!1);continue}s+=f,s===r&&i<n.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(" "),r=t.length;for(;r>0&&!(R(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Bu=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",u,o,s=Au(e),i=[""];for(let[f,l]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let D=R(i[i.length-1]);if(f!==0&&(D>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),D=0),(D>0||r.trim===!1)&&(i[i.length-1]+=" ",D++)),r.hard&&s[f]>t){let c=t-D,p=1+Math.floor((s[f]-c-1)/t);Math.floor((s[f]-1)/t)<p&&i.push(""),He(i,l,t);continue}if(D+s[f]>t&&D>0&&s[f]>0){if(r.wordWrap===!1&&D<t){He(i,l,t);continue}i.push("")}if(D+s[f]>t&&r.wordWrap===!1){He(i,l,t);continue}i[i.length-1]+=l}r.trim!==!1&&(i=i.map(f=>vu(f)));let a=[...i.join(`
4
- `)];for(let[f,l]of a.entries()){if(n+=l,Fe.has(l)){let{groups:c}=new RegExp(`(?:\\${Vt}(?<code>\\d+)m|\\${Ge}(?<uri>.*)${je})`).exec(a.slice(f).join(""))||{groups:{}};if(c.code!==void 0){let p=Number.parseFloat(c.code);u=p===wu?void 0:p}else c.uri!==void 0&&(o=c.uri.length===0?void 0:c.uri)}let D=yu.codes.get(Number(u));a[f+1]===`
5
- `?(o&&(n+=Zt("")),u&&D&&(n+=Jt(D))):l===`
6
- `&&(u&&D&&(n+=Jt(u)),o&&(n+=Zt(o)))}return n};function $u(e,t,r){return String(e).normalize().replace(/\r\n/g,`
2
+ import Se from"tty";import{createRequire as cn}from"module";import{Buffer as ln}from"node:buffer";import V from"node:path";import Mt from"node:child_process";import T from"node:process";import fn from"child_process";import X from"path";import Pe from"fs";import pn from"node:url";import dn,{constants as St}from"node:os";import Pt from"assert";import Tt from"events";import mn from"buffer";import Te from"stream";import _t from"util";import _e from"inquirer";import Ne from"ora";import g from"chalk";import{of as _,concatMap as k,from as N,map as R,catchError as j,mergeMap as hn,BehaviorSubject as Nt,ReplaySubject as gn,lastValueFrom as Cn,filter as Fn,toArray as En}from"rxjs";import Re from"@anthropic-ai/sdk";import{fromPromise as G}from"rxjs/internal/observable/innerFrom";import yn from"https";import"@dqbd/tiktoken";import wn from"net";import bn from"tls";import An,{fileURLToPath as vn,pathToFileURL as Bn}from"url";import Rt from"os";import{FormData as $n,Blob as xn}from"formdata-node";import O from"fs/promises";import On from"axios";import{GoogleGenerativeAI as In}from"@google/generative-ai";import me from"readline";import Mn from"figlet";import Sn from"inquirer-reactive-list-prompt";const Pn="known-flag",Tn="unknown-flag",_n="argument",{stringify:ue}=JSON,Nn=/\B([A-Z])/g,Rn=e=>e.replace(Nn,"-$1").toLowerCase(),{hasOwnProperty:Ln}=Object.prototype,se=(e,t)=>Ln.call(e,t),kn=e=>Array.isArray(e),Lt=e=>typeof e=="function"?[e,!1]:kn(e)?[e[0],!0]:Lt(e.type),jn=(e,t)=>e===Boolean?t!=="false":t,Gn=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Hn=/[\s.:=]/,Un=e=>{const t=`Flag name ${ue(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 r=e.match(Hn);if(r)throw new Error(`${t} cannot contain ${ue(r?.[0])}`)},Kn=e=>{const t={},r=(n,o)=>{if(se(t,n))throw new Error(`Duplicate flags named ${ue(n)}`);t[n]=o};for(const n in e){if(!se(e,n))continue;Un(n);const o=e[n],u=[[],...Lt(o),o];r(n,u);const s=Rn(n);if(n!==s&&r(s,u),"alias"in o&&typeof o.alias=="string"){const{alias:i}=o,a=`Flag alias ${ue(i)} for flag ${ue(n)}`;if(i.length===0)throw new Error(`${a} cannot be empty`);if(i.length>1)throw new Error(`${a} must be a single character`);r(i,u)}}return t},qn=(e,t)=>{const r={};for(const n in e){if(!se(e,n))continue;const[o,,u,s]=t[n];if(o.length===0&&"default"in s){let{default:i}=s;typeof i=="function"&&(i=i()),r[n]=i}else r[n]=u?o:o.pop()}return r},he="--",zn=/[.:=]/,Yn=/^-{1,2}\w/,Wn=e=>{if(!Yn.test(e))return;const t=!e.startsWith(he);let r=e.slice(t?1:2),n;const o=r.match(zn);if(o){const{index:u}=o;n=r.slice(u+1),r=r.slice(0,u)}return[r,n,t]},Vn=(e,{onFlag:t,onArgument:r})=>{let n;const o=(u,s)=>{if(typeof n!="function")return!0;n(u,s),n=void 0};for(let u=0;u<e.length;u+=1){const s=e[u];if(s===he){o();const a=e.slice(u+1);r?.(a,[u],!0);break}const i=Wn(s);if(i){if(o(),!t)continue;const[a,f,l]=i;if(l)for(let D=0;D<a.length;D+=1){o();const c=D===a.length-1;n=t(a[D],c?f:void 0,[u,D+1,c])}else n=t(a,f,[u])}else o(s,[u])&&r?.([s],[u])}o()},Xn=(e,t)=>{for(const[r,n,o]of t.reverse()){if(n){const u=e[r];let s=u.slice(0,n);if(o||(s+=u.slice(n+1)),s!=="-"){e[r]=s;continue}}e.splice(r,1)}},Jn=(e,t=process.argv.slice(2),{ignore:r}={})=>{const n=[],o=Kn(e),u={},s=[];return s[he]=[],Vn(t,{onFlag(i,a,f){const l=se(o,i);if(!r?.(l?Pn:Tn,i,a)){if(l){const[D,c]=o[i],p=jn(c,a),d=(m,h)=>{n.push(f),h&&n.push(h),D.push(Gn(c,m||""))};return p===void 0?d:d(p)}se(u,i)||(u[i]=[]),u[i].push(a===void 0?!0:a),n.push(f)}},onArgument(i,a,f){r?.(_n,t[a[0]])||(s.push(...i),f?(s[he]=i,t.splice(a[0])):n.push(a))}}),Xn(t,n),{flags:qn(e,o),unknownFlags:u,_:s}};var Zn=Object.create,ge=Object.defineProperty,Qn=Object.defineProperties,eo=Object.getOwnPropertyDescriptor,to=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols,no=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,Gt=(e,t,r)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ce=(e,t)=>{for(var r in t||(t={}))jt.call(t,r)&&Gt(e,r,t[r]);if(kt)for(var r of kt(t))oo.call(t,r)&&Gt(e,r,t[r]);return e},Le=(e,t)=>Qn(e,to(t)),uo=e=>ge(e,"__esModule",{value:!0}),so=(e,t)=>()=>(e&&(t=e(e=0)),t),io=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ao=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ro(t))!jt.call(e,o)&&(r||o!=="default")&&ge(e,o,{get:()=>t[o],enumerable:!(n=eo(t,o))||n.enumerable});return e},Do=(e,t)=>ao(uo(ge(e!=null?Zn(no(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),B=so(()=>{}),co=io((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 lo=e=>{var t,r,n;let o=(t=process.stdout.columns)!=null?t:Number.POSITIVE_INFINITY;return typeof e=="function"&&(e=e(o)),e||(e={}),Array.isArray(e)?{columns:e,stdoutColumns:o}:{columns:(r=e.columns)!=null?r:[],stdoutColumns:(n=e.stdoutColumns)!=null?n:o}};B(),B(),B(),B(),B();function fo({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 Ht(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(fo(),"")}B();function po(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 mo=Do(co(),1);function H(e){if(typeof e!="string"||e.length===0||(e=Ht(e),e.length===0))return 0;e=e.replace((0,mo.default)()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=po(n)?2:1)}return t}var Ut=e=>Math.max(...e.split(`
3
+ `).map(H)),ho=e=>{let t=[];for(let r of e){let{length:n}=r,o=n-t.length;for(let u=0;u<o;u+=1)t.push(0);for(let u=0;u<n;u+=1){let s=Ut(r[u]);s>t[u]&&(t[u]=s)}}return t};B();var Kt=/^\d+%$/,qt={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},go=(e,t)=>{var r;let n=[];for(let o=0;o<e.length;o+=1){let u=(r=t[o])!=null?r:"auto";if(typeof u=="number"||u==="auto"||u==="content-width"||typeof u=="string"&&Kt.test(u)){n.push(Le(Ce({},qt),{width:u,contentWidth:e[o]}));continue}if(u&&typeof u=="object"){let s=Le(Ce(Ce({},qt),u),{contentWidth:e[o]});s.horizontalPadding=s.paddingLeft+s.paddingRight,n.push(s);continue}throw new Error(`Invalid column width: ${JSON.stringify(u)}`)}return n};function Co(e,t){for(let r of e){let{width:n}=r;if(n==="content-width"&&(r.width=r.contentWidth),n==="auto"){let a=Math.min(20,r.contentWidth);r.width=a,r.autoOverflow=r.contentWidth-a}if(typeof n=="string"&&Kt.test(n)){let a=Number.parseFloat(n.slice(0,-1))/100;r.width=Math.floor(t*a)-(r.paddingLeft+r.paddingRight)}let{horizontalPadding:o}=r,u=1,s=u+o;if(s>=t){let a=s-t,f=Math.ceil(r.paddingLeft/o*a),l=a-f;r.paddingLeft-=f,r.paddingRight-=l,r.horizontalPadding=r.paddingLeft+r.paddingRight}r.paddingLeftString=r.paddingLeft?" ".repeat(r.paddingLeft):"",r.paddingRightString=r.paddingRight?" ".repeat(r.paddingRight):"";let i=t-r.horizontalPadding;r.width=Math.max(Math.min(r.width,i),u)}}var zt=()=>Object.assign([],{columns:0});function Fo(e,t){let r=[zt()],[n]=r;for(let o of e){let u=o.width+o.horizontalPadding;n.columns+u>t&&(n=zt(),r.push(n)),n.push(o),n.columns+=u}for(let o of r){let u=o.reduce((c,p)=>c+p.width+p.horizontalPadding,0),s=t-u;if(s===0)continue;let i=o.filter(c=>"autoOverflow"in c),a=i.filter(c=>c.autoOverflow>0),f=a.reduce((c,p)=>c+p.autoOverflow,0),l=Math.min(f,s);for(let c of a){let p=Math.floor(c.autoOverflow/f*l);c.width+=p,s-=p}let D=Math.floor(s/i.length);for(let c=0;c<i.length;c+=1){let p=i[c];c===i.length-1?p.width+=s:p.width+=D,s-=D}}return r}function Eo(e,t,r){let n=go(r,t);return Co(n,e),Fo(n,e)}B(),B(),B();var ke=10,Yt=(e=0)=>t=>`\x1B[${t+e}m`,Wt=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Vt=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`;function yo(){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[r,n]of Object.entries(t)){for(let[o,u]of Object.entries(n))t[o]={open:`\x1B[${u[0]}m`,close:`\x1B[${u[1]}m`},n[o]=t[o],e.set(u[0],u[1]);Object.defineProperty(t,r,{value:n,enumerable:!1})}return Object.defineProperty(t,"codes",{value:e,enumerable:!1}),t.color.close="\x1B[39m",t.bgColor.close="\x1B[49m",t.color.ansi=Yt(),t.color.ansi256=Wt(),t.color.ansi16m=Vt(),t.bgColor.ansi=Yt(ke),t.bgColor.ansi256=Wt(ke),t.bgColor.ansi16m=Vt(ke),Object.defineProperties(t,{rgbToAnsi256:{value:(r,n,o)=>r===n&&n===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(n/255*5)+Math.round(o/255*5),enumerable:!1},hexToRgb:{value:r=>{let n=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(r.toString(16));if(!n)return[0,0,0];let{colorString:o}=n.groups;o.length===3&&(o=o.split("").map(s=>s+s).join(""));let u=Number.parseInt(o,16);return[u>>16&255,u>>8&255,u&255]},enumerable:!1},hexToAnsi256:{value:r=>t.rgbToAnsi256(...t.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value:r=>{if(r<8)return 30+r;if(r<16)return 90+(r-8);let n,o,u;if(r>=232)n=((r-232)*10+8)/255,o=n,u=n;else{r-=16;let a=r%36;n=Math.floor(r/36)/5,o=Math.floor(a/6)/5,u=a%6/5}let s=Math.max(n,o,u)*2;if(s===0)return 30;let i=30+(Math.round(u)<<2|Math.round(o)<<1|Math.round(n));return s===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(r,n,o)=>t.ansi256ToAnsi(t.rgbToAnsi256(r,n,o)),enumerable:!1},hexToAnsi:{value:r=>t.ansi256ToAnsi(t.hexToAnsi256(r)),enumerable:!1}}),t}var wo=yo(),bo=wo,Fe=new Set(["\x1B","\x9B"]),Ao=39,je="\x07",Xt="[",vo="]",Jt="m",Ge=`${vo}8;;`,Zt=e=>`${Fe.values().next().value}${Xt}${e}${Jt}`,Qt=e=>`${Fe.values().next().value}${Ge}${e}${je}`,Bo=e=>e.split(" ").map(t=>H(t)),He=(e,t,r)=>{let n=[...t],o=!1,u=!1,s=H(Ht(e[e.length-1]));for(let[i,a]of n.entries()){let f=H(a);if(s+f<=r?e[e.length-1]+=a:(e.push(a),s=0),Fe.has(a)&&(o=!0,u=n.slice(i+1).join("").startsWith(Ge)),o){u?a===je&&(o=!1,u=!1):a===Jt&&(o=!1);continue}s+=f,s===r&&i<n.length-1&&(e.push(""),s=0)}!s&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},$o=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(H(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},xo=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,u,s=Bo(e),i=[""];for(let[f,l]of e.split(" ").entries()){r.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let D=H(i[i.length-1]);if(f!==0&&(D>=t&&(r.wordWrap===!1||r.trim===!1)&&(i.push(""),D=0),(D>0||r.trim===!1)&&(i[i.length-1]+=" ",D++)),r.hard&&s[f]>t){let c=t-D,p=1+Math.floor((s[f]-c-1)/t);Math.floor((s[f]-1)/t)<p&&i.push(""),He(i,l,t);continue}if(D+s[f]>t&&D>0&&s[f]>0){if(r.wordWrap===!1&&D<t){He(i,l,t);continue}i.push("")}if(D+s[f]>t&&r.wordWrap===!1){He(i,l,t);continue}i[i.length-1]+=l}r.trim!==!1&&(i=i.map(f=>$o(f)));let a=[...i.join(`
4
+ `)];for(let[f,l]of a.entries()){if(n+=l,Fe.has(l)){let{groups:c}=new RegExp(`(?:\\${Xt}(?<code>\\d+)m|\\${Ge}(?<uri>.*)${je})`).exec(a.slice(f).join(""))||{groups:{}};if(c.code!==void 0){let p=Number.parseFloat(c.code);o=p===Ao?void 0:p}else c.uri!==void 0&&(u=c.uri.length===0?void 0:c.uri)}let D=bo.codes.get(Number(o));a[f+1]===`
5
+ `?(u&&(n+=Qt("")),o&&D&&(n+=Zt(D))):l===`
6
+ `&&(o&&D&&(n+=Zt(o)),u&&(n+=Qt(u)))}return n};function Oo(e,t,r){return String(e).normalize().replace(/\r\n/g,`
7
7
  `).split(`
8
- `).map(n=>Bu(n,t,r)).join(`
9
- `)}var Qt=e=>Array.from({length:e}).fill("");function xu(e,t){let r=[],n=0;for(let u of e){let o=0,s=u.map(a=>{var f;let l=(f=t[n])!=null?f:"";n+=1,a.preprocess&&(l=a.preprocess(l)),Ht(l)>a.width&&(l=$u(l,a.width,{hard:!0}));let D=l.split(`
10
- `);if(a.postprocess){let{postprocess:c}=a;D=D.map((p,d)=>c.call(a,p,d))}return a.paddingTop&&D.unshift(...Qt(a.paddingTop)),a.paddingBottom&&D.push(...Qt(a.paddingBottom)),D.length>o&&(o=D.length),ke(Ce({},a),{lines:D})}),i=[];for(let a=0;a<o;a+=1){let f=s.map(l=>{var D;let c=(D=l.lines[a])!=null?D:"",p=Number.isFinite(l.width)?" ".repeat(l.width-R(c)):"",d=l.paddingLeftString;return l.align==="right"&&(d+=p),d+=c,l.align==="left"&&(d+=p),d+l.paddingRightString}).join("");i.push(f)}r.push(i.join(`
8
+ `).map(n=>xo(n,t,r)).join(`
9
+ `)}var er=e=>Array.from({length:e}).fill("");function Io(e,t){let r=[],n=0;for(let o of e){let u=0,s=o.map(a=>{var f;let l=(f=t[n])!=null?f:"";n+=1,a.preprocess&&(l=a.preprocess(l)),Ut(l)>a.width&&(l=Oo(l,a.width,{hard:!0}));let D=l.split(`
10
+ `);if(a.postprocess){let{postprocess:c}=a;D=D.map((p,d)=>c.call(a,p,d))}return a.paddingTop&&D.unshift(...er(a.paddingTop)),a.paddingBottom&&D.push(...er(a.paddingBottom)),D.length>u&&(u=D.length),Le(Ce({},a),{lines:D})}),i=[];for(let a=0;a<u;a+=1){let f=s.map(l=>{var D;let c=(D=l.lines[a])!=null?D:"",p=Number.isFinite(l.width)?" ".repeat(l.width-H(c)):"",d=l.paddingLeftString;return l.align==="right"&&(d+=p),d+=c,l.align==="left"&&(d+=p),d+l.paddingRightString}).join("");i.push(f)}r.push(i.join(`
11
11
  `))}return r.join(`
12
- `)}function Ou(e,t){if(!e||e.length===0)return"";let r=du(e),n=r.length;if(n===0)return"";let{stdoutColumns:u,columns:o}=cu(t);if(o.length>n)throw new Error(`${o.length} columns defined, but only ${n} columns found`);let s=Cu(u,o,r);return e.map(i=>xu(s,i)).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(r=>{let[n,u]=r.split(" ");Su(n);let o=Number.parseInt(u,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${u}`);let s=e[r];return{operator:n,breakpoint:o,value:s}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:u,breakpoint:o})=>u==="="&&r===o||u===">"&&r>o||u==="<"&&r<o||u===">="&&r>=o||u==="<="&&r<=o))==null?void 0:n.value}}const Mu=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.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((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],u="alias"in n;return u&&(t=!0),{name:r,flag:n,flagFormatted:`--${_u(r)}`,aliasesEnabled:t,aliasFormatted:u?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:Tu}}}const er=e=>!e||(e.version??(e.help?e.help.version:void 0)),tr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function Ru(e){const t=[];e.name&&t.push(tr(e));const r=er(e)??("parent"in e&&er(e.parent));if(r&&t.push(`v${r}`),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
- `):t.usage}}:void 0;if(e.name){const r=[],n=[tr(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:u}=e,o=u.indexOf("--"),s=o>-1&&u.slice(o+1).some(i=>i.startsWith("<"));n.push(u.map(i=>i!=="--"?i:s?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
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:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
- `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}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 Ku=e=>[Ru,ku,Lu,ju,Gu,Hu,Uu].map(t=>t(e)).filter(Boolean),qu=Pe.WriteStream.prototype.hasColors();class zu{text(t){return t}bold(t){return qu?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
12
+ `)}function Mo(e,t){if(!e||e.length===0)return"";let r=ho(e),n=r.length;if(n===0)return"";let{stdoutColumns:o,columns:u}=lo(t);if(u.length>n)throw new Error(`${u.length} columns defined, but only ${n} columns found`);let s=Eo(o,u,r);return e.map(i=>Io(s,i)).join(`
13
+ `)}B();var So=["<",">","=",">=","<="];function Po(e){if(!So.includes(e))throw new TypeError(`Invalid breakpoint operator: ${e}`)}function To(e){let t=Object.keys(e).map(r=>{let[n,o]=r.split(" ");Po(n);let u=Number.parseInt(o,10);if(Number.isNaN(u))throw new TypeError(`Invalid breakpoint value: ${o}`);let s=e[r];return{operator:n,breakpoint:u,value:s}}).sort((r,n)=>n.breakpoint-r.breakpoint);return r=>{var n;return(n=t.find(({operator:o,breakpoint:u})=>o==="="&&r===u||o===">"&&r>u||o==="<"&&r<u||o===">="&&r>=u||o==="<="&&r<=u))==null?void 0:n.value}}const _o=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),No=e=>e.replace(/\B([A-Z])/g,"-$1").toLowerCase(),Ro={"> 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 Lo(e){let t=!1;return{type:"table",data:{tableData:Object.keys(e).sort((r,n)=>r.localeCompare(n)).map(r=>{const n=e[r],o="alias"in n;return o&&(t=!0),{name:r,flag:n,flagFormatted:`--${No(r)}`,aliasesEnabled:t,aliasFormatted:o?`-${n.alias}`:void 0}}).map(r=>(r.aliasesEnabled=t,[{type:"flagName",data:r},{type:"flagDescription",data:r}])),tableBreakpoints:Ro}}}const tr=e=>!e||(e.version??(e.help?e.help.version:void 0)),rr=e=>{const t="parent"in e&&e.parent?.name;return(t?`${t} `:"")+e.name};function ko(e){const t=[];e.name&&t.push(rr(e));const r=tr(e)??("parent"in e&&tr(e.parent));if(r&&t.push(`v${r}`),t.length!==0)return{id:"name",type:"text",data:`${t.join(" ")}
14
+ `}}function jo(e){const{help:t}=e;if(!(!t||!t.description))return{id:"description",type:"text",data:`${t.description}
15
+ `}}function Go(e){const t=e.help||{};if("usage"in t)return t.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(t.usage)?t.usage.join(`
16
+ `):t.usage}}:void 0;if(e.name){const r=[],n=[rr(e)];if(e.flags&&Object.keys(e.flags).length>0&&n.push("[flags...]"),e.parameters&&e.parameters.length>0){const{parameters:o}=e,u=o.indexOf("--"),s=u>-1&&o.slice(u+1).some(i=>i.startsWith("<"));n.push(o.map(i=>i!=="--"?i:s?"--":"[--]").join(" "))}if(n.length>1&&r.push(n.join(" ")),"commands"in e&&e.commands?.length&&r.push(`${e.name} <command>`),r.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:r.join(`
17
+ `)}}}}function Ho(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 Uo(e){if(!(!e.flags||Object.keys(e.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:Lo(e.flags),indentBody:0}}}function Ko(e){const{help:t}=e;if(!t||!t.examples||t.examples.length===0)return;let{examples:r}=t;if(Array.isArray(r)&&(r=r.join(`
18
+ `)),r)return{id:"examples",type:"section",data:{title:"Examples:",body:r}}}function qo(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 zo=e=>[ko,jo,Go,Ho,Uo,Ko,qo].map(t=>t(e)).filter(Boolean),Yo=Se.WriteStream.prototype.hasColors();class Wo{text(t){return t}bold(t){return Yo?`\x1B[1m${t}\x1B[22m`:t.toLocaleUpperCase()}indentText({text:t,spaces:r}){return t.replace(/^/gm," ".repeat(r))}heading(t){return this.bold(t)}section({title:t,body:r,indentBody:n=2}){return`${(t?`${this.heading(t)}
19
19
  `:"")+(r?this.indentText({text:this.render(r),spaces:n}):"")}
20
- `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return Ou(t.map(u=>u.map(o=>this.render(o))),n?Pu(n):r)}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:r,flagFormatted:n,aliasesEnabled:u,aliasFormatted:o}=t;let s="";if(o?s+=`${o}, `:u&&(s+=" "),s+=n,"placeholder"in r&&typeof r.placeholder=="string")s+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(s+=`${this.flagOperator(t)}${i}`)}return s}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
- `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ue=/^[\w.-]+$/,{stringify:I}=JSON,Yu=/[|\\{}()[\]^$+*?.]/;function Ke(e){const t=[];let r,n;for(const u of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${I(n)} must be last`);const o=u[0],s=u[u.length-1];let i;if(o==="<"&&s===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${I(u)} cannot come after optional parameter ${I(r)}`);if(o==="["&&s==="]"&&(i=!1,r=u),i===void 0)throw new Error(`Invalid parameter: ${I(u)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=u.slice(1,-1);const f=a.slice(-3)==="...";f&&(n=u,a=a.slice(0,-3));const l=a.match(Yu);if(l)throw new Error(`Invalid parameter: ${I(u)}. Invalid character found ${I(l[0])}`);t.push({name:a,required:i,spread:f})}return t}function qe(e,t,r,n){for(let u=0;u<t.length;u+=1){const{name:o,required:s,spread:i}=t[u],a=Mu(o);if(a in e)throw new Error(`Invalid parameter: ${I(o)} is used more than once.`);const f=i?r.slice(u):r[u];if(i&&(u=t.length),s&&(!f||i&&f.length===0))return console.error(`Error: Missing required parameter ${I(o)}
22
- `),n(),process.exit(1);e[a]=f}}function Wu(e){return e===void 0||e!==!1}function rr(e,t,r,n){const u={...t.flags},o=t.version;o&&(u.version={type:Boolean,description:"Show version"});const{help:s}=t,i=Wu(s);i&&!("help"in u)&&(u.help={type:Boolean,alias:"h",description:"Show help"});const a=Xn(u,n,{ignore:t.ignoreArgv}),f=()=>{console.log(t.version)};if(o&&a.flags.version===!0)return f(),process.exit(0);const l=new zu,D=i&&s?.render?s.render:d=>l.render(d),c=d=>{const m=Ku({...t,...d?{help:d}:{},flags:u});console.log(D(m,l))};if(i&&a.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=a._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const $=a._["--"];m=m.slice(0,-$.length||void 0),qe(w,Ke(d),m,c),qe(w,Ke(C),$,c)}else qe(w,Ke(d),m,c);Object.assign(a._,w)}const p={...a,showVersion:f,showHelp:c};return typeof r=="function"&&r(p),{command:e,...p}}function Vu(e,t){const r=new Map;for(const n of t){const u=[n.options.name],{alias:o}=n.options;o&&(Array.isArray(o)?u.push(...o):u.push(o));for(const s of u){if(r.has(s))throw new Error(`Duplicate command name found: ${I(s)}`);r.set(s,n)}}return r.get(e)}function Xu(e,t,r=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: ${I(e.name)}`);const n=r[0];if(e.commands&&Ue.test(n)){const u=Vu(n,e.commands);if(u)return rr(u.options.name,{...u.options,parent:e},u.callback,r.slice(1))}return rr(void 0,e,t,r)}function nr(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ue.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var Ju=Dn(import.meta.url),b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function W(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var V={exports:{}},ze,ur;function Zu(){if(ur)return ze;ur=1,ze=n,n.sync=u;var e=Me;function t(o,s){var i=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var a=0;a<i.length;a++){var f=i[a].toLowerCase();if(f&&o.substr(-f.length).toLowerCase()===f)return!0}return!1}function r(o,s,i){return!o.isSymbolicLink()&&!o.isFile()?!1:t(s,i)}function n(o,s,i){e.stat(o,function(a,f){i(a,a?!1:r(f,o,s))})}function u(o,s){return r(e.statSync(o),o,s)}return ze}var Ye,or;function Qu(){if(or)return Ye;or=1,Ye=t,t.sync=r;var e=Me;function t(o,s,i){e.stat(o,function(a,f){i(a,a?!1:n(f,s))})}function r(o,s){return n(e.statSync(o),s)}function n(o,s){return o.isFile()&&u(o,s)}function u(o,s){var i=o.mode,a=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),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=i&d||i&p&&f===D||i&c&&a===l||i&m&&l===0;return h}return Ye}var Ee;process.platform==="win32"||b.TESTING_WINDOWS?Ee=Zu():Ee=Qu();var eo=We;We.sync=to;function We(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,u){We(e,t||{},function(o,s){o?u(o):n(s)})})}Ee(e,t||{},function(n,u){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,u=!1),r(n,u)})}function to(e,t){try{return Ee.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const X=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",sr=U,ro=X?";":":",ir=eo,ar=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),Dr=(e,t)=>{const r=t.colon||ro,n=e.match(/\//)||X&&e.match(/\\/)?[""]:[...X?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],u=X?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=X?u.split(r):[""];return X&&e.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:u}},cr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:u,pathExtExe:o}=Dr(e,t),s=[],i=f=>new Promise((l,D)=>{if(f===n.length)return t.all&&s.length?l(s):D(ar(e));const c=n[f],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=sr.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;l(a(m,f,0))}),a=(f,l,D)=>new Promise((c,p)=>{if(D===u.length)return c(i(l+1));const d=u[D];ir(f+d,{pathExt:o},(m,h)=>{if(!m&&h)if(t.all)s.push(f+d);else return c(f+d);return c(a(f,l,D+1))})});return r?i(0).then(f=>r(null,f),r):i(0)},no=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:u}=Dr(e,t),o=[];for(let s=0;s<r.length;s++){const i=r[s],a=/^".*"$/.test(i)?i.slice(1,-1):i,f=sr.join(a,e),l=!a&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;for(let D=0;D<n.length;D++){const c=l+n[D];try{if(ir.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 ar(e)};var uo=cr;cr.sync=no;var Ve={exports:{}};const lr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Ve.exports=lr,Ve.exports.default=lr;var oo=Ve.exports;const fr=U,so=uo,io=oo;function pr(e,t){const r=e.options.env||process.env,n=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:r[io({env:r})],pathExt:t?fr.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return s&&(s=fr.resolve(u?e.options.cwd:"",s)),s}function ao(e){return pr(e)||pr(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[r,n]=t[0].replace(/#! ?/,"").split(" "),u=r.split("/").pop();return u==="env"?n:n?`${u} ${n}`:u};const Ze=Me,ho=mo;function go(e){const r=Buffer.alloc(150);let n;try{n=Ze.openSync(e,"r"),Ze.readSync(n,r,0,150,0),Ze.closeSync(n)}catch{}return ho(r.toString())}var Co=go;const Fo=U,dr=Do,mr=Xe,Eo=Co,yo=process.platform==="win32",wo=/\.(?:com|exe)$/i,bo=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function Ao(e){e.file=dr(e);const t=e.file&&Eo(e.file);return t?(e.args.unshift(e.file),e.command=t,dr(e)):e.file}function vo(e){if(!yo)return e;const t=Ao(e),r=!wo.test(t);if(e.options.forceShell||r){const n=bo.test(t);e.command=Fo.normalize(e.command),e.command=mr.command(e.command),e.args=e.args.map(o=>mr.argument(o,n));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,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:vo(n)}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 r=e.emit;e.emit=function(n,u){if(n==="exit"){const o=hr(u,t);if(o)return r.call(e,"error",o)}return r.apply(e,arguments)}}function hr(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:hr,verifyENOENTSync:Oo,notFoundError:et};const gr=ln,tt=$o,rt=Io;function Cr(e,t,r){const n=tt(e,t,r),u=gr.spawn(n.command,n.args,n.options);return rt.hookChildProcess(u,n),u}function So(e,t,r){const n=tt(e,t,r),u=gr.spawnSync(n.command,n.args,n.options);return u.error=u.error||rt.verifyENOENTSync(u.status,n),u}V.exports=Cr,V.exports.spawn=Cr,V.exports.sync=So,V.exports._parse=tt,V.exports._enoent=rt;var Po=V.exports,Mo=W(Po);function _o(e){const t=typeof e=="string"?`
20
+ `}table({tableData:t,tableOptions:r,tableBreakpoints:n}){return Mo(t.map(o=>o.map(u=>this.render(u))),n?To(n):r)}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:r,flagFormatted:n,aliasesEnabled:o,aliasFormatted:u}=t;let s="";if(u?s+=`${u}, `:o&&(s+=" "),s+=n,"placeholder"in r&&typeof r.placeholder=="string")s+=`${this.flagOperator(t)}${r.placeholder}`;else{const i=this.flagParameter("type"in r?r.type:r);i&&(s+=`${this.flagOperator(t)}${i}`)}return s}flagDefault(t){return JSON.stringify(t)}flagDescription({flag:t}){let r="description"in t?t.description??"":"";if("default"in t){let{default:n}=t;typeof n=="function"&&(n=n()),n&&(r+=` (default: ${this.flagDefault(n)})`)}return r}render(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(r=>this.render(r)).join(`
21
+ `);if("type"in t&&this[t.type]){const r=this[t.type];if(typeof r=="function")return r.call(this,t.data)}throw new Error(`Invalid node type: ${JSON.stringify(t)}`)}}const Ue=/^[\w.-]+$/,{stringify:I}=JSON,Vo=/[|\\{}()[\]^$+*?.]/;function Ke(e){const t=[];let r,n;for(const o of e){if(n)throw new Error(`Invalid parameter: Spread parameter ${I(n)} must be last`);const u=o[0],s=o[o.length-1];let i;if(u==="<"&&s===">"&&(i=!0,r))throw new Error(`Invalid parameter: Required parameter ${I(o)} cannot come after optional parameter ${I(r)}`);if(u==="["&&s==="]"&&(i=!1,r=o),i===void 0)throw new Error(`Invalid parameter: ${I(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=o.slice(1,-1);const f=a.slice(-3)==="...";f&&(n=o,a=a.slice(0,-3));const l=a.match(Vo);if(l)throw new Error(`Invalid parameter: ${I(o)}. Invalid character found ${I(l[0])}`);t.push({name:a,required:i,spread:f})}return t}function qe(e,t,r,n){for(let o=0;o<t.length;o+=1){const{name:u,required:s,spread:i}=t[o],a=_o(u);if(a in e)throw new Error(`Invalid parameter: ${I(u)} is used more than once.`);const f=i?r.slice(o):r[o];if(i&&(o=t.length),s&&(!f||i&&f.length===0))return console.error(`Error: Missing required parameter ${I(u)}
22
+ `),n(),process.exit(1);e[a]=f}}function Xo(e){return e===void 0||e!==!1}function nr(e,t,r,n){const o={...t.flags},u=t.version;u&&(o.version={type:Boolean,description:"Show version"});const{help:s}=t,i=Xo(s);i&&!("help"in o)&&(o.help={type:Boolean,alias:"h",description:"Show help"});const a=Jn(o,n,{ignore:t.ignoreArgv}),f=()=>{console.log(t.version)};if(u&&a.flags.version===!0)return f(),process.exit(0);const l=new Wo,D=i&&s?.render?s.render:d=>l.render(d),c=d=>{const m=zo({...t,...d?{help:d}:{},flags:o});console.log(D(m,l))};if(i&&a.flags.help===!0)return c(),process.exit(0);if(t.parameters){let{parameters:d}=t,m=a._;const h=d.indexOf("--"),C=d.slice(h+1),w=Object.create(null);if(h>-1&&C.length>0){d=d.slice(0,h);const $=a._["--"];m=m.slice(0,-$.length||void 0),qe(w,Ke(d),m,c),qe(w,Ke(C),$,c)}else qe(w,Ke(d),m,c);Object.assign(a._,w)}const p={...a,showVersion:f,showHelp:c};return typeof r=="function"&&r(p),{command:e,...p}}function Jo(e,t){const r=new Map;for(const n of t){const o=[n.options.name],{alias:u}=n.options;u&&(Array.isArray(u)?o.push(...u):o.push(u));for(const s of o){if(r.has(s))throw new Error(`Duplicate command name found: ${I(s)}`);r.set(s,n)}}return r.get(e)}function Zo(e,t,r=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: ${I(e.name)}`);const n=r[0];if(e.commands&&Ue.test(n)){const o=Jo(n,e.commands);if(o)return nr(o.options.name,{...o.options,parent:e},o.callback,r.slice(1))}return nr(void 0,e,t,r)}function or(e,t){if(!e)throw new Error("Command options are required");const{name:r}=e;if(e.name===void 0)throw new Error("Command name is required");if(!Ue.test(r))throw new Error(`Invalid command name ${JSON.stringify(r)}. Command names must be one word.`);return{options:e,callback:t}}var Qo=cn(import.meta.url),b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Z={exports:{}},ze,ur;function eu(){if(ur)return ze;ur=1,ze=n,n.sync=o;var e=Pe;function t(u,s){var i=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!i||(i=i.split(";"),i.indexOf("")!==-1))return!0;for(var a=0;a<i.length;a++){var f=i[a].toLowerCase();if(f&&u.substr(-f.length).toLowerCase()===f)return!0}return!1}function r(u,s,i){return!u.isSymbolicLink()&&!u.isFile()?!1:t(s,i)}function n(u,s,i){e.stat(u,function(a,f){i(a,a?!1:r(f,u,s))})}function o(u,s){return r(e.statSync(u),u,s)}return ze}var Ye,sr;function tu(){if(sr)return Ye;sr=1,Ye=t,t.sync=r;var e=Pe;function t(u,s,i){e.stat(u,function(a,f){i(a,a?!1:n(f,s))})}function r(u,s){return n(e.statSync(u),s)}function n(u,s){return u.isFile()&&o(u,s)}function o(u,s){var i=u.mode,a=u.uid,f=u.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),p=parseInt("010",8),d=parseInt("001",8),m=c|p,h=i&d||i&p&&f===D||i&c&&a===l||i&m&&l===0;return h}return Ye}var Ee;process.platform==="win32"||b.TESTING_WINDOWS?Ee=eu():Ee=tu();var ru=We;We.sync=nu;function We(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){We(e,t||{},function(u,s){u?o(u):n(s)})})}Ee(e,t||{},function(n,o){n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function nu(e,t){try{return Ee.sync(e,t||{})}catch(r){if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}const Q=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",ir=X,ou=Q?";":":",ar=ru,Dr=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),cr=(e,t)=>{const r=t.colon||ou,n=e.match(/\//)||Q&&e.match(/\\/)?[""]:[...Q?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=Q?t.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",u=Q?o.split(r):[""];return Q&&e.indexOf(".")!==-1&&u[0]!==""&&u.unshift(""),{pathEnv:n,pathExt:u,pathExtExe:o}},lr=(e,t,r)=>{typeof t=="function"&&(r=t,t={}),t||(t={});const{pathEnv:n,pathExt:o,pathExtExe:u}=cr(e,t),s=[],i=f=>new Promise((l,D)=>{if(f===n.length)return t.all&&s.length?l(s):D(Dr(e));const c=n[f],p=/^".*"$/.test(c)?c.slice(1,-1):c,d=ir.join(p,e),m=!p&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;l(a(m,f,0))}),a=(f,l,D)=>new Promise((c,p)=>{if(D===o.length)return c(i(l+1));const d=o[D];ar(f+d,{pathExt:u},(m,h)=>{if(!m&&h)if(t.all)s.push(f+d);else return c(f+d);return c(a(f,l,D+1))})});return r?i(0).then(f=>r(null,f),r):i(0)},uu=(e,t)=>{t=t||{};const{pathEnv:r,pathExt:n,pathExtExe:o}=cr(e,t),u=[];for(let s=0;s<r.length;s++){const i=r[s],a=/^".*"$/.test(i)?i.slice(1,-1):i,f=ir.join(a,e),l=!a&&/^\.[\\\/]/.test(e)?e.slice(0,2)+f:f;for(let D=0;D<n.length;D++){const c=l+n[D];try{if(ar.sync(c,{pathExt:o}))if(t.all)u.push(c);else return c}catch{}}}if(t.all&&u.length)return u;if(t.nothrow)return null;throw Dr(e)};var su=lr;lr.sync=uu;var Ve={exports:{}};const fr=(e={})=>{const t=e.env||process.env;return(e.platform||process.platform)!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Ve.exports=fr,Ve.exports.default=fr;var iu=Ve.exports;const pr=X,au=su,Du=iu;function dr(e,t){const r=e.options.env||process.env,n=process.cwd(),o=e.options.cwd!=null,u=o&&process.chdir!==void 0&&!process.chdir.disabled;if(u)try{process.chdir(e.options.cwd)}catch{}let s;try{s=au.sync(e.command,{path:r[Du({env:r})],pathExt:t?pr.delimiter:void 0})}catch{}finally{u&&process.chdir(n)}return s&&(s=pr.resolve(o?e.options.cwd:"",s)),s}function cu(e){return dr(e)||dr(e,!0)}var lu=cu,Xe={};const Je=/([()\][%!^"`<>&|;, *?])/g;function fu(e){return e=e.replace(Je,"^$1"),e}function pu(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=fu,Xe.argument=pu;var du=/^#!(.*)/;const mu=du;var hu=(e="")=>{const t=e.match(mu);if(!t)return null;const[r,n]=t[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o};const Ze=Pe,gu=hu;function Cu(e){const r=Buffer.alloc(150);let n;try{n=Ze.openSync(e,"r"),Ze.readSync(n,r,0,150,0),Ze.closeSync(n)}catch{}return gu(r.toString())}var Fu=Cu;const Eu=X,mr=lu,hr=Xe,yu=Fu,wu=process.platform==="win32",bu=/\.(?:com|exe)$/i,Au=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function vu(e){e.file=mr(e);const t=e.file&&yu(e.file);return t?(e.args.unshift(e.file),e.command=t,mr(e)):e.file}function Bu(e){if(!wu)return e;const t=vu(e),r=!bu.test(t);if(e.options.forceShell||r){const n=Au.test(t);e.command=Eu.normalize(e.command),e.command=hr.command(e.command),e.args=e.args.map(u=>hr.argument(u,n));const o=[e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.windowsVerbatimArguments=!0}return e}function $u(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign({},r);const n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:Bu(n)}var xu=$u;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 Ou(e,t){if(!Qe)return;const r=e.emit;e.emit=function(n,o){if(n==="exit"){const u=gr(o,t);if(u)return r.call(e,"error",u)}return r.apply(e,arguments)}}function gr(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawn"):null}function Iu(e,t){return Qe&&e===1&&!t.file?et(t.original,"spawnSync"):null}var Mu={hookChildProcess:Ou,verifyENOENT:gr,verifyENOENTSync:Iu,notFoundError:et};const Cr=fn,tt=xu,rt=Mu;function Fr(e,t,r){const n=tt(e,t,r),o=Cr.spawn(n.command,n.args,n.options);return rt.hookChildProcess(o,n),o}function Su(e,t,r){const n=tt(e,t,r),o=Cr.spawnSync(n.command,n.args,n.options);return o.error=o.error||rt.verifyENOENTSync(o.status,n),o}Z.exports=Fr,Z.exports.spawn=Fr,Z.exports.sync=Su,Z.exports._parse=tt,Z.exports._enoent=rt;var Pu=Z.exports,Tu=J(Pu);function _u(e){const t=typeof e=="string"?`
23
23
  `:`
24
- `.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Fr(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}function To(e={}){const{cwd:t=_.cwd(),path:r=_.env[Fr()],execPath:n=_.execPath}=e;let u;const o=t instanceof URL?fn.fileURLToPath(t):t;let s=H.resolve(o);const i=[];for(;u!==s;)i.push(H.join(s,"node_modules/.bin")),u=s,s=H.resolve(s,"..");return i.push(H.resolve(o,n,"..")),[...i,r].join(H.delimiter)}function No({env:e=_.env,...t}={}){e={...e};const r=Fr({env:e});return t.path=e[r],e[r]=To(t),e}const Ro=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const u=Object.getOwnPropertyDescriptor(e,r),o=Object.getOwnPropertyDescriptor(t,r);!ko(u,o)&&n||Object.defineProperty(e,r,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 r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},jo=(e,t)=>`/* Wrapped ${e}*/
25
- ${t}`,Go=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Ho=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Uo=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,u=jo.bind(null,n,t.toString());Object.defineProperty(u,"name",Ho),Object.defineProperty(e,"toString",{...Go,value:u})};function Ko(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const u of Reflect.ownKeys(t))Ro(e,t,u,r);return Lo(e,t),Uo(e,t,n),e}const ye=new WeakMap,Er=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const u=e.displayName||e.name||"<anonymous>",o=function(...s){if(ye.set(o,++n),n===1)r=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${u}\` can only be called once`);return r};return Ko(o,e),ye.set(o,n),o};Er.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 qo=()=>{const e=wr-yr+1;return Array.from({length:e},zo)},zo=(e,t)=>({name:`SIGRT${t+1}`,number:yr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),yr=34,wr=64,Yo=[{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"}],br=()=>{const e=qo();return[...Yo,...e].map(Wo)},Wo=({name:e,number:t,description:r,action:n,forced:u=!1,standard:o})=>{const{signals:{[e]:s}}=St,i=s!==void 0;return{name:e,number:i?s:t,description:r,supported:i,action:n,forced:u,standard:o}},Vo=()=>{const e=br();return Object.fromEntries(e.map(Xo))},Xo=({name:e,number:t,description:r,supported:n,action:u,forced:o,standard:s})=>[e,{name:e,number:t,description:r,supported:n,action:u,forced:o,standard:s}],Jo=Vo(),Zo=()=>{const e=br(),t=wr+1,r=Array.from({length:t},(n,u)=>Qo(u,e));return Object.assign({},...r)},Qo=(e,t)=>{const r=es(e,t);if(r===void 0)return{};const{name:n,description:u,supported:o,action:s,forced:i,standard:a}=r;return{[e]:{name:n,number:e,description:u,supported:o,action:s,forced:i,standard:a}}},es=(e,t)=>{const r=t.find(({name:n})=>St.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};Zo();const ts=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:u,exitCode:o,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${u})`:o!==void 0?`failed with exit code ${o}`:"failed",Ar=({stdout:e,stderr:t,all:r,error:n,signal:u,exitCode:o,command:s,escapedCommand:i,timedOut:a,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,p=n&&n.code,m=`Command ${ts({timedOut:a,timeout:D,errorCode:p,signal:u,signalDescription:c,exitCode:o,isCanceled:f})}: ${s}`,h=Object.prototype.toString.call(n)==="[object Error]",C=h?`${m}
24
+ `.charCodeAt(),r=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,-1)),e[e.length-1]===r&&(e=e.slice(0,-1)),e}function Er(e={}){const{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}function Nu(e={}){const{cwd:t=T.cwd(),path:r=T.env[Er()],execPath:n=T.execPath}=e;let o;const u=t instanceof URL?pn.fileURLToPath(t):t;let s=V.resolve(u);const i=[];for(;o!==s;)i.push(V.join(s,"node_modules/.bin")),o=s,s=V.resolve(s,"..");return i.push(V.resolve(u,n,"..")),[...i,r].join(V.delimiter)}function Ru({env:e=T.env,...t}={}){e={...e};const r=Er({env:e});return t.path=e[r],e[r]=Nu(t),e}const Lu=(e,t,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;const o=Object.getOwnPropertyDescriptor(e,r),u=Object.getOwnPropertyDescriptor(t,r);!ku(o,u)&&n||Object.defineProperty(e,r,u)},ku=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)},ju=(e,t)=>{const r=Object.getPrototypeOf(t);r!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,r)},Gu=(e,t)=>`/* Wrapped ${e}*/
25
+ ${t}`,Hu=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Uu=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Ku=(e,t,r)=>{const n=r===""?"":`with ${r.trim()}() `,o=Gu.bind(null,n,t.toString());Object.defineProperty(o,"name",Uu),Object.defineProperty(e,"toString",{...Hu,value:o})};function qu(e,t,{ignoreNonConfigurable:r=!1}={}){const{name:n}=e;for(const o of Reflect.ownKeys(t))Lu(e,t,o,r);return ju(e,t),Ku(e,t,n),e}const ye=new WeakMap,yr=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let r,n=0;const o=e.displayName||e.name||"<anonymous>",u=function(...s){if(ye.set(u,++n),n===1)r=e.apply(this,s),e=null;else if(t.throw===!0)throw new Error(`Function \`${o}\` can only be called once`);return r};return qu(u,e),ye.set(u,n),u};yr.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 zu=()=>{const e=br-wr+1;return Array.from({length:e},Yu)},Yu=(e,t)=>({name:`SIGRT${t+1}`,number:wr+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),wr=34,br=64,Wu=[{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"}],Ar=()=>{const e=zu();return[...Wu,...e].map(Vu)},Vu=({name:e,number:t,description:r,action:n,forced:o=!1,standard:u})=>{const{signals:{[e]:s}}=St,i=s!==void 0;return{name:e,number:i?s:t,description:r,supported:i,action:n,forced:o,standard:u}},Xu=()=>{const e=Ar();return Object.fromEntries(e.map(Ju))},Ju=({name:e,number:t,description:r,supported:n,action:o,forced:u,standard:s})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:u,standard:s}],Zu=Xu(),Qu=()=>{const e=Ar(),t=br+1,r=Array.from({length:t},(n,o)=>es(o,e));return Object.assign({},...r)},es=(e,t)=>{const r=ts(e,t);if(r===void 0)return{};const{name:n,description:o,supported:u,action:s,forced:i,standard:a}=r;return{[e]:{name:n,number:e,description:o,supported:u,action:s,forced:i,standard:a}}},ts=(e,t)=>{const r=t.find(({name:n})=>St.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)};Qu();const rs=({timedOut:e,timeout:t,errorCode:r,signal:n,signalDescription:o,exitCode:u,isCanceled:s})=>e?`timed out after ${t} milliseconds`:s?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${o})`:u!==void 0?`failed with exit code ${u}`:"failed",vr=({stdout:e,stderr:t,all:r,error:n,signal:o,exitCode:u,command:s,escapedCommand:i,timedOut:a,isCanceled:f,killed:l,parsed:{options:{timeout:D}}})=>{u=u===null?void 0:u,o=o===null?void 0:o;const c=o===void 0?void 0:Zu[o].description,p=n&&n.code,m=`Command ${rs({timedOut:a,timeout:D,errorCode:p,signal:o,signalDescription:c,exitCode:u,isCanceled:f})}: ${s}`,h=Object.prototype.toString.call(n)==="[object Error]",C=h?`${m}
26
26
  ${n.message}`:m,w=[C,t,e].filter(Boolean).join(`
27
- `);return h?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=C,n.command=s,n.escapedCommand=i,n.exitCode=o,n.signal=u,n.signalDescription=c,n.stdout=e,n.stderr=t,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!a,n.isCanceled=f,n.killed=l&&!a,n},we=["stdin","stdout","stderr"],rs=e=>we.some(t=>e[t]!==void 0),ns=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return we.map(n=>e[n]);if(rs(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${we.map(n=>`\`${n}\``).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 r=Math.max(t.length,we.length);return Array.from({length:r},(n,u)=>t[u])};var J={exports:{}},be={exports:{}};be.exports;var vr;function us(){return vr||(vr=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 k=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(!k(F))J.exports=function(){return function(){}};else{var os=Pt,ie=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),J.exports=function(e,t){if(!k(b.process))return function(){};os.equal(typeof e,"function","a callback must be provided for exit handler"),ae===!1&&Br();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&nt()};return v.on(r,e),n};var nt=function(){!ae||!k(b.process)||(ae=!1,ie.forEach(function(t){try{F.removeListener(t,ut[t])}catch{}}),F.emit=ot,F.reallyExit=$r,v.count-=1)};J.exports.unload=nt;var Z=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},ut={};ie.forEach(function(e){ut[e]=function(){if(k(b.process)){var r=F.listeners(e);r.length===v.count&&(nt(),Z("exit",null,e),Z("afterexit",null,e),ss&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),J.exports.signals=function(){return ie};var ae=!1,Br=function(){ae||!k(b.process)||(ae=!0,v.count+=1,ie=ie.filter(function(t){try{return F.on(t,ut[t]),!0}catch{return!1}}),F.emit=as,F.reallyExit=is)};J.exports.load=Br;var $r=F.reallyExit,is=function(t){k(b.process)&&(F.exitCode=t||0,Z("exit",F.exitCode,null),Z("afterexit",F.exitCode,null),$r.call(F,F.exitCode))},ot=F.emit,as=function(t,r){if(t==="exit"&&k(b.process)){r!==void 0&&(F.exitCode=r);var n=ot.apply(this,arguments);return Z("exit",F.exitCode,null),Z("afterexit",F.exitCode,null),n}else return ot.apply(this,arguments)}}var Ds=J.exports,cs=W(Ds);const ls=1e3*5,fs=(e,t="SIGTERM",r={})=>{const n=e(t);return ps(e,t,r,n),n},ps=(e,t,r,n)=>{if(!ds(t,r,n))return;const u=hs(r),o=setTimeout(()=>{e("SIGKILL")},u);o.unref&&o.unref()},ds=(e,{forceKillAfterTimeout:t},r)=>ms(e)&&t!==!1&&r,ms=e=>e===pn.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,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Fs=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let u;const o=new Promise((i,a)=>{u=setTimeout(()=>{Cs(e,r,a)},t)}),s=n.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:r},n)=>{if(!t||r)return n;const u=cs(()=>{e.kill()});return n.finally(()=>{u()})};function ws(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var De={exports:{}};const{PassThrough:bs}=_e;var As=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let u=!1;t?u=!(r||n):r=r||"utf8",n&&(r=null);const o=new bs({objectMode:u});r&&o.setEncoding(r);let s=0;const i=[];return o.on("data",a=>{i.push(a),u?s=i.length:s+=a.length}),o.getBufferedValue=()=>t?i:n?Buffer.concat(i,s):i.join(""),o.getBufferedLength=()=>s,o};const{constants:vs}=dn,Bs=_e,{promisify:$s}=_t,xs=As,Os=$s(Bs.pipeline);class xr 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:r}=t,n=xs(t);return await new Promise((u,o)=>{const s=i=>{i&&n.getBufferedLength()<=vs.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),o(i)};(async()=>{try{await Os(e,n),u()}catch(i){s(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&s(new xr)})}),n.getBufferedValue()}De.exports=st,De.exports.buffer=(e,t)=>st(e,{...t,encoding:"buffer"}),De.exports.array=(e,t)=>st(e,{...t,array:!0}),De.exports.MaxBufferError=xr;var Is=De.exports,Or=W(Is);const{PassThrough:Ss}=_e;var Ps=function(){var e=[],t=new Ss({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",u),Array.prototype.slice.call(arguments).forEach(r),t;function r(o){return Array.isArray(o)?(o.forEach(r),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 n(){return e.length==0}function u(o){e=e.filter(function(s){return s!==o}),!e.length&&t.readable&&t.end()}},Ms=W(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 r=Ms();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},it=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},at=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Or(e,{encoding:t,maxBuffer:n}):Or.buffer(e,{maxBuffer:n})},Ns=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:u,maxBuffer:o},s)=>{const i=at(e,{encoding:n,buffer:u,maxBuffer:o}),a=at(t,{encoding:n,buffer:u,maxBuffer:o}),f=at(r,{encoding:n,buffer:u,maxBuffer:o*2});try{return await Promise.all([s,i,a,f])}catch(l){return Promise.all([{error:l,signal:l.signal,timedOut:l.timedOut},it(e,i),it(t,a),it(r,f)])}},Rs=(async()=>{})().constructor.prototype,ks=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Rs,e)]),Ir=(e,t)=>{for(const[r,n]of ks){const u=typeof t=="function"?(...o)=>Reflect.apply(n.value,t(),o):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:u})}return e},Ls=e=>new Promise((t,r)=>{e.on("exit",(n,u)=>{t({exitCode:n,signal:u})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Sr=(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)=>Sr(e,t).join(" "),Ks=(e,t)=>Sr(e,t).map(r=>Hs(r)).join(" "),qs=1e3*1e3*100,zs=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:u})=>{const o=t?{..._.env,...e}:e;return r?No({env:o,cwd:n,execPath:u}):o},Ys=(e,t,r={})=>{const n=Mo._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:qs,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||_.cwd(),execPath:_.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r},r.env=zs(r),r.stdio=ns(r),_.platform==="win32"&&H.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},Dt=(e,t,r)=>typeof t!="string"&&!cn.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?_o(t):t;function Q(e,t,r){const n=Ys(e,t,r),u=Us(e,t),o=Ks(e,t);Es(n.options);let s;try{s=It.spawn(n.file,n.args,n.options)}catch(p){const d=new It.ChildProcess,m=Promise.reject(Ar({error:p,stdout:"",stderr:"",all:"",command:u,escapedCommand:o,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Ir(d,m)}const i=Ls(s),a=Fs(s,n.options,i),f=ys(s,n.options,a),l={isCanceled:!1};s.kill=fs.bind(null,s.kill.bind(s)),s.cancel=gs.bind(null,s,l);const c=Er(async()=>{const[{error:p,exitCode:d,signal:m,timedOut:h},C,w,$]=await Ns(s,n.options,f),G=Dt(n.options,C),S=Dt(n.options,w),A=Dt(n.options,$);if(p||d!==0||m!==null){const M=Ar({error:p,exitCode:d,signal:m,stdout:G,stderr:S,all:A,command:u,escapedCommand:o,parsed:n,timedOut:h,isCanceled:l.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:s.killed});if(!n.options.reject)return M;throw M}return{command:u,escapedCommand:o,exitCode:0,stdout:G,stderr:S,all:A,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return _s(s,n.options.input),s.all=Ts(s,n.options),Ir(s,c)}class ee{static create(t,r){return new t(r)}}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]}`,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)}`},Pr=(e,t,r)=>["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[r],Vs(r)].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),L={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY"},Mr=Object.values(L).map(e=>e);class te{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),K({name:`${this.errorPrefix} ${n}`,value:n,isError:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,u,o){return`${Pr(t,u,o)}
27
+ `);return h?(n.originalMessage=n.message,n.message=w):n=new Error(w),n.shortMessage=C,n.command=s,n.escapedCommand=i,n.exitCode=u,n.signal=o,n.signalDescription=c,n.stdout=e,n.stderr=t,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!a,n.isCanceled=f,n.killed=l&&!a,n},we=["stdin","stdout","stderr"],ns=e=>we.some(t=>e[t]!==void 0),os=e=>{if(!e)return;const{stdio:t}=e;if(t===void 0)return we.map(n=>e[n]);if(ns(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${we.map(n=>`\`${n}\``).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 r=Math.max(t.length,we.length);return Array.from({length:r},(n,o)=>t[o])};var ee={exports:{}},be={exports:{}};be.exports;var Br;function us(){return Br||(Br=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 U=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(!U(F))ee.exports=function(){return function(){}};else{var ss=Pt,ie=us(),is=/^win/i.test(F.platform),Ae=Tt;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),ee.exports=function(e,t){if(!U(b.process))return function(){};ss.equal(typeof e,"function","a callback must be provided for exit handler"),ae===!1&&$r();var r="exit";t&&t.alwaysLast&&(r="afterexit");var n=function(){v.removeListener(r,e),v.listeners("exit").length===0&&v.listeners("afterexit").length===0&&nt()};return v.on(r,e),n};var nt=function(){!ae||!U(b.process)||(ae=!1,ie.forEach(function(t){try{F.removeListener(t,ot[t])}catch{}}),F.emit=ut,F.reallyExit=xr,v.count-=1)};ee.exports.unload=nt;var te=function(t,r,n){v.emitted[t]||(v.emitted[t]=!0,v.emit(t,r,n))},ot={};ie.forEach(function(e){ot[e]=function(){if(U(b.process)){var r=F.listeners(e);r.length===v.count&&(nt(),te("exit",null,e),te("afterexit",null,e),is&&e==="SIGHUP"&&(e="SIGINT"),F.kill(F.pid,e))}}}),ee.exports.signals=function(){return ie};var ae=!1,$r=function(){ae||!U(b.process)||(ae=!0,v.count+=1,ie=ie.filter(function(t){try{return F.on(t,ot[t]),!0}catch{return!1}}),F.emit=Ds,F.reallyExit=as)};ee.exports.load=$r;var xr=F.reallyExit,as=function(t){U(b.process)&&(F.exitCode=t||0,te("exit",F.exitCode,null),te("afterexit",F.exitCode,null),xr.call(F,F.exitCode))},ut=F.emit,Ds=function(t,r){if(t==="exit"&&U(b.process)){r!==void 0&&(F.exitCode=r);var n=ut.apply(this,arguments);return te("exit",F.exitCode,null),te("afterexit",F.exitCode,null),n}else return ut.apply(this,arguments)}}var cs=ee.exports,ls=J(cs);const fs=1e3*5,ps=(e,t="SIGTERM",r={})=>{const n=e(t);return ds(e,t,r,n),n},ds=(e,t,r,n)=>{if(!ms(t,r,n))return;const o=gs(r),u=setTimeout(()=>{e("SIGKILL")},o);u.unref&&u.unref()},ms=(e,{forceKillAfterTimeout:t},r)=>hs(e)&&t!==!1&&r,hs=e=>e===dn.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",gs=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return fs;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},Cs=(e,t)=>{e.kill()&&(t.isCanceled=!0)},Fs=(e,t,r)=>{e.kill(t),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},Es=(e,{timeout:t,killSignal:r="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let o;const u=new Promise((i,a)=>{o=setTimeout(()=>{Fs(e,r,a)},t)}),s=n.finally(()=>{clearTimeout(o)});return Promise.race([u,s])},ys=({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})`)},ws=async(e,{cleanup:t,detached:r},n)=>{if(!t||r)return n;const o=ls(()=>{e.kill()});return n.finally(()=>{o()})};function bs(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}var De={exports:{}};const{PassThrough:As}=Te;var vs=e=>{e={...e};const{array:t}=e;let{encoding:r}=e;const n=r==="buffer";let o=!1;t?o=!(r||n):r=r||"utf8",n&&(r=null);const u=new As({objectMode:o});r&&u.setEncoding(r);let s=0;const i=[];return u.on("data",a=>{i.push(a),o?s=i.length:s+=a.length}),u.getBufferedValue=()=>t?i:n?Buffer.concat(i,s):i.join(""),u.getBufferedLength=()=>s,u};const{constants:Bs}=mn,$s=Te,{promisify:xs}=_t,Os=vs,Is=xs($s.pipeline);class Or 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:r}=t,n=Os(t);return await new Promise((o,u)=>{const s=i=>{i&&n.getBufferedLength()<=Bs.MAX_LENGTH&&(i.bufferedData=n.getBufferedValue()),u(i)};(async()=>{try{await Is(e,n),o()}catch(i){s(i)}})(),n.on("data",()=>{n.getBufferedLength()>r&&s(new Or)})}),n.getBufferedValue()}De.exports=st,De.exports.buffer=(e,t)=>st(e,{...t,encoding:"buffer"}),De.exports.array=(e,t)=>st(e,{...t,array:!0}),De.exports.MaxBufferError=Or;var Ms=De.exports,Ir=J(Ms);const{PassThrough:Ss}=Te;var Ps=function(){var e=[],t=new Ss({objectMode:!0});return t.setMaxListeners(0),t.add=r,t.isEmpty=n,t.on("unpipe",o),Array.prototype.slice.call(arguments).forEach(r),t;function r(u){return Array.isArray(u)?(u.forEach(r),this):(e.push(u),u.once("end",o.bind(null,u)),u.once("error",t.emit.bind(t,"error")),u.pipe(t,{end:!1}),this)}function n(){return e.length==0}function o(u){e=e.filter(function(s){return s!==u}),!e.length&&t.readable&&t.end()}},Ts=J(Ps);const _s=(e,t)=>{t!==void 0&&(bs(t)?t.pipe(e.stdin):e.stdin.end(t))},Ns=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;const r=Ts();return e.stdout&&r.add(e.stdout),e.stderr&&r.add(e.stderr),r},it=async(e,t)=>{if(!(!e||t===void 0)){e.destroy();try{return await t}catch(r){return r.bufferedData}}},at=(e,{encoding:t,buffer:r,maxBuffer:n})=>{if(!(!e||!r))return t?Ir(e,{encoding:t,maxBuffer:n}):Ir.buffer(e,{maxBuffer:n})},Rs=async({stdout:e,stderr:t,all:r},{encoding:n,buffer:o,maxBuffer:u},s)=>{const i=at(e,{encoding:n,buffer:o,maxBuffer:u}),a=at(t,{encoding:n,buffer:o,maxBuffer:u}),f=at(r,{encoding:n,buffer:o,maxBuffer:u*2});try{return await Promise.all([s,i,a,f])}catch(l){return Promise.all([{error:l,signal:l.signal,timedOut:l.timedOut},it(e,i),it(t,a),it(r,f)])}},Ls=(async()=>{})().constructor.prototype,ks=["then","catch","finally"].map(e=>[e,Reflect.getOwnPropertyDescriptor(Ls,e)]),Mr=(e,t)=>{for(const[r,n]of ks){const o=typeof t=="function"?(...u)=>Reflect.apply(n.value,t(),u):n.value.bind(t);Reflect.defineProperty(e,r,{...n,value:o})}return e},js=e=>new Promise((t,r)=>{e.on("exit",(n,o)=>{t({exitCode:n,signal:o})}),e.on("error",n=>{r(n)}),e.stdin&&e.stdin.on("error",n=>{r(n)})}),Sr=(e,t=[])=>Array.isArray(t)?[e,...t]:[e],Gs=/^[\w.-]+$/,Hs=/"/g,Us=e=>typeof e!="string"||Gs.test(e)?e:`"${e.replace(Hs,'\\"')}"`,Ks=(e,t)=>Sr(e,t).join(" "),qs=(e,t)=>Sr(e,t).map(r=>Us(r)).join(" "),zs=1e3*1e3*100,Ys=({env:e,extendEnv:t,preferLocal:r,localDir:n,execPath:o})=>{const u=t?{...T.env,...e}:e;return r?Ru({env:u,cwd:n,execPath:o}):u},Ws=(e,t,r={})=>{const n=Tu._parse(e,t,r);return e=n.command,t=n.args,r=n.options,r={maxBuffer:zs,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||T.cwd(),execPath:T.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r},r.env=Ys(r),r.stdio=os(r),T.platform==="win32"&&V.basename(e,".exe")==="cmd"&&t.unshift("/q"),{file:e,args:t,options:r,parsed:n}},Dt=(e,t,r)=>typeof t!="string"&&!ln.isBuffer(t)?r===void 0?void 0:"":e.stripFinalNewline?_u(t):t;function re(e,t,r){const n=Ws(e,t,r),o=Ks(e,t),u=qs(e,t);ys(n.options);let s;try{s=Mt.spawn(n.file,n.args,n.options)}catch(p){const d=new Mt.ChildProcess,m=Promise.reject(vr({error:p,stdout:"",stderr:"",all:"",command:o,escapedCommand:u,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Mr(d,m)}const i=js(s),a=Es(s,n.options,i),f=ws(s,n.options,a),l={isCanceled:!1};s.kill=ps.bind(null,s.kill.bind(s)),s.cancel=Cs.bind(null,s,l);const c=yr(async()=>{const[{error:p,exitCode:d,signal:m,timedOut:h},C,w,$]=await Rs(s,n.options,f),W=Dt(n.options,C),M=Dt(n.options,w),A=Dt(n.options,$);if(p||d!==0||m!==null){const P=vr({error:p,exitCode:d,signal:m,stdout:W,stderr:M,all:A,command:o,escapedCommand:u,parsed:n,timedOut:h,isCanceled:l.isCanceled||(n.options.signal?n.options.signal.aborted:!1),killed:s.killed});if(!n.options.reject)return P;throw P}return{command:o,escapedCommand:u,exitCode:0,stdout:W,stderr:M,all:A,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return _s(s,n.options.input),s.all=Ns(s,n.options),Mr(s,c)}class K{static create(t,r){return new t(r)}}const Vs={"":"<commit message>",conventional:"<type>(<optional scope>): <description>",gitmoji:":<emoji>: <description>"},Xs=e=>`The output response must be in ${e} commit type:
28
+ ${Vs[e]}`,Js={"":"",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)}`},Pr=(e,t,r)=>["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.`,"Please exclude anything unnecessary such as translation or explanation. Your entire response will be passed directly into git commit.",Js[r],Xs(r)].filter(Boolean).join(`
30
+ `),Zs=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),Qs=e=>/^\:\w+\: (.*)$/.test(e),L={OPEN_AI:"OPENAI_KEY",GEMINI:"GEMINI_KEY",ANTHROPIC:"ANTHROPIC_KEY",HUGGING:"HUGGING_COOKIE",CLOVA_X:"CLOVAX_COOKIE",MISTRAL:"MISTRAL_KEY",OLLAMA:"OLLAMA_MODEL"},Tr=Object.values(L).map(e=>e);class q{constructor(t){this.handleError$=r=>{let n="An error occurred";return r.message&&(n=r.message),_({name:`${this.errorPrefix} ${n}`,value:n,isError:!0})},this.serviceName="AI",this.errorPrefix="ERROR",this.colors={primary:""}}buildPrompt(t,r,n,o,u){return`${Pr(t,o,u)}
31
31
  Please just generate ${n} messages in numbered list format.
32
32
  Here are git diff:
33
- ${r}`}extractCommitMessageFromRawText(t,r){switch(t){case"conventional":const n=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),u=r.match(n);return u?u[0].replace(/: (\w)/,(i,a)=>`: ${a.toLowerCase()}`):"";case"gitmoji":const o=new RegExp(/\:\w+\: (.*)$/),s=r.match(o);return s?s[0]:"";default:return r}}}var _r="1.5.0",Qs="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const ct=" ",ve=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
33
+ ${r}`}extractCommitMessageFromRawText(t,r){switch(t){case"conventional":const n=new RegExp(/(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?: .*$/),o=r.match(n);return o?o[0].replace(/: (\w)/,(i,a)=>`: ${a.toLowerCase()}`):"";case"gitmoji":const u=new RegExp(/\:\w+\: (.*)$/),s=r.match(u);return s?s[0]:"";default:return r}}}var _r="1.6.0",ei="A Reactive CLI that generates git commit messages with various AI";class y extends Error{}const ct=" ",ve=e=>{e instanceof Error&&(e instanceof y||(e.stack&&console.error(g.dim(e.stack.split(`
34
34
  `).slice(1).join(`
35
35
  `))),console.error(`
36
36
  ${ct}${g.dim(`aicommit2 v${_r}`)}`),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:{}},ce={exports:{}},pt,Tr;function ei(){if(Tr)return pt;Tr=1;var e=1e3,t=e*60,r=t*60,n=r*24,u=n*7,o=n*365.25;pt=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?a(l):i(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]),p=(D[2]||"ms").toLowerCase();switch(p){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*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;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 i(l){var D=Math.abs(l);return D>=n?Math.round(l/n)+"d":D>=r?Math.round(l/r)+"h":D>=t?Math.round(l/t)+"m":D>=e?Math.round(l/e)+"s":l+"ms"}function a(l){var D=Math.abs(l);return D>=n?f(l,D,n,"day"):D>=r?f(l,D,r,"hour"):D>=t?f(l,D,t,"minute"):D>=e?f(l,D,e,"second"):l+" ms"}function f(l,D,c,p){var d=D>=c*1.5;return Math.round(l/c)+" "+p+(d?"s":"")}return pt}var dt,Nr;function Rr(){if(Nr)return dt;Nr=1;function e(t){n.debug=n,n.default=n,n.coerce=f,n.disable=s,n.enable=o,n.enabled=i,n.humanize=ei(),n.destroy=l,Object.keys(t).forEach(D=>{n[D]=t[D]}),n.names=[],n.skips=[],n.formatters={};function r(D){let c=0;for(let p=0;p<D.length;p++)c=(c<<5)-c+D.charCodeAt(p),c|=0;return n.colors[Math.abs(c)%n.colors.length]}n.selectColor=r;function n(D){let c,p=null,d,m;function h(...C){if(!h.enabled)return;const w=h,$=Number(new Date),G=$-(c||$);w.diff=G,w.prev=c,w.curr=$,c=$,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let S=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(M,sn)=>{if(M==="%%")return"%";S++;const Ot=n.formatters[sn];if(typeof Ot=="function"){const an=C[S];M=Ot.call(w,an),C.splice(S,1),S--}return M}),n.formatArgs.call(w,C),(w.log||n.log).apply(w,C)}return h.namespace=D,h.useColors=n.useColors(),h.color=n.selectColor(D),h.extend=u,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,m=n.enabled(D)),m),set:C=>{p=C}}),typeof n.init=="function"&&n.init(h),h}function u(D,c){const p=n(this.namespace+(typeof c>"u"?":":c)+D);return p.log=this.log,p}function o(D){n.save(D),n.namespaces=D,n.names=[],n.skips=[];let c;const p=(typeof D=="string"?D:"").split(/[\s,]+/),d=p.length;for(c=0;c<d;c++)p[c]&&(D=p[c].replace(/\*/g,".*?"),D[0]==="-"?n.skips.push(new RegExp("^"+D.slice(1)+"$")):n.names.push(new RegExp("^"+D+"$")))}function s(){const D=[...n.names.map(a),...n.skips.map(a).map(c=>"-"+c)].join(",");return n.enable(""),D}function i(D){if(D[D.length-1]==="*")return!0;let c,p;for(c=0,p=n.skips.length;c<p;c++)if(n.skips[c].test(D))return!1;for(c=0,p=n.names.length;c<p;c++)if(n.names[c].test(D))return!0;return!1}function a(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 n.enable(n.load()),n}return dt=e,dt}ce.exports;var kr;function ti(){return kr||(kr=1,function(e,t){t.formatArgs=n,t.save=u,t.load=o,t.useColors=r,t.storage=s(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!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 r(){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 n(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;a.splice(1,0,f,"color: inherit");let l=0,D=0;a[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(l++,c==="%c"&&(D=l))}),a.splice(D,0,f)}t.log=console.debug||console.log||(()=>{});function u(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function o(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function s(){try{return localStorage}catch{}}e.exports=Rr()(t);const{formatters:i}=e.exports;i.j=function(a){try{return JSON.stringify(a)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}(ce,ce.exports)),ce.exports}var le={exports:{}},mt,Lr;function ri(){return Lr||(Lr=1,mt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),u=t.indexOf("--");return n!==-1&&(u===-1||n<u)}),mt}var ht,jr;function ni(){if(jr)return ht;jr=1;const e=Nt,t=Pe,r=ri(),{env:n}=process;let u;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?u=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(u=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?u=1:n.FORCE_COLOR==="false"?u=0:u=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function o(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function s(a,f){if(u===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!f&&u===void 0)return 0;const l=u||0;if(n.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 n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in n)||n.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const D=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:l}function i(a){const f=s(a,a&&a.isTTY);return o(f)}return ht={supportsColor:i,stdout:o(s(!0,t.isatty(1))),stderr:o(s(!0,t.isatty(2)))},ht}le.exports;var Gr;function ui(){return Gr||(Gr=1,function(e,t){const r=Pe,n=_t;t.init=l,t.log=i,t.formatArgs=o,t.save=a,t.load=f,t.useColors=u,t.destroy=n.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=ni();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,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];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[d]=m,c},{});function u(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(c){const{namespace:p,useColors:d}=this;if(d){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;c[0]=C+c[0].split(`
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:{}},ce={exports:{}},pt,Nr;function ti(){if(Nr)return pt;Nr=1;var e=1e3,t=e*60,r=t*60,n=r*24,o=n*7,u=n*365.25;pt=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?a(l):i(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]),p=(D[2]||"ms").toLowerCase();switch(p){case"years":case"year":case"yrs":case"yr":case"y":return c*u;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;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 i(l){var D=Math.abs(l);return D>=n?Math.round(l/n)+"d":D>=r?Math.round(l/r)+"h":D>=t?Math.round(l/t)+"m":D>=e?Math.round(l/e)+"s":l+"ms"}function a(l){var D=Math.abs(l);return D>=n?f(l,D,n,"day"):D>=r?f(l,D,r,"hour"):D>=t?f(l,D,t,"minute"):D>=e?f(l,D,e,"second"):l+" ms"}function f(l,D,c,p){var d=D>=c*1.5;return Math.round(l/c)+" "+p+(d?"s":"")}return pt}var dt,Rr;function Lr(){if(Rr)return dt;Rr=1;function e(t){n.debug=n,n.default=n,n.coerce=f,n.disable=s,n.enable=u,n.enabled=i,n.humanize=ti(),n.destroy=l,Object.keys(t).forEach(D=>{n[D]=t[D]}),n.names=[],n.skips=[],n.formatters={};function r(D){let c=0;for(let p=0;p<D.length;p++)c=(c<<5)-c+D.charCodeAt(p),c|=0;return n.colors[Math.abs(c)%n.colors.length]}n.selectColor=r;function n(D){let c,p=null,d,m;function h(...C){if(!h.enabled)return;const w=h,$=Number(new Date),W=$-(c||$);w.diff=W,w.prev=c,w.curr=$,c=$,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let M=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(P,an)=>{if(P==="%%")return"%";M++;const It=n.formatters[an];if(typeof It=="function"){const Dn=C[M];P=It.call(w,Dn),C.splice(M,1),M--}return P}),n.formatArgs.call(w,C),(w.log||n.log).apply(w,C)}return h.namespace=D,h.useColors=n.useColors(),h.color=n.selectColor(D),h.extend=o,h.destroy=n.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==n.namespaces&&(d=n.namespaces,m=n.enabled(D)),m),set:C=>{p=C}}),typeof n.init=="function"&&n.init(h),h}function o(D,c){const p=n(this.namespace+(typeof c>"u"?":":c)+D);return p.log=this.log,p}function u(D){n.save(D),n.namespaces=D,n.names=[],n.skips=[];let c;const p=(typeof D=="string"?D:"").split(/[\s,]+/),d=p.length;for(c=0;c<d;c++)p[c]&&(D=p[c].replace(/\*/g,".*?"),D[0]==="-"?n.skips.push(new RegExp("^"+D.slice(1)+"$")):n.names.push(new RegExp("^"+D+"$")))}function s(){const D=[...n.names.map(a),...n.skips.map(a).map(c=>"-"+c)].join(",");return n.enable(""),D}function i(D){if(D[D.length-1]==="*")return!0;let c,p;for(c=0,p=n.skips.length;c<p;c++)if(n.skips[c].test(D))return!1;for(c=0,p=n.names.length;c<p;c++)if(n.names[c].test(D))return!0;return!1}function a(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 n.enable(n.load()),n}return dt=e,dt}ce.exports;var kr;function ri(){return kr||(kr=1,function(e,t){t.formatArgs=n,t.save=o,t.load=u,t.useColors=r,t.storage=s(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!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 r(){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 n(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;a.splice(1,0,f,"color: inherit");let l=0,D=0;a[0].replace(/%[a-zA-Z%]/g,c=>{c!=="%%"&&(l++,c==="%c"&&(D=l))}),a.splice(D,0,f)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function u(){let a;try{a=t.storage.getItem("debug")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=process.env.DEBUG),a}function s(){try{return localStorage}catch{}}e.exports=Lr()(t);const{formatters:i}=e.exports;i.j=function(a){try{return JSON.stringify(a)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}(ce,ce.exports)),ce.exports}var le={exports:{}},mt,jr;function ni(){return jr||(jr=1,mt=(e,t=process.argv)=>{const r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}),mt}var ht,Gr;function oi(){if(Gr)return ht;Gr=1;const e=Rt,t=Se,r=ni(),{env:n}=process;let o;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?o=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(o=1),"FORCE_COLOR"in n&&(n.FORCE_COLOR==="true"?o=1:n.FORCE_COLOR==="false"?o=0:o=n.FORCE_COLOR.length===0?1:Math.min(parseInt(n.FORCE_COLOR,10),3));function u(a){return a===0?!1:{level:a,hasBasic:!0,has256:a>=2,has16m:a>=3}}function s(a,f){if(o===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!f&&o===void 0)return 0;const l=o||0;if(n.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 n)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(D=>D in n)||n.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in n)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(n.TEAMCITY_VERSION)?1:0;if(n.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in n){const D=parseInt((n.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(n.TERM_PROGRAM){case"iTerm.app":return D>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(n.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(n.TERM)||"COLORTERM"in n?1:l}function i(a){const f=s(a,a&&a.isTTY);return u(f)}return ht={supportsColor:i,stdout:u(s(!0,t.isatty(1))),stderr:u(s(!0,t.isatty(2)))},ht}le.exports;var Hr;function ui(){return Hr||(Hr=1,function(e,t){const r=Se,n=_t;t.init=l,t.log=i,t.formatArgs=u,t.save=a,t.load=f,t.useColors=o,t.destroy=n.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=oi();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,p)=>{const d=p.substring(6).toLowerCase().replace(/_([a-z])/g,(h,C)=>C.toUpperCase());let m=process.env[p];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[d]=m,c},{});function o(){return"colors"in t.inspectOpts?!!t.inspectOpts.colors:r.isatty(process.stderr.fd)}function u(c){const{namespace:p,useColors:d}=this;if(d){const m=this.color,h="\x1B[3"+(m<8?m:"8;5;"+m),C=` ${h};1m${p} \x1B[0m`;c[0]=C+c[0].split(`
38
38
  `).join(`
39
39
  `+C),c.push(h+"m+"+e.exports.humanize(this.diff)+"\x1B[0m")}else c[0]=s()+p+" "+c[0]}function s(){return t.inspectOpts.hideDate?"":new Date().toISOString()+" "}function i(...c){return process.stderr.write(n.format(...c)+`
40
- `)}function a(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function f(){return process.env.DEBUG}function l(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=Rr()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts).split(`
41
- `).map(p=>p.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts)}}(le,le.exports)),le.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,r){return new Promise((n,u)=>{e.call(this,t,r,(o,s)=>{o?u(o):n(s)})})}}Ct.default=oi;var Hr=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const si=Mt,ii=Hr(gt),ai=Hr(Ct),fe=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(n,u){super();let o=u;typeof n=="function"?this.callback=n:n&&(o=n),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(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Ft()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,u,o){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,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,n._last=!0,n.shouldKeepAlive=!1;let s=!1,i=null;const a=o.timeout||this.timeout,f=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},l=()=>{i=null,s=!0;const p=new Error(`A "socket" was not created for HTTP request before ${a}ms`);p.code="ETIMEOUT",f(p)},D=p=>{s||(i!==null&&(clearTimeout(i),i=null),f(p))},c=p=>{if(s)return;if(i!=null&&(clearTimeout(i),i=null),Di(p)){fe("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,o);return}if(p){p.once("free",()=>{this.freeSocket(p,o)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);f(d)};if(typeof this.callback!="function"){f(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(fe("Converting legacy callback function to promise"),this.promisifiedCallback=ai.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(i=setTimeout(l,a)),"port"in o&&typeof o.port!="number"&&(o.port=Number(o.port));try{fe("Resolving socket for %o request: %o",o.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,o)).then(c,D)}catch(p){Promise.reject(p).catch(D)}}freeSocket(n,u){fe("Freeing socket %o %o",n.constructor.name,u),n.destroy()}destroy(){fe("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),pe=fi.default("https-proxy-agent:parse-proxy-response");function pi(e){return new Promise((t,r)=>{let n=0;const u=[];function o(){const D=e.read();D?l(D):e.once("readable",o)}function s(){e.removeListener("end",a),e.removeListener("error",f),e.removeListener("close",i),e.removeListener("readable",o)}function i(D){pe("onclose had error %o",D)}function a(){pe("onend")}function f(D){s(),pe("onerror %o",D),r(D)}function l(D){u.push(D),n+=D.length;const c=Buffer.concat(u,n);if(c.indexOf(`\r
40
+ `)}function a(c){c?process.env.DEBUG=c:delete process.env.DEBUG}function f(){return process.env.DEBUG}function l(c){c.inspectOpts={};const p=Object.keys(t.inspectOpts);for(let d=0;d<p.length;d++)c.inspectOpts[p[d]]=t.inspectOpts[p[d]]}e.exports=Lr()(t);const{formatters:D}=e.exports;D.o=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts).split(`
41
+ `).map(p=>p.trim()).join(" ")},D.O=function(c){return this.inspectOpts.colors=this.useColors,n.inspect(c,this.inspectOpts)}}(le,le.exports)),le.exports}typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ft.exports=ri():ft.exports=ui();var gt=ft.exports,Ct={};Object.defineProperty(Ct,"__esModule",{value:!0});function si(e){return function(t,r){return new Promise((n,o)=>{e.call(this,t,r,(u,s)=>{u?o(u):n(s)})})}}Ct.default=si;var Ur=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const ii=Tt,ai=Ur(gt),Di=Ur(Ct),fe=ai.default("agent-base");function ci(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 ii.EventEmitter{constructor(n,o){super();let u=o;typeof n=="function"?this.callback=n:n&&(u=n),this.timeout=null,u&&typeof u.timeout=="number"&&(this.timeout=u.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(n){this.explicitDefaultPort=n}get protocol(){return typeof this.explicitProtocol=="string"?this.explicitProtocol:Ft()?"https:":"http:"}set protocol(n){this.explicitProtocol=n}callback(n,o,u){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')}addRequest(n,o){const u=Object.assign({},o);typeof u.secureEndpoint!="boolean"&&(u.secureEndpoint=Ft()),u.host==null&&(u.host="localhost"),u.port==null&&(u.port=u.secureEndpoint?443:80),u.protocol==null&&(u.protocol=u.secureEndpoint?"https:":"http:"),u.host&&u.path&&delete u.path,delete u.agent,delete u.hostname,delete u._defaultAgent,delete u.defaultPort,delete u.createConnection,n._last=!0,n.shouldKeepAlive=!1;let s=!1,i=null;const a=u.timeout||this.timeout,f=p=>{n._hadError||(n.emit("error",p),n._hadError=!0)},l=()=>{i=null,s=!0;const p=new Error(`A "socket" was not created for HTTP request before ${a}ms`);p.code="ETIMEOUT",f(p)},D=p=>{s||(i!==null&&(clearTimeout(i),i=null),f(p))},c=p=>{if(s)return;if(i!=null&&(clearTimeout(i),i=null),ci(p)){fe("Callback returned another Agent instance %o",p.constructor.name),p.addRequest(n,u);return}if(p){p.once("free",()=>{this.freeSocket(p,u)}),n.onSocket(p);return}const d=new Error(`no Duplex stream was returned to agent-base for \`${n.method} ${n.path}\``);f(d)};if(typeof this.callback!="function"){f(new Error("`callback` is not defined"));return}this.promisifiedCallback||(this.callback.length>=3?(fe("Converting legacy callback function to promise"),this.promisifiedCallback=Di.default(this.callback)):this.promisifiedCallback=this.callback),typeof a=="number"&&a>0&&(i=setTimeout(l,a)),"port"in u&&typeof u.port!="number"&&(u.port=Number(u.port));try{fe("Resolving socket for %o request: %o",u.protocol,`${n.method} ${n.path}`),Promise.resolve(this.promisifiedCallback(n,u)).then(c,D)}catch(p){Promise.reject(p).catch(D)}}freeSocket(n,o){fe("Freeing socket %o %o",n.constructor.name,o),n.destroy()}destroy(){fe("Destroying agent %o",this.constructor.name)}}e.Agent=t,e.prototype=e.Agent.prototype})(Be||(Be={}));var li=Be,Et={},fi=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});const pi=fi(gt),pe=pi.default("https-proxy-agent:parse-proxy-response");function di(e){return new Promise((t,r)=>{let n=0;const o=[];function u(){const D=e.read();D?l(D):e.once("readable",u)}function s(){e.removeListener("end",a),e.removeListener("error",f),e.removeListener("close",i),e.removeListener("readable",u)}function i(D){pe("onclose had error %o",D)}function a(){pe("onend")}function f(D){s(),pe("onerror %o",D),r(D)}function l(D){o.push(D),n+=D.length;const c=Buffer.concat(o,n);if(c.indexOf(`\r
43
43
  \r
44
- `)===-1){pe("have not received end of HTTP headers yet..."),o();return}const d=c.toString("ascii",0,c.indexOf(`\r
45
- `)),m=+d.split(" ")[1];pe("got proxy server response: %o",d),t({statusCode:m,buffered:c})}e.on("error",f),e.on("close",i),e.on("end",a),o()})}Et.default=pi;var di=b&&b.__awaiter||function(e,t,r,n){function u(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function i(l){try{f(n.next(l))}catch(D){s(D)}}function a(l){try{f(n.throw(l))}catch(D){s(D)}}function f(l){l.done?o(l.value):u(l.value).then(i,a)}f((n=n.apply(e,t||[])).next())})},re=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lt,"__esModule",{value:!0});const Ur=re(yn),Kr=re(wn),mi=re(bn),hi=re(Pt),gi=re(gt),Ci=ci,Fi=re(Et),de=gi.default("https-proxy-agent:agent");class Ei extends Ci.Agent{constructor(t){let r;if(typeof t=="string"?r=mi.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");de("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||bi(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return di(this,void 0,void 0,function*(){const{proxy:n,secureProxy:u}=this;let o;u?(de("Creating `tls.Socket`: %o",n),o=Kr.default.connect(n)):(de("Creating `net.Socket`: %o",n),o=Ur.default.connect(n));const s=Object.assign({},n.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
46
- `;n.auth&&(s["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:f,port:l,secureEndpoint:D}=r;wi(l,D)||(f+=`:${l}`),s.Host=f,s.Connection="close";for(const h of Object.keys(s))a+=`${h}: ${s[h]}\r
47
- `;const c=Fi.default(o);o.write(`${a}\r
48
- `);const{statusCode:p,buffered:d}=yield c;if(p===200){if(t.once("socket",yi),r.secureEndpoint){de("Upgrading socket connection to TLS");const h=r.servername||r.host;return Kr.default.connect(Object.assign(Object.assign({},Ai(r,"host","hostname","path","port")),{socket:o,servername:h}))}return o}o.destroy();const m=new Ur.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(d),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 r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}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=W(Bi);const xi=async(e,t,r,n,u,o,s)=>new Promise((i,a)=>{const f=JSON.stringify(n),l=En.request({port:s||void 0,hostname:e,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(f),...r},timeout:u,agent:o?$i(o):void 0},D=>{const c=[];D.on("data",p=>c.push(p)),D.on("end",()=>{i({request:l,response:D,data:Buffer.concat(c).toString()})})});l.on("error",a),l.on("timeout",()=>{l.destroy(),a(new y(`Time out error: request took over ${u}ms. Try increasing the \`timeout\` config`))}),l.write(f),l.end()}),Oi=async(e,t,r,n)=>{const{response:u,data:o}=await xi("api.openai.com","/v1/chat/completions",{Authorization:`Bearer ${e}`},t,r,n);if(!u.statusCode||u.statusCode<200||u.statusCode>299){let s=`OpenAI API Error: ${u.statusCode} - ${u.statusMessage}`;throw o&&(s+=`
44
+ `)===-1){pe("have not received end of HTTP headers yet..."),u();return}const d=c.toString("ascii",0,c.indexOf(`\r
45
+ `)),m=+d.split(" ")[1];pe("got proxy server response: %o",d),t({statusCode:m,buffered:c})}e.on("error",f),e.on("close",i),e.on("end",a),u()})}Et.default=di;var mi=b&&b.__awaiter||function(e,t,r,n){function o(u){return u instanceof r?u:new r(function(s){s(u)})}return new(r||(r=Promise))(function(u,s){function i(l){try{f(n.next(l))}catch(D){s(D)}}function a(l){try{f(n.throw(l))}catch(D){s(D)}}function f(l){l.done?u(l.value):o(l.value).then(i,a)}f((n=n.apply(e,t||[])).next())})},ne=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lt,"__esModule",{value:!0});const Kr=ne(wn),qr=ne(bn),hi=ne(An),gi=ne(Pt),Ci=ne(gt),Fi=li,Ei=ne(Et),de=Ci.default("https-proxy-agent:agent");class yi extends Fi.Agent{constructor(t){let r;if(typeof t=="string"?r=hi.default.parse(t):r=t,!r)throw new Error("an HTTP(S) proxy server `host` and `port` must be specified!");de("creating new HttpsProxyAgent instance: %o",r),super(r);const n=Object.assign({},r);this.secureProxy=r.secureProxy||Ai(n.protocol),n.host=n.hostname||n.host,typeof n.port=="string"&&(n.port=parseInt(n.port,10)),!n.port&&n.host&&(n.port=this.secureProxy?443:80),this.secureProxy&&!("ALPNProtocols"in n)&&(n.ALPNProtocols=["http 1.1"]),n.host&&n.path&&(delete n.path,delete n.pathname),this.proxy=n}callback(t,r){return mi(this,void 0,void 0,function*(){const{proxy:n,secureProxy:o}=this;let u;o?(de("Creating `tls.Socket`: %o",n),u=qr.default.connect(n)):(de("Creating `net.Socket`: %o",n),u=Kr.default.connect(n));const s=Object.assign({},n.headers);let a=`CONNECT ${`${r.host}:${r.port}`} HTTP/1.1\r
46
+ `;n.auth&&(s["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:f,port:l,secureEndpoint:D}=r;bi(l,D)||(f+=`:${l}`),s.Host=f,s.Connection="close";for(const h of Object.keys(s))a+=`${h}: ${s[h]}\r
47
+ `;const c=Ei.default(u);u.write(`${a}\r
48
+ `);const{statusCode:p,buffered:d}=yield c;if(p===200){if(t.once("socket",wi),r.secureEndpoint){de("Upgrading socket connection to TLS");const h=r.servername||r.host;return qr.default.connect(Object.assign(Object.assign({},vi(r,"host","hostname","path","port")),{socket:u,servername:h}))}return u}u.destroy();const m=new Kr.default.Socket({writable:!1});return m.readable=!0,t.once("socket",h=>{de("replaying proxy buffer for failed request"),gi.default(h.listenerCount("data")>0),h.push(d),h.push(null)}),m})}}lt.default=yi;function wi(e){e.resume()}function bi(e,t){return!!(!t&&e===80||t&&e===443)}function Ai(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function vi(e,...t){const r={};let n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}var Bi=b&&b.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const yt=Bi(lt);function wt(e){return new yt.default(e)}(function(e){e.HttpsProxyAgent=yt.default,e.prototype=yt.default.prototype})(wt||(wt={}));var $i=wt,xi=J($i);const Oi=async(e,t,r,n,o,u,s)=>new Promise((i,a)=>{const f=JSON.stringify(n),l=yn.request({port:s||void 0,hostname:e,path:t,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(f),...r},timeout:o,agent:u?xi(u):void 0},D=>{const c=[];D.on("data",p=>c.push(p)),D.on("end",()=>{i({request:l,response:D,data:Buffer.concat(c).toString()})})});l.on("error",a),l.on("timeout",()=>{l.destroy(),a(new y(`Time out error: request took over ${o}ms. Try increasing the \`timeout\` config`))}),l.write(f),l.end()}),Ii=async(e,t,r,n)=>{const{response:o,data:u}=await Oi("api.openai.com","/v1/chat/completions",{Authorization:`Bearer ${e}`},t,r,n);if(!o.statusCode||o.statusCode<200||o.statusCode>299){let s=`OpenAI API Error: ${o.statusCode} - ${o.statusMessage}`;throw u&&(s+=`
49
49
 
50
- ${o}`),u.statusCode===500&&(s+=`
50
+ ${u}`),o.statusCode===500&&(s+=`
51
51
 
52
- Check the API status: https://status.openai.com`),new y(s)}return JSON.parse(o)},Ii=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),ne=e=>Array.from(new Set(e)),Si=async(e,t,r,n,u,o,s,i,a,f,l)=>{try{const D=await Oi(e,{model:t,messages:[{role:"system",content:Pr(r,o,s)},{role:"user",content:n}],temperature:f,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:a,stream:!1,n:u},i,l);return ne(D.choices.filter(c=>c.message?.content).map(c=>Ii(c.message.content)).map(c=>{if(s==="conventional"){const p=/: (\w)/;return c.replace(p,(d,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 y(`Error connecting to ${c.hostname} (${c.syscall})`):c}};class Pi extends te{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return K({name:`${this.errorPrefix} ${n}`,value:n,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 Y(this.generateMessage()).pipe(q(t=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(r,t,n,o,u),a=(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 ne(this.sanitizeMessage(a))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){return t.split(`
52
+ Check the API status: https://status.openai.com`),new y(s)}return JSON.parse(u)},Mi=e=>e.trim().replace(/[\n\r]/g,"").replace(/(\w)\.$/,"$1"),z=e=>Array.from(new Set(e)),Si=async(e,t,r,n,o,u,s,i,a,f,l)=>{try{const D=await Ii(e,{model:t,messages:[{role:"system",content:Pr(r,u,s)},{role:"user",content:n}],temperature:f,top_p:1,frequency_penalty:0,presence_penalty:0,max_tokens:a,stream:!1,n:o},i,l);return z(D.choices.filter(c=>c.message?.content).map(c=>Mi(c.message.content)).map(c=>{if(s==="conventional"){const p=/: (\w)/;return c.replace(p,(d,m)=>`: ${m.toLowerCase()}`)}return c}).filter(c=>{switch(s){case"gitmoji":return Qs(c);case"conventional":return Zs(c);case"":default:return!0}}))}catch(D){const c=D;throw c.code==="ENOTFOUND"?new y(`Error connecting to ${c.hostname} (${c.syscall})`):c}};class Pi extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.error?.error?.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return _({name:`${this.errorPrefix} ${n}`,value:n,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 G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,u=this.params.config["max-length"],s=this.buildPrompt(r,t,n,u,o),a=(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 z(this.sanitizeMessage(a))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){return t.split(`
53
53
  `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}const{hasOwnProperty:bt}=Object.prototype,$e=typeof process<"u"&&process.platform==="win32"?`\r
54
54
  `:`
55
- `,At=(e,t)=>{const r=[];let n="";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 i of s)n+=ue(o+"[]")+u+ue(i)+$e;else s&&typeof s=="object"?r.push(o):n+=ue(o)+u+ue(s)+$e}t.section&&n.length&&(n="["+ue(t.section)+"]"+$e+n);for(const o of r){const s=qr(o).join("\\."),i=(t.section?t.section+".":"")+s,{whitespace:a}=t,f=At(e[o],{section:i,whitespace:a});n.length&&f.length&&(n+=$e),n+=f}return n},qr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),zr=e=>{const t=Object.create(null);let r=t,n=null;const u=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=e.split(/[\r\n]+/g);for(const i of o){if(!i||i.match(/^\s*[;#]/))continue;const a=i.match(u);if(!a)continue;if(a[1]!==void 0){if(n=xe(a[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const f=xe(a[2]),l=f.length>2&&f.slice(-2)==="[]",D=l?f.slice(0,-2):f;if(D==="__proto__")continue;const c=a[3]?xe(a[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;l&&(bt.call(r,D)?Array.isArray(r[D])||(r[D]=[r[D]]):r[D]=[]),Array.isArray(r[D])?r[D].push(p):r[D]=p}const s=[];for(const i of Object.keys(t)){if(!bt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const a=qr(i);r=t;const f=a.pop(),l=f.replace(/\\\./g,".");for(const D of a)D!=="__proto__"&&((!bt.call(r,D)||typeof r[D]!="object")&&(r[D]=Object.create(null)),r=r[D]);r===t&&l===f||(r[l]=t[i],s.push(i))}for(const i of s)delete t[i];return t},Yr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),ue=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Yr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),xe=(e,t)=>{if(e=(e||"").trim(),Yr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let u=0,o=e.length;u<o;u++){const s=e.charAt(u);if(r)"\\;#".indexOf(s)!==-1?n+=s:n+="\\"+s,r=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?r=!0:n+=s}}return r&&(n+="\\"),n.trim()}return e};var Mi={parse:zr,decode:zr,stringify:At,encode:At,safe:ue,unsafe:xe},Wr=W(Mi);const Vr=e=>x.lstat(e).then(()=>!0,()=>!1),_i=["","conventional","gitmoji"],{hasOwnProperty:Ti}=Object.prototype,j=(e,t)=>Ti.call(e,t),E=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},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-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),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=U.join(Nt.homedir(),".aicommit2"),Xr=async()=>{if(!await Vr(vt))return Object.create(null);const t=await x.readFile(vt,"utf8");return Wr.parse(t)},Bt=async(e,t)=>{const r=await Xr(),n={};for(const u of Object.keys(Oe)){const o=Oe[u],s=e?.[u]??r[u];if(t)try{n[u]=o(s)}catch{}else n[u]=o(s)}return n},Ni=async e=>{const t=await Xr();for(const[r,n]of e){if(!j(Oe,r))throw new y(`Invalid config property: ${r}`);const u=Oe[r](n);t[r]=u}await x.writeFile(vt,Wr.stringify(t),"utf8")};class O{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=xn.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 te{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 Y(this.generateMessage()).pipe(q(t=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,r,u,n);await this.getAllConversationIds();const i=await this.sendMessage(s),{conversationId:a,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(a),ne(this.sanitizeMessage(f))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async getAllConversationIds(){const r=(await new O({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(!r||!r.content)throw new Error("No content on conversations ClovaX");return r.content.length===0?[]:r.content.map(u=>u.conversationId||"").filter(u=>!!u)}async sendMessage(t){const r={text:t,action:"new"},n=new Bn;return n.set("form",new $n([JSON.stringify(r)],{type:"application/json"})),(await new O({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(n),Cookie:this.cookie}).setBody(n).execute()).data}parseSendMessageResult(t){const r=/data:{(.*)}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");const u=n.map(a=>a.trim().replace(/data:/g,""));if(!u||u.length===0)throw new Error("Cannot extract message");let o="",s="",i="";if(u.map(a=>{try{return JSON.parse(a)}catch{return null}}).filter(a=>!!a).forEach(a=>{if(j(a,"conversationId")){o=a.conversationId;return}if(j(a,"text")){s+=a.text;return}if(j(a,"error")){i=`${a.error}: ${a.type||a.message||""}`;return}}),i)throw new Error(i);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(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}async deleteConversation(t){return(await new O({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(),([r,n])=>({[r]:{ContentLength:typeof n=="string"?n.length:n.size}}))}}class ki extends te{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),u=/(\[.*?\]\s*[^[]*)/g,o=[...n.matchAll(u)],s=[];o.forEach(a=>s.push(a[1]));const i=s[1]||"An error occurred";return K({name:`${this.errorPrefix} ${i}`,value:i,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 On(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return Y(this.generateMessage()).pipe(q(t=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(r,t,n,o,u),i=this.params.config["max-tokens"],D=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(s)).response).text();return ne(this.sanitizeMessage(D))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){return t.split(`
57
- `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}class Li extends te{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 Y(this.generateMessage()).pipe(q(t=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n}=this.params.config,u=this.params.config["max-length"],o=this.params.stagedDiff.diff,s=this.buildPrompt(t,o,r,u,n);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:a}=await this.getConversationInfo(i),f=await this.sendMessage(i,s,a);return await this.deleteConversation(i),ne(this.sanitizeMessage(f))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){const r=/{[^{}]*}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");let u=null;if(n.forEach((o,s)=>{try{const i=JSON.parse(o);j(i,"type")&&i.type==="finalAnswer"&&(u=i)}catch{}}),!u||!j(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 O({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 O({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 O({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 n=(await new O({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(!n||!n.nodes||n.nodes.length===0)throw new Error("No Nodes on conversation info");if(!n.nodes[1]||!n.nodes[1].data||n.nodes[1].data.length===0||!n.nodes[1].data[3])throw new Error("No data on node");const s=n.nodes[1]?.data[3];return{conversationInfo:n,lastMessageId:s}}async deleteConversation(t){return await new O({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new O({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,r,n){return(await new O({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:n,inputs:r,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}const ji=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r};class Gi extends te{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return K({name:`${this.errorPrefix} ${n}`,value:n,isError:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return Y(this.generateMessage()).pipe(q(t=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:u}=this.params.config,o=this.params.config["max-length"],s=this.buildPrompt(r,t,n,o,u);await this.checkAvailableModels();const i=await this.createChatCompletions(s);return ne(this.sanitizeMessage(i))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new O({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new O({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:ji(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}sanitizeMessage(t){return t.split(`
59
- `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}class Hi extends te{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
60
- `)[0];const u=this.extractJSONFromError(r.message);n+=`: ${u.error.message}`}return K({name:`${this.errorPrefix} ${n}`,value:n,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 Y(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=>T(t)),N(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),z(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(u=>JSON.parse(u))):{error:{message:"Unknown error"}}}}class Jr{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return T(t).pipe(mn(r=>{const n={config:this.config,stagedDiff:this.stagedDiff};switch(r){case L.OPEN_AI:return ee.create(Hi,n).generateCommitMessage$();case L.GEMINI:return ee.create(ki,n).generateCommitMessage$();case L.ANTHROPIC:return ee.create(Pi,n).generateCommitMessage$();case L.HUGGING:return ee.create(Li,n).generateCommitMessage$();case L.CLOVA_X:return ee.create(Ri,n).generateCommitMessage$();case L.MISTRAL:return ee.create(Gi,n).generateCommitMessage$();default:const u=g.red.bold(`[${r}]`);return K({name:u+" Invalid AI type",value:"Invalid AI type",isError:!0})}}))}}const Zr=async()=>{const{stdout:e,failed:t}=await Q("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},$t=e=>`:(exclude)${e}`,Qr=["package-lock.json","pnpm-lock.yaml","*.lock"].map($t),en=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await Q("git",[...t,"--name-only",...Qr,...e?e.map($t):[]]);if(!r)return null;const{stdout:n}=await Q("git",[...t,...Qr,...e?e.map($t):[]]);return{files:r.split(`
61
- `),diff:n}},Ui=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ie{constructor(){this.title="aicommit2"}printTitle(){console.log(In.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(`${Ui(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
55
+ `,At=(e,t)=>{const r=[];let n="";typeof t=="string"?t={section:t,whitespace:!1}:(t=t||Object.create(null),t.whitespace=t.whitespace===!0);const o=t.whitespace?" = ":"=";for(const u of Object.keys(e)){const s=e[u];if(s&&Array.isArray(s))for(const i of s)n+=oe(u+"[]")+o+oe(i)+$e;else s&&typeof s=="object"?r.push(u):n+=oe(u)+o+oe(s)+$e}t.section&&n.length&&(n="["+oe(t.section)+"]"+$e+n);for(const u of r){const s=zr(u).join("\\."),i=(t.section?t.section+".":"")+s,{whitespace:a}=t,f=At(e[u],{section:i,whitespace:a});n.length&&f.length&&(n+=$e),n+=f}return n},zr=e=>e.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(t=>t.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")),Yr=e=>{const t=Object.create(null);let r=t,n=null;const o=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,u=e.split(/[\r\n]+/g);for(const i of u){if(!i||i.match(/^\s*[;#]/))continue;const a=i.match(o);if(!a)continue;if(a[1]!==void 0){if(n=xe(a[1]),n==="__proto__"){r=Object.create(null);continue}r=t[n]=t[n]||Object.create(null);continue}const f=xe(a[2]),l=f.length>2&&f.slice(-2)==="[]",D=l?f.slice(0,-2):f;if(D==="__proto__")continue;const c=a[3]?xe(a[4]):!0,p=c==="true"||c==="false"||c==="null"?JSON.parse(c):c;l&&(bt.call(r,D)?Array.isArray(r[D])||(r[D]=[r[D]]):r[D]=[]),Array.isArray(r[D])?r[D].push(p):r[D]=p}const s=[];for(const i of Object.keys(t)){if(!bt.call(t,i)||typeof t[i]!="object"||Array.isArray(t[i]))continue;const a=zr(i);r=t;const f=a.pop(),l=f.replace(/\\\./g,".");for(const D of a)D!=="__proto__"&&((!bt.call(r,D)||typeof r[D]!="object")&&(r[D]=Object.create(null)),r=r[D]);r===t&&l===f||(r[l]=t[i],s.push(i))}for(const i of s)delete t[i];return t},Wr=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),oe=e=>typeof e!="string"||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&Wr(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),xe=(e,t)=>{if(e=(e||"").trim(),Wr(e)){e.charAt(0)==="'"&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let r=!1,n="";for(let o=0,u=e.length;o<u;o++){const s=e.charAt(o);if(r)"\\;#".indexOf(s)!==-1?n+=s:n+="\\"+s,r=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?r=!0:n+=s}}return r&&(n+="\\"),n.trim()}return e};var Ti={parse:Yr,decode:Yr,stringify:At,encode:At,safe:oe,unsafe:xe},Vr=J(Ti);const Xr=e=>O.lstat(e).then(()=>!0,()=>!1),_i=["","conventional","gitmoji"],{hasOwnProperty:Ni}=Object.prototype,Y=(e,t)=>Ni.call(e,t),E=(e,t,r)=>{if(!t)throw new y(`Invalid config property ${e}: ${r}`)},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-2.0","claude-instant-1.2"].includes(e),"Invalid model type of Anthropic"),e)},ANTHROPIC_KEY(e){return e||""},MISTRAL_KEY(e){return e||""},MISTRAL_MODEL(e){return!e||e.length===0?"mistral-tiny":(E("MISTRAL_MODEL",["open-mistral-7b","mistral-tiny-2312","mistral-tiny","open-mixtral-8x7b","mistral-small-2312","mistral-small","mistral-small-2402","mistral-small-latest","mistral-medium-latest","mistral-medium-2312","mistral-medium","mistral-large-latest","mistral-large-2402","mistral-embed"].includes(e),"Invalid model type of Mistral AI"),e)},OLLAMA_MODEL(e){return e||""},OLLAMA_HOST(e){return e||"http://localhost:11434"},OLLAMA_TIMEOUT(e){if(!e)return 1e5;E("OLLAMA_TIMEOUT",/^\d+$/.test(e),"Must be an integer");const t=Number(e);return E("OLLAMA_TIMEOUT",t>=500,"Must be greater than 500ms"),t},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=X.join(Rt.homedir(),".aicommit2"),Jr=async()=>{if(!await Xr(vt))return Object.create(null);const t=await O.readFile(vt,"utf8");return Vr.parse(t)},Bt=async(e,t)=>{const r=await Jr(),n={};for(const o of Object.keys(Oe)){const u=Oe[o],s=e?.[o]??r[o];if(t)try{n[o]=u(s)}catch{}else n[o]=u(s)}return n},Ri=async e=>{const t=await Jr();for(const[r,n]of e){if(!Y(Oe,r))throw new y(`Invalid config property: ${r}`);const o=Oe[r](n);t[r]=o}await O.writeFile(vt,Vr.stringify(t),"utf8")};class x{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=On.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 Li extends q{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 G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,s=this.buildPrompt(t,u,r,o,n);await this.getAllConversationIds();const i=await this.sendMessage(s),{conversationId:a,allText:f}=this.parseSendMessageResult(i);return await this.deleteConversation(a),z(this.sanitizeMessage(f))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async getAllConversationIds(){const r=(await new x({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(!r||!r.content)throw new Error("No content on conversations ClovaX");return r.content.length===0?[]:r.content.map(o=>o.conversationId||"").filter(o=>!!o)}async sendMessage(t){const r={text:t,action:"new"},n=new $n;return n.set("form",new xn([JSON.stringify(r)],{type:"application/json"})),(await new x({method:"POST",baseURL:`${this.host}/api/v1/generate`,timeout:this.params.config.timeout}).setHeaders({"Content-Type":"multipart/form-data","Content-Length":this.getContentLength(n),Cookie:this.cookie}).setBody(n).execute()).data}parseSendMessageResult(t){const r=/data:{(.*)}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");const o=n.map(a=>a.trim().replace(/data:/g,""));if(!o||o.length===0)throw new Error("Cannot extract message");let u="",s="",i="";if(o.map(a=>{try{return JSON.parse(a)}catch{return null}}).filter(a=>!!a).forEach(a=>{if(Y(a,"conversationId")){u=a.conversationId;return}if(Y(a,"text")){s+=a.text;return}if(Y(a,"error")){i=`${a.error}: ${a.type||a.message||""}`;return}}),i)throw new Error(i);if(!u)throw new Error("No conversationId!");if(!s)throw new Error("No allText!");return{conversationId:u,allText:s}}sanitizeMessage(t){return t.split(`
56
+ `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}async deleteConversation(t){return(await new x({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(),([r,n])=>({[r]:{ContentLength:typeof n=="string"?n.length:n.size}}))}}class ki extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{const n=r.message||r.toString(),o=/(\[.*?\]\s*[^[]*)/g,u=[...n.matchAll(o)],s=[];u.forEach(a=>s.push(a[1]));const i=s[1]||"An error occurred";return _({name:`${this.errorPrefix} ${i}`,value:i,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 In(this.params.config.GEMINI_KEY)}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,u=this.params.config["max-length"],s=this.buildPrompt(r,t,n,u,o),i=this.params.config["max-tokens"],D=(await(await this.genAI.getGenerativeModel({model:this.params.config.GEMINI_MODEL,generationConfig:{maxOutputTokens:i,temperature:this.params.config.temperature}}).generateContent(s)).response).text();return z(this.sanitizeMessage(D))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){return t.split(`
57
+ `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}class ji extends q{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 G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const{locale:t,generate:r,type:n}=this.params.config,o=this.params.config["max-length"],u=this.params.stagedDiff.diff,s=this.buildPrompt(t,u,r,o,n);await this.prepareNewConversation();const{conversationId:i}=await this.getNewConversationId();await this.prepareConversationEvent(i);const{lastMessageId:a}=await this.getConversationInfo(i),f=await this.sendMessage(i,s,a);return await this.deleteConversation(i),z(this.sanitizeMessage(f))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}sanitizeMessage(t){const r=/{[^{}]*}/g,n=t.match(r);if(!n)throw new Error("Failed to extract object from generated text");let o=null;if(n.forEach((u,s)=>{try{const i=JSON.parse(u);Y(i,"type")&&i.type==="finalAnswer"&&(o=i)}catch{}}),!o||!Y(o,"text"))throw new Error("Cannot parse finalAnswer");return o.text.split(`
58
+ `).map(u=>u.trim().replace(/^\d+\.\s/,"")).map(u=>u.replace(/`/g,"")).map(u=>this.extractCommitMessageFromRawText(this.params.config.type,u)).filter(u=>!!u)}async prepareNewConversation(){return(await new x({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 x({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 x({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 n=(await new x({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(!n||!n.nodes||n.nodes.length===0)throw new Error("No Nodes on conversation info");if(!n.nodes[1]||!n.nodes[1].data||n.nodes[1].data.length===0||!n.nodes[1].data[3])throw new Error("No data on node");const s=n.nodes[1]?.data[3];return{conversationInfo:n,lastMessageId:s}}async deleteConversation(t){return await new x({method:"DELETE",baseURL:`${this.host}/chat/conversation/${t}`,timeout:this.params.config.timeout}).setHeaders({Cookie:this.cookie}).execute(),(await new x({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,r,n){return(await new x({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:n,inputs:r,is_continue:!1,is_retry:!1,use_cache:!1}).execute()).data}}const Gi=(e,t)=>{const r=Math.ceil(e),n=Math.floor(t);return Math.floor(Math.random()*(n-r+1))+r};class Hi extends q{constructor(t){super(t),this.params=t,this.host="https://api.mistral.ai",this.apiKey="",this.handleError$=r=>{const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return _({name:`${this.errorPrefix} ${n}`,value:n,isError:!0})},this.colors={primary:"#FC4A0A",secondary:"#fff"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[MistralAI]"),this.errorPrefix=g.red.bold("[MistralAI]"),this.apiKey=this.params.config.MISTRAL_KEY}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,u=this.params.config["max-length"],s=this.buildPrompt(r,t,n,u,o);await this.checkAvailableModels();const i=await this.createChatCompletions(s);return z(this.sanitizeMessage(i))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.MISTRAL_MODEL))return!0;throw new Error("Invalid model type of Mistral AI")}async getAvailableModels(){return(await new x({method:"GET",baseURL:`${this.host}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(r=>r.object==="model").map(r=>r.id)}async createChatCompletions(t){const n=(await new x({method:"POST",baseURL:`${this.host}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody({model:this.params.config.MISTRAL_MODEL,messages:[{role:"user",content:t}],temperature:this.params.config.temperature,top_p:1,max_tokens:this.params.config["max-tokens"],stream:!1,safe_prompt:!1,random_seed:Gi(10,1e3)}).execute()).data;if(!n.choices||n.choices.length===0||!n.choices[0].message?.content)throw new Error("No Content on response. Please open a Bug report");return n.choices[0].message.content}sanitizeMessage(t){return t.split(`
59
+ `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}class Ui extends q{constructor(t){super(t),this.params=t,this.host="http://localhost:11434",this.model="",this.handleError$=r=>{if(r.response.data?.error)return _({name:`${this.errorPrefix} ${r.response.data?.error}`,value:r.response.data?.error,isError:!0});const n=r.message?.replace(/(\r\n|\n|\r)/gm,"")||"An error occurred";return _({name:`${this.errorPrefix} ${n}`,value:n,isError:!0})},this.colors={primary:"#FFF",secondary:"#000"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold("[Ollama]"),this.errorPrefix=g.red.bold("[Ollama]"),this.model=this.params.config.OLLAMA_MODEL,this.host=this.params.config.OLLAMA_HOST||"http://localhost:11434"}generateCommitMessage$(){return G(this.generateMessage()).pipe(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}async generateMessage(){try{const t=this.params.stagedDiff.diff,{locale:r,generate:n,type:o}=this.params.config,u=this.params.config["max-length"],s=this.buildPrompt(r,t,n,u,o);await this.checkIsAvailableOllama();const i=await this.createChatCompletions(s);return z(this.sanitizeMessage(i))}catch(t){const r=t;throw r.code==="ENOTFOUND"?new y(`Error connecting to ${r.hostname} (${r.syscall})`):r}}async checkIsAvailableOllama(){try{return(await new x({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.OLLAMA_TIMEOUT}).execute()).data}catch(t){throw t.code==="ECONNREFUSED"?new y(`Error connecting to ${this.host}. Please run Ollama or check host`):t}}async createChatCompletions(t){return(await new x({method:"POST",baseURL:`${this.host}/api/generate`,timeout:this.params.config.OLLAMA_TIMEOUT}).setBody({model:this.params.config.OLLAMA_MODEL,prompt:t,stream:!1,options:{temperature:this.params.config.temperature,top_p:1}}).execute()).data.response}sanitizeMessage(t){return t.split(`
60
+ `).map(r=>r.trim().replace(/^\d+\.\s/,"")).map(r=>r.replace(/`/g,"")).map(r=>this.extractCommitMessageFromRawText(this.params.config.type,r)).filter(r=>!!r)}}class Ki extends q{constructor(t){super(t),this.params=t,this.handleError$=r=>{let n="An error occurred";if(r.message){n=r.message.split(`
61
+ `)[0];const o=this.extractJSONFromError(r.message);n+=`: ${o.error.message}`}return _({name:`${this.errorPrefix} ${n}`,value:n,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 G(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(k(t=>N(t)),R(t=>({name:`${this.serviceName} ${t}`,value:t,isError:!1})),j(this.handleError$))}extractJSONFromError(t){const r=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,n=t.match(r);return n?Object.assign({},...n.map(o=>JSON.parse(o))):{error:{message:"Unknown error"}}}}class Zr{constructor(t,r){this.config=t,this.stagedDiff=r}createAIRequests$(t){return N(t).pipe(hn(r=>{const n={config:this.config,stagedDiff:this.stagedDiff};switch(r){case L.OPEN_AI:return K.create(Ki,n).generateCommitMessage$();case L.GEMINI:return K.create(ki,n).generateCommitMessage$();case L.ANTHROPIC:return K.create(Pi,n).generateCommitMessage$();case L.HUGGING:return K.create(ji,n).generateCommitMessage$();case L.CLOVA_X:return K.create(Li,n).generateCommitMessage$();case L.MISTRAL:return K.create(Hi,n).generateCommitMessage$();case L.OLLAMA:return K.create(Ui,n).generateCommitMessage$();default:const o=g.red.bold(`[${r}]`);return _({name:o+" Invalid AI type",value:"Invalid AI type",isError:!0})}}))}}const Qr=async()=>{const{stdout:e,failed:t}=await re("git",["rev-parse","--show-toplevel"],{reject:!1});if(t)throw new y("The current directory must be a Git repository!");return e},$t=e=>`:(exclude)${e}`,en=["package-lock.json","pnpm-lock.yaml","*.lock"].map($t),tn=async e=>{const t=["diff","--cached","--diff-algorithm=minimal"],{stdout:r}=await re("git",[...t,"--name-only",...en,...e?e.map($t):[]]);if(!r)return null;const{stdout:n}=await re("git",[...t,...en,...e?e.map($t):[]]);return{files:r.split(`
62
+ `),diff:n}},qi=e=>`Detected ${e.length.toLocaleString()} staged file${e.length>1?"s":""}`;class Ie{constructor(){this.title="aicommit2"}printTitle(){console.log(Mn.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(`${qi(t.files)}:`)),console.log(`${t.files.map(r=>` ${r}`).join(`
62
63
  `)}
63
64
  `)}printAnalyzed(){console.log(`
64
65
  ${g.bold.green("\u2714")} ${g.bold("Changes analyzed")}`)}printCommitted(){console.log(`
@@ -66,14 +67,14 @@ ${g.bold.green("\u2714")} ${g.bold("Successfully committed!")}`)}printCopied(){c
66
67
  ${g.bold.green("\u2714")} ${g.bold("Successfully copied! Press 'Ctrl + V' to paste")}`)}printSavedCommitMessage(){console.log(`
67
68
  ${g.bold.green("\u2714")} ${g.bold("Saved commit message")}`)}printCancelledCommit(){console.log(`
68
69
  ${g.bold.yellow("\u26A0")} ${g.yellow("Commit cancelled")}`)}printErrorMessage(t){console.log(`
69
- ${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 Ki={isLoading:!1,startOption:{text:"AI is analyzing your changes"}};class qi{constructor(){this.choices$=new Tt([]),this.loader$=new Tt(Ki),this.destroyed$=new hn(1)}initPrompt(){return Te.registerPrompt("reactiveListPrompt",Sn),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:r,value:n,isError:u}=t;if(!t||!n)return;const o=this.choices$.getValue();this.choices$.next([...o,{name:r,value:n,disabled:u,isError:u}])}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.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 zi=async(e,t,r,n,u,o,s,i)=>(async()=>{P.printTitle(),await Zr(),n&&await Q("git",["add","--update"]);const a=P.displaySpinner("Detecting staged files"),f=await en(r);if(a.stop(),!f)throw new y("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])=>Mr.includes(A)).filter(([A,M])=>!!M).map(([A])=>A);if(c.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const d=new Jr(D,f),m=new qi,h=m.initPrompt();m.startLoader();const C=d.createAIRequests$(c).subscribe(A=>m.refreshChoices(A),()=>{},()=>m.checkErrorOnChoices()),w=await h;C.unsubscribe(),m.completeSubject(),P.moveCursorUp();const $=w.aicommit2Prompt?.value;if(!$)throw new y("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 Q("git",["commit","-m",$,...i]),A.stop(),A.clear(),P.printCommitted(),process.exit()}const G=await Te.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:S}=G;if(S){const A=Ne("Committing with the generated message").start();await Q("git",["commit","-m",$,...i]),A.stop(),A.clear(),P.printCommitted(),process.exit()}P.printCancelledCommit(),process.exit()})().catch(a=>{P.printErrorMessage(a.message),ve(a),process.exit(1)}),Yi=nr({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await Bt({},!0);for(const u of r)j(n,u)&&console.log(`${u}=${n[u]}`);return}if(t==="set"){await Ni(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ie().printErrorMessage(t.message),ve(t),process.exit(1)})});const tn="prepare-commit-msg",rn=`.git/hooks/${tn}`,Se=An(new URL("cli.mjs",import.meta.url)),Wi=process.argv[1].replace(/\\/g,"/").endsWith(`/${rn}`),nn=process.platform==="win32",un=`
70
+ ${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 zi={isLoading:!1,startOption:{text:"AI is analyzing your changes"}},xt="No commit messages were generated";class Yi{constructor(){this.choices$=new Nt([]),this.loader$=new Nt(zi),this.destroyed$=new gn(1)}initPrompt(){return _e.registerPrompt("reactiveListPrompt",Sn),_e.prompt({type:"reactiveListPrompt",name:"aicommit2Prompt",message:"Pick a commit message to use: ",emptyMessage:`\u26A0 ${xt}`,choices$:this.choices$,loader$:this.loader$})}startLoader(){this.loader$.next({isLoading:!0})}refreshChoices(t){const{name:r,value:n,isError:o}=t;if(!t||!n)return;const u=this.choices$.getValue();this.choices$.next([...u,{name:r,value:n,disabled:o,isError:o}])}checkErrorOnChoices(){if(this.choices$.getValue().map(r=>r).every(r=>r?.isError||r?.disabled)){this.alertNoGeneratedMessage(),this.logEmptyCommitMessage(),process.exit(1);return}this.stopLoaderOnSuccess()}completeSubject(){this.choices$.complete(),this.loader$.complete(),this.destroyed$.next(!0),this.destroyed$.complete()}alertNoGeneratedMessage(){this.loader$.next({isLoading:!1,message:xt,stopOption:{doneFrame:"\u26A0",color:"yellow"}})}stopLoaderOnSuccess(){this.loader$.next({isLoading:!1,message:"Changes analyzed"})}logEmptyCommitMessage(){console.log(`${g.bold.yellow("\u26A0")} ${g.yellow(`${xt}`)}`)}}const S=new Ie;var Wi=async(e,t,r,n,o,u,s,i)=>(async()=>{S.printTitle(),await Qr(),n&&await re("git",["add","--update"]);const a=S.displaySpinner("Detecting staged files"),f=await tn(r);if(a.stop(),!f)throw new y("No staged changes found. Stage your changes manually, or automatically stage all changes with the `--all` flag.");S.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:o?.toString()||l.type,locale:e?.toString()||l.locale}),c=Object.entries(D).filter(([A])=>Tr.includes(A)).filter(([A,P])=>!!P).map(([A])=>A);if(c.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const d=new Zr(D,f),m=new Yi,h=m.initPrompt();m.startLoader();const C=d.createAIRequests$(c).subscribe(A=>m.refreshChoices(A),()=>{},()=>m.checkErrorOnChoices()),w=await h;C.unsubscribe(),m.completeSubject(),S.moveCursorUp();const $=w.aicommit2Prompt?.value;if(!$)throw new y("An error occurred! No selected message");if(s&&(Qo("copy-paste").copy($),S.printCopied(),process.exit()),u){const A=Ne("Committing with the generated message").start();await re("git",["commit","-m",$,...i]),A.stop(),A.clear(),S.printCommitted(),process.exit()}const W=await _e.prompt([{type:"confirm",name:"confirmationPrompt",message:"Use selected message?",default:!0}]),{confirmationPrompt:M}=W;if(M){const A=Ne("Committing with the generated message").start();await re("git",["commit","-m",$,...i]),A.stop(),A.clear(),S.printCommitted(),process.exit()}S.printCancelledCommit(),process.exit()})().catch(a=>{S.printErrorMessage(a.message),ve(a),process.exit(1)}),Vi=or({name:"config",parameters:["<mode>","<key=value...>"]},e=>{(async()=>{const{mode:t,keyValue:r}=e._;if(t==="get"){const n=await Bt({},!0);for(const o of r)Y(n,o)&&console.log(`${o}=${n[o]}`);return}if(t==="set"){await Ri(r.map(n=>n.split("=")));return}throw new y(`Invalid mode: ${t}`)})().catch(t=>{new Ie().printErrorMessage(t.message),ve(t),process.exit(1)})});const rn="prepare-commit-msg",nn=`.git/hooks/${rn}`,Me=vn(new URL("cli.mjs",import.meta.url)),Xi=process.argv[1].replace(/\\/g,"/").endsWith(`/${nn}`),on=process.platform==="win32",un=`
70
71
  #!/usr/bin/env node
71
- import(${JSON.stringify(vn(Se))})
72
- `.trim();var Vi=nr({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Zr(),{installUninstall:r}=e._,n=U.join(t,rn),u=await Vr(n);if(r==="install"){if(u){if(await x.realpath(n).catch(()=>{})===Se){console.warn("The hook is already installed");return}throw new y(`A different ${tn} hook seems to be installed. Please remove it before installing aicommit2.`)}await x.mkdir(U.dirname(n),{recursive:!0}),nn?await x.writeFile(n,un):(await x.symlink(Se,n,"file"),await x.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!u){console.warn("Hook is not installed");return}if(nn){if(await x.readFile(n,"utf8")!==un){console.warn("Hook is not installed");return}}else if(await x.realpath(n)!==Se){console.warn("Hook is not installed");return}await x.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),ve(t),process.exit(1)})});const[xt,Xi]=process.argv.slice(2);var Ji=()=>(async()=>{if(!xt)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Xi)return;const e=await en();if(!e)return;const t=new Ie;t.printTitle();const{env:r}=process,n=await Bt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),u=Object.entries(n).filter(([p])=>Mr.includes(p)).filter(([p,d])=>!!d).map(([p])=>p);if(u.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const s=new Jr(n,e),i=t.displaySpinner("The AI is analyzing your changes");let a;try{a=await gn(s.createAIRequests$(u).pipe(Cn(p=>!p.isError),N(p=>p.value),Fn()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const l=await x.readFile(xt,"utf8")!=="",D=a.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${D?"s":""}
72
+ import(${JSON.stringify(Bn(Me))})
73
+ `.trim();var Ji=or({name:"hook",parameters:["<install/uninstall>"]},e=>{(async()=>{const t=await Qr(),{installUninstall:r}=e._,n=X.join(t,nn),o=await Xr(n);if(r==="install"){if(o){if(await O.realpath(n).catch(()=>{})===Me){console.warn("The hook is already installed");return}throw new y(`A different ${rn} hook seems to be installed. Please remove it before installing aicommit2.`)}await O.mkdir(X.dirname(n),{recursive:!0}),on?await O.writeFile(n,un):(await O.symlink(Me,n,"file"),await O.chmod(n,493)),console.log(`${g.green("\u2714")} Hook installed`);return}if(r==="uninstall"){if(!o){console.warn("Hook is not installed");return}if(on){if(await O.readFile(n,"utf8")!==un){console.warn("Hook is not installed");return}}else if(await O.realpath(n)!==Me){console.warn("Hook is not installed");return}await O.rm(n),console.log(`${g.green("\u2714")} Hook uninstalled`);return}throw new y(`Invalid mode: ${r}`)})().catch(t=>{console.error(`${g.red("\u2716")} ${t.message}`),ve(t),process.exit(1)})});const[Ot,Zi]=process.argv.slice(2);var Qi=()=>(async()=>{if(!Ot)throw new y('Commit message file path is missing. This file should be called from the "prepare-commit-msg" git hook');if(Zi)return;const e=await tn();if(!e)return;const t=new Ie;t.printTitle();const{env:r}=process,n=await Bt({proxy:r.https_proxy||r.HTTPS_PROXY||r.http_proxy||r.HTTP_PROXY}),o=Object.entries(n).filter(([p])=>Tr.includes(p)).filter(([p,d])=>!!d).map(([p])=>p);if(o.length===0)throw new y("Please set at least one API key via `aicommit2 config set OPENAI_KEY=<your token>`");const s=new Zr(n,e),i=t.displaySpinner("The AI is analyzing your changes");let a;try{a=await Cn(s.createAIRequests$(o).pipe(Fn(p=>!p.isError),R(p=>p.value),En()))}finally{i.stop(),i.clear(),t.printAnalyzed()}const l=await O.readFile(Ot,"utf8")!=="",D=a.length>1;let c="";l&&(c=`# \u{1F916} AI generated commit${D?"s":""}
73
74
  `),D?(l&&(c+=`# Select one of the following messages by uncommenting:
74
75
  `),c+=`
75
76
  ${a.map(p=>`# ${p}`).join(`
76
77
  `)}`):(l&&(c+=`# Edit the message below and commit:
77
78
  `),c+=`
78
79
  ${a[0]}
79
- `),await x.appendFile(xt,c),t.printSavedCommitMessage()})().catch(e=>{new Ie().printErrorMessage(e.message),ve(e),process.exit(1)});const on=process.argv.slice(2);Xu({name:"aicommit2",version:_r,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:[Yi,Vi],help:{description:Qs},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Wi){Ji();return}zi(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,on)},on);
80
+ `),await O.appendFile(Ot,c),t.printSavedCommitMessage()})().catch(e=>{new Ie().printErrorMessage(e.message),ve(e),process.exit(1)});const sn=process.argv.slice(2);Zo({name:"aicommit2",version:_r,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:[Vi,Ji],help:{description:ei},ignoreArgv:e=>e==="unknown-flag"||e==="argument"},e=>{if(Xi){Qi();return}Wi(e.flags.locale,e.flags.generate,e.flags.exclude,e.flags.all,e.flags.type,e.flags.confirm,e.flags.clipboard,sn)},sn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicommit2",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "A Reactive CLI that generates git commit messages with various AI",
5
5
  "keywords": [
6
6
  "cli",
@@ -19,7 +19,8 @@
19
19
  "claude",
20
20
  "gemini",
21
21
  "generative-ai",
22
- "mistral"
22
+ "mistral",
23
+ "ollama"
23
24
  ],
24
25
  "license": "MIT",
25
26
  "repository": "tak-bro/aicommit2",