citadel_cli 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -207
- package/dist/citadel.es.js +1289 -1449
- package/dist/citadel.umd.js +19 -19
- package/dist/command_examples/basic-commands.d.ts +2 -83
- package/dist/src/__test-utils__/factories.d.ts +29 -10
- package/dist/src/components/Citadel/Citadel.d.ts +11 -7
- package/dist/src/components/Citadel/components/AvailableCommands.d.ts +1 -8
- package/dist/src/components/Citadel/components/CommandInput.d.ts +0 -2
- package/dist/src/components/Citadel/config/CitadelConfigContext.d.ts +5 -2
- package/dist/src/components/Citadel/config/defaults.d.ts +15 -7
- package/dist/src/components/Citadel/config/types.d.ts +32 -20
- package/dist/src/components/Citadel/hooks/useCitadelState.d.ts +2 -1
- package/dist/src/components/Citadel/hooks/useCommandHistory.d.ts +19 -9
- package/dist/src/components/Citadel/hooks/useCommandParser.d.ts +18 -15
- package/dist/src/components/Citadel/hooks/useSegmentStack.d.ts +14 -0
- package/dist/src/components/Citadel/hooks/useSegmentStackVersion.d.ts +1 -0
- package/dist/src/components/Citadel/storage/BaseStorage.d.ts +2 -2
- package/dist/src/components/Citadel/storage/LocalStorage.d.ts +1 -1
- package/dist/src/components/Citadel/storage/MemoryStorage.d.ts +2 -2
- package/dist/src/components/Citadel/types/__tests__/command-registry.test.d.ts +1 -0
- package/dist/src/components/Citadel/types/__tests__/segment-stack.test.d.ts +1 -0
- package/dist/src/components/Citadel/types/command-registry.d.ts +84 -0
- package/dist/src/components/Citadel/types/command-trie.d.ts +49 -203
- package/dist/src/components/Citadel/types/help-command.d.ts +3 -3
- package/dist/src/components/Citadel/types/segment-stack.d.ts +62 -0
- package/dist/src/components/Citadel/types/state.d.ts +8 -22
- package/dist/src/components/Citadel/types/storage.d.ts +4 -3
- package/dist/src/components/Citadel/utils/logger.d.ts +21 -0
- package/dist/src/index.d.ts +0 -1
- package/package.json +3 -3
package/dist/citadel.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
var
|
|
1
|
+
var Qn = Object.defineProperty;
|
|
2
|
+
var Zn = (o, n, t) => n in o ? Qn(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
|
|
3
|
+
var j = (o, n, t) => Zn(o, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import Z, { useEffect as I, useMemo as be, createContext as et, useContext as ve, useState as Y, useCallback as A, useReducer as nt, useRef as Q } from "react";
|
|
5
|
+
import tt from "react-dom";
|
|
6
|
+
var Te = { exports: {} }, ae = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.min.js
|
|
@@ -13,21 +13,21 @@ var Se = { exports: {} }, re = {};
|
|
|
13
13
|
* This source code is licensed under the MIT license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
function
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
for (
|
|
25
|
-
if (d && d.defaultProps) for (
|
|
26
|
-
return { $$typeof: n, type: d, key:
|
|
27
|
-
}
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
var
|
|
16
|
+
var on;
|
|
17
|
+
function rt() {
|
|
18
|
+
if (on) return ae;
|
|
19
|
+
on = 1;
|
|
20
|
+
var o = Z, n = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
21
|
+
function p(d, u, f) {
|
|
22
|
+
var w, g = {}, v = null, O = null;
|
|
23
|
+
f !== void 0 && (v = "" + f), u.key !== void 0 && (v = "" + u.key), u.ref !== void 0 && (O = u.ref);
|
|
24
|
+
for (w in u) r.call(u, w) && !s.hasOwnProperty(w) && (g[w] = u[w]);
|
|
25
|
+
if (d && d.defaultProps) for (w in u = d.defaultProps, u) g[w] === void 0 && (g[w] = u[w]);
|
|
26
|
+
return { $$typeof: n, type: d, key: v, ref: O, props: g, _owner: i.current };
|
|
27
|
+
}
|
|
28
|
+
return ae.Fragment = t, ae.jsx = p, ae.jsxs = p, ae;
|
|
29
|
+
}
|
|
30
|
+
var se = {};
|
|
31
31
|
/**
|
|
32
32
|
* @license React
|
|
33
33
|
* react-jsx-runtime.development.js
|
|
@@ -37,91 +37,91 @@ var oe = {};
|
|
|
37
37
|
* This source code is licensed under the MIT license found in the
|
|
38
38
|
* LICENSE file in the root directory of this source tree.
|
|
39
39
|
*/
|
|
40
|
-
var
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
var
|
|
44
|
-
function
|
|
40
|
+
var an;
|
|
41
|
+
function ot() {
|
|
42
|
+
return an || (an = 1, process.env.NODE_ENV !== "production" && function() {
|
|
43
|
+
var o = Z, n = Symbol.for("react.element"), t = Symbol.for("react.portal"), r = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), p = Symbol.for("react.provider"), d = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), O = Symbol.for("react.offscreen"), k = Symbol.iterator, D = "@@iterator";
|
|
44
|
+
function U(e) {
|
|
45
45
|
if (e === null || typeof e != "object")
|
|
46
46
|
return null;
|
|
47
|
-
var
|
|
48
|
-
return typeof
|
|
47
|
+
var a = k && e[k] || e[D];
|
|
48
|
+
return typeof a == "function" ? a : null;
|
|
49
49
|
}
|
|
50
|
-
var
|
|
51
|
-
function
|
|
50
|
+
var c = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
51
|
+
function h(e) {
|
|
52
52
|
{
|
|
53
|
-
for (var
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
for (var a = arguments.length, l = new Array(a > 1 ? a - 1 : 0), b = 1; b < a; b++)
|
|
54
|
+
l[b - 1] = arguments[b];
|
|
55
|
+
E("error", e, l);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function E(e, a, l) {
|
|
59
59
|
{
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
var
|
|
63
|
-
return String(
|
|
60
|
+
var b = c.ReactDebugCurrentFrame, S = b.getStackAddendum();
|
|
61
|
+
S !== "" && (a += "%s", l = l.concat([S]));
|
|
62
|
+
var _ = l.map(function(C) {
|
|
63
|
+
return String(C);
|
|
64
64
|
});
|
|
65
|
-
|
|
65
|
+
_.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, _);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
function
|
|
71
|
-
return !!(typeof e == "string" || typeof e == "function" || e ===
|
|
68
|
+
var x = !1, R = !1, V = !1, z = !1, H = !1, K;
|
|
69
|
+
K = Symbol.for("react.module.reference");
|
|
70
|
+
function ne(e) {
|
|
71
|
+
return !!(typeof e == "string" || typeof e == "function" || e === r || e === s || H || e === i || e === f || e === w || z || e === O || x || R || V || typeof e == "object" && e !== null && (e.$$typeof === v || e.$$typeof === g || e.$$typeof === p || e.$$typeof === d || e.$$typeof === u || // This needs to include all possible module reference object
|
|
72
72
|
// types supported by any Flight configuration anywhere since
|
|
73
73
|
// we don't know which Flight build this will end up being used
|
|
74
74
|
// with.
|
|
75
|
-
e.$$typeof ===
|
|
75
|
+
e.$$typeof === K || e.getModuleId !== void 0));
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
var
|
|
79
|
-
if (
|
|
80
|
-
return
|
|
81
|
-
var
|
|
82
|
-
return
|
|
77
|
+
function _n(e, a, l) {
|
|
78
|
+
var b = e.displayName;
|
|
79
|
+
if (b)
|
|
80
|
+
return b;
|
|
81
|
+
var S = a.displayName || a.name || "";
|
|
82
|
+
return S !== "" ? l + "(" + S + ")" : l;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function De(e) {
|
|
85
85
|
return e.displayName || "Context";
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function L(e) {
|
|
88
88
|
if (e == null)
|
|
89
89
|
return null;
|
|
90
|
-
if (typeof e.tag == "number" &&
|
|
90
|
+
if (typeof e.tag == "number" && h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
91
91
|
return e.displayName || e.name || null;
|
|
92
92
|
if (typeof e == "string")
|
|
93
93
|
return e;
|
|
94
94
|
switch (e) {
|
|
95
|
-
case
|
|
95
|
+
case r:
|
|
96
96
|
return "Fragment";
|
|
97
97
|
case t:
|
|
98
98
|
return "Portal";
|
|
99
|
-
case
|
|
99
|
+
case s:
|
|
100
100
|
return "Profiler";
|
|
101
101
|
case i:
|
|
102
102
|
return "StrictMode";
|
|
103
|
-
case
|
|
103
|
+
case f:
|
|
104
104
|
return "Suspense";
|
|
105
|
-
case
|
|
105
|
+
case w:
|
|
106
106
|
return "SuspenseList";
|
|
107
107
|
}
|
|
108
108
|
if (typeof e == "object")
|
|
109
109
|
switch (e.$$typeof) {
|
|
110
110
|
case d:
|
|
111
|
-
var
|
|
112
|
-
return
|
|
113
|
-
case l:
|
|
114
|
-
var c = e;
|
|
115
|
-
return Te(c._context) + ".Provider";
|
|
116
|
-
case h:
|
|
117
|
-
return gn(e, e.render, "ForwardRef");
|
|
111
|
+
var a = e;
|
|
112
|
+
return De(a) + ".Consumer";
|
|
118
113
|
case p:
|
|
119
|
-
var
|
|
120
|
-
return
|
|
121
|
-
case u:
|
|
122
|
-
|
|
114
|
+
var l = e;
|
|
115
|
+
return De(l._context) + ".Provider";
|
|
116
|
+
case u:
|
|
117
|
+
return _n(e, e.render, "ForwardRef");
|
|
118
|
+
case g:
|
|
119
|
+
var b = e.displayName || null;
|
|
120
|
+
return b !== null ? b : L(e.type) || "Memo";
|
|
121
|
+
case v: {
|
|
122
|
+
var S = e, _ = S._payload, C = S._init;
|
|
123
123
|
try {
|
|
124
|
-
return
|
|
124
|
+
return L(C(_));
|
|
125
125
|
} catch {
|
|
126
126
|
return null;
|
|
127
127
|
}
|
|
@@ -129,18 +129,18 @@ function Jn() {
|
|
|
129
129
|
}
|
|
130
130
|
return null;
|
|
131
131
|
}
|
|
132
|
-
var
|
|
133
|
-
function
|
|
132
|
+
var B = Object.assign, te = 0, ze, Fe, Ue, $e, Me, He, We;
|
|
133
|
+
function Ye() {
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
function
|
|
135
|
+
Ye.__reactDisabledLog = !0;
|
|
136
|
+
function En() {
|
|
137
137
|
{
|
|
138
|
-
if (
|
|
139
|
-
|
|
138
|
+
if (te === 0) {
|
|
139
|
+
ze = console.log, Fe = console.info, Ue = console.warn, $e = console.error, Me = console.group, He = console.groupCollapsed, We = console.groupEnd;
|
|
140
140
|
var e = {
|
|
141
141
|
configurable: !0,
|
|
142
142
|
enumerable: !0,
|
|
143
|
-
value:
|
|
143
|
+
value: Ye,
|
|
144
144
|
writable: !0
|
|
145
145
|
};
|
|
146
146
|
Object.defineProperties(console, {
|
|
@@ -153,336 +153,336 @@ function Jn() {
|
|
|
153
153
|
groupEnd: e
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
te++;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function kn() {
|
|
160
160
|
{
|
|
161
|
-
if (
|
|
161
|
+
if (te--, te === 0) {
|
|
162
162
|
var e = {
|
|
163
163
|
configurable: !0,
|
|
164
164
|
enumerable: !0,
|
|
165
165
|
writable: !0
|
|
166
166
|
};
|
|
167
167
|
Object.defineProperties(console, {
|
|
168
|
-
log:
|
|
169
|
-
value:
|
|
168
|
+
log: B({}, e, {
|
|
169
|
+
value: ze
|
|
170
170
|
}),
|
|
171
|
-
info:
|
|
172
|
-
value:
|
|
171
|
+
info: B({}, e, {
|
|
172
|
+
value: Fe
|
|
173
173
|
}),
|
|
174
|
-
warn:
|
|
175
|
-
value:
|
|
174
|
+
warn: B({}, e, {
|
|
175
|
+
value: Ue
|
|
176
176
|
}),
|
|
177
|
-
error:
|
|
178
|
-
value:
|
|
177
|
+
error: B({}, e, {
|
|
178
|
+
value: $e
|
|
179
179
|
}),
|
|
180
|
-
group:
|
|
181
|
-
value:
|
|
180
|
+
group: B({}, e, {
|
|
181
|
+
value: Me
|
|
182
182
|
}),
|
|
183
|
-
groupCollapsed:
|
|
184
|
-
value:
|
|
183
|
+
groupCollapsed: B({}, e, {
|
|
184
|
+
value: He
|
|
185
185
|
}),
|
|
186
|
-
groupEnd:
|
|
187
|
-
value:
|
|
186
|
+
groupEnd: B({}, e, {
|
|
187
|
+
value: We
|
|
188
188
|
})
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
te < 0 && h("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
var
|
|
195
|
-
function
|
|
194
|
+
var Ce = c.ReactCurrentDispatcher, Se;
|
|
195
|
+
function me(e, a, l) {
|
|
196
196
|
{
|
|
197
|
-
if (
|
|
197
|
+
if (Se === void 0)
|
|
198
198
|
try {
|
|
199
199
|
throw Error();
|
|
200
|
-
} catch (
|
|
201
|
-
var
|
|
202
|
-
|
|
200
|
+
} catch (S) {
|
|
201
|
+
var b = S.stack.trim().match(/\n( *(at )?)/);
|
|
202
|
+
Se = b && b[1] || "";
|
|
203
203
|
}
|
|
204
204
|
return `
|
|
205
|
-
` +
|
|
205
|
+
` + Se + e;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
var
|
|
208
|
+
var _e = !1, pe;
|
|
209
209
|
{
|
|
210
|
-
var
|
|
211
|
-
|
|
210
|
+
var Rn = typeof WeakMap == "function" ? WeakMap : Map;
|
|
211
|
+
pe = new Rn();
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
if (!e ||
|
|
213
|
+
function Le(e, a) {
|
|
214
|
+
if (!e || _e)
|
|
215
215
|
return "";
|
|
216
216
|
{
|
|
217
|
-
var
|
|
218
|
-
if (
|
|
219
|
-
return
|
|
217
|
+
var l = pe.get(e);
|
|
218
|
+
if (l !== void 0)
|
|
219
|
+
return l;
|
|
220
220
|
}
|
|
221
|
-
var
|
|
222
|
-
|
|
223
|
-
var
|
|
221
|
+
var b;
|
|
222
|
+
_e = !0;
|
|
223
|
+
var S = Error.prepareStackTrace;
|
|
224
224
|
Error.prepareStackTrace = void 0;
|
|
225
|
-
var
|
|
226
|
-
|
|
225
|
+
var _;
|
|
226
|
+
_ = Ce.current, Ce.current = null, En();
|
|
227
227
|
try {
|
|
228
|
-
if (
|
|
229
|
-
var
|
|
228
|
+
if (a) {
|
|
229
|
+
var C = function() {
|
|
230
230
|
throw Error();
|
|
231
231
|
};
|
|
232
|
-
if (Object.defineProperty(
|
|
232
|
+
if (Object.defineProperty(C.prototype, "props", {
|
|
233
233
|
set: function() {
|
|
234
234
|
throw Error();
|
|
235
235
|
}
|
|
236
236
|
}), typeof Reflect == "object" && Reflect.construct) {
|
|
237
237
|
try {
|
|
238
|
-
Reflect.construct(
|
|
239
|
-
} catch (
|
|
240
|
-
|
|
238
|
+
Reflect.construct(C, []);
|
|
239
|
+
} catch ($) {
|
|
240
|
+
b = $;
|
|
241
241
|
}
|
|
242
|
-
Reflect.construct(e, [],
|
|
242
|
+
Reflect.construct(e, [], C);
|
|
243
243
|
} else {
|
|
244
244
|
try {
|
|
245
|
-
|
|
246
|
-
} catch (
|
|
247
|
-
|
|
245
|
+
C.call();
|
|
246
|
+
} catch ($) {
|
|
247
|
+
b = $;
|
|
248
248
|
}
|
|
249
|
-
e.call(
|
|
249
|
+
e.call(C.prototype);
|
|
250
250
|
}
|
|
251
251
|
} else {
|
|
252
252
|
try {
|
|
253
253
|
throw Error();
|
|
254
|
-
} catch (
|
|
255
|
-
|
|
254
|
+
} catch ($) {
|
|
255
|
+
b = $;
|
|
256
256
|
}
|
|
257
257
|
e();
|
|
258
258
|
}
|
|
259
|
-
} catch (
|
|
260
|
-
if (
|
|
261
|
-
for (var
|
|
262
|
-
`),
|
|
263
|
-
`), P =
|
|
264
|
-
|
|
265
|
-
for (; P >= 1 &&
|
|
266
|
-
if (
|
|
267
|
-
if (P !== 1 ||
|
|
259
|
+
} catch ($) {
|
|
260
|
+
if ($ && b && typeof $.stack == "string") {
|
|
261
|
+
for (var y = $.stack.split(`
|
|
262
|
+
`), F = b.stack.split(`
|
|
263
|
+
`), P = y.length - 1, T = F.length - 1; P >= 1 && T >= 0 && y[P] !== F[T]; )
|
|
264
|
+
T--;
|
|
265
|
+
for (; P >= 1 && T >= 0; P--, T--)
|
|
266
|
+
if (y[P] !== F[T]) {
|
|
267
|
+
if (P !== 1 || T !== 1)
|
|
268
268
|
do
|
|
269
|
-
if (P--,
|
|
270
|
-
var
|
|
271
|
-
` +
|
|
272
|
-
return e.displayName &&
|
|
269
|
+
if (P--, T--, T < 0 || y[P] !== F[T]) {
|
|
270
|
+
var W = `
|
|
271
|
+
` + y[P].replace(" at new ", " at ");
|
|
272
|
+
return e.displayName && W.includes("<anonymous>") && (W = W.replace("<anonymous>", e.displayName)), typeof e == "function" && pe.set(e, W), W;
|
|
273
273
|
}
|
|
274
|
-
while (P >= 1 &&
|
|
274
|
+
while (P >= 1 && T >= 0);
|
|
275
275
|
break;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
} finally {
|
|
279
|
-
|
|
279
|
+
_e = !1, Ce.current = _, kn(), Error.prepareStackTrace = S;
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
return typeof e == "function" &&
|
|
281
|
+
var X = e ? e.displayName || e.name : "", q = X ? me(X) : "";
|
|
282
|
+
return typeof e == "function" && pe.set(e, q), q;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
285
|
-
return
|
|
284
|
+
function jn(e, a, l) {
|
|
285
|
+
return Le(e, !1);
|
|
286
286
|
}
|
|
287
|
-
function
|
|
288
|
-
var
|
|
289
|
-
return !!(
|
|
287
|
+
function An(e) {
|
|
288
|
+
var a = e.prototype;
|
|
289
|
+
return !!(a && a.isReactComponent);
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function fe(e, a, l) {
|
|
292
292
|
if (e == null)
|
|
293
293
|
return "";
|
|
294
294
|
if (typeof e == "function")
|
|
295
|
-
return
|
|
295
|
+
return Le(e, An(e));
|
|
296
296
|
if (typeof e == "string")
|
|
297
|
-
return
|
|
297
|
+
return me(e);
|
|
298
298
|
switch (e) {
|
|
299
|
+
case f:
|
|
300
|
+
return me("Suspense");
|
|
299
301
|
case w:
|
|
300
|
-
return
|
|
301
|
-
case m:
|
|
302
|
-
return se("SuspenseList");
|
|
302
|
+
return me("SuspenseList");
|
|
303
303
|
}
|
|
304
304
|
if (typeof e == "object")
|
|
305
305
|
switch (e.$$typeof) {
|
|
306
|
-
case
|
|
307
|
-
return
|
|
308
|
-
case
|
|
309
|
-
return
|
|
310
|
-
case
|
|
311
|
-
var
|
|
306
|
+
case u:
|
|
307
|
+
return jn(e.render);
|
|
308
|
+
case g:
|
|
309
|
+
return fe(e.type, a, l);
|
|
310
|
+
case v: {
|
|
311
|
+
var b = e, S = b._payload, _ = b._init;
|
|
312
312
|
try {
|
|
313
|
-
return
|
|
313
|
+
return fe(_(S), a, l);
|
|
314
314
|
} catch {
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
return "";
|
|
319
319
|
}
|
|
320
|
-
var
|
|
321
|
-
function
|
|
320
|
+
var re = Object.prototype.hasOwnProperty, Ve = {}, Ke = c.ReactDebugCurrentFrame;
|
|
321
|
+
function ge(e) {
|
|
322
322
|
if (e) {
|
|
323
|
-
var
|
|
324
|
-
|
|
323
|
+
var a = e._owner, l = fe(e.type, e._source, a ? a.type : null);
|
|
324
|
+
Ke.setExtraStackFrame(l);
|
|
325
325
|
} else
|
|
326
|
-
|
|
326
|
+
Ke.setExtraStackFrame(null);
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function Pn(e, a, l, b, S) {
|
|
329
329
|
{
|
|
330
|
-
var
|
|
331
|
-
for (var
|
|
332
|
-
if (
|
|
333
|
-
var
|
|
330
|
+
var _ = Function.call.bind(re);
|
|
331
|
+
for (var C in e)
|
|
332
|
+
if (_(e, C)) {
|
|
333
|
+
var y = void 0;
|
|
334
334
|
try {
|
|
335
|
-
if (typeof e[
|
|
336
|
-
var
|
|
337
|
-
throw
|
|
335
|
+
if (typeof e[C] != "function") {
|
|
336
|
+
var F = Error((b || "React class") + ": " + l + " type `" + C + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[C] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
337
|
+
throw F.name = "Invariant Violation", F;
|
|
338
338
|
}
|
|
339
|
-
|
|
339
|
+
y = e[C](a, C, b, l, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
340
340
|
} catch (P) {
|
|
341
|
-
|
|
341
|
+
y = P;
|
|
342
342
|
}
|
|
343
|
-
|
|
343
|
+
y && !(y instanceof Error) && (ge(S), h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", b || "React class", l, C, typeof y), ge(null)), y instanceof Error && !(y.message in Ve) && (Ve[y.message] = !0, ge(S), h("Failed %s type: %s", l, y.message), ge(null));
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
var
|
|
348
|
-
function
|
|
349
|
-
return
|
|
347
|
+
var Tn = Array.isArray;
|
|
348
|
+
function Ee(e) {
|
|
349
|
+
return Tn(e);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
351
|
+
function On(e) {
|
|
352
352
|
{
|
|
353
|
-
var
|
|
354
|
-
return
|
|
353
|
+
var a = typeof Symbol == "function" && Symbol.toStringTag, l = a && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
354
|
+
return l;
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
function
|
|
357
|
+
function Nn(e) {
|
|
358
358
|
try {
|
|
359
|
-
return
|
|
359
|
+
return Be(e), !1;
|
|
360
360
|
} catch {
|
|
361
361
|
return !0;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function Be(e) {
|
|
365
365
|
return "" + e;
|
|
366
366
|
}
|
|
367
|
-
function
|
|
368
|
-
if (
|
|
369
|
-
return
|
|
367
|
+
function qe(e) {
|
|
368
|
+
if (Nn(e))
|
|
369
|
+
return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", On(e)), Be(e);
|
|
370
370
|
}
|
|
371
|
-
var
|
|
371
|
+
var oe = c.ReactCurrentOwner, In = {
|
|
372
372
|
key: !0,
|
|
373
373
|
ref: !0,
|
|
374
374
|
__self: !0,
|
|
375
375
|
__source: !0
|
|
376
|
-
},
|
|
377
|
-
|
|
378
|
-
function
|
|
379
|
-
if (
|
|
380
|
-
var
|
|
381
|
-
if (
|
|
376
|
+
}, Je, Ge, ke;
|
|
377
|
+
ke = {};
|
|
378
|
+
function Dn(e) {
|
|
379
|
+
if (re.call(e, "ref")) {
|
|
380
|
+
var a = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
381
|
+
if (a && a.isReactWarning)
|
|
382
382
|
return !1;
|
|
383
383
|
}
|
|
384
384
|
return e.ref !== void 0;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
387
|
-
if (
|
|
388
|
-
var
|
|
389
|
-
if (
|
|
386
|
+
function zn(e) {
|
|
387
|
+
if (re.call(e, "key")) {
|
|
388
|
+
var a = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
389
|
+
if (a && a.isReactWarning)
|
|
390
390
|
return !1;
|
|
391
391
|
}
|
|
392
392
|
return e.key !== void 0;
|
|
393
393
|
}
|
|
394
|
-
function
|
|
395
|
-
if (typeof e.ref == "string" &&
|
|
396
|
-
var
|
|
397
|
-
|
|
394
|
+
function Fn(e, a) {
|
|
395
|
+
if (typeof e.ref == "string" && oe.current && a && oe.current.stateNode !== a) {
|
|
396
|
+
var l = L(oe.current.type);
|
|
397
|
+
ke[l] || (h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', L(oe.current.type), e.ref), ke[l] = !0);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function Un(e, a) {
|
|
401
401
|
{
|
|
402
|
-
var
|
|
403
|
-
|
|
402
|
+
var l = function() {
|
|
403
|
+
Je || (Je = !0, h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
|
|
404
404
|
};
|
|
405
|
-
|
|
406
|
-
get:
|
|
405
|
+
l.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
406
|
+
get: l,
|
|
407
407
|
configurable: !0
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function $n(e, a) {
|
|
412
412
|
{
|
|
413
|
-
var
|
|
414
|
-
|
|
413
|
+
var l = function() {
|
|
414
|
+
Ge || (Ge = !0, h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
|
|
415
415
|
};
|
|
416
|
-
|
|
417
|
-
get:
|
|
416
|
+
l.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
417
|
+
get: l,
|
|
418
418
|
configurable: !0
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
var
|
|
423
|
-
var
|
|
422
|
+
var Mn = function(e, a, l, b, S, _, C) {
|
|
423
|
+
var y = {
|
|
424
424
|
// This tag allows us to uniquely identify this as a React Element
|
|
425
425
|
$$typeof: n,
|
|
426
426
|
// Built-in properties that belong on the element
|
|
427
427
|
type: e,
|
|
428
|
-
key:
|
|
429
|
-
ref:
|
|
430
|
-
props:
|
|
428
|
+
key: a,
|
|
429
|
+
ref: l,
|
|
430
|
+
props: C,
|
|
431
431
|
// Record the component responsible for creating this element.
|
|
432
|
-
_owner:
|
|
432
|
+
_owner: _
|
|
433
433
|
};
|
|
434
|
-
return
|
|
434
|
+
return y._store = {}, Object.defineProperty(y._store, "validated", {
|
|
435
435
|
configurable: !1,
|
|
436
436
|
enumerable: !1,
|
|
437
437
|
writable: !0,
|
|
438
438
|
value: !1
|
|
439
|
-
}), Object.defineProperty(
|
|
439
|
+
}), Object.defineProperty(y, "_self", {
|
|
440
440
|
configurable: !1,
|
|
441
441
|
enumerable: !1,
|
|
442
442
|
writable: !1,
|
|
443
|
-
value:
|
|
444
|
-
}), Object.defineProperty(
|
|
443
|
+
value: b
|
|
444
|
+
}), Object.defineProperty(y, "_source", {
|
|
445
445
|
configurable: !1,
|
|
446
446
|
enumerable: !1,
|
|
447
447
|
writable: !1,
|
|
448
|
-
value:
|
|
449
|
-
}), Object.freeze && (Object.freeze(
|
|
448
|
+
value: S
|
|
449
|
+
}), Object.freeze && (Object.freeze(y.props), Object.freeze(y)), y;
|
|
450
450
|
};
|
|
451
|
-
function
|
|
451
|
+
function Hn(e, a, l, b, S) {
|
|
452
452
|
{
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
for (
|
|
456
|
-
|
|
453
|
+
var _, C = {}, y = null, F = null;
|
|
454
|
+
l !== void 0 && (qe(l), y = "" + l), zn(a) && (qe(a.key), y = "" + a.key), Dn(a) && (F = a.ref, Fn(a, S));
|
|
455
|
+
for (_ in a)
|
|
456
|
+
re.call(a, _) && !In.hasOwnProperty(_) && (C[_] = a[_]);
|
|
457
457
|
if (e && e.defaultProps) {
|
|
458
458
|
var P = e.defaultProps;
|
|
459
|
-
for (
|
|
460
|
-
|
|
459
|
+
for (_ in P)
|
|
460
|
+
C[_] === void 0 && (C[_] = P[_]);
|
|
461
461
|
}
|
|
462
|
-
if (
|
|
463
|
-
var
|
|
464
|
-
|
|
462
|
+
if (y || F) {
|
|
463
|
+
var T = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
464
|
+
y && Un(C, T), F && $n(C, T);
|
|
465
465
|
}
|
|
466
|
-
return
|
|
466
|
+
return Mn(e, y, F, S, b, oe.current, C);
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
var
|
|
470
|
-
function
|
|
469
|
+
var Re = c.ReactCurrentOwner, Xe = c.ReactDebugCurrentFrame;
|
|
470
|
+
function G(e) {
|
|
471
471
|
if (e) {
|
|
472
|
-
var
|
|
473
|
-
|
|
472
|
+
var a = e._owner, l = fe(e.type, e._source, a ? a.type : null);
|
|
473
|
+
Xe.setExtraStackFrame(l);
|
|
474
474
|
} else
|
|
475
|
-
|
|
475
|
+
Xe.setExtraStackFrame(null);
|
|
476
476
|
}
|
|
477
|
-
var
|
|
478
|
-
|
|
479
|
-
function
|
|
477
|
+
var je;
|
|
478
|
+
je = !1;
|
|
479
|
+
function Ae(e) {
|
|
480
480
|
return typeof e == "object" && e !== null && e.$$typeof === n;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function Qe() {
|
|
483
483
|
{
|
|
484
|
-
if (
|
|
485
|
-
var e =
|
|
484
|
+
if (Re.current) {
|
|
485
|
+
var e = L(Re.current.type);
|
|
486
486
|
if (e)
|
|
487
487
|
return `
|
|
488
488
|
|
|
@@ -491,212 +491,308 @@ Check the render method of \`` + e + "`.";
|
|
|
491
491
|
return "";
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
function
|
|
494
|
+
function Wn(e) {
|
|
495
495
|
return "";
|
|
496
496
|
}
|
|
497
|
-
var
|
|
498
|
-
function
|
|
497
|
+
var Ze = {};
|
|
498
|
+
function Yn(e) {
|
|
499
499
|
{
|
|
500
|
-
var
|
|
501
|
-
if (!
|
|
502
|
-
var
|
|
503
|
-
|
|
500
|
+
var a = Qe();
|
|
501
|
+
if (!a) {
|
|
502
|
+
var l = typeof e == "string" ? e : e.displayName || e.name;
|
|
503
|
+
l && (a = `
|
|
504
504
|
|
|
505
|
-
Check the top-level render call using <` +
|
|
505
|
+
Check the top-level render call using <` + l + ">.");
|
|
506
506
|
}
|
|
507
|
-
return
|
|
507
|
+
return a;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function en(e, a) {
|
|
511
511
|
{
|
|
512
512
|
if (!e._store || e._store.validated || e.key != null)
|
|
513
513
|
return;
|
|
514
514
|
e._store.validated = !0;
|
|
515
|
-
var
|
|
516
|
-
if (
|
|
515
|
+
var l = Yn(a);
|
|
516
|
+
if (Ze[l])
|
|
517
517
|
return;
|
|
518
|
-
|
|
519
|
-
var
|
|
520
|
-
e && e._owner && e._owner !==
|
|
518
|
+
Ze[l] = !0;
|
|
519
|
+
var b = "";
|
|
520
|
+
e && e._owner && e._owner !== Re.current && (b = " It was passed a child from " + L(e._owner.type) + "."), G(e), h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', l, b), G(null);
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function nn(e, a) {
|
|
524
524
|
{
|
|
525
525
|
if (typeof e != "object")
|
|
526
526
|
return;
|
|
527
|
-
if (
|
|
528
|
-
for (var
|
|
529
|
-
var
|
|
530
|
-
|
|
527
|
+
if (Ee(e))
|
|
528
|
+
for (var l = 0; l < e.length; l++) {
|
|
529
|
+
var b = e[l];
|
|
530
|
+
Ae(b) && en(b, a);
|
|
531
531
|
}
|
|
532
|
-
else if (
|
|
532
|
+
else if (Ae(e))
|
|
533
533
|
e._store && (e._store.validated = !0);
|
|
534
534
|
else if (e) {
|
|
535
|
-
var
|
|
536
|
-
if (typeof
|
|
537
|
-
for (var
|
|
538
|
-
|
|
535
|
+
var S = U(e);
|
|
536
|
+
if (typeof S == "function" && S !== e.entries)
|
|
537
|
+
for (var _ = S.call(e), C; !(C = _.next()).done; )
|
|
538
|
+
Ae(C.value) && en(C.value, a);
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function Ln(e) {
|
|
543
543
|
{
|
|
544
|
-
var
|
|
545
|
-
if (
|
|
544
|
+
var a = e.type;
|
|
545
|
+
if (a == null || typeof a == "string")
|
|
546
546
|
return;
|
|
547
|
-
var
|
|
548
|
-
if (typeof
|
|
549
|
-
|
|
550
|
-
else if (typeof
|
|
547
|
+
var l;
|
|
548
|
+
if (typeof a == "function")
|
|
549
|
+
l = a.propTypes;
|
|
550
|
+
else if (typeof a == "object" && (a.$$typeof === u || // Note: Memo only checks outer props here.
|
|
551
551
|
// Inner props are checked in the reconciler.
|
|
552
|
-
|
|
553
|
-
|
|
552
|
+
a.$$typeof === g))
|
|
553
|
+
l = a.propTypes;
|
|
554
554
|
else
|
|
555
555
|
return;
|
|
556
|
-
if (
|
|
557
|
-
var
|
|
558
|
-
|
|
559
|
-
} else if (
|
|
560
|
-
|
|
561
|
-
var
|
|
562
|
-
|
|
556
|
+
if (l) {
|
|
557
|
+
var b = L(a);
|
|
558
|
+
Pn(l, e.props, "prop", b, e);
|
|
559
|
+
} else if (a.PropTypes !== void 0 && !je) {
|
|
560
|
+
je = !0;
|
|
561
|
+
var S = L(a);
|
|
562
|
+
h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", S || "Unknown");
|
|
563
563
|
}
|
|
564
|
-
typeof
|
|
564
|
+
typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Vn(e) {
|
|
568
568
|
{
|
|
569
|
-
for (var
|
|
570
|
-
var
|
|
571
|
-
if (
|
|
572
|
-
|
|
569
|
+
for (var a = Object.keys(e.props), l = 0; l < a.length; l++) {
|
|
570
|
+
var b = a[l];
|
|
571
|
+
if (b !== "children" && b !== "key") {
|
|
572
|
+
G(e), h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", b), G(null);
|
|
573
573
|
break;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
e.ref !== null && (
|
|
576
|
+
e.ref !== null && (G(e), h("Invalid attribute `ref` supplied to `React.Fragment`."), G(null));
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
var
|
|
580
|
-
function
|
|
579
|
+
var tn = {};
|
|
580
|
+
function rn(e, a, l, b, S, _) {
|
|
581
581
|
{
|
|
582
|
-
var
|
|
583
|
-
if (!
|
|
584
|
-
var
|
|
585
|
-
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (
|
|
586
|
-
var
|
|
587
|
-
|
|
582
|
+
var C = ne(e);
|
|
583
|
+
if (!C) {
|
|
584
|
+
var y = "";
|
|
585
|
+
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (y += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
586
|
+
var F = Wn();
|
|
587
|
+
F ? y += F : y += Qe();
|
|
588
588
|
var P;
|
|
589
|
-
e === null ? P = "null" :
|
|
589
|
+
e === null ? P = "null" : Ee(e) ? P = "array" : e !== void 0 && e.$$typeof === n ? (P = "<" + (L(e.type) || "Unknown") + " />", y = " Did you accidentally export a JSX literal instead of a component?") : P = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", P, y);
|
|
590
590
|
}
|
|
591
|
-
var
|
|
592
|
-
if (
|
|
593
|
-
return
|
|
594
|
-
if (
|
|
595
|
-
var
|
|
596
|
-
if (
|
|
597
|
-
if (
|
|
598
|
-
if (
|
|
599
|
-
for (var
|
|
600
|
-
|
|
601
|
-
Object.freeze && Object.freeze(
|
|
591
|
+
var T = Hn(e, a, l, S, _);
|
|
592
|
+
if (T == null)
|
|
593
|
+
return T;
|
|
594
|
+
if (C) {
|
|
595
|
+
var W = a.children;
|
|
596
|
+
if (W !== void 0)
|
|
597
|
+
if (b)
|
|
598
|
+
if (Ee(W)) {
|
|
599
|
+
for (var X = 0; X < W.length; X++)
|
|
600
|
+
nn(W[X], e);
|
|
601
|
+
Object.freeze && Object.freeze(W);
|
|
602
602
|
} else
|
|
603
|
-
|
|
603
|
+
h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
604
604
|
else
|
|
605
|
-
|
|
605
|
+
nn(W, e);
|
|
606
606
|
}
|
|
607
|
-
if (
|
|
608
|
-
var
|
|
609
|
-
return
|
|
610
|
-
}),
|
|
611
|
-
if (!
|
|
612
|
-
var
|
|
613
|
-
|
|
607
|
+
if (re.call(a, "key")) {
|
|
608
|
+
var q = L(e), $ = Object.keys(a).filter(function(Xn) {
|
|
609
|
+
return Xn !== "key";
|
|
610
|
+
}), Pe = $.length > 0 ? "{key: someKey, " + $.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
611
|
+
if (!tn[q + Pe]) {
|
|
612
|
+
var Gn = $.length > 0 ? "{" + $.join(": ..., ") + ": ...}" : "{}";
|
|
613
|
+
h(`A props object containing a "key" prop is being spread into JSX:
|
|
614
614
|
let props = %s;
|
|
615
615
|
<%s {...props} />
|
|
616
616
|
React keys must be passed directly to JSX without using spread:
|
|
617
617
|
let props = %s;
|
|
618
|
-
<%s key={someKey} {...props} />`,
|
|
618
|
+
<%s key={someKey} {...props} />`, Pe, q, Gn, q), tn[q + Pe] = !0;
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
return e ===
|
|
621
|
+
return e === r ? Vn(T) : Ln(T), T;
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
-
function
|
|
625
|
-
return
|
|
624
|
+
function Kn(e, a, l) {
|
|
625
|
+
return rn(e, a, l, !0);
|
|
626
626
|
}
|
|
627
|
-
function
|
|
628
|
-
return
|
|
627
|
+
function Bn(e, a, l) {
|
|
628
|
+
return rn(e, a, l, !1);
|
|
629
629
|
}
|
|
630
|
-
var
|
|
631
|
-
|
|
632
|
-
}()),
|
|
630
|
+
var qn = Bn, Jn = Kn;
|
|
631
|
+
se.Fragment = r, se.jsx = qn, se.jsxs = Jn;
|
|
632
|
+
}()), se;
|
|
633
633
|
}
|
|
634
|
-
process.env.NODE_ENV === "production" ?
|
|
635
|
-
var
|
|
634
|
+
process.env.NODE_ENV === "production" ? Te.exports = rt() : Te.exports = ot();
|
|
635
|
+
var m = Te.exports, Oe, he = tt;
|
|
636
636
|
if (process.env.NODE_ENV === "production")
|
|
637
|
-
|
|
637
|
+
Oe = he.createRoot, he.hydrateRoot;
|
|
638
638
|
else {
|
|
639
|
-
var
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
var sn = he.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
640
|
+
Oe = function(o, n) {
|
|
641
|
+
sn.usingClientEntryPoint = !0;
|
|
642
642
|
try {
|
|
643
|
-
return
|
|
643
|
+
return he.createRoot(o, n);
|
|
644
644
|
} finally {
|
|
645
|
-
|
|
645
|
+
sn.usingClientEntryPoint = !1;
|
|
646
646
|
}
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
const i = (
|
|
652
|
-
var
|
|
653
|
-
!t &&
|
|
649
|
+
const at = ({ onOpen: o, onClose: n, isVisible: t, showCitadelKey: r }) => {
|
|
650
|
+
I(() => {
|
|
651
|
+
const i = (s) => {
|
|
652
|
+
var p, d;
|
|
653
|
+
!t && s.key === r && !["input", "textarea"].includes(((d = (p = s.target) == null ? void 0 : p.tagName) == null ? void 0 : d.toLowerCase()) || "") && (s.preventDefault(), o()), t && s.key === "Escape" && (s.preventDefault(), n());
|
|
654
654
|
};
|
|
655
655
|
return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
|
|
656
|
-
}, [
|
|
657
|
-
},
|
|
658
|
-
container:
|
|
659
|
-
innerContainer:
|
|
660
|
-
inputSection:
|
|
661
|
-
resizeHandle:
|
|
662
|
-
citadel_slideUp:
|
|
663
|
-
citadel_slideDown:
|
|
664
|
-
},
|
|
665
|
-
const { isVisible: n, isClosing: t, onAnimationComplete:
|
|
666
|
-
return
|
|
667
|
-
if (
|
|
668
|
-
const
|
|
669
|
-
|
|
656
|
+
}, [o, n, t, r]);
|
|
657
|
+
}, st = "_container_141sr_3", it = "_innerContainer_141sr_19", lt = "_inputSection_141sr_28", ct = "_resizeHandle_141sr_35", ut = "_citadel_slideUp_141sr_64", dt = "_citadel_slideDown_141sr_68", ln = {
|
|
658
|
+
container: st,
|
|
659
|
+
innerContainer: it,
|
|
660
|
+
inputSection: lt,
|
|
661
|
+
resizeHandle: ct,
|
|
662
|
+
citadel_slideUp: ut,
|
|
663
|
+
citadel_slideDown: dt
|
|
664
|
+
}, mt = (o) => {
|
|
665
|
+
const { isVisible: n, isClosing: t, onAnimationComplete: r } = o, i = be(() => n ? t ? ln.slideDown : ln.slideUp : "", [n, t]);
|
|
666
|
+
return I(() => {
|
|
667
|
+
if (r) {
|
|
668
|
+
const p = setTimeout(() => {
|
|
669
|
+
r();
|
|
670
670
|
}, 200);
|
|
671
|
-
return () => clearTimeout(
|
|
671
|
+
return () => clearTimeout(p);
|
|
672
672
|
}
|
|
673
|
-
}, [t,
|
|
674
|
-
style:
|
|
673
|
+
}, [t, r]), {
|
|
674
|
+
style: be(() => ({
|
|
675
675
|
opacity: n ? 1 : 0,
|
|
676
676
|
transform: n ? "translateY(0)" : t ? "translateY(100%)" : "translateY(-100%)",
|
|
677
677
|
transition: "opacity 200ms ease-in-out, transform 200ms ease-in-out"
|
|
678
678
|
}), [n, t]),
|
|
679
679
|
animationClass: i
|
|
680
680
|
};
|
|
681
|
-
}
|
|
681
|
+
};
|
|
682
|
+
var ie = /* @__PURE__ */ ((o) => (o.Pending = "pending", o.Success = "success", o.Failure = "failure", o.Timeout = "timeout", o))(ie || {});
|
|
683
|
+
class ee {
|
|
684
|
+
constructor(n = Date.now()) {
|
|
685
|
+
j(this, "_status", "pending");
|
|
686
|
+
this.timestamp = n;
|
|
687
|
+
}
|
|
688
|
+
get status() {
|
|
689
|
+
return this._status;
|
|
690
|
+
}
|
|
691
|
+
markSuccess() {
|
|
692
|
+
this._status = "success";
|
|
693
|
+
}
|
|
694
|
+
markFailure() {
|
|
695
|
+
this._status = "failure";
|
|
696
|
+
}
|
|
697
|
+
markTimeout() {
|
|
698
|
+
this._status = "timeout";
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
class Yt extends ee {
|
|
702
|
+
constructor(n, t) {
|
|
703
|
+
super(t), this.data = n;
|
|
704
|
+
}
|
|
705
|
+
render() {
|
|
706
|
+
return /* @__PURE__ */ m.jsx("pre", { className: "text-gray-200", children: JSON.stringify(this.data, null, 2) });
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
class gn extends ee {
|
|
710
|
+
constructor(n, t) {
|
|
711
|
+
super(t), this.text = n;
|
|
712
|
+
}
|
|
713
|
+
render() {
|
|
714
|
+
return /* @__PURE__ */ m.jsx("div", { className: "text-gray-200 whitespace-pre font-mono", children: this.text });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
class pt extends ee {
|
|
718
|
+
constructor(n, t) {
|
|
719
|
+
super(t), this.error = n, this.markFailure();
|
|
720
|
+
}
|
|
721
|
+
render() {
|
|
722
|
+
return /* @__PURE__ */ m.jsx("div", { className: "mt-1 text-red-400", children: this.error });
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
class ft extends ee {
|
|
726
|
+
render() {
|
|
727
|
+
return /* @__PURE__ */ m.jsx("div", { className: "text-gray-400", children: "..." });
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
class Lt extends ee {
|
|
731
|
+
constructor(n, t = "", r) {
|
|
732
|
+
super(r), this.imageUrl = n, this.altText = t;
|
|
733
|
+
}
|
|
734
|
+
render() {
|
|
735
|
+
return /* @__PURE__ */ m.jsx("div", { className: "my-2", children: /* @__PURE__ */ m.jsx(
|
|
736
|
+
"img",
|
|
737
|
+
{
|
|
738
|
+
src: this.imageUrl,
|
|
739
|
+
alt: this.altText,
|
|
740
|
+
className: "max-w-[400px] max-h-[300px] h-auto rounded-lg object-contain"
|
|
741
|
+
}
|
|
742
|
+
) });
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
const gt = (o) => async function(n) {
|
|
746
|
+
const t = o.commands.filter((r) => r.fullPath[0] !== "help").map((r) => `${r.segments.map((s) => s.type === "argument" ? `<${s.name}>` : s.name).join(" ")} - ${r.description}`).sort();
|
|
747
|
+
return t.push("help - Show available commands"), new gn(
|
|
748
|
+
t.length > 0 ? `Available Commands:
|
|
749
|
+
` + t.join(`
|
|
750
|
+
`) : "No commands available yet. Add some commands to get started!"
|
|
751
|
+
);
|
|
752
|
+
};
|
|
753
|
+
var we = /* @__PURE__ */ ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o[o.TRACE = 5] = "TRACE", o))(we || {});
|
|
754
|
+
class N {
|
|
755
|
+
static configure(n) {
|
|
756
|
+
this.level = n.level, this.prefix = n.prefix || "[Citadel]";
|
|
757
|
+
}
|
|
758
|
+
static trace(...n) {
|
|
759
|
+
this.level >= 5 && process.env.NODE_ENV !== "production" && console.trace(this.prefix, ...n);
|
|
760
|
+
}
|
|
761
|
+
static debug(...n) {
|
|
762
|
+
this.level >= 4 && process.env.NODE_ENV !== "production" && console.debug(this.prefix, ...n);
|
|
763
|
+
}
|
|
764
|
+
static info(...n) {
|
|
765
|
+
this.level >= 3 && console.info(this.prefix, ...n);
|
|
766
|
+
}
|
|
767
|
+
static warn(...n) {
|
|
768
|
+
this.level >= 2 && console.warn(this.prefix, ...n);
|
|
769
|
+
}
|
|
770
|
+
static error(...n) {
|
|
771
|
+
this.level >= 1 && console.error(this.prefix, ...n);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
j(N, "level", 0), j(N, "prefix", "");
|
|
775
|
+
const M = {
|
|
682
776
|
commandTimeoutMs: 1e4,
|
|
777
|
+
cursorColor: "var(--cursor-color, #fff)",
|
|
778
|
+
cursorSpeed: 530,
|
|
779
|
+
cursorType: "blink",
|
|
683
780
|
includeHelpCommand: !0,
|
|
781
|
+
initialHeight: "40vh",
|
|
782
|
+
logLevel: process.env.NODE_ENV === "production" ? we.ERROR : we.DEBUG,
|
|
684
783
|
maxHeight: "80vh",
|
|
685
784
|
minHeight: "200",
|
|
686
|
-
outputFontSize: "
|
|
785
|
+
outputFontSize: "0.875rem",
|
|
687
786
|
resetStateOnHide: !1,
|
|
688
787
|
showCitadelKey: ".",
|
|
689
|
-
cursorType: "bbs",
|
|
690
|
-
cursorColor: "var(--cursor-color, #fff)",
|
|
691
|
-
cursorSpeed: 530,
|
|
692
788
|
storage: {
|
|
693
789
|
type: "localStorage",
|
|
694
790
|
maxCommands: 100
|
|
695
791
|
}
|
|
696
792
|
};
|
|
697
|
-
class
|
|
793
|
+
class hn {
|
|
698
794
|
constructor(n) {
|
|
699
|
-
|
|
795
|
+
j(this, "config");
|
|
700
796
|
this.config = {
|
|
701
797
|
type: "localStorage",
|
|
702
798
|
maxCommands: 100,
|
|
@@ -706,22 +802,25 @@ class ln {
|
|
|
706
802
|
/**
|
|
707
803
|
* Add a command to history, enforcing storage limits
|
|
708
804
|
*/
|
|
709
|
-
async
|
|
710
|
-
const t = await this.
|
|
805
|
+
async addStoredCommand(n) {
|
|
806
|
+
const t = await this.getStoredCommands();
|
|
711
807
|
for (t.push(n); t.length > this.config.maxCommands; )
|
|
712
808
|
t.shift();
|
|
713
809
|
await this.saveCommands(t);
|
|
714
810
|
}
|
|
715
811
|
}
|
|
716
|
-
class
|
|
812
|
+
class ht extends hn {
|
|
717
813
|
constructor(t) {
|
|
718
814
|
super(t);
|
|
719
|
-
|
|
815
|
+
j(this, "storageKey", "citadel_command_history");
|
|
720
816
|
}
|
|
721
|
-
async
|
|
817
|
+
async getStoredCommands() {
|
|
722
818
|
try {
|
|
723
819
|
const t = window.localStorage.getItem(this.storageKey);
|
|
724
|
-
return t ? JSON.parse(t)
|
|
820
|
+
return t ? JSON.parse(t).map((i) => ({
|
|
821
|
+
commandSegments: i.commandSegments || [],
|
|
822
|
+
timestamp: i.timestamp
|
|
823
|
+
})) : [];
|
|
725
824
|
} catch (t) {
|
|
726
825
|
return console.warn("Failed to load commands from localStorage:", t), [];
|
|
727
826
|
}
|
|
@@ -735,50 +834,50 @@ class ot extends ln {
|
|
|
735
834
|
}
|
|
736
835
|
async saveCommands(t) {
|
|
737
836
|
try {
|
|
738
|
-
const
|
|
739
|
-
|
|
837
|
+
const r = t.map((i) => ({
|
|
838
|
+
commandSegments: Array.isArray(i.commandSegments) ? [...i.commandSegments] : [],
|
|
740
839
|
timestamp: i.timestamp
|
|
741
840
|
}));
|
|
742
|
-
window.localStorage.setItem(this.storageKey, JSON.stringify(
|
|
743
|
-
} catch (
|
|
744
|
-
throw console.warn("Failed to save commands to localStorage:",
|
|
841
|
+
window.localStorage.setItem(this.storageKey, JSON.stringify(r));
|
|
842
|
+
} catch (r) {
|
|
843
|
+
throw console.warn("Failed to save commands to localStorage:", r), r;
|
|
745
844
|
}
|
|
746
845
|
}
|
|
747
846
|
}
|
|
748
|
-
class
|
|
847
|
+
class bt extends hn {
|
|
749
848
|
constructor(t) {
|
|
750
849
|
super(t);
|
|
751
|
-
|
|
850
|
+
j(this, "storedCommands", []);
|
|
752
851
|
}
|
|
753
|
-
async
|
|
754
|
-
return this.
|
|
755
|
-
|
|
852
|
+
async getStoredCommands() {
|
|
853
|
+
return this.storedCommands.map((t) => ({
|
|
854
|
+
commandSegments: Array.isArray(t.commandSegments) ? [...t.commandSegments] : [],
|
|
756
855
|
timestamp: t.timestamp
|
|
757
856
|
}));
|
|
758
857
|
}
|
|
759
858
|
async clear() {
|
|
760
|
-
this.
|
|
859
|
+
this.storedCommands = [];
|
|
761
860
|
}
|
|
762
861
|
async saveCommands(t) {
|
|
763
|
-
this.
|
|
764
|
-
|
|
765
|
-
timestamp:
|
|
862
|
+
this.storedCommands = t.map((r) => ({
|
|
863
|
+
commandSegments: Array.isArray(r.commandSegments) ? [...r.commandSegments] : [],
|
|
864
|
+
timestamp: r.timestamp
|
|
766
865
|
}));
|
|
767
866
|
}
|
|
768
867
|
}
|
|
769
|
-
const
|
|
868
|
+
const J = class J {
|
|
770
869
|
constructor() {
|
|
771
|
-
|
|
870
|
+
j(this, "currentStorage");
|
|
772
871
|
}
|
|
773
872
|
static getInstance() {
|
|
774
|
-
return
|
|
873
|
+
return J.instance || (J.instance = new J()), J.instance;
|
|
775
874
|
}
|
|
776
875
|
initializeStorage(n) {
|
|
777
876
|
if (!this.currentStorage)
|
|
778
877
|
try {
|
|
779
|
-
this.currentStorage = new
|
|
878
|
+
this.currentStorage = new ht(n);
|
|
780
879
|
} catch (t) {
|
|
781
|
-
console.warn("Failed to create storage, falling back to memory storage:", t), this.currentStorage = new
|
|
880
|
+
console.warn("Failed to create storage, falling back to memory storage:", t), this.currentStorage = new bt(n);
|
|
782
881
|
}
|
|
783
882
|
}
|
|
784
883
|
getStorage() {
|
|
@@ -787,913 +886,497 @@ const K = class K {
|
|
|
787
886
|
return this.currentStorage;
|
|
788
887
|
}
|
|
789
888
|
};
|
|
790
|
-
|
|
791
|
-
let
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
description: i.description,
|
|
797
|
-
handler: i.handler,
|
|
798
|
-
argument: i.argument
|
|
799
|
-
};
|
|
800
|
-
(d.handler || d.argument || d.description) && (t[l] = {
|
|
801
|
-
description: d.description || `${l} command`,
|
|
802
|
-
...d.handler && { handler: d.handler },
|
|
803
|
-
...d.argument && { argument: d.argument }
|
|
804
|
-
});
|
|
805
|
-
const h = Object.keys(i).filter(
|
|
806
|
-
(w) => typeof i[w] == "object" && w !== "argument" && !["description", "handler"].includes(w)
|
|
807
|
-
);
|
|
808
|
-
if (h.length > 0) {
|
|
809
|
-
const w = h.reduce((m, p) => (m[p] = i[p], m), {});
|
|
810
|
-
Object.assign(t, cn(w, a));
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return t;
|
|
814
|
-
}
|
|
815
|
-
const he = Kn({ config: F }), it = ({ config: r = F, commands: n, children: t }) => {
|
|
816
|
-
const [o, i] = fe.useState(), a = {
|
|
817
|
-
...F,
|
|
818
|
-
...r,
|
|
819
|
-
// Ensure nested objects are properly merged
|
|
820
|
-
storage: {
|
|
821
|
-
...F.storage,
|
|
822
|
-
...r.storage
|
|
823
|
-
},
|
|
824
|
-
// Ensure explicit values from config take precedence
|
|
825
|
-
cursorType: r.cursorType ?? F.cursorType,
|
|
826
|
-
cursorColor: r.cursorColor ?? F.cursorColor,
|
|
827
|
-
cursorSpeed: r.cursorSpeed ?? F.cursorSpeed,
|
|
828
|
-
showCitadelKey: r.showCitadelKey || "."
|
|
829
|
-
};
|
|
830
|
-
$(() => {
|
|
831
|
-
me.getInstance().initializeStorage(
|
|
832
|
-
a.storage ?? F.storage
|
|
833
|
-
), i(me.getInstance().getStorage());
|
|
834
|
-
}, []);
|
|
835
|
-
const l = n ? cn(n) : void 0, d = {
|
|
836
|
-
config: a,
|
|
837
|
-
commands: l,
|
|
838
|
-
storage: o
|
|
839
|
-
};
|
|
840
|
-
return /* @__PURE__ */ g.jsx(he.Provider, { value: d, children: t });
|
|
841
|
-
}, G = () => {
|
|
842
|
-
const r = Re(he);
|
|
843
|
-
if (r === void 0)
|
|
844
|
-
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
845
|
-
return r.config;
|
|
846
|
-
}, st = () => {
|
|
847
|
-
const r = Re(he);
|
|
848
|
-
if (r === void 0)
|
|
849
|
-
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
850
|
-
return r.commands;
|
|
851
|
-
}, dn = () => {
|
|
852
|
-
const r = Re(he);
|
|
853
|
-
if (r === void 0)
|
|
854
|
-
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
855
|
-
return r.storage;
|
|
856
|
-
};
|
|
857
|
-
var ae = /* @__PURE__ */ ((r) => (r.Pending = "pending", r.Success = "success", r.Failure = "failure", r.Timeout = "timeout", r))(ae || {});
|
|
858
|
-
class X {
|
|
859
|
-
constructor(n = Date.now()) {
|
|
860
|
-
A(this, "_status", "pending");
|
|
861
|
-
this.timestamp = n;
|
|
889
|
+
j(J, "instance");
|
|
890
|
+
let ye = J;
|
|
891
|
+
const bn = async (o) => new gn("");
|
|
892
|
+
class Ne {
|
|
893
|
+
constructor(n, t, r) {
|
|
894
|
+
this.type = n, this.name = t, this.description = r;
|
|
862
895
|
}
|
|
863
|
-
|
|
864
|
-
return this.
|
|
896
|
+
toString() {
|
|
897
|
+
return this.name;
|
|
865
898
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
this._status = "failure";
|
|
871
|
-
}
|
|
872
|
-
markTimeout() {
|
|
873
|
-
this._status = "timeout";
|
|
899
|
+
}
|
|
900
|
+
class wn extends Ne {
|
|
901
|
+
constructor() {
|
|
902
|
+
super("null", ">null<", "Empty segment");
|
|
874
903
|
}
|
|
875
904
|
}
|
|
876
|
-
class
|
|
905
|
+
class wt extends Ne {
|
|
877
906
|
constructor(n, t) {
|
|
878
|
-
super(
|
|
907
|
+
super("word", n, t);
|
|
879
908
|
}
|
|
880
|
-
|
|
881
|
-
|
|
909
|
+
}
|
|
910
|
+
class yt extends Ne {
|
|
911
|
+
constructor(n, t, r, i) {
|
|
912
|
+
super("argument", n, t), this.value = r, this.valid = i;
|
|
882
913
|
}
|
|
883
914
|
}
|
|
884
|
-
class
|
|
885
|
-
constructor(n, t) {
|
|
886
|
-
|
|
915
|
+
class vt {
|
|
916
|
+
constructor(n, t, r = bn) {
|
|
917
|
+
j(this, "_segments");
|
|
918
|
+
j(this, "_description");
|
|
919
|
+
// Used by `Help` command, etc.
|
|
920
|
+
j(this, "_handler");
|
|
921
|
+
this._segments = n, this._description = t, this._handler = r;
|
|
887
922
|
}
|
|
888
|
-
|
|
889
|
-
return
|
|
923
|
+
get segments() {
|
|
924
|
+
return this._segments;
|
|
890
925
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
constructor(n, t) {
|
|
894
|
-
super(t), this.error = n, this.markFailure();
|
|
926
|
+
get description() {
|
|
927
|
+
return this._description;
|
|
895
928
|
}
|
|
896
|
-
|
|
897
|
-
return
|
|
929
|
+
get handler() {
|
|
930
|
+
return this._handler;
|
|
898
931
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
render() {
|
|
902
|
-
return /* @__PURE__ */ g.jsx("div", { className: "text-gray-400", children: "..." });
|
|
932
|
+
get hasArguments() {
|
|
933
|
+
return this.segments.some((n) => n.type === "argument");
|
|
903
934
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
constructor(n, t = "", o) {
|
|
907
|
-
super(o), this.imageUrl = n, this.altText = t;
|
|
935
|
+
get fullPath() {
|
|
936
|
+
return this.segments.map((n) => n.name);
|
|
908
937
|
}
|
|
909
|
-
|
|
910
|
-
return
|
|
911
|
-
"img",
|
|
912
|
-
{
|
|
913
|
-
src: this.imageUrl,
|
|
914
|
-
alt: this.altText,
|
|
915
|
-
className: "max-w-[400px] max-h-[300px] h-auto rounded-lg object-contain"
|
|
916
|
-
}
|
|
917
|
-
) });
|
|
938
|
+
get fullPath_s() {
|
|
939
|
+
return this.fullPath.join(" ");
|
|
918
940
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
constructor(n, t) {
|
|
922
|
-
A(this, "timestamp");
|
|
923
|
-
A(this, "command");
|
|
924
|
-
A(this, "result");
|
|
925
|
-
this.command = n, this.timestamp = Date.now(), this.result = t ?? new ct();
|
|
941
|
+
equals(n) {
|
|
942
|
+
return this.fullPath.join(" ") === n.fullPath.join(" ");
|
|
926
943
|
}
|
|
927
944
|
}
|
|
928
|
-
|
|
929
|
-
|
|
945
|
+
class Ie {
|
|
946
|
+
constructor() {
|
|
947
|
+
j(this, "_commands", []);
|
|
948
|
+
}
|
|
949
|
+
get commands() {
|
|
950
|
+
return this._commands;
|
|
951
|
+
}
|
|
930
952
|
/**
|
|
931
|
-
*
|
|
932
|
-
* high level, a command is one or more words followed by an optional
|
|
933
|
-
* argument, and with an optional handler.
|
|
953
|
+
* Registers a new command
|
|
934
954
|
*
|
|
935
|
-
* @param
|
|
936
|
-
* @
|
|
937
|
-
* @param params.description Human-readable description of the command
|
|
938
|
-
* @param params.parent Optional parent node in the command hierarchy
|
|
939
|
-
* @param params.handler Optional async function to execute when command is invoked
|
|
940
|
-
* @param params.argument Optional argument definition for the command
|
|
941
|
-
* @throws {Error} If fullPath is empty or undefined
|
|
955
|
+
* @param newCommandNode The new command to add
|
|
956
|
+
* @throws {Error} If attempting to add a duplicate leaf command or a subcommand to a leaf
|
|
942
957
|
*
|
|
943
958
|
*/
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
A(this, "_description");
|
|
947
|
-
A(this, "_children");
|
|
948
|
-
A(this, "_argument");
|
|
949
|
-
A(this, "_handler");
|
|
950
|
-
A(this, "_parent");
|
|
951
|
-
A(this, "_signature");
|
|
952
|
-
if (!n.fullPath || n.fullPath.length === 0)
|
|
959
|
+
addCommand(n, t, r = bn) {
|
|
960
|
+
if (n === void 0 || n.length === 0)
|
|
953
961
|
throw new Error("Command path cannot be empty");
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
get isLeaf() {
|
|
966
|
-
return this._children.size === 0;
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* Whether this command has a handler
|
|
970
|
-
*/
|
|
971
|
-
get hasHandler() {
|
|
972
|
-
return this._handler !== void 0;
|
|
962
|
+
const i = new vt(n, t, r), s = this._commands.find((p) => {
|
|
963
|
+
const d = p.segments.map(
|
|
964
|
+
(f) => f.type === "argument" ? "*" : f.name
|
|
965
|
+
).join(" "), u = n.map(
|
|
966
|
+
(f) => f.type === "argument" ? "*" : f.name
|
|
967
|
+
).join(" ");
|
|
968
|
+
return d === u;
|
|
969
|
+
});
|
|
970
|
+
if (s)
|
|
971
|
+
throw new Error(`Duplicate commands: '${s.fullPath_s}' and '${i.fullPath_s}'`);
|
|
972
|
+
this._commands.push(i);
|
|
973
973
|
}
|
|
974
974
|
/**
|
|
975
|
-
*
|
|
975
|
+
* Retrieves a command from the registry for the given path.
|
|
976
|
+
*
|
|
977
|
+
* @param path The path of the command.
|
|
978
|
+
* @returns The command node or undefined if not found.
|
|
976
979
|
*/
|
|
977
|
-
|
|
978
|
-
return this.
|
|
980
|
+
getCommand(n) {
|
|
981
|
+
return this._commands.find((t) => {
|
|
982
|
+
const r = t.fullPath.join(" "), i = n.join(" ");
|
|
983
|
+
return r === i;
|
|
984
|
+
});
|
|
979
985
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
986
|
+
commandExistsForPath(n) {
|
|
987
|
+
const t = this._commands.map(
|
|
988
|
+
(i) => i.segments.map(
|
|
989
|
+
(s) => s.type === "argument" ? "*" : s.name
|
|
990
|
+
).join(" ")
|
|
991
|
+
), r = n.map((i, s) => this._commands.some(
|
|
992
|
+
(d) => {
|
|
993
|
+
var u;
|
|
994
|
+
return ((u = d.segments[s]) == null ? void 0 : u.type) === "argument";
|
|
995
|
+
}
|
|
996
|
+
) ? "*" : i).join(" ");
|
|
997
|
+
return t.includes(r);
|
|
985
998
|
}
|
|
986
999
|
/**
|
|
987
|
-
* Gets
|
|
1000
|
+
* Gets possible matches for a given path.
|
|
1001
|
+
*
|
|
1002
|
+
* @param path The path to get completions for.
|
|
1003
|
+
* @returns An array of completion strings.
|
|
988
1004
|
*/
|
|
989
|
-
|
|
990
|
-
|
|
1005
|
+
// used by AvailableCommands
|
|
1006
|
+
getCompletions_s(n) {
|
|
1007
|
+
return this.getCompletions(n).map((t) => t.name);
|
|
991
1008
|
}
|
|
992
1009
|
/**
|
|
993
|
-
*
|
|
994
|
-
*
|
|
1010
|
+
* Gets an array of segments reachable from a given path
|
|
1011
|
+
*
|
|
1012
|
+
* @param path The path to get completions for.
|
|
1013
|
+
* @returns An array of completion strings.
|
|
995
1014
|
*/
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1015
|
+
getCompletions(n) {
|
|
1016
|
+
if (N.debug("[getCompletions] path: ", n), !n.length) {
|
|
1017
|
+
const s = this._commands.map((u) => u.segments[0]), p = (u, f) => u.type === f.type && u.name === f.name;
|
|
1018
|
+
return s.filter(
|
|
1019
|
+
(u, f, w) => f === w.findIndex((g) => p(g, u))
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
const t = n.length;
|
|
1023
|
+
return this._commands.filter((s) => {
|
|
1024
|
+
const p = s.segments;
|
|
1025
|
+
if (p.length <= t - 1)
|
|
1026
|
+
return !1;
|
|
1027
|
+
for (let d = 0; d < t; d++) {
|
|
1028
|
+
const u = n[d], f = p[d];
|
|
1029
|
+
if (!(u === "*" && f.type === "argument") && u !== f.name)
|
|
1030
|
+
return !1;
|
|
1031
|
+
}
|
|
1032
|
+
return !0;
|
|
1033
|
+
}).filter((s) => s.segments.length > t).map((s) => {
|
|
1034
|
+
const p = s.segments[t], d = p.type === "argument" ? yt : wt;
|
|
1035
|
+
return new d(p.name, p.description);
|
|
1036
|
+
}).filter(
|
|
1037
|
+
(s, p, d) => p === d.findIndex(
|
|
1038
|
+
(u) => u.type === s.type && u.name === s.name
|
|
1039
|
+
)
|
|
1040
|
+
);
|
|
999
1041
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
*/
|
|
1003
|
-
get children() {
|
|
1004
|
-
return this._children;
|
|
1042
|
+
hasNextSegment(n) {
|
|
1043
|
+
return this.getCompletions(n).length > 0;
|
|
1005
1044
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1045
|
+
}
|
|
1046
|
+
class yn {
|
|
1047
|
+
constructor() {
|
|
1048
|
+
j(this, "segments", []);
|
|
1049
|
+
j(this, "nullSegment", new wn());
|
|
1050
|
+
j(this, "observers", []);
|
|
1011
1051
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
*/
|
|
1015
|
-
addChild(n, t) {
|
|
1016
|
-
this._children.set(n, t);
|
|
1052
|
+
subscribe(n) {
|
|
1053
|
+
this.observers.push(n);
|
|
1017
1054
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
*/
|
|
1021
|
-
getChild(n) {
|
|
1022
|
-
return this._children.get(n);
|
|
1055
|
+
unsubscribe(n) {
|
|
1056
|
+
this.observers = this.observers.filter((t) => t !== n);
|
|
1023
1057
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
*/
|
|
1027
|
-
get fullPath() {
|
|
1028
|
-
return this._fullPath;
|
|
1058
|
+
notifyObservers() {
|
|
1059
|
+
this.observers.forEach((n) => n.update());
|
|
1029
1060
|
}
|
|
1030
1061
|
/**
|
|
1031
|
-
*
|
|
1062
|
+
* Clears all segments from the stack
|
|
1032
1063
|
*/
|
|
1033
|
-
|
|
1034
|
-
|
|
1064
|
+
clear() {
|
|
1065
|
+
this.segments = [], this.notifyObservers();
|
|
1035
1066
|
}
|
|
1036
1067
|
/**
|
|
1037
|
-
*
|
|
1068
|
+
* Pushes a new segment onto the stack
|
|
1038
1069
|
*/
|
|
1039
|
-
|
|
1040
|
-
|
|
1070
|
+
push(n) {
|
|
1071
|
+
this.segments.push(n), this.notifyObservers();
|
|
1041
1072
|
}
|
|
1042
1073
|
/**
|
|
1043
|
-
*
|
|
1074
|
+
* Pushes an array of segments onto the stack
|
|
1044
1075
|
*/
|
|
1045
|
-
|
|
1046
|
-
|
|
1076
|
+
pushAll(n) {
|
|
1077
|
+
n.forEach((t) => this.push(t));
|
|
1047
1078
|
}
|
|
1048
1079
|
/**
|
|
1049
|
-
*
|
|
1080
|
+
* Removes and returns the top segment from the stack
|
|
1081
|
+
* Returns NullSegment if stack is empty
|
|
1050
1082
|
*/
|
|
1051
|
-
|
|
1052
|
-
|
|
1083
|
+
pop() {
|
|
1084
|
+
const n = this.segments.pop() || this.nullSegment;
|
|
1085
|
+
return this.notifyObservers(), n;
|
|
1053
1086
|
}
|
|
1054
1087
|
/**
|
|
1055
|
-
*
|
|
1088
|
+
* Returns the top segment without removing it
|
|
1089
|
+
* Returns NullSegment if stack is empty
|
|
1056
1090
|
*/
|
|
1057
|
-
|
|
1058
|
-
this.
|
|
1091
|
+
peek() {
|
|
1092
|
+
return this.segments[this.segments.length - 1] || this.nullSegment;
|
|
1059
1093
|
}
|
|
1060
|
-
}
|
|
1061
|
-
class ut {
|
|
1062
1094
|
/**
|
|
1063
|
-
*
|
|
1095
|
+
* Returns the number of segments in the stack
|
|
1064
1096
|
*/
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
this._root = new Ee({
|
|
1068
|
-
fullPath: ["ROOT"],
|
|
1069
|
-
description: "Root command node"
|
|
1070
|
-
});
|
|
1097
|
+
size() {
|
|
1098
|
+
return this.segments.length;
|
|
1071
1099
|
}
|
|
1072
1100
|
/**
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
* @param params Parameters for the command.
|
|
1076
|
-
* @param params.path The path segments for the command (e.g., ['service', 'deploy'])
|
|
1077
|
-
* @param params.description Description of what the command does
|
|
1078
|
-
* @param params.handler Optional function to execute when command is invoked
|
|
1079
|
-
* @param params.argument Optional argument definition for the command
|
|
1080
|
-
* @throws {Error} If attempting to add a duplicate leaf command or a subcommand to a leaf
|
|
1081
|
-
*
|
|
1101
|
+
* Returns true if the stack has no segments
|
|
1082
1102
|
*/
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
if (!(t != null && t.length))
|
|
1086
|
-
throw new Error("Command path cannot be empty");
|
|
1087
|
-
let l = this._root;
|
|
1088
|
-
const d = t.length - 1;
|
|
1089
|
-
for (let h = 0; h < t.length; h++) {
|
|
1090
|
-
const w = t[h], m = h === d, p = t.slice(0, h + 1), u = l.children;
|
|
1091
|
-
if (u.has(w)) {
|
|
1092
|
-
const y = u.get(w);
|
|
1093
|
-
if (m && y.isLeaf)
|
|
1094
|
-
throw new Error(`Duplicate command: ${t.join(" ")}`);
|
|
1095
|
-
if (!m && y.isLeaf)
|
|
1096
|
-
throw new Error(`Cannot add subcommand to leaf command: ${t.slice(0, h + 1).join(" ")}`);
|
|
1097
|
-
l = y;
|
|
1098
|
-
} else {
|
|
1099
|
-
const y = new Ee({
|
|
1100
|
-
description: m ? o : `${w} commands`,
|
|
1101
|
-
fullPath: p,
|
|
1102
|
-
parent: l,
|
|
1103
|
-
handler: m ? i : void 0,
|
|
1104
|
-
argument: m ? a : void 0
|
|
1105
|
-
});
|
|
1106
|
-
l.addChild(w, y), l = y, this.setSignatures();
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1103
|
+
isEmpty() {
|
|
1104
|
+
return this.segments.length === 0;
|
|
1109
1105
|
}
|
|
1110
1106
|
/**
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
* @param path The path of the command.
|
|
1114
|
-
* @returns The command node or undefined if not found.
|
|
1107
|
+
* Returns true if any segment in the stack is an argument
|
|
1115
1108
|
*/
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
for (const o of n) {
|
|
1119
|
-
const a = t.children.get(o);
|
|
1120
|
-
if (!a)
|
|
1121
|
-
return;
|
|
1122
|
-
t = a;
|
|
1123
|
-
}
|
|
1124
|
-
return t;
|
|
1109
|
+
get hasArguments() {
|
|
1110
|
+
return this.segments.some((n) => n.type === "argument");
|
|
1125
1111
|
}
|
|
1126
1112
|
/**
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
* @param path The path to get completions for.
|
|
1130
|
-
* @returns An array of completion strings.
|
|
1113
|
+
* Returns all argument segments in the stack
|
|
1131
1114
|
*/
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
if (!h)
|
|
1137
|
-
return [];
|
|
1138
|
-
t = h;
|
|
1139
|
-
}
|
|
1140
|
-
const o = n[n.length - 1] || "", i = [], a = t.children;
|
|
1141
|
-
if (n.length > 0) {
|
|
1142
|
-
const l = a.get(o);
|
|
1143
|
-
if (l)
|
|
1144
|
-
return l.children.forEach((d, h) => {
|
|
1145
|
-
i.push(h);
|
|
1146
|
-
}), i;
|
|
1147
|
-
}
|
|
1148
|
-
return a.forEach((l, d) => {
|
|
1149
|
-
d.startsWith(o) && i.push(d);
|
|
1150
|
-
}), i;
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* Executes a command with the given path and arguments.
|
|
1154
|
-
* @param path The command path
|
|
1155
|
-
* @param args Arguments to pass to the command handler
|
|
1156
|
-
* @returns The command result or undefined if command not found
|
|
1157
|
-
* @throws Error if command validation fails
|
|
1158
|
-
*/
|
|
1159
|
-
async executeCommand(n, t = []) {
|
|
1160
|
-
var a;
|
|
1161
|
-
const o = this.getCommand(n);
|
|
1162
|
-
if (!o)
|
|
1163
|
-
return;
|
|
1164
|
-
if (!o.hasHandler)
|
|
1165
|
-
throw new Error(`Command '${n.join(" ")}' is not executable`);
|
|
1166
|
-
if (o.requiresArgument && t.length === 0)
|
|
1167
|
-
throw new Error(`Command '${n.join(" ")}' requires argument: ${(a = o.argument) == null ? void 0 : a.name}`);
|
|
1168
|
-
const i = o.handler;
|
|
1169
|
-
if (!i)
|
|
1170
|
-
throw new Error(`Command '${n.join(" ")}' has no handler`);
|
|
1171
|
-
return await i(t);
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Gets the root commands in the trie.
|
|
1175
|
-
*
|
|
1176
|
-
* @returns An array of root command nodes.
|
|
1177
|
-
*/
|
|
1178
|
-
getRootCommands() {
|
|
1179
|
-
return Array.from(this._root.children.values());
|
|
1115
|
+
get arguments() {
|
|
1116
|
+
return this.segments.filter(
|
|
1117
|
+
(n) => n.type === "argument"
|
|
1118
|
+
);
|
|
1180
1119
|
}
|
|
1181
1120
|
/**
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
* @returns An array of leaf command nodes.
|
|
1121
|
+
* Returns the command path as an array of segment names
|
|
1185
1122
|
*/
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
o.isLeaf ? n.push(o) : o.children.forEach((i) => {
|
|
1189
|
-
t(i);
|
|
1190
|
-
});
|
|
1191
|
-
};
|
|
1192
|
-
return this._root.children.forEach((o) => {
|
|
1193
|
-
t(o);
|
|
1194
|
-
}), n;
|
|
1123
|
+
path() {
|
|
1124
|
+
return this.segments.map((n) => n.name);
|
|
1195
1125
|
}
|
|
1196
1126
|
/**
|
|
1197
|
-
*
|
|
1198
|
-
* A signature is the minimal sequence of prefixes that uniquely identifies a command.
|
|
1199
|
-
*
|
|
1200
|
-
* @param signature Array of minimal prefixes that uniquely identify the command
|
|
1201
|
-
* @returns The matching command node or undefined if not found
|
|
1202
|
-
*
|
|
1203
|
-
* @example
|
|
1204
|
-
* // Will match 'image random cat' command
|
|
1205
|
-
* getCommandBySignature(['i', 'r', 'c'])
|
|
1206
|
-
* // Will match 'user show' command (not ambiguous with 'user status')
|
|
1207
|
-
* getCommandBySignature(['u', 'sh'])
|
|
1127
|
+
* Returns a copy of the internal segments array
|
|
1208
1128
|
*/
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1129
|
+
toArray() {
|
|
1130
|
+
return [...this.segments];
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
const xt = {
|
|
1134
|
+
config: M,
|
|
1135
|
+
commands: new Ie(),
|
|
1136
|
+
segmentStack: new yn()
|
|
1137
|
+
}, le = et(xt), Ct = ({ config: o = M, commands: n, children: t }) => {
|
|
1138
|
+
const [r, i] = Z.useState(), s = {
|
|
1139
|
+
...M,
|
|
1140
|
+
...o,
|
|
1141
|
+
// Ensure nested objects are properly merged
|
|
1142
|
+
storage: {
|
|
1143
|
+
...M.storage,
|
|
1144
|
+
...o.storage
|
|
1145
|
+
},
|
|
1146
|
+
// Ensure explicit values from config take precedence
|
|
1147
|
+
cursorType: o.cursorType ?? M.cursorType,
|
|
1148
|
+
cursorColor: o.cursorColor ?? M.cursorColor,
|
|
1149
|
+
cursorSpeed: o.cursorSpeed ?? M.cursorSpeed,
|
|
1150
|
+
showCitadelKey: o.showCitadelKey || "."
|
|
1151
|
+
};
|
|
1152
|
+
I(() => {
|
|
1153
|
+
ye.getInstance().initializeStorage(
|
|
1154
|
+
s.storage ?? M.storage
|
|
1155
|
+
), i(ye.getInstance().getStorage());
|
|
1156
|
+
}, []), I(() => {
|
|
1157
|
+
if (n && s.includeHelpCommand && !n.commandExistsForPath(["help"])) {
|
|
1158
|
+
const d = gt(n);
|
|
1159
|
+
n.addCommand(
|
|
1160
|
+
[{ type: "word", name: "help" }],
|
|
1161
|
+
"Show available commands",
|
|
1162
|
+
d
|
|
1163
|
+
);
|
|
1226
1164
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1165
|
+
}, [n, s.includeHelpCommand]);
|
|
1166
|
+
const p = {
|
|
1167
|
+
config: s,
|
|
1168
|
+
commands: n || new Ie(),
|
|
1169
|
+
storage: r,
|
|
1170
|
+
segmentStack: new yn()
|
|
1171
|
+
};
|
|
1172
|
+
return /* @__PURE__ */ m.jsx(le.Provider, { value: p, children: t });
|
|
1173
|
+
}, ce = () => {
|
|
1174
|
+
const o = ve(le);
|
|
1175
|
+
if (o === void 0)
|
|
1176
|
+
throw new Error("useCitadelConfig must be used within a CitadelConfigProvider");
|
|
1177
|
+
return o.config;
|
|
1178
|
+
}, xe = () => {
|
|
1179
|
+
const o = ve(le);
|
|
1180
|
+
if (o === void 0)
|
|
1181
|
+
throw new Error("useCitadelCommands must be used within a CitadelConfigProvider");
|
|
1182
|
+
return o.commands;
|
|
1183
|
+
}, vn = () => {
|
|
1184
|
+
const o = ve(le);
|
|
1185
|
+
if (o === void 0)
|
|
1186
|
+
throw new Error("useCitadelStorage must be used within a CitadelConfigProvider");
|
|
1187
|
+
return o.storage;
|
|
1188
|
+
}, ue = () => {
|
|
1189
|
+
const o = ve(le);
|
|
1190
|
+
if (o === void 0)
|
|
1191
|
+
throw new Error("useSegmentStack must be used within a CitadelConfigProvider");
|
|
1192
|
+
return o.segmentStack;
|
|
1193
|
+
};
|
|
1194
|
+
class St {
|
|
1195
|
+
constructor(n, t) {
|
|
1196
|
+
j(this, "timestamp");
|
|
1197
|
+
j(this, "command");
|
|
1198
|
+
j(this, "result");
|
|
1199
|
+
this.command = n.toArray().map((r) => r.type === "argument" ? r.value || "" : r.name), this.timestamp = Date.now(), this.result = t ?? new ft();
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
const de = () => {
|
|
1203
|
+
const o = ue(), [n, t] = Y(0);
|
|
1204
|
+
return I(() => {
|
|
1205
|
+
const r = {
|
|
1206
|
+
update: () => {
|
|
1207
|
+
t((i) => i + 1);
|
|
1264
1208
|
}
|
|
1265
|
-
w || t.push(l), o = a;
|
|
1266
|
-
}
|
|
1267
|
-
return { signature: t };
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* Validates the command trie structure for common errors.
|
|
1271
|
-
*
|
|
1272
|
-
* Performs the following validations:
|
|
1273
|
-
* 1. Checks for duplicate command paths
|
|
1274
|
-
* 2. Ensures non-leaf nodes (nodes with children) use NoopHandler
|
|
1275
|
-
* 3. Ensures non-leaf nodes don't have arguments
|
|
1276
|
-
* 4. Verifies all nodes have a handler (either custom or NoopHandler)
|
|
1277
|
-
* 5. Validates command path uniqueness
|
|
1278
|
-
*
|
|
1279
|
-
* @returns An object containing:
|
|
1280
|
-
* - isValid: boolean indicating if the trie is valid
|
|
1281
|
-
* - errors: array of error messages describing any validation failures
|
|
1282
|
-
*
|
|
1283
|
-
* @example
|
|
1284
|
-
* ```typescript
|
|
1285
|
-
* const result = commandTrie.validate();
|
|
1286
|
-
* if (!result.isValid) {
|
|
1287
|
-
* console.error('Command trie validation failed:');
|
|
1288
|
-
* result.errors.forEach(error => console.error(error));
|
|
1289
|
-
* }
|
|
1290
|
-
* ```
|
|
1291
|
-
*/
|
|
1292
|
-
/**
|
|
1293
|
-
* Updates signatures for all nodes in the trie
|
|
1294
|
-
*/
|
|
1295
|
-
setSignatures() {
|
|
1296
|
-
const n = (t) => {
|
|
1297
|
-
t !== this._root && t.setSignature(this), t.children.forEach((o) => n(o));
|
|
1298
|
-
};
|
|
1299
|
-
n(this._root);
|
|
1300
|
-
}
|
|
1301
|
-
validate() {
|
|
1302
|
-
const n = [], t = /* @__PURE__ */ new Set(), o = (i) => {
|
|
1303
|
-
if (i === this._root)
|
|
1304
|
-
return;
|
|
1305
|
-
const a = i.fullPath.join(" ");
|
|
1306
|
-
t.has(a) && n.push(`Duplicate command path: ${a}`), t.add(a), i.handler || n.push(`Command missing handler: ${a}`);
|
|
1307
|
-
const l = i.children;
|
|
1308
|
-
l.size > 0 && (i.handler !== je && n.push(`Non-leaf command should use NoopHandler: ${a}`), i.argument && n.push(`Non-leaf command cannot have argument: ${a}`), l.forEach((d) => {
|
|
1309
|
-
o(d);
|
|
1310
|
-
}));
|
|
1311
1209
|
};
|
|
1312
|
-
return
|
|
1313
|
-
o(
|
|
1314
|
-
}), {
|
|
1315
|
-
isValid: n.length === 0,
|
|
1316
|
-
errors: n
|
|
1210
|
+
return o.subscribe(r), () => {
|
|
1211
|
+
o.unsubscribe(r);
|
|
1317
1212
|
};
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
const mt = (r, n) => {
|
|
1321
|
-
const t = async function(o) {
|
|
1322
|
-
const i = r.getLeafCommands().filter((a) => a.name !== "help").map((a) => {
|
|
1323
|
-
var d;
|
|
1324
|
-
return `${a.fullPath.join(" ") + (a.requiresArgument ? ` <${(d = a.argument) == null ? void 0 : d.name}>` : "")} - ${a.description}`;
|
|
1325
|
-
}).sort();
|
|
1326
|
-
return n.includeHelpCommand && i.push("help - Show available commands"), new un(
|
|
1327
|
-
i.length > 0 ? `Available Commands:
|
|
1328
|
-
` + i.join(`
|
|
1329
|
-
`) : "No commands available yet. Add some commands to get started!"
|
|
1330
|
-
);
|
|
1331
|
-
};
|
|
1332
|
-
return ["help", new Ee({
|
|
1333
|
-
fullPath: ["help"],
|
|
1334
|
-
description: "Show available commands",
|
|
1335
|
-
handler: t
|
|
1336
|
-
})];
|
|
1337
|
-
}, mn = () => {
|
|
1338
|
-
const r = G(), n = st();
|
|
1339
|
-
return ie(() => {
|
|
1340
|
-
const o = new ut();
|
|
1341
|
-
if (r.includeHelpCommand) {
|
|
1342
|
-
const [i, a] = mt(o, r);
|
|
1343
|
-
o.addCommand({
|
|
1344
|
-
path: [i],
|
|
1345
|
-
description: a.description,
|
|
1346
|
-
handler: a.handler,
|
|
1347
|
-
argument: a.argument
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
return n && Object.entries(n).forEach(([i, a]) => {
|
|
1351
|
-
o.addCommand({
|
|
1352
|
-
path: i.split("."),
|
|
1353
|
-
...a
|
|
1354
|
-
});
|
|
1355
|
-
}), o;
|
|
1356
|
-
}, [r.includeHelpCommand, n]);
|
|
1213
|
+
}, [o]), n;
|
|
1357
1214
|
};
|
|
1358
|
-
function
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1215
|
+
function _t(o) {
|
|
1216
|
+
return {
|
|
1217
|
+
commandSegments: o,
|
|
1218
|
+
timestamp: Date.now()
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function xn() {
|
|
1222
|
+
const o = vn(), [n, t] = Y({
|
|
1223
|
+
storedCommands: [],
|
|
1224
|
+
position: null
|
|
1225
|
+
}), r = A(async (d) => {
|
|
1226
|
+
if (o)
|
|
1367
1227
|
try {
|
|
1368
|
-
const
|
|
1369
|
-
t((
|
|
1370
|
-
...
|
|
1371
|
-
|
|
1228
|
+
const u = _t(d);
|
|
1229
|
+
await o.addStoredCommand(u), t((f) => ({
|
|
1230
|
+
...f,
|
|
1231
|
+
storedCommands: [...f.storedCommands, u],
|
|
1232
|
+
position: null
|
|
1372
1233
|
}));
|
|
1373
|
-
} catch (
|
|
1374
|
-
console.warn("Failed to
|
|
1234
|
+
} catch (u) {
|
|
1235
|
+
console.warn("Failed to save command to history:", u);
|
|
1375
1236
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1237
|
+
}, [o]), i = A(async () => o ? await o.getStoredCommands() : [], [o]);
|
|
1238
|
+
I(() => {
|
|
1239
|
+
if (!o) return;
|
|
1240
|
+
(async () => {
|
|
1380
1241
|
try {
|
|
1381
|
-
await
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
console.warn("Failed to save command to history:", m);
|
|
1242
|
+
const u = await o.getStoredCommands();
|
|
1243
|
+
return t((f) => ({
|
|
1244
|
+
...f,
|
|
1245
|
+
storedCommands: u
|
|
1246
|
+
})), u;
|
|
1247
|
+
} catch (u) {
|
|
1248
|
+
console.warn("Failed to load command history:", u);
|
|
1389
1249
|
}
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
};
|
|
1406
|
-
return t((y) => ({
|
|
1407
|
-
...y,
|
|
1408
|
-
savedInput: null
|
|
1409
|
-
})), { command: u, position: null };
|
|
1410
|
-
}
|
|
1411
|
-
return {
|
|
1412
|
-
command: p !== null ? n.commands[p] : null,
|
|
1413
|
-
position: p
|
|
1250
|
+
})();
|
|
1251
|
+
}, [o]);
|
|
1252
|
+
const s = A(async (d) => {
|
|
1253
|
+
if ((await i()).length === 0)
|
|
1254
|
+
return { segments: null, position: null };
|
|
1255
|
+
let f = null;
|
|
1256
|
+
return d === "up" ? n.position === null ? f = n.storedCommands.length - 1 : n.position > 0 ? f = n.position - 1 : f = 0 : n.position === null || n.position >= n.storedCommands.length - 1 ? f = null : f = n.position + 1, t((g) => ({
|
|
1257
|
+
...g,
|
|
1258
|
+
position: f
|
|
1259
|
+
})), f === null ? {
|
|
1260
|
+
segments: [],
|
|
1261
|
+
position: null
|
|
1262
|
+
} : {
|
|
1263
|
+
segments: f !== null ? n.storedCommands[f].commandSegments : null,
|
|
1264
|
+
position: f
|
|
1414
1265
|
};
|
|
1415
|
-
}, [n]),
|
|
1416
|
-
t((m) => ({
|
|
1417
|
-
...m,
|
|
1418
|
-
savedInput: w
|
|
1419
|
-
}));
|
|
1420
|
-
}, []), d = j(async () => {
|
|
1266
|
+
}, [n, de]), p = A(async () => {
|
|
1421
1267
|
try {
|
|
1422
|
-
if (!
|
|
1423
|
-
await
|
|
1424
|
-
|
|
1425
|
-
position: null
|
|
1426
|
-
savedInput: null
|
|
1268
|
+
if (!o) return;
|
|
1269
|
+
await o.clear(), t({
|
|
1270
|
+
storedCommands: [],
|
|
1271
|
+
position: null
|
|
1427
1272
|
});
|
|
1428
|
-
} catch (
|
|
1429
|
-
console.warn("Failed to clear command history:",
|
|
1430
|
-
}
|
|
1431
|
-
}, [r]);
|
|
1432
|
-
return [n, {
|
|
1433
|
-
addCommand: o,
|
|
1434
|
-
getCommands: i,
|
|
1435
|
-
navigateHistory: a,
|
|
1436
|
-
saveInput: l,
|
|
1437
|
-
clear: d
|
|
1438
|
-
}];
|
|
1439
|
-
}
|
|
1440
|
-
function fn({ commandTrie: r } = {}) {
|
|
1441
|
-
const [n, t] = Y("idle"), o = mn(), i = r || o, a = j((b, C) => b ? C.filter((f) => f.name.toLowerCase().startsWith(b.toLowerCase())) : C, []), l = j((b, C) => {
|
|
1442
|
-
const f = a(b, C);
|
|
1443
|
-
return f.length === 1 ? f[0].name : null;
|
|
1444
|
-
}, [a]), d = j((b) => b != null && b.hasChildren ? Array.from(b.children.values()) : i.getRootCommands(), [i]), h = j((b, C) => a(b, C).length > 0, [a]), w = j((b, C, f) => {
|
|
1445
|
-
i.getCommand(b) && (C.executeCommand(b, f || void 0), C.setCurrentInput(""), C.setIsEnteringArg(!1), t("idle"));
|
|
1446
|
-
}, [i]), m = j((b, C, f) => {
|
|
1447
|
-
if (f.setCurrentInput(b), !C.isEnteringArg) {
|
|
1448
|
-
const _ = d(C.currentNode), S = l(b, _);
|
|
1449
|
-
if (S && S !== b) {
|
|
1450
|
-
const I = [...C.commandStack, S], T = i.getCommand(I);
|
|
1451
|
-
T && (f.setCommandStack(I), f.setCurrentInput(""), f.setCurrentNode(T), !T.hasChildren && T.argument ? (f.setIsEnteringArg(!0), t("entering_argument")) : (f.setIsEnteringArg(!1), t("idle")));
|
|
1452
|
-
}
|
|
1273
|
+
} catch (d) {
|
|
1274
|
+
console.warn("Failed to clear command history:", d);
|
|
1453
1275
|
}
|
|
1454
|
-
}, [
|
|
1455
|
-
const { commandStack: _, currentInput: S, isEnteringArg: I, currentNode: T } = C;
|
|
1456
|
-
switch (b.key) {
|
|
1457
|
-
case "Tab":
|
|
1458
|
-
if (b.preventDefault(), !I && S) {
|
|
1459
|
-
const D = d(T), U = l(S, D);
|
|
1460
|
-
U && f.setCurrentInput(U);
|
|
1461
|
-
}
|
|
1462
|
-
return;
|
|
1463
|
-
case "Backspace":
|
|
1464
|
-
if (S === "" && (b.preventDefault(), _.length > 0)) {
|
|
1465
|
-
const D = _.slice(0, -1), U = D.length > 0 ? i.getCommand(D) : void 0;
|
|
1466
|
-
f.setCommandStack(D), f.setCurrentNode(U), f.setIsEnteringArg(!1), t("entering_command");
|
|
1467
|
-
}
|
|
1468
|
-
return;
|
|
1469
|
-
case "Enter":
|
|
1470
|
-
if (b.preventDefault(), I && (T != null && T.handler))
|
|
1471
|
-
S.trim() && w(_, f, [S.trim()]);
|
|
1472
|
-
else if (!I && S) {
|
|
1473
|
-
const D = d(T), U = a(S, D);
|
|
1474
|
-
if (U.length === 1) {
|
|
1475
|
-
const Z = U[0], Q = [..._, Z.name];
|
|
1476
|
-
Z.argument ? (f.setCommandStack(Q), f.setCurrentNode(Z), f.setCurrentInput(""), f.setIsEnteringArg(!0), t("entering_argument")) : w(Q, f, void 0);
|
|
1477
|
-
}
|
|
1478
|
-
} else T && !T.argument && w(_, f, void 0);
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
if (!I && !(T != null && T.argument)) {
|
|
1482
|
-
const D = d(T);
|
|
1483
|
-
if (!h(S + b.key, D)) {
|
|
1484
|
-
b.preventDefault();
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}, [
|
|
1489
|
-
d,
|
|
1490
|
-
l,
|
|
1491
|
-
a,
|
|
1492
|
-
w,
|
|
1493
|
-
i,
|
|
1494
|
-
h
|
|
1495
|
-
]), u = j(async (b, C, f) => {
|
|
1496
|
-
y(f);
|
|
1497
|
-
let _ = [], S;
|
|
1498
|
-
for (const I of b.inputs) {
|
|
1499
|
-
const T = {
|
|
1500
|
-
...C,
|
|
1501
|
-
commandStack: _,
|
|
1502
|
-
currentNode: S
|
|
1503
|
-
};
|
|
1504
|
-
if (S != null && S.argument)
|
|
1505
|
-
f.setIsEnteringArg(!0), f.setCurrentInput(I);
|
|
1506
|
-
else {
|
|
1507
|
-
const D = v(I, T);
|
|
1508
|
-
D && (_ = [..._, D], f.setCommandStack(_), S = i.getCommand(_), f.setCurrentNode(S));
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
}, [m]), y = j((b) => {
|
|
1512
|
-
b.setCurrentInput(""), b.setCommandStack([]), b.setCurrentNode(void 0), b.setIsEnteringArg(!1);
|
|
1513
|
-
}, []), v = (b, C) => {
|
|
1514
|
-
const f = d(C.currentNode);
|
|
1515
|
-
return l(b, f) || "";
|
|
1516
|
-
};
|
|
1276
|
+
}, [o]);
|
|
1517
1277
|
return {
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
// Expose internal functions for testing
|
|
1524
|
-
findMatchingCommands: a,
|
|
1525
|
-
getAutocompleteSuggestion: l,
|
|
1526
|
-
getAvailableNodes: d,
|
|
1527
|
-
isValidCommandInput: h
|
|
1278
|
+
history: n,
|
|
1279
|
+
addStoredCommand: r,
|
|
1280
|
+
getStoredCommands: i,
|
|
1281
|
+
navigateHistory: s,
|
|
1282
|
+
clear: p
|
|
1528
1283
|
};
|
|
1529
1284
|
}
|
|
1530
|
-
const
|
|
1531
|
-
const
|
|
1532
|
-
commandStack: [],
|
|
1285
|
+
const Cn = () => {
|
|
1286
|
+
const o = ce(), n = xe(), t = xn(), r = ue(), i = de(), s = vn(), [p, d] = Y({
|
|
1533
1287
|
currentInput: "",
|
|
1534
1288
|
isEnteringArg: !1,
|
|
1535
|
-
currentNode: void 0,
|
|
1536
1289
|
output: [],
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}, [d]), $(() => {
|
|
1542
|
-
l((u) => ({
|
|
1543
|
-
...u,
|
|
1544
|
-
history: t
|
|
1545
|
-
}));
|
|
1546
|
-
}, [t]);
|
|
1547
|
-
const h = j(async (u, y) => {
|
|
1548
|
-
const v = r.getCommand(u);
|
|
1549
|
-
if (!v || !v.isLeaf) return;
|
|
1550
|
-
const b = new dt([...u, ...y || []]);
|
|
1551
|
-
l((C) => ({
|
|
1552
|
-
...C,
|
|
1553
|
-
output: [...C.output, b]
|
|
1554
|
-
})), l((C) => ({
|
|
1555
|
-
...C,
|
|
1556
|
-
commandStack: [],
|
|
1557
|
-
currentInput: "",
|
|
1558
|
-
isEnteringArg: !1,
|
|
1559
|
-
currentNode: void 0,
|
|
1560
|
-
validation: { isValid: !0 }
|
|
1561
|
-
}));
|
|
1562
|
-
try {
|
|
1563
|
-
const C = new Promise((S, I) => {
|
|
1564
|
-
setTimeout(() => {
|
|
1565
|
-
I(new Error("Request timed out"));
|
|
1566
|
-
}, n.commandTimeoutMs);
|
|
1567
|
-
}), f = await Promise.race([
|
|
1568
|
-
v.handler(y || []),
|
|
1569
|
-
C
|
|
1570
|
-
]);
|
|
1571
|
-
if (!(f instanceof X))
|
|
1572
|
-
throw new Error(
|
|
1573
|
-
`The ${v.fullPath.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
1574
|
-
For example:
|
|
1575
|
-
return new JsonCommandResult({ text: "Hello World" });
|
|
1576
|
-
Check the definition of the ${v.fullPath.join(".")} command and update the return type.`
|
|
1577
|
-
);
|
|
1578
|
-
f.markSuccess();
|
|
1579
|
-
const _ = {
|
|
1580
|
-
inputs: [...v.fullPath, ...y || []],
|
|
1581
|
-
timestamp: Date.now()
|
|
1582
|
-
};
|
|
1583
|
-
try {
|
|
1584
|
-
await o.addCommand(_), l((S) => ({
|
|
1585
|
-
...S,
|
|
1586
|
-
output: S.output.map(
|
|
1587
|
-
(I) => I.timestamp === b.timestamp ? { ...I, result: f } : I
|
|
1588
|
-
)
|
|
1589
|
-
}));
|
|
1590
|
-
} catch (S) {
|
|
1591
|
-
console.warn("Failed to save command to history:", S), l((I) => ({
|
|
1592
|
-
...I,
|
|
1593
|
-
output: I.output.map(
|
|
1594
|
-
(T) => T.timestamp === b.timestamp ? { ...T, result: f } : T
|
|
1595
|
-
)
|
|
1596
|
-
}));
|
|
1597
|
-
}
|
|
1598
|
-
} catch (C) {
|
|
1599
|
-
const f = new lt(
|
|
1600
|
-
C instanceof Error ? C.message : "Unknown error"
|
|
1601
|
-
);
|
|
1602
|
-
f.markSuccess(), l((_) => ({
|
|
1603
|
-
..._,
|
|
1604
|
-
output: _.output.map(
|
|
1605
|
-
(S) => S.timestamp === b.timestamp ? { ...S, result: f } : S
|
|
1606
|
-
)
|
|
1607
|
-
}));
|
|
1608
|
-
}
|
|
1609
|
-
}, [r, n.commandTimeoutMs, o, a]), w = j((u) => {
|
|
1610
|
-
const { key: y } = u;
|
|
1611
|
-
switch (y) {
|
|
1612
|
-
case "ArrowUp":
|
|
1613
|
-
u.preventDefault();
|
|
1614
|
-
const { command: v } = o.navigateHistory("up", a.currentInput);
|
|
1615
|
-
v && i(v, a, m);
|
|
1616
|
-
break;
|
|
1617
|
-
case "ArrowDown":
|
|
1618
|
-
u.preventDefault();
|
|
1619
|
-
const { command: b } = o.navigateHistory("down", a.currentInput);
|
|
1620
|
-
b && i(b, a, m);
|
|
1621
|
-
break;
|
|
1622
|
-
case "Enter":
|
|
1623
|
-
if (u.preventDefault(), a.history.position !== null) {
|
|
1624
|
-
const C = a.history.commands[a.history.position];
|
|
1625
|
-
h([...C.inputs]), l((f) => ({
|
|
1626
|
-
...f,
|
|
1627
|
-
history: {
|
|
1628
|
-
...f.history,
|
|
1629
|
-
position: null,
|
|
1630
|
-
savedInput: null
|
|
1631
|
-
}
|
|
1632
|
-
}));
|
|
1633
|
-
}
|
|
1634
|
-
break;
|
|
1635
|
-
case "Escape":
|
|
1636
|
-
if (u.preventDefault(), a.history.position !== null) {
|
|
1637
|
-
const C = a.history.savedInput || "";
|
|
1638
|
-
l((f) => ({
|
|
1639
|
-
...f,
|
|
1640
|
-
currentInput: C,
|
|
1641
|
-
history: {
|
|
1642
|
-
...f.history,
|
|
1643
|
-
position: null,
|
|
1644
|
-
savedInput: null
|
|
1645
|
-
}
|
|
1646
|
-
}));
|
|
1647
|
-
}
|
|
1648
|
-
break;
|
|
1290
|
+
history: {
|
|
1291
|
+
commands: [],
|
|
1292
|
+
position: null,
|
|
1293
|
+
storage: s
|
|
1649
1294
|
}
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1295
|
+
});
|
|
1296
|
+
I(() => {
|
|
1297
|
+
}, [s]), I(() => {
|
|
1298
|
+
d((g) => ({
|
|
1299
|
+
...g,
|
|
1300
|
+
history: {
|
|
1301
|
+
commands: t.history.storedCommands,
|
|
1302
|
+
position: t.history.position,
|
|
1303
|
+
storage: s
|
|
1304
|
+
}
|
|
1305
|
+
}));
|
|
1306
|
+
}, [t.history, s]);
|
|
1307
|
+
const u = {
|
|
1308
|
+
setCurrentInput: A((g) => {
|
|
1309
|
+
N.debug("[CitadelActions] setCurrentInput: ", g), d((v) => ({ ...v, currentInput: g }));
|
|
1665
1310
|
}, []),
|
|
1666
|
-
|
|
1667
|
-
|
|
1311
|
+
setIsEnteringArg: A((g) => {
|
|
1312
|
+
N.debug("[CitadelActions] setIsEnteringArg: ", g), d((v) => ({ ...v, isEnteringArg: g }));
|
|
1668
1313
|
}, []),
|
|
1669
|
-
addOutput:
|
|
1670
|
-
|
|
1671
|
-
...
|
|
1672
|
-
output: [...
|
|
1314
|
+
addOutput: A((g) => {
|
|
1315
|
+
N.debug("[CitadelActions]addOutput: ", g), d((v) => ({
|
|
1316
|
+
...v,
|
|
1317
|
+
output: [...v.output, g]
|
|
1673
1318
|
}));
|
|
1674
1319
|
}, []),
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
}, []),
|
|
1678
|
-
executeCommand: h,
|
|
1679
|
-
executeHistoryCommand: j(async (u) => {
|
|
1680
|
-
const v = a.history.commands[u];
|
|
1320
|
+
executeCommand: A(async () => {
|
|
1321
|
+
const g = r.path(), v = n.getCommand(g);
|
|
1681
1322
|
if (!v) {
|
|
1682
|
-
console.
|
|
1323
|
+
console.error("[CitadelActions][executeCommand] Cannot execute command because no command was found for the given path: ", g);
|
|
1683
1324
|
return;
|
|
1684
1325
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1326
|
+
const O = new St(r);
|
|
1327
|
+
d((k) => ({
|
|
1328
|
+
...k,
|
|
1329
|
+
output: [...k.output, O]
|
|
1330
|
+
}));
|
|
1688
1331
|
try {
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1332
|
+
const k = new Promise((c, h) => {
|
|
1333
|
+
setTimeout(() => {
|
|
1334
|
+
h(new Error("Request timed out"));
|
|
1335
|
+
}, o.commandTimeoutMs);
|
|
1336
|
+
}), D = r.arguments.map((c) => c.value || ""), U = await Promise.race([
|
|
1337
|
+
v.handler(D),
|
|
1338
|
+
k
|
|
1339
|
+
]);
|
|
1340
|
+
if (!(U instanceof ee))
|
|
1341
|
+
throw new Error(
|
|
1342
|
+
`The ${g.join(".")} command returned an invalid result type. Commands must return an instance of a CommandResult.
|
|
1343
|
+
For example:
|
|
1344
|
+
return new JsonCommandResult({ text: "Hello World" });
|
|
1345
|
+
Check the definition of the ${g.join(".")} command and update the return type for its handler.`
|
|
1346
|
+
);
|
|
1347
|
+
U.markSuccess(), d((c) => ({
|
|
1348
|
+
...c,
|
|
1349
|
+
output: c.output.map(
|
|
1350
|
+
(h) => h.timestamp === O.timestamp ? { ...h, result: U } : h
|
|
1351
|
+
)
|
|
1352
|
+
}));
|
|
1353
|
+
} catch (k) {
|
|
1354
|
+
const D = new pt(
|
|
1355
|
+
k instanceof Error ? k.message : "Unknown error"
|
|
1356
|
+
);
|
|
1357
|
+
D.markFailure(), d((U) => ({
|
|
1358
|
+
...U,
|
|
1359
|
+
output: U.output.map(
|
|
1360
|
+
(c) => c.timestamp === O.timestamp ? { ...c, result: D } : c
|
|
1361
|
+
)
|
|
1362
|
+
}));
|
|
1692
1363
|
}
|
|
1693
|
-
}, [o])
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1364
|
+
}, [n, o.commandTimeoutMs, i]),
|
|
1365
|
+
clearHistory: A(async () => {
|
|
1366
|
+
try {
|
|
1367
|
+
await t.clear();
|
|
1368
|
+
} catch (g) {
|
|
1369
|
+
console.warn("Failed to clear history:", g);
|
|
1370
|
+
}
|
|
1371
|
+
}, [t])
|
|
1372
|
+
}, f = A(() => n.getCompletions_s(r.path()), [r, n]), w = A(() => n.getCompletions(r.path()), [r, n]);
|
|
1373
|
+
return {
|
|
1374
|
+
state: p,
|
|
1375
|
+
actions: u,
|
|
1376
|
+
getAvailableCommands_s: f,
|
|
1377
|
+
getAvailableCommandSegments: w
|
|
1378
|
+
};
|
|
1379
|
+
}, Et = {
|
|
1697
1380
|
blink: {
|
|
1698
1381
|
character: "▋",
|
|
1699
1382
|
speed: 530,
|
|
@@ -1714,160 +1397,336 @@ Check the definition of the ${v.fullPath.join(".")} command and update the retur
|
|
|
1714
1397
|
speed: 120,
|
|
1715
1398
|
color: "#fff"
|
|
1716
1399
|
}
|
|
1717
|
-
},
|
|
1718
|
-
style:
|
|
1400
|
+
}, cn = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"], un = ["|", "/", "-", "\\"], kt = ({
|
|
1401
|
+
style: o = { type: "blink" },
|
|
1719
1402
|
isValid: n = !0,
|
|
1720
1403
|
errorMessage: t
|
|
1721
1404
|
}) => {
|
|
1722
|
-
const
|
|
1723
|
-
...
|
|
1724
|
-
...
|
|
1725
|
-
}), [
|
|
1726
|
-
|
|
1727
|
-
if (
|
|
1728
|
-
const
|
|
1729
|
-
|
|
1730
|
-
},
|
|
1731
|
-
return () => clearInterval(
|
|
1732
|
-
}, [
|
|
1733
|
-
const
|
|
1734
|
-
color: n ?
|
|
1405
|
+
const r = be(() => ({
|
|
1406
|
+
...Et[o.type],
|
|
1407
|
+
...o
|
|
1408
|
+
}), [o]), [i, s] = Y(!0), [p, d] = Y(0);
|
|
1409
|
+
I(() => {
|
|
1410
|
+
if (r.speed === 0) return;
|
|
1411
|
+
const w = setInterval(() => {
|
|
1412
|
+
r.type === "blink" ? s((g) => !g) : ["spin", "bbs"].includes(r.type) && d((g) => (g + 1) % (r.type === "bbs" ? un.length : cn.length));
|
|
1413
|
+
}, r.speed);
|
|
1414
|
+
return () => clearInterval(w);
|
|
1415
|
+
}, [r.type, r.speed]);
|
|
1416
|
+
const u = be(() => ({
|
|
1417
|
+
color: n ? r.color : "#ff4444",
|
|
1735
1418
|
transition: "color 0.15s ease-in-out"
|
|
1736
|
-
}), [n,
|
|
1737
|
-
return /* @__PURE__ */
|
|
1419
|
+
}), [n, r.color]), f = () => !n && t ? "✗" : ["spin", "bbs"].includes(r.type) ? (r.type === "bbs" ? un : cn)[p] : r.type === "solid" || i ? r.character : " ";
|
|
1420
|
+
return /* @__PURE__ */ m.jsx("div", { className: "relative inline-block", children: /* @__PURE__ */ m.jsx(
|
|
1738
1421
|
"span",
|
|
1739
1422
|
{
|
|
1740
1423
|
className: `command-cursor ${n ? "" : "animate-shake"}`,
|
|
1741
|
-
style:
|
|
1424
|
+
style: u,
|
|
1742
1425
|
title: t,
|
|
1743
|
-
children:
|
|
1426
|
+
children: f()
|
|
1744
1427
|
}
|
|
1745
1428
|
) });
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
const o =
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1429
|
+
};
|
|
1430
|
+
function Rt(o, n) {
|
|
1431
|
+
switch (n.type) {
|
|
1432
|
+
case "set":
|
|
1433
|
+
return N.debug(`[inputStateReducer] InputState changing from ${o} to ${n.state}`), n.state;
|
|
1434
|
+
default:
|
|
1435
|
+
return o;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
const jt = () => {
|
|
1439
|
+
const { state: o } = Cn(), n = xe(), t = xn(), r = ue(), i = de(), [s, p] = nt(Rt, "idle"), d = (c) => {
|
|
1440
|
+
p({ type: "set", state: c });
|
|
1441
|
+
}, u = () => {
|
|
1442
|
+
const h = n.getCompletions(r.path())[0] || r.nullSegment;
|
|
1443
|
+
return N.debug("[getNextExpectedSegment] ", h), h;
|
|
1444
|
+
}, f = A(() => n.getCompletions_s(r.path()).map((h) => n.getCommand([...r.path(), h])).filter((h) => h !== void 0), [n]), w = A((c, h) => {
|
|
1445
|
+
if (!c) return h;
|
|
1446
|
+
const E = h.reduce((R, V) => {
|
|
1447
|
+
const z = u();
|
|
1448
|
+
return (z == null ? void 0 : z.type) === "word" && R.set(z.name, V), R;
|
|
1449
|
+
}, /* @__PURE__ */ new Map());
|
|
1450
|
+
return Array.from(E.values()).filter((R) => {
|
|
1451
|
+
const V = u();
|
|
1452
|
+
return V.type !== "word" ? !1 : V.name.toLowerCase().startsWith(c.toLowerCase());
|
|
1453
|
+
});
|
|
1454
|
+
}, []), g = A((c) => {
|
|
1455
|
+
const E = n.getCompletions(r.path()).filter((x) => x.type === "word").filter(
|
|
1456
|
+
(x) => x.name.toLowerCase().startsWith(c.toLowerCase())
|
|
1457
|
+
);
|
|
1458
|
+
return E.length === 1 ? E[0] : r.nullSegment;
|
|
1459
|
+
}, [w]), v = A((c) => {
|
|
1460
|
+
const h = r.path(), E = n.getCompletions(h);
|
|
1461
|
+
return E.length === 0 && c ? !1 : E.some((x) => x.type === "argument") ? !0 : E.some(
|
|
1462
|
+
(x) => x.type === "word" && x.name.toLowerCase().startsWith(c.toLowerCase())
|
|
1463
|
+
);
|
|
1464
|
+
}, [n]), O = A((c) => {
|
|
1465
|
+
N.debug("[tryAutoComplete] input: ", c);
|
|
1466
|
+
const h = g(c);
|
|
1467
|
+
return !h || h.name === c ? new wn() : (N.debug("[tryAutoComplete] result: ", h), h);
|
|
1468
|
+
}, [f, g, r, n, u]), k = A((c, h) => {
|
|
1469
|
+
if (o.history.position === null) {
|
|
1470
|
+
if (h.setCurrentInput(c), N.debug("[useCommandParser][handleInputChange] newValue: ", c), s === "entering_argument") {
|
|
1471
|
+
const E = dn(c);
|
|
1472
|
+
if (E.isQuoted)
|
|
1473
|
+
if (E.isComplete) {
|
|
1474
|
+
const x = u();
|
|
1475
|
+
if (x.type === "argument") {
|
|
1476
|
+
const R = x;
|
|
1477
|
+
R.value = c.trim() || "", N.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", R), r.push(R), h.setCurrentInput(""), d("idle");
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
} else
|
|
1481
|
+
return;
|
|
1482
|
+
else if (E.isComplete) {
|
|
1483
|
+
const x = u();
|
|
1484
|
+
x.value = c.trim() || "", N.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", x), r.push(x), h.setCurrentInput(""), d("idle");
|
|
1485
|
+
return;
|
|
1486
|
+
} else
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
if (s == "entering_command") {
|
|
1490
|
+
const E = O(c);
|
|
1491
|
+
if (E.type === "word") {
|
|
1492
|
+
N.debug("[useCommandParser][handleInputChange][entering_command] pushing: ", E), r.push(E), h.setCurrentInput(""), d("idle");
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1762
1496
|
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1497
|
+
}, [O, i, o]), D = A(async (c, h, E) => {
|
|
1498
|
+
if (!(c.key === "Backspace" || c.key === "Enter" || c.key === "ArrowUp" || c.key === "ArrowDown" || c.key === "ArrowLeft" || c.key === "ArrowRight" || c.key === "Escape" || c.key === "Delete" || c.key === "Home" || c.key === "End" || c.key.length === 1))
|
|
1499
|
+
return;
|
|
1500
|
+
const { currentInput: R, isEnteringArg: V } = h, z = dn(R);
|
|
1501
|
+
switch (c.key) {
|
|
1502
|
+
case "Backspace": {
|
|
1503
|
+
R === "" && (c.preventDefault(), r.size() > 0 && r.pop(), d("idle"));
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
case "Enter": {
|
|
1507
|
+
if (c.preventDefault(), z.isQuoted && !z.isComplete)
|
|
1508
|
+
return;
|
|
1509
|
+
if (s === "entering_argument") {
|
|
1510
|
+
const K = u();
|
|
1511
|
+
K.value = R, N.debug("[handleKeyDown][Enter]['entering_argument'] pushing: ", K), r.push(K);
|
|
1512
|
+
}
|
|
1513
|
+
N.debug("[handleKeyDown][Enter] calling actions.executeCommand. segmentStack: ", r), E.executeCommand(), t.addStoredCommand(r.toArray()), U(E);
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
case "ArrowUp": {
|
|
1517
|
+
c.preventDefault();
|
|
1518
|
+
const H = await t.navigateHistory("up", r.toArray());
|
|
1519
|
+
H.segments && (r.clear(), r.pushAll(H.segments), E.setCurrentInput(""));
|
|
1769
1520
|
return;
|
|
1770
1521
|
}
|
|
1522
|
+
case "ArrowDown": {
|
|
1523
|
+
c.preventDefault();
|
|
1524
|
+
const H = await t.navigateHistory("down", r.toArray());
|
|
1525
|
+
H.segments && (r.clear(), r.pushAll(H.segments), E.setCurrentInput(""));
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
default:
|
|
1529
|
+
if (!V && c.key.length === 1) {
|
|
1530
|
+
const H = R + c.key;
|
|
1531
|
+
if (!v(H)) {
|
|
1532
|
+
c.preventDefault();
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1771
1536
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1537
|
+
}, [
|
|
1538
|
+
n,
|
|
1539
|
+
w,
|
|
1540
|
+
f,
|
|
1541
|
+
g,
|
|
1542
|
+
s,
|
|
1543
|
+
v,
|
|
1544
|
+
i
|
|
1545
|
+
]), U = A((c) => {
|
|
1546
|
+
c.setCurrentInput(""), c.setIsEnteringArg(!1), r.clear(), d("idle");
|
|
1547
|
+
}, []);
|
|
1548
|
+
return {
|
|
1549
|
+
handleInputChange: k,
|
|
1550
|
+
handleKeyDown: D,
|
|
1551
|
+
inputState: s,
|
|
1552
|
+
setInputStateWithLogging: d,
|
|
1553
|
+
// Expose internal functions for testing
|
|
1554
|
+
findMatchingCommands: w,
|
|
1555
|
+
getAutocompleteSuggestion: g,
|
|
1556
|
+
getAvailableNodes: f,
|
|
1557
|
+
getNextExpectedSegment: u,
|
|
1558
|
+
isValidCommandInput: v
|
|
1779
1559
|
};
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1560
|
+
};
|
|
1561
|
+
function dn(o) {
|
|
1562
|
+
const n = [];
|
|
1563
|
+
let t = "", r = !1, i;
|
|
1564
|
+
for (let s = 0; s < o.length; s++) {
|
|
1565
|
+
const p = o[s];
|
|
1566
|
+
(p === '"' || p === "'") && (!r || p === i) ? r ? (n.push(t), t = "", r = !1, i = void 0) : (t && (n.push(t), t = ""), r = !0, i = p) : !r && p === " " ? t && (n.push(t), t = "") : t += p;
|
|
1567
|
+
}
|
|
1568
|
+
return {
|
|
1569
|
+
words: n,
|
|
1570
|
+
currentWord: t,
|
|
1571
|
+
isQuoted: r,
|
|
1572
|
+
quoteChar: i,
|
|
1573
|
+
isComplete: !r && !t
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
const At = "_invalidInput_e9b9w_12", Pt = "_shake_e9b9w_1", Tt = "_flashBorder_e9b9w_1", Ot = {
|
|
1577
|
+
invalidInput: At,
|
|
1578
|
+
shake: Pt,
|
|
1579
|
+
flashBorder: Tt
|
|
1580
|
+
}, Nt = ({
|
|
1581
|
+
state: o,
|
|
1582
|
+
actions: n
|
|
1583
|
+
}) => {
|
|
1584
|
+
const t = Q(null), r = xe(), i = ue(), {
|
|
1585
|
+
handleKeyDown: s,
|
|
1586
|
+
handleInputChange: p,
|
|
1587
|
+
inputState: d,
|
|
1588
|
+
setInputStateWithLogging: u,
|
|
1589
|
+
getNextExpectedSegment: f
|
|
1590
|
+
} = jt(), [w] = Y(!1), g = ce(), v = de(), O = (x) => {
|
|
1591
|
+
s(x, o, n);
|
|
1592
|
+
}, k = (x) => {
|
|
1593
|
+
p(x.target.value, n);
|
|
1594
|
+
}, D = (x) => {
|
|
1595
|
+
x.preventDefault();
|
|
1596
|
+
const R = x.clipboardData.getData("text");
|
|
1597
|
+
p(R, n);
|
|
1598
|
+
};
|
|
1599
|
+
I(() => {
|
|
1600
|
+
t.current && t.current.focus(), d !== "entering_command" && u("entering_command");
|
|
1601
|
+
}, []), I(() => {
|
|
1602
|
+
if (d !== "idle") return;
|
|
1603
|
+
const x = f();
|
|
1604
|
+
let R = "idle";
|
|
1605
|
+
switch (x.type) {
|
|
1606
|
+
case "word":
|
|
1607
|
+
R = "entering_command", n.setIsEnteringArg(!1);
|
|
1608
|
+
break;
|
|
1609
|
+
case "argument":
|
|
1610
|
+
R = "entering_argument", n.setIsEnteringArg(!0);
|
|
1611
|
+
break;
|
|
1612
|
+
}
|
|
1613
|
+
N.debug(`[CommandInput] changing inputState to '${R}'`), u(R);
|
|
1614
|
+
}, [v]);
|
|
1615
|
+
const [U, c] = Y([]);
|
|
1616
|
+
I(() => {
|
|
1617
|
+
const x = [], R = i.toArray().map((z, H) => {
|
|
1618
|
+
x.push(z.name);
|
|
1619
|
+
const K = r.hasNextSegment(x);
|
|
1620
|
+
if (z.type === "argument") {
|
|
1621
|
+
let ne = z;
|
|
1622
|
+
return /* @__PURE__ */ m.jsxs(Z.Fragment, { children: [
|
|
1623
|
+
/* @__PURE__ */ m.jsx("span", { className: "text-gray-200 whitespace-pre", children: ne.value }),
|
|
1624
|
+
H < i.size() && K && /* @__PURE__ */ m.jsx("span", { className: "text-gray-200 whitespace-pre", children: " " })
|
|
1625
|
+
] }, "arg-" + ne.name + ne.value);
|
|
1626
|
+
}
|
|
1627
|
+
return /* @__PURE__ */ m.jsxs(Z.Fragment, { children: [
|
|
1628
|
+
/* @__PURE__ */ m.jsx("span", { className: "text-blue-400 whitespace-pre", children: z.name }),
|
|
1629
|
+
H < i.size() && K && /* @__PURE__ */ m.jsx("span", { className: "text-blue-400 whitespace-pre", children: " " })
|
|
1630
|
+
] }, "word-" + z.name);
|
|
1631
|
+
});
|
|
1632
|
+
c([/* @__PURE__ */ m.jsx("div", { className: "flex items-center gap-1", "data-testid": "user-input-area", children: R }, "{segmentStackVersion}")]);
|
|
1633
|
+
}, [v]);
|
|
1634
|
+
const [h, E] = Y("");
|
|
1635
|
+
return I(() => {
|
|
1636
|
+
const x = f();
|
|
1637
|
+
x.type === "argument" ? E(x.name) : E("");
|
|
1638
|
+
}, [v]), /* @__PURE__ */ m.jsx("div", { className: "flex flex-col w-full bg-gray-900 rounded-lg p-4", children: /* @__PURE__ */ m.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1639
|
+
/* @__PURE__ */ m.jsx("div", { className: "text-gray-400 font-mono", children: ">" }),
|
|
1640
|
+
/* @__PURE__ */ m.jsxs("div", { className: "flex-1 font-mono flex items-center", children: [
|
|
1641
|
+
U,
|
|
1642
|
+
/* @__PURE__ */ m.jsxs("div", { className: "relative flex-1", children: [
|
|
1643
|
+
/* @__PURE__ */ m.jsx(
|
|
1644
|
+
"input",
|
|
1645
|
+
{
|
|
1646
|
+
ref: t,
|
|
1647
|
+
type: "text",
|
|
1648
|
+
role: "textbox",
|
|
1649
|
+
value: o.currentInput,
|
|
1650
|
+
onChange: k,
|
|
1651
|
+
onKeyDown: O,
|
|
1652
|
+
onPaste: D,
|
|
1653
|
+
"data-testid": "citadel-command-input",
|
|
1654
|
+
className: `w-full bg-transparent outline-none text-gray-200 caret-transparent ${w ? Ot.invalidInput : ""}`,
|
|
1655
|
+
spellCheck: !1,
|
|
1656
|
+
autoComplete: "off",
|
|
1657
|
+
placeholder: h
|
|
1658
|
+
}
|
|
1659
|
+
),
|
|
1660
|
+
/* @__PURE__ */ m.jsx(
|
|
1661
|
+
"div",
|
|
1662
|
+
{
|
|
1663
|
+
className: "absolute top-0 pointer-events-none",
|
|
1664
|
+
style: {
|
|
1665
|
+
left: `${o.currentInput.length}ch`,
|
|
1666
|
+
transition: "left 0.05s ease-out"
|
|
1667
|
+
},
|
|
1668
|
+
children: /* @__PURE__ */ m.jsx(
|
|
1669
|
+
kt,
|
|
1670
|
+
{
|
|
1671
|
+
style: {
|
|
1672
|
+
type: g.cursorType ?? M.cursorType,
|
|
1673
|
+
color: g.cursorColor || M.cursorColor,
|
|
1674
|
+
speed: g.cursorSpeed || M.cursorSpeed
|
|
1828
1675
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1676
|
+
}
|
|
1677
|
+
)
|
|
1678
|
+
}
|
|
1679
|
+
)
|
|
1833
1680
|
] })
|
|
1834
|
-
] })
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
}, Ct = () => /* @__PURE__ */ g.jsx(
|
|
1681
|
+
] })
|
|
1682
|
+
] }) });
|
|
1683
|
+
}, It = () => /* @__PURE__ */ m.jsx(
|
|
1838
1684
|
"div",
|
|
1839
1685
|
{
|
|
1840
1686
|
"data-testid": "spinner",
|
|
1841
1687
|
className: "animate-spin rounded-full h-4 w-4 border-2 border-gray-300 border-t-gray-600"
|
|
1842
1688
|
}
|
|
1843
|
-
),
|
|
1844
|
-
command:
|
|
1689
|
+
), Dt = ({
|
|
1690
|
+
command: o,
|
|
1845
1691
|
timestamp: n,
|
|
1846
1692
|
status: t
|
|
1847
|
-
}) => /* @__PURE__ */
|
|
1848
|
-
/* @__PURE__ */
|
|
1693
|
+
}) => /* @__PURE__ */ m.jsxs("div", { className: "flex items-center gap-2 font-mono text-sm", children: [
|
|
1694
|
+
/* @__PURE__ */ m.jsxs("span", { className: "text-gray-200", children: [
|
|
1849
1695
|
"> ",
|
|
1850
|
-
r
|
|
1696
|
+
o.split(" ").map((r, i) => {
|
|
1697
|
+
const s = r.startsWith("<") && r.endsWith(">");
|
|
1698
|
+
return /* @__PURE__ */ m.jsxs(
|
|
1699
|
+
"span",
|
|
1700
|
+
{
|
|
1701
|
+
className: s ? "text-green-400" : "text-gray-200",
|
|
1702
|
+
children: [
|
|
1703
|
+
i > 0 ? " " : "",
|
|
1704
|
+
r
|
|
1705
|
+
]
|
|
1706
|
+
},
|
|
1707
|
+
i
|
|
1708
|
+
);
|
|
1709
|
+
})
|
|
1851
1710
|
] }),
|
|
1852
|
-
/* @__PURE__ */
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
t ===
|
|
1855
|
-
t ===
|
|
1711
|
+
/* @__PURE__ */ m.jsx("span", { className: "text-gray-400", children: "·" }),
|
|
1712
|
+
/* @__PURE__ */ m.jsx("span", { className: "text-gray-500", children: n }),
|
|
1713
|
+
t === ie.Pending && /* @__PURE__ */ m.jsx(It, {}),
|
|
1714
|
+
t === ie.Success && /* @__PURE__ */ m.jsx(
|
|
1856
1715
|
"div",
|
|
1857
1716
|
{
|
|
1858
1717
|
"data-testid": "success-indicator",
|
|
1859
1718
|
className: "w-4 h-4 rounded-full bg-green-500"
|
|
1860
1719
|
}
|
|
1861
1720
|
),
|
|
1862
|
-
(t ===
|
|
1721
|
+
(t === ie.Timeout || t === ie.Failure) && /* @__PURE__ */ m.jsx(
|
|
1863
1722
|
"div",
|
|
1864
1723
|
{
|
|
1865
|
-
"data-testid": "
|
|
1724
|
+
"data-testid": "success-indicator",
|
|
1866
1725
|
className: "w-4 h-4 rounded-full bg-red-500"
|
|
1867
1726
|
}
|
|
1868
1727
|
)
|
|
1869
|
-
] }),
|
|
1870
|
-
const t =
|
|
1728
|
+
] }), zt = ({ output: o, outputRef: n }) => {
|
|
1729
|
+
const t = ce(), r = A(() => {
|
|
1871
1730
|
if (n.current) {
|
|
1872
1731
|
const i = n.current;
|
|
1873
1732
|
requestAnimationFrame(() => {
|
|
@@ -1875,69 +1734,67 @@ Check the definition of the ${v.fullPath.join(".")} command and update the retur
|
|
|
1875
1734
|
});
|
|
1876
1735
|
}
|
|
1877
1736
|
}, [n]);
|
|
1878
|
-
return
|
|
1879
|
-
if (
|
|
1880
|
-
const i = n.current.getElementsByTagName("img"),
|
|
1881
|
-
if (
|
|
1882
|
-
return
|
|
1737
|
+
return I(() => {
|
|
1738
|
+
if (r(), n.current) {
|
|
1739
|
+
const i = n.current.getElementsByTagName("img"), s = i[i.length - 1];
|
|
1740
|
+
if (s && !s.complete)
|
|
1741
|
+
return s.addEventListener("load", r), () => s.removeEventListener("load", r);
|
|
1883
1742
|
}
|
|
1884
|
-
}, [
|
|
1743
|
+
}, [o, r]), /* @__PURE__ */ m.jsx(
|
|
1885
1744
|
"div",
|
|
1886
1745
|
{
|
|
1887
1746
|
ref: n,
|
|
1888
1747
|
className: "h-full overflow-y-auto border border-gray-700 rounded-lg p-3 text-left",
|
|
1889
|
-
children:
|
|
1890
|
-
/* @__PURE__ */
|
|
1891
|
-
|
|
1748
|
+
children: o.map((i, s) => /* @__PURE__ */ m.jsxs("div", { className: "mb-4 last:mb-0", children: [
|
|
1749
|
+
/* @__PURE__ */ m.jsx(
|
|
1750
|
+
Dt,
|
|
1892
1751
|
{
|
|
1893
1752
|
command: i.command.join(" "),
|
|
1894
1753
|
timestamp: new Date(i.timestamp).toLocaleTimeString(),
|
|
1895
1754
|
status: i.result.status
|
|
1896
1755
|
}
|
|
1897
1756
|
),
|
|
1898
|
-
/* @__PURE__ */
|
|
1899
|
-
] },
|
|
1757
|
+
/* @__PURE__ */ m.jsx("pre", { className: `text-gray-200 whitespace-pre font-mono ${t.outputFontSize}`, children: i.result.render() })
|
|
1758
|
+
] }, s))
|
|
1900
1759
|
}
|
|
1901
1760
|
);
|
|
1902
|
-
},
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
/* @__PURE__ */ g.jsx("span", { className: "text-blue-400", children: r.currentNode.name }),
|
|
1916
|
-
/* @__PURE__ */ g.jsxs("span", { className: "text-gray-400 ml-2", children: [
|
|
1761
|
+
}, Ft = () => {
|
|
1762
|
+
const o = xe(), n = ce(), t = ue(), r = de(), i = "h-12 mt-2 border-t border-gray-700 px-4", s = "text-gray-300 pt-2", p = o.getCompletions(t.path());
|
|
1763
|
+
N.debug("[AvailableCommands] nextCommandSegments: ", p);
|
|
1764
|
+
const d = Z.useMemo(() => {
|
|
1765
|
+
if (n.includeHelpCommand) {
|
|
1766
|
+
const w = p.filter((v) => v.name !== "help"), g = p.find((v) => v.name === "help");
|
|
1767
|
+
return [...w, ...g ? [g] : []];
|
|
1768
|
+
}
|
|
1769
|
+
return p;
|
|
1770
|
+
}, [p, r, n.includeHelpCommand]), u = p.some((w) => w.type === "argument"), f = p[0];
|
|
1771
|
+
return /* @__PURE__ */ m.jsx("div", { className: i, "data-testid": "available-commands", children: /* @__PURE__ */ m.jsx("div", { className: s, children: u ? p.length > 0 ? /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
|
|
1772
|
+
/* @__PURE__ */ m.jsx("span", { className: "text-blue-400", children: f.name }),
|
|
1773
|
+
f.description && /* @__PURE__ */ m.jsxs("span", { className: "text-gray-400 ml-2", children: [
|
|
1917
1774
|
"- ",
|
|
1918
|
-
|
|
1775
|
+
f.description
|
|
1919
1776
|
] })
|
|
1920
|
-
] }) : null
|
|
1921
|
-
const
|
|
1922
|
-
if (
|
|
1923
|
-
let
|
|
1924
|
-
for (;
|
|
1925
|
-
|
|
1926
|
-
return Math.max(
|
|
1777
|
+
] }) : null : /* @__PURE__ */ m.jsx("div", { className: "flex flex-wrap gap-2", children: d == null ? void 0 : d.map((w) => {
|
|
1778
|
+
const g = d == null ? void 0 : d.reduce((v, O) => {
|
|
1779
|
+
if (O === w) return v;
|
|
1780
|
+
let k = 0;
|
|
1781
|
+
for (; k < w.name.length && k < O.name.length && w.name[k].toLowerCase() === O.name[k].toLowerCase(); )
|
|
1782
|
+
k++;
|
|
1783
|
+
return Math.max(v, k + 1);
|
|
1927
1784
|
}, 1);
|
|
1928
|
-
return /* @__PURE__ */
|
|
1785
|
+
return /* @__PURE__ */ m.jsx(
|
|
1929
1786
|
"div",
|
|
1930
1787
|
{
|
|
1931
1788
|
className: "px-2 py-1 rounded bg-gray-800 mr-2 last:mr-0",
|
|
1932
|
-
children: /* @__PURE__ */
|
|
1933
|
-
/* @__PURE__ */
|
|
1934
|
-
|
|
1789
|
+
children: /* @__PURE__ */ m.jsxs("span", { className: "font-mono text-white", children: [
|
|
1790
|
+
/* @__PURE__ */ m.jsx("strong", { className: "underline", children: w.name.slice(0, g) }),
|
|
1791
|
+
w.name.slice(g)
|
|
1935
1792
|
] })
|
|
1936
1793
|
},
|
|
1937
|
-
|
|
1794
|
+
w.name
|
|
1938
1795
|
);
|
|
1939
|
-
}) }) })
|
|
1940
|
-
},
|
|
1796
|
+
}) }) }) });
|
|
1797
|
+
}, mn = `:host {
|
|
1941
1798
|
--citadel-bg: rgb(17, 24, 39);
|
|
1942
1799
|
--citadel-text: rgba(255, 255, 255, 0.87);
|
|
1943
1800
|
--citadel-border: rgb(55, 65, 81);
|
|
@@ -1945,7 +1802,7 @@ Check the definition of the ${v.fullPath.join(".")} command and update the retur
|
|
|
1945
1802
|
--citadel-accent-hover: #535bf2;
|
|
1946
1803
|
--citadel-min-height: 200px;
|
|
1947
1804
|
--citadel-max-height: 80vh;
|
|
1948
|
-
--citadel-default-height:
|
|
1805
|
+
--citadel-default-height: 35vh;
|
|
1949
1806
|
--citadel-error: rgb(239, 68, 68);
|
|
1950
1807
|
|
|
1951
1808
|
height: var(--citadel-default-height);
|
|
@@ -2026,7 +1883,7 @@ a:hover {
|
|
|
2026
1883
|
text-align: left;
|
|
2027
1884
|
}
|
|
2028
1885
|
|
|
2029
|
-
`,
|
|
1886
|
+
`, pn = `/* Keep only component-specific styles here */
|
|
2030
1887
|
|
|
2031
1888
|
.container {
|
|
2032
1889
|
position: fixed;
|
|
@@ -2096,10 +1953,10 @@ a:hover {
|
|
|
2096
1953
|
.citadel_slideDown {
|
|
2097
1954
|
animation: citadel_slideDown 0.2s ease-out forwards;
|
|
2098
1955
|
}
|
|
2099
|
-
`,
|
|
1956
|
+
`, fn = `@tailwind base;
|
|
2100
1957
|
@tailwind components;
|
|
2101
1958
|
@tailwind utilities;
|
|
2102
|
-
`,
|
|
1959
|
+
`, Ut = `*, ::before, ::after {
|
|
2103
1960
|
--tw-border-spacing-x: 0;
|
|
2104
1961
|
--tw-border-spacing-y: 0;
|
|
2105
1962
|
--tw-translate-x: 0;
|
|
@@ -2916,41 +2773,45 @@ video {
|
|
|
2916
2773
|
.last\\:mr-0:last-child {
|
|
2917
2774
|
margin-right: 0px;
|
|
2918
2775
|
}
|
|
2919
|
-
`,
|
|
2920
|
-
config:
|
|
2921
|
-
|
|
2776
|
+
`, Vt = ({
|
|
2777
|
+
config: o = M,
|
|
2778
|
+
commandRegistry: n = new Ie(),
|
|
2922
2779
|
containerId: t = null
|
|
2923
|
-
}) => (
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2780
|
+
}) => (I(() => {
|
|
2781
|
+
N.configure({
|
|
2782
|
+
level: o.logLevel || M.logLevel || we.ERROR,
|
|
2783
|
+
prefix: "[Citadel]"
|
|
2784
|
+
});
|
|
2785
|
+
const r = new Sn(n, o), i = t ? document.getElementById(t) : document.body;
|
|
2786
|
+
return i ? i.appendChild(r) : (console.warn(`Container with id "${t}" not found, falling back to body`), document.body.appendChild(r)), () => {
|
|
2787
|
+
var s;
|
|
2788
|
+
(s = r.parentElement) == null || s.removeChild(r);
|
|
2928
2789
|
};
|
|
2929
2790
|
}, [n, t]), null);
|
|
2930
|
-
class
|
|
2931
|
-
constructor(t,
|
|
2791
|
+
class Sn extends HTMLElement {
|
|
2792
|
+
constructor(t, r) {
|
|
2932
2793
|
super();
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
this.shadow = this.attachShadow({ mode: "open" }), this.commands = t, this.config =
|
|
2794
|
+
j(this, "shadow");
|
|
2795
|
+
j(this, "root", null);
|
|
2796
|
+
j(this, "commands");
|
|
2797
|
+
j(this, "config");
|
|
2798
|
+
this.shadow = this.attachShadow({ mode: "open" }), this.commands = t, this.config = r;
|
|
2938
2799
|
}
|
|
2939
2800
|
connectedCallback() {
|
|
2940
2801
|
try {
|
|
2941
|
-
const
|
|
2942
|
-
const
|
|
2943
|
-
return
|
|
2802
|
+
const r = [mn, pn, fn, Ut].map((i) => {
|
|
2803
|
+
const s = new CSSStyleSheet();
|
|
2804
|
+
return s.replaceSync(i), s;
|
|
2944
2805
|
});
|
|
2945
|
-
this.shadow.adoptedStyleSheets = [...
|
|
2806
|
+
this.shadow.adoptedStyleSheets = [...r];
|
|
2946
2807
|
} catch {
|
|
2947
|
-
const i = [
|
|
2948
|
-
`),
|
|
2949
|
-
|
|
2808
|
+
const i = [mn, pn, fn].join(`
|
|
2809
|
+
`), s = document.createElement("style");
|
|
2810
|
+
s.textContent = i, this.shadow.appendChild(s);
|
|
2950
2811
|
}
|
|
2951
2812
|
const t = document.createElement("div");
|
|
2952
|
-
t.id = "citadel-root", this.shadow.appendChild(t), this.root =
|
|
2953
|
-
/* @__PURE__ */
|
|
2813
|
+
t.id = "citadel-root", this.shadow.appendChild(t), this.root = Oe(t), this.root.render(
|
|
2814
|
+
/* @__PURE__ */ m.jsx(Ct, { config: this.config || M, commands: this.commands, children: /* @__PURE__ */ m.jsx($t, {}) })
|
|
2954
2815
|
);
|
|
2955
2816
|
}
|
|
2956
2817
|
// disconnectedCallback() {
|
|
@@ -2960,65 +2821,44 @@ class hn extends HTMLElement {
|
|
|
2960
2821
|
// }
|
|
2961
2822
|
// }
|
|
2962
2823
|
}
|
|
2963
|
-
customElements.define("citadel-element",
|
|
2964
|
-
const
|
|
2965
|
-
const [
|
|
2966
|
-
|
|
2967
|
-
}, []),
|
|
2968
|
-
|
|
2969
|
-
if (!h.current) return;
|
|
2970
|
-
const I = S.clientY - w.current, T = (U = p.maxHeight) != null && U.endsWith("vh") ? window.innerHeight * parseInt(p.maxHeight, 10) / 100 : parseInt(p.maxHeight || "80vh", 10), D = Math.min(
|
|
2971
|
-
Math.max(m.current - I, parseInt(p.minHeight || "200", 10)),
|
|
2972
|
-
T
|
|
2973
|
-
);
|
|
2974
|
-
d.current && (d.current.style.height = `${D}px`, d.current.style.bottom = "0", a(D));
|
|
2975
|
-
}, [p.maxHeight]), f = j(() => {
|
|
2976
|
-
h.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", f);
|
|
2824
|
+
customElements.define("citadel-element", Sn);
|
|
2825
|
+
const $t = () => {
|
|
2826
|
+
const [o, n] = Y(!1), [t, r] = Y(!1), i = ce(), [s, p] = Y(() => i.initialHeight || null), d = Q(null), u = Q(null), f = Q(!1), w = Q(0), g = Q(0), { state: v, actions: O } = Cn(), k = A((c) => {
|
|
2827
|
+
u.current && (f.current = !0, w.current = c.clientY, g.current = u.current.offsetHeight, document.documentElement.style.userSelect = "none", document.documentElement.style.webkitUserSelect = "none", document.documentElement.style.mozUserSelect = "none", document.documentElement.style.msUserSelect = "none", document.addEventListener("mouseup", D));
|
|
2828
|
+
}, []), D = A(() => {
|
|
2829
|
+
f.current = !1, document.documentElement.style.userSelect = "", document.documentElement.style.webkitUserSelect = "", document.documentElement.style.mozUserSelect = "", document.documentElement.style.msUserSelect = "", document.removeEventListener("mouseup", D);
|
|
2977
2830
|
}, []);
|
|
2978
|
-
|
|
2979
|
-
document.removeEventListener("
|
|
2980
|
-
}, [
|
|
2831
|
+
I(() => () => {
|
|
2832
|
+
document.removeEventListener("mouseup", D);
|
|
2833
|
+
}, [D]), at({
|
|
2981
2834
|
onOpen: () => n(!0),
|
|
2982
|
-
onClose: () =>
|
|
2983
|
-
isVisible:
|
|
2984
|
-
showCitadelKey:
|
|
2835
|
+
onClose: () => r(!0),
|
|
2836
|
+
isVisible: o,
|
|
2837
|
+
showCitadelKey: i.showCitadelKey || "."
|
|
2985
2838
|
});
|
|
2986
|
-
const
|
|
2987
|
-
t && (n(!1),
|
|
2839
|
+
const U = A(() => {
|
|
2840
|
+
t && (n(!1), r(!1));
|
|
2988
2841
|
}, [t]);
|
|
2989
|
-
return
|
|
2990
|
-
isVisible:
|
|
2842
|
+
return mt({
|
|
2843
|
+
isVisible: o,
|
|
2991
2844
|
isClosing: t,
|
|
2992
|
-
onAnimationComplete:
|
|
2993
|
-
}),
|
|
2845
|
+
onAnimationComplete: U
|
|
2846
|
+
}), o ? /* @__PURE__ */ m.jsxs(
|
|
2994
2847
|
"div",
|
|
2995
2848
|
{
|
|
2996
|
-
ref:
|
|
2997
|
-
className: `container ${
|
|
2849
|
+
ref: u,
|
|
2850
|
+
className: `container ${o ? "citadel_slideUp" : ""} ${t ? "citadel_slideDown" : ""}`,
|
|
2998
2851
|
style: {
|
|
2999
|
-
...
|
|
3000
|
-
maxHeight:
|
|
2852
|
+
...s ? { height: s } : void 0,
|
|
2853
|
+
maxHeight: i.maxHeight
|
|
3001
2854
|
},
|
|
3002
2855
|
children: [
|
|
3003
|
-
/* @__PURE__ */
|
|
3004
|
-
/* @__PURE__ */
|
|
3005
|
-
/* @__PURE__ */
|
|
3006
|
-
/* @__PURE__ */
|
|
3007
|
-
/* @__PURE__ */
|
|
3008
|
-
|
|
3009
|
-
{
|
|
3010
|
-
state: u,
|
|
3011
|
-
actions: y,
|
|
3012
|
-
availableCommands: v()
|
|
3013
|
-
}
|
|
3014
|
-
),
|
|
3015
|
-
/* @__PURE__ */ g.jsx(
|
|
3016
|
-
kt,
|
|
3017
|
-
{
|
|
3018
|
-
state: u,
|
|
3019
|
-
availableCommands: v()
|
|
3020
|
-
}
|
|
3021
|
-
)
|
|
2856
|
+
/* @__PURE__ */ m.jsx("div", { className: "resizeHandle", onMouseDown: k }),
|
|
2857
|
+
/* @__PURE__ */ m.jsxs("div", { className: "innerContainer", children: [
|
|
2858
|
+
/* @__PURE__ */ m.jsx("div", { className: "flex-1 min-h-0 pt-3 px-4", children: /* @__PURE__ */ m.jsx(zt, { output: v.output, outputRef: d }) }),
|
|
2859
|
+
/* @__PURE__ */ m.jsxs("div", { children: [
|
|
2860
|
+
/* @__PURE__ */ m.jsx(Nt, { state: v, actions: O }),
|
|
2861
|
+
/* @__PURE__ */ m.jsx(Ft, {})
|
|
3022
2862
|
] })
|
|
3023
2863
|
] })
|
|
3024
2864
|
]
|
|
@@ -3026,14 +2866,14 @@ const Rt = () => {
|
|
|
3026
2866
|
) : null;
|
|
3027
2867
|
};
|
|
3028
2868
|
export {
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
2869
|
+
Vt as Citadel,
|
|
2870
|
+
ee as CommandResult,
|
|
2871
|
+
ie as CommandStatus,
|
|
2872
|
+
Et as DEFAULT_CURSOR_CONFIGS,
|
|
2873
|
+
pt as ErrorCommandResult,
|
|
2874
|
+
Lt as ImageCommandResult,
|
|
2875
|
+
Yt as JsonCommandResult,
|
|
2876
|
+
St as OutputItem,
|
|
2877
|
+
ft as PendingCommandResult,
|
|
2878
|
+
gn as TextCommandResult
|
|
3039
2879
|
};
|