@uipath/auth 0.1.7 → 0.1.9

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 (2) hide show
  1. package/dist/index.js +102 -977
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1,35 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
2
  var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
3
  var __returnValue = (v) => v;
34
4
  function __exportSetter(name, newValue) {
35
5
  this[name] = __returnValue.bind(null, newValue);
@@ -60,64 +30,6 @@ function getGlobalThis() {
60
30
  return;
61
31
  }
62
32
 
63
- // ../../node_modules/sisteransi/src/index.js
64
- var require_src = __commonJS((exports, module) => {
65
- var ESC = "\x1B";
66
- var CSI = `${ESC}[`;
67
- var beep = "\x07";
68
- var cursor = {
69
- to(x, y) {
70
- if (!y)
71
- return `${CSI}${x + 1}G`;
72
- return `${CSI}${y + 1};${x + 1}H`;
73
- },
74
- move(x, y) {
75
- let ret = "";
76
- if (x < 0)
77
- ret += `${CSI}${-x}D`;
78
- else if (x > 0)
79
- ret += `${CSI}${x}C`;
80
- if (y < 0)
81
- ret += `${CSI}${-y}A`;
82
- else if (y > 0)
83
- ret += `${CSI}${y}B`;
84
- return ret;
85
- },
86
- up: (count = 1) => `${CSI}${count}A`,
87
- down: (count = 1) => `${CSI}${count}B`,
88
- forward: (count = 1) => `${CSI}${count}C`,
89
- backward: (count = 1) => `${CSI}${count}D`,
90
- nextLine: (count = 1) => `${CSI}E`.repeat(count),
91
- prevLine: (count = 1) => `${CSI}F`.repeat(count),
92
- left: `${CSI}G`,
93
- hide: `${CSI}?25l`,
94
- show: `${CSI}?25h`,
95
- save: `${ESC}7`,
96
- restore: `${ESC}8`
97
- };
98
- var scroll = {
99
- up: (count = 1) => `${CSI}S`.repeat(count),
100
- down: (count = 1) => `${CSI}T`.repeat(count)
101
- };
102
- var erase = {
103
- screen: `${CSI}2J`,
104
- up: (count = 1) => `${CSI}1J`.repeat(count),
105
- down: (count = 1) => `${CSI}J`.repeat(count),
106
- line: `${CSI}2K`,
107
- lineEnd: `${CSI}K`,
108
- lineStart: `${CSI}1K`,
109
- lines(count) {
110
- let clear = "";
111
- for (let i = 0;i < count; i++)
112
- clear += this.line + (i < count - 1 ? cursor.up() : "");
113
- if (count)
114
- clear += cursor.left;
115
- return clear;
116
- }
117
- };
118
- module.exports = { cursor, scroll, erase, beep };
119
- });
120
-
121
33
  // src/strategies/browser-strategy.ts
122
34
  var exports_browser_strategy = {};
123
35
  __export(exports_browser_strategy, {
@@ -254,13 +166,29 @@ var getBaseHtml = ({ title, message, type }) => {
254
166
  border-top: 3px solid var(--color-accent);
255
167
  border-radius: 12px;
256
168
  padding: 40px 32px;
169
+ text-align: center;
170
+ }
171
+ .logo {
172
+ display: flex;
173
+ justify-content: center;
174
+ margin-bottom: 24px;
175
+ }
176
+ .logo svg {
177
+ width: 160px;
178
+ height: auto;
179
+ }
180
+ .logo-dark { display: none; }
181
+ .logo-light { display: block; }
182
+ @media (prefers-color-scheme: dark) {
183
+ .logo-dark { display: block; }
184
+ .logo-light { display: none; }
257
185
  }
258
186
  .icon {
259
187
  width: 56px;
260
188
  height: 56px;
261
189
  border-radius: 50%;
262
190
  font-size: 28px;
263
- display: flex;
191
+ display: inline-flex;
264
192
  align-items: center;
265
193
  justify-content: center;
266
194
  margin-bottom: 16px;
@@ -298,6 +226,14 @@ var getBaseHtml = ({ title, message, type }) => {
298
226
  <body>
299
227
  <div class="container">
300
228
  <div class="card">
229
+ <div class="logo">
230
+ <div class="logo-light">
231
+ <svg aria-hidden="true" width="400" height="116" viewBox="0 0 400 116" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M62.6439 33.1429H60.885C56.2918 33.1429 53.4387 35.9377 53.4387 40.4355V76.6177C53.4387 93.7722 48.1098 100.769 35.0451 100.769C21.9804 100.769 16.6514 93.7405 16.6514 76.5097V40.4355C16.6514 35.9377 13.7982 33.1429 9.20575 33.1429H7.44592C2.85326 33.1429 0 35.9377 0 40.4355V76.6177C0 102.75 11.7912 116 35.0451 116C58.2991 116 70.0897 102.75 70.0897 76.6177V40.4355C70.0897 35.9377 67.2364 33.1429 62.6439 33.1429Z" fill="black"/><path d="M91.1326 55.0988H89.6751C84.9685 55.0988 82.0451 58.0021 82.0451 62.6744V108.425C82.0451 113.097 84.9685 116 89.6751 116H91.1326C95.8386 116 98.762 113.097 98.762 108.425V62.6744C98.762 58.0021 95.8386 55.0988 91.1326 55.0988Z" fill="#FA4616"/><path d="M111.322 26.7778C100.684 25.0967 92.2902 16.8376 90.5818 6.37143C90.5496 6.17388 90.2894 6.17388 90.2572 6.37143C88.5488 16.8376 80.1548 25.0967 69.5175 26.7778C69.3167 26.8094 69.3167 27.0656 69.5175 27.0973C80.1548 28.7781 88.5488 37.0375 90.2572 47.5037C90.2894 47.7012 90.5496 47.7012 90.5818 47.5037C92.2902 37.0375 100.684 28.7781 111.322 27.0973C111.522 27.0656 111.522 26.8095 111.322 26.7778ZM100.87 27.0174C95.5518 27.8578 91.3548 31.9875 90.5007 37.2206C90.4845 37.3194 90.3544 37.3194 90.3383 37.2206C89.4841 31.9875 85.2871 27.8578 79.9685 27.0174C79.868 27.0016 79.868 26.8735 79.9685 26.8577C85.2871 26.0171 89.4841 21.8876 90.3383 16.6545C90.3544 16.5557 90.4845 16.5557 90.5007 16.6545C91.3548 21.8876 95.5518 26.0171 100.87 26.8577C100.971 26.8735 100.971 27.0016 100.87 27.0174Z" fill="#FA4616"/><path d="M117.694 10.4371C112.376 11.2774 108.179 15.4071 107.325 20.6402C107.308 20.739 107.178 20.739 107.162 20.6402C106.308 15.4071 102.111 11.2774 96.7923 10.4371C96.6919 10.4212 96.6919 10.2931 96.7923 10.2773C102.111 9.43674 106.308 5.3072 107.162 0.0740898C107.178 -0.0246966 107.308 -0.0246966 107.325 0.0740898C108.179 5.3072 112.376 9.43672 117.694 10.2773C117.795 10.2931 117.795 10.4212 117.694 10.4371Z" fill="#FA4616"/><path d="M135.312 33.1429H119.087C114.445 33.1429 111.561 35.9675 111.561 40.5133V108.63C111.561 113.175 114.445 116 119.087 116H120.865C125.507 116 128.391 113.175 128.391 108.63V92.5058H135.423C163.58 92.5058 175.066 83.9066 175.066 62.8243C175.066 41.742 163.548 33.1429 135.312 33.1429ZM158.014 62.6068C158.014 73.4525 152.762 77.1123 137.201 77.1123H128.391V48.2095H137.201C152.762 48.2095 158.014 51.8421 158.014 62.6068Z" fill="black"/><path d="M237.564 48.4739H236.23C231.589 48.4739 228.705 51.2986 228.705 55.8444V55.8538C223.938 50.4474 216.554 47.2772 208.114 47.2772C199.516 47.2772 191.74 50.3711 186.22 55.9903C180.207 62.1094 177.029 70.9412 177.029 81.5299C177.029 92.1647 180.226 101.047 186.274 107.217C191.825 112.881 199.621 116 208.225 116C216.505 116 223.944 112.79 228.711 107.462C228.711 107.468 228.711 108.998 228.712 109.004C228.866 113.33 231.717 116 236.23 116H237.564C242.206 116 245.089 113.176 245.089 108.631V55.8444C245.089 51.2986 242.206 48.4739 237.564 48.4739ZM229.038 81.5299C229.038 93.9678 222.256 101.695 211.337 101.695C200.281 101.695 193.414 93.9678 193.414 81.5299C193.414 69.1579 200.196 61.473 211.115 61.473C222.003 61.473 229.038 69.3462 229.038 81.5299Z" fill="black"/><path d="M334.448 47.3426C325.733 47.3426 319.516 50.7418 315.624 55.0257V40.518C315.624 35.9693 312.738 33.1429 308.094 33.1429H306.759C302.115 33.1429 299.229 35.9693 299.229 40.518V108.625C299.229 113.174 302.115 116 306.759 116H308.094C312.738 116 315.624 113.174 315.624 108.625V81.2897C315.624 63.7895 324.146 61.7658 330.556 61.7658C341.32 61.7658 345.711 67.0126 345.711 79.8747V108.625C345.711 113.174 348.596 116 353.241 116H354.576C359.22 116 362.105 113.174 362.105 108.625V78.8939C362.105 57.6628 353.059 47.3426 334.448 47.3426Z" fill="black"/><path d="M294.515 107.664C294.284 105.472 292.945 102.34 286.565 102.34C279.021 102.34 275.431 100.037 275.431 86.9529V61.7659H286.675C291.313 61.7659 294.194 59.19 294.194 55.0447C294.194 50.9661 291.313 48.4318 286.675 48.4318H275.444V40.518C275.444 35.9693 272.541 33.1429 267.869 33.1429H266.526C261.854 33.1429 258.951 35.9693 258.951 40.518V48.4318H256.366C252.276 48.4318 249.736 50.9661 249.736 55.0447C249.736 59.19 252.617 61.7659 257.254 61.7659H258.951V88.369C258.951 107.737 266.645 116 284.677 116C284.707 116 284.736 115.999 284.765 115.998C285.813 115.997 286.937 115.981 288.081 115.881C290.354 115.67 292.073 114.886 293.191 113.546C294.305 112.213 294.75 109.871 294.515 107.664Z" fill="black"/><path d="M367.331 47.6328V36.4082H364.1C362.823 36.4082 362.105 35.8367 362.105 34.7755C362.105 33.7143 362.823 33.1428 364.1 33.1428H373.952C375.228 33.1428 375.946 33.7143 375.946 34.7755C375.946 35.8367 375.228 36.4082 373.952 36.4082H370.801V47.6328C370.801 48.939 370.203 49.6733 369.086 49.6733C367.969 49.6733 367.331 48.939 367.331 47.6328ZM377.822 49.7139C376.745 49.7139 376.174 48.8937 376.465 47.4695L379.018 34.9388C379.258 33.7553 379.976 33.1428 381.172 33.1428H381.771C382.887 33.1428 383.637 33.6775 384.044 34.7341L388.192 45.5096L392.38 34.7341C392.795 33.6652 393.577 33.1428 394.694 33.1428H395.252C396.449 33.1428 397.167 33.7553 397.406 34.9388L399.919 47.4695C400.206 48.8979 399.72 49.7143 398.643 49.7143C397.486 49.7143 396.772 49.1022 396.529 47.9183L394.415 37.6736L390.426 48.1226C390.007 49.2164 389.309 49.7139 388.232 49.7139C387.115 49.7139 386.417 49.2164 385.998 48.1226L382.01 37.6736L379.935 47.9183C379.696 49.1022 378.978 49.7139 377.822 49.7139Z" fill="black"/></svg>
232
+ </div>
233
+ <div class="logo-dark">
234
+ <svg aria-hidden="true" width="400" height="116" viewBox="0 0 400 116" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M62.6439 33.1428H60.885C56.2918 33.1428 53.4387 35.9376 53.4387 40.4354V76.6177C53.4387 93.7722 48.1098 100.769 35.0451 100.769C21.9804 100.769 16.6514 93.7404 16.6514 76.5096V40.4354C16.6514 35.9377 13.7982 33.1428 9.20575 33.1428H7.44592C2.85326 33.1428 0 35.9377 0 40.4354V76.6177C0 102.75 11.7912 116 35.0451 116C58.2991 116 70.0897 102.75 70.0897 76.6177V40.4354C70.0897 35.9377 67.2364 33.1428 62.6439 33.1428Z" fill="white"/><path d="M91.1326 55.0989H89.6751C84.9685 55.0989 82.0451 58.0021 82.0451 62.6744V108.425C82.0451 113.097 84.9685 116 89.6751 116H91.1326C95.8386 116 98.762 113.097 98.762 108.425V62.6744C98.762 58.0021 95.8386 55.0989 91.1326 55.0989Z" fill="white"/><path d="M111.322 26.7778C100.684 25.0967 92.2902 16.8376 90.5818 6.37143C90.5496 6.17388 90.2894 6.17388 90.2572 6.37143C88.5488 16.8376 80.1548 25.0967 69.5175 26.7778C69.3167 26.8094 69.3167 27.0656 69.5175 27.0973C80.1548 28.7781 88.5488 37.0375 90.2572 47.5037C90.2894 47.7012 90.5496 47.7012 90.5818 47.5037C92.2902 37.0375 100.684 28.7781 111.322 27.0973C111.522 27.0656 111.522 26.8095 111.322 26.7778ZM100.87 27.0174C95.5518 27.8578 91.3548 31.9875 90.5007 37.2206C90.4845 37.3194 90.3544 37.3194 90.3383 37.2206C89.4841 31.9875 85.2871 27.8578 79.9685 27.0174C79.868 27.0016 79.868 26.8735 79.9685 26.8577C85.2871 26.0171 89.4841 21.8876 90.3383 16.6545C90.3544 16.5557 90.4845 16.5557 90.5007 16.6545C91.3548 21.8876 95.5518 26.0171 100.87 26.8577C100.971 26.8735 100.971 27.0016 100.87 27.0174Z" fill="white"/><path d="M117.694 10.4371C112.376 11.2774 108.179 15.4071 107.325 20.6402C107.308 20.739 107.178 20.739 107.162 20.6402C106.308 15.4071 102.111 11.2774 96.7923 10.4371C96.6919 10.4212 96.6919 10.2931 96.7923 10.2773C102.111 9.43674 106.308 5.3072 107.162 0.0740898C107.178 -0.0246966 107.308 -0.0246966 107.325 0.0740898C108.179 5.3072 112.376 9.43672 117.694 10.2773C117.795 10.2931 117.795 10.4212 117.694 10.4371Z" fill="white"/><path d="M135.312 33.1428H119.087C114.445 33.1428 111.561 35.9674 111.561 40.5133V108.63C111.561 113.175 114.445 116 119.087 116H120.865C125.507 116 128.391 113.175 128.391 108.63V92.5057H135.423C163.58 92.5057 175.066 83.9066 175.066 62.8243C175.066 41.7419 163.548 33.1428 135.312 33.1428ZM158.014 62.6067C158.014 73.4525 152.762 77.1123 137.201 77.1123H128.391V48.2095H137.201C152.762 48.2095 158.014 51.842 158.014 62.6067Z" fill="white"/><path d="M237.564 48.4739H236.23C231.589 48.4739 228.705 51.2986 228.705 55.8444V55.8538C223.938 50.4474 216.554 47.2772 208.114 47.2772C199.516 47.2772 191.74 50.3711 186.22 55.9903C180.207 62.1094 177.029 70.9412 177.029 81.5299C177.029 92.1647 180.226 101.047 186.274 107.217C191.825 112.881 199.621 116 208.225 116C216.505 116 223.944 112.79 228.711 107.462C228.711 107.468 228.711 108.998 228.712 109.004C228.866 113.33 231.717 116 236.23 116H237.564C242.206 116 245.089 113.176 245.089 108.631V55.8444C245.089 51.2986 242.206 48.4739 237.564 48.4739ZM229.038 81.5299C229.038 93.9678 222.256 101.695 211.337 101.695C200.281 101.695 193.414 93.9678 193.414 81.5299C193.414 69.1579 200.196 61.473 211.115 61.473C222.003 61.473 229.038 69.3462 229.038 81.5299Z" fill="white"/><path d="M334.448 47.3425C325.733 47.3425 319.516 50.7417 315.624 55.0256V40.5179C315.624 35.9693 312.738 33.1428 308.094 33.1428H306.759C302.115 33.1428 299.229 35.9693 299.229 40.5179V108.625C299.229 113.174 302.115 116 306.759 116H308.094C312.738 116 315.624 113.174 315.624 108.625V81.2897C315.624 63.7894 324.146 61.7657 330.556 61.7657C341.32 61.7657 345.711 67.0125 345.711 79.8746V108.625C345.711 113.174 348.596 116 353.241 116H354.576C359.22 116 362.105 113.174 362.105 108.625V78.8938C362.105 57.6627 353.059 47.3425 334.448 47.3425Z" fill="white"/><path d="M294.515 107.664C294.284 105.472 292.945 102.34 286.565 102.34C279.021 102.34 275.431 100.037 275.431 86.9529V61.7658H286.675C291.313 61.7658 294.194 59.19 294.194 55.0446C294.194 50.966 291.313 48.4317 286.675 48.4317H275.444V40.5179C275.444 35.9693 272.541 33.1428 267.869 33.1428H266.526C261.854 33.1428 258.951 35.9693 258.951 40.5179V48.4317H256.366C252.276 48.4317 249.736 50.966 249.736 55.0446C249.736 59.19 252.617 61.7658 257.254 61.7658H258.951V88.3689C258.951 107.737 266.645 116 284.677 116C284.707 116 284.736 115.999 284.765 115.998C285.813 115.997 286.937 115.981 288.081 115.881C290.354 115.67 292.073 114.885 293.191 113.546C294.305 112.213 294.75 109.87 294.515 107.664Z" fill="white"/><path d="M367.331 47.6328V36.4082H364.1C362.823 36.4082 362.105 35.8367 362.105 34.7755C362.105 33.7143 362.823 33.1428 364.1 33.1428H373.952C375.228 33.1428 375.946 33.7143 375.946 34.7755C375.946 35.8367 375.228 36.4082 373.952 36.4082H370.801V47.6328C370.801 48.939 370.203 49.6733 369.086 49.6733C367.969 49.6733 367.331 48.939 367.331 47.6328ZM377.822 49.7139C376.745 49.7139 376.174 48.8937 376.465 47.4695L379.018 34.9388C379.258 33.7553 379.976 33.1428 381.172 33.1428H381.771C382.887 33.1428 383.637 33.6775 384.044 34.7341L388.192 45.5096L392.38 34.7341C392.795 33.6652 393.577 33.1428 394.694 33.1428H395.252C396.449 33.1428 397.167 33.7553 397.406 34.9388L399.919 47.4695C400.206 48.8979 399.72 49.7143 398.643 49.7143C397.486 49.7143 396.772 49.1022 396.529 47.9183L394.415 37.6736L390.426 48.1226C390.007 49.2164 389.309 49.7139 388.232 49.7139C387.115 49.7139 386.417 49.2164 385.998 48.1226L382.01 37.6736L379.935 47.9183C379.696 49.1022 378.978 49.7139 377.822 49.7139Z" fill="white"/></svg>
235
+ </div>
236
+ </div>
301
237
  <div class="icon ${iconClass}">${icon}</div>
302
238
  <h1>${title}</h1>
303
239
  <p>${message}</p>
@@ -438,7 +374,7 @@ var init_node_strategy = __esm(() => {
438
374
  import { DEFAULT_REDIRECT_URI } from "@uipath/common";
439
375
 
440
376
  // src/config.ts
441
- import { DEFAULT_BASE_URL } from "@uipath/common";
377
+ import { catchError, DEFAULT_BASE_URL } from "@uipath/common";
442
378
 
443
379
  // src/utils/loadConfig.ts
444
380
  import {
@@ -14135,20 +14071,17 @@ var resolveConfigAsync = async ({
14135
14071
  while (baseUrl.endsWith("/")) {
14136
14072
  baseUrl = baseUrl.slice(0, -1);
14137
14073
  }
14138
- try {
14139
- const url2 = new URL(baseUrl);
14140
- const isValidUiPathDomain = url2.hostname === "uipath.com" || url2.hostname.endsWith(".uipath.com");
14141
- if (!isValidUiPathDomain) {
14142
- throw new InvalidBaseUrlError(baseUrl, `Domain "${url2.hostname}" is not a valid UiPath domain. Only uipath.com and its subdomains are allowed.`);
14143
- }
14144
- if (url2.pathname.length > 1) {
14145
- baseUrl = url2.origin;
14146
- }
14147
- } catch (error48) {
14148
- if (error48 instanceof InvalidBaseUrlError) {
14149
- throw error48;
14150
- }
14151
- throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${error48 instanceof Error ? error48.message : "Unknown error"}`);
14074
+ const resolvedBaseUrl = baseUrl;
14075
+ const [urlError, url2] = catchError(() => new URL(resolvedBaseUrl));
14076
+ if (urlError) {
14077
+ throw new InvalidBaseUrlError(baseUrl, `Malformed URL. ${urlError instanceof Error ? urlError.message : "Unknown error"}`);
14078
+ }
14079
+ const isValidUiPathDomain = url2.hostname === "uipath.com" || url2.hostname.endsWith(".uipath.com");
14080
+ if (!isValidUiPathDomain) {
14081
+ throw new InvalidBaseUrlError(baseUrl, `Domain "${url2.hostname}" is not a valid UiPath domain. Only uipath.com and its subdomains are allowed.`);
14082
+ }
14083
+ if (url2.pathname.length > 1) {
14084
+ baseUrl = url2.origin;
14152
14085
  }
14153
14086
  let clientId = customClientId;
14154
14087
  if (!clientId) {
@@ -14866,6 +14799,7 @@ Troubleshooting:` + `
14866
14799
  };
14867
14800
  // src/interactive.ts
14868
14801
  import {
14802
+ catchError as catchError2,
14869
14803
  getOutputFormat,
14870
14804
  logger as logger6,
14871
14805
  OutputFormatter,
@@ -14884,848 +14818,41 @@ var AuthTelemetryEvents = {
14884
14818
  // src/tenantSelection.ts
14885
14819
  import { logger as logger4 } from "@uipath/common";
14886
14820
 
14887
- // ../../node_modules/@clack/core/dist/index.mjs
14888
- import { styleText as D } from "node:util";
14889
- import { stdout as R, stdin as q } from "node:process";
14890
- var import_sisteransi = __toESM(require_src(), 1);
14891
- import ot from "node:readline";
14892
- function x(t, e, s) {
14893
- if (!s.some((u) => !u.disabled))
14894
- return t;
14895
- const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
14896
- return s[n].disabled ? x(n, e < 0 ? -1 : 1, s) : n;
14897
- }
14898
- var at = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109;
14899
- var lt = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510;
14900
- var ht = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141;
14901
- var O = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
14902
- var y = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
14903
- var L = /\t{1,1000}/y;
14904
- var P = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
14905
- var M = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
14906
- var ct = /\p{M}+/gu;
14907
- var ft = { limit: 1 / 0, ellipsis: "" };
14908
- var X = (t, e = {}, s = {}) => {
14909
- const i = e.limit ?? 1 / 0, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X(r, ft, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
14910
- let h = 0, o = 0, p = t.length, v = 0, F = false, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
14911
- t:
14912
- for (;; ) {
14913
- if (w > C || o >= p && o > h) {
14914
- const ut = t.slice(C, w) || t.slice(h, o);
14915
- v = 0;
14916
- for (const Y of ut.replaceAll(ct, "")) {
14917
- const $ = Y.codePointAt(0) || 0;
14918
- if (lt($) ? f = m : ht($) ? f = V : E !== A && at($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
14919
- F = true;
14920
- break t;
14921
- }
14922
- v += Y.length, c += f;
14923
- }
14924
- C = w = 0;
14925
- }
14926
- if (o >= p)
14927
- break;
14928
- if (M.lastIndex = o, M.test(t)) {
14929
- if (v = M.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
14930
- F = true;
14931
- break;
14932
- }
14933
- c += f, C = h, w = o, o = h = M.lastIndex;
14934
- continue;
14935
- }
14936
- if (O.lastIndex = o, O.test(t)) {
14937
- if (c + u > b && (d = Math.min(d, o)), c + u > i) {
14938
- F = true;
14939
- break;
14940
- }
14941
- c += u, C = h, w = o, o = h = O.lastIndex;
14942
- continue;
14943
- }
14944
- if (y.lastIndex = o, y.test(t)) {
14945
- if (v = y.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
14946
- F = true;
14947
- break;
14948
- }
14949
- c += f, C = h, w = o, o = h = y.lastIndex;
14950
- continue;
14951
- }
14952
- if (L.lastIndex = o, L.test(t)) {
14953
- if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
14954
- F = true;
14955
- break;
14956
- }
14957
- c += f, C = h, w = o, o = h = L.lastIndex;
14958
- continue;
14959
- }
14960
- if (P.lastIndex = o, P.test(t)) {
14961
- if (c + g > b && (d = Math.min(d, o)), c + g > i) {
14962
- F = true;
14963
- break;
14964
- }
14965
- c += g, C = h, w = o, o = h = P.lastIndex;
14966
- continue;
14967
- }
14968
- o += 1;
14969
- }
14970
- return { width: F ? b : c, index: F ? d : p, truncated: F, ellipsed: F && i >= n };
14971
- };
14972
- var pt = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
14973
- var S = (t, e = {}) => X(t, pt, e).width;
14974
- var T = "\x1B";
14975
- var Z = "›";
14976
- var Ft = 39;
14977
- var j = "\x07";
14978
- var Q = "[";
14979
- var dt = "]";
14980
- var tt = "m";
14981
- var U = `${dt}8;;`;
14982
- var et = new RegExp(`(?:\\${Q}(?<code>\\d+)m|\\${U}(?<uri>.*)${j})`, "y");
14983
- var mt = (t) => {
14984
- if (t >= 30 && t <= 37 || t >= 90 && t <= 97)
14985
- return 39;
14986
- if (t >= 40 && t <= 47 || t >= 100 && t <= 107)
14987
- return 49;
14988
- if (t === 1 || t === 2)
14989
- return 22;
14990
- if (t === 3)
14991
- return 23;
14992
- if (t === 4)
14993
- return 24;
14994
- if (t === 7)
14995
- return 27;
14996
- if (t === 8)
14997
- return 28;
14998
- if (t === 9)
14999
- return 29;
15000
- if (t === 0)
15001
- return 0;
15002
- };
15003
- var st = (t) => `${T}${Q}${t}${tt}`;
15004
- var it = (t) => `${T}${U}${t}${j}`;
15005
- var gt = (t) => t.map((e) => S(e));
15006
- var G = (t, e, s) => {
15007
- const i = e[Symbol.iterator]();
15008
- let r = false, n = false, u = t.at(-1), a = u === undefined ? 0 : S(u), l = i.next(), E = i.next(), g = 0;
15009
- for (;!l.done; ) {
15010
- const m = l.value, A = S(m);
15011
- a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === T || m === Z) && (r = true, n = e.startsWith(U, g + 1)), r ? n ? m === j && (r = false, n = false) : m === tt && (r = false) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
15012
- }
15013
- u = t.at(-1), !a && u !== undefined && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
15014
- };
15015
- var vt = (t) => {
15016
- const e = t.split(" ");
15017
- let s = e.length;
15018
- for (;s > 0 && !(S(e[s - 1]) > 0); )
15019
- s--;
15020
- return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
15021
- };
15022
- var Et = (t, e, s = {}) => {
15023
- if (s.trim !== false && t.trim() === "")
15024
- return "";
15025
- let i = "", r, n;
15026
- const u = t.split(" "), a = gt(u);
15027
- let l = [""];
15028
- for (const [h, o] of u.entries()) {
15029
- s.trim !== false && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
15030
- let p = S(l.at(-1) ?? "");
15031
- if (h !== 0 && (p >= e && (s.wordWrap === false || s.trim === false) && (l.push(""), p = 0), (p > 0 || s.trim === false) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
15032
- const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
15033
- Math.floor((a[h] - 1) / e) < F && l.push(""), G(l, o, e);
15034
- continue;
15035
- }
15036
- if (p + a[h] > e && p > 0 && a[h] > 0) {
15037
- if (s.wordWrap === false && p < e) {
15038
- G(l, o, e);
15039
- continue;
15040
- }
15041
- l.push("");
15042
- }
15043
- if (p + a[h] > e && s.wordWrap === false) {
15044
- G(l, o, e);
15045
- continue;
15046
- }
15047
- l[l.length - 1] += o;
15048
- }
15049
- s.trim !== false && (l = l.map((h) => vt(h)));
15050
- const E = l.join(`
15051
- `), g = E[Symbol.iterator]();
15052
- let m = g.next(), A = g.next(), V = 0;
15053
- for (;!m.done; ) {
15054
- const h = m.value, o = A.value;
15055
- if (i += h, h === T || h === Z) {
15056
- et.lastIndex = V + 1;
15057
- const F = et.exec(E)?.groups;
15058
- if (F?.code !== undefined) {
15059
- const d = Number.parseFloat(F.code);
15060
- r = d === Ft ? undefined : d;
15061
- } else
15062
- F?.uri !== undefined && (n = F.uri.length === 0 ? undefined : F.uri);
15063
- }
15064
- const p = r ? mt(r) : undefined;
15065
- o === `
15066
- ` ? (n && (i += it("")), r && p && (i += st(p))) : h === `
15067
- ` && (r && p && (i += st(r)), n && (i += it(n))), V += h.length, m = A, A = g.next();
15068
- }
15069
- return i;
15070
- };
15071
- function K(t, e, s) {
15072
- return String(t).normalize().replaceAll(`\r
15073
- `, `
15074
- `).split(`
15075
- `).map((i) => Et(i, e, s)).join(`
15076
- `);
15077
- }
15078
- var At = ["up", "down", "left", "right", "space", "enter", "cancel"];
15079
- var _ = { actions: new Set(At), aliases: new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"], ["\x03", "cancel"], ["escape", "cancel"]]), messages: { cancel: "Canceled", error: "Something went wrong" }, withGuide: true };
15080
- function H(t, e) {
15081
- if (typeof t == "string")
15082
- return _.aliases.get(t) === e;
15083
- for (const s of t)
15084
- if (s !== undefined && H(s, e))
15085
- return true;
15086
- return false;
15087
- }
15088
- function _t(t, e) {
15089
- if (t === e)
15090
- return;
15091
- const s = t.split(`
15092
- `), i = e.split(`
15093
- `), r = Math.max(s.length, i.length), n = [];
15094
- for (let u = 0;u < r; u++)
15095
- s[u] !== i[u] && n.push(u);
15096
- return { lines: n, numLinesBefore: s.length, numLinesAfter: i.length, numLines: r };
15097
- }
15098
- var bt = globalThis.process.platform.startsWith("win");
15099
- var z2 = Symbol("clack:cancel");
15100
- function Ct(t) {
15101
- return t === z2;
15102
- }
15103
- function W(t, e) {
15104
- const s = t;
15105
- s.isTTY && s.setRawMode(e);
15106
- }
15107
- var rt = (t) => ("columns" in t) && typeof t.columns == "number" ? t.columns : 80;
15108
- var nt = (t) => ("rows" in t) && typeof t.rows == "number" ? t.rows : 20;
15109
- function Bt(t, e, s, i = s) {
15110
- const r = rt(t ?? R);
15111
- return K(e, r - s.length, { hard: true, trim: false }).split(`
15112
- `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
15113
- `);
15114
- }
15115
-
15116
- class B {
15117
- input;
15118
- output;
15119
- _abortSignal;
15120
- rl;
15121
- opts;
15122
- _render;
15123
- _track = false;
15124
- _prevFrame = "";
15125
- _subscribers = new Map;
15126
- _cursor = 0;
15127
- state = "initial";
15128
- error = "";
15129
- value;
15130
- userInput = "";
15131
- constructor(e, s = true) {
15132
- const { input: i = q, output: r = R, render: n, signal: u, ...a } = e;
15133
- this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
15134
- }
15135
- unsubscribe() {
15136
- this._subscribers.clear();
15137
- }
15138
- setSubscriber(e, s) {
15139
- const i = this._subscribers.get(e) ?? [];
15140
- i.push(s), this._subscribers.set(e, i);
15141
- }
15142
- on(e, s) {
15143
- this.setSubscriber(e, { cb: s });
15144
- }
15145
- once(e, s) {
15146
- this.setSubscriber(e, { cb: s, once: true });
15147
- }
15148
- emit(e, ...s) {
15149
- const i = this._subscribers.get(e) ?? [], r = [];
15150
- for (const n of i)
15151
- n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
15152
- for (const n of r)
15153
- n();
15154
- }
15155
- prompt() {
15156
- return new Promise((e) => {
15157
- if (this._abortSignal) {
15158
- if (this._abortSignal.aborted)
15159
- return this.state = "cancel", this.close(), e(z2);
15160
- this._abortSignal.addEventListener("abort", () => {
15161
- this.state = "cancel", this.close();
15162
- }, { once: true });
15163
- }
15164
- this.rl = ot.createInterface({ input: this.input, tabSize: 2, prompt: "", escapeCodeTimeout: 50, terminal: true }), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), W(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
15165
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(this.value);
15166
- }), this.once("cancel", () => {
15167
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), W(this.input, false), e(z2);
15168
- });
15169
- });
15170
- }
15171
- _isActionKey(e, s) {
15172
- return e === "\t";
15173
- }
15174
- _setValue(e) {
15175
- this.value = e, this.emit("value", this.value);
15176
- }
15177
- _setUserInput(e, s) {
15178
- this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
15179
- }
15180
- _clearUserInput() {
15181
- this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
15182
- }
15183
- onKeypress(e, s) {
15184
- if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _.aliases.has(s.name) && this.emit("cursor", _.aliases.get(s.name)), _.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
15185
- if (this.opts.validate) {
15186
- const i = this.opts.validate(this.value);
15187
- i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
15188
- }
15189
- this.state !== "error" && (this.state = "submit");
15190
- }
15191
- H([e, s?.name, s?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
15192
- }
15193
- close() {
15194
- this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
15195
- `), W(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
15196
- }
15197
- restoreCursor() {
15198
- const e = K(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
15199
- `).length - 1;
15200
- this.output.write(import_sisteransi.cursor.move(-999, e * -1));
15201
- }
15202
- render() {
15203
- const e = K(this._render(this) ?? "", process.stdout.columns, { hard: true, trim: false });
15204
- if (e !== this._prevFrame) {
15205
- if (this.state === "initial")
15206
- this.output.write(import_sisteransi.cursor.hide);
15207
- else {
15208
- const s = _t(this._prevFrame, e), i = nt(this.output);
15209
- if (this.restoreCursor(), s) {
15210
- const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
15211
- let u = s.lines.find((a) => a >= r);
15212
- if (u === undefined) {
15213
- this._prevFrame = e;
15214
- return;
15215
- }
15216
- if (s.lines.length === 1) {
15217
- this.output.write(import_sisteransi.cursor.move(0, u - n)), this.output.write(import_sisteransi.erase.lines(1));
15218
- const a = e.split(`
15219
- `);
15220
- this.output.write(a[u]), this._prevFrame = e, this.output.write(import_sisteransi.cursor.move(0, a.length - u - 1));
15221
- return;
15222
- } else if (s.lines.length > 1) {
15223
- if (r < n)
15224
- u = r;
15225
- else {
15226
- const l = u - n;
15227
- l > 0 && this.output.write(import_sisteransi.cursor.move(0, l));
15228
- }
15229
- this.output.write(import_sisteransi.erase.down());
15230
- const a = e.split(`
15231
- `).slice(u);
15232
- this.output.write(a.join(`
15233
- `)), this._prevFrame = e;
15234
- return;
15235
- }
15236
- }
15237
- this.output.write(import_sisteransi.erase.down());
15238
- }
15239
- this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
15240
- }
15241
- }
15242
- }
15243
- function wt(t, e) {
15244
- if (t === undefined || e.length === 0)
15245
- return 0;
15246
- const s = e.findIndex((i) => i.value === t);
15247
- return s !== -1 ? s : 0;
15248
- }
15249
- function Dt(t, e) {
15250
- return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
15251
- }
15252
- function St(t, e) {
15253
- if (e)
15254
- return t ? e : e[0];
15255
- }
15256
-
15257
- class Vt extends B {
15258
- filteredOptions;
15259
- multiple;
15260
- isNavigating = false;
15261
- selectedValues = [];
15262
- focusedValue;
15263
- #t = 0;
15264
- #s = "";
15265
- #i;
15266
- #e;
15267
- get cursor() {
15268
- return this.#t;
15269
- }
15270
- get userInputWithCursor() {
15271
- if (!this.userInput)
15272
- return D(["inverse", "hidden"], "_");
15273
- if (this._cursor >= this.userInput.length)
15274
- return `${this.userInput}█`;
15275
- const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
15276
- return `${e}${D("inverse", s)}${i.join("")}`;
15277
- }
15278
- get options() {
15279
- return typeof this.#e == "function" ? this.#e() : this.#e;
15280
- }
15281
- constructor(e) {
15282
- super(e), this.#e = e.options;
15283
- const s = this.options;
15284
- this.filteredOptions = [...s], this.multiple = e.multiple === true, this.#i = e.filter ?? Dt;
15285
- let i;
15286
- if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
15287
- for (const r of i) {
15288
- const n = s.findIndex((u) => u.value === r);
15289
- n !== -1 && (this.toggleSelected(r), this.#t = n);
15290
- }
15291
- this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
15292
- }
15293
- _isActionKey(e, s) {
15294
- return e === "\t" || this.multiple && this.isNavigating && s.name === "space" && e !== undefined && e !== "";
15295
- }
15296
- #r(e, s) {
15297
- const i = s.name === "up", r = s.name === "down", n = s.name === "return";
15298
- i || r ? (this.#t = x(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = St(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== undefined && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
15299
- }
15300
- deselectAll() {
15301
- this.selectedValues = [];
15302
- }
15303
- toggleSelected(e) {
15304
- this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
15305
- }
15306
- #n(e) {
15307
- if (e !== this.#s) {
15308
- this.#s = e;
15309
- const s = this.options;
15310
- e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
15311
- const i = wt(this.focusedValue, this.filteredOptions);
15312
- this.#t = x(i, 0, this.filteredOptions);
15313
- const r = this.filteredOptions[this.#t];
15314
- r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = undefined, this.multiple || (this.focusedValue !== undefined ? this.toggleSelected(this.focusedValue) : this.deselectAll());
15315
- }
15316
- }
15317
- }
15318
- class yt extends B {
15319
- options;
15320
- cursor = 0;
15321
- #t;
15322
- getGroupItems(e) {
15323
- return this.options.filter((s) => s.group === e);
15324
- }
15325
- isGroupSelected(e) {
15326
- const s = this.getGroupItems(e), i = this.value;
15327
- return i === undefined ? false : s.every((r) => i.includes(r.value));
15328
- }
15329
- toggleValue() {
15330
- const e = this.options[this.cursor];
15331
- if (this.value === undefined && (this.value = []), e.group === true) {
15332
- const s = e.value, i = this.getGroupItems(s);
15333
- this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
15334
- } else {
15335
- const s = this.value.includes(e.value);
15336
- this.value = s ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
15337
- }
15338
- }
15339
- constructor(e) {
15340
- super(e, false);
15341
- const { options: s } = e;
15342
- this.#t = e.selectableGroups !== false, this.options = Object.entries(s).flatMap(([i, r]) => [{ value: i, group: true, label: i }, ...r.map((n) => ({ ...n, group: i }))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
15343
- switch (i) {
15344
- case "left":
15345
- case "up": {
15346
- this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
15347
- const r = this.options[this.cursor]?.group === true;
15348
- !this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
15349
- break;
15350
- }
15351
- case "down":
15352
- case "right": {
15353
- this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
15354
- const r = this.options[this.cursor]?.group === true;
15355
- !this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
15356
- break;
15357
- }
15358
- case "space":
15359
- this.toggleValue();
15360
- break;
15361
- }
15362
- });
15363
- }
15364
- }
15365
- class Tt extends B {
15366
- options;
15367
- cursor = 0;
15368
- get _selectedValue() {
15369
- return this.options[this.cursor];
15370
- }
15371
- changeValue() {
15372
- this.value = this._selectedValue.value;
15373
- }
15374
- constructor(e) {
15375
- super(e, false), this.options = e.options;
15376
- const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
15377
- this.cursor = this.options[i].disabled ? x(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
15378
- switch (r) {
15379
- case "left":
15380
- case "up":
15381
- this.cursor = x(this.cursor, -1, this.options);
15382
- break;
15383
- case "down":
15384
- case "right":
15385
- this.cursor = x(this.cursor, 1, this.options);
15386
- break;
15387
- }
15388
- this.changeValue();
15389
- });
15390
- }
15391
- }
15392
-
15393
- // ../../node_modules/@clack/prompts/dist/index.mjs
15394
- import { styleText as t, stripVTControlCharacters as ue } from "node:util";
15395
- import N2 from "node:process";
15396
- var import_sisteransi2 = __toESM(require_src(), 1);
15397
- function pt2() {
15398
- return N2.platform !== "win32" ? N2.env.TERM !== "linux" : !!N2.env.CI || !!N2.env.WT_SESSION || !!N2.env.TERMINUS_SUBLIME || N2.env.ConEmuTask === "{cmd::Cmder}" || N2.env.TERM_PROGRAM === "Terminus-Sublime" || N2.env.TERM_PROGRAM === "vscode" || N2.env.TERM === "xterm-256color" || N2.env.TERM === "alacritty" || N2.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
15399
- }
15400
- var ee = pt2();
15401
- var I2 = (e, r) => ee ? e : r;
15402
- var Re = I2("◆", "*");
15403
- var $e = I2("■", "x");
15404
- var de = I2("▲", "x");
15405
- var V = I2("◇", "o");
15406
- var he = I2("┌", "T");
15407
- var h = I2("│", "|");
15408
- var x2 = I2("└", "—");
15409
- var Oe = I2("┐", "T");
15410
- var Pe = I2("┘", "—");
15411
- var z3 = I2("●", ">");
15412
- var H2 = I2("○", " ");
15413
- var te = I2("◻", "[•]");
15414
- var U2 = I2("◼", "[+]");
15415
- var q2 = I2("◻", "[ ]");
15416
- var Ne = I2("▪", "•");
15417
- var se = I2("─", "-");
15418
- var pe = I2("╮", "+");
15419
- var We = I2("├", "+");
15420
- var me = I2("╯", "+");
15421
- var ge = I2("╰", "+");
15422
- var Ge = I2("╭", "+");
15423
- var fe = I2("●", "•");
15424
- var Fe = I2("◆", "*");
15425
- var ye = I2("▲", "!");
15426
- var Ee = I2("■", "x");
15427
- var W2 = (e) => {
15428
- switch (e) {
15429
- case "initial":
15430
- case "active":
15431
- return t("cyan", Re);
15432
- case "cancel":
15433
- return t("red", $e);
15434
- case "error":
15435
- return t("yellow", de);
15436
- case "submit":
15437
- return t("green", V);
15438
- }
15439
- };
15440
- var ve = (e) => {
15441
- switch (e) {
15442
- case "initial":
15443
- case "active":
15444
- return t("cyan", h);
15445
- case "cancel":
15446
- return t("red", h);
15447
- case "error":
15448
- return t("yellow", h);
15449
- case "submit":
15450
- return t("green", h);
15451
- }
15452
- };
15453
- var mt2 = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109;
15454
- var gt2 = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510;
15455
- var ft2 = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141;
15456
- var we = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y;
15457
- var re = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
15458
- var ie = /\t{1,1000}/y;
15459
- var Ae = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
15460
- var ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
15461
- var Ft2 = /\p{M}+/gu;
15462
- var yt2 = { limit: 1 / 0, ellipsis: "" };
15463
- var Le = (e, r = {}, s = {}) => {
15464
- const i = r.limit ?? 1 / 0, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? Le(a, yt2, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, p = s.emojiWidth ?? 2, f = s.fullWidthWidth ?? 2, g = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
15465
- let $ = 0, m = 0, d = e.length, F = 0, y2 = false, v = d, C = Math.max(0, i - o), A = 0, b = 0, w = 0, S2 = 0;
15466
- e:
15467
- for (;; ) {
15468
- if (b > A || m >= d && m > $) {
15469
- const T2 = e.slice(A, b) || e.slice($, m);
15470
- F = 0;
15471
- for (const M2 of T2.replaceAll(Ft2, "")) {
15472
- const O2 = M2.codePointAt(0) || 0;
15473
- if (gt2(O2) ? S2 = f : ft2(O2) ? S2 = E : c !== g && mt2(O2) ? S2 = c : S2 = g, w + S2 > C && (v = Math.min(v, Math.max(A, $) + F)), w + S2 > i) {
15474
- y2 = true;
15475
- break e;
15476
- }
15477
- F += M2.length, w += S2;
15478
- }
15479
- A = b = 0;
15480
- }
15481
- if (m >= d)
15482
- break;
15483
- if (ne.lastIndex = m, ne.test(e)) {
15484
- if (F = ne.lastIndex - m, S2 = F * g, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / g))), w + S2 > i) {
15485
- y2 = true;
15486
- break;
15487
- }
15488
- w += S2, A = $, b = m, m = $ = ne.lastIndex;
15489
- continue;
15490
- }
15491
- if (we.lastIndex = m, we.test(e)) {
15492
- if (w + u > C && (v = Math.min(v, m)), w + u > i) {
15493
- y2 = true;
15494
- break;
15495
- }
15496
- w += u, A = $, b = m, m = $ = we.lastIndex;
15497
- continue;
15498
- }
15499
- if (re.lastIndex = m, re.test(e)) {
15500
- if (F = re.lastIndex - m, S2 = F * l, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / l))), w + S2 > i) {
15501
- y2 = true;
15502
- break;
15503
- }
15504
- w += S2, A = $, b = m, m = $ = re.lastIndex;
15505
- continue;
15506
- }
15507
- if (ie.lastIndex = m, ie.test(e)) {
15508
- if (F = ie.lastIndex - m, S2 = F * n, w + S2 > C && (v = Math.min(v, m + Math.floor((C - w) / n))), w + S2 > i) {
15509
- y2 = true;
15510
- break;
15511
- }
15512
- w += S2, A = $, b = m, m = $ = ie.lastIndex;
15513
- continue;
15514
- }
15515
- if (Ae.lastIndex = m, Ae.test(e)) {
15516
- if (w + p > C && (v = Math.min(v, m)), w + p > i) {
15517
- y2 = true;
15518
- break;
15519
- }
15520
- w += p, A = $, b = m, m = $ = Ae.lastIndex;
15521
- continue;
15522
- }
15523
- m += 1;
15524
- }
15525
- return { width: y2 ? C : w, index: y2 ? v : d, truncated: y2, ellipsed: y2 && i >= o };
15526
- };
15527
- var Et2 = { limit: 1 / 0, ellipsis: "", ellipsisWidth: 0 };
15528
- var D2 = (e, r = {}) => Le(e, Et2, r).width;
15529
- var ae = "\x1B";
15530
- var je = "›";
15531
- var vt2 = 39;
15532
- var Ce = "\x07";
15533
- var ke = "[";
15534
- var wt2 = "]";
15535
- var Ve = "m";
15536
- var Se = `${wt2}8;;`;
15537
- var He = new RegExp(`(?:\\${ke}(?<code>\\d+)m|\\${Se}(?<uri>.*)${Ce})`, "y");
15538
- var At2 = (e) => {
15539
- if (e >= 30 && e <= 37 || e >= 90 && e <= 97)
15540
- return 39;
15541
- if (e >= 40 && e <= 47 || e >= 100 && e <= 107)
15542
- return 49;
15543
- if (e === 1 || e === 2)
15544
- return 22;
15545
- if (e === 3)
15546
- return 23;
15547
- if (e === 4)
15548
- return 24;
15549
- if (e === 7)
15550
- return 27;
15551
- if (e === 8)
15552
- return 28;
15553
- if (e === 9)
15554
- return 29;
15555
- if (e === 0)
15556
- return 0;
15557
- };
15558
- var Ue = (e) => `${ae}${ke}${e}${Ve}`;
15559
- var Ke = (e) => `${ae}${Se}${e}${Ce}`;
15560
- var Ct2 = (e) => e.map((r) => D2(r));
15561
- var Ie = (e, r, s) => {
15562
- const i = r[Symbol.iterator]();
15563
- let a = false, o = false, u = e.at(-1), l = u === undefined ? 0 : D2(u), n = i.next(), c = i.next(), p = 0;
15564
- for (;!n.done; ) {
15565
- const f = n.value, g = D2(f);
15566
- l + g <= s ? e[e.length - 1] += f : (e.push(f), l = 0), (f === ae || f === je) && (a = true, o = r.startsWith(Se, p + 1)), a ? o ? f === Ce && (a = false, o = false) : f === Ve && (a = false) : (l += g, l === s && !c.done && (e.push(""), l = 0)), n = c, c = i.next(), p += f.length;
15567
- }
15568
- u = e.at(-1), !l && u !== undefined && u.length > 0 && e.length > 1 && (e[e.length - 2] += e.pop());
15569
- };
15570
- var St2 = (e) => {
15571
- const r = e.split(" ");
15572
- let s = r.length;
15573
- for (;s > 0 && !(D2(r[s - 1]) > 0); )
15574
- s--;
15575
- return s === r.length ? e : r.slice(0, s).join(" ") + r.slice(s).join("");
15576
- };
15577
- var It2 = (e, r, s = {}) => {
15578
- if (s.trim !== false && e.trim() === "")
15579
- return "";
15580
- let i = "", a, o;
15581
- const u = e.split(" "), l = Ct2(u);
15582
- let n = [""];
15583
- for (const [$, m] of u.entries()) {
15584
- s.trim !== false && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
15585
- let d = D2(n.at(-1) ?? "");
15586
- if ($ !== 0 && (d >= r && (s.wordWrap === false || s.trim === false) && (n.push(""), d = 0), (d > 0 || s.trim === false) && (n[n.length - 1] += " ", d++)), s.hard && l[$] > r) {
15587
- const F = r - d, y2 = 1 + Math.floor((l[$] - F - 1) / r);
15588
- Math.floor((l[$] - 1) / r) < y2 && n.push(""), Ie(n, m, r);
15589
- continue;
15590
- }
15591
- if (d + l[$] > r && d > 0 && l[$] > 0) {
15592
- if (s.wordWrap === false && d < r) {
15593
- Ie(n, m, r);
15594
- continue;
15595
- }
15596
- n.push("");
15597
- }
15598
- if (d + l[$] > r && s.wordWrap === false) {
15599
- Ie(n, m, r);
15600
- continue;
15601
- }
15602
- n[n.length - 1] += m;
15603
- }
15604
- s.trim !== false && (n = n.map(($) => St2($)));
15605
- const c = n.join(`
15606
- `), p = c[Symbol.iterator]();
15607
- let f = p.next(), g = p.next(), E = 0;
15608
- for (;!f.done; ) {
15609
- const $ = f.value, m = g.value;
15610
- if (i += $, $ === ae || $ === je) {
15611
- He.lastIndex = E + 1;
15612
- const y2 = He.exec(c)?.groups;
15613
- if (y2?.code !== undefined) {
15614
- const v = Number.parseFloat(y2.code);
15615
- a = v === vt2 ? undefined : v;
15616
- } else
15617
- y2?.uri !== undefined && (o = y2.uri.length === 0 ? undefined : y2.uri);
15618
- }
15619
- const d = a ? At2(a) : undefined;
15620
- m === `
15621
- ` ? (o && (i += Ke("")), a && d && (i += Ue(d))) : $ === `
15622
- ` && (a && d && (i += Ue(a)), o && (i += Ke(o))), E += $.length, f = g, g = p.next();
15623
- }
15624
- return i;
15625
- };
15626
- function J(e, r, s) {
15627
- return String(e).normalize().replaceAll(`\r
15628
- `, `
15629
- `).split(`
15630
- `).map((i) => It2(i, r, s)).join(`
15631
- `);
15632
- }
15633
- var bt2 = (e, r, s, i, a) => {
15634
- let o = r, u = 0;
15635
- for (let l = s;l < i; l++) {
15636
- const n = e[l];
15637
- if (o = o - n.length, u++, o <= a)
15638
- break;
15639
- }
15640
- return { lineCount: o, removals: u };
15641
- };
15642
- var X2 = ({ cursor: e, options: r, style: s, output: i = process.stdout, maxItems: a = Number.POSITIVE_INFINITY, columnPadding: o = 0, rowPadding: u = 4 }) => {
15643
- const l = rt(i) - o, n = nt(i), c = t("dim", "..."), p = Math.max(n - u, 0), f = Math.max(Math.min(a, p), 5);
15644
- let g = 0;
15645
- e >= f - 3 && (g = Math.max(Math.min(e - f + 3, r.length - f), 0));
15646
- let E = f < r.length && g > 0, $ = f < r.length && g + f < r.length;
15647
- const m = Math.min(g + f, r.length), d = [];
15648
- let F = 0;
15649
- E && F++, $ && F++;
15650
- const y2 = g + (E ? 1 : 0), v = m - ($ ? 1 : 0);
15651
- for (let A = y2;A < v; A++) {
15652
- const b = J(s(r[A], A === e), l, { hard: true, trim: false }).split(`
15653
- `);
15654
- d.push(b), F += b.length;
15655
- }
15656
- if (F > p) {
15657
- let A = 0, b = 0, w = F;
15658
- const S2 = e - y2, T2 = (M2, O2) => bt2(d, w, M2, O2, p);
15659
- E ? ({ lineCount: w, removals: A } = T2(0, S2), w > p && ({ lineCount: w, removals: b } = T2(S2 + 1, d.length))) : ({ lineCount: w, removals: b } = T2(S2 + 1, d.length), w > p && ({ lineCount: w, removals: A } = T2(0, S2))), A > 0 && (E = true, d.splice(0, A)), b > 0 && ($ = true, d.splice(d.length - b, b));
15660
- }
15661
- const C = [];
15662
- E && C.push(c);
15663
- for (const A of d)
15664
- for (const b of A)
15665
- C.push(b);
15666
- return $ && C.push(c), C;
15667
- };
15668
- var ze = { light: I2("─", "-"), heavy: I2("━", "="), block: I2("█", "#") };
15669
- var oe = (e, r) => e.includes(`
15670
- `) ? e.split(`
15671
- `).map((s) => r(s)).join(`
15672
- `) : r(e);
15673
- var Jt = (e) => {
15674
- const r = (s, i) => {
15675
- const a = s.label ?? String(s.value);
15676
- switch (i) {
15677
- case "disabled":
15678
- return `${t("gray", H2)} ${oe(a, (o) => t("gray", o))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
15679
- case "selected":
15680
- return `${oe(a, (o) => t("dim", o))}`;
15681
- case "active":
15682
- return `${t("green", z3)} ${a}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
15683
- case "cancelled":
15684
- return `${oe(a, (o) => t(["strikethrough", "dim"], o))}`;
15685
- default:
15686
- return `${t("dim", H2)} ${oe(a, (o) => t("dim", o))}`;
15687
- }
15688
- };
15689
- return new Tt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
15690
- const s = e.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${ve(this.state)} `, o = Bt(e.output, e.message, a, i), u = `${s ? `${t("gray", h)}
15691
- ` : ""}${o}
15692
- `;
15693
- switch (this.state) {
15694
- case "submit": {
15695
- const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "selected"), l);
15696
- return `${u}${n}`;
15697
- }
15698
- case "cancel": {
15699
- const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "cancelled"), l);
15700
- return `${u}${n}${s ? `
15701
- ${t("gray", h)}` : ""}`;
15702
- }
15703
- default: {
15704
- const l = s ? `${t("cyan", h)} ` : "", n = s ? t("cyan", x2) : "", c = u.split(`
15705
- `).length, p = s ? 2 : 1;
15706
- return `${u}${l}${X2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: (f, g) => r(f, f.disabled ? "disabled" : g ? "active" : "inactive") }).join(`
15707
- ${l}`)}
15708
- ${n}
15709
- `;
15710
- }
15711
- }
15712
- } }).prompt();
15713
- };
15714
- var Qe = `${t("gray", h)} `;
15715
-
15716
14821
  // src/utils/prompt.ts
14822
+ import { createInterface } from "node:readline";
15717
14823
  var promptSelect = async (options, message) => {
15718
- const selected = await Jt({
15719
- message,
15720
- options: options.map((option, index) => ({
15721
- value: index,
15722
- label: option
15723
- }))
14824
+ const rl = createInterface({
14825
+ input: process.stdin,
14826
+ output: process.stderr
15724
14827
  });
15725
- if (Ct(selected)) {
15726
- throw new Error("Selection cancelled by user");
14828
+ const lines = options.map((opt, i) => ` ${i + 1}. ${opt}`).join(`
14829
+ `);
14830
+ process.stderr.write(`${message}
14831
+ ${lines}
14832
+ > `);
14833
+ const answer = await new Promise((resolve, reject) => {
14834
+ const onLine = (line) => {
14835
+ rl.removeListener("close", onClose);
14836
+ resolve(line);
14837
+ };
14838
+ const onClose = () => {
14839
+ rl.removeListener("line", onLine);
14840
+ reject(new Error("Selection cancelled by user"));
14841
+ };
14842
+ rl.once("line", onLine);
14843
+ rl.once("close", onClose);
14844
+ });
14845
+ rl.close();
14846
+ const input = answer.trim();
14847
+ const parsed = Number.parseInt(input, 10);
14848
+ if (!Number.isNaN(parsed) && parsed >= 1 && parsed <= options.length) {
14849
+ return parsed - 1;
14850
+ }
14851
+ const matchIndex = options.findIndex((opt) => opt.toLowerCase() === input.toLowerCase());
14852
+ if (matchIndex !== -1) {
14853
+ return matchIndex;
15727
14854
  }
15728
- return selected;
14855
+ throw new Error(`Invalid selection: "${input}". Enter a number (1-${options.length}) or a value from the list.`);
15729
14856
  };
15730
14857
 
15731
14858
  // src/tenantSelection.ts
@@ -15762,7 +14889,7 @@ var selectTenantWithDeps = async (baseUrl, accessToken, organizationId, targetTe
15762
14889
  if (targetTenantName) {
15763
14890
  selectedIndex = tenants.findIndex((tenant) => tenant.name === targetTenantName);
15764
14891
  if (selectedIndex === -1) {
15765
- const availableTenants = tenants.map((t2) => t2.name).join(", ");
14892
+ const availableTenants = tenants.map((t) => t.name).join(", ");
15766
14893
  throw new Error(`Invalid tenant requested: "${targetTenantName}"
