@prozilla-os/terminal 2.0.0 → 2.0.5

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.
package/dist/main.js CHANGED
@@ -1,50 +1,54 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._Terminal_cqg7e_1{--char-width: .585rem;display:flex;flex-direction:column;align-items:flex-start;padding:.5rem;overflow:auto;height:100%;cursor:text}._Terminal_cqg7e_1 *{font-family:var(--mono-font-family);letter-spacing:-.03em}._Terminal_cqg7e_1 p,._Terminal_cqg7e_1 pre{margin:0;height:1.25rem;line-height:inherit;font-size:inherit;letter-spacing:inherit}._Prefix_cqg7e_26{display:flex;width:max-content;white-space:nowrap}._Input_cqg7e_32,._Output_cqg7e_32{display:flex;flex-direction:row;align-items:center;width:100%;line-height:1.25rem;font-size:1rem;text-align:start;white-space:pre}._Input_cqg7e_32{height:1.25rem}._Input-container_cqg7e_47{--cursor-width: var(--char-width);--cursor-offset: 0;position:relative;height:100%;width:fit-content}._Input-container_cqg7e_47:after{content:"";position:absolute;top:0;left:calc(var(--cursor-offset) * var(--char-width) * .9746124950079872);width:var(--cursor-width);height:100%;background-color:var(--foreground-color-0);animation:_blink_cqg7e_1 1s step-end infinite}._Input-container_cqg7e_47 input{color:transparent;position:absolute;left:0;width:100%;padding:0;background:none;border:none;outline:none;font-size:inherit;caret-color:transparent}@keyframes _blink_cqg7e_1{0%,to{background-color:transparent}50%{background-color:var(--foreground-color-0)}}._Input_cqg7e_32 label{position:absolute;width:100%;height:100%;top:0;left:0;cursor:text}._ansi-black-fg_cqg7e_99{color:var(--black-2)}._ansi-red-fg_cqg7e_100{color:var(--red-0)}._ansi-green-fg_cqg7e_101{color:var(--green-0)}._ansi-yellow-fg_cqg7e_102{color:var(--yellow-0)}._ansi-blue-fg_cqg7e_103{color:var(--blue-0)}._ansi-magenta-fg_cqg7e_104{color:var(--purple-0)}._ansi-cyan-fg_cqg7e_105{color:var(--cyan-0)}._ansi-white-fg_cqg7e_106{color:var(--foreground-color-0)}._ansi-bright-black-fg_cqg7e_108{color:var(--black-2)}._ansi-bright-red-fg_cqg7e_109{color:var(--red-0)}._ansi-bright-green-fg_cqg7e_110{color:var(--green-0)}._ansi-bright-yellow-fg_cqg7e_111{color:var(--yellow-0)}._ansi-bright-blue-fg_cqg7e_112{color:var(--blue-0)}._ansi-bright-magenta-fg_cqg7e_113{color:var(--purple-0)}._ansi-bright-cyan-fg_cqg7e_114{color:var(--cyan-0)}._ansi-bright-white-fg_cqg7e_115{color:var(--foreground-color-0)}._ansi-black-bg_cqg7e_117{background-color:var(--black-2)}._ansi-red-bg_cqg7e_118{background-color:var(--red-0)}._ansi-green-bg_cqg7e_119{background-color:var(--green-0)}._ansi-yellow-bg_cqg7e_120{background-color:var(--yellow-0)}._ansi-blue-bg_cqg7e_121{background-color:var(--blue-0)}._ansi-magenta-bg_cqg7e_122{background-color:var(--purple-0)}._ansi-cyan-bg_cqg7e_123{background-color:var(--cyan-0)}._ansi-white-bg_cqg7e_124{background-color:var(--foreground-color-0)}._ansi-dim_cqg7e_126{opacity:.65}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
- import { useShell as M, USERNAME as z, HOSTNAME as B, App as J, AppsConfig as K, CommandsManager as U } from "@prozilla-os/core";
3
- import { jsx as k, jsxs as I, Fragment as W } from "react/jsx-runtime";
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._Terminal_1y9ey_1{--char-width: .585rem;--char-height: 1.25rem;position:relative;display:flex;flex-direction:column;align-items:flex-start;padding:.5rem;overflow:auto;height:100%;cursor:text;box-sizing:border-box}._Terminal_1y9ey_1 *{font-family:var(--mono-font-family);letter-spacing:-.03em}._Terminal_1y9ey_1 p,._Terminal_1y9ey_1 pre{margin:0;height:var(--char-height);line-height:var(--char-height);font-size:1rem;letter-spacing:inherit}._VirtualCursor_1y9ey_29{position:absolute;margin-left:.5rem;margin-top:.5rem;width:var(--char-width);height:var(--char-height);background-color:var(--foreground-color-0);mix-blend-mode:difference;pointer-events:none;z-index:10;animation:_blink_1y9ey_1 1s step-end infinite}._History_1y9ey_44{width:100%}._Prefix_1y9ey_48{display:flex;width:max-content;white-space:nowrap}._Input_1y9ey_54,._Output_1y9ey_54{display:flex;flex-direction:row;align-items:center;width:100%;line-height:var(--char-height);font-size:1rem;text-align:start;white-space:pre}._Input_1y9ey_54{height:var(--char-height)}._Input-container_1y9ey_69{--cursor-width: var(--char-width);--cursor-offset: 0;position:relative;height:100%;width:fit-content}._Input-container_1y9ey_69:after{content:"";position:absolute;top:0;left:calc(var(--cursor-offset) * var(--char-width));width:var(--cursor-width);height:100%;background-color:var(--foreground-color-0);animation:_blink_1y9ey_1 1s step-end infinite}._Input-container_1y9ey_69 input{color:transparent;position:absolute;left:0;width:100%;padding:0;background:none;border:none;outline:none;font-size:inherit;caret-color:transparent}@keyframes _blink_1y9ey_1{0%,to{opacity:0}50%{opacity:1}}._Input_1y9ey_54 label{position:absolute;width:100%;height:100%;top:0;left:0;cursor:text}._InterruptButton_1y9ey_120{display:none;gap:.5rem;flex-direction:row-reverse;justify-content:center;align-items:center;position:absolute;bottom:1rem;right:1rem;padding:.5rem 1rem;border-radius:var(--border-radius-1)}._InterruptButton_1y9ey_120>svg{margin:0!important;width:auto}._InterruptButton_1y9ey_120 *{color:inherit}@media(pointer:coarse){._InterruptButton_1y9ey_120{display:flex}}._ansi-black-fg_1y9ey_148{color:var(--black-2)}._ansi-red-fg_1y9ey_149{color:var(--red-0)}._ansi-green-fg_1y9ey_150{color:var(--green-0)}._ansi-yellow-fg_1y9ey_151{color:var(--yellow-0)}._ansi-blue-fg_1y9ey_152{color:var(--blue-0)}._ansi-magenta-fg_1y9ey_153{color:var(--purple-0)}._ansi-cyan-fg_1y9ey_154{color:var(--cyan-0)}._ansi-white-fg_1y9ey_155{color:var(--foreground-color-0)}._ansi-bright-black-fg_1y9ey_157{color:var(--black-2)}._ansi-bright-red-fg_1y9ey_158{color:var(--red-0)}._ansi-bright-green-fg_1y9ey_159{color:var(--green-0)}._ansi-bright-yellow-fg_1y9ey_160{color:var(--yellow-0)}._ansi-bright-blue-fg_1y9ey_161{color:var(--blue-0)}._ansi-bright-magenta-fg_1y9ey_162{color:var(--purple-0)}._ansi-bright-cyan-fg_1y9ey_163{color:var(--cyan-0)}._ansi-bright-white-fg_1y9ey_164{color:var(--foreground-color-0)}._ansi-black-bg_1y9ey_166{background-color:var(--black-2)}._ansi-red-bg_1y9ey_167{background-color:var(--red-0)}._ansi-green-bg_1y9ey_168{background-color:var(--green-0)}._ansi-yellow-bg_1y9ey_169{background-color:var(--yellow-0)}._ansi-blue-bg_1y9ey_170{background-color:var(--blue-0)}._ansi-magenta-bg_1y9ey_171{background-color:var(--purple-0)}._ansi-cyan-bg_1y9ey_172{background-color:var(--cyan-0)}._ansi-white-bg_1y9ey_173{background-color:var(--foreground-color-0)}._ansi-dim_1y9ey_175{opacity:.65}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
+ import { useFontMetrics as Z, useShell as G, HistoryFlags as Q, Button as X, utilStyles as Y, App as ee, AppsConfig as te, ExecutableResolver as re } from "@prozilla-os/core";
3
+ import { jsx as k, jsxs as I } from "react/jsx-runtime";
4
4
  import * as L from "react";
