citadel_cli 1.1.6 → 1.1.7

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.
@@ -1,13 +1,13 @@
1
- var ge = Object.defineProperty;
2
- var fe = (r, e, n) => e in r ? ge(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var y = (r, e, n) => fe(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { jsx as m, jsxs as _, Fragment as we } from "react/jsx-runtime";
5
- import L, { createContext as be, useEffect as A, useContext as Y, useState as R, useCallback as b, useMemo as V, useReducer as ye, useRef as P } from "react";
6
- import { createRoot as xe } from "react-dom/client";
7
- var T = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(T || {});
8
- class U {
1
+ var ye = Object.defineProperty;
2
+ var xe = (r, e, n) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var b = (r, e, n) => xe(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { jsx as m, jsxs as N, Fragment as ve } from "react/jsx-runtime";
5
+ import O, { createContext as Ce, useState as R, useEffect as A, useMemo as D, useContext as Y, useCallback as y, useReducer as Se, useRef as H } from "react";
6
+ import { createRoot as ke } from "react-dom/client";
7
+ var F = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(F || {});
8
+ class T {
9
9
  constructor(e = Date.now()) {
10
- y(this, "_status", "pending");
10
+ b(this, "_status", "pending");
11
11
  this.timestamp = e;
12
12
  }
13
13
  get status() {
@@ -23,7 +23,7 @@ class U {
23
23
  this._status = "timeout";
24
24
  }
25
25
  }
26
- class an extends U {
26
+ class ln extends T {
27
27
  constructor(e, n) {
28
28
  super(n), this.data = e;
29
29
  }
@@ -31,7 +31,7 @@ class an extends U {
31
31
  return /* @__PURE__ */ m("pre", { className: "text-gray-200", children: JSON.stringify(this.data, null, 2) });
32
32
  }
33
33
  }
34
- class ae extends U {
34
+ class G extends T {
35
35
  constructor(e, n) {
36
36
  super(n), this.text = e;
37
37
  }
@@ -39,7 +39,7 @@ class ae extends U {
39
39
  return /* @__PURE__ */ m("div", { className: "text-gray-200 whitespace-pre font-mono", children: this.text });
40
40
  }
41
41
  }
42
- class ve extends U {
42
+ class Ne extends T {
43
43
  constructor(e, n) {
44
44
  super(n), this.error = e, this.markFailure();
45
45
  }
@@ -47,12 +47,12 @@ class ve extends U {
47
47
  return /* @__PURE__ */ m("div", { className: "mt-1 text-red-400", children: this.error });
48
48
  }
49
49
  }
50
- class Ce extends U {
50
+ class Ee extends T {
51
51
  render() {
52
52
  return /* @__PURE__ */ m("div", { className: "text-gray-400", children: "..." });
53
53
  }
54
54
  }
55
- class ln extends U {
55
+ class cn extends T {
56
56
  constructor(e, n = "", t) {
57
57
  super(t), this.imageUrl = e, this.altText = n;
58
58
  }
@@ -67,24 +67,27 @@ class ln extends U {
67
67
  ) });
68
68
  }
69
69
  }
70
- const Se = (r) => async function() {
70
+ const _e = (r) => async function() {
71
71
  const e = r.commands.filter((n) => n.fullPath[0] !== "help").map((n) => `${n.segments.map((o) => o.type === "argument" ? `<${o.name}>` : o.name).join(" ")} - ${n.description}`).sort();
72
- return e.push("help - Show available commands"), new ae(
73
- e.length > 0 ? `Available Commands:
72
+ return e.length === 0 ? new G(
73
+ "No commands available yet. Add some commands to get started!"
74
+ ) : (e.push("help - Show available commands"), new G(
75
+ `Available Commands:
74
76
  ` + e.join(`
75
- `) : "No commands available yet. Add some commands to get started!"
76
- );
77
+ `)
78
+ ));
77
79
  };
78
- var W = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.ERROR = 1] = "ERROR", r[r.WARN = 2] = "WARN", r[r.INFO = 3] = "INFO", r[r.DEBUG = 4] = "DEBUG", r[r.TRACE = 5] = "TRACE", r))(W || {});
79
- class E {
80
+ var Q = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.ERROR = 1] = "ERROR", r[r.WARN = 2] = "WARN", r[r.INFO = 3] = "INFO", r[r.DEBUG = 4] = "DEBUG", r[r.TRACE = 5] = "TRACE", r))(Q || {});
81
+ const ne = !0;
82
+ class C {
80
83
  static configure(e) {
81
84
  this.level = e.level, this.prefix = e.prefix || "[Citadel]";
82
85
  }
83
86
  static trace(...e) {
84
- this.level >= 5 && process.env.NODE_ENV !== "production" && console.trace(this.prefix, ...e);
87
+ this.level >= 5 && !ne && console.trace(this.prefix, ...e);
85
88
  }
86
89
  static debug(...e) {
87
- this.level >= 4 && process.env.NODE_ENV !== "production" && console.debug(this.prefix, ...e);
90
+ this.level >= 4 && !ne && console.debug(this.prefix, ...e);
88
91
  }
89
92
  static info(...e) {
90
93
  this.level >= 3 && console.info(this.prefix, ...e);
@@ -96,15 +99,15 @@ class E {
96
99
  this.level >= 1 && console.error(this.prefix, ...e);
97
100
  }
98
101
  }
99
- y(E, "level", 0), y(E, "prefix", "");
100
- const z = {
102
+ b(C, "level", 0), b(C, "prefix", "");
103
+ const _ = {
101
104
  commandTimeoutMs: 1e4,
102
105
  cursorColor: "var(--cursor-color, #fff)",
103
106
  cursorSpeed: 530,
104
107
  cursorType: "blink",
105
108
  includeHelpCommand: !0,
106
109
  initialHeight: "40vh",
107
- logLevel: process.env.NODE_ENV === "production" ? W.ERROR : W.DEBUG,
110
+ logLevel: Q.ERROR,
108
111
  maxHeight: "80vh",
109
112
  minHeight: "200",
110
113
  outputFontSize: "0.875rem",
@@ -116,9 +119,9 @@ const z = {
116
119
  maxCommands: 100
117
120
  }
118
121
  };
119
- class ie {
122
+ class de {
120
123
  constructor(e) {
121
- y(this, "config");
124
+ b(this, "config");
122
125
  this.config = {
123
126
  type: "localStorage",
124
127
  maxCommands: 100,
@@ -135,10 +138,10 @@ class ie {
135
138
  await this.saveCommands(n);
136
139
  }
137
140
  }
138
- class ke extends ie {
141
+ class Ae extends de {
139
142
  constructor(n) {
140
143
  super(n);
141
- y(this, "storageKey", "citadel_command_history");
144
+ b(this, "storageKey", "citadel_command_history");
142
145
  }
143
146
  async getStoredCommands() {
144
147
  try {
@@ -170,10 +173,10 @@ class ke extends ie {
170
173
  }
171
174
  }
172
175
  }
173
- class Ee extends ie {
176
+ class te extends de {
174
177
  constructor(n) {
175
178
  super(n);
176
- y(this, "storedCommands", []);
179
+ b(this, "storedCommands", []);
177
180
  }
178
181
  async getStoredCommands() {
179
182
  return this.storedCommands.map((n) => ({
@@ -191,20 +194,22 @@ class Ee extends ie {
191
194
  }));
192
195
  }
193
196
  }
194
- const D = class D {
197
+ const P = class P {
195
198
  constructor() {
196
- y(this, "currentStorage");
199
+ b(this, "currentStorage");
200
+ }
201
+ static reset() {
202
+ P.instance = void 0;
197
203
  }
198
204
  static getInstance() {
199
- return D.instance || (D.instance = new D()), D.instance;
205
+ return P.instance || (P.instance = new P()), P.instance;
200
206
  }
201
207
  initializeStorage(e) {
202
- if (!this.currentStorage)
203
- try {
204
- this.currentStorage = new ke(e);
205
- } catch (n) {
206
- console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new Ee(e);
207
- }
208
+ try {
209
+ e.type === "memory" ? this.currentStorage = new te(e) : this.currentStorage = new Ae(e);
210
+ } catch (n) {
211
+ console.warn("Failed to create storage, falling back to memory storage:", n), this.currentStorage = new te(e);
212
+ }
208
213
  }
209
214
  getStorage() {
210
215
  if (!this.currentStorage)
@@ -212,10 +217,10 @@ const D = class D {
212
217
  return this.currentStorage;
213
218
  }
214
219
  };
215
- y(D, "instance");
216
- let q = D;
217
- const le = async () => new ae("");
218
- class J {
220
+ b(P, "instance");
221
+ let q = P;
222
+ const me = async () => new G("");
223
+ class X {
219
224
  constructor(e, n, t) {
220
225
  this.type = e, this.name = n, this.description = t;
221
226
  }
@@ -223,27 +228,27 @@ class J {
223
228
  return this.name;
224
229
  }
225
230
  }
226
- class ce extends J {
231
+ class ue extends X {
227
232
  constructor() {
228
233
  super("null", ">null<", "Empty segment");
229
234
  }
230
235
  }
231
- class Ne extends J {
236
+ class ze extends X {
232
237
  constructor(e, n) {
233
238
  super("word", e, n);
234
239
  }
235
240
  }
236
- class _e extends J {
241
+ class W extends X {
237
242
  constructor(e, n, t, o) {
238
243
  super("argument", e, n), this.value = t, this.valid = o;
239
244
  }
240
245
  }
241
- class Ae {
242
- constructor(e, n, t = le) {
243
- y(this, "_segments");
244
- y(this, "_description");
246
+ class Ie {
247
+ constructor(e, n, t = me) {
248
+ b(this, "_segments");
249
+ b(this, "_description");
245
250
  // Used by `Help` command, etc.
246
- y(this, "_handler");
251
+ b(this, "_handler");
247
252
  this._segments = e, this._description = n, this._handler = t;
248
253
  }
249
254
  get segments() {
@@ -268,9 +273,9 @@ class Ae {
268
273
  return this.fullPath.join(" ") === e.fullPath.join(" ");
269
274
  }
270
275
  }
271
- class Q {
276
+ class Z {
272
277
  constructor() {
273
- y(this, "_commands", []);
278
+ b(this, "_commands", []);
274
279
  }
275
280
  get commands() {
276
281
  return this._commands;
@@ -286,19 +291,19 @@ class Q {
286
291
  * @param handler Async handler executed when the command is submitted; defaults to `NoopHandler`.
287
292
  * @throws {Error} If the segment list is empty or the path collides with an existing command.
288
293
  */
289
- addCommand(e, n, t = le) {
294
+ addCommand(e, n, t = me) {
290
295
  if (e === void 0 || e.length === 0)
291
296
  throw new Error("Command path cannot be empty");
292
- const o = new Ae(e, n, t), s = this._commands.find((a) => {
293
- const l = a.segments.map(
294
- (c) => c.type === "argument" ? "*" : c.name
295
- ).join(" "), d = e.map(
296
- (c) => c.type === "argument" ? "*" : c.name
297
+ const o = new Ie(e, n, t), a = this._commands.find((i) => {
298
+ const c = i.segments.map(
299
+ (l) => l.type === "argument" ? "*" : l.name
300
+ ).join(" "), s = e.map(
301
+ (l) => l.type === "argument" ? "*" : l.name
297
302
  ).join(" ");
298
- return l === d;
303
+ return c === s;
299
304
  });
300
- if (s)
301
- throw new Error(`Duplicate commands: '${s.fullPath_s}' and '${o.fullPath_s}'`);
305
+ if (a)
306
+ throw new Error(`Duplicate commands: '${a.fullPath_s}' and '${o.fullPath_s}'`);
302
307
  this._commands.push(o);
303
308
  }
304
309
  /**
@@ -322,19 +327,19 @@ class Q {
322
327
  const t = n.fullPath.join(" "), o = e.join(" ");
323
328
  if (t === o)
324
329
  return !0;
325
- const a = n.segments.filter((l) => l.type === "word").map((l) => l.name);
326
- return a.length === e.length && a.join(" ") === o;
330
+ const i = n.segments.filter((c) => c.type === "word").map((c) => c.name);
331
+ return i.length === e.length && i.join(" ") === o;
327
332
  });
328
333
  }
329
334
  commandExistsForPath(e) {
330
335
  const n = this._commands.map(
331
336
  (o) => o.segments.map(
332
- (s) => s.type === "argument" ? "*" : s.name
337
+ (a) => a.type === "argument" ? "*" : a.name
333
338
  ).join(" ")
334
- ), t = e.map((o, s) => this._commands.some(
335
- (l) => {
336
- var d;
337
- return ((d = l.segments[s]) == null ? void 0 : d.type) === "argument";
339
+ ), t = e.map((o, a) => this._commands.some(
340
+ (c) => {
341
+ var s;
342
+ return ((s = c.segments[a]) == null ? void 0 : s.type) === "argument";
338
343
  }
339
344
  ) ? "*" : o).join(" ");
340
345
  return n.includes(t);
@@ -345,8 +350,7 @@ class Q {
345
350
  * @param path The path to get completions for.
346
351
  * @returns An array of completion strings.
347
352
  */
348
- // used by AvailableCommands
349
- getCompletions_s(e) {
353
+ getCompletionNames(e) {
350
354
  return this.getCompletions(e).map((n) => n.name);
351
355
  }
352
356
  /**
@@ -356,29 +360,29 @@ class Q {
356
360
  * @returns An array of completion strings.
357
361
  */
358
362
  getCompletions(e) {
359
- if (E.debug("[getCompletions] path: ", e), !e.length) {
360
- const s = this._commands.map((d) => d.segments[0]), a = (d, c) => d.type === c.type && d.name === c.name;
361
- return s.filter(
362
- (d, c, u) => c === u.findIndex((h) => a(h, d))
363
+ if (C.debug("[getCompletions] path: ", e), !e.length) {
364
+ const a = this._commands.map((s) => s.segments[0]), i = (s, l) => s.type === l.type && s.name === l.name;
365
+ return a.filter(
366
+ (s, l, h) => l === h.findIndex((p) => i(p, s))
363
367
  );
364
368
  }
365
369
  const n = e.length;
366
- return this._commands.filter((s) => {
367
- const a = s.segments;
368
- if (a.length <= n - 1)
370
+ return this._commands.filter((a) => {
371
+ const i = a.segments;
372
+ if (i.length <= n - 1)
369
373
  return !1;
370
- for (let l = 0; l < n; l++) {
371
- const d = e[l], c = a[l];
372
- if (!(d === "*" && c.type === "argument") && d !== c.name)
374
+ for (let c = 0; c < n; c++) {
375
+ const s = e[c], l = i[c];
376
+ if (!(s === "*" && l.type === "argument") && s !== l.name)
373
377
  return !1;
374
378
  }
375
379
  return !0;
376
- }).filter((s) => s.segments.length > n).map((s) => {
377
- const a = s.segments[n], l = a.type === "argument" ? _e : Ne;
378
- return new l(a.name, a.description);
380
+ }).filter((a) => a.segments.length > n).map((a) => {
381
+ const i = a.segments[n], c = i.type === "argument" ? W : ze;
382
+ return new c(i.name, i.description);
379
383
  }).filter(
380
- (s, a, l) => a === l.findIndex(
381
- (d) => d.type === s.type && d.name === s.name
384
+ (a, i, c) => i === c.findIndex(
385
+ (s) => s.type === a.type && s.name === a.name
382
386
  )
383
387
  );
384
388
  }
@@ -386,11 +390,11 @@ class Q {
386
390
  return this.getCompletions(e).length > 0;
387
391
  }
388
392
  }
389
- class de {
393
+ class he {
390
394
  constructor() {
391
- y(this, "segments", []);
392
- y(this, "nullSegment", new ce());
393
- y(this, "observers", []);
395
+ b(this, "segments", []);
396
+ b(this, "nullSegment", new ue());
397
+ b(this, "observers", []);
394
398
  }
395
399
  subscribe(e) {
396
400
  this.observers.push(e);
@@ -473,153 +477,167 @@ class de {
473
477
  return [...this.segments];
474
478
  }
475
479
  }
476
- const ze = {
477
- config: z,
478
- commands: new Q(),
479
- segmentStack: new de()
480
- }, j = be(ze), Ie = ({ config: r = z, commandRegistry: e, children: n }) => {
481
- const [t, o] = L.useState(), s = {
482
- ...z,
480
+ const Re = {
481
+ config: _,
482
+ commands: new Z(),
483
+ segmentStack: new he()
484
+ }, L = Ce(Re), Pe = ({ config: r = _, commandRegistry: e, children: n }) => {
485
+ const [t, o] = O.useState(), [a] = R(() => new he()), i = {
486
+ ..._,
483
487
  ...r,
484
488
  // Ensure nested objects are properly merged
485
489
  storage: {
486
- ...z.storage,
490
+ ..._.storage,
487
491
  ...r.storage
488
492
  },
489
493
  // Ensure explicit values from config take precedence
490
- cursorType: r.cursorType ?? z.cursorType,
491
- cursorColor: r.cursorColor ?? z.cursorColor,
492
- cursorSpeed: r.cursorSpeed ?? z.cursorSpeed,
494
+ cursorType: r.cursorType ?? _.cursorType,
495
+ cursorColor: r.cursorColor ?? _.cursorColor,
496
+ cursorSpeed: r.cursorSpeed ?? _.cursorSpeed,
493
497
  showCitadelKey: r.showCitadelKey || "."
494
498
  };
495
499
  A(() => {
496
500
  q.getInstance().initializeStorage(
497
- s.storage ?? z.storage
501
+ i.storage ?? _.storage
498
502
  ), o(q.getInstance().getStorage());
499
503
  }, []), A(() => {
500
504
  if (e) {
501
- if (s.includeHelpCommand) {
505
+ if (i.includeHelpCommand) {
502
506
  if (!e.commandExistsForPath(["help"])) {
503
- const l = Se(e);
507
+ const s = _e(e);
504
508
  e.addCommand(
505
509
  [{ type: "word", name: "help" }],
506
510
  "Show available commands",
507
- l
511
+ s
508
512
  );
509
513
  }
510
514
  return;
511
515
  }
512
516
  e.removeCommand(["help"]);
513
517
  }
514
- }, [e, s.includeHelpCommand]);
515
- const a = {
516
- config: s,
517
- commands: e || new Q(),
518
+ }, [e, i.includeHelpCommand]);
519
+ const c = D(() => ({
520
+ config: i,
521
+ commands: e || new Z(),
518
522
  storage: t,
519
- segmentStack: new de()
520
- };
521
- return /* @__PURE__ */ m(j.Provider, { value: a, children: n });
522
- }, F = () => {
523
- const r = Y(j);
523
+ segmentStack: a
524
+ }), [i, e, t, a]);
525
+ return /* @__PURE__ */ m(L.Provider, { value: c, children: n });
526
+ }, $ = () => {
527
+ const r = Y(L);
524
528
  if (r === void 0)
525
529
  throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
526
530
  return r.config;
527
531
  }, B = () => {
528
- const r = Y(j);
532
+ const r = Y(L);
529
533
  if (r === void 0)
530
534
  throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
531
535
  return r.commands;
532
- }, me = () => {
533
- const r = Y(j);
536
+ }, pe = () => {
537
+ const r = Y(L);
534
538
  if (r === void 0)
535
539
  throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
536
540
  return r.storage;
537
- }, O = () => {
538
- const r = Y(j);
541
+ }, K = () => {
542
+ const r = Y(L);
539
543
  if (r === void 0)
540
544
  throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
541
545
  return r.segmentStack;
542
- };
543
- class Re {
546
+ }, V = class V {
544
547
  constructor(e, n) {
545
- y(this, "timestamp");
546
- y(this, "command");
547
- y(this, "result");
548
- this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new Ce();
548
+ b(this, "id");
549
+ b(this, "timestamp");
550
+ b(this, "command");
551
+ b(this, "result");
552
+ this.id = `output-${Date.now()}-${V.idCounter++}`, this.command = e.toArray().map((t) => t.type === "argument" ? t.value || "" : t.name), this.timestamp = Date.now(), this.result = n ?? new Ee();
549
553
  }
550
- }
554
+ };
555
+ b(V, "idCounter", 0);
556
+ let J = V;
551
557
  function He(r) {
552
558
  return {
553
559
  commandSegments: r,
554
560
  timestamp: Date.now()
555
561
  };
556
562
  }
557
- function ue() {
558
- const r = me(), [e, n] = R({
563
+ function ge() {
564
+ const r = pe(), [e, n] = R({
559
565
  storedCommands: [],
560
566
  position: null
561
- }), t = b(async (l) => {
567
+ }), t = y(async (c) => {
562
568
  if (r)
563
569
  try {
564
- const d = He(l);
565
- await r.addStoredCommand(d), n((c) => ({
566
- ...c,
567
- storedCommands: [...c.storedCommands, d],
570
+ const s = He(c);
571
+ await r.addStoredCommand(s), n((l) => ({
572
+ ...l,
573
+ storedCommands: [...l.storedCommands, s],
568
574
  position: null
569
575
  }));
570
- } catch (d) {
571
- console.warn("Failed to save command to history:", d);
576
+ } catch (s) {
577
+ console.warn("Failed to save command to history:", s);
572
578
  }
573
- }, [r]), o = b(async () => r ? await r.getStoredCommands() : [], [r]);
579
+ }, [r]), o = y(async () => r ? await r.getStoredCommands() : [], [r]);
574
580
  A(() => {
575
581
  if (!r) return;
576
582
  (async () => {
577
583
  try {
578
- const d = await r.getStoredCommands();
579
- return n((c) => ({
580
- ...c,
581
- storedCommands: d
582
- })), d;
583
- } catch (d) {
584
- console.warn("Failed to load command history:", d);
584
+ const s = await r.getStoredCommands();
585
+ return n((l) => ({
586
+ ...l,
587
+ storedCommands: s
588
+ })), s;
589
+ } catch (s) {
590
+ console.warn("Failed to load command history:", s);
585
591
  }
586
592
  })();
587
593
  }, [r]);
588
- const s = b(async (l) => {
589
- if ((await o()).length === 0)
590
- return { segments: null, position: null };
591
- let c = null;
592
- return l === "up" ? e.position === null ? c = e.storedCommands.length - 1 : e.position > 0 ? c = e.position - 1 : c = 0 : e.position === null || e.position >= e.storedCommands.length - 1 ? c = null : c = e.position + 1, n((h) => ({
593
- ...h,
594
- position: c
595
- })), c === null ? {
594
+ const a = y(async (c) => {
595
+ const s = await o();
596
+ if (s.length === 0)
597
+ return n((p) => ({
598
+ ...p,
599
+ storedCommands: [],
600
+ position: null
601
+ })), { segments: null, position: null };
602
+ let l = null;
603
+ if (c === "up" ? e.position === null ? l = s.length - 1 : e.position > 0 ? l = e.position - 1 : l = 0 : e.position === null || e.position >= s.length - 1 ? l = null : l = e.position + 1, n((p) => ({
604
+ ...p,
605
+ storedCommands: s,
606
+ position: l
607
+ })), l === null)
608
+ return {
609
+ segments: [],
610
+ position: null
611
+ };
612
+ const h = s[l];
613
+ return h ? {
614
+ segments: h.commandSegments,
615
+ position: l
616
+ } : {
596
617
  segments: [],
597
618
  position: null
598
- } : {
599
- segments: c !== null ? e.storedCommands[c].commandSegments : null,
600
- position: c
601
619
  };
602
- }, [e, o]), a = b(async () => {
620
+ }, [e.position, o]), i = y(async () => {
603
621
  try {
604
622
  if (!r) return;
605
623
  await r.clear(), n({
606
624
  storedCommands: [],
607
625
  position: null
608
626
  });
609
- } catch (l) {
610
- console.warn("Failed to clear command history:", l);
627
+ } catch (c) {
628
+ console.warn("Failed to clear command history:", c);
611
629
  }
612
630
  }, [r]);
613
631
  return {
614
632
  history: e,
615
633
  addStoredCommand: t,
616
634
  getStoredCommands: o,
617
- navigateHistory: s,
618
- clear: a
635
+ navigateHistory: a,
636
+ clear: i
619
637
  };
620
638
  }
621
- const X = () => {
622
- const r = F(), e = B(), n = ue(), t = O(), o = me(), [s, a] = R({
639
+ const ee = () => {
640
+ const r = $(), e = B(), n = ge(), t = K(), o = pe(), [a, i] = R({
623
641
  currentInput: "",
624
642
  isEnteringArg: !1,
625
643
  output: [],
@@ -631,8 +649,8 @@ const X = () => {
631
649
  });
632
650
  A(() => {
633
651
  }, [o]), A(() => {
634
- a((u) => ({
635
- ...u,
652
+ i((s) => ({
653
+ ...s,
636
654
  history: {
637
655
  commands: n.history.storedCommands,
638
656
  position: n.history.position,
@@ -640,105 +658,100 @@ const X = () => {
640
658
  }
641
659
  }));
642
660
  }, [n.history, o]);
643
- const l = {
644
- setCurrentInput: b((u) => {
645
- E.debug("[CitadelActions] setCurrentInput: ", u), a((h) => ({ ...h, currentInput: u }));
661
+ const c = {
662
+ setCurrentInput: y((s) => {
663
+ C.debug("[CitadelActions] setCurrentInput: ", s), i((l) => ({ ...l, currentInput: s }));
646
664
  }, []),
647
- setIsEnteringArg: b((u) => {
648
- E.debug("[CitadelActions] setIsEnteringArg: ", u), a((h) => ({ ...h, isEnteringArg: u }));
665
+ setIsEnteringArg: y((s) => {
666
+ C.debug("[CitadelActions] setIsEnteringArg: ", s), i((l) => ({ ...l, isEnteringArg: s }));
649
667
  }, []),
650
- addOutput: b((u) => {
651
- E.debug("[CitadelActions]addOutput: ", u), a((h) => ({
652
- ...h,
653
- output: [...h.output, u]
668
+ addOutput: y((s) => {
669
+ C.debug("[CitadelActions]addOutput: ", s), i((l) => ({
670
+ ...l,
671
+ output: [...l.output, s]
654
672
  }));
655
673
  }, []),
656
- executeCommand: b(async () => {
657
- const u = t.path(), h = e.getCommand(u);
658
- if (!h) {
659
- console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", u);
674
+ executeCommand: y(async () => {
675
+ const s = t.path(), l = e.getCommand(s);
676
+ if (!l) {
677
+ console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", s);
660
678
  return;
661
679
  }
662
- const C = new Re(t);
663
- a((f) => ({
664
- ...f,
665
- output: [...f.output, C]
680
+ const h = new J(t);
681
+ i((p) => ({
682
+ ...p,
683
+ output: [...p.output, h]
666
684
  }));
667
685
  try {
668
- const f = new Promise((i, p) => {
686
+ const p = new Promise((u, k) => {
669
687
  setTimeout(() => {
670
- p(new Error("Request timed out"));
688
+ k(new Error("Request timed out"));
671
689
  }, r.commandTimeoutMs);
672
- }), x = t.arguments.map((i) => i.value || ""), k = await Promise.race([
673
- h.handler(x),
674
- f
690
+ }), S = t.arguments.map((u) => u.value || ""), v = await Promise.race([
691
+ l.handler(S),
692
+ p
675
693
  ]);
676
- if (!(k instanceof U))
694
+ if (!(v instanceof T))
677
695
  throw new Error(
678
- `The ${u.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
696
+ `The ${s.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
679
697
  For example:
680
698
  return new JsonCommandResult({ text: "Hello World" });
681
- Check the definition of the ${u.join(".")} command and update the return type for its handler.`
699
+ Check the definition of the ${s.join(".")} command and update the return type for its handler.`
682
700
  );
683
- k.markSuccess(), a((i) => ({
684
- ...i,
685
- output: i.output.map(
686
- (p) => p.timestamp === C.timestamp ? { ...p, result: k } : p
701
+ v.markSuccess(), i((u) => ({
702
+ ...u,
703
+ output: u.output.map(
704
+ (k) => k.id === h.id ? { ...k, result: v } : k
687
705
  )
688
706
  }));
689
- } catch (f) {
690
- const x = new ve(
691
- f instanceof Error ? f.message : "Unknown error"
707
+ } catch (p) {
708
+ const S = new Ne(
709
+ p instanceof Error ? p.message : "Unknown error"
692
710
  );
693
- x.markFailure(), a((k) => ({
694
- ...k,
695
- output: k.output.map(
696
- (i) => i.timestamp === C.timestamp ? { ...i, result: x } : i
711
+ S.markFailure(), i((v) => ({
712
+ ...v,
713
+ output: v.output.map(
714
+ (u) => u.id === h.id ? { ...u, result: S } : u
697
715
  )
698
716
  }));
699
717
  }
700
718
  }, [e, r.commandTimeoutMs, t]),
701
- clearHistory: b(async () => {
719
+ clearHistory: y(async () => {
702
720
  try {
703
721
  await n.clear();
704
- } catch (u) {
705
- console.warn("Failed to clear history:", u);
722
+ } catch (s) {
723
+ console.warn("Failed to clear history:", s);
706
724
  }
707
725
  }, [n])
708
- }, d = b(() => e.getCompletions_s(t.path()), [t, e]), c = b(() => e.getCompletions(t.path()), [t, e]);
709
- return {
710
- state: s,
711
- actions: l,
712
- getAvailableCommands_s: d,
713
- getAvailableCommandSegments: c
714
726
  };
715
- }, Pe = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
727
+ return { state: a, actions: c };
728
+ }, Me = ({ onOpen: r, onClose: e, isVisible: n, showCitadelKey: t }) => {
716
729
  A(() => {
717
- const o = (s) => {
718
- var a, l;
719
- !n && s.key === t && !["input", "textarea"].includes(((l = (a = s.target) == null ? void 0 : a.tagName) == null ? void 0 : l.toLowerCase()) || "") && (s.preventDefault(), r()), n && s.key === "Escape" && (s.preventDefault(), e());
730
+ const o = (a) => {
731
+ var i, c;
732
+ !n && a.key === t && !["input", "textarea"].includes(((c = (i = a.target) == null ? void 0 : i.tagName) == null ? void 0 : c.toLowerCase()) || "") && (a.preventDefault(), r()), n && a.key === "Escape" && (a.preventDefault(), e());
720
733
  };
721
734
  return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
722
735
  }, [r, e, n, t]);
723
- }, De = "_panelContainer_1pav9_3", Me = "_innerContainer_1pav9_19", Ue = "_inputSection_1pav9_29", Fe = "_resizeHandle_1pav9_36", Te = "_citadel_slideUp_1pav9_65", je = "_citadel_slideDown_1pav9_69", Oe = "_inlineContainer_1pav9_73", Z = {
736
+ }, De = "_panelContainer_1pav9_3", Te = "_innerContainer_1pav9_19", Ue = "_inputSection_1pav9_29", je = "_resizeHandle_1pav9_36", Fe = "_citadel_slideUp_1pav9_65", Oe = "_citadel_slideDown_1pav9_69", Le = "_inlineContainer_1pav9_73", re = {
724
737
  panelContainer: De,
725
- innerContainer: Me,
738
+ innerContainer: Te,
726
739
  inputSection: Ue,
727
- resizeHandle: Fe,
728
- citadel_slideUp: Te,
729
- citadel_slideDown: je,
730
- inlineContainer: Oe
740
+ resizeHandle: je,
741
+ citadel_slideUp: Fe,
742
+ citadel_slideDown: Oe,
743
+ inlineContainer: Le
731
744
  }, $e = (r) => {
732
- const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o = V(() => e ? n ? Z.slideDown : Z.slideUp : "", [e, n]);
745
+ const { isVisible: e, isClosing: n, onAnimationComplete: t } = r, o = D(() => e ? n ? re.slideDown : re.slideUp : "", [e, n]);
733
746
  return A(() => {
734
747
  if (t) {
735
- const a = setTimeout(() => {
748
+ const i = setTimeout(() => {
736
749
  t();
737
750
  }, 200);
738
- return () => clearTimeout(a);
751
+ return () => clearTimeout(i);
739
752
  }
740
753
  }, [n, t]), {
741
- style: V(() => ({
754
+ style: D(() => ({
742
755
  opacity: e ? 1 : 0,
743
756
  transform: e ? "translateY(0)" : n ? "translateY(100%)" : "translateY(-100%)",
744
757
  transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
@@ -751,19 +764,19 @@ Check the definition of the ${u.join(".")} command and update the return type fo
751
764
  "data-testid": "spinner",
752
765
  className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
753
766
  }
754
- ), Le = ({
767
+ ), We = ({
755
768
  command: r,
756
769
  timestamp: e,
757
770
  status: n
758
- }) => /* @__PURE__ */ _("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
759
- /* @__PURE__ */ _("span", { className: "text-gray-200", children: [
771
+ }) => /* @__PURE__ */ N("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
772
+ /* @__PURE__ */ N("span", { className: "text-gray-200", children: [
760
773
  "> ",
761
774
  r.split(" ").map((t, o) => {
762
- const s = t.startsWith("<") && t.endsWith(">");
763
- return /* @__PURE__ */ _(
775
+ const a = t.startsWith("<") && t.endsWith(">");
776
+ return /* @__PURE__ */ N(
764
777
  "span",
765
778
  {
766
- className: s ? "text-green-400" : "text-gray-200",
779
+ className: a ? "text-green-400" : "text-gray-200",
767
780
  children: [
768
781
  o > 0 ? " " : "",
769
782
  t
@@ -775,23 +788,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
775
788
  ] }),
776
789
  /* @__PURE__ */ m("span", { className: "text-gray-400", children: "·" }),
777
790
  /* @__PURE__ */ m("span", { className: "text-gray-500", children: e }),
778
- n === T.Pending && /* @__PURE__ */ m(Ke, {}),
779
- n === T.Success && /* @__PURE__ */ m(
791
+ n === F.Pending && /* @__PURE__ */ m(Ke, {}),
792
+ n === F.Success && /* @__PURE__ */ m(
780
793
  "div",
781
794
  {
782
795
  "data-testid": "success-indicator",
783
796
  className: "w-4 h-4 rounded-full bg-green-500"
784
797
  }
785
798
  ),
786
- (n === T.Timeout || n === T.Failure) && /* @__PURE__ */ m(
799
+ (n === F.Timeout || n === F.Failure) && /* @__PURE__ */ m(
787
800
  "div",
788
801
  {
789
802
  "data-testid": "success-indicator",
790
803
  className: "w-4 h-4 rounded-full bg-red-500"
791
804
  }
792
805
  )
793
- ] }), Ve = ({ output: r, outputRef: e }) => {
794
- const n = F(), t = b(() => {
806
+ ] }), qe = ({ output: r, outputRef: e }) => {
807
+ const n = $(), t = y(() => {
795
808
  if (e.current) {
796
809
  const o = e.current;
797
810
  requestAnimationFrame(() => {
@@ -801,9 +814,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
801
814
  }, [e]);
802
815
  return A(() => {
803
816
  if (t(), e.current) {
804
- const o = e.current.getElementsByTagName("img"), s = o[o.length - 1];
805
- if (s && !s.complete)
806
- return s.addEventListener("load", t), () => s.removeEventListener("load", t);
817
+ const o = e.current.getElementsByTagName("img"), a = o[o.length - 1];
818
+ if (a && !a.complete)
819
+ return a.addEventListener("load", t), () => a.removeEventListener("load", t);
807
820
  }
808
821
  }, [r, t, e]), /* @__PURE__ */ m(
809
822
  "div",
@@ -811,9 +824,9 @@ Check the definition of the ${u.join(".")} command and update the return type fo
811
824
  ref: e,
812
825
  className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
813
826
  "data-testid": "citadel-command-output",
814
- children: r.map((o, s) => /* @__PURE__ */ _("div", { className: "mb-4 last:mb-0", children: [
827
+ children: r.map((o) => /* @__PURE__ */ N("div", { className: "mb-4 last:mb-0", children: [
815
828
  /* @__PURE__ */ m(
816
- Le,
829
+ We,
817
830
  {
818
831
  command: o.command.join(" "),
819
832
  timestamp: new Date(o.timestamp).toLocaleTimeString(),
@@ -821,10 +834,10 @@ Check the definition of the ${u.join(".")} command and update the return type fo
821
834
  }
822
835
  ),
823
836
  /* @__PURE__ */ m("pre", { className: `text-gray-200 whitespace-pre font-mono ${n.outputFontSize}`, children: o.result.render() })
824
- ] }, s))
837
+ ] }, o.id))
825
838
  }
826
839
  );
827
- }, We = {
840
+ }, Ve = {
828
841
  blink: {
829
842
  character: "▋",
830
843
  speed: 530,
@@ -845,23 +858,23 @@ Check the definition of the ${u.join(".")} command and update the return type fo
845
858
  speed: 120,
846
859
  color: "#fff"
847
860
  }
848
- }, ee = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], ne = ["|", "/", "-", "\\"], qe = ({
861
+ }, oe = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], se = ["|", "/", "-", "\\"], Ye = ({
849
862
  style: r = { type: "blink" },
850
863
  isValid: e = !0,
851
864
  errorMessage: n
852
865
  }) => {
853
- const t = V(() => ({
854
- ...We[r.type],
866
+ const t = D(() => ({
867
+ ...Ve[r.type],
855
868
  ...r
856
- }), [r]), [o, s] = R(!0), [a, l] = R(0);
869
+ }), [r]), [o, a] = R(!0), [i, c] = R(0);
857
870
  A(() => {
858
871
  if (t.speed === 0) return;
859
- const u = setInterval(() => {
860
- t.type === "blink" ? s((h) => !h) : ["spin", "bbs"].includes(t.type) && l((h) => (h + 1) % (t.type === "bbs" ? ne.length : ee.length));
872
+ const h = setInterval(() => {
873
+ t.type === "blink" ? a((p) => !p) : ["spin", "bbs"].includes(t.type) && c((p) => (p + 1) % (t.type === "bbs" ? se.length : oe.length));
861
874
  }, t.speed);
862
- return () => clearInterval(u);
875
+ return () => clearInterval(h);
863
876
  }, [t.type, t.speed]);
864
- const d = V(() => ({
877
+ const s = D(() => ({
865
878
  color: e ? t.color : "#ff4444",
866
879
  transition: "color 0.15s ease-in-out"
867
880
  }), [e, t.color]);
@@ -869,148 +882,144 @@ Check the definition of the ${u.join(".")} command and update the return type fo
869
882
  "span",
870
883
  {
871
884
  className: `command-cursor ${e ? "" : "animate-shake"}`,
872
- style: d,
885
+ style: s,
873
886
  title: n,
874
- children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ? ne : ee)[a] : t.type === "solid" || o ? t.character : " "
887
+ children: !e && n ? "✗" : ["spin", "bbs"].includes(t.type) ? (t.type === "bbs" ? se : oe)[i] : t.type === "solid" || o ? t.character : " "
875
888
  }
876
889
  ) });
877
890
  };
878
- function Ye(r, e) {
891
+ function Be(r, e) {
879
892
  switch (e.type) {
880
893
  case "set":
881
- return E.debug(`[inputStateReducer] InputState changing from ${r} to ${e.state}`), e.state;
894
+ return C.debug(`[inputStateReducer] InputState changing from ${r} to ${e.state}`), e.state;
882
895
  default:
883
896
  return r;
884
897
  }
885
898
  }
886
- const Be = () => {
887
- const { state: r } = X(), e = B(), n = ue(), t = O(), [o, s] = ye(Ye, "idle"), a = (i) => {
888
- s({ type: "set", state: i });
889
- }, l = b(() => {
890
- const p = e.getCompletions(t.path())[0] || t.nullSegment;
891
- return E.debug("[getNextExpectedSegment] ", p), p;
892
- }, [e, t]), d = b(() => e.getCompletions_s(t.path()).map((p) => e.getCommand([...t.path(), p])).filter((p) => p !== void 0), [e, t]), c = b((i, p) => {
893
- if (!i) return p;
894
- const g = p.reduce((w, v) => {
895
- const S = l();
896
- return (S == null ? void 0 : S.type) === "word" && w.set(S.name, v), w;
897
- }, /* @__PURE__ */ new Map());
898
- return Array.from(g.values()).filter(() => {
899
- const w = l();
900
- return w.type !== "word" ? !1 : w.name.toLowerCase().startsWith(i.toLowerCase());
899
+ const Ge = () => {
900
+ const { state: r } = ee(), e = B(), n = ge(), t = K(), [o, a] = Se(Be, "idle"), i = (d) => {
901
+ a({ type: "set", state: d });
902
+ }, c = y(() => {
903
+ const f = e.getCompletions(t.path())[0] || t.nullSegment;
904
+ return C.debug("[getNextExpectedSegment] ", f), f;
905
+ }, [e, t]), s = y(() => e.getCompletionNames(t.path()).map((f) => e.getCommand([...t.path(), f])).filter((f) => f !== void 0), [e, t]), l = y((d, f) => {
906
+ if (!d) return f;
907
+ const w = t.path().length;
908
+ return f.filter((x) => {
909
+ const g = x.segments[w];
910
+ return !g || g.type !== "word" ? !1 : g.name.toLowerCase().startsWith(d.toLowerCase());
901
911
  });
902
- }, [l]), u = b((i) => {
903
- const g = e.getCompletions(t.path()).filter((N) => N.type === "word").filter(
904
- (N) => N.name.toLowerCase().startsWith(i.toLowerCase())
912
+ }, [t]), h = y((d) => {
913
+ const w = e.getCompletions(t.path()).filter((x) => x.type === "word").filter(
914
+ (x) => x.name.toLowerCase().startsWith(d.toLowerCase())
905
915
  );
906
- return g.length === 1 ? g[0] : t.nullSegment;
907
- }, [e, t]), h = b((i) => {
908
- const p = t.path(), g = e.getCompletions(p);
909
- return g.length === 0 && i ? !1 : g.some((w) => w.type === "argument") ? !0 : g.some(
910
- (w) => w.type === "word" && w.name.toLowerCase().startsWith(i.toLowerCase())
916
+ return w.length === 1 ? w[0] : t.nullSegment;
917
+ }, [e, t]), p = y((d) => {
918
+ const f = t.path(), w = e.getCompletions(f);
919
+ return w.length === 0 && d ? !1 : w.some((g) => g.type === "argument") ? !0 : w.some(
920
+ (g) => g.type === "word" && g.name.toLowerCase().startsWith(d.toLowerCase())
911
921
  );
912
- }, [e, t]), C = b((i) => {
913
- E.debug("[tryAutoComplete] input: ", i);
914
- const p = u(i);
915
- return !p || p.name === i ? new ce() : (E.debug("[tryAutoComplete] result: ", p), p);
916
- }, [u]), f = b((i, p) => {
922
+ }, [e, t]), S = y((d) => {
923
+ C.debug("[tryAutoComplete] input: ", d);
924
+ const f = h(d);
925
+ return !f || f.name === d ? new ue() : (C.debug("[tryAutoComplete] result: ", f), f);
926
+ }, [h]), v = y((d, f) => {
917
927
  if (r.history.position === null) {
918
- if (p.setCurrentInput(i), E.debug("[useCommandParser][handleInputChange] newValue: ", i), o === "entering_argument") {
919
- const g = te(i);
920
- if (g.isQuoted)
921
- if (g.isComplete) {
922
- const N = l();
923
- if (N.type === "argument") {
924
- const w = N;
925
- w.value = i.trim() || "", E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), t.push(w), p.setCurrentInput(""), a("idle");
926
- return;
927
- }
928
+ if (f.setCurrentInput(d), C.debug("[useCommandParser][handleInputChange] newValue: ", d), o === "entering_argument") {
929
+ const w = ae(d);
930
+ if (w.isQuoted)
931
+ if (w.isComplete) {
932
+ const x = c();
933
+ if (!(x instanceof W)) return;
934
+ x.value = d.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", x), t.push(x), f.setCurrentInput(""), i("idle");
935
+ return;
928
936
  } else
929
937
  return;
930
- else if (g.isComplete) {
931
- const N = l();
932
- N.value = i.trim() || "", E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", N), t.push(N), p.setCurrentInput(""), a("idle");
938
+ else if (w.isComplete) {
939
+ const x = c();
940
+ if (!(x instanceof W)) return;
941
+ x.value = d.trim() || "", C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", x), t.push(x), f.setCurrentInput(""), i("idle");
933
942
  return;
934
943
  } else
935
944
  return;
936
945
  }
937
- if (o == "entering_command") {
938
- const g = C(i);
939
- if (g.type === "word") {
940
- E.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", g), t.push(g), p.setCurrentInput(""), a("idle");
946
+ if (o === "entering_command") {
947
+ const w = S(d);
948
+ if (w.type === "word") {
949
+ C.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", w), t.push(w), f.setCurrentInput(""), i("idle");
941
950
  return;
942
951
  }
943
952
  }
944
953
  }
945
- }, [C, r, l, o, t]), x = b((i) => {
946
- i.setCurrentInput(""), i.setIsEnteringArg(!1), t.clear(), a("idle");
947
- }, [t]), k = b((i, p, g) => {
948
- if (!(i.key === "Backspace" || i.key === "Enter" || i.key === "ArrowUp" || i.key === "ArrowDown" || i.key === "ArrowLeft" || i.key === "ArrowRight" || i.key === "Escape" || i.key === "Delete" || i.key === "Home" || i.key === "End" || i.key.length === 1))
954
+ }, [S, r, c, o, t]), u = y((d) => {
955
+ d.setCurrentInput(""), d.setIsEnteringArg(!1), t.clear(), i("idle");
956
+ }, [t]), k = y((d, f, w) => {
957
+ if (!(d.key === "Backspace" || d.key === "Enter" || d.key === "ArrowUp" || d.key === "ArrowDown" || d.key === "ArrowLeft" || d.key === "ArrowRight" || d.key === "Escape" || d.key === "Delete" || d.key === "Home" || d.key === "End" || d.key.length === 1))
949
958
  return !0;
950
- const { currentInput: w, isEnteringArg: v } = p, S = te(w);
951
- switch (i.key) {
959
+ const { currentInput: g, isEnteringArg: E } = f, I = ae(g);
960
+ switch (d.key) {
952
961
  case "Backspace":
953
- return w === "" && (i.preventDefault(), t.size() > 0 && t.pop(), a("idle")), !0;
962
+ return g === "" && (d.preventDefault(), t.size() > 0 && t.pop(), i("idle")), !0;
954
963
  case "Enter": {
955
- if (i.preventDefault(), S.isQuoted && !S.isComplete)
964
+ if (d.preventDefault(), I.isQuoted && !I.isComplete)
956
965
  return !0;
957
- if (o === "entering_argument" || v && w.trim()) {
958
- const G = l();
959
- G.value = w, E.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", G), t.push(G);
966
+ if (o === "entering_argument" || E && g.trim()) {
967
+ const M = c();
968
+ M instanceof W && (M.value = g, C.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", M), t.push(M));
960
969
  }
961
- const I = t.path(), H = e.getCommand(I);
962
- if (!H)
970
+ const z = t.path(), U = e.getCommand(z);
971
+ if (!U)
963
972
  return !1;
964
- const $ = H.segments.filter((M) => M.type === "argument"), K = t.arguments;
965
- return $.length > K.length ? !1 : (E.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", t), g.executeCommand(), n.addStoredCommand(t.toArray()), x(g), !0);
973
+ const j = U.segments.filter((M) => M.type === "argument"), be = t.arguments;
974
+ return j.length > be.length ? !1 : (C.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", t), w.executeCommand(), n.addStoredCommand(t.toArray()), u(w), !0);
966
975
  }
967
976
  case "ArrowUp":
968
- return i.preventDefault(), (async () => {
969
- const I = await n.navigateHistory("up", t.toArray());
970
- return I.segments && (t.clear(), t.pushAll(I.segments), g.setCurrentInput("")), !0;
977
+ return d.preventDefault(), (async () => {
978
+ const z = await n.navigateHistory("up");
979
+ return z.segments && (t.clear(), t.pushAll(z.segments), w.setCurrentInput("")), !0;
971
980
  })();
972
981
  case "ArrowDown":
973
- return i.preventDefault(), (async () => {
974
- const I = await n.navigateHistory("down", t.toArray());
975
- return I.segments && (t.clear(), t.pushAll(I.segments), g.setCurrentInput("")), !0;
982
+ return d.preventDefault(), (async () => {
983
+ const z = await n.navigateHistory("down");
984
+ return z.segments && (t.clear(), t.pushAll(z.segments), w.setCurrentInput("")), !0;
976
985
  })();
977
986
  default: {
978
- if (!v && i.key.length === 1) {
979
- const I = w + i.key;
980
- if (!h(I))
981
- return i.preventDefault(), !1;
987
+ if (!E && d.key.length === 1) {
988
+ const z = g + d.key;
989
+ if (!p(z))
990
+ return d.preventDefault(), !1;
982
991
  }
983
992
  return !0;
984
993
  }
985
994
  }
986
995
  }, [
987
996
  o,
988
- h,
989
- l,
997
+ p,
998
+ c,
990
999
  n,
991
- x,
1000
+ u,
992
1001
  e,
993
1002
  t
994
1003
  ]);
995
1004
  return {
996
- handleInputChange: f,
1005
+ handleInputChange: v,
997
1006
  handleKeyDown: k,
998
1007
  inputState: o,
999
- setInputStateWithLogging: a,
1008
+ setInputStateWithLogging: i,
1000
1009
  // Expose internal functions for testing
1001
- findMatchingCommands: c,
1002
- getAutocompleteSuggestion: u,
1003
- getAvailableNodes: d,
1004
- getNextExpectedSegment: l,
1005
- isValidCommandInput: h
1010
+ findMatchingCommands: l,
1011
+ getAutocompleteSuggestion: h,
1012
+ getAvailableNodes: s,
1013
+ getNextExpectedSegment: c,
1014
+ isValidCommandInput: p
1006
1015
  };
1007
1016
  };
1008
- function te(r) {
1017
+ function ae(r) {
1009
1018
  const e = [];
1010
1019
  let n = "", t = !1, o;
1011
- for (let s = 0; s < r.length; s++) {
1012
- const a = r[s];
1013
- (a === '"' || a === "'") && (!t || a === o) ? t ? (e.push(n), n = "", t = !1, o = void 0) : (n && (e.push(n), n = ""), t = !0, o = a) : !t && a === " " ? n && (e.push(n), n = "") : n += a;
1020
+ for (let a = 0; a < r.length; a++) {
1021
+ const i = r[a];
1022
+ (i === '"' || i === "'") && (!t || i === o) ? t ? (e.push(n), n = "", t = !1, o = void 0) : (n && (e.push(n), n = ""), t = !0, o = i) : !t && i === " " ? n && (e.push(n), n = "") : n += i;
1014
1023
  }
1015
1024
  return {
1016
1025
  words: e,
@@ -1020,8 +1029,8 @@ function te(r) {
1020
1029
  isComplete: !t && !n
1021
1030
  };
1022
1031
  }
1023
- const Ge = () => {
1024
- const r = O(), [e, n] = R(0);
1032
+ const Je = () => {
1033
+ const r = K(), [e, n] = R(0);
1025
1034
  return A(() => {
1026
1035
  const t = {
1027
1036
  update: () => {
@@ -1032,66 +1041,64 @@ const Ge = () => {
1032
1041
  r.unsubscribe(t);
1033
1042
  };
1034
1043
  }, [r]), e;
1035
- }, Je = ({
1044
+ }, Qe = ({
1036
1045
  state: r,
1037
1046
  actions: e
1038
1047
  }) => {
1039
- const n = P(null), t = B(), o = O(), {
1040
- handleKeyDown: s,
1041
- handleInputChange: a,
1042
- inputState: l,
1043
- setInputStateWithLogging: d,
1044
- getNextExpectedSegment: c
1045
- } = Be(), [u, h] = R(!1), C = F(), f = Ge(), x = async (v) => {
1046
- const S = s(v, r, e);
1047
- await Promise.resolve(S) === !1 && (h(!0), setTimeout(() => h(!1), 500));
1048
- }, k = (v) => {
1049
- a(v.target.value, e);
1050
- }, i = (v) => {
1051
- v.preventDefault();
1052
- const S = v.clipboardData.getData("text");
1053
- a(S, e);
1048
+ const n = H(null), t = B(), o = K(), {
1049
+ handleKeyDown: a,
1050
+ handleInputChange: i,
1051
+ inputState: c,
1052
+ setInputStateWithLogging: s,
1053
+ getNextExpectedSegment: l
1054
+ } = Ge(), [h, p] = R(!1), S = $(), v = Je(), u = async (g) => {
1055
+ const E = a(g, r, e);
1056
+ await Promise.resolve(E) === !1 && (p(!0), setTimeout(() => p(!1), 500));
1057
+ }, k = (g) => {
1058
+ i(g.target.value, e);
1059
+ }, d = (g) => {
1060
+ g.preventDefault();
1061
+ const E = g.clipboardData.getData("text");
1062
+ i(E, e);
1054
1063
  };
1055
1064
  A(() => {
1056
- n.current && n.current.focus(), l !== "entering_command" && d("entering_command");
1057
- }, [l, d]), A(() => {
1058
- if (l !== "idle") return;
1059
- const v = c();
1060
- let S = "idle";
1061
- switch (v.type) {
1065
+ n.current && n.current.focus(), c !== "entering_command" && s("entering_command");
1066
+ }, [c, s]), A(() => {
1067
+ if (c !== "idle") return;
1068
+ const g = l();
1069
+ let E = "idle";
1070
+ switch (g.type) {
1062
1071
  case "word":
1063
- S = "entering_command", e.setIsEnteringArg(!1);
1072
+ E = "entering_command", e.setIsEnteringArg(!1);
1064
1073
  break;
1065
1074
  case "argument":
1066
- S = "entering_argument", e.setIsEnteringArg(!0);
1075
+ E = "entering_argument", e.setIsEnteringArg(!0);
1067
1076
  break;
1068
1077
  }
1069
- d(S);
1070
- }, [f, l, c, d, e]);
1071
- const [p, g] = R([]);
1072
- A(() => {
1073
- const v = [], S = o.toArray().map((H, $) => {
1074
- v.push(H.name);
1075
- const K = t.hasNextSegment(v);
1076
- if (H.type === "argument") {
1077
- const M = H;
1078
- return /* @__PURE__ */ _(L.Fragment, { children: [
1079
- /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: M.value }),
1080
- $ < o.size() && K && /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: " " })
1081
- ] }, "arg-" + M.name + M.value);
1078
+ s(E);
1079
+ }, [v, c, l, s, e]);
1080
+ const f = D(() => {
1081
+ const g = [], E = o.toArray().map((I, z) => {
1082
+ g.push(I.name);
1083
+ const U = t.hasNextSegment(g);
1084
+ if (I.type === "argument") {
1085
+ const j = I;
1086
+ return /* @__PURE__ */ N(O.Fragment, { children: [
1087
+ /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: j.value }),
1088
+ z < o.size() && U && /* @__PURE__ */ m("span", { className: "text-gray-200 whitespace-pre", children: " " })
1089
+ ] }, "arg-" + j.name + j.value);
1082
1090
  }
1083
- return /* @__PURE__ */ _(L.Fragment, { children: [
1084
- /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: H.name }),
1085
- $ < o.size() && K && /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: " " })
1086
- ] }, "word-" + H.name);
1091
+ return /* @__PURE__ */ N(O.Fragment, { children: [
1092
+ /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: I.name }),
1093
+ z < o.size() && U && /* @__PURE__ */ m("span", { className: "text-blue-400 whitespace-pre", children: " " })
1094
+ ] }, "word-" + I.name);
1087
1095
  });
1088
- g([/* @__PURE__ */ m("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: S }, "{segmentStackVersion}")]);
1089
- }, [f, t, o]);
1090
- const [N, w] = R("");
1096
+ return [/* @__PURE__ */ m("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: E }, "{segmentStackVersion}")];
1097
+ }, [v, t, o]), [w, x] = R("");
1091
1098
  return A(() => {
1092
- const v = c();
1093
- v.type === "argument" ? w(v.name) : w("");
1094
- }, [f, c]), /* @__PURE__ */ _("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: [
1099
+ const g = l();
1100
+ g.type === "argument" ? x(g.name) : x("");
1101
+ }, [v, l]), /* @__PURE__ */ N("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: [
1095
1102
  /* @__PURE__ */ m("style", { children: `
1096
1103
  @keyframes subtleGlow {
1097
1104
  0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
@@ -1101,11 +1108,11 @@ const Ge = () => {
1101
1108
  animation: subtleGlow 0.4s ease-in-out;
1102
1109
  }
1103
1110
  ` }),
1104
- /* @__PURE__ */ _("div", { className: "flex items-center gap-2", children: [
1111
+ /* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
1105
1112
  /* @__PURE__ */ m("div", { className: "text-gray-400 font-mono", children: ">" }),
1106
- /* @__PURE__ */ _("div", { className: "flex-1 font-mono flex items-center", children: [
1107
- p,
1108
- /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
1113
+ /* @__PURE__ */ N("div", { className: "flex-1 font-mono flex items-center", children: [
1114
+ f,
1115
+ /* @__PURE__ */ N("div", { className: "relative flex-1", children: [
1109
1116
  /* @__PURE__ */ m(
1110
1117
  "input",
1111
1118
  {
@@ -1114,13 +1121,13 @@ const Ge = () => {
1114
1121
  role: "textbox",
1115
1122
  value: r.currentInput,
1116
1123
  onChange: k,
1117
- onKeyDown: x,
1118
- onPaste: i,
1124
+ onKeyDown: u,
1125
+ onPaste: d,
1119
1126
  "data-testid": "citadel-command-input",
1120
- className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${u ? "invalid-input-animation" : ""}`,
1127
+ className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${h ? "invalid-input-animation" : ""}`,
1121
1128
  spellCheck: !1,
1122
1129
  autoComplete: "off",
1123
- placeholder: N
1130
+ placeholder: w
1124
1131
  }
1125
1132
  ),
1126
1133
  /* @__PURE__ */ m(
@@ -1132,12 +1139,12 @@ const Ge = () => {
1132
1139
  transition: "left 0.05s ease-out"
1133
1140
  },
1134
1141
  children: /* @__PURE__ */ m(
1135
- qe,
1142
+ Ye,
1136
1143
  {
1137
1144
  style: {
1138
- type: C.cursorType ?? z.cursorType,
1139
- color: C.cursorColor || z.cursorColor,
1140
- speed: C.cursorSpeed || z.cursorSpeed
1145
+ type: S.cursorType ?? _.cursorType,
1146
+ color: S.cursorColor || _.cursorColor,
1147
+ speed: S.cursorSpeed || _.cursorSpeed
1141
1148
  }
1142
1149
  }
1143
1150
  )
@@ -1147,116 +1154,120 @@ const Ge = () => {
1147
1154
  ] })
1148
1155
  ] })
1149
1156
  ] });
1150
- }, Qe = () => {
1151
- const r = B(), e = F(), n = O(), t = "mt-2 border-t border-gray-700 px-4 py-2", o = "text-gray-300", s = r.getCompletions(n.path());
1152
- E.debug("[AvailableCommands] nextCommandSegments: ", s);
1153
- const a = L.useMemo(() => {
1154
- const c = [...s], u = (x) => x.name.toLowerCase() === "help", C = c.filter((x) => !u(x)).sort(
1155
- (x, k) => x.name.localeCompare(k.name, void 0, { sensitivity: "base" })
1156
- );
1157
- if (!e.includeHelpCommand)
1158
- return C;
1159
- const f = c.find(u);
1160
- return f ? [...C, f] : C;
1161
- }, [s, e.includeHelpCommand]), l = s.some((c) => c.type === "argument"), d = s[0];
1162
- return /* @__PURE__ */ m("div", { className: t, "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: o, children: l ? s.length > 0 ? /* @__PURE__ */ _(we, { children: [
1163
- /* @__PURE__ */ m("span", { className: "text-blue-400", children: d.name }),
1164
- d.description && /* @__PURE__ */ _("span", { className: "text-gray-400 ml-2", children: [
1157
+ }, Xe = () => {
1158
+ const r = B(), e = K(), n = "mt-2 border-t border-gray-700 px-4 py-2", t = "text-gray-300", o = r.getCompletions(e.path());
1159
+ C.debug("[AvailableCommands] nextCommandSegments: ", o);
1160
+ const a = O.useMemo(() => {
1161
+ const l = [...o], h = (u) => u.name.toLowerCase() === "help", p = l.filter(h);
1162
+ return [...l.filter((u) => !h(u)).sort(
1163
+ (u, k) => u.name.localeCompare(k.name, void 0, { sensitivity: "base" })
1164
+ ), ...p];
1165
+ }, [o]), i = O.useMemo(() => {
1166
+ const l = /* @__PURE__ */ new Map();
1167
+ for (const h of a) {
1168
+ const p = a.reduce((S, v) => {
1169
+ if (v === h) return S;
1170
+ let u = 0;
1171
+ for (; u < h.name.length && u < v.name.length && h.name[u].toLowerCase() === v.name[u].toLowerCase(); )
1172
+ u++;
1173
+ return Math.max(S, u + 1);
1174
+ }, 1);
1175
+ l.set(h.name, p);
1176
+ }
1177
+ return l;
1178
+ }, [a]), c = o.some((l) => l.type === "argument"), s = o[0];
1179
+ return /* @__PURE__ */ m("div", { className: n, "data-testid": "available-commands", children: /* @__PURE__ */ m("div", { className: t, children: c ? o.length > 0 ? /* @__PURE__ */ N(ve, { children: [
1180
+ /* @__PURE__ */ m("span", { className: "text-blue-400", children: s.name }),
1181
+ s.description && /* @__PURE__ */ N("span", { className: "text-gray-400 ml-2", children: [
1165
1182
  "- ",
1166
- d.description
1183
+ s.description
1167
1184
  ] })
1168
- ] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((c) => {
1169
- const u = a == null ? void 0 : a.reduce((h, C) => {
1170
- if (C === c) return h;
1171
- let f = 0;
1172
- for (; f < c.name.length && f < C.name.length && c.name[f].toLowerCase() === C.name[f].toLowerCase(); )
1173
- f++;
1174
- return Math.max(h, f + 1);
1175
- }, 1);
1185
+ ] }) : null : /* @__PURE__ */ m("div", { className: "flex flex-wrap gap-2", children: a == null ? void 0 : a.map((l) => {
1186
+ const h = i.get(l.name) ?? 1;
1176
1187
  return /* @__PURE__ */ m(
1177
1188
  "div",
1178
1189
  {
1179
1190
  className: "px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",
1180
- children: /* @__PURE__ */ _("span", { className: "font-mono text-white", children: [
1181
- /* @__PURE__ */ m("strong", { className: "underline", children: c.name.slice(0, u) }),
1182
- c.name.slice(u)
1191
+ children: /* @__PURE__ */ N("span", { className: "font-mono text-white", children: [
1192
+ /* @__PURE__ */ m("strong", { className: "underline", children: l.name.slice(0, h) }),
1193
+ l.name.slice(h)
1183
1194
  ] })
1184
1195
  },
1185
- c.name
1196
+ l.name
1186
1197
  );
1187
1198
  }) }) }) });
1188
- }, pe = ({
1199
+ }, fe = ({
1189
1200
  state: r,
1190
1201
  actions: e,
1191
1202
  outputRef: n
1192
- }) => /* @__PURE__ */ _("div", { className: "innerContainer", children: [
1193
- /* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(Ve, { output: r.output, outputRef: n }) }),
1194
- /* @__PURE__ */ _("div", { children: [
1195
- /* @__PURE__ */ m(Je, { state: r, actions: e }),
1196
- /* @__PURE__ */ m(Qe, {})
1203
+ }) => /* @__PURE__ */ N("div", { className: "innerContainer", children: [
1204
+ /* @__PURE__ */ m("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m(qe, { output: r.output, outputRef: n }) }),
1205
+ /* @__PURE__ */ N("div", { children: [
1206
+ /* @__PURE__ */ m(Qe, { state: r, actions: e }),
1207
+ /* @__PURE__ */ m(Xe, {})
1197
1208
  ] })
1198
- ] }), Xe = () => {
1199
- const [r, e] = R(!1), [n, t] = R(!1), o = F(), [s, a] = R(() => o.initialHeight || null), l = P(null), d = P(null), c = P(!1), u = P(0), h = P(0), { state: C, actions: f } = X();
1200
- Pe({
1209
+ ] }), Ze = () => {
1210
+ const [r, e] = R(!1), [n, t] = R(!1), o = $(), [a, i] = R(() => o.initialHeight || null), c = H(null), s = H(null), l = H(!1), h = H(0), p = H(0), { state: S, actions: v } = ee();
1211
+ Me({
1201
1212
  onOpen: () => e(!0),
1202
1213
  onClose: () => t(!0),
1203
1214
  isVisible: r,
1204
1215
  showCitadelKey: o.showCitadelKey || "."
1205
1216
  });
1206
- const x = b((g) => {
1207
- var S;
1208
- if (!c.current) return;
1209
- const N = g.clientY - u.current, w = (S = o.maxHeight) != null && S.endsWith("vh") ? window.innerHeight * parseInt(o.maxHeight, 10) / 100 : parseInt(o.maxHeight || "80vh", 10), v = Math.min(
1210
- Math.max(h.current - N, parseInt(o.minHeight || "200", 10)),
1211
- w
1217
+ const u = y((w) => {
1218
+ var I;
1219
+ if (!l.current) return;
1220
+ const x = w.clientY - h.current, g = (I = o.maxHeight) != null && I.endsWith("vh") ? window.innerHeight * parseInt(o.maxHeight, 10) / 100 : parseInt(o.maxHeight || "80vh", 10), E = Math.min(
1221
+ Math.max(p.current - x, parseInt(o.minHeight || "200", 10)),
1222
+ g
1212
1223
  );
1213
- d.current && (d.current.style.height = `${v}px`, d.current.style.bottom = "0", a(`${v}px`));
1214
- }, [o.maxHeight, o.minHeight]), k = b(() => {
1215
- c.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", k);
1216
- }, [x]), i = b((g) => {
1217
- d.current && (c.current = !0, u.current = g.clientY, h.current = d.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", x), document.addEventListener("mouseup", k));
1218
- }, [x, k]);
1224
+ s.current && (s.current.style.height = `${E}px`, s.current.style.bottom = "0", i(`${E}px`));
1225
+ }, [o.maxHeight, o.minHeight]), k = y(() => {
1226
+ l.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", k);
1227
+ }, [u]), d = y((w) => {
1228
+ s.current && (l.current = !0, h.current = w.clientY, p.current = s.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mousemove", u), document.addEventListener("mouseup", k));
1229
+ }, [u, k]);
1219
1230
  A(() => () => {
1220
- document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", k);
1221
- }, [x, k]);
1222
- const p = b(() => {
1231
+ document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", k);
1232
+ }, [u, k]);
1233
+ const f = y(() => {
1223
1234
  n && (e(!1), t(!1));
1224
1235
  }, [n]);
1225
1236
  return $e({
1226
1237
  isVisible: r,
1227
1238
  isClosing: n,
1228
- onAnimationComplete: p
1229
- }), r ? /* @__PURE__ */ _(
1239
+ onAnimationComplete: f
1240
+ }), r ? /* @__PURE__ */ N(
1230
1241
  "div",
1231
1242
  {
1232
- ref: d,
1243
+ ref: s,
1233
1244
  className: `panelContainer ${r ? "citadel_slideUp" : ""} ${n ? "citadel_slideDown" : ""}`,
1234
1245
  style: {
1235
- ...s ? { height: s } : void 0,
1246
+ ...a ? { height: a } : void 0,
1236
1247
  maxHeight: o.maxHeight
1237
1248
  },
1238
1249
  children: [
1239
- /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: i }),
1250
+ /* @__PURE__ */ m("div", { className: "resizeHandle", onMouseDown: d }),
1240
1251
  /* @__PURE__ */ m(
1241
- pe,
1252
+ fe,
1242
1253
  {
1243
- state: C,
1244
- actions: f,
1245
- outputRef: l
1254
+ state: S,
1255
+ actions: v,
1256
+ outputRef: c
1246
1257
  }
1247
1258
  )
1248
1259
  ]
1249
1260
  }
1250
1261
  ) : null;
1251
- }, Ze = () => {
1252
- const { state: r, actions: e } = X(), n = P(null);
1262
+ }, en = () => {
1263
+ const { state: r, actions: e } = ee(), n = H(null);
1253
1264
  return /* @__PURE__ */ m(
1254
1265
  "div",
1255
1266
  {
1256
1267
  className: "inlineContainer",
1257
1268
  "data-testid": "citadel-inline-container",
1258
1269
  children: /* @__PURE__ */ m(
1259
- pe,
1270
+ fe,
1260
1271
  {
1261
1272
  state: r,
1262
1273
  actions: e,
@@ -1265,7 +1276,7 @@ const Ge = () => {
1265
1276
  )
1266
1277
  }
1267
1278
  );
1268
- }, re = `:host {
1279
+ }, ie = `:host {
1269
1280
  --citadel-bg: rgb(17, 24, 39);
1270
1281
  --citadel-text: rgba(255, 255, 255, 0.87);
1271
1282
  --citadel-border: rgb(55, 65, 81);
@@ -1369,7 +1380,7 @@ a:hover {
1369
1380
  .text-left {
1370
1381
  text-align: left;
1371
1382
  }
1372
- `, oe = `/* Keep only component-specific styles here */
1383
+ `, le = `/* Keep only component-specific styles here */
1373
1384
 
1374
1385
  .panelContainer {
1375
1386
  position: fixed;
@@ -1451,10 +1462,10 @@ a:hover {
1451
1462
  overflow: hidden;
1452
1463
  box-sizing: border-box;
1453
1464
  }
1454
- `, se = `@tailwind base;
1465
+ `, ce = `@tailwind base;
1455
1466
  @tailwind components;
1456
1467
  @tailwind utilities;
1457
- `, en = `*, ::before, ::after {
1468
+ `, nn = `*, ::before, ::after {
1458
1469
  --tw-border-spacing-x: 0;
1459
1470
  --tw-border-spacing-y: 0;
1460
1471
  --tw-translate-x: 0;
@@ -2271,75 +2282,85 @@ video {
2271
2282
  .last\\:mr-0:last-child {
2272
2283
  margin-right: 0px;
2273
2284
  }
2274
- `, cn = ({
2275
- config: r = z,
2276
- commandRegistry: e = new Q(),
2285
+ `, dn = ({
2286
+ config: r = _,
2287
+ commandRegistry: e = new Z(),
2277
2288
  containerId: n = null
2278
2289
  }) => {
2279
- const t = P(null), o = r.displayMode ?? z.displayMode ?? "panel";
2290
+ const t = H(null), o = r.displayMode ?? _.displayMode ?? "panel";
2280
2291
  return A(() => {
2281
- E.configure({
2282
- level: r.logLevel || z.logLevel || W.ERROR,
2292
+ C.configure({
2293
+ level: r.logLevel || _.logLevel || Q.ERROR,
2283
2294
  prefix: "[Citadel]"
2284
2295
  });
2285
- const s = new he(e, r), a = o === "inline" && !n, l = a ? t.current : n ? document.getElementById(n) : document.body;
2286
- if (l)
2287
- l.appendChild(s);
2296
+ const a = new we(e, r), i = o === "inline" && !n, c = i ? t.current : n ? document.getElementById(n) : document.body;
2297
+ if (c)
2298
+ c.appendChild(a);
2288
2299
  else {
2289
- if (a) {
2300
+ if (i) {
2290
2301
  console.warn("[Citadel] No host available for inline mode; skipping mount.");
2291
2302
  return;
2292
2303
  }
2293
- console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(s);
2304
+ console.warn(`Container with id "${n}" not found, falling back to body`), document.body.appendChild(a);
2294
2305
  }
2295
2306
  return () => {
2296
- var d;
2297
- (d = s.parentElement) == null || d.removeChild(s);
2307
+ var s;
2308
+ (s = a.parentElement) == null || s.removeChild(a);
2298
2309
  };
2299
2310
  }, [e, n, r, o]), o === "inline" && !n ? /* @__PURE__ */ m("div", { ref: t, style: { width: "100%", height: "100%" } }) : null;
2300
2311
  };
2301
- class he extends HTMLElement {
2312
+ class we extends HTMLElement {
2302
2313
  constructor(n, t) {
2303
- var s;
2314
+ var a;
2304
2315
  super();
2305
- y(this, "shadow");
2306
- y(this, "root", null);
2307
- y(this, "commandRegistry");
2308
- y(this, "config");
2316
+ b(this, "shadow");
2317
+ b(this, "root", null);
2318
+ b(this, "commandRegistry");
2319
+ b(this, "config");
2309
2320
  this.shadow = this.attachShadow({ mode: "open" }), this.commandRegistry = n, this.config = t;
2310
- const o = ((s = this.config) == null ? void 0 : s.displayMode) ?? "panel";
2321
+ const o = ((a = this.config) == null ? void 0 : a.displayMode) ?? "panel";
2311
2322
  this.setAttribute("data-display-mode", o);
2312
2323
  }
2313
2324
  connectedCallback() {
2314
2325
  try {
2315
- const t = [re, oe, se, en].map((o) => {
2316
- const s = new CSSStyleSheet();
2317
- return s.replaceSync(o), s;
2326
+ const t = [ie, le, ce, nn].map((o) => {
2327
+ const a = new CSSStyleSheet();
2328
+ return a.replaceSync(o), a;
2318
2329
  });
2319
2330
  this.shadow.adoptedStyleSheets = [...t];
2320
2331
  } catch {
2321
- const t = [re, oe, se].join(`
2332
+ const t = [ie, le, ce].join(`
2322
2333
  `), o = document.createElement("style");
2323
2334
  o.textContent = t, this.shadow.appendChild(o);
2324
2335
  }
2325
2336
  const n = document.createElement("div");
2326
- n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = xe(n), this.root.render(
2327
- /* @__PURE__ */ m(Ie, { config: this.config || z, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(nn, {}) })
2337
+ n.id = "citadel-root", n.style.width = "100%", n.style.height = "100%", this.shadow.appendChild(n), this.root = ke(n), this.root.render(
2338
+ /* @__PURE__ */ m(Pe, { config: this.config || _, commandRegistry: this.commandRegistry, children: /* @__PURE__ */ m(tn, {}) })
2328
2339
  );
2329
2340
  }
2341
+ disconnectedCallback() {
2342
+ const n = this.root;
2343
+ if (this.root = null, !n) {
2344
+ this.shadow.replaceChildren();
2345
+ return;
2346
+ }
2347
+ queueMicrotask(() => {
2348
+ n.unmount(), this.shadow.replaceChildren();
2349
+ });
2350
+ }
2330
2351
  }
2331
- customElements.define("citadel-element", he);
2332
- const nn = () => (F().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(Ze, {}) : /* @__PURE__ */ m(Xe, {});
2352
+ typeof window < "u" && window.customElements && !window.customElements.get("citadel-element") && window.customElements.define("citadel-element", we);
2353
+ const tn = () => ($().displayMode ?? "panel") === "inline" ? /* @__PURE__ */ m(en, {}) : /* @__PURE__ */ m(Ze, {});
2333
2354
  export {
2334
- cn as Citadel,
2335
- Q as CommandRegistry,
2336
- U as CommandResult,
2337
- T as CommandStatus,
2338
- We as DEFAULT_CURSOR_CONFIGS,
2339
- ve as ErrorCommandResult,
2340
- ln as ImageCommandResult,
2341
- an as JsonCommandResult,
2342
- Re as OutputItem,
2343
- Ce as PendingCommandResult,
2344
- ae as TextCommandResult
2355
+ dn as Citadel,
2356
+ Z as CommandRegistry,
2357
+ T as CommandResult,
2358
+ F as CommandStatus,
2359
+ Ve as DEFAULT_CURSOR_CONFIGS,
2360
+ Ne as ErrorCommandResult,
2361
+ cn as ImageCommandResult,
2362
+ ln as JsonCommandResult,
2363
+ J as OutputItem,
2364
+ Ee as PendingCommandResult,
2365
+ G as TextCommandResult
2345
2366
  };