15767
14894
  ` + `Organization: ${organization.name}
15768
14895
  ` + `Available tenants: ${availableTenants}`);
@@ -15937,44 +15064,44 @@ var interactiveLoginWithDeps = async (options, deps) => {
15937
15064
  customClientId: clientId,
15938
15065
  customClientSecret: clientSecret
15939
15066
  });
15940
- let tokens;
15941
15067
  const authFlow = config2.clientSecret ? "client_credentials" : "authorization_code";
15942
- try {
15943
- if (config2.clientSecret) {
15944
- const creds = await clientCredentials({
15945
- clientId: config2.clientId,
15946
- clientSecret: config2.clientSecret,
15947
- authority: config2.baseUrl,
15948
- scope
15949
- });
15950
- logger6.info("Authenticated using Client Credentials!");
15951
- tokens = creds;
15952
- } else {
15953
- logger6.info(`→ Opening browser for authentication against ${config2.baseUrl}...`);
15954
- const authTokens = await auth({
15955
- baseUrl: authority,
15956
- clientId,
15957
- clientSecret,
15958
- scope
15959
- });
15960
- logger6.info("✓ Authenticated!");
15961
- tokens = {
15962
- UIPATH_ACCESS_TOKEN: authTokens.accessToken,
15963
- UIPATH_REFRESH_TOKEN: authTokens.refreshToken
15964
- };
15965
- }
15966
- telemetry.trackEvent(AuthTelemetryEvents.Login, {
15967
- flow: authFlow,
15968
- success: "true"
15068
+ const { clientSecret: resolvedSecret } = config2;
15069
+ const authPromise = resolvedSecret ? (async () => {
15070
+ const creds = await clientCredentials({
15071
+ clientId: config2.clientId,
15072
+ clientSecret: resolvedSecret,
15073
+ authority: config2.baseUrl,
15074
+ scope
15969
15075
  });
15970
- } catch (error48) {
15076
+ logger6.info("Authenticated using Client Credentials!");
15077
+ return creds;
15078
+ })() : (async () => {
15079
+ logger6.info(`→ Opening browser for authentication against ${config2.baseUrl}...`);
15080
+ const authTokens = await auth({
15081
+ baseUrl: authority,
15082
+ clientId,
15083
+ clientSecret,
15084
+ scope
15085
+ });
15086
+ logger6.info("✓ Authenticated!");
15087
+ return {
15088
+ UIPATH_ACCESS_TOKEN: authTokens.accessToken,
15089
+ UIPATH_REFRESH_TOKEN: authTokens.refreshToken
15090
+ };
15091
+ })();
15092
+ const [authError, tokens] = await catchError2(authPromise);
15093
+ if (authError) {
15971
15094
  telemetry.trackEvent(AuthTelemetryEvents.Login, {
15972
15095
  flow: authFlow,
15973
15096
  success: "false",
15974
- errorMessage: error48 instanceof Error ? error48.message : String(error48)
15097
+ errorMessage: authError instanceof Error ? authError.message : String(authError)
15975
15098
  });
15976
- throw error48;
15099
+ throw authError;
15977
15100
  }
15101
+ telemetry.trackEvent(AuthTelemetryEvents.Login, {
15102
+ flow: authFlow,
15103
+ success: "true"
15104
+ });
15978
15105
  const credentials = {
15979
15106
  ...tokens,
15980
15107
  UIPATH_URL: config2.baseUrl
@@ -16060,7 +15187,6 @@ var interactiveLogin = async (options) => {
16060
15187
  // src/loginStatus.ts
16061
15188
  import {
16062
15189
  logger as logger8,
16063
- sessionId,
16064
15190
  setGlobalTelemetryProperties,
16065
15191
  telemetry as telemetry2
16066
15192
  } from "@uipath/common";
@@ -16146,7 +15272,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
16146
15272
  try {
16147
15273
  const { absolutePath, errorMessage } = await resolveEnvFilePath(envFilePath);
16148
15274
  if (absolutePath === undefined) {
16149
- logger8.error(errorMessage ?? "Failed to resolve env file path");
15275
+ logger8.debug(errorMessage ?? "Failed to resolve env file path");
16150
15276
  return { loginStatus: "Not logged in" };
16151
15277
  }
16152
15278
  const credentials = await loadEnvFile({ envPath: absolutePath });
@@ -16205,7 +15331,6 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
16205
15331
  if (result.loginStatus === "Logged in") {
16206
15332
  const userId = getUserIdFromToken(accessToken);
16207
15333
  const defaultProps = {
16208
- sessionId,
16209
15334
  ...userId ? { userId } : {},
16210
15335
  ...result.tenantId ? { tenantId: result.tenantId } : {},
16211
15336
  ...result.organizationId ? { organizationId: result.organizationId } : {},
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@uipath/auth",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "repository": {
5
5
  "type": "git",
6
- "url": "https://github.com/UiPath/uipcli.git",
6
+ "url": "https://github.com/UiPath/cli.git",
7
7
  "directory": "packages/auth"
8
8
  },
9
9
  "publishConfig": {
@@ -24,19 +24,19 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "bun build ./src/index.ts --outdir dist --format esm --target node --external @uipath/common --external @uipath/filesystem",
27
- "lint": "biome check ."
27
+ "lint": "biome check .",
28
+ "typecheck": "tsc --noEmit"
28
29
  },
29
30
  "dependencies": {
30
- "@clack/prompts": "^1.0.1",
31
31
  "openid-client": "^6.8.2",
32
32
  "zod": "^4.3.6"
33
33
  },
34
34
  "peerDependencies": {
35
- "@uipath/common": "^0.1.7",
35
+ "@uipath/common": "^0.1.12",
36
36
  "@uipath/filesystem": "^0.1.6"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/node": "^25.2.3",
39
+ "@types/node": "^25.5.0",
40
40
  "typescript": "^5"
41
41
  }
42
42
  }