5
- import { forwardRef as Z, useState as $, useRef as R, useLayoutEffect as V, useEffect as E } from "react";
6
- import { Vector2 as G } from "@prozilla-os/shared";
7
- const Q = "_Terminal_cqg7e_1", X = "_Prefix_cqg7e_26", Y = "_Input_cqg7e_32", ee = "_Output_cqg7e_32", te = "_blink_cqg7e_1", C = {
8
- Terminal: Q,
9
- Prefix: X,
10
- Input: Y,
11
- Output: ee,
12
- "Input-container": "_Input-container_cqg7e_47",
13
- blink: te,
14
- "ansi-black-fg": "_ansi-black-fg_cqg7e_99",
15
- "ansi-red-fg": "_ansi-red-fg_cqg7e_100",
16
- "ansi-green-fg": "_ansi-green-fg_cqg7e_101",
17
- "ansi-yellow-fg": "_ansi-yellow-fg_cqg7e_102",
18
- "ansi-blue-fg": "_ansi-blue-fg_cqg7e_103",
19
- "ansi-magenta-fg": "_ansi-magenta-fg_cqg7e_104",
20
- "ansi-cyan-fg": "_ansi-cyan-fg_cqg7e_105",
21
- "ansi-white-fg": "_ansi-white-fg_cqg7e_106",
22
- "ansi-bright-black-fg": "_ansi-bright-black-fg_cqg7e_108",
23
- "ansi-bright-red-fg": "_ansi-bright-red-fg_cqg7e_109",
24
- "ansi-bright-green-fg": "_ansi-bright-green-fg_cqg7e_110",
25
- "ansi-bright-yellow-fg": "_ansi-bright-yellow-fg_cqg7e_111",
26
- "ansi-bright-blue-fg": "_ansi-bright-blue-fg_cqg7e_112",
27
- "ansi-bright-magenta-fg": "_ansi-bright-magenta-fg_cqg7e_113",
28
- "ansi-bright-cyan-fg": "_ansi-bright-cyan-fg_cqg7e_114",
29
- "ansi-bright-white-fg": "_ansi-bright-white-fg_cqg7e_115",
30
- "ansi-black-bg": "_ansi-black-bg_cqg7e_117",
31
- "ansi-red-bg": "_ansi-red-bg_cqg7e_118",
32
- "ansi-green-bg": "_ansi-green-bg_cqg7e_119",
33
- "ansi-yellow-bg": "_ansi-yellow-bg_cqg7e_120",
34
- "ansi-blue-bg": "_ansi-blue-bg_cqg7e_121",
35
- "ansi-magenta-bg": "_ansi-magenta-bg_cqg7e_122",
36
- "ansi-cyan-bg": "_ansi-cyan-bg_cqg7e_123",
37
- "ansi-white-bg": "_ansi-white-bg_cqg7e_124",
38
- "ansi-dim": "_ansi-dim_cqg7e_126"
5
+ import { memo as se, forwardRef as ne, useState as j, useRef as O, useLayoutEffect as ie, useEffect as E, useMemo as D } from "react";
6
+ import { Vector2 as le, Ansi as oe } from "@prozilla-os/shared";
7
+ import { faStop as ae } from "@fortawesome/free-solid-svg-icons";
8
+ const ce = "_Terminal_1y9ey_1", ue = "_VirtualCursor_1y9ey_29", fe = "_blink_1y9ey_1", ge = "_History_1y9ey_44", he = "_Prefix_1y9ey_48", pe = "_Input_1y9ey_54", ye = "_Output_1y9ey_54", _e = "_InterruptButton_1y9ey_120", C = {
9
+ Terminal: ce,
10
+ VirtualCursor: ue,
11
+ blink: fe,
12
+ History: ge,
13
+ Prefix: he,
14
+ Input: pe,
15
+ Output: ye,
16
+ "Input-container": "_Input-container_1y9ey_69",
17
+ InterruptButton: _e,
18
+ "ansi-black-fg": "_ansi-black-fg_1y9ey_148",
19
+ "ansi-red-fg": "_ansi-red-fg_1y9ey_149",
20
+ "ansi-green-fg": "_ansi-green-fg_1y9ey_150",
21
+ "ansi-yellow-fg": "_ansi-yellow-fg_1y9ey_151",
22
+ "ansi-blue-fg": "_ansi-blue-fg_1y9ey_152",
23
+ "ansi-magenta-fg": "_ansi-magenta-fg_1y9ey_153",
24
+ "ansi-cyan-fg": "_ansi-cyan-fg_1y9ey_154",
25
+ "ansi-white-fg": "_ansi-white-fg_1y9ey_155",
26
+ "ansi-bright-black-fg": "_ansi-bright-black-fg_1y9ey_157",
27
+ "ansi-bright-red-fg": "_ansi-bright-red-fg_1y9ey_158",
28
+ "ansi-bright-green-fg": "_ansi-bright-green-fg_1y9ey_159",
29
+ "ansi-bright-yellow-fg": "_ansi-bright-yellow-fg_1y9ey_160",
30
+ "ansi-bright-blue-fg": "_ansi-bright-blue-fg_1y9ey_161",
31
+ "ansi-bright-magenta-fg": "_ansi-bright-magenta-fg_1y9ey_162",
32
+ "ansi-bright-cyan-fg": "_ansi-bright-cyan-fg_1y9ey_163",
33
+ "ansi-bright-white-fg": "_ansi-bright-white-fg_1y9ey_164",
34
+ "ansi-black-bg": "_ansi-black-bg_1y9ey_166",
35
+ "ansi-red-bg": "_ansi-red-bg_1y9ey_167",
36
+ "ansi-green-bg": "_ansi-green-bg_1y9ey_168",
37
+ "ansi-yellow-bg": "_ansi-yellow-bg_1y9ey_169",
38
+ "ansi-blue-bg": "_ansi-blue-bg_1y9ey_170",
39
+ "ansi-magenta-bg": "_ansi-magenta-bg_1y9ey_171",
40
+ "ansi-cyan-bg": "_ansi-cyan-bg_1y9ey_172",
41
+ "ansi-white-bg": "_ansi-white-bg_1y9ey_173",
42
+ "ansi-dim": "_ansi-dim_1y9ey_175"
39
43
  };
40
- function re(s) {
41
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
44
+ function de(n) {
45
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
42
46
  }
43
- var P, j;
44
- function ne() {
45
- if (j) return P;
46
- j = 1;
47
- const s = [
47
+ var P, N;
48
+ function me() {
49
+ if (N) return P;
50
+ N = 1;
51
+ const n = [
48
52
  [
49
53
  { color: "0, 0, 0", class: "ansi-black" },
50
54
  { color: "187, 0, 0", class: "ansi-red" },
@@ -65,7 +69,7 @@ function ne() {
65
69
  { color: "85, 255, 255", class: "ansi-bright-cyan" },
66
70
  { color: "255, 255, 255", class: "ansi-bright-white" }
67
71
  ]
68
- ], o = /(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;
72
+ ], c = /(https?:\/\/(?:[A-Za-z0-9#;/?:@=+$',_.!~*()[\]-]|&amp;|%[A-Fa-f0-9]{2})+)/gm;
69
73
  class g {
70
74
  /**
71
75
  * Anser.escapeForHtml
@@ -80,8 +84,8 @@ function ne() {
80
84
  * @param {String} txt The input text (containing the ANSI snippets).
81
85
  * @returns {String} The escaped html.
82
86
  */
83
- static escapeForHtml(r) {
84
- return new g().escapeForHtml(r);
87
+ static escapeForHtml(t) {
88
+ return new g().escapeForHtml(t);
85
89
  }
86
90
  /**
87
91
  * Anser.linkify
@@ -95,8 +99,8 @@ function ne() {
95
99
  * @param {String} txt The input text.
96
100
  * @returns {String} The HTML containing the <a> tags (unescaped).
97
101
  */
98
- static linkify(r) {
99
- return new g().linkify(r);
102
+ static linkify(t) {
103
+ return new g().linkify(t);
100
104
  }
101
105
  /**
102
106
  * Anser.ansiToHtml
@@ -122,8 +126,8 @@ function ne() {
122
126
  * @param {Object} options The options passed to the ansiToHTML method.
123
127
  * @returns {String} The HTML output.
124
128
  */
125
- static ansiToHtml(r, t) {
126
- return new g().ansiToHtml(r, t);
129
+ static ansiToHtml(t, e) {
130
+ return new g().ansiToHtml(t, e);
127
131
  }
128
132
  /**
129
133
  * Anser.ansiToJson
@@ -135,8 +139,8 @@ function ne() {
135
139
  * @param {Object} options The options passed to the ansiToHTML method.
136
140
  * @returns {String} The HTML output.
137
141
  */
138
- static ansiToJson(r, t) {
139
- return new g().ansiToJson(r, t);
142
+ static ansiToJson(t, e) {
143
+ return new g().ansiToJson(t, e);
140
144
  }
141
145
  /**
142
146
  * Anser.ansiToText
@@ -147,8 +151,8 @@ function ne() {
147
151
  * @param {String} txt The input text.
148
152
  * @returns {String} The text output.
149
153
  */
150
- static ansiToText(r) {
151
- return new g().ansiToText(r);
154
+ static ansiToText(t) {
155
+ return new g().ansiToText(t);
152
156
  }
153
157
  /**
154
158
  * Anser
@@ -170,16 +174,16 @@ function ne() {
170
174
  */
171
175
  setupPalette() {
172
176
  this.PALETTE_COLORS = [];
173
- for (let e = 0; e < 2; ++e)
177
+ for (let r = 0; r < 2; ++r)
174
178
  for (let l = 0; l < 8; ++l)
175
- this.PALETTE_COLORS.push(s[e][l].color);
176
- let r = [0, 95, 135, 175, 215, 255], t = (e, l, a) => r[e] + ", " + r[l] + ", " + r[a];
177
- for (let e = 0; e < 6; ++e)
179
+ this.PALETTE_COLORS.push(n[r][l].color);
180
+ let t = [0, 95, 135, 175, 215, 255], e = (r, l, a) => t[r] + ", " + t[l] + ", " + t[a];
181
+ for (let r = 0; r < 6; ++r)
178
182
  for (let l = 0; l < 6; ++l)
179
183
  for (let a = 0; a < 6; ++a)
180
- this.PALETTE_COLORS.push(t(e, l, a));
184
+ this.PALETTE_COLORS.push(e(r, l, a));
181
185
  let h = 8;
182
- for (let e = 0; e < 24; ++e, h += 10)
186
+ for (let r = 0; r < 24; ++r, h += 10)
183
187
  this.PALETTE_COLORS.push(h + ", " + h + ", " + h);
184
188
  }
185
189
  /**
@@ -191,10 +195,10 @@ function ne() {
191
195
  * @param {String} txt The input text.
192
196
  * @returns {String} The escpaed HTML output.
193
197
  */
194
- escapeForHtml(r) {
195
- return r.replace(
198
+ escapeForHtml(t) {
199
+ return t.replace(
196
200
  /[&<>\"]/gm,
197
- (t) => t == "&" ? "&amp;" : t == '"' ? "&quot;" : t == "<" ? "&lt;" : t == ">" ? "&gt;" : ""
201
+ (e) => e == "&" ? "&amp;" : e == '"' ? "&quot;" : e == "<" ? "&lt;" : e == ">" ? "&gt;" : ""
198
202
  );
199
203
  }
200
204
  /**
@@ -206,8 +210,8 @@ function ne() {
206
210
  * @param {String} txt The input text.
207
211
  * @returns {String} The HTML output containing link elements.
208
212
  */
209
- linkify(r) {
210
- return r.replace(o, (t) => `<a href="${t}">${t}</a>`);
213
+ linkify(t) {
214
+ return t.replace(c, (e) => `<a href="${e}">${e}</a>`);
211
215
  }
212
216
  /**
213
217
  * ansiToHtml
@@ -219,8 +223,8 @@ function ne() {
219
223
  * @param {Object} options The options passed ot the `process` method.
220
224
  * @returns {String} The HTML output.
221
225
  */
222
- ansiToHtml(r, t) {
223
- return this.process(r, t, !0);
226
+ ansiToHtml(t, e) {
227
+ return this.process(t, e, !0);
224
228
  }
225
229
  /**
226
230
  * ansiToJson
@@ -232,8 +236,8 @@ function ne() {
232
236
  * @param {Object} options The options passed ot the `process` method.
233
237
  * @returns {String} The JSON output.
234
238
  */
235
- ansiToJson(r, t) {
236
- return t = t || {}, t.json = !0, t.clearLine = !1, this.process(r, t, !0);
239
+ ansiToJson(t, e) {
240
+ return e = e || {}, e.json = !0, e.clearLine = !1, this.process(t, e, !0);
237
241
  }
238
242
  /**
239
243
  * ansiToText
@@ -244,8 +248,8 @@ function ne() {
244
248
  * @param {String} txt The input text.
245
249
  * @returns {String} The text output.
246
250
  */
247
- ansiToText(r) {
248
- return this.process(r, {}, !1);
251
+ ansiToText(t) {
252
+ return this.process(t, {}, !1);
249
253
  }
250
254
  /**
251
255
  * process
@@ -261,16 +265,16 @@ function ne() {
261
265
  *
262
266
  * @param {Boolean} markup
263
267
  */
264
- process(r, t, h) {
265
- let e = this, l = r.split(/\033\[/), a = l.shift();
266
- t == null && (t = {}), t.clearLine = /\r/.test(r);
267
- let c = l.map((p) => this.processChunk(p, t, h));
268
- if (t && t.json) {
269
- let p = e.processChunkJson("");
270
- return p.content = a, p.clearLine = t.clearLine, c.unshift(p), t.remove_empty && (c = c.filter((n) => !n.isEmpty())), c;
268
+ process(t, e, h) {
269
+ let r = this, l = t.split(/\033\[/), a = l.shift();
270
+ e == null && (e = {}), e.clearLine = /\r/.test(t);
271
+ let u = l.map((f) => this.processChunk(f, e, h));
272
+ if (e && e.json) {
273
+ let f = r.processChunkJson("");
274
+ return f.content = a, f.clearLine = e.clearLine, u.unshift(f), e.remove_empty && (u = u.filter((s) => !s.isEmpty())), u;
271
275
  } else
272
- c.unshift(a);
273
- return c.join("");
276
+ u.unshift(a);
277
+ return u.join("");
274
278
  }
275
279
  /**
276
280
  * processChunkJson
@@ -297,99 +301,99 @@ function ne() {
297
301
  * - `isEmpty` (Function): A function returning `true` if the content is empty, or `false` otherwise.
298
302
  *
299
303
  */
300
- processChunkJson(r, t, h) {
301
- t = typeof t > "u" ? {} : t;
302
- let e = t.use_classes = typeof t.use_classes < "u" && t.use_classes, l = t.key = e ? "class" : "color", a = {
303
- content: r,
304
+ processChunkJson(t, e, h) {
305
+ e = typeof e > "u" ? {} : e;
306
+ let r = e.use_classes = typeof e.use_classes < "u" && e.use_classes, l = e.key = r ? "class" : "color", a = {
307
+ content: t,
304
308
  fg: null,
305
309
  bg: null,
306
310
  fg_truecolor: null,
307
311
  bg_truecolor: null,
308
312
  isInverted: !1,
309
- clearLine: t.clearLine,
313
+ clearLine: e.clearLine,
310
314
  decoration: null,
311
315
  decorations: [],
312
316
  was_processed: !1,
313
317
  isEmpty: () => !a.content
314
- }, c = r.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);
315
- if (!c) return a;
316
- a.content = c[4];
317
- let p = c[2].split(";");
318
- if (c[1] !== "" || c[3] !== "m" || !h)
318
+ }, u = t.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);
319
+ if (!u) return a;
320
+ a.content = u[4];
321
+ let f = u[2].split(";");
322
+ if (u[1] !== "" || u[3] !== "m" || !h)
319
323
  return a;
320
- let n = this;
321
- for (; p.length > 0; ) {
322
- let u = p.shift(), i = parseInt(u);
324
+ let s = this;
325
+ for (; f.length > 0; ) {
326
+ let v = f.shift(), i = parseInt(v);
323
327
  if (isNaN(i) || i === 0)
324
- n.fg = n.bg = null, n.decorations = [];
328
+ s.fg = s.bg = null, s.decorations = [];
325
329
  else if (i === 1)
326
- n.decorations.push("bold");
330
+ s.decorations.push("bold");
327
331
  else if (i === 2)
328
- n.decorations.push("dim");
332
+ s.decorations.push("dim");
329
333
  else if (i === 3)
330
- n.decorations.push("italic");
334
+ s.decorations.push("italic");
331
335
  else if (i === 4)
332
- n.decorations.push("underline");
336
+ s.decorations.push("underline");
333
337
  else if (i === 5)
334
- n.decorations.push("blink");
338
+ s.decorations.push("blink");
335
339
  else if (i === 7)
336
- n.decorations.push("reverse");
340
+ s.decorations.push("reverse");
337
341
  else if (i === 8)
338
- n.decorations.push("hidden");
342
+ s.decorations.push("hidden");
339
343
  else if (i === 9)
340
- n.decorations.push("strikethrough");
344
+ s.decorations.push("strikethrough");
341
345
  else if (i === 21)
342
- n.removeDecoration("bold");
346
+ s.removeDecoration("bold");
343
347
  else if (i === 22)
344
- n.removeDecoration("bold"), n.removeDecoration("dim");
348
+ s.removeDecoration("bold"), s.removeDecoration("dim");
345
349
  else if (i === 23)
346
- n.removeDecoration("italic");
350
+ s.removeDecoration("italic");
347
351
  else if (i === 24)
348
- n.removeDecoration("underline");
352
+ s.removeDecoration("underline");
349
353
  else if (i === 25)
350
- n.removeDecoration("blink");
354
+ s.removeDecoration("blink");
351
355
  else if (i === 27)
352
- n.removeDecoration("reverse");
356
+ s.removeDecoration("reverse");
353
357
  else if (i === 28)
354
- n.removeDecoration("hidden");
358
+ s.removeDecoration("hidden");
355
359
  else if (i === 29)
356
- n.removeDecoration("strikethrough");
360
+ s.removeDecoration("strikethrough");
357
361
  else if (i === 39)
358
- n.fg = null;
362
+ s.fg = null;
359
363
  else if (i === 49)
360
- n.bg = null;
364
+ s.bg = null;
361
365
  else if (i >= 30 && i < 38)
362
- n.fg = s[0][i % 10][l];
366
+ s.fg = n[0][i % 10][l];
363
367
  else if (i >= 90 && i < 98)
364
- n.fg = s[1][i % 10][l];
368
+ s.fg = n[1][i % 10][l];
365
369
  else if (i >= 40 && i < 48)
366
- n.bg = s[0][i % 10][l];
370
+ s.bg = n[0][i % 10][l];
367
371
  else if (i >= 100 && i < 108)
368
- n.bg = s[1][i % 10][l];
372
+ s.bg = n[1][i % 10][l];
369
373
  else if (i === 38 || i === 48) {
370
- let m = i === 38;
371
- if (p.length >= 1) {
372
- let y = p.shift();
373
- if (y === "5" && p.length >= 1) {
374
- let b = parseInt(p.shift());
375
- if (b >= 0 && b <= 255)
376
- if (!e)
377
- this.PALETTE_COLORS || n.setupPalette(), m ? n.fg = this.PALETTE_COLORS[b] : n.bg = this.PALETTE_COLORS[b];
374
+ let b = i === 38;
375
+ if (f.length >= 1) {
376
+ let w = f.shift();
377
+ if (w === "5" && f.length >= 1) {
378
+ let _ = parseInt(f.shift());
379
+ if (_ >= 0 && _ <= 255)
380
+ if (!r)
381
+ this.PALETTE_COLORS || s.setupPalette(), b ? s.fg = this.PALETTE_COLORS[_] : s.bg = this.PALETTE_COLORS[_];
378
382
  else {
379
- let v = b >= 16 ? "ansi-palette-" + b : s[b > 7 ? 1 : 0][b % 8].class;
380
- m ? n.fg = v : n.bg = v;
383
+ let d = _ >= 16 ? "ansi-palette-" + _ : n[_ > 7 ? 1 : 0][_ % 8].class;
384
+ b ? s.fg = d : s.bg = d;
381
385
  }
382
- } else if (y === "2" && p.length >= 3) {
383
- let b = parseInt(p.shift()), v = parseInt(p.shift()), T = parseInt(p.shift());
384
- if (b >= 0 && b <= 255 && v >= 0 && v <= 255 && T >= 0 && T <= 255) {
385
- let f = b + ", " + v + ", " + T;
386
- e ? m ? (n.fg = "ansi-truecolor", n.fg_truecolor = f) : (n.bg = "ansi-truecolor", n.bg_truecolor = f) : m ? n.fg = f : n.bg = f;
386
+ } else if (w === "2" && f.length >= 3) {
387
+ let _ = parseInt(f.shift()), d = parseInt(f.shift()), o = parseInt(f.shift());
388
+ if (_ >= 0 && _ <= 255 && d >= 0 && d <= 255 && o >= 0 && o <= 255) {
389
+ let T = _ + ", " + d + ", " + o;
390
+ r ? b ? (s.fg = "ansi-truecolor", s.fg_truecolor = T) : (s.bg = "ansi-truecolor", s.bg_truecolor = T) : b ? s.fg = T : s.bg = T;
387
391
  }
388
392
  }
389
393
  }
390
394
  }
391
395
  }
392
- return n.fg === null && n.bg === null && n.decorations.length === 0 || (a.fg = n.fg, a.bg = n.bg, a.fg_truecolor = n.fg_truecolor, a.bg_truecolor = n.bg_truecolor, a.decorations = n.decorations, a.decoration = n.decorations.slice(-1).pop() || null, a.was_processed = !0), a;
396
+ return s.fg === null && s.bg === null && s.decorations.length === 0 || (a.fg = s.fg, a.bg = s.bg, a.fg_truecolor = s.fg_truecolor, a.bg_truecolor = s.bg_truecolor, a.decorations = s.decorations, a.decoration = s.decorations.slice(-1).pop() || null, a.was_processed = !0), a;
393
397
  }
394
398
  /**
395
399
  * processChunk
@@ -406,207 +410,207 @@ function ne() {
406
410
  * @param {Boolean} markup If false, the colors will not be parsed.
407
411
  * @return {Object|String} The result (object if `json` is wanted back or string otherwise).
408
412
  */
409
- processChunk(r, t, h) {
410
- t = t || {};
411
- let e = this.processChunkJson(r, t, h), l = t.use_classes;
412
- if (e.decorations = e.decorations.filter((i) => {
413
+ processChunk(t, e, h) {
414
+ e = e || {};
415
+ let r = this.processChunkJson(t, e, h), l = e.use_classes;
416
+ if (r.decorations = r.decorations.filter((i) => {
413
417
  if (i === "reverse") {
414
- e.fg || (e.fg = s[0][7][l ? "class" : "color"]), e.bg || (e.bg = s[0][0][l ? "class" : "color"]);
415
- let m = e.fg;
416
- e.fg = e.bg, e.bg = m;
417
- let y = e.fg_truecolor;
418
- return e.fg_truecolor = e.bg_truecolor, e.bg_truecolor = y, e.isInverted = !0, !1;
418
+ r.fg || (r.fg = n[0][7][l ? "class" : "color"]), r.bg || (r.bg = n[0][0][l ? "class" : "color"]);
419
+ let b = r.fg;
420
+ r.fg = r.bg, r.bg = b;
421
+ let w = r.fg_truecolor;
422
+ return r.fg_truecolor = r.bg_truecolor, r.bg_truecolor = w, r.isInverted = !0, !1;
419
423
  }
420
424
  return !0;
421
- }), t.json)
422
- return e;
423
- if (e.isEmpty())
425
+ }), e.json)
426
+ return r;
427
+ if (r.isEmpty())
424
428
  return "";
425
- if (!e.was_processed)
426
- return e.content;
427
- let a = [], c = [], p = [], n = {}, u = (i) => {
428
- let m = [], y;
429
- for (y in i)
430
- i.hasOwnProperty(y) && m.push("data-" + y + '="' + this.escapeForHtml(i[y]) + '"');
431
- return m.length > 0 ? " " + m.join(" ") : "";
429
+ if (!r.was_processed)
430
+ return r.content;
431
+ let a = [], u = [], f = [], s = {}, v = (i) => {
432
+ let b = [], w;
433
+ for (w in i)
434
+ i.hasOwnProperty(w) && b.push("data-" + w + '="' + this.escapeForHtml(i[w]) + '"');
435
+ return b.length > 0 ? " " + b.join(" ") : "";
432
436
  };
433
- return e.isInverted && (n["ansi-is-inverted"] = "true"), e.fg && (l ? (a.push(e.fg + "-fg"), e.fg_truecolor !== null && (n["ansi-truecolor-fg"] = e.fg_truecolor, e.fg_truecolor = null)) : a.push("color:rgb(" + e.fg + ")")), e.bg && (l ? (a.push(e.bg + "-bg"), e.bg_truecolor !== null && (n["ansi-truecolor-bg"] = e.bg_truecolor, e.bg_truecolor = null)) : a.push("background-color:rgb(" + e.bg + ")")), e.decorations.forEach((i) => {
437
+ return r.isInverted && (s["ansi-is-inverted"] = "true"), r.fg && (l ? (a.push(r.fg + "-fg"), r.fg_truecolor !== null && (s["ansi-truecolor-fg"] = r.fg_truecolor, r.fg_truecolor = null)) : a.push("color:rgb(" + r.fg + ")")), r.bg && (l ? (a.push(r.bg + "-bg"), r.bg_truecolor !== null && (s["ansi-truecolor-bg"] = r.bg_truecolor, r.bg_truecolor = null)) : a.push("background-color:rgb(" + r.bg + ")")), r.decorations.forEach((i) => {
434
438
  if (l) {
435
- c.push("ansi-" + i);
439
+ u.push("ansi-" + i);
436
440
  return;
437
441
  }
438
- i === "bold" ? c.push("font-weight:bold") : i === "dim" ? c.push("opacity:0.5") : i === "italic" ? c.push("font-style:italic") : i === "hidden" ? c.push("visibility:hidden") : i === "strikethrough" ? p.push("line-through") : p.push(i);
439
- }), p.length && c.push("text-decoration:" + p.join(" ")), l ? '<span class="' + a.concat(c).join(" ") + '"' + u(n) + ">" + e.content + "</span>" : '<span style="' + a.concat(c).join(";") + '"' + u(n) + ">" + e.content + "</span>";
442
+ i === "bold" ? u.push("font-weight:bold") : i === "dim" ? u.push("opacity:0.5") : i === "italic" ? u.push("font-style:italic") : i === "hidden" ? u.push("visibility:hidden") : i === "strikethrough" ? f.push("line-through") : f.push(i);
443
+ }), f.length && u.push("text-decoration:" + f.join(" ")), l ? '<span class="' + a.concat(u).join(" ") + '"' + v(s) + ">" + r.content + "</span>" : '<span style="' + a.concat(u).join(";") + '"' + v(s) + ">" + r.content + "</span>";
440
444
  }
441
- removeDecoration(r) {
442
- const t = this.decorations.indexOf(r);
443
- t >= 0 && this.decorations.splice(t, 1);
445
+ removeDecoration(t) {
446
+ const e = this.decorations.indexOf(t);
447
+ e >= 0 && this.decorations.splice(e, 1);
444
448
  }
445
449
  }
446
450
  return P = g, P;
447
451
  }
448
- var se = ne();
449
- const ie = /* @__PURE__ */ re(se);
450
- var q = { exports: {} }, N;
451
- function le() {
452
- if (N) return q.exports;
453
- N = 1;
454
- function s(r) {
455
- if (!r) return "";
456
- if (!/\r/.test(r)) return r;
457
- for (r = r.replace(/\r+\n/gm, `
458
- `); /\r./.test(r); )
459
- r = r.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm, function(t, h, e) {
460
- return e + h.slice(e.length);
452
+ var be = me();
453
+ const we = /* @__PURE__ */ de(be);
454
+ var x = { exports: {} }, H;
455
+ function ke() {
456
+ if (H) return x.exports;
457
+ H = 1;
458
+ function n(t) {
459
+ if (!t) return "";
460
+ if (!/\r/.test(t)) return t;
461
+ for (t = t.replace(/\r+\n/gm, `
462
+ `); /\r./.test(t); )
463
+ t = t.replace(/^([^\r\n]*)\r+([^\r\n]+)/gm, function(e, h, r) {
464
+ return r + h.slice(r.length);
461
465
  });
462
- return r;
463
- }
464
- function o(r) {
465
- for (var t = 0, h = 0; h < r.length; h++)
466
- r[t].length <= r[h].length && (t = h);
467
466
  return t;
468
467
  }
469
- function g(r) {
470
- if (!/\r/.test(r)) return r;
471
- for (var t = r.split("\r"), h = []; t.length > 0; ) {
472
- var e = o(t);
473
- h.push(t[e]), t = t.slice(e + 1);
468
+ function c(t) {
469
+ for (var e = 0, h = 0; h < t.length; h++)
470
+ t[e].length <= t[h].length && (e = h);
471
+ return e;
472
+ }
473
+ function g(t) {
474
+ if (!/\r/.test(t)) return t;
475
+ for (var e = t.split("\r"), h = []; e.length > 0; ) {
476
+ var r = c(e);
477
+ h.push(e[r]), e = e.slice(r + 1);
474
478
  }
475
479
  return h.join("\r");
476
480
  }
477
- function d(r) {
478
- if (!r) return "";
479
- if (!/\r/.test(r)) return r;
480
- if (!/\n/.test(r)) return g(r);
481
- r = r.replace(/\r+\n/gm, `
481
+ function y(t) {
482
+ if (!t) return "";
483
+ if (!/\r/.test(t)) return t;
484
+ if (!/\n/.test(t)) return g(t);
485
+ t = t.replace(/\r+\n/gm, `
482
486
  `);
483
- var t = r.lastIndexOf(`
487
+ var e = t.lastIndexOf(`
484
488
  `);
485
- return s(r.slice(0, t)) + `
486
- ` + g(r.slice(t + 1));
489
+ return n(t.slice(0, e)) + `
490
+ ` + g(t.slice(e + 1));
487
491
  }
488
- return q.exports = s, q.exports.escapeCarriageReturn = s, q.exports.escapeCarriageReturnSafe = d, q.exports;
492
+ return x.exports = n, x.exports.escapeCarriageReturn = n, x.exports.escapeCarriageReturnSafe = y, x.exports;
489
493
  }
490
- var oe = le();
491
- function ae(s, o) {
492
- return s = oe.escapeCarriageReturn(ge(s)), ie.ansiToJson(s, {
494
+ var Ce = ke();
495
+ function ve(n, c) {
496
+ return n = Ce.escapeCarriageReturn(xe(n)), we.ansiToJson(n, {
493
497
  json: !0,
494
498
  // eslint-disable-next-line @typescript-eslint/naming-convention
495
499
  remove_empty: !0,
496
500
  // eslint-disable-next-line @typescript-eslint/naming-convention
497
- use_classes: o
501
+ use_classes: c
498
502
  });
499
503
  }
500
- function ce(s) {
501
- const o = [];
502
- return s.bg && o.push(C[`${s.bg}-bg`]), s.fg && o.push(C[`${s.fg}-fg`]), s.decoration && o.push(C[`ansi-${s.decoration}`]), o.length === 0 ? null : o.join(" ");
504
+ function Se(n) {
505
+ const c = [];
506
+ return n.bg && c.push(C[`${n.bg}-bg`]), n.fg && c.push(C[`${n.fg}-fg`]), n.decoration && c.push(C[`ansi-${n.decoration}`]), c.length === 0 ? null : c.join(" ");
503
507
  }
504
- function ue(s) {
505
- const o = {};
506
- switch (s.bg && (o.backgroundColor = `rgb(${s.bg})`), s.fg && (o.color = `rgb(${s.fg})`), s.decoration) {
508
+ function Te(n) {
509
+ const c = {};
510
+ switch (n.bg && (c.backgroundColor = `rgb(${n.bg})`), n.fg && (c.color = `rgb(${n.fg})`), n.decoration) {
507
511
  case "bold":
508
- o.fontWeight = "bold";
512
+ c.fontWeight = "bold";
509
513
  break;
510
514
  case "dim":
511
- o.opacity = "0.5";
515
+ c.opacity = "0.5";
512
516
  break;
513
517
  case "italic":
514
- o.fontStyle = "italic";
518
+ c.fontStyle = "italic";
515
519
  break;
516
520
  case "hidden":
517
- o.visibility = "hidden";
521
+ c.visibility = "hidden";
518
522
  break;
519
523
  case "strikethrough":
520
- o.textDecoration = "line-through";
524
+ c.textDecoration = "line-through";
521
525
  break;
522
526
  case "underline":
523
- o.textDecoration = "underline";
527
+ c.textDecoration = "underline";
524
528
  break;
525
529
  case "blink":
526
- o.textDecoration = "blink";
530
+ c.textDecoration = "blink";
527
531
  break;
528
532
  }
529
- return o;
533
+ return c;
530
534
  }
531
- function fe(s, o, g, d) {
532
- const r = o ? null : ue(g), t = o ? ce(g) : null;
533
- if (!s)
535
+ function Ee(n, c, g, y) {
536
+ const t = c ? null : Te(g), e = c ? Se(g) : null;
537
+ if (!n)
534
538
  return L.createElement(
535
539
  "pre",
536
- { style: r, key: d, className: t },
540
+ { style: t, key: y, className: e },
537
541
  g.content
538
542
  );
539
- const h = [], e = /(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;
543
+ const h = [], r = /(\s|^)(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/g;
540
544
  let l = 0, a;
541
- for (; (a = e.exec(g.content)) !== null; ) {
542
- const [, c, p] = a, n = a.index + c.length;
543
- n > l && h.push(g.content.substring(l, n));
544
- const u = p.startsWith("www.") ? `http://${p}` : p;
545
+ for (; (a = r.exec(g.content)) !== null; ) {
546
+ const [, u, f] = a, s = a.index + u.length;
547
+ s > l && h.push(g.content.substring(l, s));
548
+ const v = f.startsWith("www.") ? `http://${f}` : f;
545
549
  h.push(
546
550
  L.createElement(
547
551
  "a",
548
552
  {
549
553
  key: l,
550
- href: u,
554
+ href: v,
551
555
  target: "_blank"
552
556
  },
553
- `${p}`
557
+ `${f}`
554
558
  )
555
- ), l = e.lastIndex;
559
+ ), l = r.lastIndex;
556
560
  }
557
- return l < g.content.length && h.push(g.content.substring(l)), L.createElement("span", { style: r, key: d, className: t }, h);
561
+ return l < g.content.length && h.push(g.content.substring(l)), L.createElement("span", { style: t, key: y, className: e }, h);
558
562
  }
559
- function F(s) {
560
- const { className: o, useClasses: g, children: d, linkify: r } = s;
563
+ function K(n) {
564
+ const { className: c, useClasses: g, children: y, linkify: t } = n;
561
565
  return L.createElement(
562
566
  "code",
563
- { className: o },
564
- ae(d ?? "", g ?? !1).map(
565
- fe.bind(null, r ?? !1, g ?? !1)
567
+ { className: c },
568
+ ve(y ?? "", g ?? !1).map(
569
+ Ee.bind(null, t ?? !1, g ?? !1)
566
570
  )
567
571
  );
568
572
  }
569
- function ge(s) {
570
- let o = s;
573
+ function xe(n) {
574
+ let c = n;
571
575
  do
572
- s = o, o = s.replace(/[^\n]\x08/gm, "");
573
- while (o.length < s.length);
574
- return s;
576
+ n = c, c = n.replace(/[^\n]\x08/gm, "");
577
+ while (c.length < n.length);
578
+ return n;
575
579
  }
576
- const A = Z(({ text: s }, o) => {
577
- const g = s?.split(`
580
+ const A = se(ne(({ text: n }, c) => {
581
+ const g = n?.split(`
578
582
  `);
579
- return /* @__PURE__ */ k("div", { ref: o, children: g?.map(
580
- (d, r) => /* @__PURE__ */ k(F, { className: C.Output, useClasses: !0, children: d === "" ? " " : d }, r)
583
+ return /* @__PURE__ */ k("div", { ref: c, children: g?.map(
584
+ (y, t) => /* @__PURE__ */ k(K, { className: C.Output, useClasses: !0, children: y === "" ? " " : y }, t)
581
585
  ) });
582
- });
583
- function he({ value: s, prefix: o, onChange: g, onKeyUp: d, onKeyDown: r, inputRef: t }) {
584
- const [h, e] = $(0), l = R(null);
585
- V(() => {
586
- const c = t.current;
587
- c && l.current !== null ? (c.setSelectionRange(l.current, l.current), e(l.current), l.current = null) : c && c.selectionStart !== null && e(c.selectionStart);
588
- }, [s, t]);
586
+ }));
587
+ function Re({ value: n, prefix: c, onChange: g, onKeyUp: y, onKeyDown: t, inputRef: e }) {
588
+ const [h, r] = j(0), l = O(null);
589
+ ie(() => {
590
+ const u = e.current;
591
+ u && l.current !== null ? (u.setSelectionRange(l.current, l.current), r(l.current), l.current = null) : u && u.selectionStart !== null && r(u.selectionStart);
592
+ }, [n, e]);
589
593
  const a = () => {
590
- const c = t.current?.selectionStart;
591
- c != null && e(c);
594
+ const u = e.current?.selectionStart;
595
+ u != null && r(u);
592
596
  };
593
597
  return /* @__PURE__ */ I("span", { className: C.Input, children: [
594
- o && /* @__PURE__ */ k(F, { className: C.Prefix, useClasses: !0, children: o }),
598
+ c && /* @__PURE__ */ k(K, { className: C.Prefix, useClasses: !0, children: c }),
595
599
  /* @__PURE__ */ I("span", { className: C["Input-container"], style: { "--cursor-offset": h }, children: [
596
- /* @__PURE__ */ k("span", { "aria-hidden": "true", children: s }),
600
+ /* @__PURE__ */ k("span", { "aria-hidden": "true", children: n }),
597
601
  /* @__PURE__ */ k(
598
602
  "input",
599
603
  {
600
604
  id: "input",
601
- value: s,
605
+ value: n,
602
606
  "aria-label": "Command input",
603
- onChange: (c) => {
604
- l.current = c.target.selectionStart, g(c);
607
+ onChange: (u) => {
608
+ l.current = u.target.selectionStart, g(u);
605
609
  },
606
- ref: t,
607
- onKeyUp: d,
608
- onKeyDown: (c) => {
609
- r?.(c), a();
610
+ ref: e,
611
+ onKeyUp: y,
612
+ onKeyDown: (u) => {
613
+ t?.(u), a();
610
614
  },
611
615
  onClick: a,
612
616
  onSelect: a,
@@ -618,130 +622,145 @@ function he({ value: s, prefix: o, onChange: g, onKeyUp: d, onKeyDown: r, inputR
618
622
  ] })
619
623
  ] });
620
624
  }
621
- function pe({ app: s, path: o, input: g, setTitle: d, close: r, active: t, focus: h }) {
622
- const e = R(null), l = R(null), a = R(G.ZERO), [c, p] = $(0), [n, u] = M({
623
- app: s,
624
- path: o,
625
+ function Le({ app: n, path: c, input: g, setTitle: y, close: t, active: e, focus: h, autoSubmit: r }) {
626
+ const l = O(null), a = O(null), u = O(le.ZERO), { charSize: f, containerSize: s, sentinel: v } = Z({ containerRef: l }), [i, b] = j(0), [w, _] = j(!1), [d, o] = G({
627
+ app: n,
628
+ path: c,
625
629
  input: g,
626
- exit: r,
627
- sizeRef: a
630
+ exit: t,
631
+ sizeRef: u
628
632
  });
629
633
  E(() => {
630
- d?.(`${z}@${B}: ${u.workingDirectory.root ? "/" : u.workingDirectory.path}`);
631
- }, [u.workingDirectory.path, u.workingDirectory.root, d]), E(() => {
632
- t && (u.stream ? e.current?.focus() : l.current?.focus());
633
- }, [t, u.stream]), E(() => {
634
- if (l.current && !u.stream) {
635
- const f = u.line.length;
636
- l.current.setSelectionRange(f, f);
634
+ r && g && o.prompt && !w && (_(!0), window.confirm(`Do you want to run the following command?
635
+
636
+ ${g}`) && (d.run(g), b((p) => p + 1)));
637
+ }, [r, g, w, o.prompt, d]), E(() => {
638
+ y?.(oe.strip(o.prompt).trim());
639
+ }, [o.prompt, y]), E(() => {
640
+ e && (o.stream ? l.current?.focus() : a.current?.focus());
641
+ }, [e, o.stream]), E(() => {
642
+ if (a.current && !o.stream) {
643
+ const p = o.line.length;
644
+ a.current.setSelectionRange(p, p);
637
645
  }
638
- }, [u.historyOffset]);
639
- const i = () => {
640
- e.current && (e.current.scrollTop = e.current.scrollHeight);
646
+ }, [o.historyOffset]);
647
+ const T = () => {
648
+ l.current && (l.current.scrollTop = l.current.scrollHeight);
641
649
  };
642
650
  E(() => {
643
- i();
644
- }, [u.history.length, u.line, u.ttyBuffer]), E(() => {
645
- if (!e.current) return;
646
- const f = () => {
647
- if (!e.current) return;
648
- const w = getComputedStyle(e.current), S = parseFloat(w.fontSize), x = 0.585 * S, O = 1.25 * S, { width: D, height: H } = e.current.getBoundingClientRect();
649
- a.current.set(
650
- Math.ceil(D / x),
651
- Math.ceil(H / O)
652
- );
653
- }, _ = new ResizeObserver(f);
654
- return _.observe(e.current), f(), () => _.disconnect();
655
- }, []);
656
- const m = (f) => {
657
- const { key: _ } = f;
658
- if ((f.ctrlKey || f.metaKey) && _ === "c" && !f.shiftKey) {
659
- f.preventDefault(), n.interrupt();
660
- return;
661
- }
662
- if (!u.stream)
663
- if (_ === "Tab")
664
- f.preventDefault(), n.autoComplete();
665
- else if (_ === "Enter") {
666
- const w = f.target.value;
667
- n.run(w), p((S) => S + 1);
668
- } else _ === "ArrowUp" ? (f.preventDefault(), n.historySearch(1)) : _ === "ArrowDown" && (f.preventDefault(), n.historySearch(-1));
669
- }, y = (f) => {
670
- n.setLine(f.target.value);
671
- }, b = () => {
672
- if (u.isUsingAltScreen)
673
- return u.ttyBuffer ? /* @__PURE__ */ k(A, { text: u.ttyBuffer }) : null;
674
- let f = 0;
675
- for (let _ = u.history.length - 1; _ >= 0; _--)
676
- if (u.history[_].clear) {
677
- f = _ + 1;
651
+ T();
652
+ }, [o.history.length, o.line, o.ttyBuffer]), E(() => {
653
+ u.current.set(s.x, s.y);
654
+ }, [s]);
655
+ const F = (p) => {
656
+ d.handleKeyDown(p), p.key === "Enter" && !o.stream && b((m) => m + 1);
657
+ }, M = (p) => {
658
+ d.setLine(p.target.value);
659
+ }, z = D(() => {
660
+ if (o.isUsingAltScreen)
661
+ return o.ttyBuffer ? /* @__PURE__ */ k(A, { text: o.ttyBuffer }) : null;
662
+ let p = 0;
663
+ for (let m = o.history.length - 1; m >= 0; m--)
664
+ if ((o.history[m].flags & Q.Clear) !== 0) {
665
+ p = m + 1;
678
666
  break;
679
667
  }
680
- return /* @__PURE__ */ I(W, { children: [
681
- u.history.slice(f).map(
682
- (_, w) => /* @__PURE__ */ k(A, { text: _.text }, w)
683
- ),
684
- u.ttyBuffer && /* @__PURE__ */ k(A, { text: u.ttyBuffer })
685
- ] });
686
- }, v = (f) => {
687
- h?.(f), f.button === 2 && (f.preventDefault(), navigator.clipboard.readText().then((_) => {
688
- const w = l.current;
689
- if (!w) return;
690
- const S = w.selectionStart ?? u.line.length, x = w.selectionEnd ?? u.line.length;
691
- n.setLine((D) => D.substring(0, S) + _ + D.substring(x));
692
- const O = S + _.length;
668
+ return o.history.slice(p).map(
669
+ (m, S) => /* @__PURE__ */ k(A, { text: m.displayText }, S)
670
+ );
671
+ }, [o.history, o.isUsingAltScreen, o.ttyBuffer]), J = (p) => {
672
+ h?.(p), p.button === 2 && (p.preventDefault(), navigator.clipboard.readText().then((m) => {
673
+ if (o.isRawMode) {
674
+ for (const R of m)
675
+ d.handleKeyDown({
676
+ key: R,
677
+ ctrlKey: p.ctrlKey,
678
+ metaKey: p.metaKey,
679
+ shiftKey: p.shiftKey,
680
+ preventDefault: p.preventDefault.bind(p)
681
+ });
682
+ return;
683
+ }
684
+ const S = a.current;
685
+ if (!S)
686
+ return;
687
+ const $ = S.selectionStart ?? o.line.length, W = S.selectionEnd ?? o.line.length;
688
+ d.setLine((R) => R.substring(0, $) + m + R.substring(W));
689
+ const B = $ + m.length;
693
690
  setTimeout(() => {
694
- w.focus(), w.setSelectionRange(O, O);
691
+ S.focus(), S.setSelectionRange(B, B);
695
692
  }, 0);
696
- }).catch((_) => {
697
- console.error(_);
693
+ }).catch((m) => {
694
+ console.error(m);
698
695
  }));
699
- }, T = (f) => {
700
- f.preventDefault();
701
- };
696
+ }, U = (p) => {
697
+ p.preventDefault();
698
+ }, q = D(() => f.x === 0 || f.y === 0 ? {} : {
699
+ "--char-width": `${f.x}px`,
700
+ "--char-height": `${f.y}px`
701
+ }, [f]), V = D(() => !o.isRawMode || f.x === 0 || f.y === 0 ? {} : {
702
+ left: o.cursorPosition.x * f.x,
703
+ top: o.cursorPosition.y * f.y
704
+ }, [o.cursorPosition, o.isRawMode, f]);
702
705
  return /* @__PURE__ */ I(
703
706
  "div",
704
707
  {
705
- ref: e,
708
+ ref: l,
706
709
  tabIndex: 0,
707
710
  className: C.Terminal,
708
- onKeyDown: m,
709
- onMouseDown: v,
710
- onContextMenu: T,
711
- onClick: (f) => {
712
- window.getSelection()?.toString() === "" && (f.preventDefault(), u.stream ? e.current?.focus() : l.current?.focus());
711
+ style: q,
712
+ onKeyDown: F,
713
+ onMouseDown: J,
714
+ onContextMenu: U,
715
+ onClick: (p) => {
716
+ window.getSelection()?.toString().length || (p.preventDefault(), o.stream ? l.current?.focus() : a.current?.focus());
713
717
  },
714
718
  children: [
715
- /* @__PURE__ */ k("div", { className: C.History, children: b() }),
716
- !u.isUsingAltScreen && (u.stream ? null : /* @__PURE__ */ k(
717
- he,
719
+ v,
720
+ /* @__PURE__ */ I("div", { className: C.History, children: [
721
+ z,
722
+ o.isRawMode && /* @__PURE__ */ k("div", { className: C.VirtualCursor, style: V })
723
+ ] }),
724
+ !o.isUsingAltScreen && !o.stream && /* @__PURE__ */ k(
725
+ Re,
718
726
  {
719
- value: u.line,
720
- prefix: u.prompt,
721
- onChange: y,
722
- inputRef: l
727
+ value: o.line,
728
+ prefix: (o.ttyBuffer ?? "") + o.prompt,
729
+ onChange: M,
730
+ inputRef: a
723
731
  },
724
- c
725
- ))
732
+ i
733
+ ),
734
+ !o.isUsingAltScreen && o.stream && o.ttyBuffer && /* @__PURE__ */ k(A, { text: o.ttyBuffer }),
735
+ o.stream && /* @__PURE__ */ k(
736
+ X,
737
+ {
738
+ className: `${C.InterruptButton} ${Y.TextBold}`,
739
+ onClick: () => d.interrupt(),
740
+ title: "Interrupt (Ctrl+C)",
741
+ icon: ae,
742
+ children: "Stop"
743
+ }
744
+ )
726
745
  ]
727
746
  }
728
747
  );
729
748
  }
730
- class _e extends J {
749
+ class Oe extends ee {
731
750
  constructor() {
732
- super("Terminal", "terminal", pe), this.setIconUrl("https://os.prozilla.dev/assets/apps/icons/terminal.svg"), this.setRole(K.APP_ROLES.terminal), this.setCategory("Utilities & tools");
751
+ super("Terminal", "terminal", Le), this.setIconUrl("https://os.prozilla.dev/assets/apps/icons/terminal.svg"), this.setRole(te.APP_ROLES.terminal), this.setCategory("Utilities & tools");
733
752
  }
734
- addCommands(o) {
735
- return o.forEach((g) => this.addCommand(g)), this;
753
+ addCommands(c) {
754
+ return c.forEach((g) => this.addCommand(g)), this;
736
755
  }
737
- addCommand(o) {
738
- return U.addCommand(o), this;
756
+ addCommand(c) {
757
+ return re.builtins.push(c), this;
739
758
  }
740
759
  }
741
- const de = new _e();
742
- de.setMetadata({ name: "@prozilla-os/terminal", version: "1.1.21", author: "Prozilla" });
760
+ const Ie = new Oe();
761
+ Ie.setMetadata({ name: "@prozilla-os/terminal", version: "2.0.1", author: "Prozilla", website: "https://os.prozilla.dev/terminal" });
743
762
  export {
744
- _e as TerminalApp,
745
- de as terminal
763
+ Oe as TerminalApp,
764
+ Ie as terminal
746
765
  };
747
766
  //# sourceMappingURL=main.js.map