@redreplier/cli 0.1.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 (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +438 -0
  3. package/dist/alert-ByDPHwjO.js +1 -0
  4. package/dist/api-Dcrz3Tbv.js +3 -0
  5. package/dist/auth-DYgYo6Le.js +1 -0
  6. package/dist/chunk-B_5Rb6Gi.js +1 -0
  7. package/dist/cli.js +4 -0
  8. package/dist/client-R8kBz1Ou.js +1 -0
  9. package/dist/color-BbAK7_Y7.js +1 -0
  10. package/dist/color-D6__4GPX.js +1 -0
  11. package/dist/completion-DueI7liE.js +81 -0
  12. package/dist/config-Bg2ls0gu.js +1 -0
  13. package/dist/config-DwEEtXDc.js +1 -0
  14. package/dist/config-_SbTs7a5.js +1 -0
  15. package/dist/doctor-BpYdCjDb.js +1 -0
  16. package/dist/errors-DZ-S25mn.js +1 -0
  17. package/dist/errors-Dkv23Z0t.js +1 -0
  18. package/dist/esm-CIPTesEn.js +19 -0
  19. package/dist/exit-codes-Dth9pkcT.js +1 -0
  20. package/dist/exit-codes-IaZq17dv.js +1 -0
  21. package/dist/http-Cwj8ofnO.js +1 -0
  22. package/dist/http-DpMu6AKn.js +2 -0
  23. package/dist/keyword-BjASkU-P.js +1 -0
  24. package/dist/keyword-DFHGBpip.js +1 -0
  25. package/dist/mcp-9bwQeg1V.js +3 -0
  26. package/dist/mention-Dv8hocI7.js +1 -0
  27. package/dist/open-_iWw6bFQ.js +1 -0
  28. package/dist/open-url-CovrlP9b.js +1 -0
  29. package/dist/output-CwNjSyRl.js +1 -0
  30. package/dist/output-uP7GrsdR.js +5 -0
  31. package/dist/product-CXL7Ga4M.js +1 -0
  32. package/dist/prompt-BMmbLZHM.js +1 -0
  33. package/dist/prompt-DR68wwvQ.js +45 -0
  34. package/dist/site-ChYUR_ES.js +1 -0
  35. package/dist/time-B5S7M7Dg.js +1 -0
  36. package/dist/types-Bu8scNHe.js +1 -0
  37. package/dist/update-check-BaOMxkuv.js +1 -0
  38. package/dist/update-check-DBvD8xG2.js +1 -0
  39. package/dist/version--HODInrs.js +1 -0
  40. package/dist/version-DwIEu3-z.js +1 -0
  41. package/package.json +69 -0
@@ -0,0 +1 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import{n as t}from"./errors-Dkv23Z0t.js";import{t as n}from"./product-CXL7Ga4M.js";import{basename as r,dirname as i,join as a}from"node:path";import{chmodSync as o,existsSync as s,mkdirSync as c,readFileSync as l,renameSync as u,rmSync as d,statSync as f,writeFileSync as ee}from"node:fs";import{randomBytes as te}from"node:crypto";import{homedir as p}from"node:os";function m(e){let t=e.trim();if(t===``)return``;let n=t.lastIndexOf(`_`),r=n>=0?n+1:0;return t.slice(0,Math.min(t.length,r+4))}function h(e){if(!e)return`…`;let t=m(e);return t.length>=e.length?t:`${t}…`}function g(){return{version:1,current:`default`,profiles:{}}}function _(){return s(N())}function v(){let e=N();if(s(e))return f(e).mode&511}function y(){if(process.platform===`win32`)return;let n=v();if(n===void 0||!(n&63))return;let r=N();throw new t(`${r} is readable by other users (mode ${n.toString(8).padStart(4,`0`)})`,{exitCode:e.AUTH,hint:`chmod 600 ${r}`})}function b(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=typeof t.token==`string`?t.token:void 0;if(!n)return;let r={token:n,tokenPrefix:typeof t.tokenPrefix==`string`?t.tokenPrefix:m(n),...typeof t.apiUrl==`string`?{apiUrl:t.apiUrl}:{},...typeof t.label==`string`?{label:t.label}:{},...typeof t.createdAt==`string`?{createdAt:t.createdAt}:{}};return t.type===`oauth`?{...r,type:`oauth`,refreshToken:typeof t.refreshToken==`string`?t.refreshToken:``,expiresAt:typeof t.expiresAt==`string`?t.expiresAt:``,authkitDomain:typeof t.authkitDomain==`string`?t.authkitDomain:``}:{...r,type:`token`}}function x(){let n=N();if(!s(n))return g();y();let r;try{r=JSON.parse(l(n,`utf8`))}catch(r){throw new t(`${n} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file, or start over with: rm ${n}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return g();let i=r,a={};for(let[e,t]of Object.entries(i.profiles??{})){let n=b(t);n&&(a[e]=n)}return{version:typeof i.version==`number`?i.version:1,current:typeof i.current==`string`&&i.current!==``?i.current:`default`,profiles:a}}function S(e){P(),F(N(),`${JSON.stringify(e,null,2)}\n`,384)}function C(e){return x().profiles[e]}function w(){let e=x();return Object.entries(e.profiles).map(([t,n])=>({name:t,current:t===e.current,profile:n}))}function ne(e,t,n={}){let r=x(),i=r.profiles[e],a={token:t.token,tokenPrefix:m(t.token),...t.apiUrl?{apiUrl:t.apiUrl}:i?.apiUrl?{apiUrl:i.apiUrl}:{},...t.label?{label:t.label}:i?.label?{label:i.label}:{},createdAt:i?.createdAt??new Date().toISOString()},o=t.type===`oauth`?{...a,type:`oauth`,refreshToken:t.refreshToken??``,expiresAt:t.expiresAt??``,authkitDomain:t.authkitDomain??``}:{...a,type:`token`};return r.profiles[e]=o,n.makeCurrent!==!1&&(r.current=e),S(r),o}function re(e){let t=x();return t.profiles[e]?(delete t.profiles[e],t.current===e&&(t.current=Object.keys(t.profiles)[0]??`default`),S(t),!0):!1}function ie(){let e=x(),t=Object.keys(e.profiles).length;return S(g()),t}const ae=1,T=[`en`,`fr`,`de`,`es`,`pt`];let E={};function D(e){E={...e}}function O(){return E}function k(e){return`${n.envPrefix}_${e}`}function A(e){let t=process.env[k(e)];if(t===void 0)return;let n=t.trim();return n===``?void 0:n}function j(){if(process.platform===`win32`){let e=process.env.APPDATA?.trim();if(e)return a(e,n.displayName)}let e=process.env.XDG_CONFIG_HOME?.trim();return a(e&&e!==``?e:a(p(),`.config`),n.id)}function M(){return a(j(),`config.json`)}function N(){return a(j(),`credentials.json`)}function P(){let e=j();return c(e,{recursive:!0,mode:448}),e}function F(n,s,l){let f=i(n);c(f,{recursive:!0,mode:448});let p=a(f,`.${r(n)}.${process.pid}.${te(6).toString(`hex`)}.tmp`);try{ee(p,s,{mode:l}),o(p,l),u(p,n)}catch(r){throw d(p,{force:!0}),new t(`Could not write ${n}: ${r.message}`,{exitCode:e.GENERIC,cause:r})}}function I(){return{version:1,profiles:{}}}function L(){let n=M();if(!s(n))return I();let r;try{r=JSON.parse(l(n,`utf8`))}catch(r){throw new t(`${n} is not valid JSON`,{exitCode:e.GENERIC,hint:`Fix the file or delete it: rm ${n}`,cause:r})}if(!r||typeof r!=`object`||Array.isArray(r))return I();let i=r,a=i.profiles&&typeof i.profiles==`object`?i.profiles:{};return{...i,version:i.version??1,profiles:a}}function R(e){P(),F(M(),`${JSON.stringify(e,null,2)}\n`,420)}function z(e){let t=L();return e(t),R(t),t}function B(n){return r=>{let i=r.trim().toLowerCase();if([`true`,`1`,`yes`,`on`].includes(i))return!0;if([`false`,`0`,`no`,`off`].includes(i))return!1;throw new t(`${n} must be true or false, got "${r}"`,{exitCode:e.USAGE})}}function V(n){let r=n.trim();try{new Intl.DateTimeFormat(`en-US`,{timeZone:r})}catch{throw new t(`"${r}" is not an IANA timezone`,{exitCode:e.USAGE,hint:`Use a name such as Europe/Berlin or America/New_York`})}return r}function H(e){return e.split(`,`).map(e=>e.trim().toUpperCase()).filter(e=>e!==``)}function U(n){return r=>{let i=r.trim();if(i===``)throw new t(`${n} cannot be empty`,{exitCode:e.USAGE});return i}}function W(e){return e==null?``:Array.isArray(e)?e.join(`,`):String(e)}const G={updateCheck:{key:`updateCheck`,scope:`global`,products:`all`,description:`Check npm for a newer CLI once a day`,parse:B(`updateCheck`),format:W},language:{key:`language`,scope:`global`,products:`all`,description:`Value of the x-language header (${T.join(` `)})`,parse:n=>{let r=n.trim().toLowerCase();if(!T.includes(r))throw new t(`language must be one of ${T.join(`, `)}, got "${n}"`,{exitCode:e.USAGE});return r},format:W},timezone:{key:`timezone`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --timezone`,parse:V,format:W},defaultPlatforms:{key:`defaultPlatforms`,scope:`profile`,products:[`adaptlypost`],description:`Default value for --platform, comma separated`,parse:H,format:W},defaultSite:{key:`defaultSite`,scope:`profile`,products:[`redreplier`],description:`Default value for --site`,parse:U(`defaultSite`),format:W},defaultWebsite:{key:`defaultWebsite`,scope:`profile`,products:[`flowsery`],description:`Default website for reporting commands`,parse:U(`defaultWebsite`),format:W},workspaceId:{key:`workspaceId`,scope:`profile`,products:`all`,description:`Workspace this profile talks to`,parse:U(`workspaceId`),format:W}};function K(e){return e.products===`all`||e.products.includes(n.id)}function q(){return Object.values(G).filter(K)}function J(n){let r=G[n];if(!r||!K(r))throw new t(`Unknown config key "${n}"`,{exitCode:e.USAGE,hint:`Known keys: ${q().map(e=>e.key).join(`, `)}`});return r}function oe(e,t){let n=J(e),r=L();if(n.scope===`global`)return r[n.key];let i=t??Z();return r.profiles[i]?.[n.key]}function Y(e,t,n){let r=J(e),i=r.parse(t),a=n??Z();return z(e=>{if(r.scope===`global`){e[r.key]=i;return}let t=e.profiles[a]??{};t[r.key]=i,e.profiles[a]=t}),i}function se(e,t){let n=J(e),r=t??Z(),i=!1;return z(e=>{if(n.scope===`global`){i=e[n.key]!==void 0,delete e[n.key];return}let t=e.profiles[r];t&&(i=t[n.key]!==void 0,delete t[n.key])}),i}function ce(e){let t=e??Z(),n=L();return{profile:t,entries:q().map(e=>({key:e.key,scope:e.scope,description:e.description,value:e.scope===`global`?n[e.key]:n.profiles[t]?.[e.key]}))}}function X(e){let t=e??Z();return L().profiles[t]??{}}function Z(e=E){let t=e.profile?.trim();if(t)return t;let n=A(`PROFILE`);if(n)return n;let r=x(),i=r.current?.trim();return i&&r.profiles[i]?i:i||`default`}function Q(e=E,t){let r=e.apiUrl?.trim();if(r)return{url:$(r,`--api-url`),source:`flag`};let i=A(`API_URL`);if(i)return{url:$(i,k(`API_URL`)),source:`env`};let a=t?.trim();return a?{url:$(a,`credentials.json apiUrl`),source:`credentials`}:{url:n.defaultApiUrl,source:`default`}}function $(n,r){let i;try{i=new URL(n)}catch{throw new t(`${r} is not a valid URL: ${n}`,{exitCode:e.USAGE})}if(i.protocol!==`https:`&&i.protocol!==`http:`)throw new t(`${r} must be an http or https URL: ${n}`,{exitCode:e.USAGE});return i.toString().replace(/\/+$/,``)}function le(e){switch(e){case`flag`:return`--token flag`;case`env-token`:return k(`API_TOKEN`);case`env-key`:return k(`API_KEY`);case`credentials`:return`credentials file`}}function ue(e){switch(e){case`flag`:return`--api-url flag`;case`env`:return k(`API_URL`);case`credentials`:return`credentials file`;case`default`:return`product default`}}function de(r=E){let i=Z(r),a=x().profiles[i],o=X(i),s=r.token?.trim(),c=A(`API_TOKEN`),l=A(`API_KEY`),u,d;if(s?(u=s,d=`flag`):c?(u=c,d=`env-token`):l?(u=l,d=`env-key`):(u=a?.token,d=`credentials`),!u)throw new t(`No API token for profile "${i}"`,{exitCode:e.AUTH,hint:`Run ${n.binName} login, or set ${k(`API_TOKEN`)}`});let f=A(`WORKSPACE_ID`)??(typeof o.workspaceId==`string`?o.workspaceId:void 0);return{name:i,token:u,tokenSource:d,apiUrl:Q(r,a?.apiUrl).url,...f?{workspaceId:f}:{},defaults:o}}function fe(n=E.lang){let r=n?.trim()??L().language;if(!r)return;let i=r.toLowerCase();if(!T.includes(i))throw new t(`--lang must be one of ${T.join(`, `)}, got "${r}"`,{exitCode:e.USAGE});return i}function pe(e=E.debug){if(e)return!0;let t=A(`DEBUG`);return t!==void 0&&t!==`0`&&t.toLowerCase()!==`false`}export{_ as A,Z as C,z as D,se as E,w as F,h as I,ne as L,ie as M,re as N,R as O,C as P,de as S,D as T,q as _,J as a,Q as b,ue as c,k as d,oe as f,$ as g,ce as h,j as i,v as j,F as k,le as l,pe as m,ae as n,M as o,O as p,T as r,N as s,G as t,P as u,X as v,Y as w,fe as x,L as y};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import{u as e}from"./errors-Dkv23Z0t.js";import{r as t}from"./color-BbAK7_Y7.js";import{c as n,f as r,g as i,i as a,p as o}from"./output-uP7GrsdR.js";import{C as s,E as c,a as l,f as u,h as d,o as f,s as p,t as m,w as h}from"./config-Bg2ls0gu.js";import{t as g}from"./product-CXL7Ga4M.js";const _=()=>s();function v(s){let v=s.command(`config`).description(`read and write CLI preferences`);v.command(`list`).alias(`ls`).description(`show every key and its value`).action(()=>{let e=_(),{entries:i}=d(e);o(`config.list`,{profile:e,entries:i}),n(` profile: ${e}`),r(i.map(e=>[e.key,e.value===void 0||e.value===null?t(`unset`):l(e.key).format(e.value)]))}),v.command(`get`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).description(`print one value`).action(t=>{let r=l(t),i=_(),a=u(t,i);if(a==null)throw e(`"${t}" is not set for profile "${i}".`,`${g.binName} config set ${t} <value>`);o(`config.get`,{key:t,value:a}),n(r.format(a))}),v.command(`set`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).argument(`<value>`,`new value`).description(`write one value`).action((e,t)=>{let n=l(e),r=_(),a=h(e,t,r);o(`config.set`,{key:e,value:a,scope:n.scope,profile:r}),i(`${e} = ${n.format(a)}`)}),v.command(`unset`).argument(`<key>`,`one of ${Object.keys(m).join(`, `)}`).description(`remove one value`).action(e=>{let t=_(),n=c(e,t);o(`config.unset`,{key:e,removed:n,profile:t}),n?i(`${e} removed`):a(`${e} was not set, nothing changed.`)}),v.command(`path`).description(`print the config and credentials file paths`).action(()=>{let e=f(),t=p();o(`config.path`,{config:e,credentials:t}),r([[`config`,e],[`credentials`,t]])})}export{v as registerConfigCommands};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"./config-Bg2ls0gu.js";import{t as k}from"./product-CXL7Ga4M.js";export{C as CONFIG_KEYS,v as CONFIG_VERSION,x as LANGUAGES,k as PRODUCT,m as configDir,s as configKey,y as configPath,S as credentialsPath,l as describeApiUrlSource,g as describeTokenSource,w as ensureConfigDir,u as envVar,d as getConfigValue,b as getGlobalOptions,_ as isDebugEnabled,p as listConfigValues,f as normalizeApiUrl,o as productConfigKeys,T as profileDefaults,O as readConfig,c as resolveApiUrl,D as resolveLanguage,i as resolveProfile,e as resolveProfileName,E as setConfigValue,a as setGlobalOptions,n as unsetConfigValue,t as updateConfig,r as writeConfig,h as writeFileAtomic};
@@ -0,0 +1 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import{i as t,r as n}from"./version--HODInrs.js";import{a as r,c as i,i as a,r as o}from"./color-BbAK7_Y7.js";import{c as s,d as c,o as l}from"./output-uP7GrsdR.js";import{A as u,I as d,S as f,b as p,c as m,i as h,j as g,l as _,o as v,p as y,s as b}from"./config-Bg2ls0gu.js";import{t as x}from"./product-CXL7Ga4M.js";import{a as S,o as C}from"./update-check-BaOMxkuv.js";import{statSync as w}from"node:fs";const T=`22.12.0`,E=(e,t,n,r=null)=>({id:e,status:t,detail:n,fix:r});function D(){let e=process.versions.node;return S(e,T)>=0?E(`node`,`pass`,`v${e} (>= ${T})`):E(`node`,`fail`,`v${e} is below ${T}`,`Install Node 22.12 or newer from https://nodejs.org`)}async function O(){let e;try{e=await C()}catch{return E(`cli`,`warn`,`${n} (could not reach the npm registry)`)}return e?S(e,n)>0?E(`cli`,`warn`,`${n} (${e} is published)`,`npm i -g ${x.npmPackage}`):E(`cli`,`pass`,`${n} (latest)`):E(`cli`,`warn`,`${n} (no published release to compare against)`)}function k(e){try{return w(e).mode&511}catch{return}}function A(){let e=h(),t=k(e);if(t===void 0)return E(`config dir`,`warn`,`${e} does not exist yet`,`${x.binName} login`);let n=t.toString(8).padStart(4,`0`);return process.platform!==`win32`&&t&63?E(`config dir`,`warn`,`${e} is mode ${n}`,`chmod 700 ${e}`):E(`config dir`,`pass`,`${e} (${n})`)}function j(){let e=v(),t=k(e);return t===void 0?E(`config file`,`warn`,`${e} does not exist yet`):E(`config file`,`pass`,`${e} (${t.toString(8).padStart(4,`0`)})`)}function M(){let e=b();if(!u())return E(`credentials`,`warn`,`${e} does not exist yet`,`${x.binName} login`);let t=g()??0,n=t.toString(8).padStart(4,`0`);return process.platform!==`win32`&&t&63?E(`credentials`,`fail`,`${e} is mode ${n}, other users can read your token`,`chmod 600 ${e}`):E(`credentials`,`pass`,`${e} (${n})`)}function N(){for(let e of[`HTTPS_PROXY`,`https_proxy`,`HTTP_PROXY`,`http_proxy`]){let t=process.env[e];if(t)return E(`proxy`,`warn`,`${e} is set to ${t}`)}return null}async function P(e,n){if(!n)return[E(`api`,`warn`,`skipped, no token to authenticate with`,`${x.binName} login`)];let r=Date.now(),i;try{i=await fetch(`${e}${x.verifyPath}`,{headers:{Authorization:`Bearer ${n}`,Accept:`application/json`,"User-Agent":t(x.id)},signal:AbortSignal.timeout(15e3)})}catch(t){return[E(`api`,`fail`,`${e} unreachable: ${t instanceof Error?t.message:String(t)}`,`Check your network, a proxy, or --api-url`)]}let a=Date.now()-r,o=[];i.status===401||i.status===403?o.push(E(`api`,`fail`,`${e} answered ${i.status}, the token was rejected`,`${x.binName} login`)):i.ok?o.push(E(`api`,`pass`,`${e} ${a} ms`)):o.push(E(`api`,`fail`,`${e} answered ${i.status}`));let s=Number(i.headers.get(`ratelimit-limit`)),c=Number(i.headers.get(`ratelimit-remaining`)),l=Number(i.headers.get(`ratelimit-reset`));if(i.headers.has(`ratelimit-limit`)&&Number.isFinite(s)&&Number.isFinite(c)){let e=Number.isFinite(l)?`, resets in ${l}s`:``;o.push(E(`rate limit`,c<=20?`warn`:`pass`,`${c} of ${s} left${e}`))}else o.push(E(`rate limit`,`warn`,`the API sent no RateLimit headers`));let u=i.headers.get(`date`);if(u){let e=Math.round((Date.now()-Date.parse(u))/1e3),t=Math.abs(e);o.push(t>60?E(`clock`,`fail`,`this machine is ${t}s ${e>0?`ahead of`:`behind`} the server`,`Turn on network time sync on this machine`):E(`clock`,`pass`,`${t}s from the server clock`))}else o.push(E(`clock`,`warn`,`the API sent no Date header`));return await i.arrayBuffer().catch(()=>void 0),o}async function F(e){try{let t=await fetch(`${e}/openapi.json`,{headers:{Accept:`application/json`},signal:AbortSignal.timeout(1e4)});return t.ok?E(`openapi`,`pass`,`reachable, version ${(await t.json()).info?.version??`unknown`}`):E(`openapi`,`warn`,`answered ${t.status}`)}catch{return E(`openapi`,`warn`,`not reachable`)}}const I={pass:`✓`,warn:`⚠`,fail:`✗`};function L(e,t){return e===`pass`?a(t):e===`warn`?i(t):r(t)}function R(t){t.command(`doctor`).description(`check this machine, the config files and the API`).action(async()=>{let t=y(),n=[D(),await O(),A(),j(),M()],r,i=p().url,a=`default`;try{let e=f();r=e.token,i=e.apiUrl,a=e.name,n.push(E(`token`,`pass`,`${d(e.token)} from ${_(e.tokenSource)}`))}catch(e){a=t.profile??a,n.push(E(`token`,`fail`,e instanceof Error?e.message:String(e),`${x.binName} login`))}n.push(E(`api url`,`pass`,`${i} (from ${m(p().source)})`)),n.push(...await P(i,r)),n.push(await F(i));let u=N();u&&n.push(u);let h=n.filter(e=>e.status===`fail`);if(l()){c({ok:h.length===0,command:`doctor`,data:{profile:a,checks:n}}),h.length>0&&(process.exitCode=e.GENERIC);return}let g=Math.max(...n.map(e=>e.id.length));for(let e of n)s(` ${L(e.status,I[e.status])} ${e.id.padEnd(g)} ${e.detail}`),e.fix&&s(` ${` `.repeat(g)} ${o(`fix: ${e.fix}`)}`);s(``),s(h.length===0?`No problems found.`:`${h.length} ${h.length===1?`problem`:`problems`} found.`),h.length>0&&(process.exitCode=e.GENERIC)})}export{R as registerDoctorCommand};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./errors-Dkv23Z0t.js";export{u as ApiError,o as CliError,c as exitCodeFor,i as flattenApiMessage,e as hintFor,s as isApiError,l as isCliError,t as messageFor,a as networkError,d as notFoundError,n as toErrorPayload,r as usageError};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./exit-codes-IaZq17dv.js";const n={0:`ok`,1:`error`,2:`usage_error`,3:`auth_error`,4:`not_found`,5:`validation_error`,6:`conflict`,7:`rate_limited`,8:`network_error`,9:`quota_exceeded`,130:`cancelled`};var r=class extends Error{exitCode;code;hint;details;constructor(e,r={}){super(e,r.cause===void 0?void 0:{cause:r.cause}),this.name=`CliError`,this.exitCode=r.exitCode??t.GENERIC,this.code=r.code??n[this.exitCode],this.hint=r.hint,this.details=r.details}},i=class extends Error{status;code;requestId;body;details;method;path;hint;exitCode;constructor(t){let n=a(t.body);super(t.message??n.message??`HTTP ${t.status}`,t.cause===void 0?void 0:{cause:t.cause}),this.name=`ApiError`,this.status=t.status,this.code=t.code??h(t.body)??y(t.status),this.requestId=t.requestId??_(t.body),this.body=t.body??null,this.details=n.details,this.method=t.method,this.path=t.path,this.hint=t.hint,this.exitCode=e(t.status)}};function a(e){if(typeof e==`string`){let t=e.trim();return{message:t===``?null:t,details:null}}if(!x(e))return{message:null,details:null};let t=e.message??e.error_description??e.detail;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`&&e.trim()!==``);if(e.length>0)return{message:e.join(`; `),details:e}}if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null};if(x(e.error)){let t=e.error.message;if(typeof t==`string`&&t.trim()!==``)return{message:t.trim(),details:null}}return typeof e.error==`string`&&e.error.trim()!==``?{message:e.error.trim(),details:null}:{message:null,details:null}}function o(e){return e instanceof r}function s(e){return e instanceof i}function c(e){return s(e)||o(e)?e.exitCode:b(e)||e instanceof TypeError&&/fetch failed|network|ENOTFOUND|ECONNREFUSED/i.test(e.message)?t.NETWORK:t.GENERIC}function l(e){if(o(e)||s(e))return e.hint}function u(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Unexpected error`}function d(e){return s(e)?{code:e.code,status:e.status,message:e.message,details:e.details??null}:o(e)?{code:e.code,status:null,message:e.message,details:e.details??null}:{code:n[c(e)],status:null,message:u(e),details:null}}function f(e,n){return new r(e,{exitCode:t.USAGE,hint:n})}function p(e,n){return new r(e,{exitCode:t.NOT_FOUND,hint:n})}function m(e,n,i){return new r(e,{exitCode:t.NETWORK,cause:n,hint:i})}function h(e){if(x(e)){if(typeof e.code==`string`&&e.code.trim()!==``)return e.code.trim();if(x(e.error)&&typeof e.error.code==`string`&&e.error.code.trim()!==``)return e.error.code.trim();if(typeof e.error==`string`){let t=g(e.error);if(t!==``)return t}}}function g(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,64)}function _(e){if(!x(e))return;let t=e.requestId??e.request_id??e.traceId;return typeof t==`string`&&t.trim()!==``?t.trim():void 0}const v={400:`bad_request`,401:`unauthorized`,402:`payment_required`,403:`forbidden`,404:`not_found`,405:`method_not_allowed`,408:`request_timeout`,409:`conflict`,410:`gone`,413:`payload_too_large`,415:`unsupported_media_type`,422:`unprocessable_entity`,429:`too_many_requests`,500:`internal_server_error`,502:`bad_gateway`,503:`service_unavailable`,504:`gateway_timeout`};function y(e){return v[e]??`http_${e}`}function b(e){return e instanceof Error?e.name===`AbortError`||e.name===`TimeoutError`:!1}function x(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{l as a,u as c,d,f,a as i,m as l,r as n,s as o,c as r,o as s,i as t,p as u};
@@ -0,0 +1,19 @@
1
+ import{n as e,r as t,t as n}from"./chunk-B_5Rb6Gi.js";var r=n((e=>{var t=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},n=class extends t{constructor(e){super(1,`commander.invalidArgument`,e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};e.CommanderError=t,e.InvalidArgumentError=n})),i=n((e=>{let{InvalidArgumentError:t}=r();var n=class{constructor(e,t){switch(this.description=t||``,this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case`<`:this.required=!0,this._name=e.slice(1,-1);break;case`[`:this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith(`...`)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function i(e){let t=e.name()+(e.variadic===!0?`...`:``);return e.required?`<`+t+`>`:`[`+t+`]`}e.Argument=n,e.humanReadableArgName=i})),a=n((e=>{let{humanReadableArgName:t}=i();var n=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let n=e=>e.short?e.short.replace(/^-/,``):e.long.replace(/^--/,``);return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),n=e._getHelpOption();if(n&&!n.hidden){let r=n.short&&e._findOption(n.short),i=n.long&&e._findOption(n.long);!r&&!i?t.push(n):n.long&&!i?t.push(e.createOption(n.long,n.description)):n.short&&!r&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let e=n.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||``}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){let n=e.registeredArguments.map(e=>t(e)).join(` `);return e._name+(e._aliases[0]?`|`+e._aliases[0]:``)+(e.options.length?` [options]`:``)+(n?` `+n:``)}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(n)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(n)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,n)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(n)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+`|`+e._aliases[0]);let n=``;for(let t=e.parent;t;t=t.parent)n=t.name()+` `+n;return n+t+` `+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==`boolean`)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(`, `)}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(`, `)})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,``]}groupItems(e,t,n){let r=new Map;return e.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[])}),t.forEach(e=>{let t=n(e);r.has(t)||r.set(t,[]),r.get(t).push(e)}),r}formatHelp(e,t){let n=t.padWidth(e,t),r=t.helpWidth??80;function i(e,r){return t.formatItem(e,n,r,t)}let a=[`${t.styleTitle(`Usage:`)} ${t.styleUsage(t.commandUsage(e))}`,``],o=t.commandDescription(e);o.length>0&&(a=a.concat([t.boxWrap(t.styleCommandDescription(o),r),``]));let s=t.visibleArguments(e).map(e=>i(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e))));if(a=a.concat(this.formatItemList(`Arguments:`,s,t)),this.groupItems(e.options,t.visibleOptions(e),e=>e.helpGroupHeading??`Options:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),t.showGlobalOptions){let n=t.visibleGlobalOptions(e).map(e=>i(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e))));a=a.concat(this.formatItemList(`Global Options:`,n,t))}return this.groupItems(e.commands,t.visibleCommands(e),e=>e.helpGroup()||`Commands:`).forEach((e,n)=>{let r=e.map(e=>i(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e))));a=a.concat(this.formatItemList(n,r,t))}),a.join(`
2
+ `)}displayWidth(e){return r(e).length}styleTitle(e){return e}styleUsage(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e===`[command]`?this.styleSubcommandText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleCommandText(e)).join(` `)}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(` `).map(e=>e===`[options]`?this.styleOptionText(e):e[0]===`[`||e[0]===`<`?this.styleArgumentText(e):this.styleSubcommandText(e)).join(` `)}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,r){let i=` `.repeat(2);if(!n)return i+e;let a=e.padEnd(t+e.length-r.displayWidth(e)),o=(this.helpWidth??80)-t-2-2,s;return s=o<this.minWidthToWrap||r.preformatted(n)?n:r.boxWrap(n,o).replace(/\n/g,`
3
+ `+` `.repeat(t+2)),i+a+` `.repeat(2)+s.replace(/\n/g,`\n${i}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach(e=>{let n=e.match(r);if(n===null){i.push(``);return}let a=[n.shift()],o=this.displayWidth(a[0]);n.forEach(e=>{let n=this.displayWidth(e);if(o+n<=t){a.push(e),o+=n;return}i.push(a.join(``));let r=e.trimStart();a=[r],o=this.displayWidth(r)}),i.push(a.join(``))}),i.join(`
4
+ `)}};function r(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,``)}e.Help=n,e.stripColor=r})),o=n((e=>{let{InvalidArgumentError:t}=r();var n=class{constructor(e,t){this.flags=e,this.description=t||``,this.required=e.includes(`<`),this.optional=e.includes(`[`),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=o(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith(`--no-`)),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e==`string`&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(`, `)}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,``):this.short.replace(/^-/,``)}attributeName(){return this.negate?a(this.name().replace(/^no-/,``)):a(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},i=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let r=this.negativeOptions.get(n).presetArg,i=r===void 0?!1:r;return t.negate===(i===e)}};function a(e){return e.split(`-`).reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function o(e){let t,n,r=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat(`guard`);if(r.test(a[0])&&(t=a.shift()),i.test(a[0])&&(n=a.shift()),!t&&r.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=n,n=a.shift()),a[0].startsWith(`-`)){let t=a[0],n=`option creation failed due to '${t}' in option flags '${e}'`;throw/^-[^-][^-]/.test(t)?Error(`${n}
5
+ - a short flag is a single dash and a single character
6
+ - either use a single dash and a single character (for a short flag)
7
+ - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):r.test(t)?Error(`${n}
8
+ - too many short flags`):i.test(t)?Error(`${n}
9
+ - too many long flags`):Error(`${n}
10
+ - unrecognised flag format`)}if(t===void 0&&n===void 0)throw Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:n}}e.Option=n,e.DualOptions=i})),s=n((e=>{function t(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=t.length;r++)for(let i=1;i<=e.length;i++){let a=1;a=e[i-1]===t[r-1]?0:1,n[i][r]=Math.min(n[i-1][r]+1,n[i][r-1]+1,n[i-1][r-1]+a),i>1&&r>1&&e[i-1]===t[r-2]&&e[i-2]===t[r-1]&&(n[i][r]=Math.min(n[i][r],n[i-2][r-2]+1))}return n[e.length][t.length]}function n(e,n){if(!n||n.length===0)return``;n=Array.from(new Set(n));let r=e.startsWith(`--`);r&&(e=e.slice(2),n=n.map(e=>e.slice(2)));let i=[],a=3;return n.forEach(n=>{if(n.length<=1)return;let r=t(e,n),o=Math.max(e.length,n.length);(o-r)/o>.4&&(r<a?(a=r,i=[n]):r===a&&i.push(n))}),i.sort((e,t)=>e.localeCompare(t)),r&&(i=i.map(e=>`--${e}`)),i.length>1?`\n(Did you mean one of ${i.join(`, `)}?)`:i.length===1?`\n(Did you mean ${i[0]}?)`:``}e.suggestSimilar=n})),c=n((t=>{let n=e(`node:events`).EventEmitter,c=e(`node:child_process`),l=e(`node:path`),u=e(`node:fs`),d=e(`node:process`),{Argument:f,humanReadableArgName:p}=i(),{CommanderError:m}=r(),{Help:h,stripColor:g}=a(),{Option:_,DualOptions:v}=o(),{suggestSimilar:y}=s();var b=class e extends n{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||``,this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description=``,this._summary=``,this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>d.stdout.write(e),writeErr:e=>d.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>d.stdout.isTTY?d.stdout.columns:void 0,getErrHelpWidth:()=>d.stderr.isTTY?d.stderr.columns:void 0,getOutHasColors:()=>S()??(d.stdout.isTTY&&d.stdout.hasColors?.()),getErrHasColors:()=>S()??(d.stderr.isTTY&&d.stderr.hasColors?.()),stripColor:e=>g(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let r=t,i=n;typeof r==`object`&&r&&(i=r,r=null),i||={};let[,a,o]=e.match(/([^ ]+) *(.*)/),s=this.createCommand(a);return r&&(s.description(r),s._executableHandler=!0),i.isDefault&&(this._defaultCommandName=s._name),s._hidden=!!(i.noHelp||i.hidden),s._executableFile=i.executableFile||null,o&&s.arguments(o),this._registerCommand(s),s.parent=this,s.copyInheritedSettings(this),r?this:s}createCommand(t){return new e(t)}createHelp(){return Object.assign(new h,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!=`string`&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw Error(`Command passed to .addCommand() must have a name
11
+ - specify the name in Command constructor or using .name()`);return t||={},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new f(e,t)}argument(e,t,n,r){let i=this.createArgument(e,t);return typeof n==`function`?i.default(r).argParser(n):i.default(n),this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t?.variadic)throw Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e==`boolean`)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let[,n,r]=(e??`help [command]`).match(/([^ ]+) *(.*)/),i=t??`display help for command`,a=this.createCommand(n);return a.helpOption(!1),r&&a.arguments(r),i&&a.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||t)&&this._initCommandGroup(a),this}addHelpCommand(e,t){return typeof e==`object`?(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this):(this.helpCommand(e,t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand(`help`))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=[`preSubcommand`,`preAction`,`postAction`];if(!n.includes(e))throw Error(`Unexpected value for event passed to hook : '${e}'.
12
+ Expecting one of '${n.join(`', '`)}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=e=>{if(e.code!==`commander.executeSubCommandAsync`)throw e},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new m(e,t,n)),d.exit(e)}action(e){return this._actionHandler=t=>{let n=this.registeredArguments.length,r=t.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)},this}createOption(e,t){return new _(e,t)}_callParseArg(e,t,n,r){try{return e.parseArg(t,n)}catch(e){if(e.code===`commander.invalidArgument`){let t=`${r} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
13
+ - already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let t=e=>[e.name()].concat(e.aliases()),n=t(e).find(e=>this._findCommand(e));if(n){let r=t(this._findCommand(n)).join(`|`),i=t(e).join(`|`);throw Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let t=e.long.replace(/^--no-/,`--`);this._findOption(t)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,`default`)}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,`default`);let r=(t,r,i)=>{t==null&&e.presetArg!==void 0&&(t=e.presetArg);let a=this.getOptionValue(n);t!==null&&e.parseArg?t=this._callParseArg(e,t,a,r):t!==null&&e.variadic&&(t=e._collectValue(t,a)),t??=e.negate?!1:e.isBoolean()||e.optional?!0:``,this.setOptionValueWithSource(n,t,i)};return this.on(`option:`+t,t=>{r(t,`error: option '${e.flags}' argument '${t}' is invalid.`,`cli`)}),e.envVar&&this.on(`optionEnv:`+t,t=>{r(t,`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`,`env`)}),this}_optionEx(e,t,n,r,i){if(typeof t==`object`&&t instanceof _)throw Error(`To add an Option object use addOption() instead of option() or requiredOption()`);let a=this.createOption(t,n);if(a.makeOptionMandatory(!!e.mandatory),typeof r==`function`)a.default(i).argParser(r);else if(r instanceof RegExp){let e=r;r=(t,n)=>{let r=e.exec(t);return r?r[0]:n},a.default(i).argParser(r)}else a.default(r);return this.addOption(a)}option(e,t,n,r){return this._optionEx({},e,t,n,r)}requiredOption(e,t,n,r){return this._optionEx({mandatory:!0},e,t,n,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw Error(`call .storeOptionsAsProperties() before adding options`);if(Object.keys(this._optionValues).length)throw Error(`call .storeOptionsAsProperties() before setting option values`);return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw Error(`first parameter to parse must be array or undefined`);if(t||={},e===void 0&&t.from===void 0){d.versions?.electron&&(t.from=`electron`);let e=d.execArgv??[];(e.includes(`-e`)||e.includes(`--eval`)||e.includes(`-p`)||e.includes(`--print`))&&(t.from=`eval`)}e===void 0&&(e=d.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case`node`:this._scriptPath=e[1],n=e.slice(2);break;case`electron`:d.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case`user`:n=e.slice(0);break;case`eval`:n=e.slice(1);break;default:throw Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||`program`,n}parse(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){this._prepareForParse();let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
14
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,t,n){if(u.existsSync(e))return;let r=`'${e}' does not exist
15
+ - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
16
+ - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
17
+ - ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=!1,r=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function i(e,t){let n=l.resolve(e,t);if(u.existsSync(n))return n;if(r.includes(l.extname(t)))return;let i=r.find(e=>u.existsSync(`${n}${e}`));if(i)return`${n}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let a=e._executableFile||`${this._name}-${e._name}`,o=this._executableDir||``;if(this._scriptPath){let e;try{e=u.realpathSync(this._scriptPath)}catch{e=this._scriptPath}o=l.resolve(l.dirname(e),o)}if(o){let t=i(o,a);if(!t&&!e._executableFile&&this._scriptPath){let n=l.basename(this._scriptPath,l.extname(this._scriptPath));n!==this._name&&(t=i(o,`${n}-${e._name}`))}a=t||a}n=r.includes(l.extname(a));let s;d.platform===`win32`?(this._checkForMissingExecutable(a,o,e._name),t.unshift(a),t=x(d.execArgv).concat(t),s=c.spawn(d.execPath,t,{stdio:`inherit`})):n?(t.unshift(a),t=x(d.execArgv).concat(t),s=c.spawn(d.argv[0],t,{stdio:`inherit`})):s=c.spawn(a,t,{stdio:`inherit`}),s.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{d.on(e,()=>{s.killed===!1&&s.exitCode===null&&s.kill(e)})});let f=this._exitCallback;s.on(`close`,e=>{e??=1,f?f(new m(e,`commander.executeSubCommandAsync`,`(close)`)):d.exit(e)}),s.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(a,o,e._name);else if(t.code===`EACCES`)throw Error(`'${a}' not executable`);if(!f)d.exit(1);else{let e=new m(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,f(e)}}),this.runningCommand=s}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!==`default`});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
18
+ `),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in d.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,d.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new v(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=y(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=y(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>p(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=l.basename(e,l.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(d.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
19
+ Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function x(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function S(){if(d.env.NO_COLOR||d.env.FORCE_COLOR===`0`||d.env.FORCE_COLOR===`false`)return!1;if(d.env.FORCE_COLOR||d.env.CLICOLOR_FORCE!==void 0)return!0}t.Command=b,t.useColor=S}));const{program:l,createCommand:u,createArgument:d,createOption:f,CommanderError:p,InvalidArgumentError:m,InvalidOptionArgumentError:h,Command:g,Argument:_,Option:v,Help:y}=t(n((e=>{let{Argument:t}=i(),{Command:n}=c(),{CommanderError:s,InvalidArgumentError:l}=r(),{Help:u}=a(),{Option:d}=o();e.program=new n,e.createCommand=e=>new n(e),e.createOption=(e,t)=>new d(e,t),e.createArgument=(e,n)=>new t(e,n),e.Command=n,e.Option=d,e.Argument=t,e.Help=u,e.CommanderError=s,e.InvalidArgumentError=l,e.InvalidOptionArgumentError=l}))(),1).default;export{g as Command,v as Option};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./exit-codes-IaZq17dv.js";export{t as ExitCode,e as httpStatusToExitCode};
@@ -0,0 +1 @@
1
+ const e={OK:0,GENERIC:1,USAGE:2,AUTH:3,NOT_FOUND:4,VALIDATION:5,CONFLICT:6,RATE_LIMITED:7,NETWORK:8,QUOTA:9,CANCELLED:130};function t(t){if(t>=200&&t<400)return e.OK;switch(t){case 401:case 403:return e.AUTH;case 402:return e.QUOTA;case 404:return e.NOT_FOUND;case 409:return e.CONFLICT;case 429:return e.RATE_LIMITED;default:break}return t>=500?e.GENERIC:t>=400?e.VALIDATION:e.GENERIC}export{t as n,e as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import"./version--HODInrs.js";import"./color-BbAK7_Y7.js";import"./output-uP7GrsdR.js";import"./config-Bg2ls0gu.js";import"./product-CXL7Ga4M.js";import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./http-DpMu6AKn.js";export{u as DEFAULT_TIMEOUT_MS,o as LONG_TIMEOUT_MS,c as MAX_ATTEMPTS,i as MAX_RETRY_AFTER_MS,e as RATE_LIMIT_WARN_THRESHOLD,s as RETRY_BASE_MS,l as buildUrl,t as configureHttp,a as getLastRateLimit,d as parseRetryAfter,n as request,r as timeoutForRequest};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import{l as t,n,t as r}from"./errors-Dkv23Z0t.js";import{i}from"./version--HODInrs.js";import{r as a}from"./color-BbAK7_Y7.js";import{s as o}from"./output-uP7GrsdR.js";import{I as s,S as c,m as l,p as u,x as d}from"./config-Bg2ls0gu.js";import{t as f}from"./product-CXL7Ga4M.js";const p=3e4,m=12e4,h=3,g=1e3,_=6e4,v=20,y=[/^\/ai\//,/^\/mentions\/[^/]+\/explain$/];let b={},x,S,C,w=!1;function T(e){let t=e;return typeof t.profile==`object`||t.globals!==void 0||t.sleep!==void 0}function E(e=u()){b=T(e)?{...e}:{globals:e},x=b.profile,S=void 0,w=!1}function D(){return x||=c(b.globals??u()),x}function O(){return b.language===void 0?(S===void 0&&(S=d(b.globals?.lang)??``),S===``?void 0:S):String(b.language)}function k(){return l(b.debug??b.globals?.debug)}function A(){return b.quiet??b.globals?.quiet??o()}function j(){return C}function M(e,t,n){let r=e.replace(/\/+$/,``),i=t.startsWith(`/`)?t:`/${t}`,a=new URL(`${r}${i}`);for(let[e,t]of Object.entries(n??{}))if(t!=null){if(Array.isArray(t)){for(let n of t)n!=null&&a.searchParams.append(e,String(n));continue}a.searchParams.append(e,String(t))}return a.toString()}function N(e,t){return e===`POST`&&y.some(e=>e.test(t))?m:p}function P(e,t=Date.now()){if(!e)return;let n=e.trim();if(n===``)return;if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);if(!Number.isNaN(r))return Math.max(0,r-t)}function F(e){let t=g*2**(e-1);return Math.round(t*(.75+Math.random()*.5))}function I(e){if(e===null)return;let t=Number(e.trim());return Number.isFinite(t)?t:void 0}function L(e){let t=I(e.get(`ratelimit-limit`)??e.get(`x-ratelimit-limit`)),n=I(e.get(`ratelimit-remaining`)??e.get(`x-ratelimit-remaining`)),r=I(e.get(`ratelimit-reset`)??e.get(`x-ratelimit-reset`)),i=e.get(`ratelimit-policy`)??void 0;t===void 0&&n===void 0&&r===void 0&&i===void 0||(C={limit:t,remaining:n,reset:r,...i?{policy:i}:{}},R())}function R(){if(w||!C)return;let{limit:e,remaining:t,reset:n}=C;if(t===void 0||t>20||A()||!process.stdout.isTTY)return;w=!0;let r=e===void 0?`the`:String(e),i=n===void 0?``:`, resets in ${Math.max(0,Math.round(n))}s`;process.stderr.write(a(`rate limit: ${t} of ${r} left${i}\n`))}function z(e){let t={};for(let[n,r]of Object.entries(e))t[n]=n.toLowerCase()===`authorization`?`Bearer ${s(r.replace(/^Bearer\s+/i,``))}`:r;return t}function B(e){process.stderr.write(a(e.endsWith(`
2
+ `)?e:`${e}\n`))}function V(e){return e.get(`x-request-id`)??e.get(`x-requestid`)??e.get(`request-id`)??void 0}async function H(e){if(e.status===204)return;let t=await e.text();if(t!==``){if((e.headers.get(`content-type`)??``).includes(`json`))try{return JSON.parse(t)}catch{return t}return t}}function U(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function W(e,n,r){return e instanceof Error&&(e.name===`TimeoutError`||e.name===`AbortError`)?t(`Request to ${n} timed out after ${Math.round(r/1e3)}s`,e):t(`Could not reach ${n}: ${e.message}`,e,`Check your network connection, a proxy, or --api-url`)}async function G(t){if(/^https?:/i.test(t.path))throw new n(`path must be relative to the API base URL, got "${t.path}"`,{exitCode:e.USAGE});let a=D(),o=k(),s=O(),c=b.sleep??U,l=t.idempotent??t.method===`GET`,u=t.timeoutMs??N(t.method,t.path),d=M(a.apiUrl,t.path,t.query),p={authorization:`Bearer ${a.token}`,accept:`application/json`,"user-agent":i(f.id),...s?{"x-language":s}:{},...t.headers},m=t.body!==void 0&&t.method!==`GET`;m&&(p[`content-type`]=`application/json`);let h;for(let e=1;e<=3;e+=1){let n=Date.now();o&&(B(`→ ${t.method} ${d} (attempt ${e}/3, timeout ${u}ms)`),B(` headers ${JSON.stringify(z(p))}`),m&&B(` body ${JSON.stringify(t.body)}`));let i;try{i=await fetch(d,{method:t.method,headers:p,...m?{body:JSON.stringify(t.body)}:{},signal:AbortSignal.timeout(u)})}catch(t){if(h=W(t,d,u),o&&B(`← network error after ${Date.now()-n}ms: ${t.message}`),e<3){await c(F(e));continue}throw h}L(i.headers);let a=await H(i);if(o&&(B(`← ${i.status} ${i.statusText} in ${Date.now()-n}ms`),B(` rateLimit ${JSON.stringify(C??{})}`)),i.ok)return a;let s=new r({status:i.status,body:a,requestId:V(i.headers),method:t.method,path:t.path});if(!(i.status===429?l:i.status===502||i.status===503||i.status===504)||e===3)throw s;let f=P(i.headers.get(`retry-after`))??F(e);if(f>_)throw s;await c(f),h=s}throw h??new n(`Request failed`,{exitCode:e.GENERIC})}export{v as a,E as c,G as d,N as f,_ as i,j as l,m as n,g as o,h as r,M as s,p as t,P as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import{f as t,n,u as r}from"./errors-Dkv23Z0t.js";import{c as i,f as a,g as o,h as s,i as c,m as l,o as u,p as d,r as f,s as p,v as m}from"./output-uP7GrsdR.js";import{t as h}from"./product-CXL7Ga4M.js";import{f as g,n as _,u as v}from"./types-Bu8scNHe.js";import{i as y}from"./prompt-DR68wwvQ.js";import{_ as b,b as x,c as S,i as C,l as w,n as T,o as E,p as D,t as O,u as k,y as A}from"./client-R8kBz1Ou.js";const j=`${h.appUrl}/billing`;function M(e){let n=e.trim().toLowerCase();if(n===``)throw t(`A keyword cannot be empty`);if(n.length>_)throw t(`"${n.slice(0,32)}…" is ${n.length} characters, the limit is ${_}`);return n}function N(e){return[...new Set(e.map(M))]}const P=(e,t=[])=>[...t,M(e)];function F(e){return`$${e.toFixed(2)}`}function I(e,t){for(let n of e){let e=n.keywords.find(e=>e.id===t);if(e)return{website:n,keyword:e}}}const L=[{header:`ID`,value:e=>f(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`NOTE`,value:e=>e.status===`PENDING`?`no free slot on this plan`:`—`}];async function R(e,t){let n=p()||u()?null:g(e);try{return await t()}finally{n?.stop()}}async function z(e){let{websites:t}=await R(`Loading keywords…`,b),n=I(t,e);if(!n)throw r(`No keyword with id "${e}" in this workspace`,`list them with: ${h.binName} site list`);return n}function B(e){let t=e.keywords.filter(e=>e.status===`PENDING`).length;t!==0&&(i(``),i(`${t} pending. Price an upgrade: ${h.binName} keyword plan --count ${e.keywords.filter(e=>e.status!==`DISABLED`).length}`))}async function V(e,n){let r=N(n);if(r.length===0)throw t(`Pass at least one keyword`);let a=await R(`Adding keywords…`,()=>T(e,{keywords:r}));if(u()){d(`keyword.add`,a);return}let c=a.keywords.filter(e=>r.includes(e.value)),l=a.keywords.filter(e=>e.status===`ACTIVE`).length;o(`${a.domain} now has ${a.keywords.length} keywords (${l} active)`),c.length>0&&(i(``),s(c,L)),B(a)}async function H(e,t){let n=M(t.value),{keyword:r}=await z(e);if(r.value===n){if(u()){d(`keyword.edit`,r);return}i(`No change (case-only edit).`);return}let s=await R(`Renaming keyword…`,()=>w(e,{value:n}));if(u()){d(`keyword.edit`,s);return}o(`${r.value} → ${s.value}`),a([[`status`,s.status],[`slot`,`kept, editing is free and unlimited`]])}async function U(e){let t=await R(`Disabling keyword…`,()=>S(e));if(u()){d(`keyword.disable`,t);return}o(`"${t.value}" is ${t.status}`),i(`Its mentions are kept and it no longer occupies a paid slot. Nothing was charged.`)}async function W(e){let t=await R(`Enabling keyword…`,()=>k(e));if(u()){d(`keyword.enable`,t);return}if(t.status===`PENDING`){o(`"${t.value}" is PENDING`),i(`No free slot on this plan, so it is not collecting yet. Nothing was charged.`),c(`price an upgrade: ${h.binName} keyword plan`);return}o(`"${t.value}" is ${t.status}`),i(`Nothing was charged.`)}async function G(t,r){let{website:i,keyword:a}=await z(t),{total:s}=await C({websiteId:i.id,keywords:[a.value],statuses:[...v],includeLowRelevance:!0});if(r.yes!==!0&&(m(`Deleting "${a.value}" also deletes the ${s} mention${s===1?``:`s`} it produced. There is no undo and no refund.`),c(`To pause instead, keeping the mentions: ${h.binName} keyword disable ${a.id}`),(await y(`Type DELETE to confirm`,{hint:`Pass --yes to delete without typing DELETE`})).trim()!==`DELETE`))throw new n(`That is not DELETE, nothing was deleted.`,{exitCode:e.CANCELLED});let l=await E(a.id);if(u()){d(`keyword.delete`,l);return}o(`Deleted`)}async function K(){let{websites:e}=await R(`Activating pending keywords…`,O);if(u()){d(`keyword.activate-pending`,e,{total:e.length,hasMore:!1});return}let t=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`ACTIVE`).length,0),n=e.reduce((e,t)=>e+t.keywords.filter(e=>e.status===`PENDING`).length,0);o(`${t} active keyword${t===1?``:`s`} across ${e.length} site${e.length===1?``:`s`}`),i(n===0?`Nothing left pending. This never charges.`:`${n} still pending, there was no free slot. This never charges.`),n>0&&c(`price an upgrade: ${h.binName} keyword plan --count ${t+n}`)}function q(e){l([`CURRENT`,`TARGET`],[[`${e.currentPlanName??`no plan`} ${F(e.currentMonthlyPrice)}/mo`,`${e.targetPlanName??`no plan`} ${F(e.targetMonthlyPrice)}/mo (${e.targetKeywords} keywords)`]]),i(``),a([[`upgrade`,e.isUpgrade?`yes`:e.isDowngrade?`no, downgrade`:`no change`],[`charged now`,`${F(e.immediateCharge)}${e.isUpgrade?` (prorated)`:``}`],[`payment needed`,e.requiresImmediatePayment?`yes`:`no`]]),i(``),i(`Plans change in the ${h.displayName} app: ${j}`)}async function J(e){let n;if(e.count===void 0)n=await R(`Pricing your pending keywords…`,A);else{let r=Number(e.count);if(!Number.isInteger(r)||r<1)throw t(`--count must be a whole number of 1 or more, got "${e.count}"`,`--count is the account-wide total of active keywords you want, not how many to add`);n=await R(`Pricing that keyword count…`,()=>x({desiredKeywordCount:r}))}if(u()){d(`keyword.plan`,n);return}q(n)}async function Y(){let e=await R(`Reading keyword edit usage…`,D);if(u()){d(`keyword.usage`,e);return}if(e.unlimited){i(`Keyword edits: unlimited (this plan does not meter them).`);return}a([[`used`,String(e.used)],[`limit`,String(e.limit)],[`remaining`,String(e.remaining)]])}function X(e){let t=e.command(`keyword`).alias(`keywords`).alias(`kw`).description(`keywords a site listens for`);t.command(`add <siteId> <keyword...>`).description(`add keywords to a site`).action(async(e,t)=>{await V(e,t)}),t.command(`edit <id>`).description(`rename a keyword, free and unlimited`).requiredOption(`--value <keyword>`,`the new keyword`).action(async(e,t)=>{await H(e,t)}),t.command(`disable <id>`).description(`stop collecting for a keyword, keeping its mentions`).action(async e=>{await U(e)}),t.command(`enable <id>`).description(`start collecting for a disabled keyword`).action(async e=>{await W(e)}),t.command(`delete <id>`).alias(`rm`).description(`delete a keyword and every mention it produced`).action(async(e,t,n)=>{await G(e,n.optsWithGlobals())}),t.command(`activate-pending`).description(`promote pending keywords into any free slots`).action(async()=>{await K()}),t.command(`plan`).description(`price the plan a keyword count needs`).option(`--count <n>`,`account-wide total of active keywords you want, not an increment`).action(async e=>{await J(e)}),t.command(`usage`).description(`how many keyword edits this plan allows`).action(async()=>{await Y()})}export{N as a,M as i,I as n,X as o,F as r,P as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import"./version--HODInrs.js";import"./color-BbAK7_Y7.js";import"./output-uP7GrsdR.js";import"./config-Bg2ls0gu.js";import"./product-CXL7Ga4M.js";import"./http-DpMu6AKn.js";import"./types-Bu8scNHe.js";import"./prompt-DR68wwvQ.js";import"./client-R8kBz1Ou.js";import{a as e,i as t,n,o as r,r as i,t as a}from"./keyword-BjASkU-P.js";export{a as collectKeyword,n as findKeyword,i as formatMoney,t as normalizeKeyword,e as normalizeKeywords,r as registerKeywordCommands};
@@ -0,0 +1,3 @@
1
+ import"./exit-codes-IaZq17dv.js";import{f as e}from"./errors-Dkv23Z0t.js";import{r as t}from"./color-BbAK7_Y7.js";import{c as n,i as r,p as i}from"./output-uP7GrsdR.js";import{I as a,S as o}from"./config-Bg2ls0gu.js";import{t as s}from"./product-CXL7Ga4M.js";import{join as c}from"node:path";import{homedir as l}from"node:os";const u=s.id,d=`https://mcp.redreplier.com/mcp`,f=`@redreplier/mcp-server`,p=`${s.envPrefix}_API_TOKEN`,m=[`claude`,`cursor`,`vscode`,`windsurf`,`codex`,`json`],h={claude:c(l(),`.claude.json`),cursor:c(l(),`.cursor`,`mcp.json`),vscode:c(`.vscode`,`mcp.json`),windsurf:c(l(),`.codeium`,`windsurf`,`mcp_config.json`),codex:c(l(),`.codex`,`config.toml`),json:c(l(),`.${u}-mcp.json`)};function g(e,t){return t?{command:`npx`,args:[`-y`,f],env:{[p]:e}}:{type:`http`,url:d,headers:{Authorization:`Bearer ${e}`}}}function _(e,t,n){if(e===`codex`){let e=[`[mcp_servers.${u}]`];return n?e.push(`command = "npx"`,`args = ["-y", "${f}"]`,`env = { ${p} = "${t}" }`):e.push(`url = "${d}"`,`http_headers = { Authorization = "Bearer ${t}" }`),e.join(`
2
+ `)}let r=e===`vscode`?`servers`:`mcpServers`;return JSON.stringify({[r]:{[u]:g(t,n)}},null,2)}function v(e,t){return t?`claude mcp add ${u} --env ${p}=${e} -- npx -y ${f}`:`claude mcp add --transport http ${u} ${d} --header "Authorization: Bearer ${e}"`}function y(c){c.command(`mcp`).description(`print the ${s.displayName} MCP server config for your editor`).option(`--client <client>`,`one of ${m.join(`, `)}`,`claude`).option(`--local`,`use the stdio server from npm instead of the hosted one`).option(`--write`,`name the file this config belongs in, without touching it`).option(`--install`,`alias of --write`).action(c=>{let l=c.client.toLowerCase();if(!m.includes(l))throw e(`Unknown MCP client "${c.client}".`,`Supported clients: ${m.join(`, `)}`);let u,g=`default`;try{let e=o();u=e.token,g=e.name}catch{u=void 0}let y=!!c.local,b=!!(c.write||c.install),x=b||!process.stdout.isTTY,S=`\${${p}}`,C=u??S,w=u&&!x?a(u):C,T=h[l];i(`mcp`,{client:l,transport:y?`stdio`:`http`,url:y?null:d,package:y?f:null,configFile:T,config:l===`codex`?_(l,C,y):JSON.parse(_(l,C,y))}),l===`claude`?(n(`Add the ${s.displayName} MCP server to Claude Code:`),n(``),n(` ${v(w,y)}`),n(``),n(`Or paste this into your MCP config:`)):n(`Paste this into ${T}:`),n(``);for(let e of _(l,w,y).split(`
3
+ `))n(` ${e}`);n(``),u?x||r(`The token is redacted on screen. Re-run with --write, or pipe this command, to get it in full.`):r(`Profile "${g}" has no token, the config above carries a placeholder. Run: ${s.binName} login`),b&&(n(`${t(`config file`)} ${T}`),r(`Nothing was written. Merge the block above into that file yourself, it may already hold other servers.`))})}export{y as registerMcpCommand};
@@ -0,0 +1 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import{f as t,u as n}from"./errors-Dkv23Z0t.js";import"./version--HODInrs.js";import{r}from"./color-BbAK7_Y7.js";import{_ as i,c as a,f as o,g as s,h as c,i as l,o as u,p as d,r as f,s as p,u as m,v as h}from"./output-uP7GrsdR.js";import{a as g,i as _,n as v,r as y,t as b}from"./time-B5S7M7Dg.js";import{v as ee}from"./config-Bg2ls0gu.js";import{t as x}from"./product-CXL7Ga4M.js";import"./http-DpMu6AKn.js";import{c as S,d as C,f as te,l as w,o as T,s as E,u as D}from"./types-Bu8scNHe.js";import{d as O,g as k,i as A,w as j}from"./client-R8kBz1Ou.js";import{spawn as ne}from"node:child_process";function re(e,n,r,i=`--limit`){if(e===void 0)return r;let a=typeof e==`number`?e:Number(e);if(!Number.isInteger(a)||a<n||a>r)throw t(`${i} must be an integer between ${n} and ${r}`);return a}function ie(e,n=`--offset`){if(e===void 0)return 0;let r=typeof e==`number`?e:Number(e);if(!Number.isInteger(r)||r<0)throw t(`${n} must be an integer of 0 or more`);return r}async function ae(e){let t=e.maxPages??50,n=e.collect!==!1,r=[],i=e.offset??0,a=0,o=0,s,c=!1;for(;a<t;){let l=await e.fetchPage({limit:e.pageSize,offset:i});if(a+=1,o+=l.items.length,l.total!==void 0&&(s=l.total),n&&r.push(...l.items),await e.onPage?.(l.items,{index:a-1,offset:i,total:l.total}),i+=l.items.length,l.items.length===0||l.hasMore===!1||l.hasMore===void 0&&(l.items.length<e.pageSize||s!==void 0&&i>=s))break;if(a>=t){c=!0;break}}return c&&!e.quiet&&h(`stopped after ${t} requests (${o} items). Continue with --offset ${i}`),{items:r,total:s,pages:a,fetched:o,truncated:c}}const M=5e3;var oe=class{keys=new Map;constructor(e){this.limit=e}has(e){return this.keys.has(e)?(this.keys.delete(e),this.keys.set(e,!0),!0):!1}add(e){for(this.keys.has(e)&&this.keys.delete(e),this.keys.set(e,!0);this.keys.size>this.limit;){let e=this.keys.keys().next();if(e.done)break;this.keys.delete(e.value)}}get size(){return this.keys.size}};function se(e){return new Promise(t=>{setTimeout(t,e).unref?.()})}function ce(e){if(!e||typeof e!=`object`)return;let t=e;if(t.status!==429)return;let n=[t.retryAfterMs,t.retryAfterSeconds,t.retryAfter];for(let[e,t]of n.entries())if(typeof t==`number`&&Number.isFinite(t))return e===0?t:t*1e3;let r=t.body;if(r&&typeof r==`object`){let e=r.retryAfter;if(typeof e==`number`&&Number.isFinite(e))return e*1e3}return M}function le(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?r===0?`${n}m`:`${n}m${r}s`:`${Math.floor(n/60)}h${n%60}m`}async function ue(t){let n=Math.max(M,t.intervalMs),i=Math.max(n,t.maxIntervalMs??6e4),a=t.sleep??se,o=t.onExit??(e=>process.exit(e)),s=new oe(1e4),c=Date.now(),l=n,u=t.cursor,d=0,f=0,p,m=!1,h,g=()=>{m=!0,h?.()};process.on(`SIGINT`,g);let _=async e=>{m||await new Promise(t=>{let n=!1,r=()=>{n||(n=!0,h=void 0,t())};h=r,a(e).then(r)})},v=e=>({emitted:d,polls:f,reason:e,cursor:u,last:p});try{for(;;){let e;try{e=await t.fetchPage(u)}catch(e){let t=ce(e);if(t===void 0)throw e;if(await _(Math.min(t,i)),m)break;continue}f+=1,u=e.cursor;let r=0,a=!1;for(let n of e.items){let e=t.key(n);if(!s.has(e)&&(s.add(e),r+=1,p=n,await t.onItem(n),d+=1,t.until?.(n))){a=!0;break}}if(a)return v(`until`);if(m)break;if(l=r>0?n:Math.min(i,Math.round(l*1.5)),t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`);if(await _(l),m)break;if(t.timeoutMs!==void 0&&Date.now()-c>=t.timeoutMs)return v(`timeout`)}}finally{process.removeListener(`SIGINT`,g)}let y=t.label??`items`;return process.stderr.write(r(`\nstopped. ${d} ${y} in ${le(Date.now()-c)}, ${f} polls\n`)),o(e.CANCELLED),v(`interrupted`)}const de=[[75,`VERY_HIGH`],[50,`HIGH`],[30,`MEDIUM`],[10,`LOW`],[0,`VERY_LOW`]];function N(e){if(e===null||!Number.isFinite(e))return null;for(let[t,n]of de)if(e>=t)return n;return`VERY_LOW`}function P(e){let n=e.trim().toUpperCase();if(!D.includes(n))throw t(`Unknown status "${e}"`,`valid statuses: ${D.join(`, `)}`);return n}function F(e){let n=e.trim().toUpperCase().replace(/-/g,`_`);if(!C.includes(n))throw t(`Unknown bucket "${e}"`,`valid buckets: ${C.join(`, `)}`);return n}function I(e){let n=e.trim().toUpperCase().replace(/-/g,`_`);if(!w.includes(n))throw t(`Unknown source "${e}"`,`valid sources: ${w.join(`, `)}`);return n}function L(e){let n=e.trim().toUpperCase();if(!S.includes(n))throw t(`Unknown sort "${e}"`,`valid sorts: ${S.join(`, `)}`);return n}const fe=(e,t=[])=>[...t,e],R=(e,t=[])=>[...t,P(e)],z=(e,t=[])=>[...t,F(e)],B=(e,t=[])=>[...t,I(e)];function V(e){let t={};return e.site!==void 0&&e.site!==``&&(t.websiteId=e.site),e.status&&e.status.length>0&&(t.statuses=e.status),e.bucket&&e.bucket.length>0&&(t.scoreBuckets=e.bucket),e.includeLow===!0&&(t.includeLowRelevance=!0),e.keyword&&e.keyword.length>0&&(t.keywords=e.keyword),e.source&&e.source.length>0&&(t.sources=e.source),e.from!==void 0&&(t.from=g(y(e.from))),e.to!==void 0&&(t.to=g(y(e.to))),t}function H(e){if(e!==void 0&&e!==``)return e;let t=ee().defaultSite;return typeof t==`string`&&t!==``?t:void 0}function U(e){return e.subreddit?`r/${e.subreddit}`:e.source}function W(e){return e.author?e.source===`REDDIT_POST`||e.source===`REDDIT_COMMENT`?e.author.startsWith(`u/`)?e.author:`u/${e.author}`:e.author:`—`}function G(e){let t=e.publishedAt??e.ingestedAt??e.createdAt;if(t===null)return null;let n=new Date(t);return Number.isNaN(n.getTime())?null:n}const pe=e=>{let t=G(e);return t===null?`—`:v(t)},K=e=>(e??``).replace(/\s+/g,` `).trim()||`—`,me=[{header:`SCORE`,value:e=>e.relevanceScore??`—`,align:`right`},{header:`SOURCE`,value:U},{header:`WHEN`,value:pe},{header:`KEYWORD`,value:e=>e.keyword||`—`},{header:`TITLE`,value:e=>K(e.title??e.contentText)}];async function q(e,t){let n=p()||u()?null:te(e);try{return await t()}finally{n?.stop()}}function he(e,t,n){let r=e.replace(/\s+/g,` `).trim().split(` `),i=[],a=``;for(let e of r){if(a===``){a=e;continue}if(`${a} ${e}`.length+n.length>t){i.push(`${n}${a}`),a=e;continue}a=`${a} ${e}`}return a!==``&&i.push(`${n}${a}`),i}function J(e,t=` `){for(let n of he(e,Math.max(40,i()-2),t))a(n)}async function ge(e,t){try{let{total:n}=await A({...e,includeLowRelevance:!0});return Math.max(0,n-t)}catch{return 0}}async function _e(e){let t=V({...e,site:H(e.site)}),n=e.limit===void 0?50:re(e.limit,E,T),r=ie(e.offset),i=e.sort,o,s,f=!1;if(e.all){let n=await ae({pageSize:T,offset:r,quiet:e.quiet===!0||p(),fetchPage:async e=>{let n=await k({...t,sort:i,limit:e.limit,offset:e.offset});return{items:n.mentions,total:n.total,hasMore:n.offset+n.mentions.length<n.total}}});o=n.items,s=n.total}else{let e=await q(`Loading mentions…`,()=>k({...t,sort:i,limit:n,offset:r}));o=e.mentions,s=e.total,f=e.offset+e.mentions.length<e.total}if(u()){d(`mention.list`,o,{total:s,limit:e.all?void 0:n,offset:e.all?void 0:r,hasMore:f}),m(o);return}if(o.length===0?a(`No mentions match those filters.`):(c(o,me),a(``),a(`${o.length} of ${s??o.length} · open: ${x.binName} mention show <id>`),f&&a(`next: --offset ${r+o.length}`)),t.statuses?.includes(`REJECTED`)||l(`REJECTED mentions are hidden unless you pass --status REJECTED.`),e.includeLow!==!0){let e=await ge(t,s??o.length);e>0&&l(`${e} mention${e===1?``:`s`} below the site’s minimum score ${e===1?`is`:`are`} hidden. Add --include-low.`)}}async function ve(e){let t=V({...e,site:H(e.site)}),n=await q(`Counting mentions…`,()=>A(t));if(u()){d(`mention.count`,n);return}a(`${n.total} mention${n.total===1?``:`s`} match`)}async function ye(e,t){let n={...t,statuses:t.statuses??[...D],includeLowRelevance:!0};for(let t=0;t<20;t+=1){let r=t*T,i=await k({...n,sort:`RECENT`,limit:T,offset:r}),a=i.mentions.find(t=>t.id===e||t.id.startsWith(e));if(a)return a;if(i.mentions.length===0||r+i.mentions.length>=i.total)return}}function Y(e){let t=G(e),n=N(e.relevanceScore);a([U(e),t===null?`unknown time`:v(t),e.relevanceScore===null?`unscored`:`score ${e.relevanceScore}${n===null?``:` (${n})`}`,e.status].join(` · `)),o([[`id`,e.id],[`keyword`,e.keyword||`—`],[`author`,W(e)],[`url`,e.url],...t===null?[]:[[`posted`,b(t,{timezone:_()})]],...e.tags.length>0?[[`tags`,e.tags.join(`, `)]]:[]]),e.title&&(a(``),J(e.title)),e.contentText&&(a(``),J(e.contentText)),e.relevanceReason&&(a(``),a(r(e.relevanceScore===null?`why it was scored`:`why it scored ${e.relevanceScore}`)),J(e.relevanceReason,` `)),e.aiReplySuggestion&&(a(``),a(r(`suggested reply`)),J(e.aiReplySuggestion,` `)),a(``),a(`approve: ${x.binName} mention status ${e.id} APPROVED`)}async function be(e,t){let r=t.explain?await q(`Explaining mention…`,()=>O(e)):await q(`Searching mentions…`,()=>ye(e,V({...t,site:H(t.site)})));if(!r)throw n(`Mention not found in this workspace`,t.explain?`drop --explain to page through /mentions instead`:`${x.binName} mention list --limit 20`);if(u()){d(`mention.show`,r);return}Y(r)}async function xe(e,t){let n=P(t),r=await q(`Updating status…`,()=>j(e,{status:n}));if(u()){d(`mention.status`,r);return}s(`${f(r.id)} is ${r.status}`),a(`Reversible: ${x.binName} mention status ${r.id} NEW`)}async function Se(e){l(`The first call runs generation and can take up to two minutes. Later calls are instant reads.`);let t=await q(`Explaining mention…`,()=>O(e));if(!t)throw n(`Mention not found in this workspace`,`${x.binName} mention list --limit 20`);if(u()){d(`mention.explain`,t);return}Y(t)}function X(e){if(e===void 0)return 60;let n=Number(e);if(!Number.isInteger(n)||n<30)throw t(`--interval must be a whole number of 30 seconds or more, got "${e}"`,`every poll spends from the 600 requests per minute budget`);return n}function Z(e){if(e===void 0)return;let n=Number(e);if(!Number.isInteger(n)||n<0||n>100)throw t(`--min-score must be a whole number between 0 and 100, got "${e}"`);return n}function Ce(e){return{RR_ID:e.id,RR_SCORE:e.relevanceScore===null?``:String(e.relevanceScore),RR_URL:e.url,RR_SOURCE:e.source,RR_KEYWORD:e.keyword??``,RR_TITLE:e.title??``}}async function we(e,t){return new Promise(n=>{let r=ne(e,{shell:!0,stdio:[`pipe`,`pipe`,`pipe`],env:{...process.env,...Ce(t)}});r.stdout?.on(`data`,e=>process.stderr.write(e)),r.stderr?.on(`data`,e=>process.stderr.write(e)),r.on(`error`,e=>{process.stderr.write(`${e.message}\n`),n(1)}),r.on(`close`,e=>n(e??1)),r.stdin?.end(`${JSON.stringify(t)}\n`)})}async function Q(e){let t=Z(e.minScore),n=X(e.interval),r=e.since===void 0?new Date:y(e.since),i=_(),o=V({...e,site:H(e.site),from:void 0}),s={...o,from:g(r),sort:`RECENT`,limit:50};u()||a(`Tailing new mentions ${o.websiteId===void 0?`for every site`:`for site ${f(o.websiteId)}`}${t===void 0?``:`, score ≥ ${t}`}, every ${n}s. Ctrl-C to stop.`),await ue({intervalMs:n*1e3,maxIntervalMs:3e5,label:`mentions`,key:e=>e.id,fetchPage:async e=>({items:[...(await k(s)).mentions].reverse().filter(e=>t===void 0?!0:(e.relevanceScore??-1)>=t),cursor:e}),onItem:async t=>{if(u()?process.stdout.write(`${JSON.stringify(t)}\n`):a([b(G(t)??new Date,{timezone:i,seconds:!0,withZone:!1}).slice(11),String(t.relevanceScore??`—`).padStart(3),U(t).padEnd(12),K(t.title??t.contentText)].join(` `)),e.exec===void 0)return;let n=await we(e.exec,t);if(n!==0){h(`--exec exited ${n} for ${t.id}, the tail continues`);return}if(e.approveOnExecSuccess===!0)try{await j(t.id,{status:`APPROVED`})}catch(e){h(`could not approve ${t.id}: ${e instanceof Error?e.message:String(e)}`)}}})}const $=e=>e.option(`--site <id>`,`only this site`).option(`--status <status>`,`filter by status, repeatable: ${D.join(`, `)}`,R,[]).option(`--bucket <bucket>`,`filter by score bucket, repeatable: ${C.join(`, `)}`,z,[]).option(`--include-low`,`include mentions below the site’s minimum score`).option(`--keyword <keyword>`,`filter by keyword, repeatable`,fe,[]).option(`--source <source>`,`filter by source, repeatable: ${w.join(`, `)}`,B,[]).option(`--from <date>`,`lower bound on ingestion time`).option(`--to <date>`,`upper bound on ingestion time`);function Te(e){let t=e.command(`mention`).alias(`mentions`).description(`lead mentions found across Reddit, Hacker News, X and Bluesky`);$(t.command(`list`)).alias(`ls`).description(`list mentions`).option(`--sort <order>`,`${S.join(` or `)}`,L).option(`--limit <n>`,`mentions per page, ${E} to ${T}`).option(`--offset <n>`,`mentions to skip`).option(`--all`,`page until the server runs out`).action(async(e,t)=>{await _e(t.optsWithGlobals())}),$(t.command(`count`)).description(`count the mentions matching the filters`).action(async e=>{await ve(e)}),$(t.command(`show <id>`)).alias(`get`).description(`show one mention, its score reason and its suggested reply`).option(`--explain`,`fetch it through /mentions/{id}/explain instead of paging /mentions`).action(async(e,t)=>{await be(e,t)}),t.command(`status <id> <status>`).description(`set a mention's status: ${D.join(`, `)}`).action(async(e,t)=>{await xe(e,t)}),t.command(`explain <id>`).description(`generate, then read, why a mention scored as it did`).action(async e=>{await Se(e)}),$(t.command(`tail`)).description(`follow new mentions as they arrive`).option(`--min-score <n>`,`skip mentions scoring below this`).option(`--interval <seconds>`,`poll every N seconds, floor 30`).option(`--since <date>`,`start from this time instead of now`).option(`--exec <command>`,`run this command once per mention, JSON on its stdin`).option(`--approve-on-exec-success`,`approve a mention when --exec exits 0`).action(async(e,t)=>{await Q(t.optsWithGlobals())})}export{W as authorLabel,V as buildFilterQuery,G as mentionDate,F as normalizeBucket,L as normalizeSort,I as normalizeSource,P as normalizeStatus,Z as parseMinScore,X as parseTailInterval,Te as registerMentionCommands,N as relevanceBucketOf,H as resolveSite,U as sourceLabel};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import{f as e}from"./errors-Dkv23Z0t.js";import"./color-BbAK7_Y7.js";import{c as t,p as n}from"./output-uP7GrsdR.js";import{p as r}from"./config-Bg2ls0gu.js";import{t as i}from"./product-CXL7Ga4M.js";import{t as a}from"./open-url-CovrlP9b.js";const o={dashboard:{path:()=>`/dashboard`,needsId:!1},mentions:{path:()=>`/mentions`,needsId:!1},mention:{path:e=>`/mentions/${e}`,needsId:!0},site:{path:e=>`/websites/${e}`,needsId:!0},sites:{path:()=>`/websites`,needsId:!1},keywords:{path:()=>`/keywords`,needsId:!1},tokens:{path:()=>`/api-tokens`,needsId:!1},billing:{path:()=>`/billing`,needsId:!1}},s={home:`dashboard`,leads:`mentions`,website:`site`,websites:`sites`,keyword:`keywords`,token:`tokens`,"api-tokens":`tokens`,plan:`billing`,upgrade:`billing`};function c(c){c.command(`open`).argument(`[what]`,`one of ${Object.keys(o).join(`, `)}`,`dashboard`).argument(`[id]`,`identifier, for the targets that need one`).description(`open the ${i.displayName} web app in your browser`).action((c,l)=>{let u=s[c.toLowerCase()]??c.toLowerCase(),d=o[u];if(!d)throw e(`There is nothing to open called "${c}".`,`Targets: ${Object.keys(o).join(`, `)}`);if(d.needsId&&l===void 0)throw e(`open ${u} needs an id.`,`${i.binName} open ${u} <id>`);let f=`${i.appUrl}${d.path(l)}`;if(n(`open`,{target:u,url:f}),r().input===!1){t(f);return}t(a(f)?`Opening ${f}`:f)})}export{c as registerOpenCommand};
@@ -0,0 +1 @@
1
+ import{spawn as e}from"node:child_process";function t(){return process.platform===`darwin`?{command:`open`,args:[]}:process.platform===`win32`?{command:`cmd`,args:[`/c`,`start`,``]}:{command:`xdg-open`,args:[]}}function n(){return process.platform===`darwin`||process.platform===`win32`?!0:!!(process.env.DISPLAY||process.env.WAYLAND_DISPLAY)}function r(r){let i;try{i=new URL(r)}catch{return!1}if(i.protocol!==`https:`&&i.protocol!==`http:`||!n())return!1;let{command:a,args:o}=t();try{let t=e(a,[...o,i.toString()],{detached:!0,stdio:`ignore`,windowsHide:!0});return t.on(`error`,()=>void 0),t.unref(),!0}catch{return!1}}export{r as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import"./color-BbAK7_Y7.js";import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./output-uP7GrsdR.js";export{h as detectOutputMode,u as failure,p as formatId,s as hint,t as initOutput,d as isMachine,m as isQuiet,n as print,c as printError,g as printFieldHints,r as printJson,i as printKeyValues,f as printResult,l as printRows,o as printTable,a as success,e as terminalWidth,_ as warn};
@@ -0,0 +1,5 @@
1
+ import{a as e,d as t,r as n}from"./errors-Dkv23Z0t.js";import{a as r,c as i,i as a,r as o,s}from"./color-BbAK7_Y7.js";const c=/^[-+]?[$€£]?\d[\d,]*(\.\d+)?%?$/;function l(e){return s(e).length}function u(e,t){if(t<=0)return``;let n=s(e);return n.length<=t?e:t===1?`…`:`${n.slice(0,t-1)}…`}function d(e,t,n={}){let r=e.map((e,n)=>t.map(t=>_(t.value(e,n)))),i=t.map((e,t)=>e.align??g(r.map(e=>e[t]??``)));return f(t.map(e=>e.header),r,{...n,align:i})}function f(e,t,n={}){if(t.length===0)return``;let r=n.gap??2,i=n.width??100,a=n.header!==!1,s=Math.max(e.length,...t.map(e=>e.length));if(s===0)return``;let c=Array.from({length:s},(t,n)=>(e[n]??``).toUpperCase()),u=Array.from({length:s},(e,r)=>n.align?.[r]??g(t.map(e=>e[r]??``))),d=Array.from({length:s},(e,n)=>{let r=a?l(c[n]):0;return t.reduce((e,t)=>Math.max(e,l(t[n]??``)),r)});p(d,i,r);let f=[];a&&f.push(o(m(c,d,u,r)));for(let e of t){let t=Array.from({length:s},(t,n)=>e[n]??``);f.push(m(t,d,u,r))}return f.join(`
2
+ `)}function p(e,t,n){let r=n*Math.max(0,e.length-1),i=e.reduce((e,t)=>e+t,0)+r-t;if(!(i<=0))for(let t=e.length-1;t>=0&&i>0;--t){let n=Math.min(e[t],3),r=e[t]-n,a=Math.min(r,i);e[t]-=a,i-=a}}function m(e,t,n,r){return e.map((e,r)=>h(u(e,t[r]),t[r],n[r])).join(` `.repeat(r)).replace(/\s+$/,``)}function h(e,t,n){let r=` `.repeat(Math.max(0,t-l(e)));return n===`right`?r+e:e+r}function g(e){let t=e.map(e=>s(e).trim()).filter(e=>e!==``);return t.length===0?`left`:t.every(e=>c.test(e))?`right`:`left`}function _(e){return e==null?``:typeof e==`number`?String(e):e}let v=`human`,y=!1,b=!1,x=``;function S(e={}){let t=e.env??process.env,n=e.envPrefix;return e.json===!0||n!==void 0&&H(t[`${n}_JSON`])?`machine`:n!==void 0&&H(t[`${n}_FORCE_TTY`])||H(t.FORCE_TTY)?`human`:H(t.CI)?`machine`:e.isTTY??!!process.stdout.isTTY?`human`:`machine`}function C(e={}){return v=S(e),y=e.quiet===!0,b=e.fullIds===!0,e.command!==void 0&&(x=e.command),v}function w(){return v===`machine`}function T(){return y}function E(){let e=process.stdout.columns;return typeof e==`number`&&e>0?e:100}function D(e=``){v===`human`&&B(`${e}\n`)}function O(e,t,n={}){if(v!==`human`||e.length===0)return;let r=d(e,t,{...n,width:n.width??E()});r!==``&&B(`${r}\n`)}function k(e,t,n={}){if(v!==`human`||t.length===0)return;let r=f(e,t,{...n,width:n.width??E()});r!==``&&B(`${r}\n`)}function A(e,t=` `){if(v!==`human`||e.length===0)return;let n=e.reduce((e,[t])=>Math.max(e,t.length),0);B(`${e.map(([e,r])=>`${t}${e.padEnd(n)} ${r}`).join(`
3
+ `)}\n`)}function j(e){B(`${JSON.stringify(e,null,2)}\n`)}function M(e,t,n){if(v!==`machine`)return;x=e;let r={ok:!0,command:e,data:t===void 0?null:t};n!==void 0&&(r.meta=n),j(r)}function N(e){if(y)return;let t=Array.isArray(e)?e[0]:e;if(typeof t!=`object`||!t)return;let n=Object.keys(t);n.length!==0&&V(`${o(`fields: ${n.join(` `)}`)}\n`)}function P(e){y||V(`${o(e)}\n`)}function F(e){y||V(`${i(`⚠`)} ${e}\n`)}function I(e){v===`human`&&B(`${a(`✓`)} ${e}\n`)}function L(e){v===`human`&&B(`${r(`✗`)} ${e}\n`)}function R(i,a=x){let s=n(i),c=t(i);if(v===`machine`)return V(`${JSON.stringify({ok:!1,command:a||`unknown`,error:c},null,2)}\n`),s;V(`${r(`✗`)} ${c.message}\n`);let l=Array.isArray(c.details)?c.details:null;if(l!==null&&l.length>1)for(let e of l)V(` ${o(`·`)} ${e}\n`);let u=e(i);if(u!==void 0&&u.trim()!==``){V(`
4
+ `);for(let e of u.split(`
5
+ `))V(` ${e}\n`)}let d=typeof i?.requestId==`string`?i.requestId:void 0;return d!==void 0&&V(`\n ${o(`request id: ${d}`)}\n`),s}function z(e,t=12){return b||v===`machine`||e.length<=t?e:`${e.slice(0,t)}…`}function B(e){process.stdout.write(e)}function V(e){process.stderr.write(e)}function H(e){if(e===void 0||e===``)return!1;let t=e.toLowerCase();return t!==`0`&&t!==`false`}export{E as _,C as a,D as c,j as d,A as f,I as g,O as h,P as i,R as l,k as m,L as n,w as o,M as p,z as r,T as s,S as t,N as u,F as v};
@@ -0,0 +1 @@
1
+ const e={id:`redreplier`,displayName:`RedReplier`,binName:`redreplier`,altBinName:`rr`,npmPackage:`@redreplier/cli`,envPrefix:`REDREPLIER`,defaultApiUrl:`https://ai.redreplier.com/ai-app/api/v1`,appUrl:`https://redreplier.com`,tokensUrl:`https://redreplier.com/api-tokens`,tokenPrefixes:[`redreplier_`],verifyPath:`/websites`};export{e as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import"./color-BbAK7_Y7.js";import{a as e,i as t,n,r,t as i}from"./prompt-DR68wwvQ.js";export{i as isInteractive,n as promptConfirm,r as promptHidden,t as promptText,e as setInteractive};
@@ -0,0 +1,45 @@
1
+ import{r as e,t}from"./chunk-B_5Rb6Gi.js";import{t as n}from"./exit-codes-IaZq17dv.js";import{f as r}from"./errors-Dkv23Z0t.js";import{l as i,r as a}from"./color-BbAK7_Y7.js";import o,{stdin as s,stdout as c}from"node:process";import{stripVTControlCharacters as l}from"node:util";import*as u from"node:readline";import d from"node:readline";import{Writable as ee}from"node:stream";var f=t(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),p=e(f(),1),m=e(i(),1);function te({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const ne=te();function h(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(ne,``)}function g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var _={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(_);var re=_.exports;const ie=g(re),ae=g(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});function v(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=h(e),e.length===0))return 0;e=e.replace(ae(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(ie.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const y=(e=0)=>t=>`\x1B[${t+e}m`,b=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,x=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,S={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(S.modifier);const oe=Object.keys(S.color),se=Object.keys(S.bgColor);[...oe,...se];function ce(){let e=new Map;for(let[t,n]of Object.entries(S)){for(let[t,r]of Object.entries(n))S[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=S[t],e.set(r[0],r[1]);Object.defineProperty(S,t,{value:n,enumerable:!1})}return Object.defineProperty(S,`codes`,{value:e,enumerable:!1}),S.color.close=`\x1B[39m`,S.bgColor.close=`\x1B[49m`,S.color.ansi=y(),S.color.ansi256=b(),S.color.ansi16m=x(),S.bgColor.ansi=y(10),S.bgColor.ansi256=b(10),S.bgColor.ansi16m=x(10),Object.defineProperties(S,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>S.rgbToAnsi256(...S.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>S.ansi256ToAnsi(S.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>S.ansi256ToAnsi(S.hexToAnsi256(e)),enumerable:!1}}),S}const le=ce(),C=new Set([`\x1B`,`›`]),w=`]8;;`,T=e=>`${C.values().next().value}[${e}m`,E=e=>`${C.values().next().value}${w}${e}`,ue=e=>e.split(` `).map(e=>v(e)),D=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=v(h(e[e.length-1]));for(let[t,s]of r.entries()){let c=v(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),C.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(w)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},de=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(v(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},fe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=ue(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=v(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),D(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){D(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){D(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>de(e)));let c=[...s.join(`
2
+ `)];for(let[e,t]of c.entries()){if(r+=t,C.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${w}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=le.codes.get(Number(i));c[e+1]===`
3
+ `?(a&&(r+=E(``)),i&&n&&(r+=T(n))):t===`
4
+ `&&(i&&n&&(r+=T(i)),a&&(r+=E(a)))}return r};function O(e,t,n){return String(e).normalize().replace(/\r\n/g,`
5
+ `).split(`
6
+ `).map(e=>fe(e,t,n)).join(`
7
+ `)}const k={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]])};function A(e,t){if(typeof e==`string`)return k.aliases.get(e)===t;for(let n of e)if(n!==void 0&&A(n,t))return!0;return!1}function pe(e,t){if(e===t)return;let n=e.split(`
8
+ `),r=t.split(`
9
+ `),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}globalThis.process.platform.startsWith(`win`);const j=Symbol(`clack:cancel`);function M(e){return e===j}function N(e,t){let n=e;n.isTTY&&n.setRawMode(t)}var me=Object.defineProperty,he=(e,t,n)=>t in e?me(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t,n)=>(he(e,typeof t==`symbol`?t:t+``,n),n),F=class{constructor(e,t=!0){P(this,`input`),P(this,`output`),P(this,`_abortSignal`),P(this,`rl`),P(this,`opts`),P(this,`_render`),P(this,`_track`,!1),P(this,`_prevFrame`,``),P(this,`_subscribers`,new Map),P(this,`_cursor`,0),P(this,`state`,`initial`),P(this,`error`,``),P(this,`value`);let{input:n=s,output:r=c,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(j);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}let n=new ee;n._write=(e,t,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,``),this._cursor=this.rl?.cursor??0,this.emit(`value`,this.value)),n()},this.input.pipe(n),this.rl=d.createInterface({input:this.input,output:n,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),d.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),N(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(p.cursor.show),this.output.off(`resize`,this.render),N(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(p.cursor.show),this.output.off(`resize`,this.render),N(this.input,!1),e(j)})})}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&k.aliases.has(t.name)&&this.emit(`cursor`,k.aliases.get(t.name)),k.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.value))}this.state!==`error`&&(this.state=`submit`)}A([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
10
+ `),N(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=O(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
11
+ `).length-1;this.output.write(p.cursor.move(-999,e*-1))}render(){let e=O(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(p.cursor.hide);else{let t=pe(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(p.cursor.move(0,n)),this.output.write(p.erase.lines(1));let r=e.split(`
12
+ `);this.output.write(r[n]),this._prevFrame=e,this.output.write(p.cursor.move(0,r.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(p.cursor.move(0,n)),this.output.write(p.erase.down());let r=e.split(`
13
+ `).slice(n);this.output.write(r.join(`
14
+ `)),this._prevFrame=e;return}this.output.write(p.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},ge=class extends F{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(p.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}};Object.defineProperty,Object.defineProperty;var _e=Object.defineProperty,ve=(e,t,n)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t,n)=>(ve(e,typeof t==`symbol`?t:t+``,n),n),ye=class extends F{constructor({mask:e,...t}){super(t),I(this,`valueWithCursor`,``),I(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${m.default.inverse(m.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${m.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}};Object.defineProperty,Object.defineProperty;var be=class extends F{get valueWithCursor(){if(this.state===`submit`)return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${m.default.inverse(t)}${n.join(``)}`}get cursor(){return this._cursor}constructor(e){super(e),this.on(`finalize`,()=>{this.value||=e.defaultValue})}},L=e(i(),1);f();function xe(){return o.platform===`win32`?!!o.env.CI||!!o.env.WT_SESSION||!!o.env.TERMINUS_SUBLIME||o.env.ConEmuTask===`{cmd::Cmder}`||o.env.TERM_PROGRAM===`Terminus-Sublime`||o.env.TERM_PROGRAM===`vscode`||o.env.TERM===`xterm-256color`||o.env.TERM===`alacritty`||o.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:o.env.TERM!==`linux`}const Se=xe(),R=(e,t)=>Se?e:t,Ce=R(`◆`,`*`),we=R(`■`,`x`),Te=R(`▲`,`x`),z=R(`◇`,`o`),B=R(`│`,`|`),V=R(`└`,`—`),H=R(`●`,`>`),U=R(`○`,` `),Ee=R(`▪`,`•`),W=R(`●`,`•`),G=R(`◆`,`*`),K=R(`▲`,`!`),q=R(`■`,`x`),J=e=>{switch(e){case`initial`:case`active`:return L.default.cyan(Ce);case`cancel`:return L.default.red(we);case`error`:return L.default.yellow(Te);case`submit`:return L.default.green(z)}},De=e=>new be({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${L.default.gray(B)}
15
+ ${J(this.state)} ${e.message}
16
+ `,n=e.placeholder?L.default.inverse(e.placeholder[0])+L.default.dim(e.placeholder.slice(1)):L.default.inverse(L.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
17
+ ${L.default.yellow(B)} ${r}
18
+ ${L.default.yellow(V)} ${L.default.yellow(this.error)}
19
+ `;case`submit`:return`${t}${L.default.gray(B)} ${L.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${L.default.gray(B)} ${L.default.strikethrough(L.default.dim(this.value??``))}${this.value?.trim()?`
20
+ ${L.default.gray(B)}`:``}`;default:return`${t}${L.default.cyan(B)} ${r}
21
+ ${L.default.cyan(V)}
22
+ `}}}).prompt(),Oe=e=>new ye({validate:e.validate,mask:e.mask??Ee,render(){let t=`${L.default.gray(B)}
23
+ ${J(this.state)} ${e.message}
24
+ `,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
25
+ ${L.default.yellow(B)} ${r}
26
+ ${L.default.yellow(V)} ${L.default.yellow(this.error)}
27
+ `;case`submit`:return`${t}${L.default.gray(B)} ${L.default.dim(r)}`;case`cancel`:return`${t}${L.default.gray(B)} ${L.default.strikethrough(L.default.dim(r??``))}${r?`
28
+ ${L.default.gray(B)}`:``}`;default:return`${t}${L.default.cyan(B)} ${n}
29
+ ${L.default.cyan(V)}
30
+ `}}}).prompt(),ke=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new ge({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${L.default.gray(B)}
31
+ ${J(this.state)} ${e.message}
32
+ `,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${L.default.gray(B)} ${L.default.dim(i)}`;case`cancel`:return`${r}${L.default.gray(B)} ${L.default.strikethrough(L.default.dim(i))}
33
+ ${L.default.gray(B)}`;default:return`${r}${L.default.cyan(B)} ${this.value?`${L.default.green(H)} ${t}`:`${L.default.dim(U)} ${L.default.dim(t)}`} ${L.default.dim(`/`)} ${this.value?`${L.default.dim(U)} ${L.default.dim(n)}`:`${L.default.green(H)} ${n}`}
34
+ ${L.default.cyan(V)}
35
+ `}}}).prompt()},Y={message:(e=``,{symbol:t=L.default.gray(B)}={})=>{let n=[`${L.default.gray(B)}`];if(e){let[r,...i]=e.split(`
36
+ `);n.push(`${t} ${r}`,...i.map(e=>`${L.default.gray(B)} ${e}`))}process.stdout.write(`${n.join(`
37
+ `)}
38
+ `)},info:e=>{Y.message(e,{symbol:L.default.blue(W)})},success:e=>{Y.message(e,{symbol:L.default.green(G)})},step:e=>{Y.message(e,{symbol:L.default.green(z)})},warn:e=>{Y.message(e,{symbol:L.default.yellow(K)})},warning:e=>{Y.warn(e)},error:e=>{Y.message(e,{symbol:L.default.red(q)})}},Ae=`${L.default.gray(B)} `,X={message:async(e,{symbol:t=L.default.gray(B)}={})=>{process.stdout.write(`${L.default.gray(B)}
39
+ ${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
40
+ ${Ae}`),t.includes(`
41
+ `)&&(n=3+l(t.slice(t.lastIndexOf(`
42
+ `))).length);let e=l(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
43
+ ${Ae}${t.trimStart()}`),n=3+l(t.trimStart()).length)}process.stdout.write(`
44
+ `)},info:e=>X.message(e,{symbol:L.default.blue(W)}),success:e=>X.message(e,{symbol:L.default.green(G)}),step:e=>X.message(e,{symbol:L.default.green(z)}),warn:e=>X.message(e,{symbol:L.default.yellow(K)}),warning:e=>X.warn(e),error:e=>X.message(e,{symbol:L.default.red(q)})};let je=!0;function Me(e){je=e}function Z(){return je&&!!process.stdin.isTTY&&!process.env.CI}function Q(e,t){if(!Z())throw r(`${e} is required and there is no terminal to ask on`,t??`Pass it as a flag, or rerun without --no-input`)}function $(){process.stderr.write(a(`Cancelled.
45
+ `)),process.exit(n.CANCELLED)}async function Ne(e,t={}){Q(e,t.hint);let n=await Oe({message:e,validate:t.validate});return M(n)&&$(),n}async function Pe(e,t={}){Q(e,t.hint);let n=await De({message:e,placeholder:t.placeholder,initialValue:t.initialValue,validate:t.validate});return M(n)&&$(),n}async function Fe(e,t={}){let n=typeof t==`boolean`?{initialValue:t}:t;if(n.assumeYes)return!0;Q(e,n.hint??`Pass --yes to confirm without a prompt`);let r=await ke({message:e,initialValue:n.initialValue??!1});return M(r)&&$(),r}export{Me as a,Pe as i,Fe as n,Ne as r,Z as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./exit-codes-IaZq17dv.js";import{f as t,n}from"./errors-Dkv23Z0t.js";import"./version--HODInrs.js";import"./color-BbAK7_Y7.js";import{c as r,f as i,g as a,h as o,i as s,n as c,o as l,p as u,r as d,s as f,u as p,v as m}from"./output-uP7GrsdR.js";import{n as h,t as g}from"./time-B5S7M7Dg.js";import{d as _}from"./config-Bg2ls0gu.js";import{t as v}from"./product-CXL7Ga4M.js";import"./http-DpMu6AKn.js";import{f as y,r as b,u as x}from"./types-Bu8scNHe.js";import{i as S,n as C}from"./prompt-DR68wwvQ.js";import{T as w,_ as T,a as E,h as D,i as O,r as k,s as A}from"./client-R8kBz1Ou.js";import{a as j,t as M}from"./keyword-BjASkU-P.js";import{resolve as N}from"node:path";import{readFile as P}from"node:fs/promises";const F=[`ACTIVE`,`PENDING`,`DISABLED`,`SUSPENDED`];function I(e){let t={ACTIVE:0,PENDING:0,DISABLED:0,SUSPENDED:0};for(let n of e.keywords)t[n.status]+=1;return t}function L(e){let t=I(e),n=F.filter(e=>t[e]>0).map(e=>`${t[e]} ${e.toLowerCase()}`);return n.length===0?`none`:n.join(`, `)}function R(e,n=`--url`){let r=e.trim(),i;try{i=new URL(r)}catch{throw t(`${n} must be a full URL, got "${e}"`,`${v.binName} site create --url https://acme.com`)}if(i.protocol!==`https:`&&i.protocol!==`http:`)throw t(`${n} must be an http or https URL, got "${e}"`);return r}async function z(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}async function B(e){let n=(e===`-`?await z():e.startsWith(`@`)?await V(e.slice(1)):e).trim();if(n.length>b)throw t(`--description is ${n.length} characters, the limit is ${b}`);return n}async function V(t){try{return await P(N(t),`utf8`)}catch(r){throw new n(`Cannot read ${t}: ${r.message}`,{exitCode:e.USAGE,cause:r})}}const H=[{header:`ID`,value:e=>d(e.id)},{header:`DOMAIN`,value:e=>e.domain},{header:`NAME`,value:e=>e.name||`—`},{header:`KEYWORDS`,value:e=>L(e)},{header:`DESCRIPTION`,value:e=>e.description?`yes`:`missing`}],U=[{header:`ID`,value:e=>d(e.id)},{header:`KEYWORD`,value:e=>e.value},{header:`STATUS`,value:e=>e.status},{header:`ADDED`,value:e=>e.createdAt?h(new Date(e.createdAt)):`—`}];async function W(e,t){let n=f()||l()?null:y(e);try{return await t()}finally{n?.stop()}}async function G(){let{websites:e}=await W(`Loading sites…`,T);if(l()){u(`site.list`,e,{total:e.length,hasMore:!1}),p(e);return}if(e.length===0){r(`No sites yet.`),s(`add one: ${v.binName} site create --url https://acme.com -k "your keyword"`);return}o(e,H),r(``),r(`${e.length} ${e.length===1?`site`:`sites`}`);for(let t of e)t.description||(m(`${t.domain} has no description. Its mentions are not scored.`),s(` fix: ${v.binName} site analyze --url ${t.url}`));let t=e.reduce((e,t)=>e+I(t).PENDING,0);s(`Listing sites activates any PENDING keyword that fits your plan’s free headroom.`),t>0&&s(`${t} keyword${t===1?``:`s`} still PENDING, there was no free slot. Price an upgrade: ${v.binName} keyword plan`)}async function K(e){let t=await W(`Loading site…`,()=>D(e));if(l()){u(`site.get`,t);return}r(t.id),i([[`domain`,t.domain],[`url`,t.url],[`name`,t.name||`—`],[`description`,t.description?`${t.description.length} characters`:`missing, mentions are not scored`],[`keywords`,L(t)],[`created`,t.createdAt?g(new Date(t.createdAt),{timezone:`UTC`}):`—`]]),t.keywords.length>0&&(r(``),o(t.keywords,U)),t.description||(r(``),s(`fix: ${v.binName} site analyze --url ${t.url}`))}async function q(t){let o=R(t.url),f=j(t.keyword),p=t.description===void 0?void 0:await B(t.description),h;if(p!==void 0)h={url:o,keywords:f,description:p,...t.name?{name:t.name}:{}};else if(t.analyze===!1)h={url:o,keywords:f,description:``,...t.name?{name:t.name}:{}},m(`--no-analyze sends an empty description, so nothing this site collects will be scored.`);else{let r=new URL(o).hostname;if(m(`No --description given. The server will scrape ${r} and spend one AI generation from this month’s quota.`),!l()&&!await C(`Continue?`,{assumeYes:t.yes===!0,initialValue:!0}))throw new n(`Cancelled.`,{exitCode:e.CANCELLED});h={url:o,keywords:f,...t.name?{name:t.name}:{}}}let g=await W(`Creating site…`,()=>E(h));if(l()){u(`site.create`,g);return}a(`Created ${d(g.id)} ${g.domain}`),i([[`description`,g.description?`${p===void 0?`generated`:`stored`} (${g.description.length} chars)`:`missing`],[`keywords`,L(g)]]),!g.description&&t.analyze!==!1&&(r(``),c(`Description generation failed. Mentions will be unscored ("Scoring skipped: website description missing").`),s(`retry: ${v.binName} site analyze --url ${g.url}`)),I(g).PENDING>0&&s(`Some keywords are PENDING. Price an upgrade: ${v.binName} keyword plan`)}async function J(e,n){let o={};if(n.name!==void 0&&(o.name=n.name),n.description!==void 0&&(o.description=await B(n.description)),Object.keys(o).length===0)throw t(`Nothing to update.`,`Pass --name, --description, or both`);let s=await W(`Updating site…`,()=>w(e,o));if(l()){u(`site.update`,s);return}a(`Updated ${d(s.id)} ${s.domain}`),i([[`name`,s.name||`—`],[`description`,s.description?`${s.description.length} characters`:`missing`]]),r(`Existing mentions are not rescored.`)}async function Y(t,i){let o=await W(`Loading site…`,()=>D(t)),{total:s}=await O({websiteId:o.id,statuses:[...x],includeLowRelevance:!0});if(i.yes!==!0&&(r(`This deletes ${o.domain}, its ${o.keywords.length} keyword${o.keywords.length===1?``:`s`} and ${s} collected mention${s===1?``:`s`}.`),(await S(`Type the domain to confirm`,{hint:`Pass --yes to delete without typing the domain`})).trim()!==o.domain))throw new n(`That is not "${o.domain}", nothing was deleted.`,{exitCode:e.CANCELLED});let c=await A(o.id);if(l()){u(`site.delete`,c);return}a(`Deleted`)}async function X(t){let r=R(t.url);if(m(`This spends one AI generation from this month’s quota unless a precomputed description exists for the domain. A failed generation is refunded.`),!l()&&!await C(`Continue?`,{assumeYes:t.yes===!0,initialValue:!0}))throw new n(`Cancelled.`,{exitCode:e.CANCELLED});let{description:i}=await W(`Analysing…`,()=>k({url:r}));if(l()){u(`site.analyze`,{description:i});return}process.stdout.write(`${i}\n`),s(`store it: ${_(`FORCE_TTY`)}=1 ${v.binName} site analyze --url ${r} | ${v.binName} site update <id> --description -`)}function Z(e){let t=e.command(`site`).alias(`sites`).description(`monitored websites and their keywords`);t.command(`list`).alias(`ls`).description(`list every monitored site`).action(async()=>{await G()}),t.command(`get <id>`).alias(`view`).description(`show one site with its full keyword table`).action(async e=>{await K(e)}),t.command(`create`).description(`start monitoring a website`).requiredOption(`--url <url>`,`the website to monitor`).option(`--name <name>`,`label for the site`).option(`-k, --keyword <keyword>`,`keyword to watch, repeatable`,M,[]).option(`--description <text>`,`what the site does; @file reads a file, - reads stdin`).option(`--no-analyze`,`send an empty description and skip the paid scrape`).action(async(e,t)=>{await q(t.optsWithGlobals())}),t.command(`update <id>`).description(`rename a site or replace its description`).option(`--name <name>`,`new label for the site`).option(`--description <text>`,`new description; @file reads a file, - reads stdin`).action(async(e,t)=>{await J(e,t)}),t.command(`delete <id>`).alias(`rm`).description(`delete a site, its keywords and every mention they produced`).action(async(e,t,n)=>{await Y(e,n.optsWithGlobals())}),t.command(`analyze`).description(`generate a site description from its URL`).requiredOption(`--url <url>`,`the website to read`).action(async(e,t)=>{await X(t.optsWithGlobals())})}export{R as assertWebsiteUrl,L as describeKeywords,I as keywordCounts,B as readDescription,Z as registerSiteCommands};
@@ -0,0 +1 @@
1
+ import{f as e}from"./errors-Dkv23Z0t.js";const t=1e3,n=60*t,r=60*n,i=24*r,a=7*i,o={ms:1,milliseconds:1,s:t,sec:t,secs:t,second:t,seconds:t,m:n,min:n,mins:n,minute:n,minutes:n,h:r,hr:r,hrs:r,hour:r,hours:r,d:i,day:i,days:i,w:a,week:a,weeks:a},s=/(\d+(?:\.\d+)?)\s*([a-z]+)/g,c=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/i,l=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{1,2}):(\d{2})(?::(\d{2}))?)?$/,u=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/,d=/^(today|tomorrow|yesterday)(?:\s+(.+))?$/;function f(e){if(typeof e!=`string`||e.trim()===``)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}),!0}catch{return!1}}function p(t){if(!f(t))throw e(`"${t}" is not a valid IANA time zone.`,`Use a zone name such as "Europe/Berlin" or "UTC".`);return t}function m(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function h(e){let t=e.trim().toLowerCase();if(t===``)return null;let n=t.startsWith(`-`)?-1:1,r=(t.startsWith(`+`)||t.startsWith(`-`)?t.slice(1):t).replace(/\s+/g,``);if(r===``)return null;s.lastIndex=0;let i=0,a=0,c;for(;(c=s.exec(r))!==null;){let e=o[c[2]];if(e===void 0)return null;i+=Number(c[1])*e,a+=c[0].length}return a===0||a!==r.length?null:n*i}function g(e,t={}){let n=t.now??new Date,r=t.timezone??`UTC`,i=e.trim();if(i===``)throw k(e);let a=i.toLowerCase();if(a===`now`)return new Date(n.getTime());if(c.test(i)){let t=new Date(i.replace(` `,`T`));if(Number.isNaN(t.getTime()))throw k(e);return t}if(i.startsWith(`+`)||i.startsWith(`-`)){let t=h(i);if(t===null)throw k(e);return new Date(n.getTime()+t)}let o=d.exec(a);if(o!==null){let t=o[1]===`tomorrow`?1:o[1]===`yesterday`?-1:0,i=x(o[2]);if(i===null)throw k(e);return w({...C(S(n,r),t),...i},r)}let s=l.exec(i);if(s!==null)return w({year:Number(s[1]),month:Number(s[2]),day:Number(s[3]),hour:s[4]===void 0?0:Number(s[4]),minute:s[5]===void 0?0:Number(s[5]),second:s[6]===void 0?0:Number(s[6])},r);if(/^\d/.test(a)){let e=h(a);if(e!==null)return new Date(n.getTime()+e)}throw k(e)}function _(e){return e.toISOString()}function v(e,t={}){let n=t.timezone??`UTC`,r=S(e,n),i=`${O(r.year,4)}-${O(r.month,2)}-${O(r.day,2)} ${O(r.hour,2)}:${O(r.minute,2)}`+(t.seconds===!0?`:${O(r.second,2)}`:``);return t.withZone===!1?i:`${i} ${n}`}function y(e,n={}){let r=n.now??new Date,i=e.getTime()-r.getTime(),a=Math.abs(i);if(a<t)return`now`;let o=b(a);return i<0?`${o} ago`:`in ${o}`}function b(e){return e<n?`${Math.max(1,Math.floor(e/t))}s`:e<r?`${Math.floor(e/n)}m`:e<i?`${Math.floor(e/r)}h`:e<30*i?`${Math.floor(e/i)}d`:e<365*i?`${Math.floor(e/(30*i))}mo`:`${Math.floor(e/(365*i))}y`}function x(e){if(e===void 0||e.trim()===``)return{hour:0,minute:0,second:0};let t=u.exec(e.trim());if(t===null)return null;let n=Number(t[1]),r=Number(t[2]),i=t[3]===void 0?0:Number(t[3]);return n>23||r>59||i>59?null:{hour:n,minute:r,second:i}}function S(e,t){let n=D(t).formatToParts(e),r=e=>{let t=n.find(t=>t.type===e);return t===void 0?0:Number(t.value)},i=r(`hour`);return{year:r(`year`),month:r(`month`),day:r(`day`),hour:i===24?0:i,minute:r(`minute`),second:r(`second`)}}function C(e,t){let n=new Date(Date.UTC(e.year,e.month-1,e.day+t));return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:e.hour,minute:e.minute,second:e.second}}function w(e,t){p(t);let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second),r=n-T(new Date(n),t);return r=n-T(new Date(r),t),new Date(r)}function T(e,t){let n=S(e,t);return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-(e.getTime()-e.getUTCMilliseconds())}const E=new Map;function D(e){let t=E.get(e);if(t!==void 0)return t;let n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return E.set(e,n),n}function O(e,t){return String(e).padStart(t,`0`)}function k(t){return e(`Could not read "${t}" as a date.`,`Use ISO 8601 (2026-09-20T09:00:00Z), an offset (+2h), a duration (30m), or "tomorrow 09:00".`)}export{_ as a,m as i,y as n,g as r,v as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,t as n}from"./color-BbAK7_Y7.js";import{o as r,s as i}from"./output-uP7GrsdR.js";const a=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`];function o(){return!!process.stderr.isTTY&&!process.env.CI&&!i()&&!r()}function s(r){let i=r,s=0,c=o(),l=()=>{process.stderr.write(`\r\u001b[2K${n(a[s++%a.length])} ${i}`)},u=c?setInterval(l,80):void 0;u?.unref?.(),c&&l();let d=()=>{c&&(clearInterval(u),process.stderr.write(`\r\x1B[2K`))};return{update(e){return i=e,this},stop(e){d(),c&&e&&process.stderr.write(`${e}\n`)},succeed(e){this.stop(t(`✓ ${e??i}`))},fail(t){this.stop(e(`✗ ${t??i}`))}}}const c=[`REDDIT_POST`,`REDDIT_COMMENT`,`TWITTER`,`BLUESKY`,`HACKERNEWS`,`FACEBOOK`,`FACEBOOK_GROUP`],l=[`NEW`,`APPROVED`,`REJECTED`],u=[`VERY_LOW`,`LOW`,`MEDIUM`,`HIGH`,`VERY_HIGH`],d=[`RELEVANCE`,`RECENT`],f=[15,30,60,120,180,240,720,1440],p=255,m=5e3,h=1,g=500,_=50,v=100;export{_ as a,d as c,u as d,s as f,v as i,c as l,p as n,g as o,m as r,h as s,f as t,l as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./version--HODInrs.js";import{c as t,r as n}from"./color-BbAK7_Y7.js";import{D as r,d as i,y as a}from"./config-Bg2ls0gu.js";import{t as o}from"./product-CXL7Ga4M.js";const s=1440*60*1e3,c=2e3,l=`https://registry.npmjs.org`;function u(e,t){let n=e=>{let[t,n]=e.replace(/^v/,``).split(`-`,2);return{parts:t.split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n??``}},r=n(e),i=n(t);for(let e=0;e<3;e+=1){let t=(r.parts[e]??0)-(i.parts[e]??0);if(t!==0)return t<0?-1:1}return r.pre===i.pre?0:r.pre===``?1:i.pre===``||r.pre<i.pre?-1:1}async function d(e=o.npmPackage,t=c){let n=await fetch(`${l}/${e.replace(`/`,`%2f`)}/latest`,{headers:{accept:`application/vnd.npm.install-v1+json, application/json`},signal:AbortSignal.timeout(t)});if(!n.ok)return;let r=await n.json();return typeof r.version==`string`?r.version:void 0}function f(e){return e.quiet||process.env.CI||process.env[i(`NO_UPDATE_CHECK`)]?!0:e.force?!1:!process.stdout.isTTY}async function p(t={}){if(f(t))return;let n=t.now??Date.now(),i;try{i=a()}catch{return}if(i.updateCheck===!1)return;let o=i.lastUpdateCheck,c=o?.checked?Date.parse(o.checked):NaN,l=!t.force&&Number.isFinite(c)&&n-c<s,p=l?o?.latest:void 0;if(!l){let e;try{e=await d()}catch{return}if(!e)return;p=e;let t={checked:new Date(n).toISOString(),latest:e};try{r(e=>{e.lastUpdateCheck=t})}catch{return}}if(p&&!(u(p,e)<=0))return{current:e,latest:p}}function m(e){process.stderr.write(`${t(`A new version of ${o.binName} is available: ${e.latest}`)} ${n(`(you have ${e.current})`)}\n`),process.stderr.write(n(`Update: npm i -g ${o.npmPackage} · disable: ${o.binName} config set updateCheck false\n`))}async function h(e={}){try{let t=await p(e);t&&m(t)}catch{return}}export{u as a,h as c,p as i,s as n,d as o,c as r,m as s,l as t};
@@ -0,0 +1 @@
1
+ import"./exit-codes-IaZq17dv.js";import"./errors-Dkv23Z0t.js";import"./version--HODInrs.js";import"./color-BbAK7_Y7.js";import"./config-Bg2ls0gu.js";import"./product-CXL7Ga4M.js";import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./update-check-BaOMxkuv.js";export{s as REGISTRY_URL,r as UPDATE_CHECK_INTERVAL_MS,a as UPDATE_CHECK_TIMEOUT_MS,n as checkForUpdate,e as compareSemver,i as fetchLatestVersion,o as printUpdateNotice,t as runUpdateCheck};
@@ -0,0 +1 @@
1
+ const e=`0.1.0`,t=process.versions.node,n=`${process.platform}-${process.arch}`;function r(r){return`${r}/${e} node-v${t} ${n}`}function i(r){return`${r}-cli/${e} node/${t} ${n}`}export{r as a,i,n,e as r,t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r,t as i}from"./version--HODInrs.js";export{i as NODE_VERSION,n as PLATFORM,r as VERSION,t as userAgent,e as versionLine};
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@redreplier/cli",
3
+ "version": "0.1.0",
4
+ "description": "RedReplier from your terminal",
5
+ "keywords": [
6
+ "cli",
7
+ "redreplier",
8
+ "reddit",
9
+ "hacker-news",
10
+ "social-listening",
11
+ "monitoring",
12
+ "leads",
13
+ "claude",
14
+ "cursor",
15
+ "windsurf"
16
+ ],
17
+ "homepage": "https://redreplier.com",
18
+ "bugs": {
19
+ "url": "https://github.com/RedReplier/redreplier-cli/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/RedReplier/redreplier-cli.git"
24
+ },
25
+ "license": "MIT",
26
+ "author": "RedReplier <contact@redreplier.com> (https://redreplier.com)",
27
+ "type": "module",
28
+ "bin": {
29
+ "redreplier": "./dist/cli.js",
30
+ "rr": "./dist/cli.js"
31
+ },
32
+ "exports": {
33
+ "./package.json": "./package.json"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "engines": {
41
+ "node": ">=22.12.0"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public",
45
+ "provenance": true
46
+ },
47
+ "sideEffects": false,
48
+ "scripts": {
49
+ "build": "tsdown",
50
+ "dev": "tsdown --watch",
51
+ "typecheck": "tsc --noEmit",
52
+ "lint": "eslint src",
53
+ "test": "vitest run",
54
+ "compile": "bun build src/cli.ts --compile --minify --sourcemap --define __CLI_VERSION__=\"\\\"$npm_package_version\\\"\" --outfile dist/redreplier",
55
+ "sync-core": "sh scripts/sync-core.sh",
56
+ "prepack": "npm run build"
57
+ },
58
+ "devDependencies": {
59
+ "@clack/prompts": "^0.11.0",
60
+ "@types/node": "^22.15.0",
61
+ "commander": "^14.0.0",
62
+ "eslint": "^9.39.0",
63
+ "picocolors": "^1.1.1",
64
+ "tsdown": "^0.15.0",
65
+ "typescript": "5.9.3",
66
+ "typescript-eslint": "^8.46.0",
67
+ "vitest": "^3.2.0"
68
+ }
69
+ }